|
@ -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范围类的随机数
|