ソースを参照

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

liubing 3 年 前
コミット
353b3cc7ef
23 ファイル変更631 行追加98 行削除
  1. 1 0
      business/es-service/src/main/java/com/yihu/jw/es/util/ElasticsearchUtil.java
  2. 24 0
      business/push-service/src/main/java/com/yihu/jw/push/dao/GetuiClientDao.java
  3. 13 3
      business/push-service/src/main/java/com/yihu/jw/push/service/GetuiService.java
  4. 5 3
      business/push-service/src/main/java/com/yihu/jw/push/util/GetuiUtil.java
  5. 9 1
      common/common-entity/sql记录
  6. 4 0
      common/common-rest-model/pom.xml
  7. 5 1
      server/svr-authentication/src/main/java/com/yihu/jw/security/core/userdetails/jdbc/WlyyUserDetailsService.java
  8. 3 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/dao/patient/BaseGetuiClientDao.java
  9. 28 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/consult/PatientConsultEndpoint.java
  10. 12 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/message/DoctorMessageEndpoint.java
  11. 97 48
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/statistics/OpenStatisticsEndpoint.java
  12. 13 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/activity/ChildActivityRegistrationService.java
  13. 2 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/assistance/EmergencyAssistanceService.java
  14. 5 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/consult/ConsultService.java
  15. 1 15
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/PatientDeviceService.java
  16. 3 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/security/SecurityMonitoringOrderService.java
  17. 291 14
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/statistics/StatisticsService.java
  18. 37 6
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/MessageUtil.java
  19. 5 1
      svr/svr-cloud-job/pom.xml
  20. 5 0
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/service/BirthdayReminderService.java
  21. 37 0
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/util/MessageUtil.java
  22. 16 0
      svr/svr-iot/src/main/java/com/yihu/iot/controller/monitorPlatform/MonitorPlatformController.java
  23. 15 5
      svr/svr-iot/src/main/java/com/yihu/iot/service/monitorPlatform/MonitorPlatformService.java

+ 1 - 0
business/es-service/src/main/java/com/yihu/jw/es/util/ElasticsearchUtil.java

@ -348,6 +348,7 @@ public class ElasticsearchUtil {
                    areaLevel = areaLevels.get(0);
                }
            }
        }

+ 24 - 0
business/push-service/src/main/java/com/yihu/jw/push/dao/GetuiClientDao.java

@ -0,0 +1,24 @@
package com.yihu.jw.push.dao;
import com.yihu.jw.entity.care.common.GetuiClientDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/12/27
 * @Description:
 */
public interface GetuiClientDao extends PagingAndSortingRepository<GetuiClientDO, String>, JpaSpecificationExecutor<GetuiClientDO> {
    @Query("from GetuiClientDO p where p.user = ?1 and p.type=?2 and p.clientId=?3 and p.clientType=?4")
    List<GetuiClientDO> findByUser(String user, Integer type,String clientId,String clientType);
    @Query("from GetuiClientDO p where p.user = ?1 and p.type=?2")
    List<GetuiClientDO> findByUser(String user, Integer type);
}

+ 13 - 3
business/push-service/src/main/java/com/yihu/jw/push/service/GetuiService.java

