From 3c6efb35ff0ebcca6e7104c20cde64825fddd59d Mon Sep 17 00:00:00 2001 From: YYC <1833023622@qq.com> Date: 星期四, 07 九月 2023 19:35:24 +0800 Subject: [PATCH] 添加数据 --- igds-inout/src/main/java/com/ld/igds/inout/manager/InoutManager.java | 145 +++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 135 insertions(+), 10 deletions(-) diff --git a/igds-inout/src/main/java/com/ld/igds/inout/manager/InoutManager.java b/igds-inout/src/main/java/com/ld/igds/inout/manager/InoutManager.java index bed9209..ebba267 100644 --- a/igds-inout/src/main/java/com/ld/igds/inout/manager/InoutManager.java +++ b/igds-inout/src/main/java/com/ld/igds/inout/manager/InoutManager.java @@ -7,6 +7,7 @@ import com.ld.igds.data.Page; import com.ld.igds.data.PageResponse; import com.ld.igds.file.CoreFileService; +import com.ld.igds.file.dto.FileData; import com.ld.igds.inout.InoutConstant; import com.ld.igds.inout.dto.InoutCheckData; import com.ld.igds.inout.dto.InoutCheckParam; @@ -19,7 +20,6 @@ import com.ld.igds.models.InoutSysConf; import com.ld.igds.util.ContextUtil; import com.ld.igds.util.DateUtil; -import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.commons.lang3.time.DateUtils; @@ -36,7 +36,6 @@ * * @author */ -@Slf4j @Component public class InoutManager { @@ -50,6 +49,8 @@ private CheckStandardManager checkStandardManager; @Resource private InoutEventControlManager inoutEventControl; + @Resource + private CoreFileService coreFileService; /** * 鐩存帴浠庢暟鎹簱鏌ヨ锛屼笉鑰冭檻淇℃伅鐘舵�� @@ -213,6 +214,34 @@ return data; } + private InoutData updateFiles(InoutData data) throws Exception { + List<FileData> files = data.getFiles(); + if (null == files) { + return data; + } + + for (FileData fileData : files) { + fileData.setFileId(ContextUtil.getUUID()); + fileData.setCompanyId(data.getCompanyId()); + fileData.setBizId(data.getId()); + if ("HANDLE".equals(fileData.getBizTag())) { + if (data.getEmptyWeightTime().before(data.getFullWeightTime())) { + fileData.setCreateTime(DateUtils.addMinutes(data.getFullWeightTime(), -20)); + } else { + fileData.setCreateTime(DateUtils.addMinutes(data.getEmptyWeightTime(), -20)); + } + } + if ("WEIGHT_EMPTY".equals(fileData.getBizTag())) { + fileData.setCreateTime(data.getEmptyWeightTime()); + } + if ("WEIGHT_FULL".equals(fileData.getBizTag())) { + fileData.setCreateTime(data.getFullWeightTime()); + } + coreFileService.addRecord(fileData); + } + + return data; + } /** * 浠庣紦瀛樹腑鑾峰彇涓嬩竴娴佺▼ @@ -367,8 +396,9 @@ if (null != msg) { return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg); } - - + data.setCompleteTime(param.getCompleteTime()); + data.setProgress(InoutConstant.PROGRESS_RECORD); + inoutService.updateInoutCache(data); // 娴佺▼瀹屾垚鏀朵簨浠� inoutEventControl.onInoutComplete(data); @@ -405,7 +435,7 @@ data.setCompleteTime(new Date()); } // 娉ㄥ唽鏃堕棿姣斿畬鎴愭椂闂存棭涓�涓皬鏃� - data.setRegisterTime(DateUtil.getNewByMinute(new Date(), -60)); + data.setRegisterTime(DateUtils.addMinutes(new Date(), -80)); if (StringUtils.isEmpty(data.getUserId())) { data.setUserId(InoutConstant.DEFAULT_ID_CARD); @@ -420,19 +450,38 @@ if (InoutConstant.TYPE_IN.equals(data.getType())) { if (null == data.getFullWeightTime()) { - data.setFullWeightTime(DateUtil.getNewByMinute(new Date(), -50)); + data.setFullWeightTime(DateUtils.addMinutes(new Date(), -50)); } if (null == data.getEmptyWeightTime()) { - data.setEmptyWeightTime(DateUtil.getNewByMinute(new Date(), -10)); + data.setEmptyWeightTime(DateUtils.addMinutes(new Date(), -10)); + } + + if (data.getCompleteTime().before(data.getEmptyWeightTime())) { + data.setEmptyWeightTime(DateUtils.addMinutes(data.getCompleteTime(), -10)); + } + if (data.getEmptyWeightTime().before(data.getFullWeightTime())) { + data.setFullWeightTime(DateUtils.addMinutes(data.getEmptyWeightTime(), -40)); + } + if (data.getFullWeightTime().before(data.getRegisterTime())) { + data.setRegisterTime(DateUtils.addMinutes(data.getFullWeightTime(), -30)); } data = this.updateCheckItems(data, false); } else { if (null == data.getEmptyWeightTime()) { - data.setEmptyWeightTime(DateUtil.getNewByMinute(new Date(), -50)); + data.setEmptyWeightTime(DateUtils.addMinutes(new Date(), -50)); } if (null == data.getFullWeightTime()) { - data.setFullWeightTime(DateUtil.getNewByMinute(new Date(), -10)); + data.setFullWeightTime(DateUtils.addMinutes(new Date(), -10)); + } + if (data.getCompleteTime().before(data.getFullWeightTime())) { + data.setFullWeightTime(DateUtils.addMinutes(data.getCompleteTime(), -10)); + } + if (data.getFullWeightTime().before(data.getEmptyWeightTime())) { + data.setEmptyWeightTime(DateUtils.addMinutes(data.getEmptyWeightTime(), -40)); + } + if (data.getEmptyWeightTime().before(data.getRegisterTime())) { + data.setRegisterTime(DateUtils.addMinutes(data.getFullWeightTime(), -30)); } } @@ -443,6 +492,7 @@ if (InoutConstant.TYPE_IN.equals(data.getType())) { this.updateCheckItems(data, true); } + this.updateFiles(data); return null; } @@ -841,6 +891,7 @@ data.setCheckTime(new Date()); } curData.setCheckStatus(data.getCheckStatus()); + curData.setFoodYear(data.getFoodYear()); // 鑾峰彇涓嬩竴涓祦绋嬬姸鎬� @@ -860,6 +911,8 @@ curData.setPrice(data.getPrice()); curData.setRemarks(data.getRemarks()); curData.setCheckItems(data.getCheckItems()); + curData.setCheckTime(data.getCheckTime()); + curData.setDepotId(data.getDepotId()); if (StringUtils.isEmpty(data.getCheckUser())) { curData.setCheckUser(ContextUtil.getLoginUserCName()); @@ -876,9 +929,50 @@ // 璐ㄦ瀹屾垚瑙﹀彂浜嬩欢 - inoutEventControl.onInCheck(data,curProgress,nextProgress); + inoutEventControl.onInCheck(data, curProgress, nextProgress); return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛"); + } + + public PageResponse<InoutCheckData> submitCheckData(InoutCheckData data) throws Exception { + + + // 鑾峰彇涓氬姟鏁版嵁淇℃伅 + InoutParam param = new InoutParam(); + param.setCompanyId(data.getCompanyId()); + param.setId(data.getId()); + InoutData curData = inoutService.inoutProgressQuery(param); + + if (null == curData) { + return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), + "娌℃湁鑾峰彇鍒板叆搴撲笟鍔℃暟鎹俊鎭紝鏇存柊澶辫触", data); + } + + if (InoutConstant.PROGRESS_RECORD.equals(curData.getProgress())) { + return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), + "褰撳墠娴佺▼宸茬粡缁撴潫锛屼笉鏀寔淇敼"); + } + + // 鏇存柊鍖栭獙椤逛俊鎭� + CheckUpdateResult checkResult = checkStandardManager.updateCheckItems(data.getCheckId(), data.getCompanyId(), data.getCheckItems()); + if (StringUtils.isNotEmpty(checkResult.getMsg())) { + return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), + "鍚庡彴鎵ц寮傚父锛�" + checkResult.getMsg(), data); + } + + curData.setType(curData.getType()); + curData.setFoodLevel(data.getFoodLevel()); + curData.setFoodVariety(data.getFoodVariety()); + curData.setPrice(data.getPrice()); + curData.setDepotId(data.getDepotId()); + curData.setCheckItems(data.getCheckItems()); + + String msg = inoutService.updateCheckData(curData); + if (null != msg) { + return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg); + } + + return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "淇濆瓨鎴愬姛"); } /** @@ -952,4 +1046,35 @@ } } + /** + * @param param + * @return + */ + public PageResponse<InoutCheckData> inoutDataByCheckId(InoutCheckParam param) { + if (StringUtils.isEmpty(param.getCheckId())) { + return new PageResponse<>(RespCodeEnum.CODE_1007.getCode(), + "鏌ヨ鍙傛暟涓嶅畬鏁达紝鏌ヨ澶辫触锛�"); + } + + InoutCheckData result; + try { + param.setProgress(InoutConstant.PROGRESS_CHECK); + result = inoutService.inoutDataByCheckId(param); + if (null == result) { + return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(), + "绯荤粺鏈煡璇㈠埌鎵ц涓殑杞﹁締淇℃伅", null); + } + + return new PageResponse<>(RespCodeEnum.CODE_0000, result); + + } catch (Exception e) { + return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(), + e.getMessage()); + } + } + + public void initInoutWeight(List<InoutConf> listInoutConf, String sort) { + inoutEventControl.initInoutWeight(listInoutConf, sort); + } + } \ No newline at end of file -- Gitblit v1.9.3