|
@ -1,5 +1,6 @@
|
|
|
package com.yihu.jw.care.service.sign;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fasterxml.jackson.databind.JavaType;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
@ -23,10 +24,10 @@ import com.yihu.jw.entity.order.BusinessOrderDO;
|
|
|
import com.yihu.jw.im.util.ImUtil;
|
|
|
import com.yihu.jw.order.dao.BusinessOrderDao;
|
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
|
import com.yihu.jw.patient.service.BasePatientMedicardCardService;
|
|
|
import com.yihu.jw.restmodel.ResponseContant;
|
|
|
import com.yihu.jw.restmodel.web.PageEnvelop;
|
|
|
import com.yihu.jw.util.common.IdCardUtil;
|
|
|
import com.yihu.jw.util.cron.CronUtils;
|
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
|
import com.yihu.jw.util.entity.ServiceException;
|
|
|
import com.yihu.jw.utils.StringUtil;
|
|
@ -41,6 +42,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@ -75,7 +77,7 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
|
|
|
@Autowired
|
|
|
private ArchiveDao archiveDao;
|
|
|
@Autowired
|
|
|
private BasePatientMedicardCardService basePatientMedicardCardService;
|
|
|
private ServiceItemPlanDao serviceItemPlanDao;
|
|
|
@Autowired
|
|
|
private PayService payService;
|
|
|
@Autowired
|
|
@ -239,7 +241,7 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
|
|
|
" LEFT JOIN wlyy_hospital_sys_dict di2 on di2.dict_name = 'level_conclusion' and di2.dict_code=ar.level_conclusion " +
|
|
|
" where p.id = '"+patient+"' limit 1";
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql+filter);
|
|
|
String packageSql = "SELECT r.id,DATE_FORMAT(r.end_time,'%Y-%m-%d %H:%i:%S') endTime,r.type,p.`name`,p.num,p.org_name orgName " +
|
|
|
String packageSql = "SELECT r.id,p.id packageId,DATE_FORMAT(r.end_time,'%Y-%m-%d %H:%i:%S') endTime,r.type,p.`name`,p.num,p.org_name orgName " +
|
|
|
"from base_service_package_sign_record r,base_service_package p " +
|
|
|
"WHERE r.patient =? and r.`status`=1 and r.service_package_id=p.id ";
|
|
|
for (Map<String,Object> map:list){
|
|
@ -319,6 +321,9 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
|
|
|
public JSONObject signInfo(String id,String type){
|
|
|
JSONObject json = new JSONObject();
|
|
|
ServicePackageSignRecordDO signRecordDO = servicePackageSignRecordDao.findOne(id);
|
|
|
if(signRecordDO == null){
|
|
|
return null;
|
|
|
}
|
|
|
ServicePackageDO servicePackageDO = servicePackageDao.findOne(signRecordDO.getServicePackageId());
|
|
|
List<ServicePackageItemDO> itemDOList = null;
|
|
|
if("1".equals(type)){
|
|
@ -457,6 +462,7 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
|
|
|
//不需要支付
|
|
|
signRecordDO.setStatus(1);//已签约
|
|
|
//设置到期时间
|
|
|
servicePackageSignRecordDao.save(signRecordDO);
|
|
|
setSignDate(servicePackageDO,signRecordDO);
|
|
|
}else{
|
|
|
signRecordDO.setPayTime("10");//10分钟
|
|
@ -520,6 +526,115 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
|
|
|
signRecordDO.setStartTime(new Date());
|
|
|
|
|
|
sendMessage(servicePackageDO,signRecordDO);
|
|
|
|
|
|
addPlans(signRecordDO.getId(),signRecordDO.getPatient(),signRecordDO.getServicePackageId());
|
|
|
}
|
|
|
|
|
|
//养护计划详情
|
|
|
public JSONObject planDetail(String signId,String serviceItemId){
|
|
|
JSONObject result = new JSONObject();
|
|
|
List<ServiceItemConfig> configList = serviceItemConfigDao.findByServerItemId(serviceItemId);
|
|
|
if(configList.size()>0){
|
|
|
result.put("itemConfig",configList.get(0));
|
|
|
}else {
|
|
|
result.put("itemConfig",null);
|
|
|
}
|
|
|
List<ServiceItemPlanDO> planDOList = serviceItemPlanDao.findBySignIdAndServiceItemId(signId,serviceItemId);
|
|
|
result.put("planDOList",planDOList);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
//养护计划
|
|
|
public JSONArray conservePlan(String signId){
|
|
|
JSONArray ja = new JSONArray();
|
|
|
List<ServiceItemPlanDO> planDOList = serviceItemPlanDao.findBySignId(signId);
|
|
|
Map<String,List<ServiceItemPlanDO>> planListMap = planDOList.stream().collect(Collectors.groupingBy(ServiceItemPlanDO::getRelationType));
|
|
|
for (String key:planListMap.keySet()){
|
|
|
List<ServiceItemPlanDO> planDOS = planListMap.get(key);
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("signId",signId);
|
|
|
json.put("serviceItemId",planDOS.get(0).getServiceItemId());
|
|
|
json.put("code",key);
|
|
|
json.put("name",planDOS.get(0).getName());
|
|
|
String completeTime = "";
|
|
|
String planTime = "";
|
|
|
int total = planDOS.size();
|
|
|
int complete = 0;
|
|
|
for (ServiceItemPlanDO planDO:planDOS){
|
|
|
if("1".equals(planDO.getStatus())){
|
|
|
complete++;
|
|
|
if(completeTime.compareTo(planDO.getCompleteTime())<0){
|
|
|
completeTime = planDO.getCompleteTime();
|
|
|
}
|
|
|
}else {
|
|
|
if("".equals(planTime)){
|
|
|
planTime = planDO.getPlanTime();
|
|
|
}else if(planTime.compareTo(planDO.getPlanTime())>0){
|
|
|
planTime = planDO.getPlanTime();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
json.put("total",total);
|
|
|
json.put("complete",complete);
|
|
|
json.put("completeTime",completeTime);
|
|
|
json.put("planTime",planTime);
|
|
|
ja.add(json);
|
|
|
}
|
|
|
return ja;
|
|
|
}
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
String ss = "";
|
|
|
String time1 = "2023-10-28";
|
|
|
String time2 = "2023-10-29";
|
|
|
String time3 = "2023-10-30";
|
|
|
System.out.println(ss.compareTo(time1));
|
|
|
System.out.println(time2.compareTo(time1));
|
|
|
System.out.println(time2.compareTo(time2));
|
|
|
System.out.println(time2.compareTo(time3));
|
|
|
}
|
|
|
|
|
|
//添加项目执行计划
|
|
|
public void addPlans(String signId,String patient,String packageId){
|
|
|
try {
|
|
|
String sql = "SELECT i.name,i.code,c.* from base_service_package_item i,base_service_item_config c " +
|
|
|
"WHERE i.service_package_id='"+packageId+"' and i.id = c.server_item_id ";
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
List<ServiceItemPlanDO> planDOList = new ArrayList<>();
|
|
|
for (Map<String,Object> map:list){
|
|
|
String name = map.get("name")+"";
|
|
|
String id = map.get("id")+"";
|
|
|
String code = map.get("code")+"";
|
|
|
String template_code = map.get("template_code")+"";
|
|
|
String server_item_id = map.get("server_item_id")+"";
|
|
|
String plan_start_time_type = map.get("plan_start_time_type")+"";//计划开始时间类型
|
|
|
String server_count = map.get("server_count")+"";//服务次数
|
|
|
String frequency_code = map.get("frequency_code")+"";//频次
|
|
|
List<String> timeList = new ArrayList<>();
|
|
|
if(StringUtils.isBlank(template_code)||"null".equals(template_code)){
|
|
|
LocalDateTime localDateTime = LocalDateTime.now();
|
|
|
int addNum = Integer.parseInt(plan_start_time_type);
|
|
|
localDateTime = localDateTime.plusDays(addNum);
|
|
|
timeList = CronUtils.getExecutionTimeByNum(frequency_code,Integer.parseInt(server_count),localDateTime);
|
|
|
}
|
|
|
for (String time :timeList){
|
|
|
ServiceItemPlanDO planDO = new ServiceItemPlanDO();
|
|
|
planDO.setPlanTime(time);
|
|
|
planDO.setPatient(patient);
|
|
|
planDO.setName(name);
|
|
|
planDO.setStatus("0");
|
|
|
planDO.setServicePackId(packageId);
|
|
|
planDO.setServiceItemId(server_item_id);
|
|
|
planDO.setItemConfigId(id);
|
|
|
planDO.setRelationType(code);
|
|
|
planDO.setSignId(signId);
|
|
|
planDOList.add(planDO);
|
|
|
}
|
|
|
}
|
|
|
serviceItemPlanDao.save(planDOList);
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//给分配者发送消息
|