|
@ -0,0 +1,1750 @@
|
|
|
package com.yihu.jw.door.service;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.yihu.jw.doctor.dao.BaseDoctorDao;
|
|
|
import com.yihu.jw.door.dao.*;
|
|
|
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
|
|
|
import com.yihu.jw.entity.base.im.ConsultDo;
|
|
|
import com.yihu.jw.entity.base.im.ConsultTeamDo;
|
|
|
import com.yihu.jw.entity.base.patient.BasePatientDO;
|
|
|
import com.yihu.jw.entity.door.*;
|
|
|
import com.yihu.jw.im.dao.ConsultDao;
|
|
|
import com.yihu.jw.im.dao.ConsultTeamDao;
|
|
|
import com.yihu.jw.im.util.ImUtil;
|
|
|
import com.yihu.jw.message.dao.MessageDao;
|
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
|
import com.yihu.jw.util.common.IdCardUtil;
|
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
|
import jxl.Workbook;
|
|
|
import jxl.write.*;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
|
|
import org.jsoup.Jsoup;
|
|
|
import org.jsoup.nodes.Document;
|
|
|
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.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import javax.transaction.Transactional;
|
|
|
import java.io.*;
|
|
|
import java.lang.Boolean;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
import java.util.zip.ZipEntry;
|
|
|
import java.util.zip.ZipOutputStream;
|
|
|
|
|
|
/**
|
|
|
* Created by wxw on 2019/3/18.
|
|
|
*
|
|
|
* @author wxw.
|
|
|
*/
|
|
|
@Service
|
|
|
@Transactional
|
|
|
public class DoorOrderService {
|
|
|
|
|
|
private Logger logger = LoggerFactory.getLogger(DoorOrderService.class);
|
|
|
|
|
|
/* @Value("${server.server_url}")
|
|
|
private String wxServerUrl;*/
|
|
|
//图片服务地址
|
|
|
@Value("${fastDFS.fastdfs_file_url}")
|
|
|
private String imgUrlDomain;
|
|
|
@Autowired
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
@Autowired
|
|
|
private WlyyDoorConclusionDao doorConclusionDao;
|
|
|
@Autowired
|
|
|
private DoorServiceOrderDao doorServiceOrderDao;
|
|
|
@Autowired
|
|
|
private DoctorRegistrationTempService templateService;
|
|
|
@Autowired
|
|
|
private ObjectMapper objectMapper;
|
|
|
@Autowired
|
|
|
private WlyyDoorFeeDetailDao doorFeeDetailDao;
|
|
|
@Autowired
|
|
|
private WlyyDoorDoctorDao doorDoctorDao;
|
|
|
@Autowired
|
|
|
private WlyyDoorPatientConfirmLogDao confirmLogDao;
|
|
|
@Autowired
|
|
|
private WlyyDoorDoctorStatusDao doctorStatusDao;
|
|
|
@Autowired
|
|
|
private BaseDoctorDao doctorDao;
|
|
|
/* @Autowired
|
|
|
private ServerPackageItemPatientDao serverPackageItemPatientDao;
|
|
|
@Autowired
|
|
|
private DmJobService dmJobService;*/
|
|
|
@Autowired
|
|
|
private WlyyDoorServiceOrderService wlyyDoorServiceOrderService;
|
|
|
@Autowired
|
|
|
private BasePatientDao patientInfoService;
|
|
|
@Autowired
|
|
|
private DoorServiceVoucherDao doorServiceVoucherDao;
|
|
|
/* @Autowired
|
|
|
private PushMsgTask pushMsgTask;
|
|
|
@Autowired
|
|
|
WeiXinAccessTokenUtils tokenUtils;
|
|
|
@Autowired
|
|
|
private WechatTemplateConfigDao templateConfigDao;*/
|
|
|
@Autowired
|
|
|
private ImUtil imUtill;
|
|
|
@Autowired
|
|
|
private ConsultDao consultDao;
|
|
|
@Autowired
|
|
|
private ConsultTeamDao consultTeamDao;
|
|
|
|
|
|
@Autowired
|
|
|
private MessageDao messageDao;
|
|
|
@Autowired
|
|
|
private WlyyDoorPrescriptionDao doorPrescriptionDao;
|
|
|
@Autowired
|
|
|
private WlyyDoorServiceOrderDao wlyyDoorServiceOrderDao;
|
|
|
@Autowired
|
|
|
private WlyyDoorFeeDetailDao wlyyDoorFeeDetailDao;
|
|
|
|
|
|
/**
|
|
|
* 顶部状态栏订单各分类总条数
|
|
|
* @param doctor
|
|
|
* @param type
|
|
|
* @return
|
|
|
*/
|
|
|
public Map<String, String> getNumGroupByStatus(String doctor, Integer type) {
|
|
|
String sql = "SELECT a.status, COUNT(DISTINCT a.id) as num FROM wlyy_door_service_order a " ;
|
|
|
|
|
|
//计算代预约记录个状态数
|
|
|
if(type != null && type == 3){
|
|
|
sql += "LEFT JOIN wlyy_door_doctor d on d.order_id = a.id WHERE a.type=3 and a.proxy_patient = ? and a.proxy_patient = ? group BY a.status";
|
|
|
}else{
|
|
|
sql += "LEFT JOIN wlyy_door_doctor d on d.order_id = a.id WHERE (d.doctor =? or a.doctor = ?) group BY a.status";
|
|
|
}
|
|
|
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql, doctor,doctor);
|
|
|
Map<String, String> map = new HashMap<>();
|
|
|
list.stream().forEach(one -> {
|
|
|
map.put(exchangeKeyName(String.valueOf(one.get("status"))), String.valueOf(one.get("num")));
|
|
|
});
|
|
|
if (!map.containsKey("cancelOrder")) {
|
|
|
map.put("cancelOrder", "0");
|
|
|
}
|
|
|
if (!map.containsKey("sendOrder")) {
|
|
|
map.put("sendOrder", "0");
|
|
|
}
|
|
|
if (!map.containsKey("waitingOrder")) {
|
|
|
map.put("waitingOrder", "0");
|
|
|
}
|
|
|
if (!map.containsKey("serviceOrder")) {
|
|
|
map.put("serviceOrder", "0");
|
|
|
}
|
|
|
if (!map.containsKey("payment")) {
|
|
|
map.put("payment", "0");
|
|
|
}
|
|
|
if (!map.containsKey("supplement")) {
|
|
|
map.put("supplement", "0");
|
|
|
}
|
|
|
if (!map.containsKey("completed")) {
|
|
|
map.put("completed", "0");
|
|
|
}
|
|
|
if(!map.containsKey("exampaperstatus")){
|
|
|
map.put("exampaperstatus", "0");
|
|
|
}
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
private String exchangeKeyName(String status) {
|
|
|
String key;
|
|
|
switch (status) {
|
|
|
case "-1":
|
|
|
key = "cancelOrder";
|
|
|
break;
|
|
|
case "1":
|
|
|
key = "sendOrder";
|
|
|
break;
|
|
|
case "2" :
|
|
|
key = "waitingOrder";
|
|
|
break;
|
|
|
case "3" :
|
|
|
key = "serviceOrder";
|
|
|
break;
|
|
|
case "4" :
|
|
|
key = "payment";
|
|
|
break;
|
|
|
case "5" :
|
|
|
key = "supplement";
|
|
|
break;
|
|
|
case "6" :
|
|
|
key = "completed";
|
|
|
break;
|
|
|
case "7" :
|
|
|
key = "exampaperstatus";
|
|
|
break;
|
|
|
default:
|
|
|
key = status;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
return key;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 根据接单医生code获取最近一次服务orderId
|
|
|
* @param doctor
|
|
|
* @return
|
|
|
*/
|
|
|
public String getOrderIdByDoctor(String doctor) {
|
|
|
String sql = "SELECT id as orderId from wlyy_door_service_order where doctor=? and status in(2,3,4,5,6) ORDER BY patient_expected_serve_time desc,update_time desc,create_time desc, status ASC limit 1";
|
|
|
String orderId = jdbcTemplate.queryForObject(sql, String.class, new Object[]{doctor});
|
|
|
return orderId;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 根据orderId获取工单服务小结
|
|
|
* @param orderId
|
|
|
* @param flag 是否获取模板
|
|
|
* @return
|
|
|
*/
|
|
|
public WlyyDoorConclusionDO getDoorConclusion(String orderId, Boolean flag){
|
|
|
WlyyDoorConclusionDO doorConclusion = doorConclusionDao.findByOrderId(orderId);
|
|
|
WlyyDoorServiceOrderDO one = doorServiceOrderDao.findOne(orderId);
|
|
|
if (flag && null != one) {
|
|
|
String doctor = one.getDoctor();
|
|
|
// 获取医生模板信息 doctor = xx
|
|
|
List<Map<String, Object>> registrationTempData = templateService.getListByDoctorCode(doctor, "");
|
|
|
if (null == doorConclusion) {
|
|
|
doorConclusion = new WlyyDoorConclusionDO();
|
|
|
BasePatientDO patient = patientInfoService.findById(one.getPatient());
|
|
|
if (patient != null) {
|
|
|
doorConclusion.setOrderId(orderId);
|
|
|
doorConclusion.setPatient(patient.getId());
|
|
|
doorConclusion.setPatientName(patient.getName());
|
|
|
doorConclusion.setAge(IdCardUtil.getAgeByIdcardOrBirthday(patient.getIdcard(),patient.getBirthday()));
|
|
|
doorConclusion.setSex(IdCardUtil.getSexNameForIdcard_new(patient.getIdcard()));
|
|
|
doorConclusion.setIdcard(patient.getIdcard());
|
|
|
doorConclusion.setPatientPhone(patient.getMobile());
|
|
|
doorConclusion.setAddress(one.getServeAddress());
|
|
|
}
|
|
|
// 设置供史者信息
|
|
|
doorConclusion.setProxyPatientName(one.getProxyPatientName());
|
|
|
doorConclusion.setProxyPatientPhone(one.getPatientPhone());
|
|
|
doorConclusion.setProxyPatientRelation(one.getPatientRelation());
|
|
|
//获取居民上次服务小结内容
|
|
|
List<WlyyDoorConclusionDO> patientLastConclusionList = doorConclusionDao.findByPatient(one.getPatient());
|
|
|
if(patientLastConclusionList.size() > 0){
|
|
|
doorConclusion.setPatientLastConclusion(patientLastConclusionList.get(0));
|
|
|
}
|
|
|
}
|
|
|
doorConclusion.setTemplate(registrationTempData);
|
|
|
}
|
|
|
return doorConclusion;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 根据工单id获取服务工单-服务项价格,按status分组,1-居民新增(预约),2-医生新增,3-医生删除
|
|
|
* @param orderId
|
|
|
* @return
|
|
|
*/
|
|
|
public List<Map<String, Object>> getDoorFeeDetailGroupByStatus(String orderId) {
|
|
|
String sql = "SELECT d.id, d.status,d.name,d.code,sum(d.number) num,fee,sum(d.number)*fee sum from wlyy_door_fee_detail d where order_id=? and type=1 GROUP BY status,code";
|
|
|
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql, orderId);
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取指定工单下的服务医生
|
|
|
* @param orderId
|
|
|
* @return
|
|
|
*/
|
|
|
public List<Map<String, Object>> getDoorServiceDoctor(String orderId) {
|
|
|
String sql = "SELECT dd.id as id,CONCAT(d.`name`,' (',dd.doctor_job_name,')') as name, dd.doctor from wlyy_door_doctor dd join wlyy_doctor d on d.`code` = dd.doctor WHERE order_id=?";
|
|
|
List<Map<String, Object>> mapList = jdbcTemplate.queryForList(sql, orderId);
|
|
|
return mapList;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 根据id获取服务工单信息
|
|
|
* @param id
|
|
|
* @return
|
|
|
*/
|
|
|
public WlyyDoorServiceOrderDO getDoorServiceOrderById(String id, Integer level) throws Exception {
|
|
|
WlyyDoorServiceOrderDO doorServiceOrder = this.doorServiceOrderDao.findOne(id);
|
|
|
if (null == doorServiceOrder) {
|
|
|
return null;
|
|
|
}
|
|
|
BasePatientDO patient = patientInfoService.findById(doorServiceOrder.getPatient());
|
|
|
if (patient != null) {
|
|
|
String sex = IdCardUtil.getSexForIdcard_new(patient.getIdcard());
|
|
|
int age = IdCardUtil.getAgeByIdcardOrBirthday(patient.getIdcard(),patient.getBirthday());
|
|
|
doorServiceOrder.setSex("1".equals(sex) ? "男" : "2".equals(sex) ? "女" : "未知");
|
|
|
doorServiceOrder.setAge(age);
|
|
|
doorServiceOrder.setPhoto(patient.getPhoto());
|
|
|
String typeValues = this.getTypeValueByPatientCode(patient.getId());
|
|
|
doorServiceOrder.setTypeValue(typeValues);
|
|
|
}
|
|
|
// 获取服务次数
|
|
|
Integer count = this.serviceCount(doorServiceOrder.getPatient());
|
|
|
Integer times = wlyyDoorServiceOrderService.countPatientDoorTimes(doorServiceOrder.getPatient());
|
|
|
List<WlyyDoorDoctorDO> djDetailList = this.djDetailList(id,level,times);
|
|
|
doorServiceOrder.setDjDetailList(djDetailList);
|
|
|
List<Map<String, Object>> feeDetailDOS = this.getDoorFeeDetailGroupByStatus(id);
|
|
|
String jsonData = this.serverPackagePriceByOrderId(id);
|
|
|
if (null != feeDetailDOS && feeDetailDOS.size() > 0) {
|
|
|
// 设置服务项及费用信息
|
|
|
doorServiceOrder.setDoorFeeDetailList(feeDetailDOS);
|
|
|
}
|
|
|
|
|
|
// 服务工单关联的医护人员
|
|
|
List<Map<String, Object>> doorServiceDoctors = this.getDoorServiceDoctor(id);
|
|
|
if (null != doorServiceDoctors && doorServiceDoctors.size() > 0) {
|
|
|
doorServiceOrder.setDoctors(doorServiceDoctors);
|
|
|
}
|
|
|
|
|
|
//获取咨询
|
|
|
ConsultDo consult = consultDao.queryByRelationCode(id);
|
|
|
if (null != consult) {
|
|
|
doorServiceOrder.setSessionId(doorServiceOrder.getProxyPatient() + "_" + consult.getId() + "_" + doorServiceOrder.getNumber() + "_" + consult.getType());
|
|
|
}
|
|
|
|
|
|
// 设置服务小结
|
|
|
WlyyDoorConclusionDO doorConclusion = this.getDoorConclusion(id, true);
|
|
|
if (null == doorConclusion) {
|
|
|
doorConclusion = new WlyyDoorConclusionDO();
|
|
|
}
|
|
|
doorConclusion.setServiceCount(count);
|
|
|
doorServiceOrder.setDoorConclusion(doorConclusion);
|
|
|
|
|
|
//获取上门前后开方详情
|
|
|
List<WlyyDoorPrescriptionDO> doorBeforePrescriptionDOList = doorPrescriptionDao.findByOrderIdAndIsAfterDoor(id, 1);
|
|
|
List<WlyyDoorPrescriptionDO> doorAfterPrescriptionDOList = doorPrescriptionDao.findByOrderIdAndIsAfterDoor(id, 2);
|
|
|
doorServiceOrder.setPrescriptionDOList(doorBeforePrescriptionDOList);
|
|
|
doorServiceOrder.setAfterPrescriptionList(doorAfterPrescriptionDOList);
|
|
|
|
|
|
return doorServiceOrder;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 门牌地址解析
|
|
|
* @param url
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public String urlAnalysis(String url)throws Exception{
|
|
|
Document doc = Jsoup.connect(url).get();
|
|
|
String html = doc.toString();
|
|
|
int start = html.indexOf("href=\"");
|
|
|
int end = html.indexOf("\"}");
|
|
|
|
|
|
int ed = url.indexOf("com");
|
|
|
String ym = url.substring(0,ed+3);
|
|
|
String path = html.substring(start+6,end);
|
|
|
Document d = Jsoup.connect(ym+path).get();
|
|
|
return d.select("div.dzksfd1_lz2").eq(1).text();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 签到保存
|
|
|
* @param orderId
|
|
|
* @param signTime
|
|
|
* @param signWay
|
|
|
* @param signLocation
|
|
|
* @param signImg
|
|
|
* @return
|
|
|
*/
|
|
|
public WlyyDoorServiceOrderDO signIn(String orderId, String signTime, Integer signWay, String signLocation, String signImg, String twoDimensionalCode) throws Exception {
|
|
|
WlyyDoorServiceOrderDO doorServiceOrder = this.doorServiceOrderDao.findOne(orderId);
|
|
|
doorServiceOrder.setDoctorSignTime(DateUtil.strToDate(signTime));
|
|
|
doorServiceOrder.setDoctorSignWay(signWay);
|
|
|
// 签到方式-2扫码时,需要去解析地址
|
|
|
doorServiceOrder.setDoctorSignLocation(signLocation);
|
|
|
doorServiceOrder.setDoctorSignImg(StringUtils.isEmpty(signImg) ? null : signImg);
|
|
|
|
|
|
|
|
|
if(signWay == 4 ){//扫码签到
|
|
|
if (twoDimensionalCode.equals(doorServiceOrder.getNumber())){
|
|
|
this.setUpdateColumnInfo(doorServiceOrder);
|
|
|
doorServiceOrder = doorServiceOrderDao.save(doorServiceOrder);
|
|
|
// 修改医生上门服务工单状态 4服务中
|
|
|
this.updateDispatchStatusBySystem(doorServiceOrder.getDoctor(), 4);
|
|
|
return doorServiceOrder;
|
|
|
}else {
|
|
|
logger.info("扫码签到失败");
|
|
|
return null;
|
|
|
}
|
|
|
}else {
|
|
|
this.setUpdateColumnInfo(doorServiceOrder);
|
|
|
doorServiceOrder = doorServiceOrderDao.save(doorServiceOrder);
|
|
|
// 修改医生上门服务工单状态 4服务中
|
|
|
this.updateDispatchStatusBySystem(doorServiceOrder.getDoctor(), 4);
|
|
|
return doorServiceOrder;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 编辑保存服务工单小结
|
|
|
* @param model
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public WlyyDoorConclusionDO updateDoorConclusion(String model, Integer examPapeStatus) throws Exception {
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd"));
|
|
|
WlyyDoorConclusionDO doorConclusion = objectMapper.readValue(model, WlyyDoorConclusionDO.class);
|
|
|
WlyyDoorServiceOrderDO one = doorServiceOrderDao.findOne(doorConclusion.getOrderId());
|
|
|
BaseDoctorDO doctorVO = doctorDao.findById(one.getDoctor());
|
|
|
if (doorConclusion != null && StringUtils.isNotEmpty(doorConclusion.getId())) {
|
|
|
doorConclusion.setUpdateTime(new Date());
|
|
|
doorConclusion.setUpdateUser(one.getDoctor());
|
|
|
doorConclusion.setUpdateUserName(null != doctorVO ? doctorVO.getName() : null);
|
|
|
} else {
|
|
|
doorConclusion.setCreateTime(new Date());
|
|
|
doorConclusion.setUpdateTime(new Date());
|
|
|
doorConclusion.setCreateUser(one.getDoctor());
|
|
|
doorConclusion.setCreateUserName(null != doctorVO ? doctorVO.getName() : null);
|
|
|
}
|
|
|
doorConclusionDao.save(doorConclusion);
|
|
|
// 设置是否需要上传补录报告
|
|
|
one.setExamPaperStatus(examPapeStatus);
|
|
|
one.setConclusionStatus(2);
|
|
|
doorServiceOrderDao.save(one);
|
|
|
return doorConclusion;
|
|
|
}
|
|
|
|
|
|
public WlyyDoorServiceOrderDO acceptOrder1(String orderId,String jobCode,String jobCodeName,int hospitalLevel ) throws Exception{
|
|
|
WlyyDoorServiceOrderDO doorServiceOrder = doorServiceOrderDao.findOne(orderId);
|
|
|
if (null == doorServiceOrder) {
|
|
|
throw new Exception("该工单不存在");
|
|
|
}
|
|
|
doorServiceOrder.setDoctorArrivingTime(doorServiceOrder.getPatientExpectedServeTime());
|
|
|
doorServiceOrder.setStatus(WlyyDoorServiceOrderDO.Status.accept.getType()); // 2-待(医生)接单,3-待服务
|
|
|
this.updateDispatchStatusBySystem(doorServiceOrder.getDoctor(), 3);
|
|
|
// this.updateServiceResponseTime(orderId);
|
|
|
doorServiceOrder.setServiceResponseTime(new Date());
|
|
|
|
|
|
//新增工单医生关联关系
|
|
|
JSONObject jsonObjectParam = new JSONObject();
|
|
|
JSONObject doc = new JSONObject();
|
|
|
doc.put("doctor",doorServiceOrder.getDoctor());
|
|
|
doc.put("doctorName",doorServiceOrder.getDoctorName());
|
|
|
doc.put("hospitalLevel",hospitalLevel);
|
|
|
doc.put("doctorJobCode",jobCode);
|
|
|
doc.put("doctorJobName",jobCodeName);
|
|
|
JSONArray docArr = new JSONArray();
|
|
|
docArr.add(doc);
|
|
|
jsonObjectParam.put("doctorArr",docArr);
|
|
|
if (wlyyDoorServiceOrderService.orderWithDoctorAdd(new JSONObject(), jsonObjectParam, doorServiceOrder)) return null;
|
|
|
|
|
|
doorServiceOrderDao.save(doorServiceOrder);
|
|
|
|
|
|
// this.messageDao.orderMessageDel(doorServiceOrder.getDoctor(),orderId);
|
|
|
|
|
|
if(doorServiceOrder.getType() == null|| doorServiceOrder.getType() != 3) {
|
|
|
//获取咨询
|
|
|
ConsultTeamDo consultTeam = consultTeamDao.queryByRelationCode(orderId);
|
|
|
consultTeam.setDoctor(doorServiceOrder.getDoctor());
|
|
|
consultTeam.setDoctorName(doorServiceOrder.getDoctorName());
|
|
|
consultTeamDao.save(consultTeam);
|
|
|
|
|
|
String sessionId = doorServiceOrder.getPatient() + "_" + consultTeam.getConsult() + "_" + doorServiceOrder.getNumber() + "_" + consultTeam.getType();
|
|
|
//成功创建服务工单后,居民所在机构调度员向居民发起一条通知服务消息
|
|
|
|
|
|
// 发送IM消息通知患者医生已接单
|
|
|
String noticeContent = "我已接受您的服务工单预约," + doorServiceOrder.getDoctorName() + "医生正在为您服务!";
|
|
|
wlyyDoorServiceOrderService.qucikSendIM(doorServiceOrder.getId(), doorServiceOrder.getDispatcher(), "智能助手", "1", noticeContent);
|
|
|
// 发送居民上门服务简要信息
|
|
|
JSONObject orderInfoContent = wlyyDoorServiceOrderService.queryOrderCardInfo(doorServiceOrder);
|
|
|
orderInfoContent.put("re_msg_type", 0);
|
|
|
wlyyDoorServiceOrderService.qucikSendIM(doorServiceOrder.getId(), doorServiceOrder.getDispatcher(), "智能助手", "2101", orderInfoContent.toJSONString());
|
|
|
}
|
|
|
|
|
|
return doorServiceOrder;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 接单
|
|
|
* @param orderId
|
|
|
*/
|
|
|
public void acceptOrder(String orderId,String jobCode,String jobCodeName,int hospitalLevel ) throws Exception {
|
|
|
|
|
|
WlyyDoorServiceOrderDO doorServiceOrder = acceptOrder1(orderId, jobCode, jobCodeName, hospitalLevel);
|
|
|
if(doorServiceOrder==null){
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// 发送微信模板消息通知患者医生已接单
|
|
|
BasePatientDO patient = patientInfoService.findById(doorServiceOrder.getPatient());
|
|
|
// 获取微信模板
|
|
|
ConsultDo consult = consultDao.queryByRelationCode(orderId);
|
|
|
try{
|
|
|
/* WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_process_feedback","smyyyjjd");
|
|
|
String first = templateConfig.getFirst();
|
|
|
first = first.replace("key1",(patient.getName()==null?"":patient.getName()));
|
|
|
first = first.replace("key2", null != doorServiceOrder.getDoctorName() ? doorServiceOrder.getDoctorName() : "");
|
|
|
String keyword1 = templateConfig.getKeyword1();
|
|
|
org.json.JSONObject json = new org.json.JSONObject();
|
|
|
json.put("first", first);
|
|
|
json.put("keyword1", DateUtil.dateToStrShort(new Date()));
|
|
|
json.put("keyword2", "上门服务已接单");
|
|
|
json.put("url", templateConfig.getUrl());
|
|
|
json.put("remark", templateConfig.getRemark());
|
|
|
if(consult != null) {
|
|
|
json.put("consult", consult.getCode());
|
|
|
}
|
|
|
logger.info("上门服务已接单推送前");
|
|
|
pushMsgTask.putWxMsg(tokenUtils.getAccessToken(), 30, patient.getOpenid(), patient.getName(), json);
|
|
|
logger.info("上门服务已接单推送后");*/
|
|
|
}catch (Exception e) {
|
|
|
logger.error(e.getMessage());
|
|
|
}
|
|
|
|
|
|
// 待接单消息设为已操作, 434 医生接单-- 王五接受了服务工单12345678
|
|
|
/* List<Message> messages = messageDao.queryByRelationCodeAndTypeIn(orderId,new Integer[]{403,407});
|
|
|
if(CollectionUtils.isEmpty(messages)){
|
|
|
logger.error("当前工单没有医生待接单消息!orderId:" + orderId);
|
|
|
} else {
|
|
|
messages.forEach(
|
|
|
message -> {
|
|
|
if (message.getType() == 403) {
|
|
|
message.setTitle("医生接单");
|
|
|
message.setContent(doorServiceOrder.getDispatcherName() + "接受了服务工单"+ doorServiceOrder.getNumber());
|
|
|
message.setType(434);
|
|
|
message.setReceiver(doorServiceOrder.getDispatcher());
|
|
|
message.setSender(doorServiceOrder.getDoctor());
|
|
|
message.setCreateTime(new Date());
|
|
|
}else{
|
|
|
message.setOver("0");
|
|
|
}
|
|
|
messageDao.save(message);
|
|
|
}
|
|
|
);
|
|
|
}*/
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 拒单
|
|
|
* @param orderId
|
|
|
* @param reason
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public void refuseOrder(String receiver, String orderId, String reason) throws Exception {
|
|
|
WlyyDoorServiceOrderDO doorServiceOrder = doorServiceOrderDao.findOne(orderId);
|
|
|
if (null == doorServiceOrder) {
|
|
|
throw new Exception("该工单不存在");
|
|
|
}
|
|
|
//给代预约医生发消息
|
|
|
if (doorServiceOrder.getType() != null && doorServiceOrder.getType() == 3) {
|
|
|
this.createMessage(doorServiceOrder.getId(), "system", doorServiceOrder.getProxyPatient(), 403, "代预约服务工单重新派单", doorServiceOrder.getPatientName() + "的代预约服务工单需重新派单,请您前往处理");
|
|
|
} else {
|
|
|
/* this.messageDao.orderMessageDel(doorServiceOrder.getDoctor(),orderId);
|
|
|
if(StringUtils.isNotBlank(doorServiceOrder.getDispatcher())){
|
|
|
// 派单消息
|
|
|
this.createMessage(doorServiceOrder.getId(), "system", doorServiceOrder.getDispatcher(), 404, "服务工单拒单待重新派单", doorServiceOrder.getDoctorName() + "拒绝了" + doorServiceOrder.getProxyPatientName() + "的服务预约申请,请重新派单");
|
|
|
|
|
|
// 调度员-派单-实时工单消息:435 医生拒单-- 王五拒绝了服务工单12345678
|
|
|
List<Message> messages = messageDao.queryByRelationCodeAndTypeIn(orderId, new Integer[]{431, 433});
|
|
|
if (CollectionUtils.isEmpty(messages)) {
|
|
|
logger.error("当前工单没有医生待接单消息!orderId:" + orderId);
|
|
|
} else {
|
|
|
Message message = messages.get(0);
|
|
|
message.setTitle("医生拒单");
|
|
|
message.setContent(doorServiceOrder.getDoctorName() + "拒绝了服务工单" + doorServiceOrder.getNumber() + ", 请重新派单");
|
|
|
message.setType(435);
|
|
|
message.setReceiver(doorServiceOrder.getDispatcher());
|
|
|
message.setSender(doorServiceOrder.getDoctor());
|
|
|
message.setCreateTime(new Date());
|
|
|
messageDao.save(message);
|
|
|
}
|
|
|
}*/
|
|
|
}
|
|
|
doorServiceOrder.setDoctor(null);
|
|
|
doorServiceOrder.setDoctorName(null);
|
|
|
doorServiceOrder.setStatus(WlyyDoorServiceOrderDO.Status.waitForSend.getType()); // 设置为1-待(调度员)派单
|
|
|
doorServiceOrder.setCancelReason(reason); // 拒绝原因
|
|
|
doorServiceOrder.setCancelTime(new Date());
|
|
|
|
|
|
doorServiceOrderDao.save(doorServiceOrder);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 添加【工单派单,转单】等系统消息
|
|
|
* @param orderId
|
|
|
* @param sender
|
|
|
* @param receiver
|
|
|
* @param Content
|
|
|
*/
|
|
|
public void createMessage(String orderId,String sender,String receiver,int type,String title,String Content){
|
|
|
/* Message message= new Message();
|
|
|
message.setCzrq(new Date());
|
|
|
message.setCreateTime(new Date());
|
|
|
message.setRead(1);
|
|
|
message.setState(1);
|
|
|
message.setRelationCode(orderId);
|
|
|
message.setOver("1");
|
|
|
message.setReceiver(receiver);
|
|
|
message.setSender(sender);
|
|
|
message.setCode(getCode());
|
|
|
message.setTitle(title);
|
|
|
message.setContent(Content);
|
|
|
//消息类型:401为资质申请审核
|
|
|
message.setType(type);
|
|
|
message.setDel("1");
|
|
|
messageDao.save(message);*/
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取工单列表
|
|
|
* @param orderId
|
|
|
* @param patientName
|
|
|
* @param patientPhone
|
|
|
* @param hospitalCode
|
|
|
* @param status
|
|
|
* @param createTimeStart
|
|
|
* @param createTimeEnd
|
|
|
* @param page
|
|
|
* @param pageSize
|
|
|
* @param type
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject getDoorOrderList(String orderId, String patientName, String patientPhone, String hospitalCode,
|
|
|
StringBuffer status, String createTimeStart, String createTimeEnd, String serverDoctorName,
|
|
|
String doctorCode, Integer examPaperStatus, Integer page, Integer pageSize, Integer type)throws Exception{
|
|
|
String sqlList = "select DISTINCT o.id as orderId,o.status,f.hospital,f.hospital_name as hospitalName1,o.is_trans_other_org,o.transed_org_code,h.name as hospitalName2,o.patient_name," +
|
|
|
" o.patient_phone,o.remark,o.serve_desc,o.create_time,o.patient as patientCode ,o.exam_paper_status as examPaperStatus,o.number as serverCode,o.total_fee,h.org_level as hosLevel, " +
|
|
|
"o.doctor, o.doctor_name as doctorName, o.doctor_type as doctorType "
|
|
|
;
|
|
|
String sqlCount = " select count(*) as total ";
|
|
|
String sql = " from wlyy_door_service_order o " +
|
|
|
" LEFT JOIN wlyy_sign_family f ON f.patient = o.patient AND f. STATUS = 1 AND f.expenses_status = 1 " +
|
|
|
" LEFT JOIN base_org h on h.code=o.hospital and h.del=1 "
|
|
|
+" LEFT JOIN wlyy_door_doctor d on d.order_id = o.id ";
|
|
|
|
|
|
sql+= " where 1=1 ";
|
|
|
if(!StringUtils.isEmpty(orderId)){
|
|
|
sql+=" and o.number = '"+orderId+"'";
|
|
|
}
|
|
|
if(!StringUtils.isEmpty(patientName)){
|
|
|
sql+=" and o.patient_name like '%"+patientName+"%'";
|
|
|
}
|
|
|
if(!StringUtils.isEmpty(patientPhone)){
|
|
|
sql+=" and o.patient_phone ='"+patientPhone+"'";
|
|
|
}
|
|
|
if(!StringUtils.isEmpty(hospitalCode)&&!"350200%".equals(hospitalCode)){
|
|
|
sql+=" and (f.hospital like '"+hospitalCode+"' or o.transed_org_code like '"+hospitalCode+"') ";
|
|
|
}
|
|
|
if(status!=null){
|
|
|
sql+=" and o.status in ("+status+")";
|
|
|
}
|
|
|
if(!StringUtils.isEmpty(createTimeStart)){
|
|
|
sql+=" and o.create_time >='"+createTimeStart+"'";
|
|
|
}
|
|
|
if(!StringUtils.isEmpty(createTimeEnd)){
|
|
|
sql+=" and o.create_time <='"+createTimeEnd+"'";
|
|
|
}
|
|
|
if(!StringUtils.isEmpty(serverDoctorName)){
|
|
|
sql+=" and d.doctor_name like '%"+serverDoctorName+"%'";
|
|
|
}
|
|
|
//获取医生代预约记录
|
|
|
if(type != null && type == 3 ){
|
|
|
sql += " and o.type = " + type + " and o.proxy_patient = '" + doctorCode + "'";
|
|
|
}else if(!StringUtils.isEmpty(doctorCode)){
|
|
|
sql+=" and (d.doctor='"+doctorCode+"' or o.doctor='"+doctorCode+"')";
|
|
|
}
|
|
|
if(examPaperStatus!=null){
|
|
|
sql+=" and o.conclusion_status =1 ";
|
|
|
}
|
|
|
List<Map<String,Object>> rstotal = jdbcTemplate.queryForList(sqlCount+sql);
|
|
|
sql+=" order by o.create_time desc LIMIT "+(page-1)*pageSize+","+pageSize;
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sqlList+sql);
|
|
|
Long count = 0L;
|
|
|
if(rstotal!=null&&rstotal.size()>0){
|
|
|
count = (Long) rstotal.get(0).get("total");
|
|
|
}
|
|
|
JSONArray jsonArray = new JSONArray();
|
|
|
for(Map<String,Object> one:list){
|
|
|
JSONObject object = new JSONObject();
|
|
|
object.put("id",one.get("orderId"));
|
|
|
object.put("serverCode",one.get("serverCode"));
|
|
|
Integer statustemp = Integer.valueOf(one.get("status")+"");
|
|
|
String statusName = "";
|
|
|
switch (statustemp){
|
|
|
case -1:statusName="已取消";break;
|
|
|
case 1:statusName="待派单";break;
|
|
|
case 2:statusName="待接单";break;
|
|
|
case 3:statusName="已接单";break;
|
|
|
case 4:statusName="待服务";break;
|
|
|
case 5:statusName="待评价";break;
|
|
|
case 6:statusName="已完成";break;
|
|
|
}
|
|
|
|
|
|
object.put("status",statustemp);
|
|
|
object.put("statusName",statusName);
|
|
|
//工单是否转给其他机构,0-不转,1-已转
|
|
|
String transOtherOrg = one.get("is_trans_other_org")+"";
|
|
|
Object hospitalName = null;
|
|
|
Object hospital = null;
|
|
|
if("0".equals(transOtherOrg)){
|
|
|
hospital = one.get("hospital");
|
|
|
hospitalName = one.get("hospitalName1");//签约表中的机构
|
|
|
}else if("1".equals(transOtherOrg)){
|
|
|
hospital = one.get("transed_org_code");
|
|
|
hospitalName = one.get("hospitalName2");//转机构中的机构
|
|
|
}else if("null".equals(transOtherOrg)){
|
|
|
hospital = one.get("hospital");
|
|
|
hospitalName = one.get("hospitalName1");//签约表中的机构
|
|
|
}
|
|
|
object.put("hospital",hospital);
|
|
|
object.put("hospitalName",hospitalName);
|
|
|
object.put("patient",one.get("patientCode"));
|
|
|
object.put("patientName",one.get("patient_name"));
|
|
|
object.put("patientPhone",one.get("patient_phone"));
|
|
|
object.put("remark",one.get("remark"));
|
|
|
object.put("serveDesc",one.get("serve_desc"));
|
|
|
object.put("hosLevel",one.get("hosLevel"));
|
|
|
Date date = (Date)one.get("create_time");
|
|
|
object.put("createTime",DateUtil.dateToStr(date,"yyyy-MM-dd HH:mm:ss"));
|
|
|
object.put("examPaperStatus",one.get("examPaperStatus"));
|
|
|
//服务人员
|
|
|
List<WlyyDoorDoctorDO> doorDoctorDOs = doorDoctorDao.findByOrderId(one.get("orderId")+"");
|
|
|
String serverDoctors = "";
|
|
|
for (WlyyDoorDoctorDO temp : doorDoctorDOs) {
|
|
|
serverDoctors += "、" + temp.getDoctorName();
|
|
|
}
|
|
|
object.put("serverDoctors",serverDoctors.startsWith("、")?serverDoctors.substring(1):serverDoctors);
|
|
|
object.put("totalFee",one.get("total_fee"));
|
|
|
List<WlyyDoorFeeDetailDO> feeDetailDOs = doorFeeDetailDao.findByOrderIdAndType(one.get("orderId")+"", 1);
|
|
|
List<Map<String,Object>> feeDetailResultList = new ArrayList();
|
|
|
for(WlyyDoorFeeDetailDO d:feeDetailDOs){
|
|
|
Map<String,Object> map = new HashMap<>();
|
|
|
map.put("code",d.getCode());
|
|
|
map.put("name",d.getName());
|
|
|
map.put("fee",d.getFee());
|
|
|
map.put("number",d.getNumber());
|
|
|
feeDetailResultList.add(map);
|
|
|
}
|
|
|
object.put("feeDetailResultList",feeDetailResultList);
|
|
|
|
|
|
// 获取或者基本信息
|
|
|
BasePatientDO patient = patientInfoService.findById(String.valueOf(one.get("patientCode")));
|
|
|
if (patient != null) {
|
|
|
String sex = IdCardUtil.getSexForIdcard(patient.getIdcard());
|
|
|
object.put("sex", "1".equals(sex) ? "男" : "2".equals(sex) ? "女" : "未知");
|
|
|
object.put("age", IdCardUtil.getAgeByIdcardOrBirthday(patient.getIdcard(),patient.getBirthday()));
|
|
|
object.put("photo", patient.getPhoto());
|
|
|
|
|
|
String typeValues = this.getTypeValueByPatientCode(patient.getId());
|
|
|
object.put("typeValue", typeValues);
|
|
|
}
|
|
|
String id = one.get("orderId").toString();
|
|
|
WlyyDoorServiceOrderDO doorServiceOrder = this.doorServiceOrderDao.findOne(id);
|
|
|
//获取咨询
|
|
|
ConsultDo consult = consultDao.queryByRelationCode(id);
|
|
|
if (null != consult) {
|
|
|
doorServiceOrder.setSessionId(doorServiceOrder.getProxyPatient() + "_" + consult.getId() + "_" + doorServiceOrder.getNumber() + "_" + consult.getType());
|
|
|
}
|
|
|
object.put("sessionId",doorServiceOrder.getSessionId());
|
|
|
|
|
|
// 获取服务次数
|
|
|
Integer serviceCount = this.serviceCount(doorServiceOrder.getPatient());
|
|
|
object.put("serviceCount", serviceCount);
|
|
|
|
|
|
//添加服务医生
|
|
|
object.put("doctorName", doorServiceOrder.getDoctorName());
|
|
|
object.put("doctorType", doorServiceOrder.getDoctorType());
|
|
|
object.put("type", doorServiceOrder.getType());
|
|
|
jsonArray.add(object);
|
|
|
}
|
|
|
|
|
|
JSONObject object = new JSONObject();
|
|
|
object.put("total",count);
|
|
|
object.put("detailModelList",jsonArray);
|
|
|
object.put("currPage",page);
|
|
|
object.put("pageSize",pageSize);
|
|
|
return object;
|
|
|
}
|
|
|
|
|
|
public void doorOrderOutExcel(String orderId,String patientName,String patientPhone,String hospitalCode,
|
|
|
Integer status,String createTimeStart,String createTimeEnd,String serverDoctorName,String doctorCode,Integer examPaperStatus, HttpServletResponse response)throws Exception{
|
|
|
WritableWorkbook book = null;
|
|
|
OutputStream os = null;
|
|
|
try {
|
|
|
String sql = "select DISTINCT o.id as orderId,o.number,o.status,f.hospital,f.hospital_name as hospitalName1,o.is_trans_other_org," +
|
|
|
" o.transed_org_code,h.name as hospitalName2,o.patient_name,f.idcard,o.doctor_sign_time,o.total_fee," +
|
|
|
" o.patient_phone,o.remark,o.create_time,o.patient as patientCode from wlyy_door_service_order o " +
|
|
|
" LEFT JOIN wlyy_sign_family f ON f.patient = o.patient AND f. STATUS = 1 AND f.expenses_status = 1 " +
|
|
|
" LEFT JOIN base_org h on h.code=o.transed_org_code and h.del=1 " ;
|
|
|
if(!StringUtils.isEmpty(serverDoctorName)){
|
|
|
sql+=" RIGHT JOIN wlyy_door_doctor d on d.order_id = o.id";
|
|
|
}
|
|
|
|
|
|
sql+=" where 1=1 ";
|
|
|
if (!StringUtils.isEmpty(orderId)) {
|
|
|
sql += " and o.id = '" + orderId + "'";
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(patientName)) {
|
|
|
sql += " and o.patient_name like '%" + patientName + "%'";
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(patientPhone)) {
|
|
|
sql += " and o.patient_phone ='" + patientPhone + "'";
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(hospitalCode) && !hospitalCode.contains("%")) {
|
|
|
sql += " and (f.hospital = '" + hospitalCode + "' or o.transed_org_code='" + hospitalCode + "') ";
|
|
|
}else if(StringUtils.isNotBlank(hospitalCode) && hospitalCode.contains("%")){
|
|
|
sql += " and (f.hospital like '" + hospitalCode + "' or o.transed_org_code like '" + hospitalCode + "') ";
|
|
|
}
|
|
|
if (status != null) {
|
|
|
sql += " and o.status ='" + status + "'";
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(createTimeStart)) {
|
|
|
sql += " and o.create_time >='" + createTimeStart + "'";
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(createTimeEnd)) {
|
|
|
sql += " and o.create_time <='" + createTimeEnd + "'";
|
|
|
}
|
|
|
if(!StringUtils.isEmpty(serverDoctorName)){
|
|
|
sql+=" and d.doctor_name like '%"+serverDoctorName+"%'";
|
|
|
}
|
|
|
if(!StringUtils.isEmpty(doctorCode)){
|
|
|
sql+=" and o.doctor='"+doctorCode+"'";
|
|
|
}
|
|
|
if(examPaperStatus!=null){
|
|
|
sql+=" and o.exam_paper_status='"+examPaperStatus+"'";
|
|
|
}
|
|
|
sql += " order by o.create_time desc ";
|
|
|
|
|
|
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
response.setContentType("application/vnd.ms-excel");
|
|
|
Date date = new Date();
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
|
|
String fileName = "上门服务工单列表";
|
|
|
response.setHeader("Content-Disposition", "attachment; filename="
|
|
|
+ new String(fileName.getBytes("UTF-8"), "ISO8859-1") + "_" + sdf.format(date) + ".xls");
|
|
|
os = response.getOutputStream();
|
|
|
book = Workbook.createWorkbook(os);
|
|
|
WritableSheet sheet = book.createSheet("按工单", 0);
|
|
|
WritableCellFormat cellFormat = new WritableCellFormat();
|
|
|
cellFormat.setAlignment(Alignment.CENTRE);
|
|
|
sheet.addCell(new Label(0, 0, "服务工单号",cellFormat));
|
|
|
sheet.addCell(new Label(1, 0, "工单状态",cellFormat));
|
|
|
sheet.addCell(new Label(2, 0, "服务机构",cellFormat));
|
|
|
sheet.addCell(new Label(3, 0, "创建时间",cellFormat));
|
|
|
sheet.addCell(new Label(4, 0, "居民姓名",cellFormat));
|
|
|
sheet.addCell(new Label(5, 0, "性别",cellFormat));
|
|
|
sheet.addCell(new Label(6, 0, "年龄",cellFormat));
|
|
|
sheet.addCell(new Label(7, 0, "身份证号",cellFormat));
|
|
|
sheet.addCell(new Label(8, 0, "联系方式",cellFormat));
|
|
|
sheet.addCell(new Label(9, 0, "服务时间",cellFormat));
|
|
|
sheet.addCell(new Label(10, 0, "服务医生",cellFormat));
|
|
|
sheet.addCell(new Label(11, 0, "医生职称",cellFormat));
|
|
|
sheet.addCell(new Label(12, 0, "支付费用",cellFormat));
|
|
|
sheet.addCell(new Label(13, 0, "服务内容",cellFormat));
|
|
|
sheet.addCell(new Label(14, 0, "服务项价格",cellFormat));
|
|
|
int b = 0;
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
String orderIdTemp = list.get(i).get("orderId") + "";
|
|
|
//获取服务项费用和医生出诊费
|
|
|
List<WlyyDoorFeeDetailDO> feeDetailDOs = doorFeeDetailDao.findByOrderIdAndType(orderIdTemp, 1);
|
|
|
feeDetailDOs.addAll(doorFeeDetailDao.findByOrderIdAndType(orderIdTemp, 2));
|
|
|
Integer a = feeDetailDOs.size();
|
|
|
if(a>1){
|
|
|
|
|
|
for (int j = 0; j < 13; j++) {
|
|
|
sheet.mergeCells(j, b + 1, j, b + a);
|
|
|
}
|
|
|
}
|
|
|
a = (a==0?1:a);
|
|
|
String serverCode = list.get(i).get("number") + "";
|
|
|
sheet.addCell(new Label(0, b + 1, serverCode,cellFormat));//服务工单号
|
|
|
Integer statustemp = Integer.valueOf(list.get(i).get("status") + "");
|
|
|
String statusName = "";
|
|
|
switch (statustemp) {
|
|
|
case -1:
|
|
|
statusName = "已取消";
|
|
|
break;
|
|
|
case 1:
|
|
|
statusName = "待派单";
|
|
|
break;
|
|
|
case 2:
|
|
|
statusName = "待接单";
|
|
|
break;
|
|
|
case 3:
|
|
|
statusName = "已接单";
|
|
|
break;
|
|
|
case 4:
|
|
|
statusName = "待服务";
|
|
|
break;
|
|
|
case 5:
|
|
|
statusName = "待评价";
|
|
|
break;
|
|
|
case 6:
|
|
|
statusName = "已完成";
|
|
|
break;
|
|
|
}
|
|
|
sheet.addCell(new Label(1, b + 1, statusName,cellFormat));//工单状态
|
|
|
//工单是否转给其他机构,0-不转,1-已转
|
|
|
String transOtherOrg = list.get(i).get("is_trans_other_org") + "";
|
|
|
String hospitalName = null;
|
|
|
if ("0".equals(transOtherOrg)) {
|
|
|
hospitalName = list.get(i).get("hospitalName1") + "";//签约表中的机构
|
|
|
} else if ("1".equals(transOtherOrg)) {
|
|
|
hospitalName = list.get(i).get("hospitalName2") + "";//转机构中的机构
|
|
|
}else if("null".equals(transOtherOrg)){
|
|
|
hospitalName = list.get(i).get("hospitalName1") + "";//签约表中的机构
|
|
|
}
|
|
|
|
|
|
sheet.addCell(new Label(2, b + 1, hospitalName,cellFormat));//服务机构
|
|
|
Date createTime = (Date) list.get(i).get("create_time");
|
|
|
sheet.addCell(new Label(3, b + 1, DateUtil.dateToStr(createTime, "yyyy/MM/dd HH:mm"),cellFormat));//创建时间
|
|
|
sheet.addCell(new Label(4, b + 1, list.get(i).get("patient_name") + "",cellFormat));//居民姓名
|
|
|
String idcard = list.get(i).get("idcard") + "";
|
|
|
Integer age = IdCardUtil.getAgeForIdcard(idcard);
|
|
|
String sex = IdCardUtil.getSexNameForIdcard_new(idcard);
|
|
|
sheet.addCell(new Label(5, b + 1, sex,cellFormat));//性别
|
|
|
sheet.addCell(new Label(6, b + 1, age + "",cellFormat));//年龄
|
|
|
sheet.addCell(new Label(7, b + 1, idcard,cellFormat));//身份证
|
|
|
sheet.addCell(new Label(8, b + 1, list.get(i).get("patient_phone") + "",cellFormat));//联系方式
|
|
|
Date doctorSignTime = list.get(i).get("doctor_sign_time") != null ? (Date) list.get(i).get("doctor_sign_time") : null;
|
|
|
sheet.addCell(new Label(9, b + 1, doctorSignTime != null ? DateUtil.dateToStr(doctorSignTime, "yyyy/MM/dd HH:mm") : "",cellFormat));//服务时间
|
|
|
List<WlyyDoorDoctorDO> doorDoctorDOs = doorDoctorDao.findByOrderId(orderIdTemp);
|
|
|
String serverDoctors = "";
|
|
|
String serverDoctorJobName = "";
|
|
|
for (WlyyDoorDoctorDO one : doorDoctorDOs) {
|
|
|
serverDoctors += "/" + one.getDoctorName();
|
|
|
serverDoctorJobName += "/" + one.getDoctorJobName();
|
|
|
}
|
|
|
sheet.addCell(new Label(10, b + 1, serverDoctors.startsWith("/") ? serverDoctors.substring(1) : serverDoctors,cellFormat));//服务医生
|
|
|
sheet.addCell(new Label(11, b + 1, serverDoctorJobName.startsWith("/") ? serverDoctorJobName.substring(1) : serverDoctorJobName,cellFormat));//医生职称
|
|
|
sheet.addCell(new Label(12, b + 1, list.get(i).get("total_fee")!=null?list.get(i).get("total_fee")+"":""));//医生职称
|
|
|
|
|
|
for (int d = 0; d < feeDetailDOs.size(); d++) {
|
|
|
sheet.addCell(new Label(13, b + 1 + d, feeDetailDOs.get(d).getName(),cellFormat));//服务内容
|
|
|
sheet.addCell(new Label(14, b + 1 + d, feeDetailDOs.get(d).getFee().toString(),cellFormat));//服务项价格
|
|
|
}
|
|
|
b = b + a;
|
|
|
}
|
|
|
}catch (IOException e){
|
|
|
e.printStackTrace();
|
|
|
}catch (WriteException e) {
|
|
|
e.printStackTrace();
|
|
|
}finally {
|
|
|
if(book!=null){
|
|
|
book.write();
|
|
|
book.close();
|
|
|
}
|
|
|
if(os!=null){
|
|
|
os.flush();
|
|
|
os.close();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 居民拍照确认
|
|
|
* @param orderId
|
|
|
* @param finishWay
|
|
|
* @param finishImg
|
|
|
* @param level
|
|
|
* @return
|
|
|
*/
|
|
|
public WlyyDoorServiceOrderDO savePatientSignOrCertificate(String orderId, Integer finishWay, String finishImg, Integer level) throws Exception {
|
|
|
WlyyDoorServiceOrderDO one = doorServiceOrderDao.findOne(orderId);
|
|
|
one.setPatientConfirmFinishWay(finishWay);
|
|
|
one.setPatientConfirmFinishImg(finishImg);
|
|
|
one.setStatus(WlyyDoorServiceOrderDO.Status.waitForCommnet.getType());
|
|
|
one.setPatientConfirmFinishTime(new Date());
|
|
|
// 更新记录
|
|
|
this.setUpdateColumnInfo(one);
|
|
|
// 计算保存服务总的支付费用
|
|
|
Integer times = wlyyDoorServiceOrderService.countPatientDoorTimes(one.getPatient());
|
|
|
String jsonData = this.serverPackagePriceByOrderId(orderId);
|
|
|
doorServiceOrderDao.save(one);
|
|
|
WlyyDoorServiceOrderDO doorServiceOrderDO = this.getDoorServiceOrderById(orderId, level);
|
|
|
|
|
|
// 发送微信通知 待付款
|
|
|
BasePatientDO patient = patientInfoService.findById(one.getPatient());
|
|
|
// 获取微信模板 smfwdwk-上门服务待付款
|
|
|
ConsultDo consult = consultDao.queryByRelationCode(orderId);
|
|
|
try {
|
|
|
/* WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_process_feedback","fwyspf");
|
|
|
String first = templateConfig.getFirst();
|
|
|
first = first.replace("key1", DateUtil.dateToStr(new Date(), "yyyy-MM-dd HH:mm"));
|
|
|
first = first .replace("key2", null != one.getDoctorName() ? one.getDoctorName() : "");
|
|
|
org.json.JSONObject json = new org.json.JSONObject();
|
|
|
json.put("first", first);
|
|
|
json.put("keyword1", DateUtil.dateToStrShort(new Date()));
|
|
|
json.put("keyword2", "服务医生评分");
|
|
|
json.put("url", templateConfig.getUrl());
|
|
|
json.put("remark", templateConfig.getRemark());
|
|
|
json.put("id",orderId);
|
|
|
//json.put("consult",consult.getCode());
|
|
|
WlyyDoorCommentDO wlyyDoorCommentDO = this.DoorCommentDao.selectCommentDoctor(patient.getCode(),orderId);
|
|
|
String finish="";
|
|
|
if(wlyyDoorCommentDO!=null){
|
|
|
finish = "0";
|
|
|
json.put("finish",finish);
|
|
|
}else {
|
|
|
finish = "1";
|
|
|
json.put("finish",finish);
|
|
|
}
|
|
|
pushMsgTask.putWxMsg(tokenUtils.getAccessToken(), 31, patient.getOpenid(), patient.getName(), json);*/
|
|
|
}catch (Exception e){
|
|
|
logger.error(e.getMessage());
|
|
|
}
|
|
|
return doorServiceOrderDO;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 医生补录报告
|
|
|
* @param orderId
|
|
|
* @param examPaperWay
|
|
|
* @param examPaperTime
|
|
|
* @param examPaperImg
|
|
|
* @return
|
|
|
*/
|
|
|
public WlyyDoorServiceOrderDO saveExamPaperInfo(String orderId, Integer examPaperWay, String examPaperTime, String examPaperImg, Integer level) throws Exception {
|
|
|
WlyyDoorServiceOrderDO one = doorServiceOrderDao.findOne(orderId);
|
|
|
one.setExamPaperUploadWay(examPaperWay);
|
|
|
one.setExamPaperUploadTime(DateUtil.strToDate(examPaperTime));
|
|
|
one.setExamPaperImgs(examPaperImg);
|
|
|
one.setExamPaperStatus(2);
|
|
|
// 更新记录
|
|
|
this.setUpdateColumnInfo(one);
|
|
|
doorServiceOrderDao.save(one);
|
|
|
return this.getDoorServiceOrderById(orderId, level);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 医生线下确认收款
|
|
|
* @param orderId
|
|
|
* @param level
|
|
|
*/
|
|
|
public WlyyDoorServiceOrderDO confirmReceipt(String orderId, Integer level) throws Exception {
|
|
|
WlyyDoorServiceOrderDO one = doorServiceOrderDao.findOne(orderId);
|
|
|
one.setPayWay(WlyyDoorServiceOrderDO.PayWay.offLine.getType()); // 1-微信支付,2-线下支付(居民自己向医院支付,具体怎么支付由医院来定)
|
|
|
one.setPayTime(new Date());
|
|
|
one.setStatus(WlyyDoorServiceOrderDO.Status.waitForCommnet.getType()); // 5-待评价
|
|
|
// 更新记录
|
|
|
this.setUpdateColumnInfo(one);
|
|
|
doorServiceOrderDao.save(one);
|
|
|
// 更新居民签约服务包服务项次数
|
|
|
this.reduceServiceItemTimes(serverPackagePriceByOrderId(orderId), one.getPatient());
|
|
|
|
|
|
// 发送微信消息通知--用户评价
|
|
|
/* BasePatientDO patient = patientInfoService.findById(one.getPatient());
|
|
|
// 获取微信模板 fwyspf-服务医生评分
|
|
|
ConsultDo consult = consultDao.queryByRelationCode(orderId);
|
|
|
try {
|
|
|
WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_process_feedback","fwyspf");
|
|
|
String first = templateConfig.getFirst();
|
|
|
first = first.replace("key1", DateUtil.dateToStr(new Date(), "yyyy-MM-dd HH:mm"));
|
|
|
first = first .replace("key2", null != one.getDoctorName() ? one.getDoctorName() : "");
|
|
|
String keyword1 = templateConfig.getKeyword1();
|
|
|
org.json.JSONObject json = new org.json.JSONObject();
|
|
|
json.put("first", first);
|
|
|
json.put("keyword1", DateUtil.dateToStrShort(new Date()));
|
|
|
json.put("keyword2", "服务医生评分");
|
|
|
json.put("url", templateConfig.getUrl());
|
|
|
json.put("remark", templateConfig.getRemark());
|
|
|
json.put("id",orderId);
|
|
|
//json.put("consult",consult.getCode());
|
|
|
WlyyDoorCommentDO wlyyDoorCommentDO = this.DoorCommentDao.selectCommentDoctor(patient.getCode(),orderId);
|
|
|
String finish="";
|
|
|
if(wlyyDoorCommentDO!=null){
|
|
|
finish = "0";
|
|
|
json.put("finish",finish);
|
|
|
}else {
|
|
|
finish = "1";
|
|
|
json.put("finish",finish);
|
|
|
}
|
|
|
pushMsgTask.putWxMsg(tokenUtils.getAccessToken(), 31, patient.getOpenid(), patient.getName(), json);
|
|
|
}catch (Exception e){
|
|
|
logger.error(e.getMessage());
|
|
|
}*/
|
|
|
return this.getDoorServiceOrderById(orderId, level);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 设置表修改时间
|
|
|
* @param one
|
|
|
* @return
|
|
|
*/
|
|
|
private void setUpdateColumnInfo(WlyyDoorServiceOrderDO one) {
|
|
|
one.setUpdateTime(new Date());
|
|
|
one.setUpdateUser(one.getDoctor());
|
|
|
one.setUpdateUserName(one.getDoctorName());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取该患者本年度服务次数
|
|
|
* @param patient
|
|
|
* @return
|
|
|
*/
|
|
|
public Integer serviceCount(String patient) {
|
|
|
String sql = "SELECT count(d.id) times FROM wlyy_door_doctor d where d.order_id in(SELECT id from wlyy_door_service_order WHERE DATE_FORMAT(doctor_sign_time, '%Y') = DATE_FORMAT(NOW(), '%Y') AND patient=?)";
|
|
|
Integer count = jdbcTemplate.queryForObject(sql, Integer.class, patient);
|
|
|
return count;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 修改预计到达时间
|
|
|
* @param orderId
|
|
|
* @param arrivingTime
|
|
|
* @return
|
|
|
*/
|
|
|
public WlyyDoorServiceOrderDO updateArrivingTime(String orderId, String arrivingTime) {
|
|
|
WlyyDoorServiceOrderDO one = doorServiceOrderDao.findOne(orderId);
|
|
|
one.setDoctorArrivingTime(arrivingTime);
|
|
|
this.setUpdateColumnInfo(one);
|
|
|
one = doorServiceOrderDao.save(one);
|
|
|
// 医生修改预计到达时间保存到日志表中
|
|
|
WlyyDoorPatientConfirmLogDO confirmLogDO = new WlyyDoorPatientConfirmLogDO();
|
|
|
confirmLogDO.setOrderId(one.getId());
|
|
|
confirmLogDO.setPatient(one.getPatient());
|
|
|
confirmLogDO.setPatientName(one.getPatientName());
|
|
|
confirmLogDO.setType(2); // 1-确认基础信息无误或变更,2-确认上门医生变更上门信息,3-同意工单转接
|
|
|
confirmLogDO.setDescription("医生修改预计到达时间");
|
|
|
confirmLogDO.setCreateTime(new Date());
|
|
|
confirmLogDO.setCreateUser(one.getDoctor());
|
|
|
confirmLogDO.setCreateUserName(one.getDoctorName());
|
|
|
confirmLogDao.save(confirmLogDO);
|
|
|
return one;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查看指定医生是否开启分派订单功能
|
|
|
* @param doctor
|
|
|
* @return
|
|
|
*/
|
|
|
public String findDispatchStatusByDoctor(String doctor) {
|
|
|
WlyyDoorDoctorStatusDO doctorSwitch = doctorStatusDao.findByDoctor(doctor);
|
|
|
BaseDoctorDO doctorVO = doctorDao.findById(doctor);
|
|
|
if (null == doctorSwitch) {
|
|
|
WlyyDoorDoctorStatusDO wlyyDoorDoctorStatusDO =new WlyyDoorDoctorStatusDO();
|
|
|
wlyyDoorDoctorStatusDO.setDoctor(doctor);
|
|
|
wlyyDoorDoctorStatusDO.setStatus(5);
|
|
|
wlyyDoorDoctorStatusDO.setCreateTime(new Date());
|
|
|
wlyyDoorDoctorStatusDO.setCreateUser(doctor);
|
|
|
wlyyDoorDoctorStatusDO.setCreateUserName(null != doctorVO ? doctorVO.getName() : null);
|
|
|
doctorStatusDao.save(wlyyDoorDoctorStatusDO);
|
|
|
return "0";
|
|
|
}
|
|
|
return doctorSwitch.getStatus() == 5 ? "0" : "1";
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 修改指定医生的分派订单开关,不存在该医生的开关,则创建
|
|
|
* @param doctor
|
|
|
* @param dispatchOrderStatus
|
|
|
*/
|
|
|
public void updateDispatchStatusByDoctor(String doctor, Integer dispatchOrderStatus) {
|
|
|
WlyyDoorDoctorStatusDO doctorSwitch = doctorStatusDao.findByDoctor(doctor);
|
|
|
BaseDoctorDO doctorVO = doctorDao.findById(doctor);
|
|
|
if (null != doctorSwitch) {
|
|
|
doctorSwitch.setStatus(dispatchOrderStatus);
|
|
|
doctorSwitch.setUpdateTime(new Date());
|
|
|
doctorSwitch.setCreateUser(doctor);
|
|
|
doctorSwitch.setCreateUserName(null != doctorVO ? doctorVO.getName() : null);
|
|
|
} else {
|
|
|
doctorSwitch = new WlyyDoorDoctorStatusDO();
|
|
|
doctorSwitch.setDoctor(doctor);
|
|
|
doctorSwitch.setStatus(dispatchOrderStatus);
|
|
|
doctorSwitch.setCreateTime(new Date());
|
|
|
doctorSwitch.setCreateUser(doctor);
|
|
|
doctorSwitch.setCreateUserName(null != doctorVO ? doctorVO.getName() : null);
|
|
|
}
|
|
|
doctorStatusDao.save(doctorSwitch);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 系统更新医生上门服务工单状态
|
|
|
* @param doctor
|
|
|
* @param dispatchOrderStatus
|
|
|
*/
|
|
|
public void updateDispatchStatusBySystem(String doctor, Integer dispatchOrderStatus) {
|
|
|
WlyyDoorDoctorStatusDO doctorSwitch = doctorStatusDao.findByDoctor(doctor);
|
|
|
if (null != doctorSwitch) {
|
|
|
doctorSwitch.setStatus(dispatchOrderStatus);
|
|
|
doctorSwitch.setUpdateTime(new Date());
|
|
|
doctorSwitch.setCreateUser("System");
|
|
|
doctorSwitch.setCreateUserName("System");
|
|
|
} else {
|
|
|
doctorSwitch = new WlyyDoorDoctorStatusDO();
|
|
|
doctorSwitch.setDoctor(doctor);
|
|
|
doctorSwitch.setStatus(dispatchOrderStatus);
|
|
|
doctorSwitch.setCreateTime(new Date());
|
|
|
doctorSwitch.setCreateUser("System");
|
|
|
doctorSwitch.setCreateUserName("System");
|
|
|
}
|
|
|
doctorStatusDao.save(doctorSwitch);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 更新调度员响应时间
|
|
|
* @param orderId
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public void updateDispatcherResponseTime(String orderId)throws Exception{
|
|
|
int t = doorServiceOrderDao.updateDispatcherResponseTime(orderId,new Date());
|
|
|
if(t<0){
|
|
|
throw new Exception("updateDispatcherResponseTime error!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 更新服务医生响应时间
|
|
|
* @param orderId
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public void updateServiceResponseTime(String orderId)throws Exception{
|
|
|
int t = doorServiceOrderDao.updateServiceResponseTime(orderId,new Date());
|
|
|
if(t<0){
|
|
|
throw new Exception("updateServiceResponseTime error!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 根据服务项计算服务费用
|
|
|
* @param jsonData 格式[{"itemCode":"","fee":"","number":""}]
|
|
|
* @param patient 居民code
|
|
|
* @return
|
|
|
*/
|
|
|
public Map<String, Object> countServerPackagePrice(String jsonData, String patient){
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
BigDecimal serverPackagePrice = new BigDecimal("0.00");
|
|
|
BigDecimal cashPrice = new BigDecimal("0.00");
|
|
|
//获取居民签约服务项及次数
|
|
|
// SignFamily signFamily = signFamilyDao.findByPatient(patient);
|
|
|
String sql = "SELECT ip.service_item_code as itemCode, sum(ip.service_times) as times FROM wlyy_server_package_patient pp , wlyy_server_package_item_patient ip " +
|
|
|
"where pp.`code` = ip.server_package_patient_code and pp.patient = '" + patient + "' and pp.hospital = '" + "" + "' and pp.`status` = 1 " +
|
|
|
// "where pp.`code` = ip.server_package_patient_code and pp.patient = '" + patient + "' and pp.hospital = '" + signFamily.getHospital() + "' and pp.`status` = 1 " +
|
|
|
"GROUP BY ip.service_item_code ";
|
|
|
List<Map<String, Object>> list =jdbcTemplate.query(sql, new BeanPropertyRowMapper(String.class));
|
|
|
|
|
|
JSONArray jsonArray = JSONArray.parseArray(jsonData);
|
|
|
for(Object o : jsonArray){
|
|
|
Boolean b = false;
|
|
|
BigDecimal times = null;
|
|
|
JSONObject jsonObject = (JSONObject) o;
|
|
|
String itemCode = jsonObject.getString("itemCode");
|
|
|
BigDecimal fee = jsonObject.getBigDecimal("fee");
|
|
|
BigDecimal number = jsonObject.getBigDecimal("number");
|
|
|
//遍历是否是居民签约的服务项,如果是,看还剩多少次数
|
|
|
for(Map<String, Object> m : list){
|
|
|
if((m.get(itemCode) + "").equals(itemCode)){
|
|
|
b = true;
|
|
|
times = (BigDecimal)map.get("times");
|
|
|
}
|
|
|
}
|
|
|
//判断服务包里面的次数是否够抵扣,不够的仍需支付
|
|
|
if(b){
|
|
|
if(times.compareTo(number) > -1) {
|
|
|
serverPackagePrice = serverPackagePrice.add(fee.multiply(number));
|
|
|
}else {
|
|
|
//还需另外支付次数
|
|
|
BigDecimal t = number.subtract(times);
|
|
|
cashPrice = cashPrice.add(fee.multiply(t));
|
|
|
}
|
|
|
}else {
|
|
|
cashPrice = cashPrice.add(fee.multiply(number));
|
|
|
}
|
|
|
}
|
|
|
map.put("serverPackagePrice", serverPackagePrice);
|
|
|
map.put("cashPrice", cashPrice);
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 更新居民签约服务包服务项次数
|
|
|
* @param itemInfo 格式[{"itemCode":"","fee":"","number":""}]
|
|
|
* @param patient 居民code
|
|
|
*/
|
|
|
public void reduceServiceItemTimes(String itemInfo, String patient){
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
//获取居民签约服务项及次数
|
|
|
// SignFamily signFamily = signFamilyDao.findByPatient(patient);
|
|
|
String sql = "SELECT ip.`code`,ip.service_item_code as itemCode, ip.service_times as times FROM wlyy_server_package_patient pp , wlyy_server_package_item_patient ip " +
|
|
|
// "where pp.`code` = ip.server_package_patient_code and pp.patient = '" + patient + "' and pp.hospital = '" + signFamily.getHospital() + "' and pp.`status` = 1 " +
|
|
|
"where pp.`code` = ip.server_package_patient_code and pp.patient = '" + patient + "' and pp.hospital = '" + "" + "' and pp.`status` = 1 " +
|
|
|
"order BY pp.end_time ";
|
|
|
List<Map<String, Object>> list =jdbcTemplate.query(sql, new BeanPropertyRowMapper(String.class));
|
|
|
|
|
|
JSONArray jsonArray = JSONArray.parseArray(itemInfo);
|
|
|
for(Object o : jsonArray) {
|
|
|
JSONObject jsonObject = (JSONObject) o;
|
|
|
String itemCode = jsonObject.getString("itemCode");
|
|
|
Integer number = jsonObject.getInteger("number");
|
|
|
//遍历是否是居民签约的服务项,如果是,看服务项次数够不够减,不够减的继续遍历其他服务项,够减则跳出循环更新次数
|
|
|
for (Map<String, Object> m : list) {
|
|
|
if ((m.get(itemCode) + "").equals(itemCode)) {
|
|
|
String itemPatientCode = map.get("code") + "";
|
|
|
Integer times = (Integer) map.get("times");
|
|
|
if (number <= times) {
|
|
|
// serverPackageItemPatientDao.updateTimesByCode(itemPatientCode, times - number);
|
|
|
break;
|
|
|
} else {
|
|
|
// serverPackageItemPatientDao.updateTimesByCode(itemPatientCode, 0);
|
|
|
number -= times;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取订单下服务包数量、单价
|
|
|
* @param orderId
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public String serverPackagePriceByOrderId(String orderId) throws Exception {
|
|
|
String sql = "SELECT d.code itemCode,sum(d.number) number,fee from wlyy_door_fee_detail d where order_id=? and d.status in(1,2) and type=1 GROUP BY code";
|
|
|
List<Map<String, Object>> mapList = jdbcTemplate.queryForList(sql, orderId);
|
|
|
return objectMapper.writeValueAsString(mapList);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 待支付总费用
|
|
|
* @param cashPrice
|
|
|
* @param orderId
|
|
|
* @param level
|
|
|
* @return
|
|
|
*/
|
|
|
public BigDecimal calculateCash(String cashPrice, String orderId, Integer level, Integer times) {
|
|
|
BigDecimal price = new BigDecimal(cashPrice);
|
|
|
List<WlyyDoorDoctorDO> doorDoctorDOList = doorDoctorDao.findByOrderId(orderId);
|
|
|
if (doorDoctorDOList != null && doorDoctorDOList.size() > 0) {
|
|
|
List<String> jobCodeList = doorDoctorDOList.stream().map(WlyyDoorDoctorDO::getDoctorJobCode).collect(Collectors.toList());
|
|
|
// Double jobFeeCost = dmJobService.getJobFeeCost(jobCodeList, level, times);
|
|
|
Double jobFeeCost = 120d;
|
|
|
if(null != jobFeeCost){
|
|
|
price = price.add(BigDecimal.valueOf(jobFeeCost));
|
|
|
}
|
|
|
}
|
|
|
return price;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 出诊费用详情
|
|
|
* @param orderId
|
|
|
* @param level
|
|
|
* @return
|
|
|
*/
|
|
|
public List<WlyyDoorDoctorDO> djDetailList(String orderId, Integer level, Integer times) {
|
|
|
List<WlyyDoorDoctorDO> djDetailList = new ArrayList<>();
|
|
|
List<WlyyDoorDoctorDO> doorDoctorDOList = doorDoctorDao.findByOrderId(orderId);
|
|
|
if (doorDoctorDOList != null && doorDoctorDOList.size() > 0) {
|
|
|
for(WlyyDoorDoctorDO wlyyDoorDoctorDO:doorDoctorDOList){
|
|
|
// Double jobFeeCost = dmJobService.getJobFee(wlyyDoorDoctorDO.getDoctorJobCode(), level, times);
|
|
|
Double jobFeeCost = 120d;
|
|
|
wlyyDoorDoctorDO.setJobFeeCost(jobFeeCost);
|
|
|
doorDoctorDao.save(wlyyDoorDoctorDO);
|
|
|
djDetailList.add(wlyyDoorDoctorDO);
|
|
|
}
|
|
|
}
|
|
|
return djDetailList;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取用户人群类型名称
|
|
|
* @param patientCode
|
|
|
* @return
|
|
|
*/
|
|
|
public String getTypeValueByPatientCode(String patientCode) {
|
|
|
List<String> typeValueList = doorServiceVoucherDao.findTypeValueByPatientCode(patientCode);
|
|
|
String typeValues = "";
|
|
|
if (typeValueList != null && typeValueList.size() > 0) {
|
|
|
typeValues = StringUtils.join(typeValueList, ",");
|
|
|
}
|
|
|
return typeValues;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 修改保存服务项
|
|
|
* @param jsonData
|
|
|
*/
|
|
|
@org.springframework.transaction.annotation.Transactional(rollbackFor = Exception.class)
|
|
|
public void updatePackageItemInfo(String jsonData) {
|
|
|
JSONObject jsonObjectParam = JSONObject.parseObject(jsonData);
|
|
|
String orderId = String.valueOf(jsonObjectParam.get("orderId"));
|
|
|
WlyyDoorServiceOrderDO order = doorServiceOrderDao.findOne(orderId);
|
|
|
// 删除出诊医生或服务项
|
|
|
wlyyDoorServiceOrderService.orderWithFeeDelete(jsonObjectParam,order);
|
|
|
// 更新服务包信息
|
|
|
wlyyDoorServiceOrderService.orderWithPackageItemFeeAdd(new JSONObject(), jsonObjectParam, order);
|
|
|
|
|
|
// 发送微信模板消息,通知居民服务项目已经变更(smyyyjjd-服务项目变更通知)
|
|
|
/* BasePatientDO patient = patientInfoService.findById(order.getProxyPatient());
|
|
|
ConsultDo consult = consultDao.queryByRelationCode(orderId);
|
|
|
Integer status = 0;
|
|
|
try{
|
|
|
|
|
|
WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_process_feedback","fwxmbgtz");
|
|
|
String first = templateConfig.getFirst();
|
|
|
first = first.replace("key1",(patient.getName()==null?"":patient.getName()));
|
|
|
first = first .replace("key2", null != order.getDoctorName() ? order.getDoctorName() : "");
|
|
|
String keyword1 = templateConfig.getKeyword1();
|
|
|
org.json.JSONObject json = new org.json.JSONObject();
|
|
|
json.put("first", first);
|
|
|
json.put("keyword1", DateUtil.dateToStrShort(new Date()));
|
|
|
json.put("keyword2", "服务项目变更确认");
|
|
|
json.put("url", templateConfig.getUrl());
|
|
|
json.put("remark", templateConfig.getRemark());
|
|
|
json.put("consult",consult.getCode());
|
|
|
json.put("status",status);
|
|
|
// pushMsgTask.putWxMsg(tokenUtils.getAccessToken(), 32, patient.getOpenid(), patient.getName(), json);
|
|
|
}catch (Exception e) {
|
|
|
logger.error(e.getMessage());
|
|
|
}*/
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取管理员端上门服务菜单分类
|
|
|
* @param hospital
|
|
|
* @return
|
|
|
*/
|
|
|
public Map<String,String> getAdministratorStatusBarNum(String hospital) {
|
|
|
String sql = " select o.`status`,count(o.id) as num from wlyy_door_service_order o LEFT JOIN wlyy_sign_family f ON f.patient = o.patient " +
|
|
|
"AND f. STATUS = 1 AND f.expenses_status = 1 LEFT JOIN base_org h on h.code=o.hospital and h.del=1 ";
|
|
|
if(!"350200%".equals(hospital)){
|
|
|
sql += " where (f.hospital like '" + hospital + "' or o.transed_org_code like '" + hospital + "') GROUP BY o.`status` ";
|
|
|
}else{
|
|
|
sql += " GROUP BY o.`status` ";
|
|
|
}
|
|
|
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
Map<String, String> map = new HashMap<>();
|
|
|
list.stream().forEach(one -> {
|
|
|
map.put(exchangeKeyName(String.valueOf(one.get("status"))), String.valueOf(one.get("num")));
|
|
|
});
|
|
|
if (!map.containsKey("cancelOrder")) {
|
|
|
map.put("cancelOrder", "0");
|
|
|
}
|
|
|
if (!map.containsKey("sendOrder")) {
|
|
|
map.put("sendOrder", "0");
|
|
|
}
|
|
|
if (!map.containsKey("waitingOrder")) {
|
|
|
map.put("waitingOrder", "0");
|
|
|
}
|
|
|
if (!map.containsKey("serviceOrder")) {
|
|
|
map.put("serviceOrder", "0");
|
|
|
}
|
|
|
if (!map.containsKey("payment")) {
|
|
|
map.put("payment", "0");
|
|
|
}
|
|
|
if (!map.containsKey("supplement")) {
|
|
|
map.put("supplement", "0");
|
|
|
}
|
|
|
if (!map.containsKey("completed")) {
|
|
|
map.put("completed", "0");
|
|
|
}
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
public WlyyDoorServiceOrderDO findById(String orderId) {
|
|
|
return doorServiceOrderDao.findOne(orderId);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 对mht模板文件的变量赋值
|
|
|
* @param doc
|
|
|
* @param orderId
|
|
|
* @return
|
|
|
*/
|
|
|
public String handleData(Document doc, String orderId) {
|
|
|
WlyyDoorServiceOrderDO orderDO = doorServiceOrderDao.findOne(orderId);
|
|
|
WlyyDoorConclusionDO conclusionDO = doorConclusionDao.findByOrderId(orderId);//808080f66e5efb24016e62838d77000a
|
|
|
String html = doc.toString();
|
|
|
//对各个字段赋值
|
|
|
html = html.replace("${name}", orderDO.getPatientName());
|
|
|
html = html.replace("${sex}",conclusionDO.getSex() == null ? "" : conclusionDO.getSex());
|
|
|
html = html.replace("${age}",conclusionDO.getAge() + "");
|
|
|
html = html.replace("${marriage}",conclusionDO.getMarriage() == null ? "" : conclusionDO.getMarriage());
|
|
|
html = html.replace("${profession}",conclusionDO.getProfession() == null ? "" : conclusionDO.getProfession());
|
|
|
html = html.replace("${nationa}", conclusionDO.getNationa() == null ? "" : conclusionDO.getNationa());
|
|
|
html = html.replace("${birthplace}",conclusionDO.getBirthPlace() == null ? "" : conclusionDO.getBirthPlace());
|
|
|
html = html.replace("${idcard}",conclusionDO.getIdcard() == null ? "" : conclusionDO.getIdcard());
|
|
|
html = html.replace("${company}",conclusionDO.getCompany() == null ? "" : conclusionDO.getCompany());
|
|
|
html = html.replace("${address}",conclusionDO.getAddress() == null ? "" : conclusionDO.getAddress());
|
|
|
html = html.replace("${phone}", conclusionDO.getPatientPhone() == null ? "" : conclusionDO.getPatientPhone());
|
|
|
html = html.replace("${count}", StringUtils.isBlank(conclusionDO.getServiceCount() + "") ? "" : conclusionDO.getServiceCount() + "");
|
|
|
html = html.replace("${proxypatientname}", conclusionDO.getProxyPatientName() == null ? "" : conclusionDO.getProxyPatientName());
|
|
|
html = html.replace("${proxypatientrelation}", conclusionDO.getProxyPatientRelation() == null ? "" : conclusionDO.getProxyPatientRelation());
|
|
|
html = html.replace("${proxypatientphone}", conclusionDO.getProxyPatientPhone() == null ? "" : conclusionDO.getProxyPatientPhone());
|
|
|
html = html.replace("${beforerecord}", conclusionDO.getBeforeRecord() == null ? "" : conclusionDO.getBeforeRecord());
|
|
|
html = html.replace("${presenillness}", conclusionDO.getPresenIllness() == null ? "" : conclusionDO.getPresenIllness());
|
|
|
html = html.replace("${familyillhistory}", conclusionDO.getFamilyIllHistory() == null ? "" : conclusionDO.getFamilyIllHistory());
|
|
|
html = html.replace("${physicalrecord}", conclusionDO.getPhysicalRecord() == null ? "" : conclusionDO.getPhysicalRecord());
|
|
|
html = html.replace("${assistantexamrecord}", conclusionDO.getAssistantExamRecord() == null ? "" : conclusionDO.getAssistantExamRecord());
|
|
|
html = html.replace("${diagnosticrecord}", conclusionDO.getDiagnosticRecord() == null ? "" : conclusionDO.getDiagnosticRecord());
|
|
|
html = html.replace("${examresult}",conclusionDO.getExamResult() == null ? "" : conclusionDO.getExamResult());
|
|
|
String imgsString = "";
|
|
|
if(StringUtils.isNotBlank(conclusionDO.getImgs())) {
|
|
|
String imgs = conclusionDO.getImgs();
|
|
|
String[] imgsArray;
|
|
|
if (imgs.contains(",")) {
|
|
|
imgsArray = imgs.split(",");
|
|
|
} else {
|
|
|
imgsArray = new String[]{imgs};
|
|
|
}
|
|
|
for (String img : imgsArray) {
|
|
|
imgsString += "<img width=80 height=100 src=" + imgUrlDomain + img + " > ";
|
|
|
}
|
|
|
}
|
|
|
html = html.replace("${imgs}", imgsString);
|
|
|
if(orderDO.getPatientConfirmFinishImg() != null) {
|
|
|
html = html.replace("${patientconfirmfinishimg}", "<img width=100 height=100 src=" + imgUrlDomain + orderDO.getPatientConfirmFinishImg() + " >");
|
|
|
}else {
|
|
|
html = html.replace("${patientconfirmfinishimg}","");
|
|
|
}
|
|
|
if(orderDO.getPatientConfirmFinishTime() != null) {
|
|
|
html = html.replace("${patientconfirmtime}", DateUtil.dateToStr(orderDO.getPatientConfirmFinishTime(), "yyyy年MM月dd日"));
|
|
|
}else {
|
|
|
html = html.replace("${patientconfirmtime}","");
|
|
|
}
|
|
|
html = html.replace("${updatetime}",DateUtil.dateToStr(conclusionDO.getUpdateTime(), "yyyy年MM月dd日"));
|
|
|
return html;
|
|
|
}
|
|
|
|
|
|
public int sendInformedConsent(String orderId , String serveDesc,String doctor) {
|
|
|
WlyyDoorServiceOrderDO doorServiceOrderDO = wlyyDoorServiceOrderDao.findOne(orderId);
|
|
|
String sql1 = "select fd.name name from wlyy_door_fee_detail fd LEFT JOIN wlyy_door_doctor dd ON fd.order_id = dd.order_id where fd.order_id = \""+ orderId +"\" AND fd.type = 1 group by code";
|
|
|
List<Map<String , Object>> list = jdbcTemplate.queryForList(sql1);
|
|
|
Object object = null;
|
|
|
JSONObject orderInfoContent = new JSONObject();
|
|
|
if(list.size()>0){
|
|
|
for (int i=0;i<list.size();i++) {
|
|
|
Map map=(Map)list.get(i);
|
|
|
Iterator iterator = map.keySet().iterator();
|
|
|
while (iterator.hasNext())
|
|
|
{
|
|
|
String key = (String) iterator.next();
|
|
|
object = map.get(key);
|
|
|
}
|
|
|
}
|
|
|
String str = object.toString();
|
|
|
String noticeContent = str;
|
|
|
orderInfoContent.put("noticeContent", noticeContent);//服务项目
|
|
|
orderInfoContent.put("orderId", orderId);
|
|
|
orderInfoContent.put("contentSize", list.size());
|
|
|
}else {
|
|
|
orderInfoContent.put("noticeContent", "居民未选择");//服务项目
|
|
|
orderInfoContent.put("orderId", orderId);
|
|
|
orderInfoContent.put("contentSize", list.size());
|
|
|
}
|
|
|
int success = this.qucikSendIM(doorServiceOrderDO.getId(), doctor, "智能助手","2105", orderInfoContent.toString());
|
|
|
String sql = "UPDATE `wlyy_door_service_order` SET order_info =1 WHERE id = \""+orderId+"\";";
|
|
|
jdbcTemplate.execute(sql);
|
|
|
return success;
|
|
|
}
|
|
|
|
|
|
public int updateServiceStatus(String orderId) {
|
|
|
String sql = "UPDATE `wlyy_door_service_order` SET service_status =2 WHERE id = ?";
|
|
|
Object [] params = new Object[]{orderId};
|
|
|
int a = jdbcTemplate.update(sql , params);
|
|
|
return a;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 【调度员,医生】快速发送IM消息
|
|
|
* @param orderId
|
|
|
* @param sendId
|
|
|
* @param sendName
|
|
|
* @param content
|
|
|
* @return
|
|
|
*/
|
|
|
public int qucikSendIM(String orderId,String sendId,String sendName,String contentType,String content) {
|
|
|
int result = -1;
|
|
|
ConsultDo consult = consultDao.queryByRelationCode(orderId);
|
|
|
if (null == consult) {
|
|
|
logger.error("当前工单未关联咨询,工单id:" + orderId);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
WlyyDoorServiceOrderDO wlyyDoorServiceOrder = null;
|
|
|
String response = null;
|
|
|
|
|
|
if(org.apache.commons.lang3.StringUtils.isBlank(sendId)){
|
|
|
wlyyDoorServiceOrder = wlyyDoorServiceOrderDao.findOne(orderId);
|
|
|
response = imUtill.sendTopicIM(wlyyDoorServiceOrder.getDispatcher(), "智能助手", consult.getId(), contentType, content, null);
|
|
|
}else{
|
|
|
response = imUtill.sendTopicIM(sendId, sendName, consult.getId(), contentType, content, null);
|
|
|
}
|
|
|
JSONObject resObj = JSONObject.parseObject(response);
|
|
|
if (resObj.getIntValue("status") == -1) {
|
|
|
logger.error("知情同意书消息发送失败:" + resObj.getString("message"));
|
|
|
return result;
|
|
|
}
|
|
|
result = 1;
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
public File writeWordFile(List<String> orderId,HttpServletResponse response) throws Exception {
|
|
|
String zipFileName = "服务小结";
|
|
|
long time = System.currentTimeMillis();
|
|
|
String exportConclusionList = time+"exportList";
|
|
|
String path = this.getClass().getResource("/").getPath() + exportConclusionList;
|
|
|
File file = new File(path);
|
|
|
// 删除文件夹、文件
|
|
|
if (file.exists()) {
|
|
|
if (file != null){
|
|
|
deleteFolder(file);
|
|
|
file.mkdir();
|
|
|
}else {
|
|
|
file.delete();
|
|
|
file.mkdir();
|
|
|
}
|
|
|
}else {
|
|
|
file.mkdir();
|
|
|
}
|
|
|
int j =1;
|
|
|
for (int i = 0; i < orderId.size(); i++) {
|
|
|
WlyyDoorServiceOrderDO orderDO = this.findById(orderId.get(i));
|
|
|
// 文件名
|
|
|
WlyyDoorConclusionDO conclusionDO = doorConclusionDao.findByOrderId(orderId.get(i));
|
|
|
if (conclusionDO == null){
|
|
|
continue;
|
|
|
}
|
|
|
String fileName = orderDO.getPatientName()+ j + "服务小结.doc";;
|
|
|
j = j + 1;
|
|
|
fileName = java.net.URLEncoder.encode(fileName,"UTF-8");
|
|
|
fileName = java.net.URLDecoder.decode(fileName,"UTF-8");
|
|
|
response.setHeader("Content-Disposition", "attachment; filename=" + fileName);
|
|
|
String pathName = this.getClass().getResource("/").getPath() + "conclusion.mht";
|
|
|
System.out.println("路径pathName:" + pathName);
|
|
|
Document doc = Jsoup.parse(new File(pathName), "UTF-8");
|
|
|
String html = this.handleData(doc, orderId.get(i));//16
|
|
|
BufferedWriter bw = new BufferedWriter(new FileWriter(path+"/"+fileName));//创建的文件
|
|
|
bw.write(html);
|
|
|
bw.close();
|
|
|
File zipFile = new File(path.replace(exportConclusionList, "") + zipFileName + ".zip");
|
|
|
if (zipFile.exists()) {
|
|
|
zipFile.delete();
|
|
|
}
|
|
|
}
|
|
|
// 打包文件夹
|
|
|
if (fileToZip(path, path.replace(exportConclusionList, ""), zipFileName)) {
|
|
|
return new File(path.replace(exportConclusionList, "") + zipFileName + ".zip");
|
|
|
} else {
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
/**
|
|
|
* 打包文件夹
|
|
|
*
|
|
|
* @param sourcePath
|
|
|
* @param zipPath
|
|
|
* @param zipName
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public boolean fileToZip(String sourcePath, String zipPath, String zipName) throws Exception {
|
|
|
File sourceFile = new File(sourcePath);
|
|
|
File zipFile = new File(zipPath + File.separator + zipName + ".zip");
|
|
|
File[] files = sourceFile.listFiles();
|
|
|
FileOutputStream fos = new FileOutputStream(zipFile);
|
|
|
ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(fos));
|
|
|
|
|
|
if (files != null) {
|
|
|
byte[] bufs = new byte[1024 * 10];
|
|
|
for (int i = 0; i < files.length; i++) {
|
|
|
// 创建ZIP实体,并添加进压缩包
|
|
|
ZipEntry zipEntry = new ZipEntry(files[i].getName());
|
|
|
zos.putNextEntry(zipEntry);
|
|
|
// 读取待压缩的文件并写进压缩包里
|
|
|
FileInputStream fis = new FileInputStream(files[i]);
|
|
|
BufferedInputStream bis = new BufferedInputStream(fis, 1024 * 10);
|
|
|
int read = 0;
|
|
|
while ((read = bis.read(bufs, 0, 1024 * 10)) != -1) {
|
|
|
zos.write(bufs, 0, read);
|
|
|
}
|
|
|
bis.close();
|
|
|
fis.close();
|
|
|
}
|
|
|
deleteFolder(sourceFile);
|
|
|
}
|
|
|
|
|
|
zos.close();
|
|
|
fos.close();
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 把is写入到对应的word输出流os中
|
|
|
* 不考虑异常的捕获,直接抛出
|
|
|
* @param is
|
|
|
* @param os
|
|
|
* @throws IOException
|
|
|
*/
|
|
|
private void inputStreamToWord(InputStream is, OutputStream os) throws IOException {
|
|
|
POIFSFileSystem fs = new POIFSFileSystem();
|
|
|
//对应于org.apache.poi.hdf.extractor.WordDocument
|
|
|
fs.createDocument(is, "WordDocument");
|
|
|
fs.writeFilesystem(os);
|
|
|
os.close();
|
|
|
is.close();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 把输入流里面的内容以UTF-8编码当文本取出。
|
|
|
* 不考虑异常,直接抛出
|
|
|
* @param ises
|
|
|
* @return
|
|
|
* @throws IOException
|
|
|
*/
|
|
|
private String getContent(InputStream... ises) throws IOException {
|
|
|
if (ises != null) {
|
|
|
StringBuilder result = new StringBuilder();
|
|
|
BufferedReader br;
|
|
|
String line;
|
|
|
for (InputStream is : ises) {
|
|
|
br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
|
|
|
while ((line=br.readLine()) != null) {
|
|
|
result.append(line);
|
|
|
}
|
|
|
}
|
|
|
return result.toString();
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
public static void deleteFolder(File folder){
|
|
|
File[] files = folder.listFiles();
|
|
|
if (files != null){
|
|
|
for(File f: files){
|
|
|
if (f.isDirectory()){
|
|
|
deleteFolder(f);
|
|
|
}else {
|
|
|
f.delete();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
folder.delete();
|
|
|
}
|
|
|
|
|
|
public List<Map<String,Object>> getOrderIdList(Integer status,String doctorCode){
|
|
|
String sqlList = "select DISTINCT o.id as orderId";
|
|
|
String sql = " from wlyy_door_service_order o " +
|
|
|
" LEFT JOIN wlyy_sign_family f ON f.patient = o.patient AND f. STATUS = 1 AND f.expenses_status = 1 " +
|
|
|
" LEFT JOIN base_org h on h.code=o.hospital and h.del=1 "
|
|
|
+" LEFT JOIN wlyy_door_doctor d on d.order_id = o.id ";
|
|
|
sql+= " where 1=1 ";
|
|
|
if(status == 6){//已完成状态
|
|
|
sql+=" and o.status ='"+status+"'";
|
|
|
}else {//5是待补录状态
|
|
|
sql+=" and o.conclusion_status =1 ";
|
|
|
}
|
|
|
if(!StringUtils.isEmpty(doctorCode)){
|
|
|
sql+=" and (d.doctor='"+doctorCode+"' or o.doctor='"+doctorCode+"')";
|
|
|
}
|
|
|
sql+=" order by o.create_time desc ";
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sqlList+sql);
|
|
|
return list;
|
|
|
}
|
|
|
}
|