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 e718d21e..b9801a29 100644 --- a/src/main/java/com/dreamchaser/depository_manage/controller/DepositoryRecordController.java +++ b/src/main/java/com/dreamchaser/depository_manage/controller/DepositoryRecordController.java @@ -1068,115 +1068,6 @@ public class DepositoryRecordController { list = depositoryRecordService.findApplicationOutRecordPByUser(userByPort, map, userKey, token); countBy = depositoryRecordService.findApplicationOutRecordPCountByUser(userByPort, map); } - Map userByPortMap = new HashMap<>(); - for (ApplicationOutRecordP outRecordP : list) { - // 根据主订单获取所有子订单 - List applicationOutMinByParentId = depositoryRecordService.findApplicationOutMinByParentId(outRecordP.getId()); - StringBuilder mname = new StringBuilder(); - StringBuilder mcode = new StringBuilder(); - StringBuilder mversion = new StringBuilder(); - StringBuilder depositoryName = new StringBuilder(); - double sumQuantity = 0; - double sumPrice = 0.0; - List depositoryIdList = new ArrayList<>(); - List mnameForMobiles = new ArrayList<>(); - for (ApplicationOutRecordMinP applicationOutRecordMin : applicationOutMinByParentId) { - // 获取子订单信息 - // 获取出库物料信息 - Inventory inventory = materialService.findInventoryById(applicationOutRecordMin.getMid()); - String brand = inventory.getBrand(); - String version = inventory.getVersion(); - if (brand == null) { - inventory.setBrand(""); - brand = ""; - } - if (version == null) { - inventory.setVersion(""); - version = ""; - } - // 获取出库物料仓库Id - Long depositoryId = applicationOutRecordMin.getDepositoryId(); - if (!depositoryIdList.contains(depositoryId)) { - depositoryIdList.add(depositoryId); - } - String inventoryMname = inventory.getMname(); - mname.append(inventoryMname).append(","); - mcode.append(inventory.getCode()).append(","); - String mversionItem = brand + " " + version; - mversion.append(mversionItem).append(","); - mnameForMobiles.add(inventoryMname + ":" + mversionItem); - sumQuantity += applicationOutRecordMin.getQuantity(); - String unit = applicationOutRecordMin.getUnit(); - if ("-1".equals(unit)) { - double amounts = ObjectFormatUtil.multiply(inventory.getPrice(), applicationOutRecordMin.getQuantity()); - sumPrice = ObjectFormatUtil.sum(sumPrice, amounts); - } else { - // 获取当前对应的拆单记录 - Map paramForSplitInfo = new HashMap<>(); - paramForSplitInfo.put("mid", inventory.getMid()); - paramForSplitInfo.put("newUnit", unit); - SplitInfo splitInfo = splitUnitService.findSplitInfoByMidAndUnit(paramForSplitInfo); - // 获取当前拆单记录与基础单位进制 - int splitInfoScaleQuantity = splitUnitService.findSplitInfoScaleQuantity(splitInfo, -1L); - BigDecimal bg = new BigDecimal(inventory.getPrice() / splitInfoScaleQuantity * applicationOutRecordMin.getQuantity()); - double newprice = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); - sumPrice = ObjectFormatUtil.sum(sumPrice, newprice); - } - } - outRecordP.setMcode(mcode.toString()); - outRecordP.setMname(mname.toString()); - outRecordP.setMversion(mversion.toString()); - List depositoryList = depositoryService.findDepositoryByIds(depositoryIdList); - for (Depository depository : depositoryList - ) { - depositoryName.append(depository.getDname()).append(","); - } - // 部门负责人 - String departmentHead = outRecordP.getDepartmenthead(); - String[] split = departmentHead.split(","); - if ("".equals(departmentHead) || departmentHead.isEmpty()) { - // 如果当前没有部门负责人 - split = new String[0]; - } - String useAdminorgName = ""; - for (String value : split) { - if ("".equals(value)) { - continue; - } - UserByPort departmenthead = null; - Long departmentheadId = ObjectFormatUtil.toLong(value); - if (userByPortMap.containsKey(departmentheadId)) { - departmenthead = userByPortMap.get(departmentheadId); - } else { - departmenthead = userService.findUserById(departmentheadId); - userByPortMap.put(departmentheadId, departmenthead); - } - // 获取用户的用工关系 - int emptype = departmenthead.getEmptype(); - if (emptype > 10) { - continue; - } - if ("".equals(useAdminorgName)) { - useAdminorgName = departmenthead.getMaindeparmentname(); - } else { - break; - } - } - - // 用于判断是否全审批完成 - if ("3".equals(outRecordP.getDepartmentheadPass()) || "3".equals(outRecordP.getDepositoryManagerPass()) || (outRecordP.getBalancePosterPass() != null && "3".equals(outRecordP.getBalancePosterPass()))) { - outRecordP.setAllApproval(false); - } else { - outRecordP.setAllApproval(true); - } - - outRecordP.setUseAdminorgName(useAdminorgName); - outRecordP.setDepositoryName(depositoryName.toString()); - outRecordP.setQuantity(sumQuantity); - outRecordP.setPrice(sumPrice); - outRecordP.setMnameStringList(mnameForMobiles); - } - return new RestResponse(list, countBy, 200); } diff --git a/src/main/java/com/dreamchaser/depository_manage/depository_mapper/DepositoryRecordMapper.xml b/src/main/java/com/dreamchaser/depository_manage/depository_mapper/DepositoryRecordMapper.xml index 727f5881..bcaacfde 100644 --- a/src/main/java/com/dreamchaser/depository_manage/depository_mapper/DepositoryRecordMapper.xml +++ b/src/main/java/com/dreamchaser/depository_manage/depository_mapper/DepositoryRecordMapper.xml @@ -117,9 +117,11 @@ + + @@ -187,7 +189,7 @@ aorid,mid,mname,depositoryId,dname,applicantId,applicantTime,applyRemark,aorcode,aorpirce,aorquantity,departmenthead,departmentheadPass,departmentHeadTime,departmentheadMessage, depositoryManager,depositoryManagerPass,depositoryManagerTime,depositoryManagerMessage,aorstate,istransfer,mcode,placeId,pass,aormUnit,aorconstructionunitid,aoradminorgid,cuname, - cuintroduce,cuaddress,outTime,abstract,outType,editUser,mbrand,mversion,flagForOpenDepository,createUid,flagForAgency,balancePoster,balancePosterTime,balancePosterPass,balancePosterMessage,outTypeName + cuintroduce,cuaddress,outTime,abstract,outType,munit,mprice,editUser,mbrand,mversion,flagForOpenDepository,createUid,flagForAgency,balancePoster,balancePosterTime,balancePosterPass,balancePosterMessage,outTypeName @@ -637,12 +639,14 @@ and constructionunitid = #{constructionunitid} - GROUP BY aorid + + GROUP BY aorid + ORDER BY pass DESC,depositoryManagerPass asc, applicantTime desc - ORDER BY applicantTime desc + ORDER BY applicantTime desc LIMIT #{begin},#{size} @@ -703,13 +707,14 @@ and constructionunitid = #{constructionunitid} - - GROUP BY aorid + + GROUP BY aorid + ORDER BY pass DESC,depositoryManagerPass asc, applicantTime desc - ORDER BY applicantTime desc + ORDER BY applicantTime desc LIMIT #{begin},#{size} @@ -718,7 +723,12 @@ select - count(DISTINCT aorid) + + count(*) + + + count(DISTINCT aorid) + + from applicationOutRecordInfo where 1 = 1 and mid is not null diff --git a/src/main/java/com/dreamchaser/depository_manage/entity/ApplicationOutRecord.java b/src/main/java/com/dreamchaser/depository_manage/entity/ApplicationOutRecord.java index c4505014..b70a501a 100644 --- a/src/main/java/com/dreamchaser/depository_manage/entity/ApplicationOutRecord.java +++ b/src/main/java/com/dreamchaser/depository_manage/entity/ApplicationOutRecord.java @@ -19,6 +19,13 @@ public class ApplicationOutRecord { */ private String mname; + /** + * 物料单位 + */ + private String munit; + + + /** * 仓库id */ @@ -65,6 +72,11 @@ public class ApplicationOutRecord { */ private Integer quantity; + /** + * 物料单价 + */ + private Integer mprice; + /** * 部门负责人编号 */ 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 28d82bf5..fe99d2c4 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 @@ -4932,24 +4932,93 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { List list = depositoryRecordMapper.findApplicationOutRecordPByUser(map); List result = new ArrayList<>(); Map userByPortMap = new HashMap<>(); - for (ApplicationOutRecord record : list) { - Long applicantId = record.getApplicantId(); + for (ApplicationOutRecord recordP : list) { + if (recordP.getQuantity() == null || 0 == recordP.getQuantity()) { + continue; + } + String unit = recordP.getUnit(); + // 当前单的总额 + double amounts = 0.0; + // 当前物料单价 + double mprice = ObjectFormatUtil.divide(recordP.getMprice(),100.0,2); + // 当前出库数 + double quantity = ObjectFormatUtil.divide(recordP.getQuantity(),100.0,2); + if ("-1".equals(unit) || unit.equals("")) { + amounts = ObjectFormatUtil.multiply(mprice, quantity); + } else { +// // 获取当前对应的拆单记录 + Map paramForSplitInfo = new HashMap<>(); + paramForSplitInfo.put("mid", recordP.getMid()); + paramForSplitInfo.put("newUnit", unit); + SplitInfo splitInfo = splitUnitMapper.findSplitInfoByMidAndUnit(paramForSplitInfo); +// // 获取当前拆单记录与基础单位进制 + int splitInfoScaleQuantity = splitUnitService.findSplitInfoScaleQuantity(splitInfo, -1L); + BigDecimal bg = new BigDecimal(mprice / splitInfoScaleQuantity * quantity); + amounts = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); + } + recordP.setPrice(amounts); + + // 获取当前申请人id + Long applicantId = recordP.getApplicantId(); + // 声明申请人信息 UserByPort userByPortById = null; if (userByPortMap.containsKey(applicantId)) { userByPortById = userByPortMap.get(applicantId); - } else { + } + else { userByPortById = userMapper.findUserById(applicantId); Administration departmentByUser = administrativeService.getDepartmentByUser(userByPortById); userByPortById.setMaindeparmentname(departmentByUser.getName()); userByPortMap.put(applicantId, userByPortById); } - String time = DateUtil.TimeStampToDateTime(ObjectFormatUtil.toLong(record.getApplicantTime())); - record.setApplicantName(userByPortById.getName()); - record.setApplicantTime(time); - record.setApplyRemark(record.getApplyRemark() == null ? "" : record.getApplyRemark()); - ApplicationOutRecordP recordP = new ApplicationOutRecordP(record); - recordP.setAdminorgName(userByPortById.getMaindeparmentname()); - result.add(recordP); + + + // 部门负责人 + String departmentHead = recordP.getDepartmenthead(); + String[] split = departmentHead.split(","); + if ("".equals(departmentHead) || departmentHead.isEmpty()) { + // 如果当前没有部门负责人 + split = new String[0]; + } + String useAdminorgName = ""; + for (String value : split) { + if ("".equals(value)) { + continue; + } + UserByPort departmenthead = null; + Long departmentheadId = ObjectFormatUtil.toLong(value); + if (userByPortMap.containsKey(departmentheadId)) { + departmenthead = userByPortMap.get(departmentheadId); + } else { + departmenthead = userMapper.findUserById(departmentheadId); + Administration departmentByUser = administrativeService.getDepartmentByUser(departmenthead); + departmenthead.setMaindeparmentname(departmentByUser.getName()); + userByPortMap.put(departmentheadId, departmenthead); + } + // 获取用户的用工关系 + int emptype = departmenthead.getEmptype(); + if (emptype > 10) { + continue; + } + if ("".equals(useAdminorgName)) { + useAdminorgName = departmenthead.getMaindeparmentname(); + } else { + break; + } + } + String time = DateUtil.TimeStampToDateTime(ObjectFormatUtil.toLong(recordP.getApplicantTime())); + recordP.setApplicantName(userByPortById.getName()); + recordP.setApplicantTime(time); + recordP.setApplyRemark(recordP.getApplyRemark() == null ? "" : recordP.getApplyRemark()); + ApplicationOutRecordP aorp = new ApplicationOutRecordP(recordP); + aorp.setAdminorgName(userByPortById.getMaindeparmentname()); + if ("3".equals(aorp.getDepartmentheadPass()) || "3".equals(aorp.getDepositoryManagerPass()) || (aorp.getBalancePosterPass() != null && "3".equals(aorp.getBalancePosterPass()))) { + aorp.setAllApproval(false); + } else { + aorp.setAllApproval(true); + } + aorp.setUseAdminorgName(useAdminorgName); + result.add(aorp); } return result; } @@ -5023,23 +5092,88 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { if (recordP.getQuantity() == null || 0 == recordP.getQuantity()) { continue; } + String unit = recordP.getUnit(); + // 当前单的总额 + double amounts = 0.0; + // 当前物料单价 + double mprice = ObjectFormatUtil.divide(recordP.getMprice(),100.0,2); + // 当前出库数 + double quantity = ObjectFormatUtil.divide(recordP.getQuantity(),100.0,2); + if ("-1".equals(unit) || unit.equals("")) { + amounts = ObjectFormatUtil.multiply(mprice, quantity); + } else { +// // 获取当前对应的拆单记录 + Map paramForSplitInfo = new HashMap<>(); + paramForSplitInfo.put("mid", recordP.getMid()); + paramForSplitInfo.put("newUnit", unit); + SplitInfo splitInfo = splitUnitMapper.findSplitInfoByMidAndUnit(paramForSplitInfo); +// // 获取当前拆单记录与基础单位进制 + int splitInfoScaleQuantity = splitUnitService.findSplitInfoScaleQuantity(splitInfo, -1L); + BigDecimal bg = new BigDecimal(mprice / splitInfoScaleQuantity * quantity); + amounts = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); + } + recordP.setPrice(amounts); + + // 获取当前申请人id Long applicantId = recordP.getApplicantId(); + // 声明申请人信息 UserByPort userByPortById = null; if (userByPortMap.containsKey(applicantId)) { userByPortById = userByPortMap.get(applicantId); - } else { + } + else { userByPortById = userMapper.findUserById(applicantId); Administration departmentByUser = administrativeService.getDepartmentByUser(userByPortById); userByPortById.setMaindeparmentname(departmentByUser.getName()); userByPortMap.put(applicantId, userByPortById); } + + + // 部门负责人 + String departmentHead = recordP.getDepartmenthead(); + String[] split = departmentHead.split(","); + if ("".equals(departmentHead) || departmentHead.isEmpty()) { + // 如果当前没有部门负责人 + split = new String[0]; + } + String useAdminorgName = ""; + for (String value : split) { + if ("".equals(value)) { + continue; + } + UserByPort departmenthead = null; + Long departmentheadId = ObjectFormatUtil.toLong(value); + if (userByPortMap.containsKey(departmentheadId)) { + departmenthead = userByPortMap.get(departmentheadId); + } else { + departmenthead = userMapper.findUserById(departmentheadId); + Administration departmentByUser = administrativeService.getDepartmentByUser(departmenthead); + departmenthead.setMaindeparmentname(departmentByUser.getName()); + userByPortMap.put(departmentheadId, departmenthead); + } + // 获取用户的用工关系 + int emptype = departmenthead.getEmptype(); + if (emptype > 10) { + continue; + } + if ("".equals(useAdminorgName)) { + useAdminorgName = departmenthead.getMaindeparmentname(); + } else { + break; + } + } String time = DateUtil.TimeStampToDateTime(ObjectFormatUtil.toLong(recordP.getApplicantTime())); recordP.setApplicantName(userByPortById.getName()); recordP.setApplicantTime(time); recordP.setApplyRemark(recordP.getApplyRemark() == null ? "" : recordP.getApplyRemark()); ApplicationOutRecordP aorp = new ApplicationOutRecordP(recordP); aorp.setAdminorgName(userByPortById.getMaindeparmentname()); - + if ("3".equals(aorp.getDepartmentheadPass()) || "3".equals(aorp.getDepositoryManagerPass()) || (aorp.getBalancePosterPass() != null && "3".equals(aorp.getBalancePosterPass()))) { + aorp.setAllApproval(false); + } else { + aorp.setAllApproval(true); + } + aorp.setUseAdminorgName(useAdminorgName); result.add(aorp); } return result; diff --git a/src/main/resources/templates/pages/depository/table-out.html b/src/main/resources/templates/pages/depository/table-out.html index e87dda16..b5394f63 100644 --- a/src/main/resources/templates/pages/depository/table-out.html +++ b/src/main/resources/templates/pages/depository/table-out.html @@ -184,10 +184,9 @@ let cols = [ {type: "checkbox", width: 50}, - {field: "code", title: '申请编码', width: 150,}, - // {field: 'mname', width: 150, title: '物料名称'}, - {field: 'mname', width: 200, title: '物料名称', templet: '#mnameSelect'}, - + {field: "code", title: '申请编码', width: 200,}, + {field: 'mname', width: 150, title: '物料名称'}, + // {field: 'mname', width: 200, title: '物料名称', templet: '#mnameSelect'}, {field: 'mcode', width: 150, title: '存货编码'}, {field: 'quantity', width: 100, title: '数量', sort: true}, {field: 'depositoryName', width: 150, title: '仓库名称'},