|  | @ -6,13 +6,16 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 | 
	
		
			
				|  |  | import com.yihu.jw.doctor.dao.BaseDoctorDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.door.dao.*;
 | 
	
		
			
				|  |  | import com.yihu.jw.door.util.MessageUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.door.util.StreamUtil;
 | 
	
		
			
				|  |  | 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.entity.hospital.message.SystemMessageDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.message.dao.SystemMessageDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.prescription.dao.PrescriptionDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.im.dao.ConsultDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.im.dao.ConsultTeamDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.im.util.ImUtil;
 | 
	
	
		
			
				|  | @ -23,7 +26,6 @@ import com.yihu.jw.util.date.DateUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.util.http.HttpClientUtil;
 | 
	
		
			
				|  |  | import jxl.Workbook;
 | 
	
		
			
				|  |  | import jxl.write.*;
 | 
	
		
			
				|  |  | import org.apache.commons.collections.CollectionUtils;
 | 
	
		
			
				|  |  | import org.apache.commons.lang.StringUtils;
 | 
	
		
			
				|  |  | import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 | 
	
		
			
				|  |  | import org.jsoup.Jsoup;
 | 
	
	
		
			
				|  | @ -32,7 +34,6 @@ 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;
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -128,6 +129,10 @@ public class DoorOrderService {
 | 
	
		
			
				|  |  |     private WlyyDoorCommentDao doorCommentDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private SystemMessageDao systemMessageDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private PrescriptionDao prescriptionDao;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 顶部状态栏订单各分类总条数
 | 
	
		
			
				|  |  |      * @param doctor
 | 
	
	
		
			
				|  | @ -343,8 +348,8 @@ public class DoorOrderService {
 | 
	
		
			
				|  |  |         doorServiceOrder.setDoorConclusion(doorConclusion);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //获取上门前后开方详情
 | 
	
		
			
				|  |  |         List<WlyyDoorPrescriptionDO> doorBeforePrescriptionDOList = doorPrescriptionDao.findByOrderIdAndIsAfterDoor(id, 1);
 | 
	
		
			
				|  |  |         List<WlyyDoorPrescriptionDO> doorAfterPrescriptionDOList = doorPrescriptionDao.findByOrderIdAndIsAfterDoor(id, 2);
 | 
	
		
			
				|  |  |         List<WlyyPrescriptionDO> doorBeforePrescriptionDOList = prescriptionDao.findByOrderIdAndIsAfterDoor(id, 1);
 | 
	
		
			
				|  |  |         List<WlyyPrescriptionDO> doorAfterPrescriptionDOList = prescriptionDao.findByOrderIdAndIsAfterDoor(id, 2);
 | 
	
		
			
				|  |  |         doorServiceOrder.setPrescriptionDOList(doorBeforePrescriptionDOList);
 | 
	
		
			
				|  |  |         doorServiceOrder.setAfterPrescriptionList(doorAfterPrescriptionDOList);
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -544,25 +549,7 @@ public class DoorOrderService {
 | 
	
		
			
				|  |  |             logger.error(e.getMessage());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         //  待接单消息设为已操作, 434 医生接单-- 王五接受了服务工单12345678
 | 
	
		
			
				|  |  |         List<SystemMessageDO> messages = systemMessageDao.queryByRelationCodeAndTypeIn(orderId,new String[]{"403","407"});
 | 
	
		
			
				|  |  |         if (CollectionUtils.isEmpty(messages)){
 | 
	
		
			
				|  |  |             logger.error("当前工单没有医生待接单消息!orderId:" + orderId);
 | 
	
		
			
				|  |  |         }else {
 | 
	
		
			
				|  |  |             messages.forEach(message->{
 | 
	
		
			
				|  |  |                 systemMessageDao.orderMessageDel(message.getReceiver(),message.getRelationCode());
 | 
	
		
			
				|  |  |                 if (message.getType().equals("403") ) {
 | 
	
		
			
				|  |  |                     BaseDoctorDO baseDoctorDO = baseDoctorDao.findById(doorServiceOrder.getDispatcher());//·
 | 
	
		
			
				|  |  |                     String msg=doorServiceOrder.getDispatcherName() + "接受了服务工单"+ doorServiceOrder.getNumber();
 | 
	
		
			
				|  |  |                     messageUtil.saveSystemMessage(message.getId(),message.getRelationCode(),"医生接单","434",doorServiceOrder.getDoctor(),doorServiceOrder.getDoctorName(),
 | 
	
		
			
				|  |  |                             doorServiceOrder.getDispatcher(),doorServiceOrder.getDispatcherName(),null,msg,message.getOver());
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 else{
 | 
	
		
			
				|  |  |                     message.setOver("0");
 | 
	
		
			
				|  |  |                     systemMessageDao.save(message);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             });
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         messageUtil.updateMessage(doorServiceOrder,new String[]{"403","407"},"434",null,null);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
	
		
			
				|  | @ -586,15 +573,7 @@ public class DoorOrderService {
 | 
	
		
			
				|  |  |                 BaseDoctorDO baseDoctorDO = baseDoctorDao.findById(doorServiceOrder.getDispatcher());//·
 | 
	
		
			
				|  |  |                 this.createMessage("服务工单拒单待重新派单","404","system","system", doorServiceOrder.getId(), doorServiceOrder.getDispatcher(),baseDoctorDO.getName() , null,doorServiceOrder.getDoctorName() + "拒绝了" + doorServiceOrder.getProxyPatientName() + "的服务预约申请,请重新派单");
 | 
	
		
			
				|  |  |                 //  调度员-派单-实时工单消息:435 医生拒单-- 王五拒绝了服务工单12345678
 | 
	
		
			
				|  |  |                 List<SystemMessageDO> messages = systemMessageDao.queryByRelationCodeAndTypeIn(orderId,new String[]{"431","433"});
 | 
	
		
			
				|  |  |                 if (CollectionUtils.isEmpty(messages)) {
 | 
	
		
			
				|  |  |                     logger.error("当前工单没有医生待接单消息!orderId:" + orderId);
 | 
	
		
			
				|  |  |                 } else {
 | 
	
		
			
				|  |  |                     SystemMessageDO message = messages.get(0);
 | 
	
		
			
				|  |  |                     String msg=doorServiceOrder.getDoctorName() + "拒绝了服务工单" + doorServiceOrder.getNumber() + ", 请重新派单";
 | 
	
		
			
				|  |  |                     messageUtil.saveSystemMessage(message.getId(),message.getRelationCode(),"医生拒单","435",doorServiceOrder.getDoctor(),doorServiceOrder.getDoctorName(),
 | 
	
		
			
				|  |  |                             doorServiceOrder.getDispatcher(),doorServiceOrder.getDispatcherName(),null,msg,message.getOver());
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 messageUtil.updateMessage(doorServiceOrder,new String[]{"431","433"},"435",null,null);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         doorServiceOrder.setDoctor(null);
 | 
	
	
		
			
				|  | @ -618,17 +597,9 @@ public class DoorOrderService {
 | 
	
		
			
				|  |  |         messageDO.setRelationCode(relationCode);
 | 
	
		
			
				|  |  |         messageDO.setReceiver(Receiver);
 | 
	
		
			
				|  |  |         messageDO.setReceiverName(ReceiverName);
 | 
	
		
			
				|  |  |         net.sf.json.JSONObject data = new net.sf.json.JSONObject();
 | 
	
		
			
				|  |  |         data.put("name", ReceiverName);
 | 
	
		
			
				|  |  |         data.put("age", IdCardUtil.getAgeForIdcard(idCard));
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             data.put("gender", IdCardUtil.getSexForIdcard(idCard));
 | 
	
		
			
				|  |  |         } catch (Exception e) {
 | 
	
		
			
				|  |  |             e.printStackTrace();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         data.put("msg", msg);
 | 
	
		
			
				|  |  |         messageDO.setData(msg);
 | 
	
		
			
				|  |  |         messageDO.setDel("1");
 | 
	
		
			
				|  |  |         messageDO.setOver("1");
 | 
	
		
			
				|  |  |         messageDO.setCreateTime(new Date());
 | 
	
		
			
				|  |  |         systemMessageDao.save(messageDO);
 | 
	
		
			
				|  |  |     }
 | 
	
	
		
			
				|  | @ -804,15 +775,14 @@ public class DoorOrderService {
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     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{
 | 
	
		
			
				|  |  |                                   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," +
 | 
	
		
			
				|  |  |             String sql = "select DISTINCT o.id as orderId,o.number,o.status,o.is_trans_other_org," +
 | 
	
		
			
				|  |  |                     " o.transed_org_code,o.patient_name,p.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 " ;
 | 
	
		
			
				|  |  |                     " LEFT JOIN base_patient p on p.id=o.patient " ;
 | 
	
		
			
				|  |  |             if(!StringUtils.isEmpty(serverDoctorName)){
 | 
	
		
			
				|  |  |                 sql+=" RIGHT JOIN wlyy_door_doctor d on d.order_id = o.id";
 | 
	
		
			
				|  |  |             }
 | 
	
	
		
			
				|  | @ -827,13 +797,15 @@ public class DoorOrderService {
 | 
	
		
			
				|  |  |             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 + "') ";
 | 
	
		
			
				|  |  | /*            if (StringUtils.isNotBlank(hospitalCode) && !hospitalCode.contains("%")) {
 | 
	
		
			
				|  |  | //                sql += " and (h.code = '" + hospitalCode + "' or o.transed_org_code='" + hospitalCode + "') ";
 | 
	
		
			
				|  |  |                 sql += " and ( 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 + "') ";
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | //                sql += " and (h.code like '" + hospitalCode + "' or o.transed_org_code like '" + hospitalCode + "') ";
 | 
	
		
			
				|  |  |                 sql += " and ( o.transed_org_code like '" + hospitalCode + "') ";
 | 
	
		
			
				|  |  |             }*/
 | 
	
		
			
				|  |  |             if (status != null) {
 | 
	
		
			
				|  |  |                 sql += " and o.status ='" + status + "'";
 | 
	
		
			
				|  |  |                 sql += " and o.status in ("+StringUtils.strip(Arrays.toString(status),"[]")+") ";
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             if (!StringUtils.isEmpty(createTimeStart)) {
 | 
	
		
			
				|  |  |                 sql += " and o.create_time >='" + createTimeStart + "'";
 | 
	
	
		
			
				|  | @ -923,14 +895,7 @@ public class DoorOrderService {
 | 
	
		
			
				|  |  |                 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") + "";//签约表中的机构
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 String hospitalName = "泰安市中医医院";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 sheet.addCell(new Label(2, b + 1, hospitalName,cellFormat));//服务机构
 | 
	
		
			
				|  |  |                 Date createTime = (Date) list.get(i).get("create_time");
 | 
	
	
		
			
				|  | @ -1080,8 +1045,7 @@ public class DoorOrderService {
 | 
	
		
			
				|  |  |         // 更新记录
 | 
	
		
			
				|  |  |         this.setUpdateColumnInfo(one);
 | 
	
		
			
				|  |  |         doorServiceOrderDao.save(one);
 | 
	
		
			
				|  |  |         // 更新居民签约服务包服务项次数
 | 
	
		
			
				|  |  |         this.reduceServiceItemTimes(serverPackagePriceByOrderId(orderId), one.getPatient());
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         // 发送微信消息通知--用户评价//·
 | 
	
		
			
				|  |  |         BasePatientDO patient = patientInfoService.findById(one.getPatient());
 | 
	
		
			
				|  |  |         // 获取微信模板  fwyspf-服务医生评分
 | 
	
	
		
			
				|  | @ -1285,13 +1249,6 @@ public class DoorOrderService {
 | 
	
		
			
				|  |  |         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){
 | 
	
	
		
			
				|  | @ -1301,67 +1258,13 @@ public class DoorOrderService {
 | 
	
		
			
				|  |  |             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));
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             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;
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 获取订单下服务包数量、单价
 | 
	
	
		
			
				|  | @ -1559,6 +1462,7 @@ public class DoorOrderService {
 | 
	
		
			
				|  |  |         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;
 | 
	
	
		
			
				|  | @ -1660,11 +1564,13 @@ public class DoorOrderService {
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     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;
 | 
	
		
			
				|  |  |     public File writeWordFile(List<String> orderId,HttpServletResponse response,String doctorCode) throws Exception {
 | 
	
		
			
				|  |  |         String zipFileName = "service_summary";
 | 
	
		
			
				|  |  |         String exportConclusionList = doctorCode+"exportList";
 | 
	
		
			
				|  |  |         String path = System.getProperty("user.dir") +"/service_summary/" + exportConclusionList;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         System.out.println("path    :"   +path);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         File file = new File(path);
 | 
	
		
			
				|  |  |         // 删除文件夹、文件
 | 
	
		
			
				|  |  |         if (file.exists()) {
 | 
	
	
		
			
				|  | @ -1691,11 +1597,15 @@ public class DoorOrderService {
 | 
	
		
			
				|  |  |             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 pathName = this.getClass().getResource("/").getPath() + "conclusion.mht";
 | 
	
		
			
				|  |  | //            System.out.println("路径pathName:" + pathName);
 | 
	
		
			
				|  |  | //            Document doc = Jsoup.parse(new File(pathName), "UTF-8");
 | 
	
		
			
				|  |  |             Document doc = Jsoup.parse(StreamUtil.readResources());
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             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");
 | 
	
	
		
			
				|  | @ -1710,6 +1620,15 @@ public class DoorOrderService {
 | 
	
		
			
				|  |  |             return null;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public static void main(String[] args) {
 | 
	
		
			
				|  |  |         String str = "file:/data/wlyy2.0/svr-door-service/svr-door-service.jar!/BOOT-INF/classes!/1609894996524exportList/";
 | 
	
		
			
				|  |  |         String c2=str.substring(0,str.indexOf("!"));//  !前面的
 | 
	
		
			
				|  |  |         String c1=str.substring(str.lastIndexOf("!")+1);//  !後面的
 | 
	
		
			
				|  |  |         String cc = c2 + c1 ;
 | 
	
		
			
				|  |  |         System.out.println(cc.replace("svr-door-service.jar/",""));
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 打包文件夹
 | 
	
		
			
				|  |  |      *
 | 
	
	
		
			
				|  | @ -1807,12 +1726,11 @@ public class DoorOrderService {
 | 
	
		
			
				|  |  |    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+"'";
 | 
	
		
			
				|  |  |            sql+=" and o.status in (5,6) ";
 | 
	
		
			
				|  |  |        }else {//5是待补录状态
 | 
	
		
			
				|  |  |            sql+=" and o.conclusion_status =1 ";
 | 
	
		
			
				|  |  |        }
 |