Jelajahi Sumber

Merge branch 'dev' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into dev

liubing 3 tahun lalu
induk
melakukan
b0e34d06ad

+ 178 - 0
business/base-service/src/main/java/com/yihu/jw/healthUpload/service/BaseDoctorHealthUploadService.java

@ -10,6 +10,7 @@ import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.healthUpload.BaseDoctorHealthUploadDO;
import com.yihu.jw.entity.healthUpload.BaseDoctorMemberDO;
import com.yihu.jw.entity.hospital.DmHospitalDO;
import com.yihu.jw.entity.hospital.dict.BaseDeptDict;
import com.yihu.jw.healthUpload.dao.BaseDoctorHealthUploadDao;
import com.yihu.jw.healthUpload.dao.BaseDoctorMemberDao;
import com.yihu.jw.restmodel.web.MixEnvelop;
@ -226,6 +227,7 @@ public class BaseDoctorHealthUploadService extends BaseJpaService<BaseDoctorHeal
                baseDoctorHospitalDO.setDeptCode(deptCode);
                baseDoctorHospitalDO.setDeptName(deptName);
                baseDoctorHospitalDO.setDel("1");
                baseDoctorHospitalDO.setCreateTime(new Date());
                baseDoctorHospitalDao.save(baseDoctorHospitalDO);
            }else {
                BaseDoctorHospitalDO baseDoctorHospitalDO = new BaseDoctorHospitalDO();
@ -235,6 +237,7 @@ public class BaseDoctorHealthUploadService extends BaseJpaService<BaseDoctorHeal
                baseDoctorHospitalDO.setDeptCode(deptCode);
                baseDoctorHospitalDO.setDeptName(deptName);
                baseDoctorHospitalDO.setDel("1");
                baseDoctorHospitalDO.setCreateTime(new Date());
                baseDoctorHospitalDao.save(baseDoctorHospitalDO);
            }
        } else {
@ -280,6 +283,7 @@ public class BaseDoctorHealthUploadService extends BaseJpaService<BaseDoctorHeal
                baseDoctorHospitalDO.setDeptCode(deptCode);
                baseDoctorHospitalDO.setDeptName(deptName);
                baseDoctorHospitalDO.setDel("1");
                baseDoctorHospitalDO.setCreateTime(new Date());
                baseDoctorHospitalDao.save(baseDoctorHospitalDO);
            }else {
                BaseDoctorHospitalDO baseDoctorHospitalDO = new BaseDoctorHospitalDO();
@ -289,6 +293,7 @@ public class BaseDoctorHealthUploadService extends BaseJpaService<BaseDoctorHeal
                baseDoctorHospitalDO.setDeptCode(deptCode);
                baseDoctorHospitalDO.setDeptName(deptName);
                baseDoctorHospitalDO.setDel("1");
                baseDoctorHospitalDO.setCreateTime(new Date());
                baseDoctorHospitalDao.save(baseDoctorHospitalDO);
            }
