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 368e7ec8..84390d4f 100644 --- a/src/main/java/com/dreamchaser/depository_manage/controller/DepositoryRecordController.java +++ b/src/main/java/com/dreamchaser/depository_manage/controller/DepositoryRecordController.java @@ -226,7 +226,7 @@ public class DepositoryRecordController { insert.put("depositoryId",map.get("depositoryId"+temp)); insert.put("applyRemark",map.get("applyRemark"+temp)); insert.put("code",map.get("code"+temp)); - insert.put("price",map.get("price").toString()); + insert.put("price",map.get("price"+temp).toString()); if(placeId == -1) { // 如果插入到仓库 insert.put("placeId",0); Integer add = depositoryRecordService.applicationInPlace(insert); @@ -248,22 +248,24 @@ public class DepositoryRecordController { } } Integer placeId = ObjectFormatUtil.toInteger(map.get("placeId")); - if(placeId == -1) {// 如果插入到仓库 - map.put("placeId",0); - Integer add = depositoryRecordService.applicationInPlace(map); - if(add == -1){ - errMsg.add(map); - }else { - integer+=add; - successMsg.add(map); - } - }else{ // 如果具体到库位 - Integer flag = depositoryRecordService.applicationInPlace(map); - if(flag == -1){ - map.put("err","存储失败,请重新选择存储位"); - errMsg.add(map); - }else{ - integer += flag; + if(placeId != null) { + if (placeId == -1) {// 如果插入到仓库 + map.put("placeId", 0); + Integer add = depositoryRecordService.applicationInPlace(map); + if (add == -1) { + errMsg.add(map); + } else { + integer += add; + successMsg.add(map); + } + } else { // 如果具体到库位 + Integer flag = depositoryRecordService.applicationInPlace(map); + if (flag == -1) { + map.put("err", "存储失败,请重新选择存储位"); + errMsg.add(map); + } else { + integer += flag; + } } } result.put("err",errMsg); @@ -274,7 +276,7 @@ public class DepositoryRecordController { }else if(integer != 0 && params.size() > 0){ if(integer == params.size() + 1){ return CrudUtil.postHandle(integer,params.size() + 1); - }else{ + }else { return new RestResponse(result,666,new StatusInfo("错误","含有错误信息")); } } @@ -326,6 +328,19 @@ public class DepositoryRecordController { }else{ // 插入主订单 map.put("departmenthead",departmentHeadId.toString()); + if(!map.containsKey("mid")){ + // 如果不包含初始的第一个卡片 + Set strings = map.keySet(); + String key = ""; + for (String tempKey : + strings) { + if(tempKey.contains("mid")){ + key = tempKey; + break; + } + } + String keyNumber = key.split("mid")[1]; + } Integer res = depositoryRecordService.insertApplicationOutRecord(map,userToken); if(res == 1) { // 获取主订单编号 @@ -607,6 +622,16 @@ public class DepositoryRecordController { Integer integer = 0; if(params.size() < 1 && map.size() > 4){ integer += depositoryRecordService.transferApply(map,userToken); + Object id = map.get("parentId"); + JSONObject jsonObject = qyWxOperationService.sendQyWxMessage(departMentHeadQyWxName.toString(), ObjectFormatUtil.toInteger(id), true); + // 将当前返回结果保存到redis中 + Map QyWxMessageMap = new HashMap<>(); + QyWxMessageMap.put("MsgId",jsonObject.getString("msgid")); + QyWxMessageMap.put("responseCode",jsonObject.getString("response_code")); + // key user:300450:QyWxOut:1 + redisTemplate.opsForHash().putAll("user:"+userToken.getNumber()+":QyWxOutId:"+id,QyWxMessageMap); + // 设置过期时间为三天 + redisTemplate.expire("user:"+userToken.getNumber()+":QyWxOutId:"+id,72,TimeUnit.HOURS); }else if(params.size() > 0){ for (int i = 0; i < params.size(); i++) { Integer temp = params.get(i); @@ -619,8 +644,28 @@ public class DepositoryRecordController { insert.put("applyRemark",map.get("applyRemark"+temp)); insert.put("code",map.get("code"+temp)); integer += depositoryRecordService.transferApply(insert,userToken); + Object id = insert.get("parentId"); + JSONObject jsonObject = qyWxOperationService.sendQyWxMessage(departMentHeadQyWxName.toString(), ObjectFormatUtil.toInteger(id), true); + // 将当前返回结果保存到redis中 + Map QyWxMessageMap = new HashMap<>(); + QyWxMessageMap.put("MsgId",jsonObject.getString("msgid")); + QyWxMessageMap.put("responseCode",jsonObject.getString("response_code")); + // key user:300450:QyWxOut:1 + redisTemplate.opsForHash().putAll("user:"+userToken.getNumber()+":QyWxOutId:"+id,QyWxMessageMap); + // 设置过期时间为三天 + redisTemplate.expire("user:"+userToken.getNumber()+":QyWxOutId:"+id,72,TimeUnit.HOURS); } integer += depositoryRecordService.transferApply(map,userToken); + Object id = map.get("parentId"); + JSONObject jsonObject = qyWxOperationService.sendQyWxMessage(departMentHeadQyWxName.toString(), ObjectFormatUtil.toInteger(id), true); + // 将当前返回结果保存到redis中 + Map QyWxMessageMap = new HashMap<>(); + QyWxMessageMap.put("MsgId",jsonObject.getString("msgid")); + QyWxMessageMap.put("responseCode",jsonObject.getString("response_code")); + // key user:300450:QyWxOut:1 + redisTemplate.opsForHash().putAll("user:"+userToken.getNumber()+":QyWxOutId:"+id,QyWxMessageMap); + // 设置过期时间为三天 + redisTemplate.expire("user:"+userToken.getNumber()+":QyWxOutId:"+id,72,TimeUnit.HOURS); } if(params.size() < 1) { return CrudUtil.postHandle(integer, 1); diff --git a/src/main/java/com/dreamchaser/depository_manage/controller/MaterialController.java b/src/main/java/com/dreamchaser/depository_manage/controller/MaterialController.java index bc90eacd..fd70ebf2 100644 --- a/src/main/java/com/dreamchaser/depository_manage/controller/MaterialController.java +++ b/src/main/java/com/dreamchaser/depository_manage/controller/MaterialController.java @@ -274,12 +274,18 @@ public class MaterialController { mp = materialPByCondition.get(0); Map paramByPrice = new HashMap<>(); paramByPrice.put("code",mp.getCode()); + // 获取当前库存中的物料单价 List inventory = materialService.findInventory(paramByPrice); if(inventory.size() > 0){ mp.setPrice(inventory.get(0).getPrice()); }else{ mp.setPrice(0.0); } + paramByPrice.put("mcode",mp.getCode()); + paramByPrice.remove("code"); + // 获取条形码与物料对应关系 + List materialByBarCodeByCondition = materialService.findMaterialByBarCodeByCondition(paramByPrice); + mp.setMaterialAndBarCodeList(materialByBarCodeByCondition); } return new RestResponse(mp, 1, 200); } @@ -339,6 +345,15 @@ public class MaterialController { return new RestResponse(200); } + // 将扫描的条形码数据暂存到redis中 + @PostMapping("/temporaryBarCodeValueForMaterial") + public RestResponse temporaryBarCodeValueForMaterial(@RequestBody Map map, HttpServletRequest request) { + UserByPort userByPort = (UserByPort) request.getAttribute("userToken"); + // 存入mids + redisTemplate.opsForValue().set("temporaryBarCodeValueForMaterial" + userByPort.getNumber(), JSONObject.toJSONString(map)); + return new RestResponse(200); + } + // 判断当前扫描的物料是否存在 @GetMapping("/IsMaterialExist") public RestResponse IsMaterialExist(HttpServletRequest request) { @@ -430,12 +445,189 @@ public class MaterialController { @GetMapping("/application_in_scanQrCode") public RestResponse applicationInScanQrCode(HttpServletRequest request){ UserByPort userByPort = (UserByPort) request.getAttribute("userToken"); + // 获取当前用户所在部门拥有的仓库 + List depositoryByAdminorg = depositoryService.findDepositoryByAdminorg(userByPort.getMaindeparment().toString()); String scanQrCodeValue = redisTemplate.opsForValue().get("scanQrCodeValue"+userByPort.getNumber()).toString(); redisTemplate.delete("scanQrCodeValue"+userByPort.getNumber()); JSONObject jsonObject = JSONObject.parseObject(scanQrCodeValue); + JSONArray materialListByJson = jsonObject.getJSONArray("materialList"); + Map param = new HashMap<>(); + List materialPList = new ArrayList<>(); + + for (int i = 0; i < materialListByJson.size(); i++) { + JSONObject material = (JSONObject) materialListByJson.get(i); + List placePList = new ArrayList<>(); + param.put("mcode",material.getString("code")); + MaterialP mp = new MaterialP(materialService.findMaterialById(material.getInteger("mid"))); + // 获取物料与条形码的对应关系 + List materialByBarCodeByCondition = materialService.findMaterialByBarCodeByCondition(param); + for (int j = 0; j < depositoryByAdminorg.size(); j++) { + Depository depository = depositoryByAdminorg.get(j); + param.put("code",material.getString("code")); + param.put("depositoryId",depository.getId()); + List inventory = materialService.findInventory(param); + if(inventory.size() > 0) { + List place = placeService.findPlaceByMidAndDid(inventory.get(0).getId(), depository.getId()); + placePList.addAll(place); + } + } + mp.setPlacePList(placePList); + mp.setMaterialAndBarCodeList(materialByBarCodeByCondition); + materialPList.add(mp); + } + jsonObject.put("materialList",materialPList); return new RestResponse(jsonObject); } + // 获取条形码扫描结果 + @GetMapping("/application_in_scanBarCode") + public RestResponse applicationInScanBarCode(HttpServletRequest request){ + UserByPort userByPort = (UserByPort) request.getAttribute("userToken"); + String scanBarCodeValue = redisTemplate.opsForValue().get("temporaryBarCodeValueForMaterial"+userByPort.getNumber()).toString(); + redisTemplate.delete("temporaryBarCodeValueForMaterial"+userByPort.getNumber()); + JSONObject jsonObject = JSONObject.parseObject(scanBarCodeValue); + JSONArray barCodeList = (JSONArray) jsonObject.get("barCodeList"); + // 获取标志位,用于判断是否扫描二维码 + Boolean flag = jsonObject.getBoolean("flag"); + Map result = new HashMap<>(); + List materialList = new ArrayList<>(); + // 获取当前用户所在部门拥有的仓库 + List depositoryByAdminorg = depositoryService.findDepositoryByAdminorg(userByPort.getMaindeparment().toString()); + Map param = new HashMap<>(); + for (int i = 0; i < barCodeList.size(); i++) { + // 获取具体的条形码 + String barCode = barCodeList.getString(i); + // 获取条形码与物料的映射 + MaterialAndBarCode materialByBarCode = null; + for (int j = 0; j < depositoryByAdminorg.size(); j++) { + param.put("depositoryId",depositoryByAdminorg.get(j).getId()); + param.put("barCode",barCode); + // 通过仓库与条形码获取对应关系 + materialByBarCode = materialService.findMaterialByBarCodeByBarCodeAndDepositoryId(param); + if(materialByBarCode != null){ + // 如果获取到对应关系 + break; + } + } + if(materialByBarCode == null) { + // 如果没有获取到 + materialByBarCode = materialService.findMaterialByBarCode(barCode); + } + materialList.add(materialByBarCode); + } + result.put("materialList",materialList); + if(flag){ + String scanQrCodeValue = redisTemplate.opsForValue().get("scanQrCodeValue"+userByPort.getNumber()).toString(); + redisTemplate.delete("scanQrCodeValue"+userByPort.getNumber()); + JSONObject parseObject = JSONObject.parseObject(scanQrCodeValue); + result.put("depository",parseObject.get("depository")); + result.put("place",parseObject.get("place")); + } + return new RestResponse(result); + } + + + // 获取条形码扫描结果 + @GetMapping("/application_transfer_scanBarCode") + public RestResponse applicationTransferScanBarCode(HttpServletRequest request){ + UserByPort userByPort = (UserByPort) request.getAttribute("userToken"); + // 获取当前用户部门所拥有仓库 + List depositoryByAdminorg = depositoryService.findDepositoryByAdminorg(userByPort.getMaindeparment().toString()); + String scanBarCodeValue = redisTemplate.opsForValue().get("temporaryBarCodeValueForMaterial"+userByPort.getNumber()).toString(); + redisTemplate.delete("temporaryBarCodeValueForMaterial"+userByPort.getNumber()); + JSONObject jsonObject = JSONObject.parseObject(scanBarCodeValue); + JSONArray barCodeList = (JSONArray) jsonObject.get("barCodeList"); + // 获取标志位,用于判断是否扫描二维码 + Boolean flag = jsonObject.getBoolean("flag"); + Map result = new HashMap<>(); + List materialList = new ArrayList<>(); + for (int i = 0; i < barCodeList.size(); i++) { + // 获取具体的条形码 + String barCode = barCodeList.getString(i); + // 获取条形码与物料的映射 + MaterialAndBarCode materialByBarCode = materialService.findMaterialByBarCode(barCode); + Boolean isExist = false; + List placePList = new ArrayList<>(); + for (int j = 0; j < depositoryByAdminorg.size(); j++) { + Map param = new HashMap<>(); + param.put("depositoryId",depositoryByAdminorg.get(j).getId()); + param.put("code",materialByBarCode.getMcode()); + List inventory = materialService.findInventory(param); + if(inventory.size() > 0){ + // 如果存在该物料 + MaterialP materialP = inventory.get(0); + List placeByMidAndDid = placeService.findPlaceByMidAndDid(materialP.getId(), depositoryByAdminorg.get(j).getId()); + placePList.addAll(placeByMidAndDid); + isExist = true; + } + } + if(isExist) { + materialByBarCode.setPlacePList(placePList); + materialList.add(materialByBarCode); + } + } + result.put("materialList",materialList); + if(flag){ + String scanQrCodeValue = redisTemplate.opsForValue().get("scanQrCodeValue"+userByPort.getNumber()).toString(); + redisTemplate.delete("scanQrCodeValue"+userByPort.getNumber()); + JSONObject parseObject = JSONObject.parseObject(scanQrCodeValue); + result.put("depository",parseObject.get("depository")); + result.put("place",parseObject.get("place")); + } + return new RestResponse(result); + } + + // 获取条形码扫描结果 + @GetMapping("/application_out_scanBarCode") + public RestResponse applicationOutScanBarCode(HttpServletRequest request){ + UserByPort userByPort = (UserByPort) request.getAttribute("userToken"); + // 获取当前用户部门所拥有仓库 + List depositoryByAdminorg = depositoryService.findDepositoryByAdminorg(userByPort.getMaindeparment().toString()); + String scanBarCodeValue = redisTemplate.opsForValue().get("temporaryBarCodeValueForMaterial"+userByPort.getNumber()).toString(); + redisTemplate.delete("temporaryBarCodeValueForMaterial"+userByPort.getNumber()); + JSONObject jsonObject = JSONObject.parseObject(scanBarCodeValue); + JSONArray barCodeList = (JSONArray) jsonObject.get("barCodeList"); + // 获取标志位,用于判断是否扫描二维码 + Boolean flag = jsonObject.getBoolean("flag"); + Map result = new HashMap<>(); + List materialList = new ArrayList<>(); + for (int i = 0; i < barCodeList.size(); i++) { + // 获取具体的条形码 + String barCode = barCodeList.getString(i); + // 获取条形码与物料的映射 + MaterialAndBarCode materialByBarCode = materialService.findMaterialByBarCode(barCode); + Boolean isExist = false; + List placePList = new ArrayList<>(); + for (int j = 0; j < depositoryByAdminorg.size(); j++) { + Map param = new HashMap<>(); + param.put("depositoryId",depositoryByAdminorg.get(j).getId()); + param.put("code",materialByBarCode.getMcode()); + List inventory = materialService.findInventory(param); + if(inventory.size() > 0){ + // 如果存在该物料 + MaterialP materialP = inventory.get(0); + List placeByMidAndDid = placeService.findPlaceByMidAndDid(materialP.getId(), depositoryByAdminorg.get(j).getId()); + materialByBarCode.setMid(materialP.getId()); + placePList.addAll(placeByMidAndDid); + isExist = true; + } + } + if(isExist) { + materialByBarCode.setPlacePList(placePList); + materialList.add(materialByBarCode); + } + } + result.put("materialList",materialList); + if(flag){ + String scanQrCodeValue = redisTemplate.opsForValue().get("scanQrCodeValue"+userByPort.getNumber()).toString(); + redisTemplate.delete("scanQrCodeValue"+userByPort.getNumber()); + JSONObject parseObject = JSONObject.parseObject(scanQrCodeValue); + result.put("depository",parseObject.get("depository")); + result.put("place",parseObject.get("place")); + } + return new RestResponse(result); + } + // 通过条形码获取物料信息 @GetMapping("/findMaterialByBarCode") public RestResponse findMaterialByBarCode(@RequestParam String barCode,HttpServletRequest request){ diff --git a/src/main/java/com/dreamchaser/depository_manage/controller/PageController.java b/src/main/java/com/dreamchaser/depository_manage/controller/PageController.java index 45a95253..d0ee99d9 100644 --- a/src/main/java/com/dreamchaser/depository_manage/controller/PageController.java +++ b/src/main/java/com/dreamchaser/depository_manage/controller/PageController.java @@ -431,6 +431,10 @@ public class PageController { UserByPort userToken = (UserByPort) request.getAttribute("userToken"); if (id != null) { Material material = materialService.findMaterialById(id); + Map map = new HashMap<>(); + map.put("mcode",material.getCode()); + // 获取物料与条形码的对应关系 + List materialByBarCodeByCondition = materialService.findMaterialByBarCodeByCondition(map); Map params = new HashMap<>(); params.put("mid",material.getId()); params.put("mname",material.getMname()); @@ -447,6 +451,7 @@ public class PageController { } mv.addObject("qrCode",qrCode); mv.addObject("record", materialService.findMaterialAndTypeById(id)); + mv.addObject("barCodeList",materialByBarCodeByCondition); mv.addObject("materialTypes", materialTypeService.findMaterialTypeAll()); } else { throw new MyException("缺少必要参数!"); @@ -649,13 +654,13 @@ public class PageController { ModelAndView mv = new ModelAndView(); mv.setViewName("pages/chart/chart-out_back"); // 转出物料数量 - mv.addObject("InCount", depositoryRecordService.CalculateAllApplicationOutCount("已出库")); + mv.addObject("OutCount", depositoryRecordService.CalculateAllApplicationOutCount("已出库")); // 转出物料金额 - mv.addObject("allInCount", depositoryRecordService.CalculateAllApplicationOutCount("")); + mv.addObject("allOutCount", depositoryRecordService.CalculateAllApplicationOutCount("")); // 出售物料数量 - mv.addObject("InPrice", depositoryRecordService.CalculateAllApplicationOutPrice("已出库")); + mv.addObject("OutPrice", depositoryRecordService.CalculateAllApplicationOutPrice("已出库")); // 出库物料总额 - mv.addObject("allInPrice", depositoryRecordService.CalculateAllApplicationOutPrice("")); + mv.addObject("allOutPrice", depositoryRecordService.CalculateAllApplicationOutPrice("")); return mv; } @@ -1603,6 +1608,11 @@ public class PageController { public String scanBarCode(){ return "pages/scanQrCode/ScanBarCode"; } + // 用于扫码条形码 + @GetMapping("/scanBarCodeByNew") + public String scanBarCodeByNew(){ + return "pages/scanQrCode/ScanBarCodeByNew"; + } // 跳转到扫码出库界面 @GetMapping("/scanQrCodeByOut") public ModelAndView scanQrCodeByOut(Integer id,HttpServletRequest request){ @@ -1615,6 +1625,36 @@ public class PageController { mv.addObject("record",applicationOutMinById); return mv; } + // 跳转到新扫码出库界面 + @GetMapping("/scanBarOrQrCodeOut") + public ModelAndView scanBarOrQrCodeOut(Integer id,HttpServletRequest request){ + ModelAndView mv = new ModelAndView(); + // 获取当前要处理的子订单 + ApplicationOutRecordMin applicationOutMinById = depositoryRecordService.findApplicationOutMinById(id); + mv.setViewName("pages/scanQrCode/ScanBarOrQrCodeOut"); + Material materialById = materialService.findMaterialById(applicationOutMinById.getMid()); + mv.addObject("materialById",materialById); + mv.addObject("record",applicationOutMinById); + return mv; + } + @GetMapping("/scanQrCodeTransfer") + public ModelAndView scanQrCodeTransfer(HttpServletRequest request){ + ModelAndView mv = new ModelAndView(); + mv.setViewName("pages/scanQrCode/scanQrCodeTransfer"); + return mv; + } + + @GetMapping("/scanBarCodeIn") + public String scanBarCodeIn(){ + return "pages/scanQrCode/ScanBarCodeIn"; + } + + @GetMapping("/scanBarCodeOut") + public ModelAndView scanBarCodeOut(){ + ModelAndView mv = new ModelAndView(); + mv.setViewName("pages/scanQrCode/ScanBarCodeOut"); + return mv; + } // 获取扫描结果并跳转到入库 @GetMapping("/application_in_scanQrCode") @@ -1653,11 +1693,13 @@ public class PageController { for (int i = 0; i < mids.size(); i++) { Map param = new HashMap<>(); Integer o = ObjectFormatUtil.toInteger(mids.get(i)); - Material materialById = materialService.findMaterialById(o); - param.put("mid",materialById.getId()); - param.put("mname",materialById.getMname()); - param.put("code",materialById.getCode()); - param.put("version",materialById.getVersion()); + MaterialP mp = new MaterialP( materialService.findMaterialById(o)); + param.put("mid",mp.getId()); + param.put("mname",mp.getMname()); + param.put("code",mp.getCode()); + param.put("version",mp.getVersion()); + List materialByBarCodeByCondition = materialService.findMaterialByBarCodeByCondition(param); + param.put("materialAndBarCodeList",materialByBarCodeByCondition); String context = JSONObject.toJSONString(param); materialList.add(context); } diff --git a/src/main/java/com/dreamchaser/depository_manage/entity/MaterialAndBarCode.java b/src/main/java/com/dreamchaser/depository_manage/entity/MaterialAndBarCode.java index 3c452a34..c351f6b1 100644 --- a/src/main/java/com/dreamchaser/depository_manage/entity/MaterialAndBarCode.java +++ b/src/main/java/com/dreamchaser/depository_manage/entity/MaterialAndBarCode.java @@ -1,8 +1,10 @@ package com.dreamchaser.depository_manage.entity; +import com.dreamchaser.depository_manage.pojo.PlaceP; import lombok.Data; import java.math.BigInteger; +import java.util.List; /** * 条形码与物料对应 @@ -57,4 +59,9 @@ public class MaterialAndBarCode { * 物料单价 */ private Double price; + + /** + * 物料所处库位 + */ + private List placePList; } 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 cda39ec5..f92e224a 100644 --- a/src/main/java/com/dreamchaser/depository_manage/mapper/DepositoryRecordMapper.java +++ b/src/main/java/com/dreamchaser/depository_manage/mapper/DepositoryRecordMapper.java @@ -2,6 +2,7 @@ package com.dreamchaser.depository_manage.mapper; import com.dreamchaser.depository_manage.entity.*; import com.dreamchaser.depository_manage.pojo.ApplicationInRecordP; +import com.dreamchaser.depository_manage.pojo.ApplicationOutRecordMinP; import com.dreamchaser.depository_manage.pojo.ApplicationOutRecordP; import org.apache.ibatis.annotations.Mapper; import org.springframework.stereotype.Repository; @@ -327,4 +328,10 @@ public interface DepositoryRecordMapper { * @return */ List findApplicationOutMinByCondition(Map map); + + /** + * 获取所有已经完成的子订单 + * @return + */ + List findApplicationOutMinForComplete(); } 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 711448f1..c25cf696 100644 --- a/src/main/java/com/dreamchaser/depository_manage/mapper/DepositoryRecordMapper.xml +++ b/src/main/java/com/dreamchaser/depository_manage/mapper/DepositoryRecordMapper.xml @@ -716,6 +716,14 @@ where 1 = 1 and aorm.parentId = #{parentId} + + diff --git a/src/main/java/com/dreamchaser/depository_manage/mapper/MaterialMapper.java b/src/main/java/com/dreamchaser/depository_manage/mapper/MaterialMapper.java index 55d60122..e1c34836 100644 --- a/src/main/java/com/dreamchaser/depository_manage/mapper/MaterialMapper.java +++ b/src/main/java/com/dreamchaser/depository_manage/mapper/MaterialMapper.java @@ -172,14 +172,29 @@ public interface MaterialMapper { * @param map * @return */ - MaterialAndBarCode findMaterialByBarCodeByCondition(Map map); + List findMaterialByBarCodeByCondition(Map map); /** - * 添加条形码与物料编码的映射 + * 添加条形码与物料编码的映射,单条数据 * @param map * @return */ Integer addBarCodeAndMcode(Map map); + + /** + * 批量添加条形码与物料之间的映射 + * @param map + * @return + */ + Integer addBarCodeAndMaterialForMoreOne(Map map); + + + /** + * 删除条形码与物料之间的映射 + * @param map + * @return + */ + Integer deleteBarCodeAndMaterial(Map map); } diff --git a/src/main/java/com/dreamchaser/depository_manage/mapper/MaterialMapper.xml b/src/main/java/com/dreamchaser/depository_manage/mapper/MaterialMapper.xml index 4a49fda9..e681ada9 100644 --- a/src/main/java/com/dreamchaser/depository_manage/mapper/MaterialMapper.xml +++ b/src/main/java/com/dreamchaser/depository_manage/mapper/MaterialMapper.xml @@ -108,8 +108,11 @@ AND m.price = #{price} - - AND m.type_id = #{typeId} + + AND m.type_id = #{materialTypeId} + + + and m.code = #{code} and state != 3 and m.depository_id is null @@ -273,6 +276,7 @@ AND tname LIKE CONCAT('%', #{tname}, '%') + group by bmcode @@ -374,6 +378,18 @@ #{code} ) + + + + insert into barcodeandmaterial(id,mcode,barCode) + values + + (#{id}, + #{code}, + #{item}) + + + @@ -398,6 +414,23 @@ + + + delete + from barcodeandmaterial + where 1 = 1 + + and barCode = #{barCode} + + + and mcode = #{mcode} + + + and id = #{id} + + + + diff --git a/src/main/java/com/dreamchaser/depository_manage/pojo/MaterialP.java b/src/main/java/com/dreamchaser/depository_manage/pojo/MaterialP.java index 52f7c7c8..0dc0c6c0 100644 --- a/src/main/java/com/dreamchaser/depository_manage/pojo/MaterialP.java +++ b/src/main/java/com/dreamchaser/depository_manage/pojo/MaterialP.java @@ -1,9 +1,11 @@ package com.dreamchaser.depository_manage.pojo; import com.dreamchaser.depository_manage.entity.Material; +import com.dreamchaser.depository_manage.entity.MaterialAndBarCode; import lombok.Data; import java.math.BigInteger; +import java.util.List; /** * 库存类的包装类 @@ -101,6 +103,17 @@ public class MaterialP { private String placeCode; + /** + * 物料编码与条形码的对应关系 + */ + private List materialAndBarCodeList; + + /** + * 物料所处库位 + */ + private List placePList; + + public MaterialP(Integer id, Integer depositoryId, String mname, Integer quantity, Double price, String typeName) { diff --git a/src/main/java/com/dreamchaser/depository_manage/service/MaterialService.java b/src/main/java/com/dreamchaser/depository_manage/service/MaterialService.java index 59f4667e..05a67747 100644 --- a/src/main/java/com/dreamchaser/depository_manage/service/MaterialService.java +++ b/src/main/java/com/dreamchaser/depository_manage/service/MaterialService.java @@ -187,4 +187,19 @@ public interface MaterialService { * @return */ MaterialAndBarCode findMaterialByBarCode(String barCode); + + + /** + * 通过条件获取条形码与物料的对应关系 + * @param map + * @return + */ + List findMaterialByBarCodeByCondition(Map map); + + /** + * 通过条形码与仓库编码获取对应关系 + * @param map + * @return + */ + MaterialAndBarCode findMaterialByBarCodeByBarCodeAndDepositoryId(Map map); } diff --git a/src/main/java/com/dreamchaser/depository_manage/service/impl/DepositoryRecordServiceImpl.java b/src/main/java/com/dreamchaser/depository_manage/service/impl/DepositoryRecordServiceImpl.java index 3660cd94..90d65cce 100644 --- a/src/main/java/com/dreamchaser/depository_manage/service/impl/DepositoryRecordServiceImpl.java +++ b/src/main/java/com/dreamchaser/depository_manage/service/impl/DepositoryRecordServiceImpl.java @@ -236,27 +236,17 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { List applicationOutRecordPAll = depositoryRecordMapper.findApplicationOutRecordPAll(); Double sum = 0.0; if (state.isEmpty()) { + // 如果要获取要出库的所有数量 for (int i = 0; i < applicationOutRecordPAll.size(); i++) { sum += (double) applicationOutRecordPAll.get(i).getQuantity(); } } else { - for (int i = 0; i < applicationOutRecordPAll.size(); i++) { - if (state.equals(applicationOutRecordPAll.get(i).getState())) { - for (int j = 0; j < applicationOutRecordPAll.size(); j++) { - ApplicationOutRecordP applicationOutRecordP = applicationOutRecordPAll.get(j); - // 获取所有子物料 - Map map = new HashMap<>(); - map.put("parentId", applicationOutRecordP.getId()); - List minByCondition = depositoryRecordMapper.findApplicationOutMinByCondition(map); - for (int k = 0; k < minByCondition.size(); k++) { - ApplicationOutRecordMin applicationOutRecordMin = minByCondition.get(k); - Integer mid = applicationOutRecordMin.getMid(); - Material materialById = materialMapper.findMaterialById(mid); - sum += (double) materialById.getQuantity(); - } - } - } + // 如果获取已经出库的数量 + List applicationOutMinForComplete = depositoryRecordMapper.findApplicationOutMinForComplete(); + for (int i = 0; i < applicationOutMinForComplete.size(); i++) { + ApplicationOutRecordMin recordMin = applicationOutMinForComplete.get(i); + sum += (double) recordMin.getQuantity(); } } return sum; @@ -466,9 +456,17 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { params.put("pid", placeId); // 获取当前物料所存放库位的数量 placeAndMaterialByMidAndPid = placeMapper.findPlaceAndMaterialByMidAndPid(params); - if (placeAndMaterialByMidAndPid.getQuantity() < record.getQuantity()) { - // 如果当前库位数量不足 - flag = false; + if(placeAndMaterialByMidAndPid != null) { + // 如果当前库位存在该物料 + if (placeAndMaterialByMidAndPid.getQuantity() < record.getQuantity()) { + // 如果当前库位数量不足 + flag = false; + } + }else{ + restResponse.setStatus(566); + restResponse.setData(""); + restResponse.setStatusInfo(new StatusInfo("出库失败","当前位置未发现该物料")); + return restResponse; } } else { // 如果是默认库位 Map params = new HashMap<>(); @@ -476,9 +474,17 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { params.put("pid", 0); // 获取当前物料在默认库位中的数量 placeAndMaterialByMidAndPid = placeMapper.findPlaceAndMaterialByMidAndPid(params); - if (placeAndMaterialByMidAndPid.getQuantity() < record.getQuantity()) { - // 如果当前库位数量不足 - flag = false; + if(placeAndMaterialByMidAndPid != null) { + // 如果当前库位存在该物料 + if (placeAndMaterialByMidAndPid.getQuantity() < record.getQuantity()) { + // 如果当前库位数量不足 + flag = false; + } + }else{ + restResponse.setStatus(566); + restResponse.setData(""); + restResponse.setStatusInfo(new StatusInfo("出库失败","当前位置未发现该物料")); + return restResponse; } } // 获取出库物料具体信息 @@ -667,7 +673,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { } // depositoryRecordMapper.insertApplicationInRecord(map); - transferRecordMapper.addTransferRecord(map);// 插入转移记录 + transferRecordMapper.addTransferRecord(map);// 插入转移记录 Integer transferId = ObjectFormatUtil.toInteger(map.get("id")); //清除主键 map.remove("id"); @@ -677,8 +683,9 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { Administration company = PageController.getCompany(userByPort.getMaindeparment(), userByPort); // 生成出库订单 map.put("code", createCode(depositoryRecordById.getDname(), "outOrderNumber", "out", company.getName())); - String placeId = map.get("fromPlaceId").toString(); - if ("".equals(placeId) || "0".equals(placeId)) { + Object placeId = map.get("fromPlaceId"); + + if (placeId == null ||"".equals(placeId.toString()) || "0".equals(placeId.toString())) { map.put("placeId", 0); } // 插入主表 @@ -687,17 +694,6 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { // 清除主键 map.remove("id"); map.put("parentId", id); - - String departMentHeadQyWxName = (String) map.get("departMentHeadQyWxName"); - JSONObject jsonObject = qyWxOperationService.sendQyWxMessage(departMentHeadQyWxName, ObjectFormatUtil.toInteger(id), true); - // 将当前返回结果保存到redis中 - Map QyWxMessageMap = new HashMap<>(); - QyWxMessageMap.put("MsgId",jsonObject.getString("msgid")); - QyWxMessageMap.put("responseCode",jsonObject.getString("response_code")); - // key user:300450:QyWxOut:1 - redisTemplate.opsForHash().putAll("user:"+userByPort.getNumber()+":QyWxOutId:"+id,QyWxMessageMap); - // 设置过期时间为三天 - redisTemplate.expire("user:"+userByPort.getNumber()+":QyWxOutId:"+id,72,TimeUnit.HOURS); return depositoryRecordMapper.insertApplicationOutRecordMin(map); } @@ -752,6 +748,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { }).start(); } else { result = "驳回"; + map.put("pass",2); map.put("state", "部门负责人审核未通过"); } @@ -927,6 +924,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { redisTemplate.expire("user:"+userByPort.getNumber()+":QyWxOutId:"+outId,72,TimeUnit.HOURS); } else { // 如果点击的是驳回 + map.put("pass", 2); map.put("departmentheadPass", 2); map.put("state", "部门负责人审核未通过"); @@ -1411,6 +1409,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { List applicationOutRecordPAll = depositoryRecordMapper.findApplicationOutRecordPAll(); Double sum = 0.0; if (state.isEmpty()) { + // 如果要获取所有待出库的金额 for (int i = 0; i < applicationOutRecordPAll.size(); i++) { ApplicationOutRecordP applicationOutRecordP = applicationOutRecordPAll.get(i); // 获取所有子物料 @@ -1426,20 +1425,13 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { } } else { - for (int i = 0; i < applicationOutRecordPAll.size(); i++) { - if (state.equals(applicationOutRecordPAll.get(i).getState())) { - ApplicationOutRecordP applicationOutRecordP = applicationOutRecordPAll.get(i); - // 获取所有子物料 - Map map = new HashMap<>(); - map.put("parentId", applicationOutRecordP.getId()); - List minByCondition = depositoryRecordMapper.findApplicationOutMinByCondition(map); - for (int k = 0; k < minByCondition.size(); k++) { - ApplicationOutRecordMin applicationOutRecordMin = minByCondition.get(k); - Integer mid = applicationOutRecordMin.getMid(); - Material materialById = materialMapper.findMaterialById(mid); - sum += ((double) materialById.getPrice() / 100) * applicationOutRecordMin.getQuantity(); - } - } + // 如果要获取已完成的金额 + List applicationOutMinForComplete = depositoryRecordMapper.findApplicationOutMinForComplete(); + for (int i = 0; i < applicationOutMinForComplete.size(); i++) { + ApplicationOutRecordMin recordMin = applicationOutMinForComplete.get(i); + Integer mid = recordMin.getMid(); + Material materialById = materialMapper.findMaterialById(mid); + sum += ((double) materialById.getPrice() / 100) * recordMin.getQuantity(); } } BigDecimal bg = new BigDecimal(sum); diff --git a/src/main/java/com/dreamchaser/depository_manage/service/impl/MaterialServiceImpl.java b/src/main/java/com/dreamchaser/depository_manage/service/impl/MaterialServiceImpl.java index 2ba02e31..ac3f883a 100644 --- a/src/main/java/com/dreamchaser/depository_manage/service/impl/MaterialServiceImpl.java +++ b/src/main/java/com/dreamchaser/depository_manage/service/impl/MaterialServiceImpl.java @@ -84,6 +84,7 @@ public class MaterialServiceImpl implements MaterialService { * @param map 参数列表 * @return 受影响的行数 */ + @Transactional @Override public Integer updateMaterial(Map map) { if(map.containsKey("price")){ @@ -98,6 +99,20 @@ public class MaterialServiceImpl implements MaterialService { Object materialTypeId = map.get("materialTypeId"); map.put("typeId", materialTypeId); } + String barCode = (String) map.get("barCode"); + if(!"0".equals(barCode)) { + Map delParam = new HashMap<>(); + delParam.put("id", barCode); + materialMapper.deleteBarCodeAndMaterial(delParam); + } + if(map.containsKey("barCodeList")){ + // 如果需要新增与条形码的映射 + List barCodeList = (ArrayList) map.get("barCodeList"); + Map param = new HashMap<>(); + param.put("list",barCodeList); + param.put("code",map.get("code")); + materialMapper.addBarCodeAndMaterialForMoreOne(param); + } return materialMapper.updateMaterial(map); } @@ -498,9 +513,39 @@ public class MaterialServiceImpl implements MaterialService { public MaterialAndBarCode findMaterialByBarCode(String barCode) { Map map =new HashMap<>(); map.put("barCode",barCode); + List materialByBarCodeByCondition = materialMapper.findMaterialByBarCodeByCondition(map); + if(materialByBarCodeByCondition.size() > 0){ + return materialByBarCodeByCondition.get(0); + } + return null; + } + + /** + * 通过条件获取条形码与物料的对应关系 + * @param map + * @return + */ + @Override + public List findMaterialByBarCodeByCondition(Map map) { return materialMapper.findMaterialByBarCodeByCondition(map); } + /** + * 通过条形码与仓库编码获取对应关系 + * @param map + * @return + */ + @Override + public MaterialAndBarCode findMaterialByBarCodeByBarCodeAndDepositoryId(Map map) { + List materialByBarCodeByCondition = materialMapper.findMaterialByBarCodeByCondition(map); + if(materialByBarCodeByCondition.size() > 0){ + MaterialAndBarCode materialAndBarCode = materialByBarCodeByCondition.get(0); + materialAndBarCode.setPrice(materialAndBarCode.getPrice() / 100); + return materialAndBarCode; + } + return null; + } + /** * 构造树形选择框 * @return diff --git a/src/main/java/com/dreamchaser/depository_manage/utils/HttpUtils.java b/src/main/java/com/dreamchaser/depository_manage/utils/HttpUtils.java index 56fd2952..56418ce9 100644 --- a/src/main/java/com/dreamchaser/depository_manage/utils/HttpUtils.java +++ b/src/main/java/com/dreamchaser/depository_manage/utils/HttpUtils.java @@ -239,6 +239,9 @@ public class HttpUtils { if(userByPort!=null) { keyAndToken = UserKeyAndTokenPool.getKeyAndToken(userByPort.getNumber()); + if(keyAndToken == null || "".equals(keyAndToken)){ + keyAndToken = " & "; + } } String[] split = keyAndToken.split("&"); diff --git a/src/main/resources/templates/pages/application/application-in.html b/src/main/resources/templates/pages/application/application-in.html index 94c9cb2c..06076911 100644 --- a/src/main/resources/templates/pages/application/application-in.html +++ b/src/main/resources/templates/pages/application/application-in.html @@ -12,17 +12,25 @@ @@ -30,105 +38,126 @@
- -