From a4d556ff6f8191637be669e7884fc3e500021516 Mon Sep 17 00:00:00 2001 From: jiazx0107@163.com <jiazx0107@163.com> Date: 星期四, 22 六月 2023 01:15:28 +0800 Subject: [PATCH] 测试入库流程 --- igds-inout/src/main/resources/mapper/InoutRecordMapper.xml | 2 igds-web/src/main/resources/templates/admin/inout/in-card-back.html | 4 igds-inout/src/main/java/com/ld/igds/inout/manager/InoutManager.java | 1300 ++++++++++++++++++++++--------------------- igds-inout/src/main/java/com/ld/igds/inout/dto/InoutCheckData.java | 3 igds-web/src/main/resources/static/admin/inout/in-sample.js | 160 ---- igds-inout/src/main/resources/mapper/InoutCheckMapper.xml | 3 igds-inout/src/main/java/com/ld/igds/inout/service/impl/InoutServiceImpl.java | 9 igds-web/src/main/resources/templates/admin/inout/in-sample.html | 26 igds-web/src/main/resources/static/admin/inout/inout-common.js | 7 igds-inout/src/main/java/com/ld/igds/inout/controller/InoutController.java | 153 ++-- igds-inout/src/main/java/com/ld/igds/inout/manager/CheckManager.java | 5 igds-web/src/main/resources/static/admin/inout/in-card-back.js | 4 igds-core/src/main/java/com/ld/igds/inout/dto/InoutParam.java | 85 +- 13 files changed, 827 insertions(+), 934 deletions(-) diff --git a/igds-core/src/main/java/com/ld/igds/inout/dto/InoutParam.java b/igds-core/src/main/java/com/ld/igds/inout/dto/InoutParam.java index 084299f..7b7f4b1 100644 --- a/igds-core/src/main/java/com/ld/igds/inout/dto/InoutParam.java +++ b/igds-core/src/main/java/com/ld/igds/inout/dto/InoutParam.java @@ -10,79 +10,80 @@ /** * 鍑哄叆搴撶殑椤甸潰鍙傛暟瀹氫箟 - * - * @author jiazx * + * @author jiazx */ @Data @EqualsAndHashCode(callSuper = false) public class InoutParam extends BaseParam { - public String plateNum;// 杞︾墝鍙� + public String plateNum;// 杞︾墝鍙� - private String intelCard;// 鏅烘収鍗″彿 + private String intelCard;// 鏅烘収鍗″彿 - private String id;// 娴佹按鍙� + private String id;// 娴佹按鍙� - private String progress;// 褰撳墠鎵�鍦ㄦ祦绋� + private String progress;// 褰撳墠鎵�鍦ㄦ祦绋� - private String type;// 涓氬姟鏁版嵁绫诲瀷锛屽嚭搴撴垨鑰呭叆搴� + private String type;// 涓氬姟鏁版嵁绫诲瀷锛屽嚭搴撴垨鑰呭叆搴� - private String checkId;// 鍖栭獙鍗曞彿 + private String checkId;// 鍖栭獙鍗曞彿 - @PropertyDef(label = "鍝佺") - private String foodVariety; + @PropertyDef(label = "鍝佺") + private String foodVariety; - @PropertyDef(label = "绫诲瀷") - private String foodType; + @PropertyDef(label = "绫诲瀷") + private String foodType; - private String checkStatus; + private String checkStatus; - private String customerName; + private String customerName; - private String customerId; + private String customerId; - private String recordStatus; + private String recordStatus; - private String msg; - - private String userId;//鐧婚檰浜篒D + private String msg; - private double curStorage=0.0;//褰撳墠搴撳瓨鑾峰彇鎹熸孩鐨勫簱瀛� + private String userId;//鐧婚檰浜篒D - private String year; // 骞翠唤 - - private String deptId;// 鎵�灞炲垎搴� - - private String orderTag = "DESC"; - - private double weight;//閲嶉噺淇℃伅 + private double curStorage = 0.0;//褰撳墠搴撳瓨鑾峰彇鎹熸孩鐨勫簱瀛� - private Double de; + private String year; // 骞翠唤 - private Double fullWeight; + private String deptId;// 鎵�灞炲垎搴� - private String fullWeightUser; + private String orderTag = "DESC"; - private Date fullWeightTime; + private double weight;//閲嶉噺淇℃伅 - private Double emptyWeight; + private Double de; - private Date emptyWeightTime; + private Double fullWeight; - private Date completeTime; + private String fullWeightUser; - private String emptyWeightUser; + private Date fullWeightTime; - private Double netWeight; + private Double emptyWeight; - private Double settleWeight; - private Double recordWeight; + private Date emptyWeightTime; - //鏄惁缁撶畻 - private String settleTag; + private Date completeTime; - private Double price; + private String emptyWeightUser; - private Double settleMoney; + private Double netWeight; + + private Double settleWeight; + private Double recordWeight; + + //鏄惁缁撶畻 + private String settleTag; + + private Double price; + + private Double settleMoney; + + private Date updateTime = new Date(); } diff --git a/igds-inout/src/main/java/com/ld/igds/inout/controller/InoutController.java b/igds-inout/src/main/java/com/ld/igds/inout/controller/InoutController.java index 759bdcc..8c1031d 100644 --- a/igds-inout/src/main/java/com/ld/igds/inout/controller/InoutController.java +++ b/igds-inout/src/main/java/com/ld/igds/inout/controller/InoutController.java @@ -25,7 +25,6 @@ import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.time.DateFormatUtils; import org.springframework.transaction.annotation.Transactional; -import org.springframework.transaction.interceptor.TransactionAspectSupport; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; @@ -100,9 +99,69 @@ view.setViewName("admin/inout/in-register"); return view; } + + + /** + * 鎵︽牱椤甸潰 + * + * @param sort 琛ㄧず浣跨敤鐨勫嚭鍏ュ簱璁惧閰嶅鍙凤紝涓嶄紶閫掗粯璁や负1 + * @return + */ + @RequestMapping("/in-sample") + public ModelAndView inSample(HttpServletRequest httpRequest, @RequestParam(value = "sort", required = false) String sort) { + if (StringUtils.isEmpty(sort)) { + sort = commonManager.getInoutWeightByClient(httpRequest); + } + ModelAndView view = new ModelAndView(); + // 浠撳簱鍒楄〃鍋氫笅鎷夋浣跨敤 + List<Depot> listDepot = commonManager.listDepot(true); + view.addObject(Constant.MODEL_KEY_DEPOT_LIST, listDepot); + + IUser user = ContextUtil.getLoginUser(); + view.addObject(Constant.MODEL_KEY_LOGIN_USER, user); + + String deptId = ContextUtil.subDeptId(user); + + view.addObject("bizType", BizType.INOUT_IN.getCode()); + view.addObject("type", InoutConstant.TYPE_IN); + view.addObject("deptId", deptId); + DefaultDept dept = commonManager.getSubDept(user, deptId); + view.addObject("deptName", dept.getName()); + + //鍏ュ簱娴佺▼ + String inoutProgress = inoutCommonManager.getInoutProgressConf(user.getCompanyId(), deptId, InoutConstant.TYPE_IN); + view.addObject("inoutProgress", inoutProgress); + + // 褰撳墠娴佺▼鑺傜偣 + view.addObject("progress", InoutConstant.PROGRESS_CHECK); + + // 绮鍝佺涓嬫媺妗� + List<DicTrigger> listFoodVariety = inoutCommonManager.getDicTrigger( + Constant.TRIGGER_PARENT_FOOD_VARIETY, user.getCompanyId()); + view.addObject("listFoodVariety", listFoodVariety); + + // 绮绛夌骇涓嬫媺妗� + List<DicTrigger> listFoodLevel = inoutCommonManager.getDicTrigger( + Constant.TRIGGER_PARENT_FOOD_LEVEL, user.getCompanyId()); + view.addObject("listFoodLevel", listFoodLevel); + + view.addObject("endTime", + DateFormatUtils.format(new Date(), "yyyy-MM-dd")); + view.addObject("startTime", DateFormatUtils.format( + DateUtil.getNewByDay(null, -10), "yyyy-MM-dd")); + + // 鑾峰彇鍑哄叆搴撻厤缃俊鎭� + List<InoutConf> listInoutConf = inoutCommonManager.getListInoutConf(user.getCompanyId(), deptId); + + // 鑾峰彇鎵︽牱鏈轰俊鎭� + InoutConf conf = inoutCommonManager.getInoutConf(listInoutConf, sort, InoutConstant.CONF_TYPE_20, InoutConstant.PROGRESS_CHECK, 1); + view.addObject("checkDto", conf); + view.setViewName("admin/inout/in-sample"); + return view; + } /** - * 鎵︽牱鍖栭獙椤甸潰 + * 璐ㄦ椤甸潰 * * @param sort 琛ㄧず浣跨敤鐨勫嚭鍏ュ簱璁惧閰嶅鍙凤紝涓嶄紶閫掗粯璁や负1 * @return @@ -309,15 +368,6 @@ // 褰撳墠娴佺▼鑺傜偣 view.addObject("progress", InoutConstant.PROGRESS_CARD_BACK); - // 绮鍝佺涓嬫媺妗� - List<DicTrigger> listFoodVariety = inoutCommonManager.getDicTrigger( - Constant.TRIGGER_PARENT_FOOD_VARIETY, user.getCompanyId()); - view.addObject("listFoodVariety", listFoodVariety); - - // 绮绛夌骇涓嬫媺妗� - List<DicTrigger> listFoodLevel = inoutCommonManager.getDicTrigger( - Constant.TRIGGER_PARENT_FOOD_LEVEL, user.getCompanyId()); - view.addObject("listFoodLevel", listFoodLevel); view.setViewName("admin/inout/in-card-back"); return view; @@ -574,6 +624,18 @@ } /** + * 鎵︽牱椤甸潰鎻愪氦鏇存柊 + * + * @param data + * @return + */ + @RequestMapping("/submit-sample") + @Transactional + public PageResponse<InoutCheckData> submitSample(@RequestBody InoutCheckData data) throws Exception { + return inoutManager.submitSample(data); + } + + /** * 鍑哄叆搴撶О閲嶇幆鑺傛彁浜� * * @param data @@ -654,64 +716,7 @@ } - /** - * 鎵︽牱椤甸潰 - * - * @param sort 琛ㄧず浣跨敤鐨勫嚭鍏ュ簱璁惧閰嶅鍙凤紝涓嶄紶閫掗粯璁や负1 - * @return - */ - @RequestMapping("/in-sample") - public ModelAndView inSample(HttpServletRequest httpRequest, @RequestParam(value = "sort", required = false) String sort) { - if (StringUtils.isEmpty(sort)) { - sort = commonManager.getInoutWeightByClient(httpRequest); - } - ModelAndView view = new ModelAndView(); - // 浠撳簱鍒楄〃鍋氫笅鎷夋浣跨敤 - List<Depot> listDepot = commonManager.listDepot(true); - view.addObject(Constant.MODEL_KEY_DEPOT_LIST, listDepot); - - IUser user = ContextUtil.getLoginUser(); - view.addObject(Constant.MODEL_KEY_LOGIN_USER, user); - - String deptId = ContextUtil.subDeptId(user); - - view.addObject("bizType", BizType.INOUT_IN.getCode()); - view.addObject("type", InoutConstant.TYPE_IN); - view.addObject("deptId", deptId); - DefaultDept dept = commonManager.getSubDept(user, deptId); - view.addObject("deptName", dept.getName()); - - //鍏ュ簱娴佺▼ - String inoutProgress = inoutCommonManager.getInoutProgressConf(user.getCompanyId(), deptId, InoutConstant.TYPE_IN); - view.addObject("inoutProgress", inoutProgress); - - // 褰撳墠娴佺▼鑺傜偣 - view.addObject("progress", InoutConstant.PROGRESS_CHECK); - - // 绮鍝佺涓嬫媺妗� - List<DicTrigger> listFoodVariety = inoutCommonManager.getDicTrigger( - Constant.TRIGGER_PARENT_FOOD_VARIETY, user.getCompanyId()); - view.addObject("listFoodVariety", listFoodVariety); - - // 绮绛夌骇涓嬫媺妗� - List<DicTrigger> listFoodLevel = inoutCommonManager.getDicTrigger( - Constant.TRIGGER_PARENT_FOOD_LEVEL, user.getCompanyId()); - view.addObject("listFoodLevel", listFoodLevel); - - view.addObject("endTime", - DateFormatUtils.format(new Date(), "yyyy-MM-dd")); - view.addObject("startTime", DateFormatUtils.format( - DateUtil.getNewByDay(null, -10), "yyyy-MM-dd")); - - // 鑾峰彇鍑哄叆搴撻厤缃俊鎭� - List<InoutConf> listInoutConf = inoutCommonManager.getListInoutConf(user.getCompanyId(), deptId); - - // 鑾峰彇鎵︽牱鏈轰俊鎭� - InoutConf conf = inoutCommonManager.getInoutConf(listInoutConf, sort, InoutConstant.CONF_TYPE_20, InoutConstant.PROGRESS_CHECK, 1); - view.addObject("checkDto", conf); - view.setViewName("admin/inout/in-sample"); - return view; - } + /** * 鍒嗛〉鑾峰彇鎵︽牱鏁版嵁 @@ -724,17 +729,7 @@ return inoutManager.pageSampleData(param); } - /** - * 鎵︽牱椤甸潰鎻愪氦鏇存柊 - * - * @param data - * @return - */ - @RequestMapping("/update-sample") - public PageResponse<InoutCheckData> updateSample(@RequestBody InoutCheckData data) { - return inoutManager.updateSampleData(data); - } /** * 鍒嗛〉鑾峰彇鍖栭獙鏁版嵁 diff --git a/igds-inout/src/main/java/com/ld/igds/inout/dto/InoutCheckData.java b/igds-inout/src/main/java/com/ld/igds/inout/dto/InoutCheckData.java index 67b104f..e41f0c0 100644 --- a/igds-inout/src/main/java/com/ld/igds/inout/dto/InoutCheckData.java +++ b/igds-inout/src/main/java/com/ld/igds/inout/dto/InoutCheckData.java @@ -2,7 +2,6 @@ import com.fasterxml.jackson.annotation.JsonFormat; import com.ld.igds.check.dto.CheckItemData; -import com.ld.igds.inout.InoutConstant; import lombok.Data; import java.io.Serializable; import java.util.Date; @@ -81,6 +80,8 @@ private String remarks; + private Date updateTime; + //鍖栭獙椤规暟鎹俊鎭� private List<CheckItemData> checkItems; } diff --git a/igds-inout/src/main/java/com/ld/igds/inout/manager/CheckManager.java b/igds-inout/src/main/java/com/ld/igds/inout/manager/CheckManager.java index c7d1e8e..1add276 100644 --- a/igds-inout/src/main/java/com/ld/igds/inout/manager/CheckManager.java +++ b/igds-inout/src/main/java/com/ld/igds/inout/manager/CheckManager.java @@ -1,17 +1,12 @@ package com.ld.igds.inout.manager; -import com.ld.igds.inout.InoutConstant; -import com.ld.igds.io.dto.CheckResultParam; import com.ld.igds.io.sample.ApiSampleManager; import com.ld.igds.io.sample.ApiSampleService; import com.ld.igds.io.sample.data.SampleDto; import com.ld.igds.m.service.InoutCommonService; -import com.ld.igds.util.ContextUtil; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import java.util.HashMap; -import java.util.Map; @Component("inout.checkManager") public class CheckManager { 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 74162dc..f9426de 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 @@ -57,7 +57,6 @@ @Resource private InoutDeviceManager inoutDeviceManager; - /** * 鐩存帴浠庢暟鎹簱鏌ヨ锛屼笉鑰冭檻淇℃伅鐘舵�� * @@ -73,7 +72,7 @@ "鏌ヨ鍙傛暟涓嶅畬鏁达紝鏌ヨ澶辫触锛�"); } - //鑾峰彇涓夊ぉ浠ュ唴鏈�鍚庝竴澶╄褰� + // 鑾峰彇涓夊ぉ浠ュ唴鏈�鍚庝竴澶╄褰� param.setStart(DateUtil.getNewByDay(new Date(), -3)); param.setType(null); param.setProgress(null); @@ -86,11 +85,13 @@ } if (InoutConstant.PROGRESS_RECORD.equals(result.getProgress())) { - return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(), "褰撳墠杞﹁締娴佺▼宸茬粡缁撴潫", result); + return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(), + "褰撳墠杞﹁締娴佺▼宸茬粡缁撴潫", result); } if (!InoutConstant.PROGRESS_CARD_BACK.equals(result.getProgress())) { - return new PageResponse<>(RespCodeEnum.CODE_1008.getCode(), "褰撳墠杞﹁締娴佺▼涓嶅湪褰撳墠鐜妭锛屾棤娉曟墽琛屽嚭搴�", result); + return new PageResponse<>(RespCodeEnum.CODE_1008.getCode(), + "褰撳墠杞﹁締娴佺▼涓嶅湪褰撳墠鐜妭锛屾棤娉曟墽琛屽嚭搴�", result); } return new PageResponse<>(RespCodeEnum.CODE_0000, result); @@ -126,16 +127,16 @@ return new PageResponse<>(RespCodeEnum.CODE_0000, result); } - - //娴佺▼绫诲瀷楠岃瘉 + // 娴佺▼绫诲瀷楠岃瘉 if (!result.getType().equals(param.getType())) { String msg = "娴佺▼閿欒锛氬綋鍓嶈溅杈嗘祦绋嬩负銆愬叆搴撱��"; - if (InoutConstant.TYPE_OUT.equals(result.getType())) msg = "娴佺▼閿欒锛氬綋鍓嶈溅杈嗘祦绋嬩负銆愬嚭搴撱��"; - return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(), msg, result); + if (InoutConstant.TYPE_OUT.equals(result.getType())) + msg = "娴佺▼閿欒锛氬綋鍓嶈溅杈嗘祦绋嬩负銆愬嚭搴撱��"; + return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(), + msg, result); } - - //娴佺▼鐜妭楠岃瘉 + // 娴佺▼鐜妭楠岃瘉 if (progress.equals(InoutConstant.PROGRESS_WEIGHT_TAG)) { if (result.getProgress().equals( InoutConstant.PROGRESS_WEIGHT_EMPTY) @@ -167,7 +168,6 @@ } } - public InoutData inoutProgressQuery(InoutData data) throws Exception { InoutParam param = new InoutParam(); param.setCompanyId(data.getCompanyId()); @@ -188,18 +188,19 @@ InoutSysConf inoutSysConf = inoutCommonService.getCacheInoutSysConf( data.getCompanyId(), data.getDeptId()); - if (inoutSysConf.getNoPassNext().equals(InoutConstant.CHECK_NOPASS_RECORD)) { + if (inoutSysConf.getNoPassNext().equals( + InoutConstant.CHECK_NOPASS_RECORD)) { // 娴佺▼缁撴潫 data.setProgress(InoutConstant.PROGRESS_RECORD); data.setCompleteTime(new Date()); } - if (inoutSysConf.getNoPassNext().equals(InoutConstant.CHECK_NOPASS_BACK)) { + if (inoutSysConf.getNoPassNext() + .equals(InoutConstant.CHECK_NOPASS_BACK)) { // 绂诲簱鏀跺崱 data.setProgress(InoutConstant.PROGRESS_CARD_BACK); } return data; } - /** * 鏇存柊璐ㄦ淇℃伅 @@ -209,11 +210,13 @@ */ private CheckUpdateResult updateCheckItems(InoutData data) { CheckUpdateResult result = new CheckUpdateResult(); - if (null == data.getCheckItems()) return result; + if (null == data.getCheckItems()) + return result; try { // 鏇存柊妫�楠岄」鏁版嵁 - result = checkStandardManager.updateCheckItems(data.getCheckId(), data.getCompanyId(), data.getCheckItems()); + result = checkStandardManager.updateCheckItems(data.getCheckId(), + data.getCompanyId(), data.getCheckItems()); // 灏嗗寲楠屾暟鎹瓨鍏ョ紦瀛樹腑 inoutService.setCheckCache(data); @@ -232,7 +235,8 @@ * * @return */ - private String getNextProgress(String curProgress, String type, InoutSysConf sysConf) { + private String getNextProgress(String curProgress, String type, + InoutSysConf sysConf) { String nextProgress = null; List<String> list = null; if (InoutConstant.TYPE_IN.equals(type)) { @@ -258,7 +262,8 @@ * @param data * @return */ - private InoutData updateBasicInfo(InoutData data, String curProgress, String nextProgress) { + private InoutData updateBasicInfo(InoutData data, String curProgress, + String nextProgress) { if (InoutConstant.PROGRESS_REGISTER.equals(curProgress)) { data.setRegisterTime(new Date()); @@ -291,7 +296,7 @@ data.setProgress(nextProgress); } - //濡傛灉涓嬩竴涓暟鎹姸鎬�=娴佺▼缁撴潫锛岀洿鎺ヨˉ鍏呭畬鏁翠俊鎭� + // 濡傛灉涓嬩竴涓暟鎹姸鎬�=娴佺▼缁撴潫锛岀洿鎺ヨˉ鍏呭畬鏁翠俊鎭� if (InoutConstant.PROGRESS_RECORD.equals(nextProgress)) { data.setCompleteTime(DateUtils.addMinutes(new Date(), 2)); data.setCompleteUser(ContextUtil.getLoginUserCName()); @@ -370,8 +375,8 @@ return data; } - - public PageResponse<InoutData> submitComplete(InoutData data) throws Exception { + public PageResponse<InoutData> submitComplete(InoutData data) + throws Exception { if (StringUtils.isEmpty(data.getId()) || StringUtils.isEmpty(data.getType()) @@ -380,7 +385,6 @@ return new PageResponse<>(RespCodeEnum.CODE_1007.getCode(), "娌℃湁鑾峰彇鍒拌溅杈嗕俊鎭��", data); } - data.setUpdateTime(new Date()); if (null == data.getCompleteTime()) { @@ -402,7 +406,6 @@ param.setCompleteTime(data.getCompleteTime()); param.setProgress(InoutConstant.PROGRESS_RECORD); - String msg = inoutService.toComplete(param); if (null != msg) { @@ -420,18 +423,18 @@ */ public PageResponse<InoutData> submitCardBack(InoutData data) { try { - //濡傛灉褰撳墠鏁版嵁宸茬粡缁撴潫 + // 濡傛灉褰撳墠鏁版嵁宸茬粡缁撴潫 if (InoutConstant.PROGRESS_RECORD.equals(data.getProgress())) { - //鍒犻櫎缂撳瓨 - inoutService.delFromCache(data.getDeptId(), data.getType(), data.getId()); + // 鍒犻櫎缂撳瓨 + inoutService.delFromCache(data.getDeptId(), data.getType(), + data.getId()); return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "褰撹溅杈嗘祦绋嬪凡缁忓畬鎴愶紝鍗$墖宸插洖鏀�", data); } - - //濡傛灉褰撳墠娴佺▼涓嶆槸鍗″洖鏀� + // 濡傛灉褰撳墠娴佺▼涓嶆槸鍗″洖鏀� if (!InoutConstant.PROGRESS_CARD_BACK.equals(data.getProgress())) { return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), @@ -447,649 +450,670 @@ return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), "鍚庣鎵ц寮傚父锛�" + e.getMessage()); } - - return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), - "鎵ц鎴愬姛", data); + + return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛", + data); } + /** + * 琛ュ崟鎿嶄綔 琛ュ崟鍥犱负瀹屾垚鏃堕棿涓嶇‘瀹氾紝鎵�浠ラ渶瑕佺郴缁熸牴鎹綋鍓嶆暟鎹繘琛岃嚜鍔ㄦ娴嬶紝璋冩暣鍘熸潵娴佹按淇℃伅鍜屽簱瀛� + * + * @param data + * @return + * @throws Exception + */ + public String addInoutData(InoutData data) throws Exception { - /** - * 琛ュ崟鎿嶄綔 琛ュ崟鍥犱负瀹屾垚鏃堕棿涓嶇‘瀹氾紝鎵�浠ラ渶瑕佺郴缁熸牴鎹綋鍓嶆暟鎹繘琛岃嚜鍔ㄦ娴嬶紝璋冩暣鍘熸潵娴佹按淇℃伅鍜屽簱瀛� - * - * @param data - * @return - * @throws Exception - */ - public String addInoutData(InoutData data) throws Exception { - - if (data.getSettleWeight() <= 0.0) { - return "琛ュ崟鏁版嵁瑕佹眰缁撶畻閲嶉噺蹇呴』澶т簬0"; - } - - // 琛ュ崟鏁版嵁鐩存帴鍒扮粨鏋滅姸鎬� - data.setRecordStatus(InoutConstant.RECORD_STATUS_ADD); - data.setProgress(InoutConstant.PROGRESS_RECORD); - if (InoutConstant.STATUS_NONE.equals(data.getCheckStatus())) { - data.setCheckStatus(InoutConstant.STATUS_PASS); - } - - String loginUser = ContextUtil.getLoginUserCName(); - data.setRegisterUser(loginUser); - data.setFullWeightUser(loginUser); - data.setEmptyWeightUser(loginUser); - data.setHandleUser(loginUser); - data.setCompleteUser(loginUser); - if (null == data.getCompleteTime()) { - data.setCompleteTime(new Date()); - } - // 娉ㄥ唽鏃堕棿姣斿畬鎴愭椂闂存棭涓�涓皬鏃� - data.setRegisterTime(DateUtil.getNewByMinute(new Date(), -60)); - - if (StringUtils.isEmpty(data.getUserId())) { - data.setUserId(InoutConstant.DEFAULT_ID_CARD); - } - if (null == data.getIntelCard()) { - data.setIntelCard(data.getUserId()); - } - if (null != data.getCheckItems()) { - data.setCheckUser(loginUser); - } - - // 淇濆瓨妫�娴嬮」鐩� - if (InoutConstant.TYPE_IN.equals(data.getType())) { - - if (null == data.getFullWeightTime()) { - data.setFullWeightTime(DateUtil.getNewByMinute(new Date(), -50)); - } - if (null == data.getEmptyWeightTime()) { - data.setEmptyWeightTime(DateUtil.getNewByMinute(new Date(), -10)); - } - - // 鍏堟墽琛屽寲楠屼俊鎭繚瀛� - CheckUpdateResult checkResult = checkStandardManager.updateCheckItems(data.getCheckId(), data.getCompanyId(), data.getCheckItems()); - if (null != checkResult) { -// if (null == data.getWet())data.setWet(checkResult.getWet()); -// if (null == data.getImpurity())data.setImpurity(checkResult.getImpurity()); - } - } else { - if (null == data.getEmptyWeightTime()) { - data.setEmptyWeightTime(DateUtil.getNewByMinute(new Date(), -50)); - } - if (null == data.getFullWeightTime()) { - data.setFullWeightTime(DateUtil.getNewByMinute(new Date(), -10)); - } - } - - // 娣诲姞琛ュ崟鏁版嵁 - String msg = inoutService.insertData(data); - - // 鍒濆鍖栭獙璇佸嚭鍏ュ簱搴撳瓨 - commonService.initInoutDepotStore(data); - return msg; + if (data.getSettleWeight() <= 0.0) { + return "琛ュ崟鏁版嵁瑕佹眰缁撶畻閲嶉噺蹇呴』澶т簬0"; } - /** - * 淇敼鎿嶄綔 淇敼閫昏緫璇存槑锛氫慨鏀规暟鎹渶瑕佽幏鍙栧師鏁版嵁搴撲腑鐨勬暟鎹繘琛屽姣斻�� - * - * @param data - * @return - * @throws Exception - */ - @Transactional - public String updateInoutData(InoutData data)throws Exception { - - if (InoutConstant.RECORD_STATUS_DEL.equals(data.getRecordStatus())) { - return "绯荤粺锛氬凡缁忓垹闄ょ殑鏁版嵁涓嶆敮鎸佷慨鏀癸紒"; - } - if (InoutConstant.RECORD_STATUS_ERROR.equals(data.getRecordStatus())) { - return "绯荤粺锛氬紓甯哥粓姝㈢殑鏁版嵁涓嶆敮鎸佷慨鏀癸紒"; - } - - // 濡傛灉娴佺▼鏈粨鏉燂紝鍙洿鏂版暟鎹� - if (!InoutConstant.PROGRESS_RECORD.equals(data.getProgress())) { - return inoutService.updateData(data); - } - - // 濡傛灉鏄凡缁忓畬鎴愮殑鏁版嵁锛屽厛鑾峰彇鍒颁慨鏀圭洿鎺ョ殑鏁版嵁鏍规嵁鏁版嵁杩涜瀵规瘮 - InoutParam param = new InoutParam(); - param.setId(data.getId()); - param.setCompanyId(data.getCompanyId()); - param.setType(data.getType()); - InoutData record = inoutService.inoutQueryById(param); - - if (null == record) { - return "褰撳墠淇敼鏁版嵁宸茬粡涓嶅瓨鍦紒"; - } - - // 閬垮厤鏁版嵁搴撲腑鐨勬暟鎹凡缁忚鍏朵粬浜轰慨鏀� - if (InoutConstant.RECORD_STATUS_DEL.equals(record.getRecordStatus())) { - return "绯荤粺锛氬凡缁忓垹闄ょ殑鏁版嵁涓嶆敮鎸佷慨鏀癸紒"; - } - if (InoutConstant.RECORD_STATUS_ERROR.equals(record.getRecordStatus())) { - return "绯荤粺锛氬紓甯哥粓姝㈢殑鏁版嵁涓嶆敮鎸佷慨鏀癸紒"; - } - - // 淇濆瓨妫�娴嬮」鐩� - if (InoutConstant.TYPE_IN.equals(data.getType())) { - // 鍏堟墽琛屽寲楠屼俊鎭繚瀛� - CheckUpdateResult checkResult = checkStandardManager - .updateCheckItems(data.getCheckId(), data.getCompanyId(), - data.getCheckItems()); - if (null != checkResult) { -// if (null == data.getWet()) -// data.setWet(checkResult.getWet()); -// if (null == data.getImpurity()) -// data.setImpurity(checkResult.getImpurity()); - } - } - - // 鏇存柊鏁版嵁 - inoutService.updateData(data); - return null; + // 琛ュ崟鏁版嵁鐩存帴鍒扮粨鏋滅姸鎬� + data.setRecordStatus(InoutConstant.RECORD_STATUS_ADD); + data.setProgress(InoutConstant.PROGRESS_RECORD); + if (InoutConstant.STATUS_NONE.equals(data.getCheckStatus())) { + data.setCheckStatus(InoutConstant.STATUS_PASS); } - /** - * 鍒犻櫎鎿嶄綔 鍒犻櫎鏁版嵁涓鸿蒋鍒犻櫎锛屽垹闄ゆ暟鎹悗闇�瑕佹牴鎹垹闄ゆ儏鍐佃仈鍔ㄥ簱瀛樼瓑淇℃伅 - * - * @param data - * @param selected 鏄惁宸茬粡鏌ヨ杩囨暟鎹� - * @return - * @throws Exception - */ - @Transactional - public String delInoutData (InoutData data,boolean selected) + String loginUser = ContextUtil.getLoginUserCName(); + data.setRegisterUser(loginUser); + data.setFullWeightUser(loginUser); + data.setEmptyWeightUser(loginUser); + data.setHandleUser(loginUser); + data.setCompleteUser(loginUser); + if (null == data.getCompleteTime()) { + data.setCompleteTime(new Date()); + } + // 娉ㄥ唽鏃堕棿姣斿畬鎴愭椂闂存棭涓�涓皬鏃� + data.setRegisterTime(DateUtil.getNewByMinute(new Date(), -60)); + + if (StringUtils.isEmpty(data.getUserId())) { + data.setUserId(InoutConstant.DEFAULT_ID_CARD); + } + if (null == data.getIntelCard()) { + data.setIntelCard(data.getUserId()); + } + if (null != data.getCheckItems()) { + data.setCheckUser(loginUser); + } + + // 淇濆瓨妫�娴嬮」鐩� + if (InoutConstant.TYPE_IN.equals(data.getType())) { + + if (null == data.getFullWeightTime()) { + data.setFullWeightTime(DateUtil.getNewByMinute(new Date(), -50)); + } + if (null == data.getEmptyWeightTime()) { + data.setEmptyWeightTime(DateUtil + .getNewByMinute(new Date(), -10)); + } + + // 鍏堟墽琛屽寲楠屼俊鎭繚瀛� + CheckUpdateResult checkResult = checkStandardManager + .updateCheckItems(data.getCheckId(), data.getCompanyId(), + data.getCheckItems()); + if (null != checkResult) { + // if (null == data.getWet())data.setWet(checkResult.getWet()); + // if (null == + // data.getImpurity())data.setImpurity(checkResult.getImpurity()); + } + } else { + if (null == data.getEmptyWeightTime()) { + data.setEmptyWeightTime(DateUtil + .getNewByMinute(new Date(), -50)); + } + if (null == data.getFullWeightTime()) { + data.setFullWeightTime(DateUtil.getNewByMinute(new Date(), -10)); + } + } + + // 娣诲姞琛ュ崟鏁版嵁 + String msg = inoutService.insertData(data); + + // 鍒濆鍖栭獙璇佸嚭鍏ュ簱搴撳瓨 + commonService.initInoutDepotStore(data); + return msg; + } + + /** + * 淇敼鎿嶄綔 淇敼閫昏緫璇存槑锛氫慨鏀规暟鎹渶瑕佽幏鍙栧師鏁版嵁搴撲腑鐨勬暟鎹繘琛屽姣斻�� + * + * @param data + * @return + * @throws Exception + */ + @Transactional + public String updateInoutData(InoutData data) throws Exception { + + if (InoutConstant.RECORD_STATUS_DEL.equals(data.getRecordStatus())) { + return "绯荤粺锛氬凡缁忓垹闄ょ殑鏁版嵁涓嶆敮鎸佷慨鏀癸紒"; + } + if (InoutConstant.RECORD_STATUS_ERROR.equals(data.getRecordStatus())) { + return "绯荤粺锛氬紓甯哥粓姝㈢殑鏁版嵁涓嶆敮鎸佷慨鏀癸紒"; + } + + // 濡傛灉娴佺▼鏈粨鏉燂紝鍙洿鏂版暟鎹� + if (!InoutConstant.PROGRESS_RECORD.equals(data.getProgress())) { + return inoutService.updateData(data); + } + + // 濡傛灉鏄凡缁忓畬鎴愮殑鏁版嵁锛屽厛鑾峰彇鍒颁慨鏀圭洿鎺ョ殑鏁版嵁鏍规嵁鏁版嵁杩涜瀵规瘮 + InoutParam param = new InoutParam(); + param.setId(data.getId()); + param.setCompanyId(data.getCompanyId()); + param.setType(data.getType()); + InoutData record = inoutService.inoutQueryById(param); + + if (null == record) { + return "褰撳墠淇敼鏁版嵁宸茬粡涓嶅瓨鍦紒"; + } + + // 閬垮厤鏁版嵁搴撲腑鐨勬暟鎹凡缁忚鍏朵粬浜轰慨鏀� + if (InoutConstant.RECORD_STATUS_DEL.equals(record.getRecordStatus())) { + return "绯荤粺锛氬凡缁忓垹闄ょ殑鏁版嵁涓嶆敮鎸佷慨鏀癸紒"; + } + if (InoutConstant.RECORD_STATUS_ERROR.equals(record.getRecordStatus())) { + return "绯荤粺锛氬紓甯哥粓姝㈢殑鏁版嵁涓嶆敮鎸佷慨鏀癸紒"; + } + + // 淇濆瓨妫�娴嬮」鐩� + if (InoutConstant.TYPE_IN.equals(data.getType())) { + // 鍏堟墽琛屽寲楠屼俊鎭繚瀛� + CheckUpdateResult checkResult = checkStandardManager + .updateCheckItems(data.getCheckId(), data.getCompanyId(), + data.getCheckItems()); + if (null != checkResult) { + // if (null == data.getWet()) + // data.setWet(checkResult.getWet()); + // if (null == data.getImpurity()) + // data.setImpurity(checkResult.getImpurity()); + } + } + + // 鏇存柊鏁版嵁 + inoutService.updateData(data); + return null; + } + + /** + * 鍒犻櫎鎿嶄綔 鍒犻櫎鏁版嵁涓鸿蒋鍒犻櫎锛屽垹闄ゆ暟鎹悗闇�瑕佹牴鎹垹闄ゆ儏鍐佃仈鍔ㄥ簱瀛樼瓑淇℃伅 + * + * @param data + * @param selected 鏄惁宸茬粡鏌ヨ杩囨暟鎹� + * @return + * @throws Exception + */ + @Transactional + public String delInoutData(InoutData data, boolean selected) throws Exception { - // 閬垮厤椤甸潰缂撳瓨棣栧厛鑾峰彇鏁版嵁搴撲腑鏈�鏂扮殑褰撳墠鏁版嵁淇℃伅 - InoutParam param = new InoutParam(); - param.setCompanyId(data.getCompanyId()); - param.setId(data.getId()); - param.setMsg(" [" + ContextUtil.getLoginUserCName() + "]鎵ц鍒犻櫎锛屽師鍥狅細" - + data.getRemarks()); + // 閬垮厤椤甸潰缂撳瓨棣栧厛鑾峰彇鏁版嵁搴撲腑鏈�鏂扮殑褰撳墠鏁版嵁淇℃伅 + InoutParam param = new InoutParam(); + param.setCompanyId(data.getCompanyId()); + param.setId(data.getId()); + param.setMsg(" [" + ContextUtil.getLoginUserCName() + "]鎵ц鍒犻櫎锛屽師鍥狅細" + + data.getRemarks()); - if (!selected) { - data = inoutService.inoutQueryById(param); - - if (InoutConstant.RECORD_STATUS_DEL.equals(data.getRecordStatus())) { - return "宸茬粡鍒犻櫎鐨勬暟鎹紝涓嶆敮鎸侀噸澶嶅垹闄わ紒"; - } - if (InoutConstant.RECORD_STATUS_ERROR - .equals(data.getRecordStatus())) { - return "褰撳墠鏁版嵁宸茬粡琚爣璁颁负寮傚父锛屼笉鏀寔鍒犻櫎锛�"; - } - } - - // 鎵ц鍒犻櫎 - param.setProgress(InoutConstant.PROGRESS_RECORD); - param.setRecordStatus(InoutConstant.RECORD_STATUS_DEL); - param.setType(data.getType()); - inoutService.deleteData(param); - - // 濡傛灉娴佺▼鏈粨鏉燂紝鐩存帴鍒犻櫎锛屼笉鐗垫壇鍒拌仈鍔ㄨ皟鏁� - if (!InoutConstant.PROGRESS_RECORD.equals(data.getProgress())) { - return null; - } - return null; - } - - /** - * 寮傚父缁堟鎿嶄綔 璁剧疆寮傚父 涓轰簡閬垮厤椤甸潰鏁版嵁缂撳瓨锛岄渶瑕侀噸鏂拌幏鍙栨渶鏂版暟鎹垽鏂� - * - * @param data - * @return - * @throws Exception - */ - @Transactional - public String errorInoutData (InoutData data){ - - InoutParam param = new InoutParam(); - param.setCompanyId(data.getCompanyId()); - param.setId(data.getId()); - param.setMsg(" [" + ContextUtil.getLoginUserCName() + "]鎵ц寮傚父缁堟锛屽師鍥狅細" - + data.getRemarks()); + if (!selected) { data = inoutService.inoutQueryById(param); if (InoutConstant.RECORD_STATUS_DEL.equals(data.getRecordStatus())) { - return "宸茬粡鍒犻櫎鐨勬暟鎹紝涓嶆敮鎸佸紓甯稿鐞嗭紒"; + return "宸茬粡鍒犻櫎鐨勬暟鎹紝涓嶆敮鎸侀噸澶嶅垹闄わ紒"; } - if (InoutConstant.RECORD_STATUS_ERROR.equals(data.getRecordStatus())) { - return "涓嶆敮鎸侀噸澶嶅紓甯稿鐞嗭紒"; + if (InoutConstant.RECORD_STATUS_ERROR + .equals(data.getRecordStatus())) { + return "褰撳墠鏁版嵁宸茬粡琚爣璁颁负寮傚父锛屼笉鏀寔鍒犻櫎锛�"; } - if (InoutConstant.PROGRESS_RECORD.equals(data.getProgress())) { - return "娴佺▼缁撴潫鐨勬暟鎹笉鏀寔寮傚父澶勭悊锛�"; - } - - return inoutService.inoutStop(param); } - /** - * 蹇�熺粨鏉熸搷浣� 娴佺▼娌℃湁缁撴潫鐨勫崟鎹繘琛岀粨鏉� - * - * @param data - * @return - */ - public String completeInoutData (InoutData data) throws Exception { - if (InoutConstant.RECORD_STATUS_DEL.equals(data.getRecordStatus())) { - return "宸茬粡鍒犻櫎鐨勬暟鎹紝涓嶆敮鎸佸畬鎴愶紒"; - } - if (InoutConstant.RECORD_STATUS_ERROR.equals(data.getRecordStatus())) { - return "寮傚父缁堟鐨勬暟鎹紝涓嶆敮鎸佸畬鎴愶紒"; - } - if (InoutConstant.PROGRESS_RECORD.equals(data.getProgress())) { - return "娴佺▼宸插畬鎴愮殑鏁版嵁锛屼笉鏀寔瀹屾垚锛�"; - } + // 鎵ц鍒犻櫎 + param.setProgress(InoutConstant.PROGRESS_RECORD); + param.setRecordStatus(InoutConstant.RECORD_STATUS_DEL); + param.setType(data.getType()); + inoutService.deleteData(param); - // 浠庢柊鏌ヨ鏁版嵁 + // 濡傛灉娴佺▼鏈粨鏉燂紝鐩存帴鍒犻櫎锛屼笉鐗垫壇鍒拌仈鍔ㄨ皟鏁� + if (!InoutConstant.PROGRESS_RECORD.equals(data.getProgress())) { + return null; + } + return null; + } + + /** + * 寮傚父缁堟鎿嶄綔 璁剧疆寮傚父 涓轰簡閬垮厤椤甸潰鏁版嵁缂撳瓨锛岄渶瑕侀噸鏂拌幏鍙栨渶鏂版暟鎹垽鏂� + * + * @param data + * @return + * @throws Exception + */ + @Transactional + public String errorInoutData(InoutData data) { + + InoutParam param = new InoutParam(); + param.setCompanyId(data.getCompanyId()); + param.setId(data.getId()); + param.setMsg(" [" + ContextUtil.getLoginUserCName() + "]鎵ц寮傚父缁堟锛屽師鍥狅細" + + data.getRemarks()); + data = inoutService.inoutQueryById(param); + + if (InoutConstant.RECORD_STATUS_DEL.equals(data.getRecordStatus())) { + return "宸茬粡鍒犻櫎鐨勬暟鎹紝涓嶆敮鎸佸紓甯稿鐞嗭紒"; + } + if (InoutConstant.RECORD_STATUS_ERROR.equals(data.getRecordStatus())) { + return "涓嶆敮鎸侀噸澶嶅紓甯稿鐞嗭紒"; + } + if (InoutConstant.PROGRESS_RECORD.equals(data.getProgress())) { + return "娴佺▼缁撴潫鐨勬暟鎹笉鏀寔寮傚父澶勭悊锛�"; + } + + return inoutService.inoutStop(param); + } + + /** + * 蹇�熺粨鏉熸搷浣� 娴佺▼娌℃湁缁撴潫鐨勫崟鎹繘琛岀粨鏉� + * + * @param data + * @return + */ + public String completeInoutData(InoutData data) throws Exception { + if (InoutConstant.RECORD_STATUS_DEL.equals(data.getRecordStatus())) { + return "宸茬粡鍒犻櫎鐨勬暟鎹紝涓嶆敮鎸佸畬鎴愶紒"; + } + if (InoutConstant.RECORD_STATUS_ERROR.equals(data.getRecordStatus())) { + return "寮傚父缁堟鐨勬暟鎹紝涓嶆敮鎸佸畬鎴愶紒"; + } + if (InoutConstant.PROGRESS_RECORD.equals(data.getProgress())) { + return "娴佺▼宸插畬鎴愮殑鏁版嵁锛屼笉鏀寔瀹屾垚锛�"; + } + + // 浠庢柊鏌ヨ鏁版嵁 + InoutParam param = new InoutParam(); + param.setId(data.getId()); + param.setCompanyId(data.getCompanyId()); + param.setType(data.getType()); + InoutData cuData = inoutService.inoutProgressQuery(param); + if (null == cuData) { + return "褰撳墠杞﹁締娴佺▼鐘舵�佸凡缁忓彉鍖栵紝璇峰埛鏂伴〉闈㈤噸鏂版搷浣滐紒"; + } + if (!cuData.getProgress().equals(data.getProgress())) { + return "褰撳墠杞﹁締娴佺▼鐘舵�佸凡缁忓彉鍖栵紝璇峰埛鏂伴〉闈㈤噸鏂版搷浣滐紒"; + } + + if (null == data.getCompleteTime()) { + return "璇峰~鍐欏畬鎴愭椂闂达紒锛�"; + } + if (StringUtils.isEmpty(data.getDepotId())) { + return "璇峰~鍐欎粨搴撲俊鎭紒"; + } + if (StringUtils.isEmpty(data.getFoodYear())) { + return "璇峰~鍐欑伯椋熷勾浠戒俊鎭紒"; + } + if (StringUtils.isEmpty(data.getFoodVariety())) { + return "璇峰~鍐欑伯椋熷搧绉嶄俊鎭紒"; + } + + if (data.getSettleWeight() <= 0) { + return "璇峰~鍐欑粨绠楀噣閲嶄俊鎭紒"; + } + + String msg = inoutService.quickComplete(data); + + if (null == msg) { + data.setProgress(InoutConstant.PROGRESS_RECORD); + commonService.initInoutDepotStore(data); + } + return msg; + } + + public void initLpr(InoutConf conf) { + inoutDeviceManager.initLpr(conf); + } + + /** + * 鍑哄叆搴撴敞鍐屾暟鎹彁浜わ紝鍏ュ簱鐧昏鍜屽嚭鍏ュ簱鐧昏浣跨敤鍚屼竴涓柟娉� + * + * @param data + * @return + * @throws Exception + */ + public PageResponse<InoutData> submitRegisterInout(InoutData data) + throws Exception { + + // 棣栧厛鍒ゆ柇娴佺▼涓槸鍚︽湁宸茬粡瀛樺湪鐨勮溅杈嗕俊鎭湭鎵ц瀹屾垚锛岀洿鎺ヤ粠鏁版嵁搴撲腑鏌ヨ + InoutParam param = new InoutParam(); + param.setCompanyId(data.getCompanyId()); + param.setPlateNum(data.getPlateNum()); + param.setIntelCard(data.getIntelCard()); + param.setType(data.getType()); + param.setStart(DateUtil.getNewByDay(null, -10)); + + int num = inoutService.checkExist(param); + if (num > 0) { + return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), + "褰撳墠杞︾墝鎴栨櫤鎱у崱鏈夋鍦ㄦ墽琛屾祦绋嬫湭缁撴潫锛岃鑱旂郴绠$悊鍛�", data); + } + + // 鑾峰彇绯荤粺鍙傛暟閰嶇疆 + InoutSysConf inoutSysConf = inoutCommonService.getCacheInoutSysConf( + data.getCompanyId(), data.getDeptId()); + if (null == inoutSysConf) { + return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), + "鎻愮ず锛氬綋鍓嶅簱鍖烘湭閰嶇疆鍑哄叆搴撴祦绋嬩俊鎭紝璇疯仈绯荤鐞嗗憳", data); + } + + // 鑾峰彇涓嬩竴涓祦绋嬬姸鎬� + String curProgress = data.getProgress(); + String nextProgress = getNextProgress(curProgress, data.getType(), + inoutSysConf); + + data = updateBasicInfo(data, curProgress, nextProgress); + + String msg = inoutService.insertData(data); + + if (null != msg) { + return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg, + data); + } + + // 鎵ц闄勪欢淇℃伅 + fileService.saveInoutFiles(data.getFiles(), data.getCompanyId(), + data.getId(), curProgress); + + return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛", + data); + } + + public PageResponse<InoutData> submitWeightIn(InoutData data) + throws Exception { + // 鑾峰彇绯荤粺鍙傛暟閰嶇疆 + InoutSysConf inoutSysConf = inoutCommonService.getCacheInoutSysConf( + data.getCompanyId(), data.getDeptId()); + if (null == inoutSysConf) { + return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), + "鎻愮ず锛氬綋鍓嶇郴缁熶腑娴佺▼閰嶇疆寮傚父锛岃鑱旂郴绠$悊鍛�", data); + } + + // 鑾峰彇涓嬩竴涓祦绋嬬姸鎬� + String curProgress = data.getProgress(); + String nextProgress = getNextProgress(curProgress, data.getType(), + inoutSysConf); + data = updateBasicInfo(data, curProgress, nextProgress); + + // 鍏ュ簱绉伴噸鍙兘璋冩暣璐ㄦ鍗� + CheckUpdateResult checkUpdateResult = updateCheckItems(data); + if (data.getDeCheck() == 0) { + data.setDeCheck(checkUpdateResult.getDeSum()); + } + if (data.getAddCheck() == 0) { + data.setAddCheck(checkUpdateResult.getAddSum()); + } + + // 鎵ц鏁版嵁鏇存柊 + String msg = inoutService.updateData(data); + + if (null != msg) { + return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg, + data); + } + + // 鎵ц闄勪欢淇℃伅 + fileService.saveInoutFiles(data.getFiles(), data.getCompanyId(), + data.getId(), curProgress); + + // 绉伴噸瀹屾垚锛岃皟鐢ㄥ嚭鍏ュ簱鎺у埗閫昏緫澶勭悊 + inoutDeviceManager.controlWeight(data, curProgress, nextProgress); + + return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛", + data); + } + + public PageResponse<InoutData> submitWeightOut(InoutData data) + throws Exception { + // 鑾峰彇绯荤粺鍙傛暟閰嶇疆 + InoutSysConf inoutSysConf = inoutCommonService.getCacheInoutSysConf( + data.getCompanyId(), data.getDeptId()); + if (null == inoutSysConf) { + return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), + "鎻愮ず锛氬綋鍓嶇郴缁熶腑娴佺▼閰嶇疆寮傚父锛岃鑱旂郴绠$悊鍛�", data); + } + + // 鑾峰彇涓嬩竴涓祦绋嬬姸鎬� + String curProgress = data.getProgress(); + String nextProgress = getNextProgress(curProgress, data.getType(), + inoutSysConf); + data = updateBasicInfo(data, curProgress, nextProgress); + + // 鎵ц鏁版嵁鏇存柊 + String msg = inoutService.updateData(data); + + if (null != msg) { + return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg, + data); + } + + // 鎵ц闄勪欢淇℃伅 + fileService.saveInoutFiles(data.getFiles(), data.getCompanyId(), + data.getId(), curProgress); + + // 绉伴噸鍚庢牴鎹綋鍓嶆祦绋嬬姸鎬佸拰涓嬩竴涓姸鎬侊紝閫氱煡绉伴噸鎺у埗鍣� + inoutDeviceManager.controlWeight(data, curProgress, nextProgress); + + return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛", + data); + } + + public PageResponse<InoutData> submitHandle(InoutData data) + throws Exception { + + if (null == data.getHandleUser()) { + data.setHandleUser(ContextUtil.getLoginUserCName()); + } + + // 鑾峰彇绯荤粺鍙傛暟閰嶇疆 + InoutSysConf inoutSysConf = inoutCommonService.getCacheInoutSysConf( + data.getCompanyId(), data.getDeptId()); + if (null == inoutSysConf) { + return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), + "鎻愮ず锛氬綋鍓嶇郴缁熶腑娴佺▼閰嶇疆寮傚父锛岃鑱旂郴绠$悊鍛�", data); + } + + // 鑾峰彇涓嬩竴涓祦绋嬬姸鎬� + String curProgress = data.getProgress(); + String nextProgress = getNextProgress(curProgress, data.getType(), + inoutSysConf); + data = updateBasicInfo(data, curProgress, nextProgress); + + // 鎵ц鏁版嵁鏇存柊 + String msg = inoutService.updateDataByHandle(data); + + if (null != msg) { + return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg, + data); + } + + // 鎵ц闄勪欢淇℃伅 + fileService.saveInoutFiles(data.getFiles(), data.getCompanyId(), + data.getId(), curProgress); + + return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛", + data); + } + + /** + * 鏍规嵁鏉′欢鑾峰彇鎵︽牱鏁版嵁 + * + * @param param + * @return + */ + public PageResponse<Page<InoutCheckData>> pageSampleData( + InoutCheckParam param) { + + if (StringUtils.isEmpty(param.getCompanyId())) { + param.setCompanyId(ContextUtil.getCompanyId()); + } + if (StringUtils.isEmpty(param.getDeptId())) { + param.setDeptId(ContextUtil.subDeptId(null)); + } + + // 鑻ユ煡璇㈡潯浠朵负宸叉墻鏍凤紝鍒欐祦绋嬬疆绌猴紱鑻ユ湭鎵︽牱锛屽垯娴佺▼涓嶅鐞嗭紝浠嶄负鎵︽牱鍖栭獙娴佺▼(CHECK) + if (!"NONE".equals(param.getSampleStatus())) { + param.setProgress(null); + } + + // 鑾峰彇鎵︽牱鏁版嵁 + Page<InoutCheckData> sampleList = inoutService.pageSampleData(param); + + if (null == sampleList.getRecords() + || sampleList.getRecords().isEmpty()) { + return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(), + "鑾峰彇鍒版暟鎹俊鎭负绌�"); + } + return new PageResponse<>(RespCodeEnum.CODE_0000, sampleList); + } + + + public PageResponse<InoutCheckData> submitSample(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(), + "褰撳墠娴佺▼宸茬粡缁撴潫锛屼笉鏀寔淇敼"); + } + + // 鎵︽牱鏃堕棿鍜屾墻鏍蜂汉 + if (StringUtils.isEmpty(data.getSampleUser())) { + data.setSampleUser(ContextUtil.getLoginUserCName()); + } + + if (null == data.getSampleTime()) { + data.setSampleTime(new Date()); + } + + String msg = inoutService.updateSampleData(data); + + if (null != msg) { + return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg); + } + + return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛"); + } + + /** + * @param param + * @return + */ + public PageResponse<Page<InoutCheckData>> pageCheckData( + InoutCheckParam param) { + + if (StringUtils.isEmpty(param.getCompanyId())) { + param.setCompanyId(ContextUtil.getCompanyId()); + } + if (StringUtils.isEmpty(param.getDeptId())) { + param.setDeptId(ContextUtil.subDeptId(null)); + } + // 濡傛灉鏄凡鍖栭獙锛屽垯灏嗘祦绋嬬姸鎬佺疆绌猴紝濡傛灉鏄湭鍖栭獙锛屽垯娴佺▼鐘舵�佷笉澶勭悊锛屼粛鏄疌HECK鐘舵�� + if (!"NONE".equals(param.getCheckStatus())) { + param.setProgress(null); + } + + Page<InoutCheckData> checkList = inoutService.pageCheckData(param); + + if (null == checkList.getRecords() || checkList.getRecords().isEmpty()) { + return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(), + "鑾峰彇鍒版暟鎹俊鎭负绌�"); + } + return new PageResponse<>(RespCodeEnum.CODE_0000, checkList); + } + + /** + * 鑾峰彇鍖栭獙椤逛俊鎭� + * + * @param param + * @return + */ + public PageResponse<List<CheckItemData>> getCheckItemData( + InoutCheckParam param) { + + try { + List<CheckItemData> result = checkStandardManager.listCheckItem( + param.getCheckId(), param.getCompanyId(), + param.getFoodVariety()); + + return new PageResponse<>(RespCodeEnum.CODE_0000, result); + } catch (Exception e) { + return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), "鍚庡彴寮傚父锛�" + + e.getMessage(), null); + } + } + + @Transactional(rollbackFor = Exception.class) + public PageResponse<InoutCheckData> updateCheckData(InoutCheckData data) { + try { + + // 鑾峰彇涓氬姟鏁版嵁淇℃伅 InoutParam param = new InoutParam(); + param.setCompanyId(data.getCompanyId()); param.setId(data.getId()); - param.setCompanyId(data.getCompanyId()); - param.setType(data.getType()); - InoutData cuData = inoutService.inoutProgressQuery(param); - if (null == cuData) { - return "褰撳墠杞﹁締娴佺▼鐘舵�佸凡缁忓彉鍖栵紝璇峰埛鏂伴〉闈㈤噸鏂版搷浣滐紒"; - } - if (!cuData.getProgress().equals(data.getProgress())) { - return "褰撳墠杞﹁締娴佺▼鐘舵�佸凡缁忓彉鍖栵紝璇峰埛鏂伴〉闈㈤噸鏂版搷浣滐紒"; - } - - if (null == data.getCompleteTime()) { - return "璇峰~鍐欏畬鎴愭椂闂达紒锛�"; - } - if (StringUtils.isEmpty(data.getDepotId())) { - return "璇峰~鍐欎粨搴撲俊鎭紒"; - } - if (StringUtils.isEmpty(data.getFoodYear())) { - return "璇峰~鍐欑伯椋熷勾浠戒俊鎭紒"; - } - if (StringUtils.isEmpty(data.getFoodVariety())) { - return "璇峰~鍐欑伯椋熷搧绉嶄俊鎭紒"; - } - - if (data.getSettleWeight() <= 0) { - return "璇峰~鍐欑粨绠楀噣閲嶄俊鎭紒"; - } - - String msg = inoutService.quickComplete(data); - - if (null == msg) { - data.setProgress(InoutConstant.PROGRESS_RECORD); - commonService.initInoutDepotStore(data); - } - return msg; - } - - public void initLpr (InoutConf conf){ - inoutDeviceManager.initLpr(conf); - } - - /** - * 鍑哄叆搴撴敞鍐屾暟鎹彁浜わ紝鍏ュ簱鐧昏鍜屽嚭鍏ュ簱鐧昏浣跨敤鍚屼竴涓柟娉� - * - * @param data - * @return - * @throws Exception - */ - public PageResponse<InoutData> submitRegisterInout (InoutData data) throws Exception { - - //棣栧厛鍒ゆ柇娴佺▼涓槸鍚︽湁宸茬粡瀛樺湪鐨勮溅杈嗕俊鎭湭鎵ц瀹屾垚锛岀洿鎺ヤ粠鏁版嵁搴撲腑鏌ヨ - InoutParam param = new InoutParam(); - param.setCompanyId(data.getCompanyId()); - param.setPlateNum(data.getPlateNum()); - param.setIntelCard(data.getIntelCard()); - param.setType(data.getType()); - param.setStart(DateUtil.getNewByDay(null, -10)); - - int num = inoutService.checkExist(param); - if (num > 0) { + InoutData curData = inoutService.inoutProgressQuery(param); + if (null == curData) { return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), - "褰撳墠杞︾墝鎴栨櫤鎱у崱鏈夋鍦ㄦ墽琛屾祦绋嬫湭缁撴潫锛岃鑱旂郴绠$悊鍛�", data); + "娌℃湁鑾峰彇鍒板叆搴撲笟鍔℃暟鎹俊鎭紝鏇存柊澶辫触", 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); + } - //鑾峰彇绯荤粺鍙傛暟閰嶇疆 - InoutSysConf inoutSysConf = inoutCommonService.getCacheInoutSysConf(data.getCompanyId(), data.getDeptId()); + // 璁剧疆鍖栭獙淇℃伅 + if (checkResult.getDeSum() > 0) { + data.setDeCheck(checkResult.getDeSum()); + } + if (checkResult.getAddSum() > 0) { + data.setAddCheck(checkResult.getAddSum()); + } + if (null == data.getCheckTime()) { + data.setCheckTime(new Date()); + } + curData.setCheckStatus(data.getCheckStatus()); + + // 鑾峰彇绯荤粺鍙傛暟閰嶇疆 + InoutSysConf inoutSysConf = inoutCommonService + .getCacheInoutSysConf(data.getCompanyId(), data.getDeptId()); if (null == inoutSysConf) { return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), "鎻愮ず锛氬綋鍓嶅簱鍖烘湭閰嶇疆鍑哄叆搴撴祦绋嬩俊鎭紝璇疯仈绯荤鐞嗗憳", data); } + // 鏇存柊涓嬩竴娴佺▼鐘舵�� + if (InoutConstant.PROGRESS_CHECK.equals(curData.getProgress())) { + curData = updateBasicInfo(curData, inoutSysConf); + // 鑻ュ寲楠岀粨鏋滀笉鍚堟牸锛屽垽鏂厤缃悗缁祦绋� + if (InoutConstant.STATUS_UNPASS + .equals(curData.getCheckStatus())) { + curData = checkNoPass(curData); + } + } + // 鍖栭獙浜恒�佸寲楠屾椂闂� + data.setCheckStatus(curData.getCheckStatus()); + data.setProgress(curData.getProgress()); + if (StringUtils.isEmpty(data.getCheckUser())) { + data.setCheckUser(ContextUtil.getLoginUserCName()); + } + if (null == data.getCheckTime()) { + data.setCheckTime(new Date()); + } - //鑾峰彇涓嬩竴涓祦绋嬬姸鎬� - String curProgress = data.getProgress(); - String nextProgress = getNextProgress(curProgress, data.getType(), inoutSysConf); - - - data = updateBasicInfo(data, curProgress, nextProgress); - - String msg = inoutService.insertData(data); - + String msg = inoutService.updateCheckData(data); if (null != msg) { + return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg); + } + + return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛"); + } catch (Exception e) { + return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), "鍚庡彴寮傚父锛�" + + e.getMessage(), null); + } + } + + /** + * 鑾峰彇鍗曚环淇℃伅 + * + * @param param + * @return + */ + public PageResponse<InoutPrice> getPrice(InoutCheckParam param) { + try { + + List<InoutPrice> price = inoutService.getPrice(param); + if (null == price || price.isEmpty()) { return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), - msg, data); + "鏈幏鍙栧埌绮瀹氫环閰嶇疆淇℃伅"); } + return new PageResponse<>(RespCodeEnum.CODE_0000, price.get(0)); - // 鎵ц闄勪欢淇℃伅 - fileService.saveInoutFiles(data.getFiles(), data.getCompanyId(), data.getId(), curProgress); - - - return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛", data); + } catch (Exception e) { + return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), "鍚庡彴寮傚父锛�" + + e.getMessage(), null); } + } - public PageResponse<InoutData> submitWeightIn (InoutData data) throws Exception { - //鑾峰彇绯荤粺鍙傛暟閰嶇疆 - InoutSysConf inoutSysConf = inoutCommonService.getCacheInoutSysConf(data.getCompanyId(), data.getDeptId()); - if (null == inoutSysConf) { - return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), - "鎻愮ず锛氬綋鍓嶇郴缁熶腑娴佺▼閰嶇疆寮傚父锛岃鑱旂郴绠$悊鍛�", data); - } - - - //鑾峰彇涓嬩竴涓祦绋嬬姸鎬� - String curProgress = data.getProgress(); - String nextProgress = getNextProgress(curProgress, data.getType(), inoutSysConf); - data = updateBasicInfo(data, curProgress, nextProgress); - - - //鍏ュ簱绉伴噸鍙兘璋冩暣璐ㄦ鍗� - CheckUpdateResult checkUpdateResult = updateCheckItems(data); - if (data.getDeCheck() == 0) { - data.setDeCheck(checkUpdateResult.getDeSum()); - } - if (data.getAddCheck() == 0) { - data.setAddCheck(checkUpdateResult.getAddSum()); - } - - //鎵ц鏁版嵁鏇存柊 - String msg = inoutService.updateData(data); - - if (null != msg) { - return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg, data); - } - - // 鎵ц闄勪欢淇℃伅 - fileService.saveInoutFiles(data.getFiles(), data.getCompanyId(), data.getId(), curProgress); - - //绉伴噸瀹屾垚锛岃皟鐢ㄥ嚭鍏ュ簱鎺у埗閫昏緫澶勭悊 - inoutDeviceManager.controlWeight(data, curProgress, nextProgress); - - return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛", data); - } - - - public PageResponse<InoutData> submitWeightOut (InoutData data) throws Exception { - //鑾峰彇绯荤粺鍙傛暟閰嶇疆 - InoutSysConf inoutSysConf = inoutCommonService.getCacheInoutSysConf(data.getCompanyId(), data.getDeptId()); - if (null == inoutSysConf) { - return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), - "鎻愮ず锛氬綋鍓嶇郴缁熶腑娴佺▼閰嶇疆寮傚父锛岃鑱旂郴绠$悊鍛�", data); - } - - - //鑾峰彇涓嬩竴涓祦绋嬬姸鎬� - String curProgress = data.getProgress(); - String nextProgress = getNextProgress(curProgress, data.getType(), inoutSysConf); - data = updateBasicInfo(data, curProgress, nextProgress); - - //鎵ц鏁版嵁鏇存柊 - String msg = inoutService.updateData(data); - - if (null != msg) { - return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg, data); - } - - // 鎵ц闄勪欢淇℃伅 - fileService.saveInoutFiles(data.getFiles(), data.getCompanyId(), data.getId(), curProgress); - - //绉伴噸鍚庢牴鎹綋鍓嶆祦绋嬬姸鎬佸拰涓嬩竴涓姸鎬侊紝閫氱煡绉伴噸鎺у埗鍣� - inoutDeviceManager.controlWeight(data, curProgress, nextProgress); - - return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛", data); - } - - public PageResponse<InoutData> submitHandle (InoutData data) throws Exception { - - - if (null == data.getHandleUser()) { - data.setHandleUser(ContextUtil.getLoginUserCName()); - } - - //鑾峰彇绯荤粺鍙傛暟閰嶇疆 - InoutSysConf inoutSysConf = inoutCommonService.getCacheInoutSysConf(data.getCompanyId(), data.getDeptId()); - if (null == inoutSysConf) { - return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), - "鎻愮ず锛氬綋鍓嶇郴缁熶腑娴佺▼閰嶇疆寮傚父锛岃鑱旂郴绠$悊鍛�", data); - } - - //鑾峰彇涓嬩竴涓祦绋嬬姸鎬� - String curProgress = data.getProgress(); - String nextProgress = getNextProgress(curProgress, data.getType(), inoutSysConf); - data = updateBasicInfo(data, curProgress, nextProgress); - - - //鎵ц鏁版嵁鏇存柊 - String msg = inoutService.updateDataByHandle(data); - - if (null != msg) { - return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg, data); - } - - // 鎵ц闄勪欢淇℃伅 - fileService.saveInoutFiles(data.getFiles(), data.getCompanyId(), data.getId(), curProgress); - - return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛", data); - } - - - /** - * 鏍规嵁鏉′欢鑾峰彇鎵︽牱鏁版嵁 - * - * @param param - * @return - */ - public PageResponse<Page<InoutCheckData>> pageSampleData (InoutCheckParam param){ - - if (StringUtils.isEmpty(param.getCompanyId())) { - param.setCompanyId(ContextUtil.getCompanyId()); - } - if (StringUtils.isEmpty(param.getDeptId())) { - param.setDeptId(ContextUtil.subDeptId(null)); - } - - //鑻ユ煡璇㈡潯浠朵负宸叉墻鏍凤紝鍒欐祦绋嬬疆绌猴紱鑻ユ湭鎵︽牱锛屽垯娴佺▼涓嶅鐞嗭紝浠嶄负鎵︽牱鍖栭獙娴佺▼(CHECK) - if (!"NONE".equals(param.getSampleStatus())) { - param.setProgress(null); - } - - //鑾峰彇鎵︽牱鏁版嵁 - Page<InoutCheckData> sampleList = inoutService.pageSampleData(param); - - - if (null == sampleList.getRecords() || sampleList.getRecords().isEmpty()) { - return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(), - "鑾峰彇鍒版暟鎹俊鎭负绌�"); - } - return new PageResponse<>(RespCodeEnum.CODE_0000, sampleList); - } - - @Transactional(rollbackFor = Exception.class) - public PageResponse<InoutCheckData> updateSampleData (InoutCheckData data){ - - try { - // 鑾峰彇涓氬姟鏁版嵁淇℃伅 - 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(), - "褰撳墠娴佺▼宸茬粡缁撴潫锛屼笉鏀寔淇敼"); - } - - //鎵︽牱鏃堕棿鍜屾墻鏍蜂汉 - if (StringUtils.isEmpty(data.getSampleUser())) { - data.setSampleUser(ContextUtil.getLoginUserCName()); - } - if (null == data.getSampleTime()) { - data.setSampleTime(new Date()); - } - String msg = inoutService.updateSampleData(data); - - if (null != msg) { - return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg); - } - - return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛"); - } catch (Exception e) { - log.error("鍚庡彴寮傚父:{}", e); - return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), - "鍚庡彴寮傚父锛�" + e.getMessage(), null); - } - } - - /** - * @param param - * @return - */ - public PageResponse<Page<InoutCheckData>> pageCheckData (InoutCheckParam param){ - - if (StringUtils.isEmpty(param.getCompanyId())) { - param.setCompanyId(ContextUtil.getCompanyId()); - } - if (StringUtils.isEmpty(param.getDeptId())) { - param.setDeptId(ContextUtil.subDeptId(null)); - } - // 濡傛灉鏄凡鍖栭獙锛屽垯灏嗘祦绋嬬姸鎬佺疆绌猴紝濡傛灉鏄湭鍖栭獙锛屽垯娴佺▼鐘舵�佷笉澶勭悊锛屼粛鏄疌HECK鐘舵�� - if (!"NONE".equals(param.getCheckStatus())) { - param.setProgress(null); - } - - Page<InoutCheckData> checkList = inoutService.pageCheckData(param); - - - if (null == checkList.getRecords() || checkList.getRecords().isEmpty()) { - return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(), - "鑾峰彇鍒版暟鎹俊鎭负绌�"); - } - return new PageResponse<>(RespCodeEnum.CODE_0000, checkList); - } - - /** - * 鑾峰彇鍖栭獙椤逛俊鎭� - * - * @param param - * @return - */ - public PageResponse<List<CheckItemData>> getCheckItemData (InoutCheckParam param){ - - try { - List<CheckItemData> result = checkStandardManager.listCheckItem(param.getCheckId(), - param.getCompanyId(), param.getFoodVariety()); - - return new PageResponse<>(RespCodeEnum.CODE_0000, result); - } catch (Exception e) { - return new PageResponse<>( - RespCodeEnum.CODE_1111.getCode(), "鍚庡彴寮傚父锛�" + e.getMessage(), null); - } - } - - @Transactional(rollbackFor = Exception.class) - public PageResponse<InoutCheckData> updateCheckData (InoutCheckData data){ - try { - - // 鑾峰彇涓氬姟鏁版嵁淇℃伅 - 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); - } - - //璁剧疆鍖栭獙淇℃伅 - if (checkResult.getDeSum() > 0) { - data.setDeCheck(checkResult.getDeSum()); - } - if (checkResult.getAddSum() > 0) { - data.setAddCheck(checkResult.getAddSum()); - } - if (null == data.getCheckTime()) { - data.setCheckTime(new Date()); - } - curData.setCheckStatus(data.getCheckStatus()); - - //鑾峰彇绯荤粺鍙傛暟閰嶇疆 - InoutSysConf inoutSysConf = inoutCommonService.getCacheInoutSysConf(data.getCompanyId(), data.getDeptId()); - if (null == inoutSysConf) { - return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), - "鎻愮ず锛氬綋鍓嶅簱鍖烘湭閰嶇疆鍑哄叆搴撴祦绋嬩俊鎭紝璇疯仈绯荤鐞嗗憳", data); - } - //鏇存柊涓嬩竴娴佺▼鐘舵�� - if (InoutConstant.PROGRESS_CHECK.equals(curData.getProgress())) { - curData = updateBasicInfo(curData, inoutSysConf); - // 鑻ュ寲楠岀粨鏋滀笉鍚堟牸锛屽垽鏂厤缃悗缁祦绋� - if (InoutConstant.STATUS_UNPASS.equals(curData.getCheckStatus())) { - curData = checkNoPass(curData); - } - } - - //鍖栭獙浜恒�佸寲楠屾椂闂� - data.setCheckStatus(curData.getCheckStatus()); - data.setProgress(curData.getProgress()); - if (StringUtils.isEmpty(data.getCheckUser())) { - data.setCheckUser(ContextUtil.getLoginUserCName()); - } - if (null == data.getCheckTime()) { - data.setCheckTime(new Date()); - } - - String msg = inoutService.updateCheckData(data); - if (null != msg) { - return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg); - } - - return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛"); - } catch (Exception e) { - return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), - "鍚庡彴寮傚父锛�" + e.getMessage(), null); - } - } - - /** - * 鑾峰彇鍗曚环淇℃伅 - * - * @param param - * @return - */ - public PageResponse<InoutPrice> getPrice (InoutCheckParam param){ - try { - - List<InoutPrice> price = inoutService.getPrice(param); - if (null == price || price.isEmpty()) { - return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), "鏈幏鍙栧埌绮瀹氫环閰嶇疆淇℃伅"); - } - return new PageResponse<>(RespCodeEnum.CODE_0000, price.get(0)); - - } catch (Exception e) { - return new PageResponse<>( - RespCodeEnum.CODE_1111.getCode(), "鍚庡彴寮傚父锛�" + e.getMessage(), null); - } - } - - - } \ No newline at end of file +} \ No newline at end of file diff --git a/igds-inout/src/main/java/com/ld/igds/inout/service/impl/InoutServiceImpl.java b/igds-inout/src/main/java/com/ld/igds/inout/service/impl/InoutServiceImpl.java index 864fa2a..cbbc2d9 100644 --- a/igds-inout/src/main/java/com/ld/igds/inout/service/impl/InoutServiceImpl.java +++ b/igds-inout/src/main/java/com/ld/igds/inout/service/impl/InoutServiceImpl.java @@ -281,12 +281,17 @@ @Override public String toComplete(InoutParam param) throws Exception { + param.setUpdateTime(new Date()); + if (null == param.getCompanyId()) { param.setCompanyId(ContextUtil.getDefaultCompanyId()); } // 娓呴櫎缂撳瓨 this.delFromCache(param.getDeptId(), param.getType(), param.getId()); + + + inoutMapper.toComplete(param); @@ -719,6 +724,7 @@ } int num = inoutCheckMapper.updateSampleData(data); + return null; } @@ -756,6 +762,9 @@ data.setCompanyId(ContextUtil.subDeptId(null)); } + + data.setUpdateTime(new Date()); + int num = inoutCheckMapper.updateCheckData(data); return null; } diff --git a/igds-inout/src/main/resources/mapper/InoutCheckMapper.xml b/igds-inout/src/main/resources/mapper/InoutCheckMapper.xml index c11d18a..e4a1112 100644 --- a/igds-inout/src/main/resources/mapper/InoutCheckMapper.xml +++ b/igds-inout/src/main/resources/mapper/InoutCheckMapper.xml @@ -44,7 +44,8 @@ <!--鏇存柊鎵︽牱淇℃伅--> <update id="updateSampleData" parameterType="com.ld.igds.inout.dto.InoutCheckData"> - UPDATE D_INOUT_RECORD SET + UPDATE D_INOUT_RECORD + set UPDATE_TIME_ = #{data.updateTime} , <if test="data.sampleUser != null">SAMPLE_USER_ = #{data.sampleUser},</if> <if test="data.sampleTime != null">SAMPLE_TIME_ = #{data.sampleTime},</if> <if test="data.sampleType != null">SAMPLE_TYPE_ = #{data.sampleType},</if> diff --git a/igds-inout/src/main/resources/mapper/InoutRecordMapper.xml b/igds-inout/src/main/resources/mapper/InoutRecordMapper.xml index b240655..387aee5 100644 --- a/igds-inout/src/main/resources/mapper/InoutRecordMapper.xml +++ b/igds-inout/src/main/resources/mapper/InoutRecordMapper.xml @@ -471,7 +471,7 @@ set PROGRESS_ = #{param.progress}, COMPLETE_TIME_ =#{param.completeTime}, COMPLETE_USER_ = #{param.userId}, - UPDATE_TIME_ = sysdate + UPDATE_TIME_ = #{param.updateTime} where ID_ = #{param.id} and TYPE_ = #{param.type} and COMPANY_ID_ = #{param.companyId} diff --git a/igds-web/src/main/resources/static/admin/inout/in-card-back.js b/igds-web/src/main/resources/static/admin/inout/in-card-back.js index 2eca8e8..d80f771 100644 --- a/igds-web/src/main/resources/static/admin/inout/in-card-back.js +++ b/igds-web/src/main/resources/static/admin/inout/in-card-back.js @@ -127,7 +127,7 @@ } // 褰撳墠瀹屾垚 -function submit() { +function submitData() { if (!recordData) { alertError("娌℃湁鏁版嵁鍙互鎻愪氦锛�"); return; @@ -140,7 +140,7 @@ $.ajax({ type : "POST", - url : "../../basic/inout/inout-back-submit", + url : "../../basic/inout/submit-card-back", dataType : "json", contentType : "application/json;charset=UTF-8", data : JSON.stringify(recordData), diff --git a/igds-web/src/main/resources/static/admin/inout/in-sample.js b/igds-web/src/main/resources/static/admin/inout/in-sample.js index dc8e4af..575d438 100644 --- a/igds-web/src/main/resources/static/admin/inout/in-sample.js +++ b/igds-web/src/main/resources/static/admin/inout/in-sample.js @@ -14,7 +14,6 @@ form = layui.form; table = layui.table; laydate = layui.laydate; - laydate.render({ elem: '#start', theme: '#7b8e9f', @@ -44,31 +43,11 @@ showDetail(obj); } }); - - //鐩戝惉绮鍝佺 - layui.form.on('select(select_foodVariety)', function (data) { - updateFoodVariety(data.value); - }); - - //鐩戝惉鍖栭獙缁撴灉鍗曞~鍐欐暟鎹�,骞剁粰鍑烘彁绀虹粨鏋� - table.on('edit(tableCheckItem)', function (obj) { - getResult(obj); - }); }); //鏄剧ず鍏ュ簱娴佺▼ showProgress(); - - // 鍒濆鍖朩ebSocket - initInoutWS(deptId, bizType, progress, userId); }); - - -// socket淇℃伅杩斿洖铏曠悊 -function socketOnMessage(packet) { - layer.alert(packet.data); - window.parent.sysNotify(packet.data); -} /** * 鏉′欢鏌ヨ @@ -193,55 +172,6 @@ form.render(); }; -//鏍规嵁濉啓鍖栭獙鏁版嵁,缁欏嚭鎻愰啋鏄惁鍚堟牸 -function getResult(obj) { - var data = obj.data; - //濉啓鐨勬暟鎹�� - var newValue = data.value; - //鏍囧噯鍊� - var limit = data.upperLimit; - //杩愮畻绗� - var symbol = data.operaSymbol; - - if (symbol && limit) { - if (">=" == symbol) { - if (newValue < limit) { - data.remarks = "涓嶅悎鏍�"; - } else { - data.remarks = "鍚堟牸"; - } - } - if ("<=" == symbol) { - if (newValue > limit) { - data.remarks = "涓嶅悎鏍�"; - } else { - data.remarks = "鍚堟牸"; - } - } - if ("==" == symbol) { - if (newValue != limit) { - data.remarks = "涓嶅悎鏍�"; - } else { - data.remarks = "鍚堟牸"; - } - } - } - obj.update(data); - //鏍规嵁鍖栭獙缁撴灉鎻愰啋鏄惁鍚堟牸 - updateCheckResultTip(); -} - -//鏍规嵁閫夋嫨浠撳簱鏄剧ず绮鍝佺 -function updateFoodVariety(foodVariety) { - if (null == foodVariety || "" == foodVariety) return; - form.val("form-detail", { - foodVariety: foodVariety - }); - form.render(); - - flushCheckItem(foodVariety); -} - // 鏍规嵁妯″紡鍚姩寮�濮嬫墻鏍� function checkExe(type) { @@ -257,14 +187,14 @@ success: function (result) { layer.close(index); if (result.code != "0000") { - layer.alert(result.msg); + alertError(result.msg); } else { - layer.msg("鎿嶄綔鍛戒护鍙戦�佹垚鍔燂紒"); + alertSuccess("鎿嶄綔鍛戒护鍙戦�佹垚鍔�!"); } }, error: function () { layer.close(index); - layer.alert("鍚庡彴寮傚父锛屾搷浣滃懡浠ゅ彂閫佸け璐ワ紒"); + alertError("鍚庡彴寮傚父锛屾搷浣滃懡浠ゅ彂閫佸け璐ワ紒"); } }); }; @@ -348,12 +278,11 @@ * 鏃堕棿绛� */ function getTime() { - - var now = new Date(); - var time = now.toLocaleString('chinese', { - hour12: false - }); - return time; + var now = new Date(); + var time = now.toLocaleString('chinese', { + hour12: false + }); + return time; } function showDetail(obj) { @@ -362,10 +291,10 @@ $("#printTime").html(nowTime); curSampleData = obj.data; - if(!curSampleData.sampleTime){ + if (!curSampleData.sampleTime) { curSampleData.sampleTime = nowTime; } - if(!curSampleData.sampleUser){ + if (!curSampleData.sampleUser) { curSampleData.sampleUser = sampleUser; } // 璧嬪�� @@ -379,9 +308,9 @@ shade: 0, content: $('#checkDetail'), btnAlign: 'c', - btn: ['淇濆瓨骞舵墦鍗�', '淇濆瓨鎻愪氦','鍏抽棴鍙栨秷'], + btn: ['淇濆瓨骞舵墦鍗�', '淇濆瓨鎻愪氦', '鍏抽棴鍙栨秷'], yes: function () { - layer.alert("鏉″舰鐮佸緟纭畾锛�"); + alertSuccess("鏉″舰鐮佸緟纭畾锛�"); }, btn2: function () { // 鏇存柊鍒伴〉闈� var data = form.val("form-detail"); @@ -409,11 +338,10 @@ layer.alert("璇疯緭鍏ユ墻鏍锋椂闂达紒锛�"); return; } - var index = layer.load(); $.ajax({ type: "POST", - url: "../../basic/inout/update-sample", + url: "../../basic/inout/submit-sample", dataType: "json", contentType: "application/json;charset=UTF-8", data: JSON.stringify(curSampleData), @@ -430,67 +358,7 @@ }, error: function () { layer.close(index); - layer.alert("鎻愪氦澶辫触锛岃閲嶆柊灏濊瘯锛�"); + alertError("鎻愪氦澶辫触锛岃閲嶆柊灏濊瘯"); } }); -} - -//鎺у埗娴佺▼鐜妭鏄剧ず -function showProgress() { - if (!inoutProgress) { - return; - } - if (inoutProgress.indexOf("REGISTER") == -1) { - $("#progress-register").css("display", "none"); - } - if (inoutProgress.indexOf("CHECK") == -1) { - $("#progress-check").css("display", "none"); - } - if (inoutProgress.indexOf("WEIGHT_FULL") == -1) { - $("#progress-fullWeight").css("display", "none"); - } - if (inoutProgress.indexOf("HANDLE") == -1) { - $("#progress-hand").css("display", "none"); - } - if (inoutProgress.indexOf("WEIGHT_EMPTY") == -1) { - $("#progress-emptyWeight").css("display", "none"); - } - if (inoutProgress.indexOf("CARD_BACK") == -1) { - $("#progress-cardBack").css("display", "none"); - } -} - -/** - * 寮瑰嚭鎻愰啋妗� - * @param msg 鎻愰啋淇℃伅 - * @param data 鏁版嵁淇℃伅锛屽彲鑳戒负绌� - */ -function notify(msg, data) { - if (data) { - //璧嬪�� - $("#resultMsg").text(msg); - $("#resultUserName").text(data.userName); - $("#resultPlateNum").text(data.plateNum); - if ("IN" == data.type) { - $("#resultType").text("鍏ュ簱-" + INOUT_PROGRESS_MSG(data.progress)); - } else { - $("#resultType").text("鍑哄簱-" + INOUT_PROGRESS_MSG(data.progress)); - } - $("#resultIntelCard").text(data.intelCard); - - layer.open({ - type: 1, - offset: ['150px', '200px'], - area: '450px;', - shade: 0.8, - id: 'dialog_notify_info', - btn: ['纭畾'], - content: $('#dialog-from-notify'), - yes: function (index) { - layer.closeAll(); - } - }); - } else { - layer.alert(msg, {offset: ['300px', '300px']}); - } } \ No newline at end of file diff --git a/igds-web/src/main/resources/static/admin/inout/inout-common.js b/igds-web/src/main/resources/static/admin/inout/inout-common.js index 800de91..6609900 100644 --- a/igds-web/src/main/resources/static/admin/inout/inout-common.js +++ b/igds-web/src/main/resources/static/admin/inout/inout-common.js @@ -31,6 +31,13 @@ }); } +function alertSuccess(msg) { + layer.alert(msg, { + icon: 1, + offset: ['300px', '300px'] + }); +} + /** * 寮瑰嚭鎻愰啋妗� * @param msg 鎻愰啋淇℃伅 diff --git a/igds-web/src/main/resources/templates/admin/inout/in-card-back.html b/igds-web/src/main/resources/templates/admin/inout/in-card-back.html index 3adde1b..cd74c0e 100644 --- a/igds-web/src/main/resources/templates/admin/inout/in-card-back.html +++ b/igds-web/src/main/resources/templates/admin/inout/in-card-back.html @@ -294,8 +294,8 @@ <div class="rkbk-quick layui-text-center"> - <button class="rkbk-quick-btn layui-btn btn-green" - onclick="submit()"> + <button class="rkbk-quick-btn layui-btn btn-green" type='button' + onclick="submitData()"> <i><img th:src="@{../../static/images/icon-ok.png}"/></i> 鏀跺崱鍑哄簱 </button> </div> diff --git a/igds-web/src/main/resources/templates/admin/inout/in-sample.html b/igds-web/src/main/resources/templates/admin/inout/in-sample.html index e91c4d7..c4e5083 100644 --- a/igds-web/src/main/resources/templates/admin/inout/in-sample.html +++ b/igds-web/src/main/resources/templates/admin/inout/in-sample.html @@ -177,21 +177,17 @@ <div class="qyzj-con radius-6"> <div class="qyzj-con-top layui-row"> <form class="layui-form" action="" id="form-param" lay-filter="form-param"> - <div class="layui-form-item display-none"> - <label class="layui-form-label">闅愯棌-绫诲瀷</label> - <div class="layui-input-block"> - <input type="text" name="type" th:value="${type}" autocomplete="off" - class="layui-input rkbk-search-input"> - </div> + <input type="text" name="type" th:value="${type}"> </div> - <div class="layui-form-item display-none"> - <label class="layui-form-label">闅愯棌-娴佺▼</label> - <div class="layui-input-block"> - <input type="text" name="progress" th:value="${progress}" autocomplete="off" - class="layui-input rkbk-search-input"> - </div> + <input type="text" name="progress" th:value="${progress}"> + </div> + <div class="layui-form-item display-none"> + <input type="text" name="companyId" th:value="${companyId}"> + </div> + <div class="layui-form-item display-none"> + <input type="text" name="deptId" th:value="${deptId}"> </div> <div class="layui-col-xs3"> @@ -299,17 +295,12 @@ var type = [[${type}]]; //userId var userId = [[${loginUser.username}]]; - var sampleUser = [[${loginUser.cname}]]; - var companyId = [[${loginUser.companyId}]]; - //鍝佺 - var listFoodVariety = [[${listFoodVariety}]]; var startTime = [[${startTime}]]; var endTime = [[${endTime}]]; //鎵︽牱鏈轰俊鎭� var checkDto = [[${checkDto}]]; - //鎵�灞炲垎搴� var deptId = [[${deptId}]]; //搴撳尯鍚嶇О @@ -321,6 +312,7 @@ <script th:src="@{../../static/js/jquery.min.js}"></script> <script th:src="@{../../static/js/constant.js}"></script> <script th:src="@{../../static/js/igds-common.js}"></script> +<script th:src="@{../../static/admin/inout/inout-common.js}"></script> <script th:src="@{../../static/admin/inout/in-sample.js}"></script> <script type="text/html" id="barControl"> -- Gitblit v1.9.3