@ -57,8 +57,8 @@ public class GetuiService {
//    public static String AppKey = "JC2LAW9IK27pansBB4jN87";
//    public static String AppSecret = "Sn9PLz1hA6NNgyb7WHx45";
//    public static String MasterSecret = "Rd86CP8bOy7RHyTf4ZE3R4";
    public static String cloudCareDoctor = "com.zjxl.medicalcare.doctor";
    public static String cloudCarePatientPad = "com.zjxl.medicalcare.patient.pad";
    public String cloudCareDoctor = "com.zjxl.medicalcare.doctor";
    public String cloudCarePatientPad = "com.zjxl.medicalcare.patient.pad";
    private String key = "hz_yxyzh_push_getui";
@ -71,11 +71,20 @@ public class GetuiService {
            AppKey = redisTemplate.opsForValue().get(key + ":AppKey");
            AppSecret = redisTemplate.opsForValue().get(key + ":AppSecret");
            MasterSecret = redisTemplate.opsForValue().get(key + ":MasterSecret");
            synchronized (GetuiService.class){
                if(pushApi == null){
                    pushApi = getPushApi();
                }
            }
            return;
        }
        forceInit();
    }
    /**
     * 如果修改了数据库参数,调用下这个方法
     */
    public void forceInit(){
        List<WlyyHospitalSysDictDO> dictDOList = sysDictDao.findByDictName(key);
        for (WlyyHospitalSysDictDO wlyyHospitalSysDictDO:dictDOList){
@ -146,7 +155,7 @@ public class GetuiService {
                    "component="+json.getString("platform")+"/io.dcloud.PandoraEntry;S.UP-OL-SU=true;" +
                    "S.title="+json.getString("title")+";" +
                    "S.content="+json.getString("body")+";" +
                    "S.payload="+json.getString("payload")+";end";
                    "S.url="+json.getString("url")+";end";
            notification1.setIntent(intent);
            ups.setNotification(notification1);
@ -171,6 +180,7 @@ public class GetuiService {
            IosDTO iosDTO = new IosDTO();
            iosDTO.setAps(aps);
            iosDTO.setType("notify");
            iosDTO.setPayload(json.getString("payload"));
            pushChannel.setIos(iosDTO);
        }

+ 5 - 3
business/push-service/src/main/java/com/yihu/jw/push/util/GetuiUtil.java

@ -107,7 +107,8 @@ public class GetuiUtil {
//        } else {
//            System.out.println("个推推送失败:code:" + apiResult.getCode() + ", msg: " + apiResult.getMsg());
//        }
        String cid = "d2fee750dcdf7a2567444b1d4f629305";
//        String cid = "d2fee750dcdf7a2567444b1d4f629305";
        String cid = "a7fff64dd3dfd12ee43a1b94f3266cfa";
        String title = "ios11:49标题";
        String body = "安卓离线展示的内容";
        String url = "https://www.baidu.com/";
@ -124,8 +125,8 @@ public class GetuiUtil {
//        json.put("clickType","url");
        json.put("platform",cloudCareDoctor);
        json.put("payload",payload.toString());
        push2(cid,2,json);
        String str = "{\"payload\":\"{\\\"title\\\":\\\"安防紧急预警\\\",\\\"body\\\":\\\"您好,张民居民发起紧急呼叫,请关注并及时处理。\\\",\\\"url\\\":\\\"/sos/index?tabActive=1\\\"}\",\"title\":\"安防紧急预警\",\"body\":\"您好,张民居民发起紧急呼叫,请关注并及时处理。\",\"url\":\"/sos/index?tabActive=1\",\"platform\":\"com.zjxl.medicalcare.doctor\"}";
        push2(cid,1,json);
    }
    /**
@ -189,6 +190,7 @@ public class GetuiUtil {
            IosDTO iosDTO = new IosDTO();
            iosDTO.setAps(aps);
            iosDTO.setType("notify");
//            iosDTO.setAutoBadge("+1");
            iosDTO.setPayload(json.getString("payload"));
            pushChannel.setIos(iosDTO);
        }

+ 9 - 1
common/common-entity/sql记录

@ -1613,4 +1613,12 @@ CREATE TABLE `base_patient_step` (
  `create_time` timestamp NULL DEFAULT NULL COMMENT '产生日期',
  `del` int(1) DEFAULT NULL COMMENT '是否有效 1有效 0无效',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=32 DEFAULT CHARSET=utf8 COMMENT='患者手表步数';
) ENGINE=InnoDB AUTO_INCREMENT=32 DEFAULT CHARSET=utf8 COMMENT='患者手表步数';
-- 2021-12-27
CREATE TABLE `base_activity_click` (
  `id` varchar(50) NOT NULL,
  `activity_type` tinyint(2) DEFAULT NULL COMMENT '活动类型 1-活动浏览2公益课程播放',
  `create_time` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='幼儿活动点击次数统计表';

+ 4 - 0
common/common-rest-model/pom.xml

@ -60,5 +60,9 @@
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
        </dependency>
    </dependencies>
</project>

+ 5 - 1
server/svr-authentication/src/main/java/com/yihu/jw/security/core/userdetails/jdbc/WlyyUserDetailsService.java

@ -665,7 +665,7 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
        }
        if(StringUtils.isNotBlank(clientId)&&StringUtils.isNotBlank(clientType)&&isPateint<3){
            try {
                List<GetuiClientDO> list = baseGetuiClientDao.findByUser(id,isPateint,clientId,clientType);
                List<GetuiClientDO> list = baseGetuiClientDao.findByUser(id,isPateint,clientType);
                if(list.size() == 0){
                    GetuiClientDO getuiClientDO = new GetuiClientDO();
                    getuiClientDO.setClientId(clientId);
@ -674,6 +674,10 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
                    getuiClientDO.setUser(id);
                    getuiClientDO.setCreateTime(new Date());
                    baseGetuiClientDao.save(getuiClientDO);
                }else{
                    GetuiClientDO getuiClientDO = list.get(0);
                    getuiClientDO.setClientId(clientId);
                    baseGetuiClientDao.save(getuiClientDO);
                }
            }catch (Exception e){
                e.printStackTrace();

+ 3 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/dao/patient/BaseGetuiClientDao.java

@ -19,4 +19,7 @@ public interface BaseGetuiClientDao extends PagingAndSortingRepository<GetuiClie
    @Query("from GetuiClientDO p where p.user = ?1 and p.type=?2 and p.clientId=?3 and p.clientType=?4")
    List<GetuiClientDO> findByUser(String user, Integer type,String clientId,String clientType);
    @Query("from GetuiClientDO p where p.user = ?1 and p.type=?2 and p.clientType=?3")
    List<GetuiClientDO> findByUser(String user, Integer type,String clientType);
}

+ 28 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/consult/PatientConsultEndpoint.java

@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.aop.ObserverRequired;
import com.yihu.jw.care.service.consult.ConsultService;
import com.yihu.jw.care.service.message.BaseServiceNewsService;
import com.yihu.jw.care.util.MessageUtil;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorRoleDao;
import com.yihu.jw.doctor.service.BaseDoctorInfoService;
@ -38,8 +39,10 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.*;
import java.net.URLEncoder;
import java.security.MessageDigest;
import java.util.*;
@ -107,6 +110,31 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
	@Autowired
	private BaseServiceNewsService serviceNewsService;
	@Autowired
	private JdbcTemplate jdbcTemplate;
	@Autowired
	private MessageUtil messageUtil;
	@PostMapping(value = "sendGetuiMessage")
	@ApiOperation(value = "im推送个推消息")
	public Envelop sendGetuiMessage(String sessionId,String type,String senderName,String senderId,String targetId){
		try {
			String body = "收到来自"+senderName+"的一条消息,请关注并及时处理。";
			String peerName = null;
			String sql = "SELECT name from im_internet_hospital.sessions WHERE id = '"+sessionId+"'";
			List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
			if(list!=null&&list.size()>0){
				peerName = URLEncoder.encode(list.get(0).get("name").toString(), "UTF-8");
			}
			String url = "/chatroom/index?type="+type+"&peerId=&peerName="+peerName+"&sessionId="+sessionId;
			messageUtil.sendDoctorGetuiMessage(targetId,"4",url,"im消息",body);
			return Envelop.getSuccess("请求成功");
		}catch (Exception e){
			e.printStackTrace();
			return Envelop.getError("请求失败");
		}
	}
	@GetMapping(value = "findLastOnlineConsult")
	@ApiOperation(value = "获取居民该机构的最近一次在线咨询")

+ 12 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/message/DoctorMessageEndpoint.java

@ -40,6 +40,18 @@ public class DoctorMessageEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = "unreadMessageNum")
    @ApiOperation("未读消息数量")
    public ObjEnvelop unreadMessageNum(@ApiParam(name = "doctor", required = true, value = "doctor")
                                   @RequestParam(value = "doctor", required = true) String doctor){
        try {
            return ObjEnvelop.getSuccess("查询成功",0);
        }catch (Exception e){
            return failedObjEnvelopException2(e);
        }
    }
    @PostMapping(value = "newOrgNotice")
    @ApiOperation("创建机构通知消息")
    @ObserverRequired

+ 97 - 48
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/statistics/OpenStatisticsEndpoint.java

@ -53,7 +53,7 @@ public class OpenStatisticsEndpoint extends EnvelopRestEndpoint {
    public ListEnvelop executeESSQL1(
            @RequestParam(required = true) String sql) {
        try {
            return success(elasticsearchUtil.excute(sql, SaveModel.class,null,null));
            return success(elasticsearchUtil.excute(sql, SaveModel.class, null, null));
        } catch (Exception e) {
            return failedListEnvelopException2(e);
        }
@ -82,6 +82,55 @@ public class OpenStatisticsEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = "patientAnalysis")
    @ApiOperation(value = "居民分析")
    public ObjEnvelop patientAnalysis(
                                      @RequestParam(required = true) String endDate,
                                      @RequestParam(required = true) String area,
                                      @RequestParam(required = true) int level,
                                      @ApiParam(name = "index", value = "42幼儿,37老人", defaultValue = "") @RequestParam(required = true) String index) {
        try {
            JSONObject result = statisticsService.patientAnalysisDP(endDate, area, level, index);
            return success(result);
        } catch (Exception e) {
            return failedObjEnvelopException2(e);
        }
    }
    @GetMapping(value = "patientTypeTotalAnalysis")
    @ApiOperation(value = "老人幼儿类型统计分析")
    public ObjEnvelop patientTypeTotalAnalysis(
            @RequestParam(required = false) String endDate,
            @ApiParam(name = "index", value = "42幼儿,37老人", defaultValue = "") @RequestParam(required = true) String index) {
        try {
            JSONObject result = statisticsService.combinedTotal(index,endDate);
            return success(result);
        } catch (Exception e) {
            return failedObjEnvelopException2(e);
        }
    }
    @GetMapping(value = "curveTotal")
    @ApiOperation(value = "曲线图")
    public ObjEnvelop curveTotal(@RequestParam(required = true) String day,
                                 @ApiParam(name = "type", value = "39-老人-生活照料-服务工单数 44-老人-生活照料-代预约 3-幼儿活动报名 41-紧急呼叫  43-老人安放监护 2-公艺课程播放  1-活动浏览次数 28-新生儿-在线咨询总数 32-新生儿-在线咨询总数  35-新生儿-上门辅导-服务工单数")
                                 @RequestParam(required = true) String type,
                                 @RequestParam(required = true) String area,
                                 @RequestParam(required = true) int level,
                                 @RequestParam(required = false) String timeLevel,
                                 @RequestParam(required = false) String interval,
                                 @RequestParam(required = false) String lowLevel
    ) {
        try {
            JSONObject result = statisticsService.curveTotal(day, type, area, level, timeLevel, interval, lowLevel);
            return success(result);
        } catch (Exception e) {
            return failedObjEnvelopException2(e);
        }
    }
    @GetMapping(value = "serviceResources")
    @ApiOperation(value = "服务资源v0.7.0")
    public ObjEnvelop ServiceResources() {
@ -107,9 +156,9 @@ public class OpenStatisticsEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = "getAllDynamics")
    @ApiOperation(value = "综合动态v0.7.0")
    public PageEnvelop getAllDynamics(
            @RequestParam(required = true) Integer page,@RequestParam(required = true) Integer size) {
            @RequestParam(required = true) Integer page, @RequestParam(required = true) Integer size) {
        try {
            return statisticsService.getAllDynamics(page,size);
            return statisticsService.getAllDynamics(page, size);
        } catch (Exception e) {
            return failedPageEnvelopException2(e);
        }
@ -118,9 +167,9 @@ public class OpenStatisticsEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = "serviceRankingAnalysis")
    @ApiOperation(value = "服务排名分析")
    public ListEnvelop serviceRankingAnalysis(
            @RequestParam(required = true) String endDate,@RequestParam(required = true) String orgType) {
            @RequestParam(required = true) String endDate, @RequestParam(required = true) String orgType) {
        try {
            return success(statisticsService.serviceRankingAnalysis(endDate,orgType));
            return success(statisticsService.serviceRankingAnalysis(endDate, orgType));
        } catch (Exception e) {
            return failedListEnvelopException2(e);
        }
@ -129,9 +178,9 @@ public class OpenStatisticsEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = "fingLoginLog")
    @ApiOperation(value = "获取登录记录")
    public PageEnvelop fingLoginLog(
            @RequestParam(required = true) Integer page,@RequestParam(required = true) Integer size) {
            @RequestParam(required = true) Integer page, @RequestParam(required = true) Integer size) {
        try {
            return statisticsService.fingLoginLog(page,size);
            return statisticsService.fingLoginLog(page, size);
        } catch (Exception e) {
            return failedPageEnvelopException2(e);
        }
@ -162,60 +211,60 @@ public class OpenStatisticsEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = "findUserByType")
    @ApiOperation(value = "人员实时动态搜索")
    public Envelop findUserByType(@ApiParam(name = "type", value = "类型:1幼儿,2老人,3助老员,4医生。不传返回四个类型的数据")
                                    @RequestParam(value = "type", required = false)String type,
                                    @ApiParam(name = "name", value = "姓名")
                                    @RequestParam(value = "name", required = false)String name,
                                    @ApiParam(name = "residentialArea", value = "居住小区")
                                    @RequestParam(value = "residentialArea", required = false)String residentialArea,
                                    @ApiParam(name = "page", value = "第几页")
                                        @RequestParam(value = "page", required = false)Integer page,
                                    @ApiParam(name = "size", value = "页面大小")
                                        @RequestParam(value = "size", required = false)Integer size){
        try{
            return success("修改成功",patientService.findUserByType(type, name, residentialArea, page, size));
        }catch (Exception e){
                                  @RequestParam(value = "type", required = false) String type,
                                  @ApiParam(name = "name", value = "姓名")
                                  @RequestParam(value = "name", required = false) String name,
                                  @ApiParam(name = "residentialArea", value = "居住小区")
                                  @RequestParam(value = "residentialArea", required = false) String residentialArea,
                                  @ApiParam(name = "page", value = "第几页")
                                  @RequestParam(value = "page", required = false) Integer page,
                                  @ApiParam(name = "size", value = "页面大小")
                                  @RequestParam(value = "size", required = false) Integer size) {
        try {
            return success("修改成功", patientService.findUserByType(type, name, residentialArea, page, size));
        } catch (Exception e) {
            return failedException2(e);
        }
    }
    @GetMapping(value = "doctorInfo")
    @ApiOperation(value = "获取医生详情")
    public ObjEnvelop doctorInfo (
    public ObjEnvelop doctorInfo(
            @ApiParam(name = "doctorId", value = "医生id", required = true)
            @RequestParam(value = "doctorId",required = true) String doctorId) throws Exception {
        try{
            return ObjEnvelop.getSuccess("查询成功",doctorService.doctorSimpleInfo(doctorId));
        }catch (Exception e){
            @RequestParam(value = "doctorId", required = true) String doctorId) throws Exception {
        try {
            return ObjEnvelop.getSuccess("查询成功", doctorService.doctorSimpleInfo(doctorId));
        } catch (Exception e) {
            return failedObjEnvelopException2(e);
        }
    }
    @GetMapping(value = "getDoctorOrderList")
    @ApiOperation("获取医生生活照料列表")
    public ObjEnvelop getDoctorOrderList(@ApiParam(name="doctor",value = "医生id",required = true)
                                      @RequestParam(value = "doctor")String doctor,
                                      @ApiParam(name="page",value="page")
                                      @RequestParam(name = "page")Integer page,
                                      @ApiParam(name="size",value="size")
                                      @RequestParam(name = "size")Integer size){
    public ObjEnvelop getDoctorOrderList(@ApiParam(name = "doctor", value = "医生id", required = true)
                                         @RequestParam(value = "doctor") String doctor,
                                         @ApiParam(name = "page", value = "page")
                                         @RequestParam(name = "page") Integer page,
                                         @ApiParam(name = "size", value = "size")
                                         @RequestParam(name = "size") Integer size) {
        try {
            return ObjEnvelop.getSuccess("查询成功",lifeCareOrderService.getDoctorOrderList(doctor,page,size));
        }catch (Exception e){
            return ObjEnvelop.getSuccess("查询成功", lifeCareOrderService.getDoctorOrderList(doctor, page, size));
        } catch (Exception e) {
            return failedObjEnvelopException2(e);
        }
    }
    @GetMapping(value = "getEmergencyAssistanceList")
    @ApiOperation(value = "紧急救助列表")
    public PageEnvelop getEmergencyAssistanceList(@ApiParam(name="doctor",value = "医生id",required = true)
                                                     @RequestParam(value = "doctor")String doctor,
                                                 @ApiParam(name="page",value = "page")
                                                 @RequestParam(value = "page") Integer page,
                                                 @ApiParam(name="size",value = "size")
                                                 @RequestParam(value = "size") Integer size){
    public PageEnvelop getEmergencyAssistanceList(@ApiParam(name = "doctor", value = "医生id", required = true)
                                                  @RequestParam(value = "doctor") String doctor,
                                                  @ApiParam(name = "page", value = "page")
                                                  @RequestParam(value = "page") Integer page,
                                                  @ApiParam(name = "size", value = "size")
                                                  @RequestParam(value = "size") Integer size) {
        try {
            return emergencyAssistanceService.getEmergencyAssistanceList(page,size,doctor);
        }catch (Exception e){
            return emergencyAssistanceService.getEmergencyAssistanceList(page, size, doctor);
        } catch (Exception e) {
            return failedPageEnvelopException2(e);
        }
    }
@ -225,7 +274,7 @@ public class OpenStatisticsEndpoint extends EnvelopRestEndpoint {
    public ObjEnvelop statisticsOrderServer(
            @RequestParam(required = true) String endDate) {
        try {
            JSONObject result = statisticsService.statisticsOrderServer("46,48",endDate,2,"4");
            JSONObject result = statisticsService.statisticsOrderServer("46,48", endDate, 2, "4");
            return success(result);
        } catch (Exception e) {
            return failedObjEnvelopException2(e);
@ -249,7 +298,7 @@ public class OpenStatisticsEndpoint extends EnvelopRestEndpoint {
    public ObjEnvelop statisticsOlderAge(
            @RequestParam(required = true) String endDate) {
        try {
            JSONObject result = statisticsService.statisticsOrderServer("50",endDate,2,"2");
            JSONObject result = statisticsService.statisticsOrderServer("50", endDate, 2, "2");
            return success(result);
        } catch (Exception e) {
            return failedObjEnvelopException2(e);
@ -261,18 +310,18 @@ public class OpenStatisticsEndpoint extends EnvelopRestEndpoint {
    public ListEnvelop searchBySql(
            @RequestParam(required = true) String sql) {
        try {
            return ListEnvelop.getSuccess("查询成功",statisticsService.searchBySql(sql));
            return ListEnvelop.getSuccess("查询成功", statisticsService.searchBySql(sql));
        } catch (Exception e) {
            return failedListEnvelopException2(e);
        }
    }
    @RequestMapping(value="esDataModify",method = RequestMethod.GET)
    public ObjEnvelop esDataModify(@RequestParam(required = true) String sql,@RequestParam(required = true) String jsonStr){
    @RequestMapping(value = "esDataModify", method = RequestMethod.GET)
    public ObjEnvelop esDataModify(@RequestParam(required = true) String sql, @RequestParam(required = true) String jsonStr) {
        try {
            return ObjEnvelop.getSuccess("success",statisticsService.esDataModify(sql,jsonStr));
        }catch (Exception e){
           return failedObjEnvelopException2(e);
            return ObjEnvelop.getSuccess("success", statisticsService.esDataModify(sql, jsonStr));
        } catch (Exception e) {
            return failedObjEnvelopException2(e);
        }
    }

+ 13 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/activity/ChildActivityRegistrationService.java

@ -14,8 +14,14 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/**
 * Created by yeshijie on 2021/10/16.
@ -114,7 +120,13 @@ public class ChildActivityRegistrationService {
     */
    @Transactional
    public void activityClick(Integer type){
        String sql = " UPDATE base_child_activity_click SET num = num+1 where type="+type;
        //取当前时间
        Date nowdate=new Date();
        //转换时间格式
        SimpleDateFormat simpleDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Timestamp timestamp = Timestamp.valueOf(simpleDate.format(nowdate));
        //String sql = " UPDATE base_child_activity_click SET num = num+1 where type="+type;
        String sql = " INSERT INTO base_activity_click VALUES ('"+UUID.randomUUID().toString().replace("-","")+"',"+type+",'"+timestamp+"')";
        jdbcTemplate.execute(sql);
    }
}

+ 2 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/assistance/EmergencyAssistanceService.java

@ -295,6 +295,8 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
                    messageUtil.sendTXYSJson("1099807",doctorDO.getMobile(),assistanceDO.getPatientName(),"紧急呼叫");
                }
            }catch (Exception e){}
            String body = "您好,"+assistanceDO.getPatientName()+"居民发起紧急呼叫,请关注并及时处理。";
            messageUtil.sendDoctorGetuiMessage(doctorDO.getId(),"2","/sos/index?tabActive=1","紧急呼叫",body);
            imUtill.sendMDTSocketMessageToDoctor(doctorDO.getId(),message.toString());
        }
        //pc管理端端推送消息

