|  |  |  | 
|---|
|  |  |  | import com.fzzy.api.data.PushProtocol; | 
|---|
|  |  |  | import com.fzzy.api.entity.*; | 
|---|
|  |  |  | import com.fzzy.api.service.ApiCommonService; | 
|---|
|  |  |  | import com.fzzy.api.service.ApiTriggerService; | 
|---|
|  |  |  | import com.fzzy.api.utils.ContextUtil; | 
|---|
|  |  |  | import com.fzzy.api.view.repository.*; | 
|---|
|  |  |  | import com.fzzy.async.fzzy40.entity.*; | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.fzzy.push.gd2022.dto.Gd2022Api1023Way; | 
|---|
|  |  |  | import com.fzzy.push.gd2022.ApiCodeConstant; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.apache.commons.lang.StringUtils; | 
|---|
|  |  |  | import org.springframework.beans.BeanUtils; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.stereotype.Component; | 
|---|
|  |  |  | 
|---|
|  |  |  | private ApiCommonService commonService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private ApiInfoDataRep apiInfoDataRep; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private ApiTriggerService apiTriggerService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | * @param end | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public void syncData(String kqdm, String deptId, Date start, Date end) { | 
|---|
|  |  |  | log.info("-------------1023接口设备信息开始同步------------------"); | 
|---|
|  |  |  | log.info("-------------1023接口熏蒸备案信息开始同步------------------"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //同步数据,只记录失败的信息 | 
|---|
|  |  |  | ApiLog apiLog = new ApiLog(); | 
|---|
|  |  |  | apiLog.setType(ApiLog.TYPE_SYNC); | 
|---|
|  |  |  | apiLog.setKqdm(deptId); | 
|---|
|  |  |  | apiLog.setUploadTime(new Date()); | 
|---|
|  |  |  | apiLog.setInteId(ApiCodeConstant.API_1023); | 
|---|
|  |  |  | apiLog.setInteId(ApiCodeConstant.API_9201); | 
|---|
|  |  |  | apiLog.setStatus(99); | 
|---|
|  |  |  | apiLog.setId(ContextUtil.getUUID()); | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | List<Fz40DrugLogApply> list = fzzy40Sync1023Rep.listDrugLogApply(deptId); | 
|---|
|  |  |  | List<Fz40DrugLogApply> list = fzzy40Sync1023Rep.listDrugLogApply(deptId, start, end); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (null == list || list.isEmpty()) { | 
|---|
|  |  |  | log.info("-------------没有获取到熏蒸备案信息------------------"); | 
|---|
|  |  |  | 
|---|
|  |  |  | GD2022Api1023.setYjlx(data.getDrugType()); | 
|---|
|  |  |  | GD2022Api1023.setLqrq(data.getLqsj()); | 
|---|
|  |  |  | GD2022Api1023.setZhgxsj(data.getUpdateTime()); | 
|---|
|  |  |  | if (data.getLqr().contains("、")) { | 
|---|
|  |  |  | GD2022Api1023.setLqr(data.getLqr().replace('、', '|')); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //储粮粮情明细表 | 
|---|
|  |  |  | List<Fz40DrugLogDtl> dtls = drugLogDtlRep.listDrugLogDtl(data.getXzbm()); | 
|---|
|  |  |  | 
|---|
|  |  |  | BeanUtils.copyProperties(data, gd2022Api1023Dtl); | 
|---|
|  |  |  | if (null != api1105) { | 
|---|
|  |  |  | gd2022Api1023Dtl.setCfmc(api1105.getHwmc()); | 
|---|
|  |  |  | gd2022Api1023Dtl.setCfdm(api1105.getHwdm().substring(0,25)); | 
|---|
|  |  |  | gd2022Api1023Dtl.setCfdm(api1105.getHwdm().substring(0, 25)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | gd2022Api1023Dtl.setLspzdm(data.getFoodVariety()); | 
|---|
|  |  |  | //粮食品种 | 
|---|
|  |  |  | String mappingCode = apiTriggerService.getMappingCode(Constant.TRIGGER_P_LSPZ, data.getFoodVariety()); | 
|---|
|  |  |  | gd2022Api1023Dtl.setLspzdm(mappingCode); | 
|---|
|  |  |  | gd2022Api1023Dtl.setLsxzdm(data.getFoodType()); | 
|---|
|  |  |  | gd2022Api1023Dtl.setLsdjdm(data.getFoodLevel()); | 
|---|
|  |  |  | gd2022Api1023Dtl.setLssl(data.getNumber()); | 
|---|
|  |  |  | 
|---|
|  |  |  | gd2022Api1023People = new Gd2022Api1023People(); | 
|---|
|  |  |  | BeanUtils.copyProperties(people, gd2022Api1023People); | 
|---|
|  |  |  | gd2022Api1023People.setXm(people.getMx()); | 
|---|
|  |  |  | if (StringUtils.isEmpty(people.getZyzg())) { | 
|---|
|  |  |  | gd2022Api1023People.setZyzg("中级"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | peopleList.add(gd2022Api1023People); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | GD2022Api1023.setPeoples(peopleList); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | infoData.setKqdm(kqdm); | 
|---|
|  |  |  | infoData.setInteType(Constant.API_CATEGORY_13); | 
|---|
|  |  |  | infoData.setInteId(ApiCodeConstant.API_1023); | 
|---|
|  |  |  | infoData.setBizType(PushProtocol.SB_GD_2022.getCode()); | 
|---|
|  |  |  | infoData.setInteId(ApiCodeConstant.API_9201); | 
|---|
|  |  |  | infoData.setBizType(PushProtocol.SB_GD_2023.getCode()); | 
|---|
|  |  |  | infoData.setUpdateTime(new Date()); | 
|---|
|  |  |  | infoData.setDataId(data.getXzbm()); | 
|---|
|  |  |  | apiInfoList = apiInfoDataRep.getDataByInteAndData(ApiCodeConstant.API_1023, data.getXzbm(), kqdm); | 
|---|
|  |  |  | apiInfoList = apiInfoDataRep.getDataByInteAndData(ApiCodeConstant.API_9201, data.getXzbm(), kqdm); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (null == apiInfoList || apiInfoList.isEmpty()) { | 
|---|
|  |  |  | GD2022Api1023.setCzbz(Constant.CZBZ_I); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | log.error("---设备信息同步执行失败----{}", e.toString()); | 
|---|
|  |  |  | apiLog.setResult("设备信息同步执行失败:" + e.getMessage()); | 
|---|
|  |  |  | log.error("---熏蒸备案同步执行失败----{}", e.toString()); | 
|---|
|  |  |  | apiLog.setResult("熏蒸备案信息同步执行失败:" + e.getMessage()); | 
|---|
|  |  |  | apiLogRep.save(apiLog); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|