소스 검색

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

# Conflicts:
#	common/common-entity/sql记录
wangjun 4 년 전
부모
커밋
7976865167
19개의 변경된 파일672개의 추가작업 그리고 71개의 파일을 삭제
  1. 3 1
      common/common-entity/sql记录
  2. 3 0
      svr/svr-cloud-care/readme.MD
  3. 7 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/apply/PatientBedApplyDao.java
  4. 2 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/security/SecurityMonitoringConclusionDao.java
  5. 1 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/apply/PatientBedApplyEndPoint.java
  6. 256 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/consult/PatientConsultEndpoint.java
  7. 2 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/doctor/DoctorEndpoint.java
  8. 2 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/lifeCare/DoctorLifeCareEndpoint.java
  9. 41 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/message/DoctorMessageEndpoint.java
  10. 2 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/patient/PatientEndpoint.java
  11. 62 16
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/security/SecurityMonitoringOrderEndpoint.java
  12. 9 6
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/sign/SignEndpoint.java
  13. 22 4
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/apply/PatientBedApplyService.java
  14. 98 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/message/DoctorMessageService.java
  15. 6 6
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/patient/CarePatientService.java
  16. 114 27
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/security/SecurityMonitoringOrderService.java
  17. 17 4
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/ArchiveService.java
  18. 8 4
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/CapacityAssessmentRecordService.java
  19. 17 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/ServicePackageService.java

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

@ -388,4 +388,6 @@ alter TABLE base.base_security_monitoring_order add COLUMN doctor_confirm_finish
alter TABLE base.base_security_monitoring_order add COLUMN doctor_confirm_finish_time timestamp NULL DEFAULT NULL COMMENT '医生确认完成时间';
-- 2021-04-09 中山消息推送
alter table wlyy_outpatient ADD last_remind_time timestamp ;
alter table wlyy_outpatient ADD remind_doctor  varchar(50) ;
alter table wlyy_outpatient ADD remind_doctor  varchar(50) ;
-- 2021-04-10 lb
ALTER table base.base_patient_bed_apply  MODIFY `patient` varchar(50) DEFAULT NULL;

+ 3 - 0
svr/svr-cloud-care/readme.MD

@ -1,3 +1,6 @@
基础微服务
    每个模块有自己独立的文件夹,这样做的好处是以后如果哪个模块需要独立成微服务,代码直接剪切到新的微服务即可。
    每个模块下面有独立的Endpoint,service,model和dao
@ObserverRequired
医生端观察者模式。医生端请求的post的接口必须加这个注解

+ 7 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/apply/PatientBedApplyDao.java

@ -1,7 +1,9 @@
package com.yihu.jw.care.dao.apply;
import com.yihu.jw.entity.care.apply.PatientBedApplyDo;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
@ -14,7 +16,10 @@ public interface PatientBedApplyDao extends PagingAndSortingRepository<PatientBe
    PatientBedApplyDo findByPatientAndOrgCodeAndStatus(String patient,String orgCode,Integer status);
    List<PatientBedApplyDo> findByOrgCodeAndStatusIn(String orgCode,Integer[] status);
    List<PatientBedApplyDo> findByOrgCodeAndStatusIn(String orgCode,Integer[] status ,Sort sort);
    List<PatientBedApplyDo> queryByIdcardAndOrgCodeAndStatusIn(String idcard,String orgCode,Integer[] status);
    List<PatientBedApplyDo> queryByIdcardAndOrgCodeAndStatusIn(String idcard, String orgCode, Integer[] status);
    @Query("select count(1) from PatientBedApplyDo p where p.orgCode=?1 and p.status<>-1 and p.status<>0")
    Integer findUnCompleteByOrgCode(String orgCode);
}

+ 2 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/security/SecurityMonitoringConclusionDao.java

@ -6,6 +6,8 @@ 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 by Bing on 2021/4/7.
 */

+ 1 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/apply/PatientBedApplyEndPoint.java