@ -550,6 +555,179 @@ public class BaseDoctorHealthUploadService extends BaseJpaService<BaseDoctorHeal
        return object;
    }
    /**
     * 首页按照科室列表统计
     *
     * @param dept
     * @param idType
     * @param status 上报状态
     * @param state 健康状态
     * @param startDate
     * @param endDate
     * @return
     */
    public List<Map<String,Object>> selectHeaderList(String dept,String idType,String status,String state,String startDate,String endDate,String name){
        String deptSql = " select code,name from dict_hospital_dept hd where hd.consult_dept_flag=1 ";
        if (StringUtils.isNoneBlank(name)){
            deptSql += " and hd.code IN(SELECT dha.dept_code FROM base_doctor_hospital dha LEFT JOIN base_doctor da ON da.id=dha.doctor_code where da.name LIKE '%"+name+"%') ";
        }
        if (StringUtils.isNoneBlank(dept)){
            deptSql +=" and hd.code = '"+dept+"' ";
        }
        List<Map<String,Object>> mapList = jdbcTemplate.queryForList(deptSql);
        for (Map<String,Object> deptmap:mapList){
            String deptCode = deptmap.get("code").toString();
            JSONObject object =new JSONObject();
            String day = DateUtil.getTwoDay(endDate,startDate);
            String doctorSql =" select COUNT(1) as \"total\" from base_doctor d where d.del=1 ";
            Integer total = 0;//总人次
            String sql = "select COUNT(DISTINCT d.doctor_id) as \"total\" from base_doctor_health_upload d where 1=1 ";
            String deptCondition = "";
            if (StringUtils.isNoneBlank(deptCode)){
                deptCondition +=" (select dh.doctor_code from base_doctor_hospital dh where dh.dept_code = '"+deptCode+"' and dh.del=1 )";
            }
            String idTypeCondition = " ";
            if (StringUtils.isNoneBlank(idType)){
                idTypeCondition +="  (select d1.id from base_doctor d1 where 1=1 and d1.id_type = '"+idType+"')";
            }
            if (StringUtils.isNoneBlank(deptCondition)){
                doctorSql+=" and d.id IN "+deptCondition;
            }
            if (StringUtils.isNoneBlank(idTypeCondition)){
                doctorSql+=" and d.id IN "+idTypeCondition ;
            }
            if (StringUtils.isNoneBlank(name)){
                doctorSql+=" and d.name like '%"+name+"%' " ;
            }
            Map<String,Object> map = jdbcTemplate.queryForMap(doctorSql);
            String doctorTotal = "";
            if (map!=null){
                doctorTotal = map.get("total").toString();
            }
            if (StringUtils.isNoneBlank(doctorTotal)){
                //总人次
                if (!day.equalsIgnoreCase("0")){
                    total = Integer.parseInt(doctorTotal)*Integer.parseInt(day);
                }else {
                    total= Integer.parseInt(doctorTotal);
                }
            }
            Integer yishangbaoTotal = 0;
            Integer weishangbaoTotal =0;
            Integer zhengchangTotal = 0;
            Integer yichangTotal = 0;
            if (StringUtils.isNoneBlank(startDate)){
                sql +=" and d.create_time >='"+startDate+" 00:00:00' and d.create_time<='"+endDate+" 23:59:59' ";
            }
            if (StringUtils.isNoneBlank(state)){
                if (state.equalsIgnoreCase("1")){
                    sql +=" and (d.health_code not in(2,3) and CAST(d.temperature as DECIMAL)<37.3 and  d.is_symptoms=2 and d.is_epidemic=2) ";
                }else if (state.equalsIgnoreCase("2")){
                    sql +=" and (d.health_code in(2,3) OR CAST(d.temperature as DECIMAL)>=37.3 OR  d.is_symptoms=1 OR d.is_epidemic=1) ";
                }
            }
            if (StringUtils.isNoneBlank(deptCondition)){
                sql+=" and d.doctor_id IN "+deptCondition;
            }
            if (StringUtils.isNoneBlank(idTypeCondition)){
                sql+=" and d.doctor_id IN "+idTypeCondition ;
            }
            if (StringUtils.isNoneBlank(name)){
                sql+=" and d.doctor_name like '%"+name+"%'" ;
            }
            //已上传
            Map<String,Object> yishangchaungMap = jdbcTemplate.queryForMap(sql);
            if (yishangchaungMap!=null){
                if (yishangchaungMap.get("total")!=null){
                    yishangbaoTotal = Integer.parseInt(yishangchaungMap.get("total").toString());
                }
            }
            //未上报
            weishangbaoTotal=total-yishangbaoTotal;
            //上传总次数
            Integer shangchuanTotal= 0;
            String shangchuanTotalSql = "select COUNT(1) as \"total\" from base_doctor_health_upload d where 1=1  ";
            if (StringUtils.isNoneBlank(startDate)){
                shangchuanTotalSql +=" and d.create_time >='"+startDate+" 00:00:00' and d.create_time<='"+endDate+" 23:59:59' ";
            }
            if (StringUtils.isNoneBlank(deptCondition)){
                shangchuanTotalSql +=" and d.doctor_id IN "+deptCondition;
            }
            if (StringUtils.isNoneBlank(idTypeCondition)){
                shangchuanTotalSql +=" and d.doctor_id IN "+idTypeCondition ;
            }
            if (StringUtils.isNoneBlank(name)){
                shangchuanTotalSql+=" and d.doctor_name like '%"+name+"%'" ;
            }
            Map<String,Object> shangchuanMap = jdbcTemplate.queryForMap(shangchuanTotalSql);
            if (shangchuanMap!=null){
                if (shangchuanMap.get("total")!=null){
                    shangchuanTotal = Integer.parseInt(shangchuanMap.get("total").toString());
                }
            }
            //正常、异常
            String sqlZhengchang = "select COUNT(1) as \"total\" from base_doctor_health_upload d where 1=1 and (d.health_code not in(2,3) AND CAST(d.temperature as DECIMAL)<37.3 AND  d.is_symptoms=2 and  d.is_epidemic=2) ";
            if (StringUtils.isNoneBlank(startDate)){
                sqlZhengchang +=" and d.create_time >='"+startDate+" 00:00:00' and d.create_time<='"+endDate+" 23:59:59' ";
            }
            if (StringUtils.isNoneBlank(deptCondition)){
                sqlZhengchang +=" and d.doctor_id IN "+deptCondition;
            }
            if (StringUtils.isNoneBlank(idTypeCondition)){
                sqlZhengchang +=" and d.doctor_id IN "+idTypeCondition ;
            }
            if (StringUtils.isNoneBlank(name)){
                sqlZhengchang+=" and d.doctor_name like '%"+name+"%'" ;
            }
            //正常
            Map<String,Object> zhengchangMap = jdbcTemplate.queryForMap(sqlZhengchang);
            if (zhengchangMap!=null){
                if (zhengchangMap.get("total")!=null){
                    zhengchangTotal = Integer.parseInt(zhengchangMap.get("total").toString());
                }
            }
            String sqlYichang = "select COUNT(1) as \"total\" from base_doctor_health_upload d where 1=1 and (d.health_code in(2,3) OR CAST(d.temperature as DECIMAL)>=37.3 OR  d.is_symptoms=1 OR d.is_epidemic=1)  ";
            if (StringUtils.isNoneBlank(startDate)){
                sqlYichang +=" and d.create_time >='"+startDate+" 00:00:00' and d.create_time<='"+endDate+" 23:59:59' ";
            }
            if (StringUtils.isNoneBlank(deptCondition)){
                sqlYichang +=" and d.doctor_id IN "+deptCondition;
            }
            if (StringUtils.isNoneBlank(idTypeCondition)){
                sqlYichang +=" and d.doctor_id IN "+idTypeCondition ;
            }
            if (StringUtils.isNoneBlank(name)){
                sqlYichang+=" and d.doctor_name like '%"+name+"%'" ;
            }
            //正常
            Map<String,Object> yichangMap = jdbcTemplate.queryForMap(sqlYichang);
            if (yichangMap!=null){
                if (yichangMap.get("total")!=null){
                    yichangTotal = Integer.parseInt(yichangMap.get("total").toString());
                }
            }
            object.put("total",total);//总人次
            object.put("yishangbaoTotal",yishangbaoTotal);//已上报
            object.put("weishangbaoTotal",weishangbaoTotal);//未上报
            object.put("zhengchangTotal",zhengchangTotal);//上报正常
            object.put("yichangTotal",yichangTotal);//上报异常
            object.put("shangchuanTotal",shangchuanTotal);//上传总次数
            deptmap.put("tongyishuju",object);
        }
        return mapList;
    }
    /**
     * 具体每一个统计时间列表
     *

+ 3 - 3
common/common-entity/src/main/java/com/yihu/jw/entity/IntegerIdentityEntity.java

@ -19,13 +19,13 @@ public abstract class IntegerIdentityEntity implements Serializable {
    @Id
//==========mysql 环境 id策略======================================================
 /*   @GeneratedValue(generator = "generator")
    @GeneratedValue(generator = "generator")
    @GenericGenerator(name = "generator", strategy = "identity")
    @Column(name = "id", unique = true, nullable = false)*/
    @Column(name = "id", unique = true, nullable = false)
