Commit d68a35f8049b1b844da53561f4fedb2dff93e98c

Authored by dongqin
1 parent db1010f5a2

修复异常

Showing 2 changed files with 81 additions and 50 deletions

platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/AreaCountController.java View file @ d68a35f
... ... @@ -7,6 +7,8 @@
7 7 import com.lyms.platform.common.result.BaseResponse;
8 8 import com.lyms.platform.operate.web.facade.AreaCountFacade;
9 9 import com.lyms.platform.permission.model.ServiceListQuery;
  10 +import org.slf4j.Logger;
  11 +import org.slf4j.LoggerFactory;
10 12 import org.springframework.beans.factory.annotation.Autowired;
11 13 import org.springframework.stereotype.Controller;
12 14 import org.springframework.web.bind.annotation.*;
... ... @@ -23,6 +25,8 @@
23 25 @Controller
24 26 public class AreaCountController extends BaseController {
25 27  
  28 + private static final Logger logger = LoggerFactory.getLogger(AreaCountController.class);
  29 +
26 30 @Autowired
27 31 private AreaCountFacade areaCountFacade;
28 32  
... ... @@ -200,6 +204,7 @@
200 204 try {
201 205 return areaCountFacade.getServiceList(query);
202 206 }catch (Exception e){
  207 + logger.error("增值服务统计失败",e);
203 208 BaseResponse baseResponse = new BaseResponse();
204 209 baseResponse.setErrorcode(ErrorCodeConstants.SYSTEM_ERROR);
205 210 baseResponse.setErrormsg("增值服务统计失败");
... ... @@ -221,6 +226,7 @@
221 226 try {
222 227 return areaCountFacade.getServiceDetailList(param);
223 228 }catch (Exception e){
  229 + logger.error("增值服务详情统计失败",e);
224 230 BaseResponse baseResponse = new BaseResponse();
225 231 baseResponse.setErrorcode(ErrorCodeConstants.SYSTEM_ERROR);
226 232 baseResponse.setErrormsg("增值服务详情统计失败");
... ... @@ -239,7 +245,11 @@
239 245 public void getServiceDetailExport(ServiceListQuery param, HttpServletRequest request, HttpServletResponse response){
240 246 LoginContext loginState = (LoginContext) request.getAttribute("loginContext");
241 247 param.setUserId(loginState.getId());
242   - areaCountFacade.getServiceDetailExport(param, response);
  248 + try {
  249 + areaCountFacade.getServiceDetailExport(param, response);
  250 + }catch (Exception e){
  251 + logger.error("增值服务统计导出失败", e);
  252 + }
243 253 }
244 254  
245 255 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/AreaCountFacade.java View file @ d68a35f
... ... @@ -25,10 +25,7 @@
25 25 import com.lyms.platform.permission.service.OrganizationService;
26 26 import com.lyms.platform.permission.service.PatientServiceService;
27 27 import com.lyms.platform.permission.service.UsersService;
28   -import com.lyms.platform.pojo.AntExRecordModel;
29   -import com.lyms.platform.pojo.BasicConfig;
30   -import com.lyms.platform.pojo.DataPermissionsModel;
31   -import com.lyms.platform.pojo.Patients;
  28 +import com.lyms.platform.pojo.*;
32 29 import com.lyms.platform.query.AntExRecordQuery;
33 30 import com.lyms.platform.query.DataPermissionsModelQuery;
34 31 import com.lyms.platform.query.PatientsQuery;
35 32  
36 33  
37 34  
38 35  
... ... @@ -1153,44 +1150,68 @@
1153 1150 return response;
1154 1151 }
1155 1152  
  1153 + private String getString(Object object){
  1154 + if (object != null){
  1155 + return object.toString();
  1156 + }
  1157 + return "";
  1158 + }
1156 1159 private List<Map<String, Object>> getServiceDetailListMap(ServiceListQuery param) {
1157 1160 List<Map<String, Object>> mapList = patientServiceService.getServeDetailList(param);
1158   - for (Map map : mapList){
1159   - String parentId = map.get("parentId").toString();
1160   - String perType = map.get("perType").toString();
1161   - String serType = map.get("serType").toString();
1162   - Object serDoct = map.get("serDoct");
1163   - Date createDate = (Date) map.get("createDate");
1164   - String userName;
1165   - if ("1".equals(perType)){
1166   - // 孕妇
1167   - Patients patient = patientsService.findOnePatientById(parentId);
1168   - userName = patient.getUsername();
1169   - Date lastMenses = patient.getLastMenses();
1170   - int differentDays = differentDays(lastMenses, createDate);
1171   - int week = differentDays / 7;
1172   - map.put("openYumSize", week);
  1161 + if (CollectionUtils.isNotEmpty(mapList)){
  1162 + for (Map map : mapList){
  1163 + Object parentIdObj = map.get("parentId");
  1164 + String parentId = getString(parentIdObj);
  1165 + Object perTypeObj = map.get("perType");
  1166 + String perType = getString(perTypeObj);
  1167 + Object serTypeObj = map.get("serType");
  1168 + String serType = getString(serTypeObj);
  1169 + Object serDoctObj = map.get("serDoct");
  1170 + String serDoct = getString(serDoctObj);
  1171 + Date createDate = (Date) map.get("createDate");
  1172 + String userName = "";
  1173 + if ("1".equals(perType)){
  1174 + // 孕妇
  1175 + Patients patient = patientsService.findOnePatientById(parentId);
  1176 + if (patient != null){
  1177 + userName = getString(patient.getUsername());
  1178 + Date lastMenses = patient.getLastMenses();
  1179 + int differentDays = differentDays(lastMenses, createDate);
  1180 + int week = differentDays / 7;
  1181 + map.put("openYumSize", week);
  1182 + } else {
  1183 + map.put("opeYumSize","");
  1184 + }
1173 1185  
1174   - }else {
1175   - // 儿童 不显示孕周数和服务周期
1176   - userName = babyBookbuildingService.queryBabyBuildById(parentId).getName();
1177   - map.put("opnYumSize", "");
1178   - map.put("serviceWeek", "");
1179   - }
1180   - map.put("patientName", userName);
1181   - String serTypeName = getSerTypeName(serType);
1182   - map.put("serTypeName", serTypeName);
1183   - String doctorName = "";
1184   - if (serDoct != null && !"".equals(serDoct)){
1185   - doctorName = usersService.getUsers(Integer.parseInt(serDoct.toString())).getName();
1186   - }
1187 1186  
1188   - map.put("doctorName", doctorName);
1189   - map.remove("parentId");
1190   - map.remove("perType");
1191   - map.remove("serType");
1192   - map.remove("serDoct");
  1187 + }else {
  1188 + // 儿童 不显示孕周数和服务周期
  1189 + BabyModel babyModel = babyBookbuildingService.queryBabyBuildById(parentId);
  1190 + if (babyModel != null){
  1191 + userName = babyModel.getName();
  1192 + }
  1193 + map.put("opnYumSize", "");
  1194 + map.put("serviceWeek", "");
  1195 + }
  1196 + map.put("patientName", userName);
  1197 + String serTypeName = getSerTypeName(serType);
  1198 + map.put("serTypeName", serTypeName);
  1199 + String doctorName = "";
  1200 + if (serDoct != null && !"".equals(serDoct)){
  1201 + Users users = usersService.getUsers(Integer.parseInt(serDoct));
  1202 + if (users != null){
  1203 + doctorName = users.getName();
  1204 + }
  1205 + }
  1206 +
  1207 + map.put("doctorName", doctorName);
  1208 + map.remove("parentId");
  1209 + map.remove("perType");
  1210 + map.remove("serType");
  1211 + map.remove("serDoct");
  1212 + }
1193 1213 }
  1214 +
1194 1215 return mapList;
1195 1216 }
1196 1217  
... ... @@ -1203,17 +1224,17 @@
1203 1224 public void getServiceDetailExport(ServiceListQuery param, HttpServletResponse response) {
1204 1225 setDefaultTime(param);
1205 1226 List<Map<String, Object>> serviceDetailListMap = getServiceDetailListMap(param);
1206   - Map<String, String> names = new LinkedHashMap<>();
1207   - names.put("createDate","购买日期");
1208   - names.put("patientName", "姓名");
1209   - names.put("opnYumSize", "开通孕周");
1210   - names.put("serTypeName", "服务类型");
1211   - names.put("serviceWeek","服务周期");
1212   - names.put("doctorName", "指定医生");
1213   - names.put("serStatus","服务状态");
1214   -
1215   - ResponseUtil.responseExcel(names,serviceDetailListMap,response);
1216   -
  1227 + if (CollectionUtils.isNotEmpty(serviceDetailListMap)){
  1228 + Map<String, String> names = new LinkedHashMap<>();
  1229 + names.put("createDate","购买日期");
  1230 + names.put("patientName", "姓名");
  1231 + names.put("opnYumSize", "开通孕周");
  1232 + names.put("serTypeName", "服务类型");
  1233 + names.put("serviceWeek","服务周期");
  1234 + names.put("doctorName", "指定医生");
  1235 + names.put("serStatus","服务状态");
  1236 + ResponseUtil.responseExcel(names,serviceDetailListMap,response);
  1237 + }
1217 1238 }
1218 1239  
1219 1240 private void setDefaultTime(ServiceListQuery param) {