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 bb394357..fde99242 100644 --- a/src/main/java/com/dreamchaser/depository_manage/controller/DepositoryRecordController.java +++ b/src/main/java/com/dreamchaser/depository_manage/controller/DepositoryRecordController.java @@ -849,13 +849,14 @@ public class DepositoryRecordController { // 删除出库记录 @PostMapping("/deleteApplicationOutRecord") - public RestResponse deleteApplicationOutRecord(@RequestBody Map map) { + public RestResponse deleteApplicationOutRecord(@RequestBody Map map,HttpServletRequest request) { + UserByPort userByPort = (UserByPort) request.getAttribute("userToken"); if (map.containsKey("id")) { Integer id = ObjectFormatUtil.toInteger(map.get("id")); - return CrudUtil.deleteHandle(depositoryRecordService.deleteApplicationOutRecordById(id), 1); + return CrudUtil.deleteHandle(depositoryRecordService.deleteApplicationOutRecordById(id,userByPort), 1); } else if (map.containsKey("ids")) { List ids = (List) map.get("ids"); - return CrudUtil.deleteHandle(depositoryRecordService.deleteApplicationOutRecordByIds(ids), ids.size()); + return CrudUtil.deleteHandle(depositoryRecordService.deleteApplicationOutRecordByIds(ids,userByPort), ids.size()); } else { throw new MyException("所需请求参数缺失!"); } @@ -866,11 +867,25 @@ public class DepositoryRecordController { public RestResponse judgeApplicationOutRecordStatus(@RequestBody Map map){ if (map.containsKey("id")) { Integer id = ObjectFormatUtil.toInteger(map.get("id")); - + // 获取当前记录是否能删除 + boolean b = depositoryRecordService.judgeApplicationOutRecordStatus(id); + return new RestResponse(b,0,1); } else if (map.containsKey("ids")) { List ids = (List) map.get("ids"); + List resultIds = new ArrayList<>(); + for (Integer id:ids + ) { + boolean b1 = depositoryRecordService.judgeApplicationOutRecordStatus(id); + if(!b1){ + resultIds.add(id); + } + } + resultIds.add(2); + return new RestResponse(resultIds,0,2); + } + else { + throw new MyException("所需请求参数缺失!"); } - return null; } @@ -1230,7 +1245,7 @@ public class DepositoryRecordController { } if (success == 0) { - depositoryRecordService.deleteApplicationOutRecordById(1); + depositoryRecordService.deleteApplicationOutRecordById(1,userToken); return new RestResponse("", 666, new StatusInfo("申请失败", "超出最大存储容量")); } if (success < mids.size()) { diff --git a/src/main/java/com/dreamchaser/depository_manage/mapper/DepositoryRecordMapper.java b/src/main/java/com/dreamchaser/depository_manage/mapper/DepositoryRecordMapper.java index 58579d9d..3996284c 100644 --- a/src/main/java/com/dreamchaser/depository_manage/mapper/DepositoryRecordMapper.java +++ b/src/main/java/com/dreamchaser/depository_manage/mapper/DepositoryRecordMapper.java @@ -391,6 +391,13 @@ public interface DepositoryRecordMapper { */ List findApplicationOutRecordMinByParent(Integer parentId); + /** + * 根据主表获取所有子表 + * @param list + * @return + */ + List findApplicationOutRecordMinByParents(List list); + /** * 修改子表记录 * @param map diff --git a/src/main/java/com/dreamchaser/depository_manage/mapper/DepositoryRecordMapper.xml b/src/main/java/com/dreamchaser/depository_manage/mapper/DepositoryRecordMapper.xml index a7522bf2..b038c3f4 100644 --- a/src/main/java/com/dreamchaser/depository_manage/mapper/DepositoryRecordMapper.xml +++ b/src/main/java/com/dreamchaser/depository_manage/mapper/DepositoryRecordMapper.xml @@ -321,19 +321,44 @@ from applicationInRecordInfo where 1 = 1 - and did in + and ( did in #{id} - or applicant_id = #{applicantId} + or applicant_id = #{applicantId} ) and applicant_id = #{applicantId} + + + + and did = #{depositoryId} + + + and mname like CONCAT('%', #{mname}, '%') + + + and mversion like CONCAT('%', #{version}, '%') + + + and mcode like CONCAT('%', #{mcode}, '%') + + + and aircode like CONCAT('%', #{code}, '%') + + + and applicant_time >= #{startDate} + + + and applicant_time <= #{endDate} + + + order by applicant_time desc LIMIT #{begin},#{size} @@ -348,12 +373,12 @@ from applicationInRecordInfo where 1 = 1 - and did in + and ( did in #{id} - or applicant_id = #{applicantId} + or applicant_id = #{applicantId} ) @@ -361,6 +386,28 @@ and applicant_id = #{applicantId} + + and did = #{depositoryId} + + + + and mname like CONCAT('%', #{mname}, '%') + + + and mversion like CONCAT('%', #{version}, '%') + + + and mcode like CONCAT('%', #{mcode}, '%') + + + and aircode like CONCAT('%', #{code}, '%') + + + and applicant_time >= #{startDate} + + + and applicant_time <= #{endDate} + @@ -489,13 +536,13 @@ from applicationOutRecordInfo where 1 = 1 - and depositoryId + and ( depositoryId in #{id} - or applicantId = #{applicantId} + or applicantId = #{applicantId} ) @@ -503,6 +550,25 @@ and applicantId = #{applicantId} + + and mversion = #{version} + + + and mcode = #{mcode} + + + and mname = #{mname} + + + and aorcode = #{code} + + + and applicantTime >= #{startDate} + + + and applicantTime <= #{endDate} + + GROUP BY aorid order by applicantTime desc @@ -516,12 +582,12 @@ from applicationOutRecordInfo where 1 = 1 - and depositoryId in + and ( depositoryId in #{id} - or applicantId = #{applicantId} + or applicantId = #{applicantId} ) @@ -529,6 +595,24 @@ and applicantId = #{applicantId} + + and mversion = #{version} + + + and mcode = #{mcode} + + + and mname = #{mname} + + + and aorcode = #{code} + + + and applicantTime >= #{startDate} + + + and applicantTime <= #{endDate} + @@ -902,6 +986,18 @@ and aorm.parentId = #{parentId} + + + +
+ +
+
-
+
+
@@ -37,16 +40,14 @@
- - +
- +
- +
@@ -55,6 +56,12 @@
+
+ +
+ +
+
@@ -110,12 +116,12 @@ move: '.layui-layer-title', fixed: false, content: '/selectDepository?type=2', - success: function(layero, index){ + success: function (layero, index) { var children = layero.children(); var content = $(children[1]); var iframeChildren = $(content.children()); - content.css('height','100%'); - iframeChildren.css('height','100%'); + content.css('height', '100%'); + iframeChildren.css('height', '100%'); } }); }); @@ -135,12 +141,12 @@ content: '/getMaterialAll?type=1&mname=""', move: '.layui-layer-title', fixed: false, - success: function(layero, index){ + success: function (layero, index) { var children = layero.children(); var content = $(children[1]); var iframeChildren = $(content.children()); - content.css('height','100%'); - iframeChildren.css('height','100%'); + content.css('height', '100%'); + iframeChildren.css('height', '100%'); } }); @@ -148,7 +154,10 @@ //日期 laydate.render({ - elem: '#date' + elem: '#startDate' + }); //日期 + laydate.render({ + elem: '#endDate' }); table.render({ elem: "#currentTableId", @@ -209,7 +218,7 @@ {title: '操作', minWidth: 150, toolbar: '#currentTableBar', align: "center"} ] ], - limits: [10, 15, 20, 25, 50,100], + limits: [10, 15, 20, 25, 50, 100], limit: 10, page: true, skin: 'line', @@ -227,13 +236,22 @@ if (data.depositoryId !== '') { req.depositoryId = data.depositoryId; } - if (data.applyTime !== '') { - req.applyTime = data.applyTime; + if (data.startDate !== '') { + req.startDate = data.startDate; + }if (data.endDate !== '') { + req.endDate = data.endDate; + } + if (data.mcode !== '') { + req.mcode = data.mcode; } if (data.code !== '') { req.code = data.code; } - if (data.code !== '') { + if (data.mname !== '') { + req.mname = data.mname; + } + + if (data.version !== '') { req.version = data.version; } //执行搜索重载 @@ -275,35 +293,72 @@ if (req.ids.length > 0) { layer.confirm('真的删除么', {icon: 2, title: '提示'}, function (index) { $.ajax({ - url: '/depositoryRecord/deleteApplicationOutRecord', - type: 'post', - dataType: 'json', - contentType: "application/json;charset=utf-8", - data: JSON.stringify(req), - beforeSend: function () { - this.layerIndex = layer.load(0, {shade: [0.5, '#393D49']}); - }, - success: function (data) { - layer.close(this.layerIndex); - if (data.status >= 300) { - layer.msg(data.statusInfo.message);//失败的表情 + url: 'depositoryRecord/judgeApplicationOutRecordStatus', + type: 'post', + dataType: 'json', + contentType: "application/json;charset=utf-8", + data: JSON.stringify(req), + success: function (res) { + let status = res.status; + let res_data = res.data; + if(status === 2){ + if(res_data.length === 0){ + layer.confirm("该操作会造成不可逆的后果,确定删除?",{ + icon:2, + title:"提示" + },function () { + $.ajax({ + url: '/depositoryRecord/deleteApplicationOutRecord', + type: 'post', + dataType: 'json', + contentType: "application/json;charset=utf-8", + data: JSON.stringify(req), + beforeSend: function () { + this.layerIndex = layer.load(0, {shade: [0.5, '#393D49']}); + }, + success: function (data) { + layer.close(this.layerIndex); + if (data.status >= 300) { + layer.msg(data.statusInfo.message);//失败的表情 - } else { - layer.msg("删除成功", { - icon: 6,//成功的表情 - time: 500 //1秒关闭(如果不配置,默认是3秒) - }); - //执行搜索重载 - table.reload('currentTableId', { - url: '/depositoryRecord/applicationOutView', - page: { - curr: 1 + } else { + layer.msg("删除成功", { + icon: 6,//成功的表情 + time: 500 //1秒关闭(如果不配置,默认是3秒) + }); + //执行搜索重载 + table.reload('currentTableId', { + url: '/depositoryRecord/applicationOutView', + page: { + curr: 1 + } + }, 'data'); + return false; + } + } + }) + }) + } + else { + let msg = "申请编码为:"; + $.each(res_data,function (index_num,item_num) { + $.each(data,function (index,item) { + if(item_num === item.id){ + msg += item.code+","; + } + }) + }); + msg += "的出库记录正在出库中,不允许删除"; + layer.msg(msg,{ + icon:2, + time:1500 + }) } - }, 'data'); - return false; + } } } - }) + ) + }); } else { layer.msg("未选中记录,请确认!"); @@ -338,28 +393,53 @@ req.id = data.id; layer.confirm('真的删除么', {icon: 2, title: '提示'}, function (index) { $.ajax({ - url: 'depositoryRecord/deleteApplicationOutRecord', + url: 'depositoryRecord/judgeApplicationOutRecordStatus', type: 'post', dataType: 'json', contentType: "application/json;charset=utf-8", data: JSON.stringify(req), - beforeSend: function () { - this.layerIndex = layer.load(0, {shade: [0.5, '#393D49']}); - }, - success: function (data) { - layer.close(this.layerIndex); - if (data.status >= 300) { - layer.msg(data.statusInfo.message);//失败的表情 + success: function (res) { + let data = res.data; + let status = res.status; + if (status === 1) { + if (data) { + // 如果可以删除 + layer.confirm('该操作将造成不可逆的后果,是否删除?', {icon: 2, title: '提示'}, function (index) { + $.ajax({ + url: 'depositoryRecord/deleteApplicationOutRecord', + type: 'post', + dataType: 'json', + contentType: "application/json;charset=utf-8", + data: JSON.stringify(req), + beforeSend: function () { + this.layerIndex = layer.load(0, {shade: [0.5, '#393D49']}); + }, + success: function (data) { + layer.close(this.layerIndex); + if (data.status >= 300) { + layer.msg(data.statusInfo.message);//失败的表情 - } else { - obj.del(); - layer.msg("删除成功", { - icon: 6,//成功的表情 - time: 500 //1秒关闭(如果不配置,默认是3秒) - }); + } else { + obj.del(); + layer.msg("删除成功", { + icon: 6,//成功的表情 + time: 500 //1秒关闭(如果不配置,默认是3秒) + }); + } + } + }) + }) + } else { + // 如果不可以删除 + layer.msg("该出库正在进行中,不允许删除", { + icon: 0, + time: 1500 + }) + } } } }) + }); } }); diff --git a/src/test/java/com/dreamchaser/depository_manage/TestOther.java b/src/test/java/com/dreamchaser/depository_manage/TestOther.java index 054bf30b..1a7e32c2 100644 --- a/src/test/java/com/dreamchaser/depository_manage/TestOther.java +++ b/src/test/java/com/dreamchaser/depository_manage/TestOther.java @@ -3,6 +3,7 @@ package com.dreamchaser.depository_manage; import com.alibaba.fastjson.JSONObject; import com.dreamchaser.depository_manage.config.PortConfig; import com.dreamchaser.depository_manage.config.QyWxConfig; +import com.dreamchaser.depository_manage.entity.ApplicationOutRecordMin; import com.dreamchaser.depository_manage.entity.UserByPort; import com.dreamchaser.depository_manage.entity.qywxDepartment; import com.dreamchaser.depository_manage.mapper.DepositoryRecordMapper; @@ -29,13 +30,6 @@ public class TestOther { @Test public void Test(){ - Map map = new HashMap<>(); - List depositoryRecordList = new ArrayList<>(); - depositoryRecordList.add(48); - map.put("depositoryIdList",depositoryRecordList); - List applicationInRecordPByCondition = depositoryRecordMapper.findApplicationInRecordPByCondition(map); - System.out.println(applicationInRecordPByCondition); - } }