//==========mysql 环境 id策略 end======================================================
//==========Oracle 环境id策略 =========================================================
   @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="id_generated")
/*   @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="id_generated")*/
//==========Oracle 环境id策略 =========================================================
    public Integer getId() {
        return id;

+ 2 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/message/BaseServiceNewsService.java

@ -340,7 +340,7 @@ public class BaseServiceNewsService {
        String content = "";
        switch (type){
            case "1":
                content = "发起上门辅导";
                content = "发起幼儿照护";
                break;
            case "2":
                content = "发起咨询";
@ -352,7 +352,7 @@ public class BaseServiceNewsService {
                content = "为"+patientName+"代预约";
                break;
            case "5":
                content = "发起了紧急救护";
                content = "发起了紧急呼叫";
                break;
            case "6":
                content = "发起了安防监护";

+ 16 - 3
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/statistics/StatisticsService.java

@ -1894,8 +1894,18 @@ public class StatisticsService {
            res.put("statusList", statusArray);
        } else {//老人
            //老人
            //能力评估 从签约时服务标签取
            res.put("levelList", cloudCareForTheElderly(endDate, area, level));
            //能力评估 从签约时服务标签取  + 照护老人
            JSONArray jsonArray = cloudCareForTheElderly(endDate, area, level);
            JSONObject oldTotalJson = new JSONObject();
            String oldTotalSql ="SELECT ((SELECT COUNT(*) FROM base_patient p  WHERE p.sign_status = 1 AND p.del = 1 ) +(SELECT COUNT(p.id) FROM base_patient p INNER JOIN " +
                    " wlyy_patient_device d ON p.id = d.`user` WHERE p.sign_status = 0 AND p.del = 1  AND d.del = 0)) total";
            List<Integer> oldTotalList = jdbcTemplate.queryForList(oldTotalSql, Integer.class);
            oldTotalJson.put("num", oldTotalList.get(0));
            oldTotalJson.put("code", 12);
            oldTotalJson.put("name", "老人数");
            jsonArray.add(oldTotalJson);
            res.put("levelList", jsonArray);
            //居民健康标签
            List<SaveModel> list = elasticsearchUtil.findDateAllQuotaLevel1(endDate, endDate, area, level, "47", SaveModel.timeLevel_DDL, null, null, areaLevel);
@ -1980,6 +1990,8 @@ public class StatisticsService {
            json.put("name", saveModel.getSlaveKey1Name());
            sexArray.add(json);
        }
        res.put("sexList", sexArray);
        return res;
    }
@ -2041,7 +2053,8 @@ public class StatisticsService {
    //老人整体概况
    public Map<String,Object> getOlderOverview(String currentUserRole,String  currentUserRoleLevel){
        String year = DateUtil.getNowYear()+"";
        String sql = " select * from base_older_num where type='"+currentUserRoleLevel+"' and code='"+currentUserRole+"' and year='"+year+"' ";
        String sql = " SELECT *,(SELECT ((SELECT COUNT(*) FROM base_patient p where  p.sign_status = 0 AND p.del = 1) - (SELECT COUNT(p.id) FROM base_patient p INNER JOIN wlyy_patient_device d ON p.id = d.`user` WHERE p.sign_status = 0 AND p.del = 1  AND d.del = 0)) total\n) total FROM base_older_num  where type='"+currentUserRoleLevel+"' and code='"+currentUserRole+"' and year='"+year+"' ";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        if (list.size()>0){
            return list.get(0);

+ 5 - 1
svr/svr-cloud-device/pom.xml

@ -150,7 +150,11 @@
            <version>2.0.0</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.eclipse.paho</groupId>
            <artifactId>org.eclipse.paho.client.mqttv3</artifactId>
            <version>1.2.5</version>
        </dependency>
    </dependencies>
    <build>

+ 24 - 0
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/common/PostConstructUtil.java

@ -0,0 +1,24 @@
package com.yihu.jw.care.common;
import com.yihu.jw.care.util.MQTTClientUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
/**
 * 项目启动就执行的类
 * Created by yeshijie on 2022/5/7.
 */
@Component
public class PostConstructUtil {
    @Autowired
    private MQTTClientUtil mqttClientUtil;
    @PostConstruct
    public void init(){
        //启动电表的mqtt订阅
        mqttClientUtil.start();
    }
}

+ 110 - 0
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/util/MQTTClientUtil.java

@ -0,0 +1,110 @@
package com.yihu.jw.care.util;
import org.eclipse.paho.client.mqttv3.*;
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.util.concurrent.ScheduledExecutorService;
/**
 * Created by yeshijie on 2022/5/5.
 */
@Component
public class MQTTClientUtil {
    private static Logger logger = LoggerFactory.getLogger(MQTTClientUtil.class);
    public static final String HOST = "tcp://47.99.215.81:8885";
    public static final String TOPIC1 = "00752217643114/get/request/online";
//    public static final String TOPIC = "00752217643114/get/request/params";
    public static final String TOPIC = "00752217643114/#";//订阅所有
    private static final String clientid = String.valueOf(System.currentTimeMillis());;
    private MqttClient client;
    private MqttConnectOptions options;
    private String userName = "admin";
    private String passWord = "password";
    private ScheduledExecutorService scheduler;
    public void start() {
        logger.info("启动监听mqtt-start");
        try {
            // host为主机名,clientid即连接MQTT的客户端ID,一般以唯一标识符表示,MemoryPersistence设置clientid的保存形式,默认为以内存保存
            client = new MqttClient(HOST, clientid, new MemoryPersistence());
            // MQTT的连接设置
            options = new MqttConnectOptions();
            // 设置是否清空session,这里如果设置为false表示服务器会保留客户端的连接记录,这里设置为true表示每次连接到服务器都以新的身份连接
            options.setCleanSession(true);
            // 设置连接的用户名
            options.setUserName(userName);
            // 设置连接的密码
            options.setPassword(passWord.toCharArray());
            // 设置超时时间 单位为秒
            options.setConnectionTimeout(10);
            options.setAutomaticReconnect(true);//设置自动重连
            // 设置会话心跳时间 单位为秒 服务器会每隔1.5*20秒的时间向客户端发送个消息判断客户端是否在线,但这个方法并没有重连的机制
            options.setKeepAliveInterval(20);
            // 设置回调
            client.setCallback(new MqttCallback(){
                @Override
                public void connectionLost(Throwable throwable) {
                    // 连接丢失后,一般在这里面进行重连
                    throwable.printStackTrace();
                    logger.info("连接断开,可以做重连");
                }
                @Override
                public void messageArrived(String s, MqttMessage message) throws Exception {
                    // subscribe后得到的消息会执行到这里面
                    logger.info("接收消息主题 : " + TOPIC);
                    logger.info("接收消息Qos : " + message.getQos());
                    logger.info("接收消息内容 : " + new String(message.getPayload()));
                }
                @Override
                public void deliveryComplete(IMqttDeliveryToken token) {
                    logger.info("deliveryComplete---------" + token.isComplete());
                }
            });
//            MqttTopic topic = client.getTopic(TOPIC);
            //setWill方法,如果项目中需要知道客户端是否掉线可以调用该方法。设置最终端口的通知消息
//            options.setWill(topic, "close".getBytes(), 2, true);
            client.connect(options);
            //订阅消息
            int[] Qos  = {1};
            String[] topic1 = {TOPIC};
            client.subscribe(topic1, Qos);
/*            // 创建消息
            String payload = "{\n" +
                    "  \"token\": 0,\n" +
                    "  \"dev_type\": \"gw\", \n" +
                    "  \"msg_type\": \"online\", \n" +
                    "  \"content\" :[{\n" +
                    "    \"action\": \"getlist\"\n" +
                    "  }]\n" +
                    "}\n";
            MqttMessage message = new MqttMessage(payload.getBytes());
            // 设置消息的服务质量
            message.setQos(0);
            // 发布消息
            client.publish(TOPIC1, message);*/
        } catch (Exception e) {
            e.printStackTrace();
        }
        logger.info("启动监听mqtt-end");
    }
//    public static void main(String[] args) throws MqttException {
//        MQTTClientUtil client = new MQTTClientUtil();
//        client.start();
//        logger.info("启动监听mqtt");
//    }
}

+ 24 - 1
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/healthUpload/HealthUploadPoint.java

@ -206,7 +206,7 @@ public class HealthUploadPoint extends EnvelopRestEndpoint {
    @GetMapping(value = "selectHeaderTotal")
    @ApiOperation(value = "首页统计")
    public ObjEnvelop selectHeaderTotal(@ApiParam(name = "dept", value = "科室code")
                                                       @RequestParam(value = "dept", required = true) String dept,
                                                       @RequestParam(value = "dept", required = false) String dept,
                                                       @ApiParam(name = "idType", value = "身份类别")
                                                       @RequestParam(value = "idType", required = false) String idType,
                                                       @ApiParam(name = "status", value = "上报状态")
@ -227,6 +227,29 @@ public class HealthUploadPoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = "selectHeaderList")
    @ApiOperation(value = "首页按照科室统计")
    public ListEnvelop selectHeaderList(@ApiParam(name = "dept", value = "科室code")
                                        @RequestParam(value = "dept", required = false) String dept,
                                        @ApiParam(name = "idType", value = "身份类别")
                                        @RequestParam(value = "idType", required = false) String idType,
                                        @ApiParam(name = "status", value = "上报状态")
                                        @RequestParam(value = "status", required = false) String status,
                                        @ApiParam(name = "state", value = "健康状态")
                                        @RequestParam(value = "state", required = false) String state,
                                        @ApiParam(name = "startDate", value = "开始时间")
                                        @RequestParam(value = "startDate", required = false) String startDate,
                                        @ApiParam(name = "endDate", value = "结束时间")
                                        @RequestParam(value = "endDate", required = false) String endDate,
                                        @ApiParam(name = "name", value = "姓名")
                                        @RequestParam(value = "name", required = false) String name) {
        try {
            return success(baseDoctorHealthUploadService.selectHeaderList(dept,idType,status,state,startDate,endDate,name));
        } catch (Exception e) {
            return failedListEnvelopException(e);
        }
    }
    @GetMapping(value = "selectListByTotal")
    @ApiOperation(value = "获取列表的时间及数量")
    public ListEnvelop selectListByTotal(@ApiParam(name = "dept", value = "科室code")