+ 5 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/consult/ConsultService.java

@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.dao.consult.BaseYunxingChannelDao;
import com.yihu.jw.care.util.EntranceUtil;
import com.yihu.jw.care.util.MessageUtil;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
@ -32,6 +33,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.net.URLEncoder;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -76,6 +78,8 @@ public class ConsultService {
    private EntranceUtil entranceUtil;
    @Autowired
    private BaseYunxingChannelDao yunxingChannelDao;
    @Autowired
    private MessageUtil messageUtil;
    /**
     * 保存云信channelId
@ -625,6 +629,7 @@ public class ConsultService {
        }
        // 保存医生咨询信息
        // 添加咨询转发记录
        // 添加医生咨询日志

+ 1 - 15
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/PatientDeviceService.java

@ -108,7 +108,7 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
    private static final String gxy = "HP0093";
    //健康问题 糖尿病
    private static final String tnb = "HP0047";
    Map<Integer, String> relations = new HashMap<>();
    @Value("${es.index.Statistics}")
    private String esIndex;
    @Autowired
@ -132,20 +132,6 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
    @Autowired
    private PatientSafeAreaConfirmDao patientSafeAreaConfirmDao;
    @PostConstruct
    public void init() {
        relations.put(0, "其他");
        relations.put(1, "父亲");
        relations.put(2, "母亲");
        relations.put(3, "老公");
        relations.put(4, "老婆");
        relations.put(5, "儿子");
        relations.put(6, "女儿");
        relations.put(7, "未知");
        relations.put(8, "免疫关联");
    }
    /**
     * 获取烟雾 燃气浓度
     * @param patient

+ 3 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/security/SecurityMonitoringOrderService.java

@ -292,7 +292,10 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
                if (StringUtils.isNotBlank(doctorDO.getMobile())){
                    messageUtil.sendTXYSJson("1141719",doctorDO.getMobile(),orderDO.getPatientName(),orderDO.getServeDesc());
                }
            }catch (Exception e){}
            String body = "您好,"+orderDO.getPatientName()+"居民"+orderDO.getServeDesc()+",请关注并及时处理。";
            messageUtil.sendDoctorGetuiMessage(doctorDO.getId(),"1","/securityMonitoring/index","安防紧急预警",body);
            imUtil.sendMDTSocketMessageToDoctor(doctorDO.getId(),message.toString());
        }
        //pc管理端端推送消息

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

@ -43,8 +43,12 @@ import org.springframework.transaction.annotation.Transactional;
import javax.persistence.Transient;
import javax.persistence.criteria.CriteriaBuilder;
import java.awt.print.Pageable;
import java.sql.Timestamp;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
@ -136,19 +140,19 @@ public class StatisticsService {
        String securityMonitoringSql = "SELECT COUNT(1) FROM base_security_monitoring_order where 1=1 "+filter;
        Integer securityMonitoringNum = jdbcTemplate.queryForObject(securityMonitoringSql,Integer.class);
        //男 女 性别总数
        /*//男 女 性别总数
        String sexCountSql = "SELECT COUNT(*) ss, CASE p.sex WHEN 1 THEN '男' WHEN 2 THEN '女' END AS sex " +
                "FROM wlyy_patient_label lab " +
                "INNER JOIN base_patient p ON p.id = lab.patient AND lab.label_type = '3' AND lab.patient NOT IN ('null') GROUP BY p.sex";
        List<Map<String, Object>> sexCountMap = jdbcTemplate.queryForList(sexCountSql);
        res.put("sexCount",sexCountMap);
        res.put("sexCount",sexCountMap);*/
        //老人-紧急预警
        res.put("index_"+41,emergencyCallNum);
        //老人 安放监护
        res.put("index_"+43,securityMonitoringNum);
        //评估类型
        res.put("capacityAssessment",capacityAssessment(endDate,defalutArea,defalutLevel));
        res.put("capacityAssessment",cloudCareForTheElderly(endDate,defalutArea,defalutLevel));
        //居民健康标签纬度
        res.put("patientLabelStatistic",statisticsOrderServer("47",endDate,2,"2"));
@ -161,20 +165,145 @@ public class StatisticsService {
            res.put("activity_"+tmp.get("type").toString(),num);
        }
        //返回活动曲线图
        sql = "select count(id),DATE_FORMAT(create_time,'%Y-%m-%d') as total from base_child_activity_registration " +
                "GROUP BY DATE_FORMAT(create_time,'%Y-%m-%d')  " +
                "ORDER BY create_time";
        List<Map<String, Object>> maps = jdbcTemplate.queryForList(sql);
        res.put("quxiantu_3",maps);
        //幼儿活动报名总数
        //activity-3 幼儿活动报名-总数
        sql = " select count(id) as total from base_child_activity_registration ";
        Integer count = jdbcTemplate.queryForObject(sql,Integer.class);
        res.put("activity_3",count);
        return res;
    }
    /*曲线*/
    public JSONObject curveTotal(String day,String type,String area,int level,String timeLevel,String interval,String lowLevel) throws Exception {
        JSONObject res = new JSONObject();
        StringBuffer sqlbuff = new StringBuffer();
        List<Map<String,Object>> listMaps = null;
        if ("".equals(day)){
            day = "30";
        }
        Calendar cal = Calendar.getInstance();
        cal.setTime(new Date());
        cal.add(Calendar.DATE, -Integer.parseInt(day));
        java.sql.Date date = new java.sql.Date(cal.getTime().getTime());
        /*---------sql----------*/
        // 3 幼儿活动
        if("3".equals(type)){
            sqlbuff.append("SELECT count(id) amount,DATE_FORMAT(create_time,'%Y-%m-%d') as `range` FROM base_child_activity_registration WHERE DATE_SUB(CURDATE(), INTERVAL "+day+" DAY) <= date(create_time) GROUP BY DATE_FORMAT(create_time,'%Y-%m-%d') ORDER BY create_time");
            listMaps = jdbcTemplate.queryForList(String.valueOf(sqlbuff));
            res.put("count",listMaps);
        }
        //41 老人-紧急呼叫
        if("41".equals(type)){
            sqlbuff.append("SELECT COUNT(id) amount,DATE_FORMAT(create_time,'%Y-%m-%d') AS `range` FROM base_emergency_assistance_order WHERE DATE_SUB(CURDATE(), INTERVAL "+day+" DAY) <= DATE(create_time) AND status >= 0 GROUP BY DATE_FORMAT(create_time,'%Y-%m-%d') ORDER BY create_time");
            listMaps = jdbcTemplate.queryForList(String.valueOf(sqlbuff));
            res.put("count",listMaps);
        }
        //43 老人 安放监护
        if ("43".equals(type)){
            sqlbuff.append("SELECT COUNT(id) amount,DATE_FORMAT(create_time,'%Y-%m-%d') AS `range` FROM base_security_monitoring_order WHERE DATE_SUB(CURDATE(), INTERVAL "+day+" DAY) <= DATE(create_time) AND status >= 0 GROUP BY DATE_FORMAT(create_time,'%Y-%m-%d') ORDER BY create_time");
            listMaps = jdbcTemplate.queryForList(String.valueOf(sqlbuff));
            res.put("count",listMaps);
        }
        // 1   活动浏览次数
        if ("1".equals(type)){
            sqlbuff.append("SELECT COUNT(id) amount,DATE_FORMAT(create_time,'%Y-%m-%d') AS `range` FROM base_activity_click WHERE DATE_SUB(CURDATE(), INTERVAL "+day+" DAY) <= DATE(create_time) AND activity_type = 1 GROUP BY DATE_FORMAT(create_time,'%Y-%m-%d') ORDER BY create_time");
            listMaps = jdbcTemplate.queryForList(String.valueOf(sqlbuff));
            res.put("count",listMaps);
        }
        // 2 公艺课程播放
        if ("2".equals(type)){
            sqlbuff.append("SELECT COUNT(id) amount,DATE_FORMAT(create_time,'%Y-%m-%d') AS `range` FROM base_activity_click WHERE DATE_SUB(CURDATE(), INTERVAL "+day+" DAY) <= DATE(create_time) AND activity_type = 2 GROUP BY DATE_FORMAT(create_time,'%Y-%m-%d') ORDER BY create_time");
            listMaps = jdbcTemplate.queryForList(String.valueOf(sqlbuff));
            res.put("count",listMaps);
        }
        /*----------es-----------*/
        // 39 老人-生活照料-服务工单数
        // 44 老人-生活照料-代预约
        // 28 新生儿-在线咨询总数
        // 32 新生儿-在线咨询总数
        // 35 新生儿-上门辅导-服务工单数
        // 54 新生儿-上门辅导-工单数发起数
        if ("".equals(interval)){
            interval ="1";
        }
        if ("".equals(timeLevel)){
            timeLevel ="1";
        }
        if (!"3".equals(type)&&!"41".equals(type)&&!"43".equals(type)&&!"1".equals(type)&&!"2".equals(type)){
            JSONArray esResoult = addLine(String.valueOf(date),LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")), area, level, type, timeLevel, interval, lowLevel);
            List<Map> maps = JSONObject.parseArray(esResoult.toJSONString(), Map.class);
            res.put("count",maps);
        }
        return res;
    }
    /*综合总数*/
    public JSONObject combinedTotal(String type,String endDate) throws Exception {
        JSONObject res = new JSONObject();
        String index = "";
        //es
        // 39 老人-生活照料-服务工单数
        // 44 老人-生活照料-代预约
        // 28 新生儿-在线咨询总数
        // 35 新生儿-上门辅导-服务工单数
        // 29 新生儿-在线咨询未回复数
        // 54 新生儿-上门辅导-工单数发起数
        //sql
        // activity-3 幼儿活动
        // activity-1   活动浏览次数
        // activity-2   公艺课程播放
        //41 老人-紧急呼叫
        //43 老人 安放监护
        //type   幼儿42    37老人
        if ("37".equals(type)){
            index = "39,44";
            String[] indexes = index.split(",");
            for(String ind:indexes){
                //总量
                SaveModel saveModel = elasticsearchUtil.findOneDateQuotaLevel0(endDate, endDate, defalutArea, defalutLevel, ind, SaveModel.timeLevel_DDL);
                res.put("index_"+ind,saveModel.getResult2().longValue());
            }
            String emergencyCallSql = "SELECT COUNT(1) FROM base_emergency_assistance_order WHERE status >= 0 ";
            Integer emergencyCallNum = jdbcTemplate.queryForObject(emergencyCallSql,Integer.class);
            String securityMonitoringSql = "SELECT COUNT(1) FROM base_security_monitoring_order where 1=1 ";
            Integer securityMonitoringNum = jdbcTemplate.queryForObject(securityMonitoringSql,Integer.class);
            res.put("index_41",emergencyCallNum);
            res.put("index_43",securityMonitoringNum);
        }else {
            index = "28,35,54,29";
            String[] indexes = index.split(",");
            for(String ind:indexes){
                //总量
                SaveModel saveModel = elasticsearchUtil.findOneDateQuotaLevel0(endDate, endDate, defalutArea, defalutLevel, ind, SaveModel.timeLevel_DDL);
                res.put("index_"+ind,saveModel.getResult2().longValue());
            }
            // activity-1   活动浏览次数
            // activity-2   公艺课程播放
            String sql = " select type,num from base_child_activity_click where type in(1,2)";
            List<Map<String,Object>> lists = jdbcTemplate.queryForList(sql);
            for (Map<String,Object> tmp:lists){
                Integer num = Integer.parseInt(tmp.get("num").toString());
                res.put("activity_"+tmp.get("type").toString(),num);
            }
            /*幼儿活动报名 总数*/
            String sqlActivity = " select count(id) as total from base_child_activity_registration ";
            Integer count = jdbcTemplate.queryForObject(sqlActivity,Integer.class);
            res.put("activity_3",count);
        }
        return res;
    }
    public JSONObject serviceResources(){
        String orgFilter = "";
        String sqlOrg = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_org' ";
@ -723,7 +852,6 @@ public class StatisticsService {
            range.put("amount", saveModel.getResult2());
            result.add(range);
        }
        return result;
    }
@ -911,10 +1039,10 @@ public class StatisticsService {
        }
        JSONArray jsonArray = new JSONArray();
        String sql = " select dict.dict_code,dict_value,count(DISTINCT A.patient) total from wlyy_hospital_sys_dict dict \n" +
                " LEFT JOIN (select distinct lab.patient,lab.label_code from  wlyy_patient_label lab  INNER JOIN base_patient p on p.id = lab.patient AND  lab.label_type='3' " +
                " LEFT JOIN (select distinct lab.patient,lab.label_code from  wlyy_patient_label lab  INNER JOIN base_patient p on p.id = lab.patient AND  lab.label_type='1' " +
                  filter+"   \n" +
                ")A on dict.dict_code = A.label_code " +
                "where  dict.dict_name='older_label'  and  dict.dict_code is not null and dict_code <= 7  \n" +
                "where  dict.dict_name='service_type'  and  dict.dict_code is not null and dict_code <> 5  \n" +
                " GROUP BY dict.dict_code; ";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
@ -1510,4 +1638,153 @@ public class StatisticsService {
    }
    /*大屏 老人云照护 病人分析 */
    public JSONObject patientAnalysisDP(String endDate, String area, int level,String index) throws Exception{
        JSONObject res = new JSONObject();
        String areaLevel = "6";
        if("42".equals(index)){
            areaLevel = "4";
            //新生儿
            //是否入学
            List<SaveModel> statusList = elasticsearchUtil.findDateAllQuotaLevel1(endDate, endDate, area, level, index, SaveModel.timeLevel_DDL,null,null,areaLevel);
            JSONArray statusArray = new JSONArray();
            for(int i=0;i<statusList.size();i++){
                SaveModel saveModel = statusList.get(i);
                JSONObject json = new JSONObject();
                json.put("num",saveModel.getResult2().longValue());
                json.put("code",saveModel.getSlaveKey1());
                json.put("name",saveModel.getSlaveKey1Name());
                statusArray.add(json);
            }
            res.put("statusList",statusArray);
        }else{
            //老人
            //能力评估 从签约时服务标签取
            res.put("levelList",cloudCareForTheElderly(null,null,null));
            //居民健康标签
            List<SaveModel> list = elasticsearchUtil.findDateAllQuotaLevel1(endDate,endDate,area,level,"47",SaveModel.timeLevel_DDL,null,null,"2");
            JSONArray labelArr = new JSONArray();
            Long total = 0l;
            for(int i=0;i<list.size();i++){
                SaveModel saveModel = list.get(i);
                JSONObject json = new JSONObject();
                if (saveModel.getResult2().longValue()==0&&StringUtils.isBlank(saveModel.getSlaveKey1())){
                    continue;
                }
                if ("0".equals(saveModel.getSlaveKey1())){//去除60岁以下老人
                    continue;
                }
                json.put("num",saveModel.getResult2().longValue());
                json.put("code",saveModel.getSlaveKey1());
                json.put("name",saveModel.getSlaveKey1Name());
                total+=saveModel.getResult2().longValue();
                labelArr.add(json);
            }
            JSONObject arrTmp = new JSONObject();
            arrTmp.put("patientLabelTotal",total);
            arrTmp.put("patientLabelList",labelArr);
            res.put("patientLabelStatistic",arrTmp);
            //年龄分布 50
//            ageList = elasticsearchUtil.findDateAllQuotaLevel1(endDate, endDate, area, level, "50", SaveModel.timeLevel_DDL,null,null,"2");
            List<SaveModel>  ageList = elasticsearchUtil.findDateAllQuotaLevel1(endDate,endDate,area,level,"50",SaveModel.timeLevel_DDL,null,null,"2");
            JSONArray ageArray = new JSONArray();
            for(int i=0;i<ageList.size();i++){
                SaveModel saveModel = ageList.get(i);
                if ("0".equals(saveModel.getSlaveKey1())){//去除60岁以下老人
                    continue;
                }
                JSONObject json = new JSONObject();
                json.put("num",saveModel.getResult2().longValue());
                json.put("code",saveModel.getSlaveKey1());
                json.put("name",saveModel.getSlaveKey1Name());
                ageArray.add(json);
            }
            res.put("ageList",ageArray);
            //居住小区分布
            String filter = "";
            String sqltmp = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_child' or dict_name = 'jkzl_older' ";
            List<Map<String,Object>> listtmp =  jdbcTemplate.queryForList(sqltmp);
            if(listtmp.size()>0){
                String orgCodes = String.valueOf(listtmp.get(0).get("orgCodes"));
                orgCodes = orgCodes.replaceAll(",","','");
                filter = " not in ('"+orgCodes+"')";
            }
            String  sql = "select count(id) total,residential_area residentialArea  from base_patient where del=1 and id "+filter+"  and archive_type=1 " +
                    "GROUP BY residential_area ORDER BY total desc";
            List<Map<String,Object>> result = jdbcTemplate.queryForList(sql);
            Iterator<Map<String, Object>> iterator = result.iterator();
            Map<String, Object> tmp = new HashMap<>();
            while (iterator.hasNext()){
                tmp = iterator.next();
                if (null==tmp.get("residentialArea")){
                    iterator.remove();
                    break;
                }
            }
            result.add(tmp);
            res.put("residentialArea",result);
        }
        //性别分析
        String archiType="";
        if("42".equals(index)){
            archiType="2";
        }
        if("37".equals(index)){
            archiType="1";
        }
        List<SaveModel> sexList = elasticsearchUtil.findDateQuotaLevel2ByKeyGroup(endDate, endDate,defalutArea, level, "51",SaveModel.timeLevel_DDL,null,archiType,null,null,"2","1");
        JSONArray sexArray = new JSONArray();
        for(int i=0;i<sexList.size();i++){
            SaveModel saveModel = sexList.get(i);
            JSONObject json = new JSONObject();
            json.put("num",saveModel.getResult2().longValue());
            json.put("code",saveModel.getSlaveKey1());
            json.put("name",saveModel.getSlaveKey1Name());
            sexArray.add(json);
        }
        res.put("sexList",sexArray);
        return res;
    }
    /*大屏 老人云照护 评估*/
    public JSONArray cloudCareForTheElderly(String endDate, String area, Integer level) throws Exception{
        //评估类型
        String filter = "";
        String sqltmp = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_child' or dict_name = 'jkzl_older' ";
        List<Map<String,Object>> listtmp =  jdbcTemplate.queryForList(sqltmp);
        if(listtmp.size()>0){
            String orgCodes = String.valueOf(listtmp.get(0).get("orgCodes"));
            if (StringUtils.isNotBlank(orgCodes)){
                orgCodes = orgCodes.replaceAll(",","','");
                filter = " and lab.patient not in ('"+orgCodes+"')";
            }
        }
        JSONArray jsonArray = new JSONArray();
        String sql = " select dict.dict_code,dict_value,count(DISTINCT A.patient) total from wlyy_hospital_sys_dict dict \n" +
                " LEFT JOIN (select distinct lab.patient,lab.label_code from  wlyy_patient_label lab  INNER JOIN base_patient p on p.id = lab.patient AND  lab.label_type='3' " +
                filter+"   \n" +
                ")A on dict.dict_code = A.label_code " +
                "where  dict.dict_name='older_label'  and  dict.dict_code is not null and dict_code <= 7  \n" +
                " GROUP BY dict.dict_code; ";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        String older = " select count(distinct lab.patient) from  wlyy_patient_label lab  INNER JOIN base_patient p on p.id = lab.patient AND  lab.label_type='1' "+filter;
        Integer count = jdbcTemplate.queryForObject(older,Integer.class);
        for(Map<String,Object> map:list){
            JSONObject json = new JSONObject();
            DecimalFormat df = new DecimalFormat("0.00");
            json.put("rate", df.format((Integer.parseInt(map.get("total").toString())*1.00) / count * 100));
            json.put("num", map.get("total"));
            json.put("code",map.get("dict_code").toString());
            json.put("name",map.get("dict_value").toString());
            jsonArray.add(json);
        }
        return jsonArray;
    }
}

