diff --git a/jshERP-boot/src/main/java/com/jsh/erp/constants/ExceptionConstants.java b/jshERP-boot/src/main/java/com/jsh/erp/constants/ExceptionConstants.java index 4173f8c5..5e29a314 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/constants/ExceptionConstants.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/constants/ExceptionConstants.java @@ -424,6 +424,9 @@ public class ExceptionConstants { //单据录入-单据中存在部分状态,需要到新增界面关联单据 public static final int DEPOT_ITEM_EXIST_PARTIALLY_STATUS_FAILED_CODE = 8500028; public static final String DEPOT_ITEM_EXIST_PARTIALLY_STATUS_FAILED_MSG = "抱歉,单据:%s是部分%s状态,需要到新增界面关联单据"; + //单据录入-关联请购单号和关联订单号不能同时录入 + public static final int DEPOT_ITEM_EXIST_REPEAT_NO_FAILED_CODE = 8500029; + public static final String DEPOT_ITEM_EXIST_REPEAT_NO_FAILED_MSG = "抱歉,关联请购单号和关联订单号不能同时录入"; /** * 单据明细信息 diff --git a/jshERP-boot/src/main/java/com/jsh/erp/datasource/entities/DepotHead.java b/jshERP-boot/src/main/java/com/jsh/erp/datasource/entities/DepotHead.java index 5dc86c77..e2a7a19e 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/datasource/entities/DepotHead.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/datasource/entities/DepotHead.java @@ -62,6 +62,8 @@ public class DepotHead { private String linkNumber; + private String linkApply; + private Long tenantId; private String deleteFlag; @@ -298,6 +300,14 @@ public class DepotHead { this.linkNumber = linkNumber == null ? null : linkNumber.trim(); } + public String getLinkApply() { + return linkApply; + } + + public void setLinkApply(String linkApply) { + this.linkApply = linkApply == null ? null : linkApply.trim(); + } + public Long getTenantId() { return tenantId; } diff --git a/jshERP-boot/src/main/java/com/jsh/erp/datasource/entities/DepotHeadExample.java b/jshERP-boot/src/main/java/com/jsh/erp/datasource/entities/DepotHeadExample.java index 1b0b9dad..ccb47722 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/datasource/entities/DepotHeadExample.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/datasource/entities/DepotHeadExample.java @@ -1996,6 +1996,76 @@ public class DepotHeadExample { return (Criteria) this; } + public Criteria andLinkApplyIsNull() { + addCriterion("link_apply is null"); + return (Criteria) this; + } + + public Criteria andLinkApplyIsNotNull() { + addCriterion("link_apply is not null"); + return (Criteria) this; + } + + public Criteria andLinkApplyEqualTo(String value) { + addCriterion("link_apply =", value, "linkApply"); + return (Criteria) this; + } + + public Criteria andLinkApplyNotEqualTo(String value) { + addCriterion("link_apply <>", value, "linkApply"); + return (Criteria) this; + } + + public Criteria andLinkApplyGreaterThan(String value) { + addCriterion("link_apply >", value, "linkApply"); + return (Criteria) this; + } + + public Criteria andLinkApplyGreaterThanOrEqualTo(String value) { + addCriterion("link_apply >=", value, "linkApply"); + return (Criteria) this; + } + + public Criteria andLinkApplyLessThan(String value) { + addCriterion("link_apply <", value, "linkApply"); + return (Criteria) this; + } + + public Criteria andLinkApplyLessThanOrEqualTo(String value) { + addCriterion("link_apply <=", value, "linkApply"); + return (Criteria) this; + } + + public Criteria andLinkApplyLike(String value) { + addCriterion("link_apply like", value, "linkApply"); + return (Criteria) this; + } + + public Criteria andLinkApplyNotLike(String value) { + addCriterion("link_apply not like", value, "linkApply"); + return (Criteria) this; + } + + public Criteria andLinkApplyIn(List values) { + addCriterion("link_apply in", values, "linkApply"); + return (Criteria) this; + } + + public Criteria andLinkApplyNotIn(List values) { + addCriterion("link_apply not in", values, "linkApply"); + return (Criteria) this; + } + + public Criteria andLinkApplyBetween(String value1, String value2) { + addCriterion("link_apply between", value1, value2, "linkApply"); + return (Criteria) this; + } + + public Criteria andLinkApplyNotBetween(String value1, String value2) { + addCriterion("link_apply not between", value1, value2, "linkApply"); + return (Criteria) this; + } + public Criteria andTenantIdIsNull() { addCriterion("tenant_id is null"); return (Criteria) this; diff --git a/jshERP-boot/src/main/java/com/jsh/erp/datasource/mappers/DepotItemMapperEx.java b/jshERP-boot/src/main/java/com/jsh/erp/datasource/mappers/DepotItemMapperEx.java index 1cefcbde..698219e5 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/datasource/mappers/DepotItemMapperEx.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/datasource/mappers/DepotItemMapperEx.java @@ -211,13 +211,15 @@ public interface DepotItemMapperEx { BigDecimal getFinishNumber( @Param("meId") Long meId, @Param("linkId") Long linkId, - @Param("linkNumber") String linkNumber, + @Param("linkStr") String linkStr, + @Param("noType") String noType, @Param("goToType") String goToType); BigDecimal getRealFinishNumber( @Param("meId") Long meId, @Param("linkId") Long linkId, - @Param("linkNumber") String linkNumber, + @Param("linkStr") String linkStr, + @Param("linkType") String linkType, @Param("currentHeaderId") Long currentHeaderId, @Param("goToType") String goToType); @@ -235,10 +237,11 @@ public interface DepotItemMapperEx { @Param("depotId") Long depotId); List getLinkBillDetailMaterialSum( - @Param("linkNumber") String linkNumber); + @Param("linkStr") String linkStr); List getBatchBillDetailMaterialSum( - @Param("linkNumber") String linkNumber, + @Param("linkStr") String linkStr, + @Param("linkType") String linkType, @Param("type") String type); Long getCountByMaterialAndBatchNumber( diff --git a/jshERP-boot/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java b/jshERP-boot/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java index 52df19fe..50593ada 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java @@ -514,7 +514,7 @@ public class DepotHeadService { BusinessConstants.SUB_TYPE_PURCHASE_ORDER.equals(depotHead.getSubType())) { DepotHead dh = new DepotHead(); //获取分批操作后单据的商品和商品数量(汇总) - List batchList = depotItemMapperEx.getBatchBillDetailMaterialSum(depotHead.getLinkNumber(), depotHead.getType()); + List batchList = depotItemMapperEx.getBatchBillDetailMaterialSum(depotHead.getLinkNumber(), "normal", depotHead.getType()); if(batchList.size()>0) { dh.setPurchaseStatus(BusinessConstants.PURCHASE_STATUS_SKIPING); } else { @@ -1004,6 +1004,11 @@ public class DepotHeadService { throw new BusinessRunTimeException(ExceptionConstants.DEPOT_HEAD_BILL_NUMBER_EXIST_CODE, String.format(ExceptionConstants.DEPOT_HEAD_BILL_NUMBER_EXIST_MSG)); } + //校验是否同时录入关联请购单号和关联订单号 + if(StringUtil.isNotEmpty(depotHead.getLinkNumber()) && StringUtil.isNotEmpty(depotHead.getLinkApply())) { + throw new BusinessRunTimeException(ExceptionConstants.DEPOT_ITEM_EXIST_REPEAT_NO_FAILED_CODE, + String.format(ExceptionConstants.DEPOT_ITEM_EXIST_REPEAT_NO_FAILED_MSG)); + } String subType = depotHead.getSubType(); //结算账户校验 if("采购".equals(subType) || "采购退货".equals(subType) || "销售".equals(subType) || "销售退货".equals(subType)) { @@ -1100,7 +1105,12 @@ public class DepotHeadService { throw new BusinessRunTimeException(ExceptionConstants.DEPOT_HEAD_BILL_NUMBER_EXIST_CODE, String.format(ExceptionConstants.DEPOT_HEAD_BILL_NUMBER_EXIST_MSG)); } - //校验单据状态,如何不是未审核则提示 + //校验是否同时录入关联请购单号和关联订单号 + if(StringUtil.isNotEmpty(depotHead.getLinkNumber()) && StringUtil.isNotEmpty(depotHead.getLinkApply())) { + throw new BusinessRunTimeException(ExceptionConstants.DEPOT_ITEM_EXIST_REPEAT_NO_FAILED_CODE, + String.format(ExceptionConstants.DEPOT_ITEM_EXIST_REPEAT_NO_FAILED_MSG)); + } + //校验单据状态,如果不是未审核则提示 if(!"0".equals(getDepotHead(depotHead.getId()).getStatus())) { throw new BusinessRunTimeException(ExceptionConstants.DEPOT_HEAD_BILL_CANNOT_EDIT_CODE, String.format(ExceptionConstants.DEPOT_HEAD_BILL_CANNOT_EDIT_MSG)); diff --git a/jshERP-boot/src/main/java/com/jsh/erp/service/depotItem/DepotItemService.java b/jshERP-boot/src/main/java/com/jsh/erp/service/depotItem/DepotItemService.java index 0f1387aa..4f805a97 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/service/depotItem/DepotItemService.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/service/depotItem/DepotItemService.java @@ -691,15 +691,21 @@ public class DepotItemService { || BusinessConstants.SUB_TYPE_OTHER.equals(depotHead.getSubType())) { if(StringUtil.isNotEmpty(depotHead.getLinkNumber())) { //单据状态:是否全部完成 2-全部完成 3-部分完成(针对订单的分批出入库) - String billStatus = getBillStatusByParam(depotHead); - changeBillStatus(depotHead, billStatus); + String billStatus = getBillStatusByParam(depotHead, depotHead.getLinkNumber(), "normal"); + changeBillStatus(depotHead.getLinkNumber(), billStatus); } } - //如果关联单据号非空则更新订单的状态,此处针对销售订单转采购订单的场景 + //当前单据类型为采购订单的逻辑 if(BusinessConstants.SUB_TYPE_PURCHASE_ORDER.equals(depotHead.getSubType())) { + //如果关联单据号非空则更新订单的状态,此处针对销售订单转采购订单的场景 if(StringUtil.isNotEmpty(depotHead.getLinkNumber())) { - String billStatus = getBillStatusByParam(depotHead); - changeBillPurchaseStatus(depotHead, billStatus); + String billStatus = getBillStatusByParam(depotHead, depotHead.getLinkNumber(), "normal"); + changeBillPurchaseStatus(depotHead.getLinkNumber(), billStatus); + } + //如果关联单据号非空则更新订单的状态,此处针对请购单转采购订单的场景 + if(StringUtil.isNotEmpty(depotHead.getLinkApply())) { + String billStatus = getBillStatusByParam(depotHead, depotHead.getLinkApply(), "apply"); + changeBillStatus(depotHead.getLinkApply(), billStatus); } } } else { @@ -711,15 +717,16 @@ public class DepotItemService { * 判断单据的状态 * 通过数组对比:原单据的商品和商品数量(汇总) 与 分批操作后单据的商品和商品数量(汇总) * @param depotHead + * @param linkStr * @return */ @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public String getBillStatusByParam(DepotHead depotHead) { + public String getBillStatusByParam(DepotHead depotHead, String linkStr, String linkType) { String res = BusinessConstants.BILLS_STATUS_SKIPED; //获取原单据的商品和商品数量(汇总) - List linkList = depotItemMapperEx.getLinkBillDetailMaterialSum(depotHead.getLinkNumber()); + List linkList = depotItemMapperEx.getLinkBillDetailMaterialSum(linkStr); //获取分批操作后单据的商品和商品数量(汇总) - List batchList = depotItemMapperEx.getBatchBillDetailMaterialSum(depotHead.getLinkNumber(), depotHead.getType()); + List batchList = depotItemMapperEx.getBatchBillDetailMaterialSum(linkStr, linkType, depotHead.getType()); //将分批操作后的单据的商品和商品数据构造成Map Map materialSumMap = new HashMap<>(); for(DepotItemVo4MaterialAndSum materialAndSum : batchList) { @@ -743,16 +750,16 @@ public class DepotItemService { /** * 更新单据状态 - * @param depotHead + * @param linkStr * @param billStatus */ @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public void changeBillStatus(DepotHead depotHead, String billStatus) { + public void changeBillStatus(String linkStr, String billStatus) { DepotHead depotHeadOrders = new DepotHead(); depotHeadOrders.setStatus(billStatus); DepotHeadExample example = new DepotHeadExample(); - List linkNumberList = StringUtil.strToStringList(depotHead.getLinkNumber()); - example.createCriteria().andNumberIn(linkNumberList); + List linkNoList = StringUtil.strToStringList(linkStr); + example.createCriteria().andNumberIn(linkNoList); try{ depotHeadMapper.updateByExampleSelective(depotHeadOrders, example); }catch(Exception e){ @@ -765,16 +772,16 @@ public class DepotItemService { /** * 更新单据状态,此处针对销售订单转采购订单的场景 - * @param depotHead + * @param linkStr * @param billStatus */ @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public void changeBillPurchaseStatus(DepotHead depotHead, String billStatus) { + public void changeBillPurchaseStatus(String linkStr, String billStatus) { DepotHead depotHeadOrders = new DepotHead(); depotHeadOrders.setPurchaseStatus(billStatus); DepotHeadExample example = new DepotHeadExample(); - List linkNumberList = StringUtil.strToStringList(depotHead.getLinkNumber()); - example.createCriteria().andNumberIn(linkNumberList); + List linkNoList = StringUtil.strToStringList(linkStr); + example.createCriteria().andNumberIn(linkNoList); try{ depotHeadMapper.updateByExampleSelective(depotHeadOrders, example); }catch(Exception e){ @@ -1085,7 +1092,7 @@ public class DepotItemService { Long linkId = id; String goToType = ""; DepotHead depotHead =depotHeadMapper.selectByPrimaryKey(headerId); - String linkNumber = depotHead.getNumber(); //订单号 + String linkStr = depotHead.getNumber(); //订单号 if("purchase".equals(linkType)) { //针对以销定购的情况 if(BusinessConstants.SUB_TYPE_SALES_ORDER.equals(depotHead.getSubType())) { @@ -1117,7 +1124,11 @@ public class DepotItemService { goToType = BusinessConstants.SUB_TYPE_SALES_RETURN; } } - BigDecimal count = depotItemMapperEx.getFinishNumber(meId, linkId, linkNumber, goToType); + String noType = "normal"; + if(linkStr.contains("QGD")) { + noType = "apply"; + } + BigDecimal count = depotItemMapperEx.getFinishNumber(meId, linkId, linkStr, noType, goToType); //根据多单位情况进行数量的转换 if(materialUnit.equals(unitInfo.getOtherUnit()) && unitInfo.getRatio()!=null && unitInfo.getRatio().compareTo(BigDecimal.ZERO)!=0) { count = count.divide(unitInfo.getRatio(),2,BigDecimal.ROUND_HALF_UP); @@ -1146,8 +1157,12 @@ public class DepotItemService { public BigDecimal getRealFinishNumber(String currentSubType, Long meId, Long linkId, Long preHeaderId, Long currentHeaderId, Unit unitInfo, String materialUnit) { String goToType = currentSubType; DepotHead depotHead =depotHeadMapper.selectByPrimaryKey(preHeaderId); - String linkNumber = depotHead.getNumber(); //订单号 - BigDecimal count = depotItemMapperEx.getRealFinishNumber(meId, linkId, linkNumber, currentHeaderId, goToType); + String linkStr = depotHead.getNumber(); //订单号 + String linkType = "normal"; + if(linkStr.contains("QGD")) { + linkType = "apply"; + } + BigDecimal count = depotItemMapperEx.getRealFinishNumber(meId, linkId, linkStr, linkType, currentHeaderId, goToType); //根据多单位情况进行数量的转换 if(materialUnit.equals(unitInfo.getOtherUnit()) && unitInfo.getRatio()!=null && unitInfo.getRatio().compareTo(BigDecimal.ZERO)!=0) { count = count.divide(unitInfo.getRatio(),2,BigDecimal.ROUND_HALF_UP); diff --git a/jshERP-boot/src/main/resources/mapper_xml/DepotHeadMapper.xml b/jshERP-boot/src/main/resources/mapper_xml/DepotHeadMapper.xml index c253ed88..399fb375 100644 --- a/jshERP-boot/src/main/resources/mapper_xml/DepotHeadMapper.xml +++ b/jshERP-boot/src/main/resources/mapper_xml/DepotHeadMapper.xml @@ -31,6 +31,7 @@ + @@ -97,7 +98,7 @@ account_id, change_amount, back_amount, total_price, pay_type, bill_type, remark, file_name, sales_man, account_id_list, account_money_list, discount, discount_money, discount_last_money, other_money, deposit, status, purchase_status, source, link_number, - tenant_id, delete_flag + link_apply, tenant_id, delete_flag select di.material_extend_id, sum(di.oper_number) oper_number from jsh_depot_head dh left join jsh_depot_item di on dh.id=di.header_id and ifnull(di.delete_flag,'0') !='1' - where dh.number=#{linkNumber} + where dh.number=#{linkStr} and ifnull(dh.delete_flag,'0') !='1' group by di.material_extend_id @@ -1025,8 +1035,14 @@