| 
					
				 | 
			
			
				@ -6,6 +6,7 @@ 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; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -23,7 +24,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; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -770,15 +770,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"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -793,13 +792,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 + "'"; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -889,14 +890,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"); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1046,8 +1040,7 @@ public class DoorOrderService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        // 更新记录 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        this.setUpdateColumnInfo(one); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        doorServiceOrderDao.save(one); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        // 更新居民签约服务包服务项次数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        this.reduceServiceItemTimes(serverPackagePriceByOrderId(orderId), one.getPatient()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        // 发送微信消息通知--用户评价//· 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BasePatientDO patient = patientInfoService.findById(one.getPatient()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        // 获取微信模板  fwyspf-服务医生评分 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1292,42 +1285,6 @@ public class DoorOrderService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        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; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 获取订单下服务包数量、单价 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1657,9 +1614,10 @@ 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); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1773,12 +1731,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 "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       } 
			 |