|  |  |  | 
|---|
|  |  |  | import com.ld.igds.io.request.DepotStatusRequest; | 
|---|
|  |  |  | import com.ld.igds.io.response.BaseResponse; | 
|---|
|  |  |  | import com.ld.igds.models.*; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.apache.commons.lang3.StringUtils; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.stereotype.Component; | 
|---|
|  |  |  | import org.springframework.transaction.annotation.Transactional; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.bstek.bdf2.core.business.IUser; | 
|---|
|  |  |  | import com.bstek.dorado.annotation.DataProvider; | 
|---|
|  |  |  | import com.bstek.dorado.annotation.DataResolver; | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.ld.igds.common.CoreSerService; | 
|---|
|  |  |  | import com.ld.igds.constant.BizType; | 
|---|
|  |  |  | import com.ld.igds.constant.Constant; | 
|---|
|  |  |  | import com.ld.igds.constant.DepotStatus; | 
|---|
|  |  |  | import com.ld.igds.constant.DepotType; | 
|---|
|  |  |  | import com.ld.igds.constant.FoodLevel; | 
|---|
|  |  |  | import com.ld.igds.order.ExeOrderService; | 
|---|
|  |  |  | import com.ld.igds.order.data.ExeRequest; | 
|---|
|  |  |  | import com.ld.igds.util.ContextUtil; | 
|---|
|  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private ExeOrderService exeOrderService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 仓房类型-非国标定义 | 
|---|
|  |  |  | * ${dorado.getDataProvider("depotPR#triggerDepotType").getResult()} | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @DataProvider | 
|---|
|  |  |  | public List<DicTrigger> triggerDepotType() { | 
|---|
|  |  |  | List<DicTrigger> list = new ArrayList<DicTrigger>(); | 
|---|
|  |  |  | list.add(new DicTrigger(DepotType.TYPE_01.getCode(), DepotType.TYPE_01.getMsg())); | 
|---|
|  |  |  | list.add(new DicTrigger(DepotType.TYPE_02.getCode(), DepotType.TYPE_02.getMsg())); | 
|---|
|  |  |  | list.add(new DicTrigger(DepotType.TYPE_03.getCode(), DepotType.TYPE_03.getMsg())); | 
|---|
|  |  |  | list.add(new DicTrigger(DepotType.TYPE_04.getCode(), DepotType.TYPE_04.getMsg())); | 
|---|
|  |  |  | list.add(new DicTrigger(DepotType.TYPE_99.getCode(), DepotType.TYPE_99.getMsg())); | 
|---|
|  |  |  | return list; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 仓房状态 | 
|---|
|  |  |  | * ${dorado.getDataProvider("depotPR#triggerDepotStatus").getResult()} | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @DataProvider | 
|---|
|  |  |  | public List<DicTrigger> triggerDepotStatus() { | 
|---|
|  |  |  | List<DicTrigger> list = new ArrayList<DicTrigger>(); | 
|---|
|  |  |  | list.add(new DicTrigger(DepotStatus.STATUS_1.getCode(), DepotStatus.STATUS_1.getMsg())); | 
|---|
|  |  |  | list.add(new DicTrigger(DepotStatus.STATUS_2.getCode(), DepotStatus.STATUS_2.getMsg())); | 
|---|
|  |  |  | list.add(new DicTrigger(DepotStatus.STATUS_3.getCode(), DepotStatus.STATUS_3.getMsg())); | 
|---|
|  |  |  | list.add(new DicTrigger(DepotStatus.STATUS_4.getCode(), DepotStatus.STATUS_4.getMsg())); | 
|---|
|  |  |  | list.add(new DicTrigger(DepotStatus.STATUS_31.getCode(), DepotStatus.STATUS_31.getMsg())); | 
|---|
|  |  |  | list.add(new DicTrigger(DepotStatus.STATUS_32.getCode(), DepotStatus.STATUS_32.getMsg())); | 
|---|
|  |  |  | list.add(new DicTrigger(DepotStatus.STATUS_33.getCode(), DepotStatus.STATUS_33.getMsg())); | 
|---|
|  |  |  | list.add(new DicTrigger(DepotStatus.STATUS_34.getCode(), DepotStatus.STATUS_34.getMsg())); | 
|---|
|  |  |  | list.add(new DicTrigger(DepotStatus.STATUS_9.getCode(), DepotStatus.STATUS_9.getMsg())); | 
|---|
|  |  |  | return list; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 粮食等级 | 
|---|
|  |  |  | * ${dorado.getDataProvider("depotPR#triggerFoodLevel").getResult()} | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @DataProvider | 
|---|
|  |  |  | public List<DicTrigger> triggerFoodLevel() { | 
|---|
|  |  |  | List<DicTrigger> list = new ArrayList<DicTrigger>(); | 
|---|
|  |  |  | list.add(new DicTrigger(FoodLevel.LEVEL_01.getCode(), FoodLevel.LEVEL_01.getMsg())); | 
|---|
|  |  |  | list.add(new DicTrigger(FoodLevel.LEVEL_02.getCode(), FoodLevel.LEVEL_02.getMsg())); | 
|---|
|  |  |  | list.add(new DicTrigger(FoodLevel.LEVEL_03.getCode(), FoodLevel.LEVEL_03.getMsg())); | 
|---|
|  |  |  | list.add(new DicTrigger(FoodLevel.LEVEL_04.getCode(), FoodLevel.LEVEL_04.getMsg())); | 
|---|
|  |  |  | list.add(new DicTrigger(FoodLevel.LEVEL_05.getCode(), FoodLevel.LEVEL_05.getMsg())); | 
|---|
|  |  |  | list.add(new DicTrigger(FoodLevel.LEVEL_06.getCode(), FoodLevel.LEVEL_06.getMsg())); | 
|---|
|  |  |  | return list; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 储粮方式 | 
|---|
|  |  |  | * ${dorado.getDataProvider("depotPR#triggerStoreType").getResult()} | 
|---|
|  |  |  | 
|---|
|  |  |  | List<DicTrigger> list = new ArrayList<DicTrigger>(); | 
|---|
|  |  |  | list.add(new DicTrigger("1", "散装储粮")); | 
|---|
|  |  |  | list.add(new DicTrigger("2", "包装储粮")); | 
|---|
|  |  |  | list.add(new DicTrigger("3", "围包散存")); | 
|---|
|  |  |  | list.add(new DicTrigger("3", "围包存")); | 
|---|
|  |  |  | list.add(new DicTrigger("9", "其他")); | 
|---|
|  |  |  | return list; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 管理方式 | 
|---|
|  |  |  | * ${dorado.getDataProvider("depotPR#triggerManagerType").getResult()} | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @DataProvider | 
|---|
|  |  |  | public List<DicTrigger> triggerManagerType() { | 
|---|
|  |  |  | List<DicTrigger> list = new ArrayList<DicTrigger>(); | 
|---|
|  |  |  | list.add(new DicTrigger("01", "直储")); | 
|---|
|  |  |  | list.add(new DicTrigger("02", "代储")); | 
|---|
|  |  |  | list.add(new DicTrigger("03", "租仓")); | 
|---|
|  |  |  | list.add(new DicTrigger("04", "委托")); | 
|---|
|  |  |  | return list; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 层行转换 | 
|---|
|  |  |  | * ${dorado.getDataProvider("depotPR#triggerStartConvert").getResult()} | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @DataProvider | 
|---|
|  |  |  | public List<DicTrigger> triggerStartConvert() { | 
|---|
|  |  |  | List<DicTrigger> list = new ArrayList<DicTrigger>(); | 
|---|
|  |  |  | list.add(new DicTrigger(Constant.GRAIN_CONVERT_DEFAULT, "默认")); | 
|---|
|  |  |  | list.add(new DicTrigger(Constant.GRAIN_CONVERT_CLOCKWISE, "顺时针")); | 
|---|
|  |  |  | list.add(new DicTrigger(Constant.GRAIN_CONVERT_ANTICLOCKWISE, "逆时针")); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return list; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 筒仓锥形 | 
|---|
|  |  |  | * ${dorado.getDataProvider("depotPR#triggerCableCone").getResult()} | 
|---|
|  |  |  | * | 
|---|
|  |  |  | 
|---|
|  |  |  | // ${dorado.getDataProvider("depotPR#getAllCache").getResult()} | 
|---|
|  |  |  | @DataProvider | 
|---|
|  |  |  | public List<Depot> getAllCache(String name) { | 
|---|
|  |  |  | return depotService.getAllCache(name, null); | 
|---|
|  |  |  | return depotService.getAllCache(name, ContextUtil.getCompanyId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // depotPR#ajaxGetAllCache | 
|---|
|  |  |  | @Expose | 
|---|
|  |  |  | 
|---|
|  |  |  | // depotPR#flushCache | 
|---|
|  |  |  | @Expose | 
|---|
|  |  |  | public void flushCache() { | 
|---|
|  |  |  | depotService.flushCache(null); | 
|---|
|  |  |  | depotService.flushCache(ContextUtil.getCompanyId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // depotPR#saveOrUpdate | 
|---|
|  |  |  | 
|---|
|  |  |  | if (null == depot.getCompanyId()) { | 
|---|
|  |  |  | depotService.saveDepot(depot); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | depotService.updataDepot(depot); | 
|---|
|  |  |  | // TODO | 
|---|
|  |  |  | //            if (StringUtils.isNotEmpty(depot.getEditTag())) { | 
|---|
|  |  |  | //                // 表示修改了仓库状态 | 
|---|
|  |  |  | //                if (depot.getEditTag().indexOf("depotStatus") >= 0) { | 
|---|
|  |  |  | //                    this.pullDepotStatus(depot.getCompanyId(), depot.getId(), depot.getDepotStatus()); | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | depotService.updateDepot(depot); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | flushCache(); | 
|---|
|  |  |  | 
|---|
|  |  |  | depotService.updateFreq(freq); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void updateByStore(DepotStore data) { | 
|---|
|  |  |  | depotService.updateByStore(data); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | public void updateByStore(DepotStore data) throws Exception { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 根据仓库初始化一条出入库的流水记录 | 
|---|
|  |  |  | * public void initDepotInoutRecord(Depot depot) { | 
|---|
|  |  |  | * InoutRecord data = new InoutRecord(); | 
|---|
|  |  |  | * if (StringUtils.isEmpty(depot.getCompanyId())) { | 
|---|
|  |  |  | * depot.setCompanyId(ContextUtil.getCompanyId()); | 
|---|
|  |  |  | * } | 
|---|
|  |  |  | * data.setId(depot.getCompanyId() + "-" + depot.getId() + "-" | 
|---|
|  |  |  | * + DateFormatUtils.format(new Date(), "yyyyMMdd")); | 
|---|
|  |  |  | * data.setCheckStatus("PASS"); | 
|---|
|  |  |  | * data.setCompanyId(depot.getCompanyId()); | 
|---|
|  |  |  | * data.setCompleteTime(new Date()); | 
|---|
|  |  |  | * data.setCompleteUser(ContextUtil.getLoginUserCName()); | 
|---|
|  |  |  | * data.setDepotId(depot.getId()); | 
|---|
|  |  |  | * data.setDeptId(depot.getDeptId()); | 
|---|
|  |  |  | * data.setFoodVariety(depot.getFoodVariety()); | 
|---|
|  |  |  | * data.setFoodYear(DateFormatUtils.format(new Date(), "yyyy")); | 
|---|
|  |  |  | * data.setProgress("RECORD"); | 
|---|
|  |  |  | * data.setRecordStatus("ADD"); | 
|---|
|  |  |  | * data.setType("NONE"); | 
|---|
|  |  |  | * if (depot.getStorageReal() == null) { | 
|---|
|  |  |  | * data.setCurStorage(0); | 
|---|
|  |  |  | * } else { | 
|---|
|  |  |  | * data.setCurStorage(depot.getStorageReal()); | 
|---|
|  |  |  | * } | 
|---|
|  |  |  | * depotService.initInoutRecord(data); | 
|---|
|  |  |  | * } | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | Depot depot = depotService.getDepotById(data.getCompanyId(), data.getDepotId()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (null == depot) return; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | depot.setStorageReal(data.getStorageReal()); | 
|---|
|  |  |  | depot.setDepotStatus(data.getDepotStatus()); | 
|---|
|  |  |  | depot.setFoodLevel(data.getFoodLevel()); | 
|---|
|  |  |  | depot.setFoodLocation(data.getFoodLocation()); | 
|---|
|  |  |  | depot.setFoodVariety(data.getFoodVariety()); | 
|---|
|  |  |  | depot.setFoodType(data.getFoodType()); | 
|---|
|  |  |  | depot.setFoodYear(data.getFoodYear()); | 
|---|
|  |  |  | if (null != data.getStoreDate()) { | 
|---|
|  |  |  | depot.setStoreDate(data.getStoreDate()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | depotService.updateDepot(depot); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public String pullDepotStatus(String companyId, String depotId, String status) { | 
|---|
|  |  |  | // 执行推送 | 
|---|