+ 37 - 6
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/MessageUtil.java

@ -8,6 +8,7 @@ import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.entity.base.wx.WxAccessTokenDO;
import com.yihu.jw.entity.base.wx.WxTemplateConfigDO;
import com.yihu.jw.entity.care.common.GetuiClientDO;
import com.yihu.jw.entity.care.doorCoach.BaseDoorCoachOrderDO;
import com.yihu.jw.entity.care.lifeCare.LifeCareOrderDO;
import com.yihu.jw.entity.care.securitymonitoring.SecurityMonitoringOrderDO;
@ -15,6 +16,8 @@ import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
import com.yihu.jw.org.dao.BaseOrgDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.push.dao.GetuiClientDao;
import com.yihu.jw.push.service.GetuiService;
import com.yihu.jw.sms.service.TXYSmsService;
import com.yihu.jw.util.wechat.WeixinMessagePushUtils;
import com.yihu.jw.wechat.dao.WxAccessTokenDao;
@ -31,9 +34,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import java.util.*;
/**
 * Created by liub on 2020/12/28.
@ -67,8 +68,10 @@ public class MessageUtil {
    private BaseOrgDao orgDao;
    @Autowired
    private TXYSmsService txySmsService;
    //发送微信模板消息
    private  String sendMessageUrl = "http://172.16.100.37:8090/hospitalPortal-sms/sms/sendMessage";
    @Autowired
    private GetuiService getuiService;
    @Autowired
    private GetuiClientDao getuiClientDao;
    /**
     * 您好{1}有一条新的在线报名申请,请及时前往APP消息应用进行处理。
@ -82,6 +85,34 @@ public class MessageUtil {
        }
    }
    /**
     * 发送医生个推推送消息
     * type 1 安防紧急预警 2紧急呼叫 4im 5生日祝福
     */
    public void sendDoctorGetuiMessage(String doctorCode,String type,String url,String title,String body){
        try {
            List<GetuiClientDO> clientDOS = getuiClientDao.findByUser(doctorCode,2);
            JSONObject payload = new JSONObject();
            payload.put("title",title);
            payload.put("body",body);
            payload.put("url",url);
            JSONObject json = new JSONObject();
            json.put("title",title);
            json.put("body",body);
            json.put("url",url);
//        json.put("clickType","url");
            json.put("platform",getuiService.cloudCareDoctor);
            json.put("payload",payload.toString());
            for(GetuiClientDO clientDO:clientDOS){
                getuiService.push2(clientDO.getClientId(),Integer.valueOf(clientDO.getClientType()),json);
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }
    /**
     *
     * @param wechatId
@ -117,7 +148,7 @@ public class MessageUtil {
                newConfig.setFirst(first);
            }
            if (StringUtils.isNoneBlank(url)){
               newConfig.setUrl(url);
                newConfig.setUrl(url);
            }
            if (StringUtils.isNoneBlank(remark)){
                newConfig.setRemark(remark);

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

@ -85,7 +85,11 @@
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>push-service</artifactId>
            <version>2.0.0</version>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>

+ 5 - 0
svr/svr-cloud-job/src/main/java/com/yihu/jw/care/service/BirthdayReminderService.java

@ -43,11 +43,16 @@ public class BirthdayReminderService {
            try {
                String doctorName = map.get("name")+"";
                String mobile = map.get("mobile")+"";
                String doctorId =  map.get("id")+"";
                Integer c = Integer.valueOf(map.get("c")+"");
                if (c>0&&mobile.length()==11){
                    messageUtil.sendTXYSJson("1099809",mobile,doctorName,c+"");
                }
                if(c>0){
                    String body = "您好,今天有"+c+"位老人走访计划,请及时处理";
                    messageUtil.sendDoctorGetuiMessage(doctorId,"1","/solicitude/birthday","生日祝福提醒",body);
                }
            }catch (Exception e){
                e.printStackTrace();
            }

+ 37 - 0
svr/svr-cloud-job/src/main/java/com/yihu/jw/care/util/MessageUtil.java

@ -5,6 +5,9 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.base.wx.WxAccessTokenDO;
import com.yihu.jw.entity.base.wx.WxTemplateConfigDO;
import com.yihu.jw.entity.care.common.GetuiClientDO;
import com.yihu.jw.push.dao.GetuiClientDao;
import com.yihu.jw.push.service.GetuiService;
import com.yihu.jw.sms.service.TXYSmsService;
import com.yihu.jw.util.wechat.WeixinMessagePushUtils;
import com.yihu.jw.wechat.dao.WxTemplateConfigDao;
@ -18,6 +21,8 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import java.util.List;
/**
 * Created by Bing on 2021/5/29.
 */
@ -36,9 +41,41 @@ public class MessageUtil {
    @Value("${sendTXMessage.flag}")
    private Boolean sendTXMessageFlag;
    @Autowired
    private GetuiService getuiService;
    @Autowired
    private GetuiClientDao getuiClientDao;
    private static Logger logger = LoggerFactory.getLogger(MessageUtil.class);
    /**
     * 发送医生个推推送消息
     * type 1 安防紧急预警 2紧急呼叫 4im 5生日祝福
     */
    public void sendDoctorGetuiMessage(String doctorCode,String type,String url,String title,String body){
        try {
            List<GetuiClientDO> clientDOS = getuiClientDao.findByUser(doctorCode,2);
            JSONObject payload = new JSONObject();
            payload.put("title",title);
            payload.put("body",body);
            payload.put("url",url);
            JSONObject json = new JSONObject();
            json.put("title",title);
            json.put("body",body);
            json.put("url",url);
//        json.put("clickType","url");
            json.put("platform",getuiService.cloudCareDoctor);
            json.put("payload",payload.toString());
            for(GetuiClientDO clientDO:clientDOS){
                getuiService.push2(clientDO.getClientId(),Integer.valueOf(clientDO.getClientType()),json);
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }
    public void putTemplateWxMessage(String wechatId, String templateName, String scene, String openId, String first
            ,String url, String remark, Integer type,JSONObject json,String ...keywords) {
        try {

+ 16 - 0
svr/svr-iot/src/main/java/com/yihu/iot/controller/monitorPlatform/MonitorPlatformController.java

@ -1121,6 +1121,22 @@ public class MonitorPlatformController extends EnvelopRestEndpoint {
        }
    }
    @ApiOperation("获取智慧药房取药信息")
    @RequestMapping(value = "getBuyDrugMessage",method = {RequestMethod.GET})
    public ObjEnvelop getBuyDrugMessage(@ApiParam(name = "deviceid", defaultValue = "设备id")
                                        @RequestParam(value = "deviceid", required = true) String deviceid,
                                        @ApiParam(name = "startTime", defaultValue = "开始时间")
                                        @RequestParam(value = "startTime", required = true) String startTime,
                                        @ApiParam(name = "endTime", defaultValue = "开始时间")
                                        @RequestParam(value = "endTime", required = true) String endTime){
        try {
            JSONObject jsonObject = monitorPlatformService.getBuyDrugMessage(deviceid,startTime,endTime);
            return ObjEnvelop.getSuccess("成功",jsonObject,200);
        } catch (Exception e) {
            return ObjEnvelop.getError("失败"+e.getMessage());
        }
    }
    @ApiOperation("智慧药房库存检测信息")
    @RequestMapping(value = "getYgStockDetection", method = {RequestMethod.GET})
    public ObjEnvelop getYgStockDetection(@ApiParam(name = "deviceid", defaultValue = "设备id")

+ 15 - 5
svr/svr-iot/src/main/java/com/yihu/iot/service/monitorPlatform/MonitorPlatformService.java

@ -3,7 +3,6 @@ package com.yihu.iot.service.monitorPlatform;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.JsonArray;
import com.yihu.iot.dao.dict.IotSystemDictDao;
import com.yihu.iot.dao.equipment.IotEquipmentDetailDao;
import com.yihu.iot.service.analyzer.WlyyIotTzDict;
@ -1911,10 +1910,10 @@ public class MonitorPlatformService {
            JSONObject quyaoQbject = mediicineorderList.getJSONObject(i);
            //取药方式(1、扫码,2、医保卡)
            String shippingType = quyaoQbject.getString("shippingType");
            String payTime = quyaoQbject.getString("payTime");
            String shippingTime = quyaoQbject.getString("shippingTime");
            String name = quyaoQbject.getString("name");
            listMap.put("shippingType", shippingType);
            listMap.put("payTime", payTime);
            listMap.put("shippingTime", shippingTime);
            listMap.put("name", name);
            mediicineorderListMap.add(listMap);
        }
@ -1939,8 +1938,6 @@ public class MonitorPlatformService {
        //取药方式获取
        JSONArray shippingTypeArray = jsonObject.getJSONArray("shippingTypeTotal");
        List<Map> shippingTypeList = JSONObject.parseArray(shippingTypeArray.toJSONString(), Map.class);
        //取药列表存放
        resoultMap.put("mediicineorderList", mediicineorderListMap);
        //设备信息存放
@ -2010,6 +2007,19 @@ public class MonitorPlatformService {
        }
    }
    /*取药信息*/
    public JSONObject getBuyDrugMessage(String deviceid, String startTime,String endTime) throws Exception {
        Map parameterMap = new HashMap<String, String>();
        parameterMap.put("deviceId", deviceid);
        parameterMap.put("startTime", startTime);
        parameterMap.put("endTime", endTime);
        String content = com.alibaba.fastjson.JSONObject.toJSONString(parameterMap);
        String params = AesEncryptUtils.agEncrypt(content);
        JSONObject jsonObject = getUrl("/open/noLogin/getDeviceOrderInfo", params, "detailModelList");
        System.out.println(jsonObject);
        return jsonObject;
    }
    /*智慧药房库存检测
     * 药房有6层,每层40个货道
     * 商品状态:未设商品、已有商品