| | |
| | | package com.fzzy.async.fzzy40.impl; |
| | | |
| | | import com.fzzy.api.Constant; |
| | | import com.fzzy.api.entity.Api1102; |
| | | import com.fzzy.api.entity.Api1105; |
| | | import com.fzzy.api.entity.Api1208; |
| | | import com.fzzy.api.entity.ApiLog; |
| | | 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.async.fzzy40.entity.Fz40DepotStore; |
| | | import com.fzzy.async.fzzy40.repository.Fzzy40Sync1208Rep; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang.StringUtils; |
| | | import org.apache.commons.lang.time.DateUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | |
| | | |
| | | Api1208 apiData; |
| | | Api1105 api1105; |
| | | List<Api1208> api1208List; |
| | | for (Fz40DepotStore fz40DepotStore : list) { |
| | | |
| | | //获取货位信息 |
| | |
| | | } |
| | | |
| | | apiData = new Api1208(); |
| | | apiData.setId(fz40DepotStore.getId()); |
| | | apiData.setHwdm(api1105.getHwdm()); |
| | | |
| | | //粮食品种 |
| | | String mappingCode = apiTriggerService.getMappingCode(Constant.TRIGGER_P_LSPZ, fz40DepotStore.getFoodVariety()); |
| | | String mappingCode = apiTriggerService.getMappingCode(Constant.TRIGGER_P_LSPZ, fz40DepotStore.getFoodVariety().substring(0, 3)); |
| | | apiData.setLspzdm(mappingCode); |
| | | |
| | | //粮食性质 |
| | |
| | | apiData.setShnd(fz40DepotStore.getFoodYear()); |
| | | |
| | | //产地代码 |
| | | String cd = commonService.getFoodLocationIdFromCache(fz40DepotStore.getFoodLocation()); |
| | | apiData.setCd(cd); |
| | | mappingCode = commonService.getFoodLocationIdFromCache(fz40DepotStore.getFoodLocation()); |
| | | if (StringUtils.isEmpty(mappingCode)) { |
| | | mappingCode = apiData.getHwdm().substring(2, 8); |
| | | } |
| | | apiData.setCd(mappingCode); |
| | | |
| | | apiData.setBgy(api1105.getBgy()); |
| | | apiData.setBgy(StringUtils.isEmpty(api1105.getBgy()) ? "保管员" : api1105.getBgy()); |
| | | //粮权归属单位 |
| | | apiData.setLqgsdwdm(api1102.getDwdm()); |
| | | if (StringUtils.isEmpty(fz40DepotStore.getLqgsdwdm())) { |
| | | apiData.setLqgsdwdm(api1102.getDwdm()); |
| | | } else { |
| | | apiData.setLqgsdwdm(fz40DepotStore.getLqgsdwdm()); |
| | | } |
| | | //粮权行政区划代码 |
| | | apiData.setLqxzqhdm(api1102.getDwdm().substring(2, 8)); |
| | | apiData.setLqxzqhdm(api1102.getXzqhdm()); |
| | | //管理方式-默认直储 |
| | | apiData.setGlfs("01"); |
| | | //收储地点-默认库内 |
| | |
| | | //货位状态 |
| | | mappingCode = apiTriggerService.getMappingCode(Constant.TRIGGER_P_HWZT, fz40DepotStore.getDepotStatus()); |
| | | apiData.setHwzt(mappingCode); |
| | | if(null == fz40DepotStore.getStoreDate()){ |
| | | if (null == fz40DepotStore.getStoreDate()) { |
| | | fz40DepotStore.setStoreDate(new Date()); |
| | | } |
| | | //入仓时间 |
| | | apiData.setRcsj(fz40DepotStore.getStoreDate()); |
| | | //封仓日期 |
| | | if("3".equals(apiData.getHwzt())){ |
| | | apiData.setFcrq(DateUtils.addDays(fz40DepotStore.getStoreDate(), 10)); |
| | | if ("3".equals(apiData.getHwzt()) || "4".equals(apiData.getHwzt())) { |
| | | if(null == fz40DepotStore.getFullDate()){ |
| | | fz40DepotStore.setFullDate(DateUtils.addDays(fz40DepotStore.getStoreDate(), 30)); |
| | | } |
| | | apiData.setFcrq(fz40DepotStore.getFullDate()); |
| | | } |
| | | //出仓完成时间 |
| | | if("1".equals(apiData.getHwzt())){ |
| | | |
| | | if ("1".equals(apiData.getHwzt())) { |
| | | //出仓完成时间 |
| | | apiData.setCcwcsj(DateUtils.addDays(fz40DepotStore.getStoreDate(), 5)); |
| | | //清仓时间 |
| | | apiData.setQcsj(DateUtils.addDays(apiData.getCcwcsj(), 1)); |
| | | } |
| | | //国别 |
| | | apiData.setGb("156"); |
| | |
| | | apiData.setSjzlxg(6); |
| | | apiData.setLdtj(10000); |
| | | |
| | | apiData.setZhgxsj(new Date()); |
| | | apiData.setZhgxsj(fz40DepotStore.getUpdateDate()); |
| | | |
| | | //业务id、库区编码、同步时间 |
| | | apiData.setBizId(fz40DepotStore.getId()); |
| | |
| | | apiData.setSyncTime(new Date()); |
| | | |
| | | //库存每次新增 |
| | | apiData.setCzbz(Constant.CZBZ_I); |
| | | apiData.setId(ContextUtil.getCurTimeMillis()); |
| | | api1208List = api1208Rep.getDataById(apiData.getId()); |
| | | if (null == api1208List || api1208List.isEmpty()) { |
| | | apiData.setCzbz(Constant.CZBZ_I); |
| | | } else { |
| | | apiData.setCzbz(api1208List.get(0).getCzbz()); |
| | | } |
| | | |
| | | //保存数据 |
| | | api1208Rep.save(apiData); |
| | | } |