diff --git a/src/main/java/com/dreamchaser/depository_manage/controller/DepositoryRecordController.java b/src/main/java/com/dreamchaser/depository_manage/controller/DepositoryRecordController.java index 0aecbf42..11e6f361 100644 --- a/src/main/java/com/dreamchaser/depository_manage/controller/DepositoryRecordController.java +++ b/src/main/java/com/dreamchaser/depository_manage/controller/DepositoryRecordController.java @@ -54,7 +54,7 @@ public class DepositoryRecordController { @GetMapping("/myApply") public RestResponse findDepositoryInAndOutRecordPByCondition(@RequestParam Map map, HttpServletRequest request) { String token = request.getHeader("user-token"); - if(token == null){ + if (token == null) { token = (String) request.getSession().getAttribute("userToken"); } UserByPort userToken = AuthenticationTokenPool.getUserToken(token); @@ -84,7 +84,7 @@ public class DepositoryRecordController { @GetMapping("/myTaskOut") public RestResponse myTaskOut(@RequestParam Map map, HttpServletRequest request) { String token = request.getHeader("user-token"); - if(token == null){ + if (token == null) { token = (String) request.getSession().getAttribute("userToken"); } UserByPort userToken = AuthenticationTokenPool.getUserToken(token); @@ -99,7 +99,7 @@ public class DepositoryRecordController { @GetMapping("/myTaskIn") public RestResponse myTaskIn(@RequestParam Map map, HttpServletRequest request) { String token = request.getHeader("user-token"); - if(token == null){ + if (token == null) { token = (String) request.getSession().getAttribute("userToken"); } UserByPort userToken = AuthenticationTokenPool.getUserToken(token); @@ -117,7 +117,7 @@ public class DepositoryRecordController { // isDone 为0为未完成,1为已完成 String isDone = (String) (map.get("isDone")); String token = request.getHeader("user-token"); - if(token == null){ + if (token == null) { token = (String) request.getSession().getAttribute("userToken"); } UserByPort userToken = AuthenticationTokenPool.getUserToken(token); @@ -200,7 +200,7 @@ public class DepositoryRecordController { @PostMapping("/depositoryRecord") public RestResponse insertDepositoryRecord(@RequestBody Map map, HttpServletRequest request) { String token = request.getHeader("user-token"); - if(token == null){ + if (token == null) { token = (String) request.getSession().getAttribute("userToken"); } UserByPort userToken = AuthenticationTokenPool.getUserToken(token); @@ -219,7 +219,7 @@ public class DepositoryRecordController { String header = request.getHeader("user-agent"); String crypt = Md5.crypt(header); String token = request.getHeader("user-token"); - if(token == null){ + if (token == null) { token = (String) request.getSession().getAttribute("userToken"); } UserByPort userToken = AuthenticationTokenPool.getUserToken(token); @@ -244,8 +244,7 @@ public class DepositoryRecordController { recordIds.add(ObjectFormatUtil.toInteger(map.get("applicationInId"))); mtIdList.add(ObjectFormatUtil.toLong(map.get("mtId"))); } - } - else { + } else { // 获取库位id Integer placeId = ObjectFormatUtil.toInteger(map.get("placeId")); if (placeId == 0) {// 如果插入到仓库 @@ -438,7 +437,7 @@ public class DepositoryRecordController { @PostMapping("/applicationOut") public RestResponse insertApplicationOutRecord(@RequestBody Map map, HttpServletRequest request) { String token = request.getHeader("user-token"); - if(token == null){ + if (token == null) { token = (String) request.getSession().getAttribute("userToken"); } UserByPort userToken = AuthenticationTokenPool.getUserToken(token); @@ -466,15 +465,21 @@ public class DepositoryRecordController { map.remove("id"); map.put("parentId", id); } - String constructionUnitId = map.get("constructionUnitId").toString(); - String adminorgId = map.get("adminorgId").toString(); - if("".equals(constructionUnitId)) - { - map.remove("constructionUnitId"); + if (map.containsKey("constructionUnitId")) { + String constructionUnitId = map.get("constructionUnitId").toString(); + if ("".equals(constructionUnitId)) { + map.remove("constructionUnitId"); + } } - if("".equals(adminorgId)){ - map.put("adminorgId",userToken.getMaindeparment()); + if (map.containsKey("adminorgId")) { + String adminorgId = map.get("adminorgId").toString(); + if ("".equals(adminorgId)) { + map.put("adminorgId", userToken.getMaindeparment()); + } + } else { + map.put("adminorgId", userToken.getMaindeparment()); } + integer += depositoryRecordService.insertApplicationOutMin(map); // 开启一个线程执行发送信息操作 @@ -542,28 +547,40 @@ public class DepositoryRecordController { insert.put("unit", map.get("unit" + temp)); // 获取主订单编号 insert.put("parentId", id); - String constructionUnitId = (String) map.get("constructionUnitId"+temp); - String adminorgId = (String) map.get("adminorgId"+temp); - if(!"".equals(constructionUnitId)) - { - insert.put("constructionUnitId",constructionUnitId); + if (map.containsKey("constructionUnitId" + temp)) { + String constructionUnitId = (String) map.get("constructionUnitId" + temp); + if (!"".equals(constructionUnitId)) { + insert.put("constructionUnitId", constructionUnitId); + } } - if("".equals(adminorgId)){ - map.put("adminorgId",userToken.getMaindeparment()); - }else{ - map.put("adminorgId",adminorgId); + if (map.containsKey("adminorgId" + temp)) { + String adminorgId = (String) map.get("adminorgId" + temp); + + if ("".equals(adminorgId)) { + map.put("adminorgId", userToken.getMaindeparment()); + } else { + map.put("adminorgId", adminorgId); + } + } else { + map.put("adminorgId", userToken.getMaindeparment()); } + // 插入子订单 integer += depositoryRecordService.insertApplicationOutMin(insert); } - String constructionUnitId = map.get("constructionUnitId").toString(); - String adminorgId = map.get("adminorgId").toString(); - if("".equals(constructionUnitId)) - { - map.remove("constructionUnitId"); + if (map.containsKey("constructionUnitId")) { + String constructionUnitId = map.get("constructionUnitId").toString(); + if ("".equals(constructionUnitId)) { + map.remove("constructionUnitId"); + } } - if("".equals(adminorgId)){ - map.put("adminorgId",userToken.getMaindeparment()); + if (map.containsKey("adminorgId")) { + String adminorgId = map.get("adminorgId").toString(); + if ("".equals(adminorgId)) { + map.put("adminorgId", userToken.getMaindeparment()); + } + } else { + map.put("adminorgId", userToken.getMaindeparment()); } // 插入子订单 map.put("parentId", id); @@ -620,7 +637,7 @@ public class DepositoryRecordController { @GetMapping("/applicationInView") public RestResponse findApplicationInRecordByCondition(@RequestParam Map map, HttpServletRequest request) { String token = request.getHeader("user-token"); - if(token == null){ + if (token == null) { token = (String) request.getSession().getAttribute("userToken"); } UserByPort userToken = AuthenticationTokenPool.getUserToken(token); @@ -652,7 +669,7 @@ public class DepositoryRecordController { // 0未完成1已完成 Integer stateOnView = ObjectFormatUtil.toInteger(map.get("state")); String token = request.getHeader("user-token"); - if(token == null){ + if (token == null) { token = (String) request.getSession().getAttribute("userToken"); } UserByPort userToken = AuthenticationTokenPool.getUserToken(token); @@ -776,19 +793,19 @@ public class DepositoryRecordController { @GetMapping("/applicationOutView") public RestResponse findApplicationOutRecordByCondition(@RequestParam Map map, HttpServletRequest request) { String token = request.getHeader("user-token"); - if(token == null){ + if (token == null) { token = (String) request.getSession().getAttribute("userToken"); } UserByPort userByPort = AuthenticationTokenPool.getUserToken(token); // 获取对应主订单 List list = new ArrayList<>(); Integer countBy = 0; - if(Integer.compare(userByPort.getMaindeparment(),361)==0){ - list = depositoryRecordService.findApplicationOutRecordPByCondition(map,userByPort); + if (Integer.compare(userByPort.getMaindeparment(), 361) == 0) { + list = depositoryRecordService.findApplicationOutRecordPByCondition(map, userByPort); countBy = depositoryRecordService.findApplicationOutRecordPCountByCondition(map); - }else{ + } else { - list = depositoryRecordService.findApplicationOutRecordPByUser(userByPort, map); + list = depositoryRecordService.findApplicationOutRecordPByUser(userByPort, map); countBy = depositoryRecordService.findApplicationOutRecordPCountByUser(userByPort, map); } @@ -845,7 +862,7 @@ public class DepositoryRecordController { @PostMapping("/addApplicationToRedis") public RestResponse addApplicationToRedis(@RequestBody Map map, HttpServletRequest request) { String token = request.getHeader("user-token"); - if(token == null){ + if (token == null) { token = (String) request.getSession().getAttribute("userToken"); } UserByPort userToken = AuthenticationTokenPool.getUserToken(token); @@ -878,7 +895,7 @@ public class DepositoryRecordController { @PostMapping("/deleteApplicationToRedis") public RestResponse deleteApplicationToRedis(@RequestBody Map map, HttpServletRequest request) { String token = request.getHeader("user-token"); - if(token == null){ + if (token == null) { token = (String) request.getSession().getAttribute("userToken"); } UserByPort userToken = AuthenticationTokenPool.getUserToken(token); @@ -901,7 +918,7 @@ public class DepositoryRecordController { @PutMapping("/review") public RestResponse review(@RequestBody Map map, HttpServletRequest request) { String token = request.getHeader("user-token"); - if(token == null){ + if (token == null) { token = (String) request.getSession().getAttribute("userToken"); } UserByPort userToken = AuthenticationTokenPool.getUserToken(token); @@ -918,7 +935,7 @@ public class DepositoryRecordController { @PutMapping("/reviewIn") public RestResponse reviewIn(@RequestBody Map map, HttpServletRequest request) { String token = request.getHeader("user-token"); - if(token == null){ + if (token == null) { token = (String) request.getSession().getAttribute("userToken"); } UserByPort userToken = AuthenticationTokenPool.getUserToken(token); @@ -936,7 +953,7 @@ public class DepositoryRecordController { @PutMapping("/transfer") public RestResponse transfer(@RequestBody Map map, HttpServletRequest request) { String token = request.getHeader("user-token"); - if(token == null){ + if (token == null) { token = (String) request.getSession().getAttribute("userToken"); } UserByPort userToken = AuthenticationTokenPool.getUserToken(token); @@ -1057,9 +1074,9 @@ public class DepositoryRecordController { // 删除入库记录 @PostMapping("/deleteApplicationInRecord") - public RestResponse deleteApplicationInRecord(@RequestBody Map map,HttpServletRequest request) { + public RestResponse deleteApplicationInRecord(@RequestBody Map map, HttpServletRequest request) { String token = request.getHeader("user-token"); - if(token == null){ + if (token == null) { token = (String) request.getSession().getAttribute("userToken"); } UserByPort userByPort = AuthenticationTokenPool.getUserToken(token); @@ -1067,10 +1084,10 @@ public class DepositoryRecordController { String crypt = Md5.crypt(header); if (map.containsKey("id")) { Integer id = ObjectFormatUtil.toInteger(map.get("id")); - return CrudUtil.deleteHandle(depositoryRecordService.deleteApplicationInRecordById(id,userByPort,crypt), 1); + return CrudUtil.deleteHandle(depositoryRecordService.deleteApplicationInRecordById(id, userByPort, crypt), 1); } else if (map.containsKey("ids")) { List ids = (List) map.get("ids"); - return CrudUtil.deleteHandle(depositoryRecordService.deleteApplicationInRecordByIds(ids,userByPort,crypt), ids.size()); + return CrudUtil.deleteHandle(depositoryRecordService.deleteApplicationInRecordByIds(ids, userByPort, crypt), ids.size()); } else { throw new MyException("所需请求参数缺失!"); } @@ -1080,7 +1097,7 @@ public class DepositoryRecordController { @PostMapping("/deleteApplicationOutRecord") public RestResponse deleteApplicationOutRecord(@RequestBody Map map, HttpServletRequest request) { String token = request.getHeader("user-token"); - if(token == null){ + if (token == null) { token = (String) request.getSession().getAttribute("userToken"); } UserByPort userByPort = AuthenticationTokenPool.getUserToken(token); @@ -1134,7 +1151,7 @@ public class DepositoryRecordController { int start = (page - 1) * pagesize; Integer end = page * 10; String token = request.getHeader("user-token"); - if(token == null){ + if (token == null) { token = (String) request.getSession().getAttribute("userToken"); } UserByPort userToken = AuthenticationTokenPool.getUserToken(token); @@ -1190,7 +1207,7 @@ public class DepositoryRecordController { @PostMapping("/createMultiApplication") public RestResponse createMultiApplication(@RequestBody Map map, HttpServletRequest request) { String token = request.getHeader("user-token"); - if(token == null){ + if (token == null) { token = (String) request.getSession().getAttribute("userToken"); } UserByPort userToken = AuthenticationTokenPool.getUserToken(token); @@ -1303,7 +1320,7 @@ public class DepositoryRecordController { @PostMapping("/createMultiApplications") public RestResponse createMultiApplications(@RequestBody Map map, HttpServletRequest request) { String token = request.getHeader("user-token"); - if(token == null){ + if (token == null) { token = (String) request.getSession().getAttribute("userToken"); } UserByPort userToken = AuthenticationTokenPool.getUserToken(token); @@ -1498,7 +1515,7 @@ public class DepositoryRecordController { @PostMapping("/isCheckOut") public RestResponse isCheckOut(@RequestBody Map map, HttpServletRequest request) { String token = request.getHeader("user-token"); - if(token == null){ + if (token == null) { token = (String) request.getSession().getAttribute("userToken"); } UserByPort userToken = AuthenticationTokenPool.getUserToken(token); diff --git a/src/main/java/com/dreamchaser/depository_manage/service/impl/GroupServiceImpl.java b/src/main/java/com/dreamchaser/depository_manage/service/impl/GroupServiceImpl.java index 8dc952e6..3df3fb0c 100644 --- a/src/main/java/com/dreamchaser/depository_manage/service/impl/GroupServiceImpl.java +++ b/src/main/java/com/dreamchaser/depository_manage/service/impl/GroupServiceImpl.java @@ -497,16 +497,19 @@ public class GroupServiceImpl implements GroupService { List allGroupOnly = groupMapper.findAllGroupOnly(gname); // 获取当前总数 - Integer totalVal = allGroupOnly.size(); + int totalVal = allGroupOnly.size(); // 定义分页数量 double size = 10.0; // 定义线程数 - Integer threadSize = (int) Math.ceil(totalVal / size); + int threadSize = (int) Math.ceil(totalVal / size); // 定义开启线程数目 - Integer openThreadSize = 0; + int openThreadSize = 0; + if(threadSize == 0){ + return list; + } // 开启对应数量的线程 ExecutorService exs = Executors.newFixedThreadPool(threadSize); // 线程结果集 diff --git a/src/main/resources/templates/pages/application/application-in.html b/src/main/resources/templates/pages/application/application-in.html index 3cf4a793..949e540d 100644 --- a/src/main/resources/templates/pages/application/application-in.html +++ b/src/main/resources/templates/pages/application/application-in.html @@ -413,6 +413,11 @@ // 用于卡片编号 var NewIdNumber = 1; + + // 用于标志当前表单是否第一次提交 + let flagForForm = false; + let GroupflagForForm = false; + // 用于暂存卡片个数(组合) var params2 = []; layui.use(['form', 'step', 'flow', 'laydate', 'element'], function () { @@ -449,92 +454,100 @@ // 用于提交操作 form.on('submit(formStep)', function (data) { - data = data.field; - data.type = 1; - data.params = params; - $.ajax({ - url: "/depositoryRecord/applicationIn", - type: 'post', - dataType: 'json', - contentType: "application/json;charset=utf-8", - data: JSON.stringify(data), - beforeSend: function () { - this.layerIndex = layer.load(0, {shade: [0.5, '#393D49']}); - }, - success: function (data) { - layer.close(this.layerIndex); - if (data.status >= 300) { - var d = data.data; - if (d === "") { - layer.msg(data.statusInfo.detail); - } else { - var err = d["err"]; - var success = d["success"]; - var errMsg = ""; - for (let i = 0; i < err.length; i++) { - errMsg += "物料编码: "; - errMsg += err[i]["code"]; - } - if (err.length > 0) { - errMsg += "添加失败,请选择新仓库或库位"; - layer.msg(errMsg, { - icon: 5, - time: 1000 - }, function () { - step.next('#stepForm'); - }); + if(!flagForForm){ + flagForForm = true; + data = data.field; + data.type = 1; + data.params = params; + $.ajax({ + url: "/depositoryRecord/applicationIn", + type: 'post', + dataType: 'json', + contentType: "application/json;charset=utf-8", + data: JSON.stringify(data), + beforeSend: function () { + this.layerIndex = layer.load(0, {shade: [0.5, '#393D49']}); + }, + success: function (data) { + layer.close(this.layerIndex); + if (data.status >= 300) { + var d = data.data; + if (d === "") { + layer.msg(data.statusInfo.detail); } else { - step.next('#stepForm'); + var err = d["err"]; + var success = d["success"]; + var errMsg = ""; + for (let i = 0; i < err.length; i++) { + errMsg += "物料编码: "; + errMsg += err[i]["code"]; + } + if (err.length > 0) { + errMsg += "添加失败,请选择新仓库或库位"; + layer.msg(errMsg, { + icon: 5, + time: 1000 + }, function () { + step.next('#stepForm'); + }); + } else { + step.next('#stepForm'); + } } - } - } else { - layer.msg("申请提交成功", { - icon: 6,//成功的表情 - time: 500 //1秒关闭(如果不配置,默认是3秒) - }, function () { - step.next('#stepForm'); - }); + } else { + layer.msg("申请提交成功", { + icon: 6,//成功的表情 + time: 500 //1秒关闭(如果不配置,默认是3秒) + }, function () { + step.next('#stepForm'); + }); + } + }, + complete: function () { + layer.close(this.layerIndex); } - }, - complete: function () { - layer.close(this.layerIndex); - } - }); + }); + } + return false; }); // 用于提交操作(组合) form.on('submit(formStep2)', function (data) { - data = data.field; - data.type = 1; - data.params = params2; - $.ajax({ - url: "/group/applicationInForGroup", - type: 'post', - dataType: 'json', - contentType: "application/json;charset=utf-8", - data: JSON.stringify(data), - beforeSend: function () { - this.layerIndex = layer.load(0, {shade: [0.5, '#393D49']}); - }, - success: function (d) { - layer.close(this.layerIndex); - if (d.status >= 300) { - layer.msg(d.statusInfo.detail);//失败的表情 - - } else { - layer.msg("申请提交成功", { - icon: 6,//成功的表情 - time: 500 //1秒关闭(如果不配置,默认是3秒) - }, function () { - step.next('#stepForm2'); - }); + if(!GroupflagForForm){ + GroupflagForForm = true; + data = data.field; + data.type = 1; + data.params = params2; + $.ajax({ + url: "/group/applicationInForGroup", + type: 'post', + dataType: 'json', + contentType: "application/json;charset=utf-8", + data: JSON.stringify(data), + beforeSend: function () { + this.layerIndex = layer.load(0, {shade: [0.5, '#393D49']}); + }, + success: function (d) { + layer.close(this.layerIndex); + if (d.status >= 300) { + layer.msg(d.statusInfo.detail);//失败的表情 + + } else { + layer.msg("申请提交成功", { + icon: 6,//成功的表情 + time: 500 //1秒关闭(如果不配置,默认是3秒) + }, function () { + step.next('#stepForm2'); + }); + } + }, + complete: function () { + layer.close(this.layerIndex); } - }, - complete: function () { - layer.close(this.layerIndex); - } - }); + }); + } + }); $('.pre').click(function () { diff --git a/src/main/resources/templates/pages/application/application-in_back.html b/src/main/resources/templates/pages/application/application-in_back.html index bc9bbd97..4b2c27fb 100644 --- a/src/main/resources/templates/pages/application/application-in_back.html +++ b/src/main/resources/templates/pages/application/application-in_back.html @@ -139,11 +139,14 @@ diff --git a/src/main/resources/templates/pages/notice/notice-add.html b/src/main/resources/templates/pages/notice/notice-add.html index 329b9098..5b482471 100644 --- a/src/main/resources/templates/pages/notice/notice-add.html +++ b/src/main/resources/templates/pages/notice/notice-add.html @@ -84,6 +84,8 @@ function selectDepartment(){ } + // 用于标志是否为第一次提交 + let flagForForm = false; layui.use(['form', 'layer', 'laydate', 'inputTag'], function () { var form = layui.form, layer = layui.layer, @@ -98,25 +100,29 @@ //监听提交 form.on('submit(noticeBtn)', function (data) { - $.ajax({ - url: "/notice/notice", - data: JSON.stringify(data.field), - type: "post", - dataType: 'json', - contentType: "application/json;charset=utf-8", - success: function (data) { - if (data.status >= 300) { - layer.msg(data.statusInfo.message);//失败的表情 - } else { - layer.msg("公告发布成功", { - icon: 6,//成功的表情 - time: 1000 //1秒关闭(如果不配置,默认是3秒) - }, function () { - window.location = "/notice_add" - }); + if(!flagForForm){ + flagForForm = true; + $.ajax({ + url: "/notice/notice", + data: JSON.stringify(data.field), + type: "post", + dataType: 'json', + contentType: "application/json;charset=utf-8", + success: function (data) { + if (data.status >= 300) { + layer.msg(data.statusInfo.message);//失败的表情 + } else { + layer.msg("公告发布成功", { + icon: 6,//成功的表情 + time: 1000 //1秒关闭(如果不配置,默认是3秒) + }, function () { + window.location = "/notice_add" + }); + } } - } - }); + }); + } + return false; }); diff --git a/src/main/resources/templates/pages/notice/notice-edit.html b/src/main/resources/templates/pages/notice/notice-edit.html index 5f5e68a6..fd15b7cd 100644 --- a/src/main/resources/templates/pages/notice/notice-edit.html +++ b/src/main/resources/templates/pages/notice/notice-edit.html @@ -86,6 +86,8 @@ function selectDepartment(){ } + // 用于标志是否为第一次提交 + let flagForForm = false; layui.use(['form', 'layer', 'laydate', 'inputTag'], function () { var form = layui.form, layer = layui.layer, @@ -100,25 +102,29 @@ //监听提交 form.on('submit(noticeBtn)', function (data) { - $.ajax({ - url: "/notice/noticeEdit", - data: JSON.stringify(data.field), - type: "post", - dataType: 'json', - contentType: "application/json;charset=utf-8", - success: function (data) { - if (data.status >= 300) { - layer.msg(data.statusInfo.message);//失败的表情 - } else { - layer.msg("公告修改成功", { - icon: 6,//成功的表情 - time: 1000 //1秒关闭(如果不配置,默认是3秒) - }, function () { - window.location = "/notice_out" - }); + if(!flagForForm){ + flagForForm = true; + $.ajax({ + url: "/notice/noticeEdit", + data: JSON.stringify(data.field), + type: "post", + dataType: 'json', + contentType: "application/json;charset=utf-8", + success: function (data) { + if (data.status >= 300) { + layer.msg(data.statusInfo.message);//失败的表情 + } else { + layer.msg("公告修改成功", { + icon: 6,//成功的表情 + time: 1000 //1秒关闭(如果不配置,默认是3秒) + }, function () { + window.location = "/notice_out" + }); + } } - } - }); + }); + } + return false; }); diff --git a/src/main/resources/templates/pages/place/place_add.html b/src/main/resources/templates/pages/place/place_add.html index b142e20f..3e43c1e1 100644 --- a/src/main/resources/templates/pages/place/place_add.html +++ b/src/main/resources/templates/pages/place/place_add.html @@ -125,7 +125,8 @@