@ -42,7 +42,7 @@ public class PatientBedApplyEndPoint extends EnvelopRestEndpoint {
    }
    @GetMapping("/getApplyList")
    @ApiOperation("居民申请机构床位")
    @ApiOperation("居民申请机构床位List")
    public ListEnvelop getApplyList(@ApiParam(name = "doctor", value = "doctor", required = true)
                                    @RequestParam(value = "doctor") String doctor) {
        try {

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

@ -0,0 +1,256 @@
package com.yihu.jw.care.endpoint.consult;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorRoleDao;
import com.yihu.jw.doctor.service.BaseDoctorInfoService;
import com.yihu.jw.entity.base.doctor.BaseDoctorRoleDO;
import com.yihu.jw.entity.base.wx.WxWechatDO;
import com.yihu.jw.file_upload.FileUploadService;
import com.yihu.jw.hospital.family.service.WlyyFamilyMemberService;
import com.yihu.jw.hospital.message.service.SystemMessageService;
import com.yihu.jw.im.service.ImService;
import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.service.BasePatientService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import com.yihu.jw.rm.patient.PatientRequestMapping;
import com.yihu.jw.util.common.FileUtil;
import com.yihu.jw.wechat.dao.WechatDao;
import com.yihu.jw.wechat.service.WechatInfoService;
import com.yihu.jw.wlyy.service.WlyyBusinessService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
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.web.bind.annotation.*;
import java.security.MessageDigest;
import java.util.*;
/**
 * @author huangwenjie
 */
@RestController
@RequestMapping(value = BaseHospitalRequestMapping.PatientIM.PREFIX)
@Api(value = "居民端咨询IM接口", description = "居民端咨询IM接口", tags = {"居民端咨询IM接口"})
public class PatientConsultEndpoint extends EnvelopRestEndpoint {
	private static final Logger logger = LoggerFactory.getLogger(PatientConsultEndpoint.class);
	@Autowired
	private ImService imService;
	@Autowired
	private BasePatientService basePatientService;
	
	
	@Autowired
	private WechatInfoService wechatInfoService;
	
	@Autowired
	private WechatDao wechatDao;
	@Autowired
	private WlyyBusinessService wlyyBusinessService;
	@Autowired
	private BaseDoctorDao baseDoctorDao;
	@Autowired
	private BasePatientDao basePatientDao;
	
	@Autowired
	FileUploadService fileUploadService;
	@Autowired
	private BaseDoctorInfoService doctorInfoService;
	@Autowired
	private SystemMessageService systemMessageService;
	@Autowired
	private BaseDoctorRoleDao doctorRoleDao;
	@Autowired
	public ImUtil imUtil;
	@Autowired
	private WlyyFamilyMemberService familyMemberService;
	@Value("${fastDFS.fastdfs_file_url}")
	private String fastdfs_file_url;
	@Value("${testPattern.sign}")
	private String isClose;
	@Value("${wechat.id}")
	private String wechat_appid;
	@Autowired
	private FileUtil fileUtil;
	
	@GetMapping(value = BaseHospitalRequestMapping.PatientIM.participants)
	@ApiOperation(value = "获取会话成员")
	public ListEnvelop participants(
			@ApiParam(name = "sessionId", value = "会话ID")
			@RequestParam(value = "sessionId",required = true) String sessionId)throws Exception{
		
		JSONArray participants = imService.getSessions(sessionId);
		return success(participants);
	}
	
	@GetMapping(value = BaseHospitalRequestMapping.PatientIM.getSessionMessage)
	@ApiOperation(value = "根据会话ID获取消息记录")
	public ListEnvelop getSessionMessage(
			@ApiParam(name = "sessionId", value = "会话ID")
			@RequestParam(value = "sessionId",required = true) String sessionId,
			@ApiParam(name = "startMsgId", value = "开始的消息记录ID")
			@RequestParam(value = "startMsgId",required = false) String startMsgId,
			@ApiParam(name = "endMsgId", value = "结束的消息记录ID")
			@RequestParam(value = "endMsgId",required = false) String endMsgId,
			@ApiParam(name = "page", value = "第几页")
			@RequestParam(value = "page",required = true) int page,
			@ApiParam(name = "pagesize", value = "分页数")
			@RequestParam(value = "pagesize",required = true) int pagesize)throws Exception{
		JSONArray messageArray = imService.getSessionMessage(sessionId, startMsgId, endMsgId, page, pagesize, getUID());
		return success(messageArray);
	}
	
	@PostMapping(value = BaseHospitalRequestMapping.PatientIM.getSign)
	@ApiOperation(value = "获取微信签名", notes = "获取微信签名")
	public Envelop getSign(@ApiParam(name = "pageUrl", value = "授权页面")
	                       @RequestParam(value = "pageUrl", required = true)String pageUrl,
	                       @ApiParam(name = "wxId", value = "微信id")
	                       @RequestParam(value = "wxId", required = true)String wxId) throws Exception {
		logger.info("pageUrl="+pageUrl);
		logger.info("wxId="+wxId);
		String ticket = wechatInfoService.getJsapi_ticketByToken(wxId);
		WxWechatDO wxWechatDO = wechatDao.findById(wxId);
		Map<Object, Object> map = new HashMap<Object, Object>();
		if (ticket != null) {
			String noncestr = UUID.randomUUID().toString();
			long timestamp = System.currentTimeMillis() / 1000;
			String url = pageUrl;
			logger.info("getSign.url="+url);
			String str = "jsapi_ticket=" + ticket + "&noncestr=" + noncestr + "&timestamp=" + timestamp + "&url=" + url;
			logger.info("getSign.str="+str);
			// sha1加密
			String signature = SHA1(str);
			map.put("noncestr", noncestr);
			map.put("timestamp", timestamp);
			map.put("signature", signature);
			map.put("appid", wxWechatDO.getAppId());
			return success(PatientRequestMapping.Wechat.api_success,map);
		}
		return failed(PatientRequestMapping.Wechat.api_error);
	}
	
	/**
	 * @description: SHA、SHA1加密 @parameter: str:待加密字符串 @return: 加密串
	 **/
	public String SHA1(String str) throws Exception {
		try {
			MessageDigest digest = MessageDigest.getInstance("SHA-1"); // 如果是SHA加密只需要将"SHA-1"改成"SHA"即可
			digest.update(str.getBytes());
			byte messageDigest[] = digest.digest();
			// Create Hex String
			StringBuffer hexStr = new StringBuffer();
			// 字节数组转换为 十六进制 数
			for (int i = 0; i < messageDigest.length; i++) {
				String shaHex = Integer.toHexString(messageDigest[i] & 0xFF);
				if (shaHex.length() < 2) {
					hexStr.append(0);
				}
				hexStr.append(shaHex);
			}
			return hexStr.toString();
			
		} catch (Exception e) {
			throw new Exception(e.getMessage());
		}
	}
	
	@PostMapping(value = BaseHospitalRequestMapping.PatientIM.updateConsultParticipant)
	@ApiOperation(value = "更新会话成员(新增或删除)", notes = "更新会话成员(新增或删除)")
	public Envelop updateConsultParticipant(@ApiParam(name = "sessionid", value = "会话ID", defaultValue = "1")
	                                       @RequestParam(value = "sessionid", required = true) String sessionid,
	                                       @ApiParam(name = "userid", value = "新增成员ID,多个以英文逗号隔开", defaultValue = "1")
	                                       @RequestParam(value = "userid", required = true) String userid,
	                                       @ApiParam(name = "olduserid", value = "删除的成员id")
	                                       @RequestParam(value = "olduserid", required = false) String olduserid)throws Exception{
		imService.updateParticipant(sessionid,userid,olduserid);
		return success("操作成功");
	}
	
	@PostMapping(value = "messageAppend")
	@ApiOperation(value = "居民单聊会话发送消息", notes = "居民单聊会话发送消息")
	public Envelop messageAppend(
			@ApiParam(name = "sender_id", value = "发送者id", defaultValue = "")
			@RequestParam(value = "sender_id", required = true) String sender_id,
			@ApiParam(name = "sender_name", value = "发送者姓名", defaultValue = "")
			@RequestParam(value = "sender_name", required = true) String sender_name,
			@ApiParam(name = "session_id", value = "session_id", defaultValue = "")
			@RequestParam(value = "session_id", required = false) String session_id,
			@ApiParam(name = "content_type", value = "内容类型", defaultValue = "")
			@RequestParam(value = "content_type", required = true) String content_type,
			@ApiParam(name = "content", value = "消息内容", defaultValue = "")
			@RequestParam(value = "content", required = true) String content,
			@ApiParam(name = "extend", value = "扩展内容", defaultValue = "")
			@RequestParam(value = "extend", required = false) String extend,
			@ApiParam(name = "type", value = "咨询type", defaultValue = "")
			@RequestParam(value = "type", required = false) String type,
			@ApiParam(name = "times", value = "times", defaultValue = "")
			@RequestParam(value = "times", required = false) Integer times
	)throws Exception{
		List<String> failed = new ArrayList<>();
		//处理语音文件
		if(!org.springframework.util.StringUtils.isEmpty(wechat_appid)){
			if("3".equalsIgnoreCase(content_type)){//语音文件
				String voicepath = imService.fetchWxVoices(wechat_appid);
				logger.info("voice_path:"+voicepath);
				JSONObject obj = new JSONObject();
				String voiceurl = "";
				// 将临时语音拷贝到正式存储路径下
				if (org.apache.commons.lang3.StringUtils.isNotEmpty(voicepath)) {
					voiceurl = fileUtil.copyTempVoice(voicepath,fastdfs_file_url);
					obj.put("path", voiceurl);
					obj.put("times", times);
					content = obj.toString();
				}
			}else if("2".equalsIgnoreCase(content_type)){//图片文件
				String imagepath = imService.fetchWxImages(wechat_appid);
				logger.info("image_path:"+imagepath);
				String imgeUrl = "";
				// 将临时语音拷贝到正式存储路径下
				if (org.apache.commons.lang3.StringUtils.isNotEmpty(imagepath)) {
					imgeUrl = fileUtil.copyTempVoice(imagepath,fastdfs_file_url);
					content = imgeUrl;
				}
			}else{
			}
		}
		session_id = imService.getPatientGuaidenceConsult(sender_id,session_id,type);
		String result = imService.patientGuaidenceAppend(sender_id,sender_name,session_id,content_type,content,"1",extend);
		List<BaseDoctorRoleDO> doctorRoleDOS = doctorRoleDao.findByRoleCode("guidance");
		for (BaseDoctorRoleDO doctorRoleDO:doctorRoleDOS){
			System.out.println("发送外层SOCKET消息:通知医生导诊");
			JSONObject object = new JSONObject();
			object.put("socket_sms_type",13);
			object.put("relation_code",session_id);
			imService.sendWaiSocketMessage(sender_id,doctorRoleDO.getDoctorCode(),object.toString(),"1");
		}
		return success(result);
	}
}

+ 2 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/doctor/DoctorEndpoint.java

@ -1,6 +1,7 @@
package com.yihu.jw.care.endpoint.doctor;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.aop.ObserverRequired;
import com.yihu.jw.care.service.doctor.CareDoctorService;
import com.yihu.jw.care.service.sign.CapacityAssessmentRecordService;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
@ -81,6 +82,7 @@ public class DoctorEndpoint extends EnvelopRestEndpoint {
    @PostMapping(value = "updateDoctor")
    @ApiOperation(value = "修改医生信息")
    @ObserverRequired
    public Envelop update(
            @ApiParam(name = "baseDoctorVo", value = "JSON数据", required = true)
            @RequestParam(value = "baseDoctorVo") String baseDoctorVo)throws Exception{

+ 2 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/lifeCare/DoctorLifeCareEndpoint.java

@ -1,6 +1,7 @@
package com.yihu.jw.care.endpoint.lifeCare;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.aop.ObserverRequired;
import com.yihu.jw.care.service.lifeCare.LifeCareOrderService;
import com.yihu.jw.entity.care.lifeCare.LifeCareOrderDO;
import com.yihu.jw.restmodel.ResponseContant;
@ -81,6 +82,7 @@ public class DoctorLifeCareEndpoint extends EnvelopRestEndpoint {
    @PostMapping("completeOrder")
    @ApiOperation(value = "记录完成情况")
    @ObserverRequired
    public Envelop completeOrder(
            @ApiParam(value = "工单id", name = "orderId")
            @RequestParam(value = "orderId", required = true) String orderId,

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

@ -0,0 +1,41 @@
package com.yihu.jw.care.endpoint.message;
import com.yihu.jw.care.service.message.DoctorMessageService;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created by Bing on 2021/4/10.
 */
@RestController
@RequestMapping(value = "doctor/message")
@Api(description = "医生消息")
public class DoctorMessageEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private DoctorMessageService doctorMessageService;
    @GetMapping(value = "messages")
    @ApiOperation("应用消息")
    public ObjEnvelop messages(@ApiParam(name = "type", value = "消息类型 10床位申请,11安全监护")
                               @RequestParam(value = "type", required = false) String type,
                               @ApiParam(name = "doctor", value = "doctor")
                               @RequestParam(value = "doctor", required = false) String doctor){
        try {
            return ObjEnvelop.getSuccess("查询成功",doctorMessageService.findDoctorAllMessage(doctor,type));
        }catch (Exception e){
            e.printStackTrace();
            return ObjEnvelop.getError("查询失败"+e.getMessage());
        }
    }
}

+ 2 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/patient/PatientEndpoint.java

@ -1,5 +1,6 @@
package com.yihu.jw.care.endpoint.patient;
import com.yihu.jw.care.aop.ObserverRequired;
import com.yihu.jw.care.aop.ServicesAuth;
import com.yihu.jw.care.aop.ServicesAuthAOP;
import com.yihu.jw.care.dao.label.WlyyPatientLabelDao;
@ -121,6 +122,7 @@ public class PatientEndpoint extends EnvelopRestEndpoint {
    @PostMapping(value = "updPatientLabel")
    @ApiOperation(value = "修改居民标签信息")
    @ObserverRequired
    public Envelop updPatientLabel(@ApiParam(name = "jsonData", value = "json格式")
                              @RequestParam(value = "jsonData", required = true)String jsonData,
                              @ApiParam(name = "patientId", value = "居民id")

+ 62 - 16
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/security/SecurityMonitoringOrderEndpoint.java

@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.aop.ObserverRequired;
import com.yihu.jw.care.service.security.SecurityMonitoringOrderService;
import com.yihu.jw.entity.care.securitymonitoring.SecurityMonitoringConclusionDO;
import com.yihu.jw.entity.care.securitymonitoring.SecurityMonitoringOrderDO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
@ -28,9 +27,9 @@ public class SecurityMonitoringOrderEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private SecurityMonitoringOrderService securityMonitoringOrderService;
    @PostMapping(value = "createOrder")
    @ApiOperation(value = "创建安防服务工单")
    @ObserverRequired
    public ObjEnvelop createOrder(@ApiParam(name="jsonData",value = "json数据",required = true)
                               @RequestParam(value = "jsonData")String jsonData){
        try {
@ -46,9 +45,13 @@ public class SecurityMonitoringOrderEndpoint extends EnvelopRestEndpoint {
    }
    @GetMapping(value = "getSecurityOrderList")
    @ApiOperation(value = "获取安防工单列表")//TODO 查询需要修改
    public ListEnvelop getSecurityOrderList(@ApiParam(name="doctor",value = "医生ID",required = true)
    @ApiOperation(value = "获取安防工单列表")
    public ListEnvelop getSecurityOrderList(@ApiParam(name="doctor",value = "医生ID,当前查看列表医生",required = true)
                                            @RequestParam(value = "doctor")String doctor,
                                            @ApiParam(name="serverDoctor",value = "处置医生di 即为患者提供服务的医生")
                                            @RequestParam(value = "serverDoctor",required = false)String serverDoctor,
                                            @ApiParam(name="patientName",value = "患者姓名或身份证")
                                            @RequestParam(value = "patientName",required = false)String patientName,
                                            @ApiParam(name="patient",value = "patient")
                                            @RequestParam(value = "patient",required = false)String patient,
                                            @ApiParam(name="status",value = "工单状态-1已取消1待处置2前往居民定位3已签到4已登记小结5待补录6待评价7已完成")
@ -60,13 +63,28 @@ public class SecurityMonitoringOrderEndpoint extends EnvelopRestEndpoint {
        try {
            page = page>1?page-1:0;
            return ListEnvelop.getSuccess("查询成功",securityMonitoringOrderService.getSecurityOrderList(doctor, patient, status, page, pageSize));
            return ListEnvelop.getSuccess("查询成功",securityMonitoringOrderService.getSecurityOrderList(doctor,serverDoctor,patientName, patient, status, page, pageSize));
        }catch (Exception e){
            e.printStackTrace();
            return ListEnvelop.getError("查询失败");
        }
    }
    @GetMapping(value = "getSecurityOrderUnCompleteList")
    @ApiOperation(value = "获取医生机构下未结束的安防工单")
    public ListEnvelop getSecurityOrderUnCompleteList(@ApiParam(name="doctor",value = "医生ID,当前查看列表医生",required = true)
                                            @RequestParam(value = "doctor")String doctor){
        try {
            return ListEnvelop.getSuccess("查询成功",securityMonitoringOrderService.getSecurityOrderUnCompleteList(doctor));
        }catch (Exception e){
            e.printStackTrace();
            return ListEnvelop.getError("查询失败");
        }
    }
    @GetMapping(value = "getSecurityOrderDetail")
    @ApiOperation(value = "获取安防工单详情")//
    public ObjEnvelop getSecurityOrderDetail(@ApiParam(name="orderId",value = "orderId",required = true)
@ -104,6 +122,7 @@ public class SecurityMonitoringOrderEndpoint extends EnvelopRestEndpoint {
    @PostMapping(value = "cancelOrder")
    @ApiOperation(value = "取消工单")
    @ObserverRequired
    public Envelop cancelOrder(
            @ApiParam(name = "orderId", value = "工单id") @RequestParam(value = "orderId", required = true) String orderId,
            @ApiParam(name = "reason", value = "取消理由") @RequestParam(value = "reason", required = true) String reason,
@ -124,6 +143,7 @@ public class SecurityMonitoringOrderEndpoint extends EnvelopRestEndpoint {
    @PostMapping("signIn")
    @ApiOperation(value = "上门服务签到")
    @ObserverRequired
    public ObjEnvelop signIn(
            @ApiParam(value = "工单id", name = "orderId")
            @RequestParam(value = "orderId", required = true) String orderId,
@ -138,12 +158,11 @@ public class SecurityMonitoringOrderEndpoint extends EnvelopRestEndpoint {
            @ApiParam(value = "二维码内容", name = "twoDimensionalCode")
            @RequestParam(value = "twoDimensionalCode", required = false) String twoDimensionalCode) {
        try {
            SecurityMonitoringOrderDO securityMonitoringOrderDO = securityMonitoringOrderService.signIn(orderId, signTime, signWay, signLocation, signImg,twoDimensionalCode,getUID());
            if (securityMonitoringOrderDO != null){
                return ObjEnvelop.getSuccess("操作成功", securityMonitoringOrderDO);
            }else {
                return ObjEnvelop.getError("扫码签到失败");
            JSONObject result = securityMonitoringOrderService.signIn(orderId, signTime, signWay, signLocation, signImg,twoDimensionalCode,getUID());
            if (result.getIntValue("resultFlag") == 0) {
                return ObjEnvelop.getError(result.getString("resultMsg"));
            }
            return ObjEnvelop.getSuccess("操作成功",result.getJSONObject("resultMsg"));
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError( "操作失败!" + e.getMessage());
@ -151,9 +170,10 @@ public class SecurityMonitoringOrderEndpoint extends EnvelopRestEndpoint {
    }
    @PostMapping("updateDoorConclusion")
    @ObserverRequired
    @ApiOperation("编辑保存服务工单小结")
    public ObjEnvelop updateDoorConclusion(
            @ApiParam(value = "处置状态",name = "manageStatus",required = true)
            @ApiParam(value = "处置状态",name = "manageStatus 1已确认安全 2已转送医疗机构 3已处置完成",required = true)
            @RequestParam Integer manageStatus,
            @ApiParam(value = "工单id", name = "orderId")
            @RequestParam(value = "orderId", required = true) String orderId,
@ -162,8 +182,11 @@ public class SecurityMonitoringOrderEndpoint extends EnvelopRestEndpoint {
            @ApiParam(value = "补录状态", name = "examPapeStatus")
            @RequestParam(value = "examPapeStatus", required = false) Integer examPapeStatus) {
        try {
            SecurityMonitoringConclusionDO doorConclusion = securityMonitoringOrderService.updateDoorConclusion(manageStatus, orderId,conclusion,examPapeStatus);
            return ObjEnvelop.getSuccess( "保存成功", doorConclusion);
            JSONObject result = securityMonitoringOrderService.updateDoorConclusion(manageStatus, orderId,conclusion,examPapeStatus);
            if (result.getIntValue("resultFlag") == 0) {
                return ObjEnvelop.getError(result.getString("resultMsg"));
            }
            return ObjEnvelop.getSuccess("保存成功",result.getJSONObject("resultMsg"));
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError( "保存失败!" + e.getMessage());
@ -172,11 +195,15 @@ public class SecurityMonitoringOrderEndpoint extends EnvelopRestEndpoint {
    @PostMapping(value = "cancelConclusion")
    @ResponseBody
    @ObserverRequired
    @ApiOperation("取消登记服务小结")
    public ObjEnvelop cancelConclusion(@ApiParam(name = "orderId", value = "工单id", required = true) @RequestParam String orderId) {
        try {
            securityMonitoringOrderService.cancelConclusion(orderId);
            return ObjEnvelop.getSuccess("取消成功",200);
            JSONObject result = securityMonitoringOrderService.cancelConclusion(orderId);
            if (result.getIntValue("resultFlag") == 0) {
                return ObjEnvelop.getError(result.getString("resultMsg"));
            }
            return ObjEnvelop.getSuccess("取消成功",result.getJSONObject("resultMsg"));
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError("取消失败");
@ -184,6 +211,7 @@ public class SecurityMonitoringOrderEndpoint extends EnvelopRestEndpoint {
    }
    @GetMapping("getDoorConclusion")
    @ObserverRequired
    @ApiOperation("获取服务工单小结")
    public ObjEnvelop getDoorConclusion(
            @ApiParam(value = "医生code", name = "doctor")
@ -217,10 +245,28 @@ public class SecurityMonitoringOrderEndpoint extends EnvelopRestEndpoint {
            @ApiParam(value = "医生确认结束服务照片", name = "finishImg")
            @RequestParam(value = "finishImg", required = false) String finishImg) {
        try {
            return ObjEnvelop.getSuccess("操作成功", securityMonitoringOrderService.saveOrderFinishBydoctor(orderId, finishImg));
            JSONObject result = securityMonitoringOrderService.saveOrderFinishBydoctor(orderId, finishImg);
            if (result.getIntValue("resultFlag") == 0) {
                return ObjEnvelop.getError(result.getString("resultMsg"));
            }
            return ObjEnvelop.getSuccess("操作成功",result.getJSONObject("resultMsg"));
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError( "操作失败!" + e.getMessage());
        }
    }
    @GetMapping(value = "getSecurityServerDoctor")
    @ApiOperation(value = "获取安防监护服务人员")//
    public ListEnvelop getSecurityServerDoctor(@ApiParam(name="patient",value = "patient",required = true)
                                             @RequestParam(value = "patient")String patient){
        try {
            return ListEnvelop.getSuccess("查询成功",securityMonitoringOrderService.getSecurityServerDoctor(patient));
        }catch (Exception e){
            e.printStackTrace();
            return ListEnvelop.getError("查询失败");
        }
    }
}

+ 9 - 6
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/sign/SignEndpoint.java

@ -205,8 +205,8 @@ public class SignEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = "assessmentPage")
    @ApiOperation(value = "获取能力评估分页")
    public PageEnvelop<List<Map<String,Object>>> assessmentPage (
            @ApiParam(name = "doctorId", value = "医生id", required = true)
            @RequestParam(value = "doctorId") String doctorId,
            @ApiParam(name = "doctorId", value = "医生id", required = false)
            @RequestParam(value = "doctorId",required = false)  String doctorId,
            @ApiParam(name = "name", value = "居民姓名或身份证", required = false)
            @RequestParam(value = "name",required = false) String name,
            @ApiParam(name = "status", value = "认可结果(0未认可,1已认可,2不认可)", required = false)
@ -237,6 +237,9 @@ public class SignEndpoint extends EnvelopRestEndpoint {
            @RequestParam String doctorId) {
        try{
            JSONObject result = capacityAssessmentRecordService.capacityAssessment(jsonData,doctorId);
            if(result == null){
                return ObjEnvelop.getError("已存在评估报告,请勿重复生成");
            }
            if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return ObjEnvelop.getError(result.getString(ResponseContant.resultMsg));
            }
@ -365,8 +368,8 @@ public class SignEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = "getArchiveTopNum")
    @ApiOperation(value = "档案管理-获取签约/未签约总数")
    public ObjEnvelop getArchiveTopNum(
            @ApiParam(name = "doctorId", value = "医生id", required = true)
            @RequestParam String doctorId) {
            @ApiParam(name = "doctorId", value = "医生id", required = false)
            @RequestParam(value = "doctorId",required = false) String doctorId) {
        try{
            return ObjEnvelop.getSuccess("查询成功",archiveService.getArchiveTopNum(doctorId));
        }catch (Exception e){
@ -378,8 +381,8 @@ public class SignEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = "archiveList")
    @ApiOperation(value = "获取档案分页")
    public PageEnvelop<List<Map<String,Object>>> archiveList (
            @ApiParam(name = "doctorId", value = "医生id", required = true)
            @RequestParam(value = "doctorId") String doctorId,
            @ApiParam(name = "doctorId", value = "医生id", required = false)
            @RequestParam(value = "doctorId",required = false) String doctorId,
            @ApiParam(name = "signStatus", value = "签约状态", required = false)
            @RequestParam(value = "signStatus",required = false) Integer signStatus,
            @ApiParam(name = "name", value = "居民姓名", required = false)

+ 22 - 4
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/apply/PatientBedApplyService.java

@ -13,13 +13,18 @@ import com.yihu.jw.entity.care.apply.PatientBedApplyDo;
import com.yihu.jw.org.dao.BaseOrgDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.mysql.query.BaseJpaService;
import net.bytebuddy.TypeCache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
/**
 * Created by Bing on 2021/4/8.
@ -78,15 +83,28 @@ public class PatientBedApplyService extends BaseJpaService<PatientBedApplyDo, Pa
        return result;
    }
    public List<PatientBedApplyDo> getApplyList(String doctor){
        List<PatientBedApplyDo> result = new ArrayList<>();
    public List<Map<String,Object>> getApplyList(String doctor){
        List<Map<String,Object>> result = new ArrayList<>();
        BaseDoctorDO doctorDO = baseDoctorDao.findById(doctor);
        if (doctorDO.getLevel()==2){//助老员
            List<BaseDoctorHospitalDO> hospitalDOS = baseDoctorHospitalDao.findByDoctorCode(doctor);
            for (BaseDoctorHospitalDO obj:hospitalDOS){
                List<PatientBedApplyDo> list = patientBedApplyDao.findByOrgCodeAndStatusIn(obj.getOrgCode(),new Integer[]{1,2});
                result.addAll(list);
                String sql="select ap.id,p.id patientCode,p.name,p.sex,p.idcard,p.photo,ap.status,DATE_FORMAT(ap.create_time,'%Y-%m-%d %H:%i:%S') create_time from base_patient_bed_apply ap INNER JOIN base_patient p where ap.idcard = p.idcard and org_code='"+obj.getOrgCode()+"' " +
                    "and ap.status <> -1 and ap.status<>0";
                List<Map<String,Object>> tmp = jdbcTemplate.queryForList(sql);
                for (Map<String,Object> map:tmp){
                    if (map.get("idcard")==null){
                        map.put("age",null);
                    }
                    else{
                        Integer age  = IdCardUtil.getAgeForIdcard(map.get("idcard").toString());
                        map.put("age",age);
                    }
                }
                result.addAll(tmp);
            }
            result.sort(Comparator.comparing(obj -> ((Map<String,Object>) obj).get("create_time").toString()));
        }
        return result;
    }

+ 98 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/message/DoctorMessageService.java

@ -0,0 +1,98 @@
package com.yihu.jw.care.service.message;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.dao.apply.PatientBedApplyDao;
import com.yihu.jw.care.dao.security.SecurityMonitoringOrderDao;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.restmodel.ResponseContant;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import javax.persistence.criteria.CriteriaBuilder;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
/**
 * Created by Bing on 2021/4/10.
 */
@Service
public class DoctorMessageService {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private BaseDoctorDao baseDoctorDao;
    @Autowired
    private BaseDoctorHospitalDao baseDoctorHospitalDao;
    @Autowired
    private PatientBedApplyDao patientBedApplyDao;
    @Autowired
    private SecurityMonitoringOrderDao securityMonitoringOrderDao;
    /**
     *
     * @param doctor
     * @param type  床位申请,11安全监护
     * @return
     */
    public JSONObject findDoctorAllMessage(String doctor,String type){
        JSONObject result = new JSONObject();
        JSONObject tmp = new JSONObject();
        boolean typeNull = StringUtils.isBlank(type);
        BaseDoctorDO doctorDO = baseDoctorDao.findById(doctor);
        if (doctorDO==null){
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg,"患者今年已做过能力评估报告,不可重复操作");
        }
        List<BaseDoctorHospitalDO> hospitalDO = baseDoctorHospitalDao.findByDoctorCode(doctor);
        Integer count;
        if (typeNull||type.equals("10")){//床位申请-未完成
            JSONObject tmpJson = new JSONObject();
            List<Map<String,Object>> listTmp = new ArrayList<>();
            count=0;
            for (BaseDoctorHospitalDO obj:hospitalDO){
                String sql ="select count(*) count,patient_name,DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%S') create_time from base_patient_bed_apply where org_code='"+obj.getOrgCode()+"' " +
                        "and status <> -1 and status<>0 order by create_time asc";
                Map<String,Object> sqlResult  = jdbcTemplate.queryForMap(sql);
                Integer sqlCount =Integer.parseInt(sqlResult.get("count").toString()) ;
                count +=sqlCount;
                listTmp.add(sqlResult);
            }
            listTmp.sort(Comparator.comparing(obj ->  obj.get("create_time").toString()));
            tmpJson.put("count",count);
            tmpJson.put("message",listTmp.get(0).get("patient_name").toString()+"居民申请床位");
            tmpJson.put("time",listTmp.get(0).get("create_time").toString());
            result.put("bedApply",tmpJson);
        }
        if (typeNull||type.equals("11")){//安全监护
            JSONObject tmpJson = new JSONObject();
            count=0;
            List<Map<String,Object>> listTmp = new ArrayList<>();
            for (BaseDoctorHospitalDO obj:hospitalDO){
                String sql ="select count(*) count,patient_name,DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%S') create_time,serve_desc from base_security_monitoring_order where hospital='"+obj.getOrgCode()+"' " +
                        "and status <>-1 and status<> 7 order by create_time asc";
                Map<String,Object> sqlResult  = jdbcTemplate.queryForMap(sql);
                Integer sqlCount =Integer.parseInt(sqlResult.get("count").toString()) ;
                count +=sqlCount;
                listTmp.add(sqlResult);
            }
            listTmp.sort(Comparator.comparing(obj ->  obj.get("create_time").toString()));
            tmpJson.put("count",count);
            tmpJson.put("message",listTmp.get(0).get("patient_name").toString()+"居民"+listTmp.get(0).get("serve_desc").toString());
            tmpJson.put("time",listTmp.get(0).get("create_time"));
            result.put("security",tmpJson);
        }
        return result;
    }
}

+ 6 - 6
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/patient/CarePatientService.java

@ -135,12 +135,12 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
        patientBrief.setName(patientDetail.getName());
        patientBrief.setSex(patientDetail.getSex());
        patientBrief.setIdcard(patientDetail.getIdcard());
        patientBrief.setProvinceCode(patientDetail.getProvinceCode());
        patientBrief.setProvinceName(patientDetail.getProvinceName());
        patientBrief.setCityCode(patientDetail.getCityCode());
        patientBrief.setCityName(patientDetail.getCityName());
        patientBrief.setTownCode(patientDetail.getTownCode());
        patientBrief.setTownName(patientDetail.getTownName());
//        patientBrief.setProvinceCode(patientDetail.getProvinceCode());
//        patientBrief.setProvinceName(patientDetail.getProvinceName());
//        patientBrief.setCityCode(patientDetail.getCityCode());
//        patientBrief.setCityName(patientDetail.getCityName());
//        patientBrief.setTownCode(patientDetail.getTownCode());
//        patientBrief.setTownName(patientDetail.getTownName());
        patientBrief.setLiveProvinceCode(patientDetail.getLiveProvinceCode());
        patientBrief.setLiveProvinceName(patientDetail.getLiveProvinceName());
        patientBrief.setLiveCityCode(patientDetail.getLiveCityCode());

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

@ -5,12 +5,15 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.care.dao.security.*;
import com.yihu.jw.care.service.sign.ServicePackageService;
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;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.servicePackage.ServicePackageRecordDO;
import com.yihu.jw.entity.care.device.PatientDevice;
@ -18,6 +21,7 @@ import com.yihu.jw.entity.care.securitymonitoring.*;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.entity.EntityUtils;
@ -63,6 +67,8 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
    private BaseDoctorDao baseDoctorDao;
    @Autowired
    private SecurityMonitoringConclusionDao securityMonitoringConclusionDao;
    @Autowired
    private BaseDoctorHospitalDao baseDoctorHospitalDao;
    private Logger logger = LoggerFactory.getLogger(SecurityMonitoringOrderService.class);
@ -115,10 +121,13 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
        }
        //签约防走失服务包
        List<ServicePackageRecordDO> signRecords = servicePackageService.servicePackageByPatient(orderDO.getPatient(),"3");
        if (signRecords.size()==0) {
        String sql ="SELECT i.code from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i  \n" +
                "where  sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id   and i.del = 1 and sr.`status`=1 \n" +
                "and  sr.patient  = '"+orderDO.getPatient()+"' and i.code=8 ";
       List<String> items = jdbcTemplate.queryForList(sql,String.class);
        if (items.size()==0) {
            result.put("resultFlag", 0);
            String failMsg = "当前服务对象未签约防走失服务包,请完成签约后再发起工单!";
            String failMsg = "当前服务对象未签约防走失服务,请签约后再发起预警!";
            result.put("resultMsg", failMsg);
            logger.error(failMsg);
            return result;
@ -173,7 +182,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
                orderDO.setMonitoringConclusion(conclusionDO);
            }
        }
        JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(orderDO, SerializerFeature.WriteMapNullValue));
        JSONObject jsonObject = JSON.parseObject(JSON.toJSONStringWithDateFormat(orderDO,"yyyy-MM-dd HH:mm:ss", SerializerFeature.WriteMapNullValue));
        jsonObject.put("conclusionStatusName",conclusionStatusName);
        Integer statustemp = Integer.valueOf(orderDO.getStatus()+"");
@ -188,28 +197,42 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
            case 6:statusName="待评价";break;
            case 7:statusName="已完成";break;
        }
        BasePatientDO patientDO = basePatientDao.findById(orderDO.getPatient());
        if (patientDO!=null){
            jsonObject.put("patientAddress",patientDO.getAddress());
        }
        else {
            jsonObject.put("patientAddress",null);
        }
        jsonObject.put("statusName",statusName);
        result.put("resultFlag", 1);
        result.put("resultMsg",jsonObject);
        return result;
    }
    public JSONArray getSecurityOrderList(String doctor, String patient, String status, Integer page, Integer pageSize){
        String sql = " select p.id patientCode,p.name,p.sex,p.idcard,ord.id orderId,ord.number,ord.serve_desc,ord.create_time,ord.`status`,ord.doctor," +
    public JSONArray getSecurityOrderList(String doctor,String serverDoctor,String patientName, String patient, String status, Integer page, Integer pageSize){
        String sql = " select p.id patientCode,p.name,p.sex,p.photo,p.idcard,ord.id orderId,ord.number,ord.serve_desc,ord.create_time,ord.`status`,ord.doctor," +
                "ord.doctor_name,ord.patient_phone,ord.conclusion_status from base_security_monitoring_order ord INNER JOIN base_patient p on p.id = ord.patient " +
                "where 1=1 ";
        if (StringUtils.isNotBlank(doctor)){
            sql +=" and ord.doctor = '"+doctor+"' ";
        List<BaseDoctorHospitalDO> hospitalDOs = baseDoctorHospitalDao.findByDoctorCode(doctor);
        if (hospitalDOs.size()>0){
            sql += "and ord.hospital = '"+hospitalDOs.get(0).getOrgCode()+"' ";
        }else  {
            return new JSONArray();
        }
        if (StringUtils.isNotBlank(serverDoctor)){
            sql +=" and ord.doctor = '"+serverDoctor+"' ";
        }
        if (StringUtils.isNotBlank(patientName)){
            sql+=" and (ord.patient_name like '%"+patientName+"%' or p.idcard='"+patientName+"')  ";
        }
        if (StringUtils.isNotBlank(patient)){
            sql+=" and ord.patient_name= like '%"+patient+"%' ";
            sql+=" and ord.patient='"+patient+"' ";
        }
        if (StringUtils.isNotBlank(status)){
            sql+=" and ord.status='"+Integer.parseInt(status)+"' ";
        }
        if (StringUtils.isBlank(status)||status.equals("1")){//状态为空或待处置时 查询该医生签约团队居民的预警
        }
        sql+=" order by ord.create_time desc limit " + (page*pageSize) + "," + pageSize;
        List<Map<String,Object>> sqlResult = jdbcTemplate.queryForList(sql);
@ -220,6 +243,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
            tmp.put("patientCode",one.get("patientCode"));
            tmp.put("patientName",one.get("name"));
            tmp.put("sex",one.get("sex"));
            tmp.put("photo",one.get("photo"));
            tmp.put("idcard",one.get("idcard"));
            tmp.put("number",one.get("number"));
            tmp.put("id",one.get("orderId"));
@ -228,7 +252,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
            tmp.put("createTime", DateUtil.dateToStr(date,"yyyy-MM-dd hh:mm:ss"));
            tmp.put("status",one.get("status"));
            tmp.put("doctor",one.get("doctor"));
            tmp.put("doctorName",one.get("doctor_ame"));
            tmp.put("doctorName",one.get("doctor_name"));
            tmp.put("patientPhone",one.get("patient_phone"));
            tmp.put("conclusionStatus",one.get("conclusion_status"));
            Integer conclusionStatus = Integer.valueOf(one.get("conclusion_status")==null?"0":(one.get("conclusion_status")+""));
@ -265,6 +289,33 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
        }
        return result;
    }
    public List<Map<String,Object>> getSecurityOrderUnCompleteList(String doctor){
        List<BaseDoctorHospitalDO> hospitalDOs = baseDoctorHospitalDao.findByDoctorCode(doctor);
        List<Map<String,Object>> result = new ArrayList<>();
        if (hospitalDOs.size()>0){
            for (BaseDoctorHospitalDO obj:hospitalDOs){
                String sql = " select p.id patientCode,p.name,p.sex,p.idcard,p.photo,ord.id orderId,ord.number,ord.serve_desc,DATE_FORMAT(ord.create_time,'%Y-%m-%d %H:%i:%S') create_time,ord.`status`,ord.doctor," +
                        "ord.doctor_name,ord.patient_phone,ord.conclusion_status from base_security_monitoring_order ord INNER JOIN base_patient p on p.id = ord.patient " +
                        "where ord.status <>-1 and ord.status<> 7  ";
                sql += "and ord.hospital = '"+obj.getOrgCode()+"' ";
                sql +=" order by ord.create_time asc ";
                List<Map<String,Object>> tmp= jdbcTemplate.queryForList(sql);
                for (Map<String,Object> map:tmp){
                    if (map.get("idcard")==null){
                        map.put("age",null);
                    }
                    else{
                        Integer age  = IdCardUtil.getAgeForIdcard(map.get("idcard").toString());
                        map.put("age",age);
                    }
                }
                result.addAll(tmp);
            }
            result.sort(Comparator.comparing(obj -> ((Map<String,Object>) obj).get("create_time").toString()));
        }
        return result;
    }
    /**
     * 系统更新医生上门服务工单状态
@ -423,8 +474,8 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
            logger.error(failMsg);
            return result;
        }
        result.put(ResponseContant.resultFlag, ResponseContant.success);
        result.put(ResponseContant.resultMsg, doorServiceOrder);
        result = getSecurityOrderDetail(orderId);
        // 发送微信模板消息通知患者医生已接单
//        BasePatientDO patient = basePatientDao.findById(doorServiceOrder.getPatient());//
@ -536,8 +587,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
//        }
//        pushMsgTask.putWxMsg(tokenUtils.getAccessToken(), 30, patient.getOpenid(), patient.getName(), json);
        result.put("resultFlag", 1);
        result.put("resultMsg", orderDO);
        result = getSecurityOrderDetail(orderId);
        return result;
    }
@ -580,7 +630,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
     * @param signImg
     * @return
     */
    public SecurityMonitoringOrderDO signIn(String orderId, String signTime, Integer signWay, String signLocation,
    public JSONObject signIn(String orderId, String signTime, Integer signWay, String signLocation,
                                         String signImg, String twoDimensionalCode,String doctorId) throws Exception {
        SecurityMonitoringOrderDO doorServiceOrder = securityMonitoringOrderDao.findOne(orderId);
        doorServiceOrder.setDoctorSignTime(DateUtil.strToDate(signTime));
@ -596,7 +646,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
                doorServiceOrder = securityMonitoringOrderDao.save(doorServiceOrder);
                // 修改医生上门服务工单状态 4服务中
                this.updateDispatchStatusBySystem(doorServiceOrder.getDoctor(), 4);//服务中
                return doorServiceOrder;
                return  getSecurityOrderDetail(orderId);
            }else {
                logger.info("扫码签到失败");
                return null;
@ -606,7 +656,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
            doorServiceOrder = securityMonitoringOrderDao.save(doorServiceOrder);
            // 修改医生上门服务工单状态 4服务中
            this.updateDispatchStatusBySystem(doorServiceOrder.getDoctor(), 4);
            return doorServiceOrder;
            return getSecurityOrderDetail(orderId);
        }
    }
@ -626,14 +676,28 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
     * @return
     * @throws Exception
     */
    public SecurityMonitoringConclusionDO updateDoorConclusion(Integer manageStatus,String orderId,String conclusion,Integer examPapeStatus) throws Exception {
    public JSONObject updateDoorConclusion(Integer manageStatus,String orderId,String conclusion,Integer examPapeStatus) throws Exception {
        JSONObject result = new JSONObject();
        ObjectMapper objectMapper = new ObjectMapper();
        objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd"));
        SecurityMonitoringConclusionDO doorConclusion = new SecurityMonitoringConclusionDO();
        SecurityMonitoringOrderDO one = securityMonitoringOrderDao.findOne(orderId);
        if (one==null){
            String failMsg = "工单不存在" ;
            result.put("resultFlag", 0);
            result.put("resultMsg", failMsg);
            return result;
        }
        SecurityMonitoringConclusionDO doorConclusion =  securityMonitoringConclusionDao.findByOrderId(orderId);
        if (doorConclusion==null){
            doorConclusion = new SecurityMonitoringConclusionDO();
            doorConclusion.setOrderId(orderId);
            doorConclusion.setPatient(one.getPatient());
            doorConclusion.setPatientName(one.getPatientName());
            doorConclusion.setDoctor(one.getDoctor());
            doorConclusion.setDoctorName(one.getDoctorName());
        }
        doorConclusion.setStatus(manageStatus);
        doorConclusion.setConclusion(conclusion);
        BaseDoctorDO doctorVO = baseDoctorDao.findById(one.getDoctor());
        if (doorConclusion != null && org.apache.commons.lang.StringUtils.isNotEmpty(doorConclusion.getId())) {
            doorConclusion.setUpdateTime(new Date());
@ -651,15 +715,16 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
        one.setExamPaperStatus(examPapeStatus);
        one.setConclusionStatus(2);
        securityMonitoringOrderDao.save(one);
        return doorConclusion;
        return getSecurityOrderDetail(orderId);
    }
    /**
     * 跳过登记服务小结
     * @param orderId
     */
    public void cancelConclusion(String orderId) {
    public JSONObject cancelConclusion(String orderId) {
        securityMonitoringOrderDao.updateConclusionStatus(orderId);
        return getSecurityOrderDetail(orderId);
    }
    /**
@ -693,11 +758,12 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
        return doorConclusion;
    }
    public SecurityMonitoringOrderDO saveOrderFinishBydoctor(String orderId ,String finishImg) throws Exception {
    public JSONObject saveOrderFinishBydoctor(String orderId ,String finishImg) throws Exception {
        SecurityMonitoringOrderDO one = securityMonitoringOrderDao.findOne(orderId);
        one.setDoctorConfirmFinishImg(finishImg);
        one.setStatus(SecurityMonitoringOrderDO.Status.complete.getType());
        one.setDoctorConfirmFinishTime(new Date());
        one.setCompleteTime(one.getDoctorConfirmFinishTime());
        // 更新记录
        this.setUpdateColumnInfo(one);
        securityMonitoringOrderDao.save(one);
@ -733,7 +799,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
        }catch (Exception e){
            logger.error(e.getMessage());
        }
        return doorServiceOrderDO;
        return getSecurityOrderDetail(orderId);
    }
    /**
@ -812,6 +878,27 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
        return doorServiceOrder;
    }
    public List<Map<String,Object>> getSecurityServerDoctor(String patient){
        //获取患者签约防走失服务的团队
        String sql="SELECT DISTINCT i.team_code from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i  \n" +
                "where  sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id   and i.del = 1 and sr.`status`=1 \n" +
                "and  sr.patient  = '"+patient+"' and i.code=8";
        List<String> teams = jdbcTemplate.queryForList(sql,String.class);
        List<Map<String,Object>> result = new ArrayList<>();
        if (teams.size()==0){
            return new ArrayList<>();
        }else {
            for (String team:teams){
                sql = "select DISTINCT doc.id doctor,CONCAT(doc.`name`,\n" +
                        "CASE WHEN doc.`level`=1 THEN '(社区医生)' ELSE '(助老员)' END) as name,doc.photo,doc.mobile from base_team_member mem " +
                        "INNER JOIN base_doctor doc on mem.doctor_code = doc.id and mem.del=1 and mem.team_code='"+team+"'";
                List<Map<String,Object>>tmp = jdbcTemplate.queryForList(sql);
                result.addAll(tmp);
            }
        }
        return result;
    }
    private String getRandomIntStr(){
        Random rand = new Random();
        int i = rand.nextInt(); //int范围类的随机数

+ 17 - 4
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/ArchiveService.java

@ -47,6 +47,8 @@ public class ArchiveService extends BaseJpaService<ArchiveDO, ArchiveDao> {
    private PatientBedApplyDao patientBedApplyDao;
    @Autowired
    private BaseDoctorHospitalDao baseDoctorHospitalDao;
    @Autowired
    private ServicePackageService servicePackageService;
    /**
@ -63,7 +65,11 @@ public class ArchiveService extends BaseJpaService<ArchiveDO, ArchiveDao> {
        JSONObject json = new JSONObject();
        json.put("signTotal",0);
        json.put("unSignTotal",0);
        String sql = " SELECT COUNT(*) num,CAST(sign_status as char) sign_status  from wlyy_archive WHERE doctor_code =  '"+doctorId+"'GROUP BY sign_status";
        String sql = " SELECT COUNT(DISTINCT patient) num,CAST(sign_status as char) sign_status  from wlyy_archive ";
        if(StringUtils.isNotBlank(doctorId)){
            sql += "  WHERE doctor_code =  '"+doctorId+"' ";
        }
        sql += " GROUP BY sign_status";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        for (Map<String,Object> map:list){
            if("1".equals(String.valueOf(map.get("sign_status")))){
@ -77,12 +83,14 @@ public class ArchiveService extends BaseJpaService<ArchiveDO, ArchiveDao> {
    }
    public PageEnvelop<List<Map<String,Object>>> archiveList(String doctorId, int page, int size,Integer signStatus,String name){
        String sql = "SELECT a.create_time,p.idcard,p.mobile,p.name,p.sex,p.id ";
        String sql = "SELECT a.create_time,p.idcard,p.mobile,p.name,p.sex,p.id,CAST(a.sign_status AS char) sign_status ";
        String countSql = "SELECT count(*) ";
        String filters = "from wlyy_archive a,base_patient p " +
                "WHERE a.doctor_code = '"+doctorId+"' and a.patient = p.id";
                "WHERE  a.patient = p.id ";
        if(StringUtils.isNotBlank(doctorId)){
            filters += " and a.doctor_code = '"+doctorId+"'";
        }
        if(signStatus!=null){
            filters += " and a.sign_status = "+signStatus;
        }
@ -96,8 +104,13 @@ public class ArchiveService extends BaseJpaService<ArchiveDO, ArchiveDao> {
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql+filters+orderBy);
        for (Map<String,Object> map :list){
            String idcard = map.get("idcard").toString();
            String patientId = map.get("id").toString();
            String sign_status = map.get("sign_status").toString();
            map.put("createTime", map.get("create_time").toString().substring(0,19));
            map.put("age", IdCardUtil.getAgeForIdcard(idcard));
            if("1".endsWith(sign_status)){
                map.put("servicePackageList",servicePackageService.getServicePackageListByPatient(patientId,null));
            }
        }
        Long count = jdbcTemplate.queryForObject(countSql+filters,Long.class);
        return PageEnvelop.getSuccessListWithPage("success",list,page,size,count);

+ 8 - 4
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/CapacityAssessmentRecordService.java

@ -119,7 +119,7 @@ public class CapacityAssessmentRecordService extends BaseJpaService<CapacityAsse
        res.put("2",0);
        res.put("3",0);
        String sql = "SELECT COUNT(DISTINCT ar.patient),level_conclusion from  " +
        String sql = "SELECT COUNT(DISTINCT ar.patient) count,level_conclusion from  " +
                "base_capacity_assessment_record ar, " +
                "base_service_package_sign_record sr,base_service_package_record r,  " +
                "                base_service_package_item i,base_team_member m  " +
@ -151,9 +151,11 @@ public class CapacityAssessmentRecordService extends BaseJpaService<CapacityAsse
        String countSql = "SELECT count(*) ";
        String filters = "from base_capacity_assessment_record c,base_patient p " +
                "WHERE c.doctor = '"+doctorId+"' and c.patient = p.id " +
                " and c.assessment_time>='" + DateUtil.getNowYear() + "-01-01'";
                "WHERE  c.patient = p.id  and c.assessment_time>='" + DateUtil.getNowYear() + "-01-01'";
        if(StringUtils.isNoneBlank(doctorId)){
            filters += " and c.doctor = '"+doctorId+"' ";
        }
        if(status!=null){
            filters += " and c.status = "+status;
        }
@ -252,7 +254,9 @@ public class CapacityAssessmentRecordService extends BaseJpaService<CapacityAsse
            result.put(ResponseContant.resultMsg,recordDO);
            return result;
        }
        return null;
        result.put(ResponseContant.resultFlag, ResponseContant.fail);
        result.put(ResponseContant.resultMsg,"患者今年已做过能力评估报告,不可重复操作");
        return result;
    }
    /**

+ 17 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/ServicePackageService.java

@ -346,6 +346,23 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
        return PageEnvelop.getSuccessListWithPage("success",list,page,size,count);
    }
    public List<ServicePackageDO> getServicePackageListByPatient(String patient,String packageType){
        //签约记录
        List<ServicePackageDO> result;
        List<ServicePackageSignRecordDO> signs = servicePackageSignRecordDao.findByStatusAndPatient(1,patient);
        if (signs.size()>0){
            ServicePackageSignRecordDO tmp = signs.get(0);
            String sql = " select p.* from base_service_package_record r, base_service_package p " +
                    "  where r.sign_id='"+tmp.getId()+"' and r.service_package_id = p.id and p.del=1 ";
            if (StringUtils.isNotBlank(packageType)){
                sql += " and p.type='"+packageType+"' ";
            }
             result = jdbcTemplate.query(sql,new BeanPropertyRowMapper(ServicePackageDO.class));
            return result;
        }
        return new ArrayList<>();
    }
    public List<ServicePackageRecordDO> servicePackageByPatient(String patient,String packageType){
        //签约记录
        List<ServicePackageSignRecordDO> signs = servicePackageSignRecordDao.findByStatusAndPatient(1,patient);