|  | @ -588,6 +588,74 @@ public class PrescriptionInfoService extends BaseService {
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
													
														
															|  |     }
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |     public void setTotalSQL(StringBuffer pre_sql, List<Object> params, Integer teamCode, String state, String startDate, String endDate, String nameKeyword, String patient) {
 | 
												
													
														
															|  | 
 |  |         if (teamCode != null && teamCode > 0) {
 | 
												
													
														
															|  | 
 |  |             pre_sql.append(" AND pr.admin_team_id =?");
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |         params.add(teamCode);
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |         if (StringUtils.isNotBlank(state)) {
 | 
												
													
														
															|  | 
 |  |             pre_sql.append(" AND pr.status IN (" + state + ") ");
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |         if (StringUtils.isNotBlank(startDate)) {
 | 
												
													
														
															|  | 
 |  |             pre_sql.append(" AND pr.create_time >= ? ");
 | 
												
													
														
															|  | 
 |  |             params.add(startDate+" 00:00:00");
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |         if (StringUtils.isNotBlank(endDate)) {
 | 
												
													
														
															|  | 
 |  |             pre_sql.append(" AND pr.create_time <= ? ");
 | 
												
													
														
															|  | 
 |  |             params.add(endDate+" 23:59:59");
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |         if (StringUtils.isNotBlank(nameKeyword)) {
 | 
												
													
														
															|  | 
 |  |             pre_sql.append(" AND pr.patient_name like ? ");
 | 
												
													
														
															|  | 
 |  |             params.add("%" + nameKeyword + "%");
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |         if (StringUtils.isNotBlank(patient)) {
 | 
												
													
														
															|  | 
 |  |             pre_sql.append(" AND pr.patient = ?");
 | 
												
													
														
															|  | 
 |  |             params.add(patient);
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |     /**
 | 
												
													
														
															|  | 
 |  |      * 获取处方详情总数
 | 
												
													
														
															|  | 
 |  |      * @param teamCode
 | 
												
													
														
															|  | 
 |  |      * @param state
 | 
												
													
														
															|  | 
 |  |      * @param diseases
 | 
												
													
														
															|  | 
 |  |      * @param startDate
 | 
												
													
														
															|  | 
 |  |      * @param endDate
 | 
												
													
														
															|  | 
 |  |      * @param nameKeyword
 | 
												
													
														
															|  | 
 |  |      * @param patient
 | 
												
													
														
															|  | 
 |  |      * @return
 | 
												
													
														
															|  | 
 |  |      */
 | 
												
													
														
															|  | 
 |  |     public JSONObject getDoctorPrescriptionTotal(Integer teamCode, String state, String diseases, String startDate, String endDate, String nameKeyword, String patient) {
 | 
												
													
														
															|  | 
 |  |         StringBuffer pre_sql = new StringBuffer("SELECT count(1) AS total" +
 | 
												
													
														
															|  | 
 |  |                 " FROM " +
 | 
												
													
														
															|  | 
 |  |                 " wlyy_prescription pr " +
 | 
												
													
														
															|  | 
 |  |                 " LEFT JOIN wlyy_patient p ON pr.patient = p.`code` ");
 | 
												
													
														
															|  | 
 |  |         List<Object> params = new ArrayList<>();
 | 
												
													
														
															|  | 
 |  |         //先判断疾病类型是否为空
 | 
												
													
														
															|  | 
 |  |         if (StringUtils.isNotBlank(diseases)) {
 | 
												
													
														
															|  | 
 |  |             //疾病类型不为空,关联查询疾病类型表
 | 
												
													
														
															|  | 
 |  |             pre_sql.append(" ,wlyy_prescription_diagnosis s " +
 | 
												
													
														
															|  | 
 |  |                     " WHERE s.prescription_code = pr.code " +
 | 
												
													
														
															|  | 
 |  |                     " AND s.health_problem = ?");
 | 
												
													
														
															|  | 
 |  |             params.add(diseases);
 | 
												
													
														
															|  | 
 |  |             setTotalSQL(pre_sql, params, teamCode, state, startDate, endDate, nameKeyword, patient);
 | 
												
													
														
															|  | 
 |  |         } else {
 | 
												
													
														
															|  | 
 |  |             //查询所有疾病类型表
 | 
												
													
														
															|  | 
 |  |             pre_sql.append(" WHERE 1=1 ");
 | 
												
													
														
															|  | 
 |  |             setTotalSQL(pre_sql, params, teamCode, state, startDate, endDate, nameKeyword, patient);
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |         List<Map<String, Object>> rs = jdbcTemplate.queryForList(pre_sql.toString(), params.toArray());
 | 
												
													
														
															|  | 
 |  |         JSONObject jsonRs = new JSONObject();
 | 
												
													
														
															|  | 
 |  |         if(rs!=null && rs.size()>0){
 | 
												
													
														
															|  | 
 |  |             jsonRs.put("total",rs.get(0).get("total"));
 | 
												
													
														
															|  | 
 |  |         }else{
 | 
												
													
														
															|  | 
 |  |             jsonRs.put("total",0);
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |         return jsonRs;
 | 
												
													
														
															|  | 
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     /**
 |  |     /**
 | 
												
													
														
															|  |      * 获取续方信息
 |  |      * 获取续方信息
 | 
												
													
														
															|  |      *
 |  |      *
 | 
												
											
												
													
														
															|  | @ -855,6 +923,26 @@ public class PrescriptionInfoService extends BaseService {
 | 
												
													
														
															|  |         return new JSONArray(rs);
 |  |         return new JSONArray(rs);
 | 
												
													
														
															|  |     }
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |     public JSONObject getHDoctorPrescriptionExpressageTotal(String teamCode, String type, String doctor, String nameKey, String startDate, String endDate, String hospital, String state) {
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |         StringBuffer pre_sql = new StringBuffer("SELECT count(1) AS total " +
 | 
												
													
														
															|  | 
 |  |                 " FROM " +
 | 
												
													
														
															|  | 
 |  |                 " wlyy_prescription pr " +
 | 
												
													
														
															|  | 
 |  |                 " LEFT JOIN wlyy_patient p ON pr.patient = p.`code` " +
 | 
												
													
														
															|  | 
 |  |                 " JOIN wlyy_prescription_expressage e ON pr.code = e.prescription_code " +
 | 
												
													
														
															|  | 
 |  |                 " WHERE 1=1 AND pr.status >="+PrescriptionLog.PrescriptionLogStatus.pay_success.getValue()+" ");
 | 
												
													
														
															|  | 
 |  |         List<Object> params = new ArrayList<>();
 | 
												
													
														
															|  | 
 |  |         setExpressageTotalSql(pre_sql, params, teamCode, type, doctor, nameKey, startDate, endDate, hospital, state);
 | 
												
													
														
															|  | 
 |  |         List<Map<String, Object>> rs = jdbcTemplate.queryForList(pre_sql.toString(), params.toArray());
 | 
												
													
														
															|  | 
 |  |         JSONObject jsonRs=new JSONObject();
 | 
												
													
														
															|  | 
 |  |         if(rs!=null&&rs.size()>0){
 | 
												
													
														
															|  | 
 |  |             jsonRs.put("total",rs.get(0).get("total"));
 | 
												
													
														
															|  | 
 |  |         }else{
 | 
												
													
														
															|  | 
 |  |             jsonRs.put("total",0);
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |         return jsonRs;
 | 
												
													
														
															|  | 
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     public void setExpressageSql(StringBuffer pre_sql, List<Object> param, String teamCode, String type, String doctor, String nameKey, String startDate, String endDate, String hospital, String state, Integer page, Integer size) {
 |  |     public void setExpressageSql(StringBuffer pre_sql, List<Object> param, String teamCode, String type, String doctor, String nameKey, String startDate, String endDate, String hospital, String state, Integer page, Integer size) {
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |         if (StringUtils.isNotBlank(type)) {
 |  |         if (StringUtils.isNotBlank(type)) {
 | 
												
											
												
													
														
															|  | @ -896,6 +984,43 @@ public class PrescriptionInfoService extends BaseService {
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
													
														
															|  |     }
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |     public void setExpressageTotalSql(StringBuffer pre_sql, List<Object> param, String teamCode, String type, String doctor, String nameKey, String startDate, String endDate, String hospital, String state) {
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |         if (StringUtils.isNotBlank(type)) {
 | 
												
													
														
															|  | 
 |  |             if ("1".equals(type)) {
 | 
												
													
														
															|  | 
 |  |                 pre_sql.append(" AND e.expressage_Code = ?");
 | 
												
													
														
															|  | 
 |  |                 param.add(doctor);
 | 
												
													
														
															|  | 
 |  |             } else {
 | 
												
													
														
															|  | 
 |  |                 pre_sql.append(" AND e.accept_Code = ?");
 | 
												
													
														
															|  | 
 |  |                 param.add(doctor);
 | 
												
													
														
															|  | 
 |  |             }
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |         if (StringUtils.isNotBlank(teamCode)) {
 | 
												
													
														
															|  | 
 |  |             pre_sql.append(" AND pr.admin_team_id = ? ");
 | 
												
													
														
															|  | 
 |  |             param.add(teamCode);
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |         if (StringUtils.isNotBlank(nameKey)) {
 | 
												
													
														
															|  | 
 |  |             pre_sql.append(" AND p.name LIKE ? ");
 | 
												
													
														
															|  | 
 |  |             param.add("%" + nameKey + "%");
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |         if (StringUtils.isNotBlank(startDate)) {
 | 
												
													
														
															|  | 
 |  |             pre_sql.append(" AND pr.create_time >= ? ");
 | 
												
													
														
															|  | 
 |  |             param.add(startDate + " 00:00:00");
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |         if (StringUtils.isNotBlank(endDate)) {
 | 
												
													
														
															|  | 
 |  |             pre_sql.append(" AND pr.create_time <= ? ");
 | 
												
													
														
															|  | 
 |  |             param.add(endDate + " 23:59:59");
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |         if (StringUtils.isNotBlank(hospital)) {
 | 
												
													
														
															|  | 
 |  |             pre_sql.append(" AND e.hospital_code = ? ");
 | 
												
													
														
															|  | 
 |  |             param.add(hospital);
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |         if (StringUtils.isNotBlank(state)) {
 | 
												
													
														
															|  | 
 |  |             pre_sql.append(" AND pr.status = ? ");
 | 
												
													
														
															|  | 
 |  |             param.add(state);
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     /**
 |  |     /**
 | 
												
													
														
															|  |      * 获取订单跟踪下拉列表
 |  |      * 获取订单跟踪下拉列表
 | 
												
													
														
															|  |      * @param doctor
 |  |      * @param doctor
 | 
												
											
												
													
														
															|  | @ -1076,6 +1201,27 @@ public class PrescriptionInfoService extends BaseService {
 | 
												
													
														
															|  |         return new JSONArray(rs);
 |  |         return new JSONArray(rs);
 | 
												
													
														
															|  |     }
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |     public JSONObject getDoctorPrescriptionExpressageTotal(Integer teamCode, String nameKey, String startDate, String endDate, String hospital, String state, String dispensaryType, String AllocationType) {
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |         StringBuffer pre_sql = new StringBuffer("SELECT count(1) AS total " +
 | 
												
													
														
															|  | 
 |  |                 " FROM " +
 | 
												
													
														
															|  | 
 |  |                 " wlyy_prescription pr " +
 | 
												
													
														
															|  | 
 |  |                 " LEFT JOIN wlyy_patient p ON pr.patient = p.`code` " +
 | 
												
													
														
															|  | 
 |  |                 " JOIN wlyy_prescription_expressage e ON pr.code = e.prescription_code " +
 | 
												
													
														
															|  | 
 |  |                 " JOIN wlyy_prescription_reviewed r ON pr.code = r.prescription_code " +
 | 
												
													
														
															|  | 
 |  |                 " WHERE r.status=1 AND pr.status >="+PrescriptionLog.PrescriptionLogStatus.pay_success.getValue()+" ");
 | 
												
													
														
															|  | 
 |  |         List<Object> params = new ArrayList<>();
 | 
												
													
														
															|  | 
 |  |         setDoctorExpressageTotalSql(pre_sql, params, teamCode, nameKey, startDate, endDate, hospital, state, dispensaryType, AllocationType);
 | 
												
													
														
															|  | 
 |  |         List<Map<String, Object>> rs = jdbcTemplate.queryForList(pre_sql.toString(), params.toArray());
 | 
												
													
														
															|  | 
 |  |         JSONObject jsonRs = new JSONObject();
 | 
												
													
														
															|  | 
 |  |         if(rs!=null && rs.size()>0){
 | 
												
													
														
															|  | 
 |  |             jsonRs.put("total",rs.get(0).get("total"));
 | 
												
													
														
															|  | 
 |  |         }else{
 | 
												
													
														
															|  | 
 |  |             jsonRs.put("total",0);
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |         return jsonRs;
 | 
												
													
														
															|  | 
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     public void setDoctorExpressageSql(StringBuffer pre_sql, List<Object> param, Integer teamCode, String nameKey, String startDate, String endDate, String hospital, String state, String dispensaryType, String AllocationType, Integer page, Integer size) {
 |  |     public void setDoctorExpressageSql(StringBuffer pre_sql, List<Object> param, Integer teamCode, String nameKey, String startDate, String endDate, String hospital, String state, String dispensaryType, String AllocationType, Integer page, Integer size) {
 | 
												
													
														
															|  |         if (StringUtils.isNotBlank(nameKey)) {
 |  |         if (StringUtils.isNotBlank(nameKey)) {
 | 
												
													
														
															|  |             pre_sql.append(" AND p.name LIKE ? ");
 |  |             pre_sql.append(" AND p.name LIKE ? ");
 | 
												
											
												
													
														
															|  | @ -1118,6 +1264,43 @@ public class PrescriptionInfoService extends BaseService {
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
													
														
															|  |     }
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |     public void setDoctorExpressageTotalSql(StringBuffer pre_sql, List<Object> param, Integer teamCode, String nameKey, String startDate, String endDate, String hospital, String state, String dispensaryType, String AllocationType) {
 | 
												
													
														
															|  | 
 |  |         if (StringUtils.isNotBlank(nameKey)) {
 | 
												
													
														
															|  | 
 |  |             pre_sql.append(" AND p.name LIKE ? ");
 | 
												
													
														
															|  | 
 |  |             param.add("%" + nameKey + "%");
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |         if (teamCode != null && teamCode > 0) {
 | 
												
													
														
															|  | 
 |  |             pre_sql.append(" AND pr.admin_team_id = ? ");
 | 
												
													
														
															|  | 
 |  |             param.add(teamCode);
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |         if (StringUtils.isNotBlank(startDate)) {
 | 
												
													
														
															|  | 
 |  |             pre_sql.append(" AND pr.create_time >= ? ");
 | 
												
													
														
															|  | 
 |  |             param.add(startDate + " 00:00:00");
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |         if (StringUtils.isNotBlank(endDate)) {
 | 
												
													
														
															|  | 
 |  |             pre_sql.append(" AND pr.create_time <= ? ");
 | 
												
													
														
															|  | 
 |  |             param.add(endDate + " 23:59:59");
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |         if (StringUtils.isNotBlank(hospital)) {
 | 
												
													
														
															|  | 
 |  |             pre_sql.append(" AND e.hospital_code = ? ");
 | 
												
													
														
															|  | 
 |  |             param.add(hospital);
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |         if (StringUtils.isNotBlank(state)) {
 | 
												
													
														
															|  | 
 |  |             pre_sql.append(" AND pr.status = ? ");
 | 
												
													
														
															|  | 
 |  |             param.add(state);
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |         if (StringUtils.isNotBlank(dispensaryType)) {
 | 
												
													
														
															|  | 
 |  |             pre_sql.append(" AND pr.dispensary_type = ? ");
 | 
												
													
														
															|  | 
 |  |             param.add(dispensaryType);
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |         if (StringUtils.isNotBlank(AllocationType)) {
 | 
												
													
														
															|  | 
 |  |             //1为未分配建管师列表
 | 
												
													
														
															|  | 
 |  |             if ("1".equals(AllocationType)) {
 | 
												
													
														
															|  | 
 |  |                 pre_sql.append(" AND e.expressage_code IS NULL ");
 | 
												
													
														
															|  | 
 |  |             }
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     public JSONObject getCountExpressage(String teamCode) {
 |  |     public JSONObject getCountExpressage(String teamCode) {
 | 
												
													
														
															|  |         StringBuffer pre_sql = new StringBuffer("SELECT " +
 |  |         StringBuffer pre_sql = new StringBuffer("SELECT " +
 | 
												
													
														
															|  |                 " count(1) AS count  " +
 |  |                 " count(1) AS count  " +
 |