| | |
| | | import com.fzzy.api.service.ApiCommonService; |
| | | import com.fzzy.api.service.ApiTriggerService; |
| | | import com.fzzy.api.utils.ContextUtil; |
| | | import com.fzzy.api.utils.DateUtil; |
| | | import com.fzzy.api.view.repository.Api1310Rep; |
| | | import com.fzzy.api.view.repository.ApiLogRep; |
| | | import com.fzzy.api.view.repository.GbCheckItemRep; |
| | | import com.fzzy.async.fzzy40.entity.Fz40CheckItem; |
| | | import com.fzzy.async.fzzy40.entity.Fz40Quality; |
| | | import com.fzzy.async.fzzy40.repository.Fzzy40Sync1203Rep; |
| | | import com.fzzy.async.fzzy40.repository.Fzzy40Sync1208Rep; |
| | | import com.fzzy.async.fzzy40.repository.Fzzy40Sync1310Rep; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang.StringUtils; |
| | |
| | | apiLog.setStatus(99); |
| | | apiLog.setId(ContextUtil.getUUID()); |
| | | try { |
| | | List<Fz40Quality> list = fzzySync1310Rep.findDateByTime(start, end); |
| | | List<Fz40Quality> list = fzzySync1310Rep.findDateByTime(deptId, start, end); |
| | | if (null == list || list.isEmpty()) { |
| | | return; |
| | | } |
| | |
| | | List<Fz40CheckItem> fz40CheckItems; |
| | | List<GbCheckItem> gbCheckList; |
| | | String jyxm; |
| | | String jyxmz; |
| | | String jyz; |
| | | List<Api1310> api1310List; |
| | | int index = 10001; |
| | | |
| | | for (Fz40Quality fz40Quality : list) { |
| | | api1105 = commonService.getApi1105Cache(fz40Quality.getDepotId()); |
| | | if (null == api1105) { |
| | | continue; |
| | | } |
| | | api1310 = new Api1310(); |
| | | api1310.setZjbgdh(fz40Quality.getType() + DateFormatUtils.format(fz40Quality.getTime(), "yyyyMMdd") + String.valueOf(index).substring(1)); |
| | | if (fz40Quality.getId().contains("ZJ_")) { |
| | | api1310.setZjbgdh(fz40Quality.getType() + fz40Quality.getId().substring(3)); |
| | | } else { |
| | | api1310.setZjbgdh(fz40Quality.getType() + fz40Quality.getId()); |
| | | } |
| | | api1310.setHwdm(api1105.getHwdm()); |
| | | api1310.setKqdm(kqdm); |
| | | //粮食品种 |
| | | String mappingCode = apiTriggerService.getMappingCode(Constant.TRIGGER_P_LSPZ, fz40Quality.getFoodVariety().substring(0,3)); |
| | | String mappingCode = apiTriggerService.getMappingCode(Constant.TRIGGER_P_LSPZ, fz40Quality.getFoodVariety().substring(0, 3)); |
| | | api1310.setLspzdm(mappingCode); |
| | | |
| | | //粮食等级 |
| | |
| | | api1310.setJydw(fz40Quality.getUser()); |
| | | api1310.setJyr(fz40Quality.getUser()); |
| | | api1310.setJyyj(fz40Quality.getStandard()); |
| | | api1310.setZblb("2"); |
| | | if (StringUtils.isEmpty(fz40Quality.getZblb())) { |
| | | api1310.setZblb("2"); |
| | | } else { |
| | | api1310.setZblb(fz40Quality.getZblb()); |
| | | } |
| | | |
| | | //检测项,检测值 |
| | | jyxm = ""; |
| | | jyxmz = ""; |
| | | jyz = ""; |
| | | fz40CheckItems = fzzySync1203Rep.listInoutCheckItem(fz40Quality.getId(), deptId.substring(0, 4)); |
| | | if (null != fz40CheckItems && fz40CheckItems.size() > 0) { |
| | | |
| | | for (Fz40CheckItem fz40CheckItem : fz40CheckItems) { |
| | | if(StringUtils.isEmpty(fz40CheckItem.getValue())){ |
| | | if (StringUtils.isEmpty(fz40CheckItem.getValue())) { |
| | | continue; |
| | | } |
| | | gbCheckList = gbCheckItemRep.findByBizCode(fz40CheckItem.getStandardId()); |
| | |
| | | continue; |
| | | } |
| | | jyxm += gbCheckList.get(0).getCode() + ","; |
| | | jyxmz += fz40CheckItem.getValue() + ","; |
| | | jyz += fz40CheckItem.getValue() + ","; |
| | | } |
| | | } |
| | | api1310.setJyxm(jyxm); |
| | | api1310.setJyxmz(jyxmz); |
| | | api1310.setJyxmz(jyz); |
| | | |
| | | api1310.setZbjgpd(fz40Quality.getResult()); |
| | | api1310.setQfrq(fz40Quality.getTime()); |
| | | api1310.setBgcjsj(fz40Quality.getTime()); |
| | | api1310.setShrxm(fz40Quality.getCheckUser()); |
| | | if (null == fz40Quality.getCheckTime()) { |
| | | fz40Quality.setCheckTime(DateUtils.addDays(fz40Quality.getTime(), -1)); |
| | | } |
| | | if (!fz40Quality.getCheckTime().before(fz40Quality.getTime())) { |
| | | fz40Quality.setCheckTime(DateUtils.addDays(fz40Quality.getTime(), -1)); |
| | | } |
| | | api1310.setQysj(fz40Quality.getCheckTime()); |
| | | api1310.setQyqy(fz40Quality.getCheckArea()); |
| | | api1310.setQyrxm(fz40Quality.getCheckUser()); |
| | | api1310.setJdrxm(fz40Quality.getCheckUser()); |
| | | if (fz40Quality.getCheckUser().contains("、")) { |
| | | api1310.setQyrxm(fz40Quality.getCheckUser().replace('、', '|')); |
| | | api1310.setJdrxm(fz40Quality.getCheckUser().replace('、', '|')); |
| | | } |
| | | |
| | | |
| | | api1310.setYpsl(fz40Quality.getYpsl() == null ? 0.0 : fz40Quality.getYpsl()); |
| | | api1310.setDbsl(fz40Quality.getDbsl() == null ? 0.0 : fz40Quality.getDbsl()); |
| | | api1310.setYpdj(StringUtils.isEmpty(fz40Quality.getYpdj())?"0": fz40Quality.getYpdj()); |
| | | api1310.setSfzcccnx(StringUtils.isEmpty(fz40Quality.getNormalYear())?"0": fz40Quality.getNormalYear()); |
| | | api1310.setYpdj(StringUtils.isEmpty(fz40Quality.getYpdj()) ? "0" : fz40Quality.getYpdj()); |
| | | api1310.setSfzcccnx(StringUtils.isEmpty(fz40Quality.getNormalYear()) ? "0" : fz40Quality.getNormalYear()); |
| | | api1310.setBz(fz40Quality.getRemark()); |
| | | api1310.setYpbh(fz40Quality.getYpbh()); |
| | | api1310.setQydbh(fz40Quality.getQydbh()); |
| | | api1310.setZhgxsj(new Date()); |
| | | api1310.setBizId(fz40Quality.getId()); |
| | | |
| | | api1310List = api1310Rep.getDataByZjbgdh(api1310.getZjbgdh()); |
| | | if(null == api1310List || api1310List.isEmpty()){ |
| | | api1310List = api1310Rep.getDataByBizId(api1310.getBizId()); |
| | | if (null == api1310List || api1310List.isEmpty()) { |
| | | api1310.setCzbz(Constant.CZBZ_I); |
| | | }else { |
| | | } else { |
| | | api1310.setCzbz(api1310List.get(0).getCzbz()); |
| | | api1310.setBglx(api1310List.get(0).getBglx()); |
| | | } |
| | | |
| | | api1310Rep.save(api1310); |
| | | index ++; |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("---同步失败----{}", e); |