|  |  |  | 
|---|
|  |  |  | import com.fzzy.api.view.repository.Api1102Rep; | 
|---|
|  |  |  | import com.fzzy.api.view.repository.Api1208Rep; | 
|---|
|  |  |  | import com.fzzy.api.view.repository.ApiLogRep; | 
|---|
|  |  |  | import com.fzzy.async.fzzy35.entity.Fz35Depot; | 
|---|
|  |  |  | import com.fzzy.async.fzzy35.entity.Fz35DepotStore; | 
|---|
|  |  |  | import com.fzzy.async.fzzy35.repository.Fzzy35Sync1208Rep; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.apache.commons.lang.time.DateUtils; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.stereotype.Component; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | apiLog.setStatus(99); | 
|---|
|  |  |  | apiLog.setId(ContextUtil.getUUID()); | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | List<Fz35Depot> list = fzzySync1208Rep.listDepot(deptId); | 
|---|
|  |  |  | List<Fz35DepotStore> list = fzzySync1208Rep.listDepot(deptId, start, end); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (null == list || list.isEmpty()) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Api1208 apiData; | 
|---|
|  |  |  | Api1105 api1105; | 
|---|
|  |  |  | //  List<GbArea> gbAreaList; | 
|---|
|  |  |  | List<Api1208> api1208List; | 
|---|
|  |  |  | for (Fz35Depot fz35Depot : list) { | 
|---|
|  |  |  | for (Fz35DepotStore fz35DepotStore : list) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //获取货位信息 | 
|---|
|  |  |  | api1105 = commonService.getApi1105Cache(fz35Depot.getId()); | 
|---|
|  |  |  | api1105 = commonService.getApi1105Cache(fz35DepotStore.getDepotId()); | 
|---|
|  |  |  | if (null == api1105) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | apiData = new Api1208(); | 
|---|
|  |  |  | apiData.setId(fz35DepotStore.getId()); | 
|---|
|  |  |  | apiData.setHwdm(api1105.getHwdm()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //粮食品种 | 
|---|
|  |  |  | String mappingCode = apiTriggerService.getMappingCode(Constant.TRIGGER_P_LSPZ, fz35Depot.getFoodVariety()); | 
|---|
|  |  |  | String mappingCode = apiTriggerService.getMappingCode(Constant.TRIGGER_P_LSPZ, fz35DepotStore.getFoodVariety().substring(0,3)); | 
|---|
|  |  |  | apiData.setLspzdm(mappingCode); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //粮食性质 | 
|---|
|  |  |  | mappingCode = apiTriggerService.getMappingCode(Constant.TRIGGER_P_LSXZ, fz35Depot.getFoodType()); | 
|---|
|  |  |  | mappingCode = apiTriggerService.getMappingCode(Constant.TRIGGER_P_LSXZ, fz35DepotStore.getFoodType()); | 
|---|
|  |  |  | apiData.setLsxzdm(mappingCode); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //粮食等级 | 
|---|
|  |  |  | mappingCode = apiTriggerService.getMappingCode(Constant.TRIGGER_P_LSDJ, fz35Depot.getFoodLevel()); | 
|---|
|  |  |  | mappingCode = apiTriggerService.getMappingCode(Constant.TRIGGER_P_LSDJ, fz35DepotStore.getFoodLevel()); | 
|---|
|  |  |  | apiData.setLsdjdm(mappingCode); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | apiData.setShnd(fz35Depot.getFoodYear()); | 
|---|
|  |  |  | apiData.setShnd(fz35DepotStore.getFoodYear()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //产地代码 | 
|---|
|  |  |  | String cd = commonService.getFoodLocationIdFromCache(fz35Depot.getFoodLocation()); | 
|---|
|  |  |  | String cd = commonService.getFoodLocationIdFromCache(fz35DepotStore.getFoodLocation()); | 
|---|
|  |  |  | apiData.setCd(cd); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | apiData.setBgy(fz35Depot.getStoreKeeperName()); | 
|---|
|  |  |  | apiData.setBgy(api1105.getBgy()); | 
|---|
|  |  |  | //粮权归属单位 | 
|---|
|  |  |  | apiData.setLqgsdwdm(api1102.getDwdm()); | 
|---|
|  |  |  | //粮权行政区划代码 | 
|---|
|  |  |  | 
|---|
|  |  |  | //收储地点-默认库内 | 
|---|
|  |  |  | apiData.setScdd("1"); | 
|---|
|  |  |  | //储粮方式 | 
|---|
|  |  |  | apiData.setClfs(fz35Depot.getStoreType()); | 
|---|
|  |  |  | apiData.setClfs(fz35DepotStore.getStoreType()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //货位状态 | 
|---|
|  |  |  | mappingCode = apiTriggerService.getMappingCode(Constant.TRIGGER_P_HWZT, fz35Depot.getDepotStatus()); | 
|---|
|  |  |  | mappingCode = apiTriggerService.getMappingCode(Constant.TRIGGER_P_HWZT, fz35DepotStore.getDepotStatus()); | 
|---|
|  |  |  | apiData.setHwzt(mappingCode); | 
|---|
|  |  |  | if(null == fz35DepotStore.getStoreDate()){ | 
|---|
|  |  |  | fz35DepotStore.setStoreDate(new Date()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //入仓时间 | 
|---|
|  |  |  | apiData.setRcsj(fz35Depot.getStoreDate()); | 
|---|
|  |  |  | apiData.setRcsj(fz35DepotStore.getStoreDate()); | 
|---|
|  |  |  | //封仓日期 | 
|---|
|  |  |  | if("3".equals(apiData.getHwzt())){ | 
|---|
|  |  |  | apiData.setFcrq(DateUtils.addDays(fz35Depot.getStoreDate(), 10)); | 
|---|
|  |  |  | apiData.setFcrq(DateUtils.addDays(fz35DepotStore.getStoreDate(), 10)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //出仓完成时间 | 
|---|
|  |  |  | if("1".equals(apiData.getHwzt())){ | 
|---|
|  |  |  | apiData.setCcwcsj(DateUtils.addDays(fz35Depot.getStoreDate(), 5)); | 
|---|
|  |  |  | apiData.setCcwcsj(DateUtils.addDays(fz35DepotStore.getStoreDate(), 5)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //国别 | 
|---|
|  |  |  | apiData.setGb("156"); | 
|---|
|  |  |  | apiData.setSjsl(fz35Depot.getStorageReal()); | 
|---|
|  |  |  | apiData.setJjsl(fz35Depot.getStorageReal()); | 
|---|
|  |  |  | apiData.setSjsl(fz35DepotStore.getStorageReal()); | 
|---|
|  |  |  | apiData.setJjsl(fz35DepotStore.getStorageReal()); | 
|---|
|  |  |  | apiData.setSjzlxg(6); | 
|---|
|  |  |  | apiData.setLdtj(10000); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | apiData.setZhgxsj(new Date()); | 
|---|
|  |  |  | apiData.setZhgxsj(fz35DepotStore.getUpdateDate()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //业务id、库区编码、同步时间 | 
|---|
|  |  |  | apiData.setBizId(fz35Depot.getId()); | 
|---|
|  |  |  | apiData.setBizId(fz35DepotStore.getId()); | 
|---|
|  |  |  | apiData.setKqdm(kqdm); | 
|---|
|  |  |  | apiData.setSyncTime(new Date()); | 
|---|
|  |  |  | api1208List = api1208Rep.getDataById(api1105.getHwdm()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //库存每次新增 | 
|---|
|  |  |  | api1208List = api1208Rep.getDataById(apiData.getId()); | 
|---|
|  |  |  | if(null == api1208List || api1208List.isEmpty()){ | 
|---|
|  |  |  | apiData.setCzbz(Constant.CZBZ_I); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | apiData.setCzbz(api1208List.get(0).getCzbz()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | apiData.setId(api1105.getHwdm()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //保存数据 | 
|---|
|  |  |  | api1208Rep.save(apiData); | 
|---|
|  |  |  | } | 
|---|