diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ShowApiServiceImpl.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ShowApiServiceImpl.java index 369c0b9753..7d2aadcc2d 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ShowApiServiceImpl.java +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ShowApiServiceImpl.java @@ -128,34 +128,37 @@ public class ShowApiServiceImpl implements ShowApiService { DayDetailResultDTO dayDetailResultDTO = null; try { dayDetailResultDTO = ShowApiUtil.queryHolidayV2020(currentDate); + if (dayDetailResultDTO == null){ + logger.warn("initWorkDay howApiUtil.queryHolidayV2020 return null"); + return; + } } catch (Exception e) { logger.error("queryHolidayV2020 exception", e); return; } List list = calenderDao.selectByDay(currentDate); if(null!=list&&list.size()>0){ - if (0 == dayDetailResultDTO.getRet_code()) { - for (CalenderEntity calenderEntity : list) { - calenderEntity.setRetCode(dayDetailResultDTO.getRet_code()); - calenderEntity.setWeekday(dayDetailResultDTO.getWeekDay()); - calenderEntity.setBegin(dayDetailResultDTO.getBegin()); - calenderEntity.setEnd(dayDetailResultDTO.getEnd()); - calenderEntity.setHoliday(dayDetailResultDTO.getHoliday()); - calenderEntity.setHolidayRemark(dayDetailResultDTO.getHoliday_remark()); - calenderEntity.setEn(dayDetailResultDTO.getEn()); - calenderEntity.setCn(dayDetailResultDTO.getCn()); - calenderEntity.setType(dayDetailResultDTO.getType()); - //1为工作日,2为周末,3为节假日 - if ("1".equals(dayDetailResultDTO.getType())) { - calenderEntity.setTypeName("工作日"); - } else if ("2".equals(dayDetailResultDTO.getType())) { - calenderEntity.setTypeName("周末"); - } else if ("3".equals(dayDetailResultDTO.getType())) { - calenderEntity.setTypeName("节假日"); - } - calenderDao.updateById(calenderEntity); + for (CalenderEntity calenderEntity : list) { + calenderEntity.setRetCode(dayDetailResultDTO.getRet_code()); + calenderEntity.setWeekday(dayDetailResultDTO.getWeekDay()); + calenderEntity.setBegin(dayDetailResultDTO.getBegin()); + calenderEntity.setEnd(dayDetailResultDTO.getEnd()); + calenderEntity.setHoliday(dayDetailResultDTO.getHoliday()); + calenderEntity.setHolidayRemark(dayDetailResultDTO.getHoliday_remark()); + calenderEntity.setEn(dayDetailResultDTO.getEn()); + calenderEntity.setCn(dayDetailResultDTO.getCn()); + calenderEntity.setType(dayDetailResultDTO.getType()); + //1为工作日,2为周末,3为节假日 + if ("1".equals(dayDetailResultDTO.getType())) { + calenderEntity.setTypeName("工作日"); + } else if ("2".equals(dayDetailResultDTO.getType())) { + calenderEntity.setTypeName("周末"); + } else if ("3".equals(dayDetailResultDTO.getType())) { + calenderEntity.setTypeName("节假日"); } + calenderDao.updateById(calenderEntity); } + }else { calenderDao.insert(getCalenderEntity(dayDetailResultDTO)); } diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/utils/ShowApiUtil.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/utils/ShowApiUtil.java index ad097e5c7c..6b9052cbcb 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/utils/ShowApiUtil.java +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/utils/ShowApiUtil.java @@ -1,10 +1,13 @@ package com.epmet.utils; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import com.epmet.commons.tools.constant.NumConstant; import com.epmet.constant.ShowApiConstant; import com.epmet.result.DayDetailResultDTO; import com.epmet.result.HolidayResultDTO; import com.epmet.result.ShowApiResult; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -51,7 +54,10 @@ public class ShowApiUtil { JSONObject jsonobject = JSONObject.parseObject(resultStr); ShowApiResult showApiResult= JSONObject.toJavaObject(jsonobject, ShowApiResult.class); logger.info(showApiResult.toString()); - + if (showApiResult.getShowapi_res_code() != NumConstant.ZERO || StringUtils.isBlank(showApiResult.getShowapi_res_body())) { + logger.error("获取工作日失败,result:{}", JSON.toJSONString(showApiResult)); + return null; + } JSONObject holidayJsonObject = JSONObject.parseObject(showApiResult.getShowapi_res_body()); DayDetailResultDTO dayDetailResultDTO= JSONObject.toJavaObject(holidayJsonObject, DayDetailResultDTO.class); logger.info(String.format("(3)QUERY_HOLIDAY_V2020返参:%s",dayDetailResultDTO.toString()));