diff --git a/jshERP-boot/docs/jsh_erp.sql b/jshERP-boot/docs/jsh_erp.sql index b13400f56..5dd219c1a 100644 --- a/jshERP-boot/docs/jsh_erp.sql +++ b/jshERP-boot/docs/jsh_erp.sql @@ -219,6 +219,7 @@ CREATE TABLE `jsh_depot_item` ( `sn_list` varchar(2000) DEFAULT NULL COMMENT '序列号列表', `batch_number` varchar(100) DEFAULT NULL COMMENT '批号', `expiration_date` datetime DEFAULT NULL COMMENT '有效日期', + `link_id` bigint(20) DEFAULT NULL COMMENT '关联明细id', `tenant_id` bigint(20) DEFAULT NULL COMMENT '租户id', `delete_flag` varchar(1) DEFAULT '0' COMMENT '删除标记,0未删除,1删除', PRIMARY KEY (`id`), @@ -231,24 +232,24 @@ CREATE TABLE `jsh_depot_item` ( -- ---------------------------- -- Records of jsh_depot_item -- ---------------------------- -INSERT INTO `jsh_depot_item` VALUES ('312', '258', '588', '10', '个', null, '10.000000', '10.000000', '11.000000', null, '110.000000', null, '14', null, null, null, null, null, null, null, null, '63', '0'); -INSERT INTO `jsh_depot_item` VALUES ('313', '259', '588', '10', '个', null, '10.000000', '10.000000', '11.000000', null, '110.000000', null, '14', null, null, '0.000000', '110.000000', null, null, null, null, '63', '0'); -INSERT INTO `jsh_depot_item` VALUES ('314', '260', '588', '10', '个', null, '2.000000', '2.000000', '11.000000', '11.000000', '22.000000', null, '14', null, '0.000000', '0.000000', '22.000000', null, null, null, null, '63', '0'); -INSERT INTO `jsh_depot_item` VALUES ('315', '261', '588', '10', '个', null, '2.000000', '2.000000', '22.000000', null, '44.000000', null, '14', null, null, null, null, null, null, null, null, '63', '0'); -INSERT INTO `jsh_depot_item` VALUES ('316', '262', '588', '10', '个', null, '2.000000', '2.000000', '22.000000', null, '44.000000', null, '14', null, null, '0.000000', '44.000000', null, null, null, null, '63', '0'); -INSERT INTO `jsh_depot_item` VALUES ('317', '263', '588', '10', '个', null, '1.000000', '1.000000', '22.000000', '22.000000', '22.000000', null, '14', null, '0.000000', '0.000000', '22.000000', null, null, null, null, '63', '0'); -INSERT INTO `jsh_depot_item` VALUES ('318', '264', '588', '10', '个', null, '1.000000', '1.000000', '22.000000', null, '22.000000', null, '14', null, null, null, null, null, null, null, null, '63', '0'); -INSERT INTO `jsh_depot_item` VALUES ('319', '265', '588', '10', '个', null, '1.000000', '1.000000', '22.000000', null, '22.000000', null, '14', null, null, null, null, null, null, null, null, '63', '0'); -INSERT INTO `jsh_depot_item` VALUES ('320', '266', '568', '2', '个', null, '5.000000', '5.000000', '11.000000', null, '55.000000', null, '14', null, null, null, null, null, null, null, null, '63', '0'); -INSERT INTO `jsh_depot_item` VALUES ('321', '267', '568', '2', '个', null, '2.000000', '2.000000', '15.000000', null, '30.000000', null, '14', null, null, null, null, null, null, null, null, '63', '0'); -INSERT INTO `jsh_depot_item` VALUES ('322', '268', '568', '2', '个', null, '1.000000', '1.000000', '11.000000', null, '11.000000', null, '14', '15', null, null, null, null, null, null, null, '63', '0'); -INSERT INTO `jsh_depot_item` VALUES ('323', '269', '588', '10', '个', null, '1.000000', '1.000000', '0.000000', null, '0.000000', null, '14', null, null, null, null, '组合件', null, null, null, '63', '0'); -INSERT INTO `jsh_depot_item` VALUES ('324', '269', '568', '2', '个', null, '1.000000', '1.000000', '0.000000', null, '0.000000', null, '14', null, null, null, null, '普通子件', null, null, null, '63', '0'); -INSERT INTO `jsh_depot_item` VALUES ('325', '270', '588', '10', '个', null, '1.000000', '1.000000', '0.000000', null, '0.000000', null, '14', null, null, null, null, '组合件', null, null, null, '63', '0'); -INSERT INTO `jsh_depot_item` VALUES ('326', '270', '568', '2', '个', null, '1.000000', '1.000000', '0.000000', null, '0.000000', null, '14', null, null, null, null, '普通子件', null, null, null, '63', '0'); -INSERT INTO `jsh_depot_item` VALUES ('327', '271', '570', '4', '个', null, '10.000000', '10.000000', '8.000000', '8.000000', '80.000000', null, '14', null, '0.000000', '0.000000', '80.000000', null, null, null, null, '63', '0'); -INSERT INTO `jsh_depot_item` VALUES ('328', '272', '570', '4', '个', null, '2.000000', '2.000000', '14.000000', '14.000000', '28.000000', null, '14', null, '0.000000', '0.000000', '28.000000', null, null, null, null, '63', '0'); -INSERT INTO `jsh_depot_item` VALUES ('330', '273', '619', '37', '件', '橙色,L', '5.000000', '5.000000', '12.000000', '12.000000', '60.000000', null, '14', null, '0.000000', '0.000000', '60.000000', null, null, null, null, '63', '0'); +INSERT INTO `jsh_depot_item` VALUES ('312', '258', '588', '10', '个', null, '10.000000', '10.000000', '11.000000', null, '110.000000', null, '14', null, null, null, null, null, null, null, null, null, '63', '0'); +INSERT INTO `jsh_depot_item` VALUES ('313', '259', '588', '10', '个', null, '10.000000', '10.000000', '11.000000', null, '110.000000', null, '14', null, null, '0.000000', '110.000000', null, null, null, null, null, '63', '0'); +INSERT INTO `jsh_depot_item` VALUES ('314', '260', '588', '10', '个', null, '2.000000', '2.000000', '11.000000', '11.000000', '22.000000', null, '14', null, '0.000000', '0.000000', '22.000000', null, null, null, null, null, '63', '0'); +INSERT INTO `jsh_depot_item` VALUES ('315', '261', '588', '10', '个', null, '2.000000', '2.000000', '22.000000', null, '44.000000', null, '14', null, null, null, null, null, null, null, null, null, '63', '0'); +INSERT INTO `jsh_depot_item` VALUES ('316', '262', '588', '10', '个', null, '2.000000', '2.000000', '22.000000', null, '44.000000', null, '14', null, null, '0.000000', '44.000000', null, null, null, null, null, '63', '0'); +INSERT INTO `jsh_depot_item` VALUES ('317', '263', '588', '10', '个', null, '1.000000', '1.000000', '22.000000', '22.000000', '22.000000', null, '14', null, '0.000000', '0.000000', '22.000000', null, null, null, null, null, '63', '0'); +INSERT INTO `jsh_depot_item` VALUES ('318', '264', '588', '10', '个', null, '1.000000', '1.000000', '22.000000', null, '22.000000', null, '14', null, null, null, null, null, null, null, null, null, '63', '0'); +INSERT INTO `jsh_depot_item` VALUES ('319', '265', '588', '10', '个', null, '1.000000', '1.000000', '22.000000', null, '22.000000', null, '14', null, null, null, null, null, null, null, null, null, '63', '0'); +INSERT INTO `jsh_depot_item` VALUES ('320', '266', '568', '2', '个', null, '5.000000', '5.000000', '11.000000', null, '55.000000', null, '14', null, null, null, null, null, null, null, null, null, '63', '0'); +INSERT INTO `jsh_depot_item` VALUES ('321', '267', '568', '2', '个', null, '2.000000', '2.000000', '15.000000', null, '30.000000', null, '14', null, null, null, null, null, null, null, null, null, '63', '0'); +INSERT INTO `jsh_depot_item` VALUES ('322', '268', '568', '2', '个', null, '1.000000', '1.000000', '11.000000', null, '11.000000', null, '14', '15', null, null, null, null, null, null, null, null, '63', '0'); +INSERT INTO `jsh_depot_item` VALUES ('323', '269', '588', '10', '个', null, '1.000000', '1.000000', '0.000000', null, '0.000000', null, '14', null, null, null, null, '组合件', null, null, null, null, '63', '0'); +INSERT INTO `jsh_depot_item` VALUES ('324', '269', '568', '2', '个', null, '1.000000', '1.000000', '0.000000', null, '0.000000', null, '14', null, null, null, null, '普通子件', null, null, null, null, '63', '0'); +INSERT INTO `jsh_depot_item` VALUES ('325', '270', '588', '10', '个', null, '1.000000', '1.000000', '0.000000', null, '0.000000', null, '14', null, null, null, null, '组合件', null, null, null, null, '63', '0'); +INSERT INTO `jsh_depot_item` VALUES ('326', '270', '568', '2', '个', null, '1.000000', '1.000000', '0.000000', null, '0.000000', null, '14', null, null, null, null, '普通子件', null, null, null, null, '63', '0'); +INSERT INTO `jsh_depot_item` VALUES ('327', '271', '570', '4', '个', null, '10.000000', '10.000000', '8.000000', '8.000000', '80.000000', null, '14', null, '0.000000', '0.000000', '80.000000', null, null, null, null, null, '63', '0'); +INSERT INTO `jsh_depot_item` VALUES ('328', '272', '570', '4', '个', null, '2.000000', '2.000000', '14.000000', '14.000000', '28.000000', null, '14', null, '0.000000', '0.000000', '28.000000', null, null, null, null, null, '63', '0'); +INSERT INTO `jsh_depot_item` VALUES ('330', '273', '619', '37', '件', '橙色,L', '5.000000', '5.000000', '12.000000', '12.000000', '60.000000', null, '14', null, '0.000000', '0.000000', '60.000000', null, null, null, null, null, '63', '0'); -- ---------------------------- -- Table structure for jsh_function diff --git a/jshERP-boot/docs/数据库更新记录-首次安装请勿使用.txt b/jshERP-boot/docs/数据库更新记录-首次安装请勿使用.txt index 48c3180e3..300533d52 100644 --- a/jshERP-boot/docs/数据库更新记录-首次安装请勿使用.txt +++ b/jshERP-boot/docs/数据库更新记录-首次安装请勿使用.txt @@ -1353,4 +1353,11 @@ alter table jsh_system_config add sale_agreement varchar(500) DEFAULT NULL COMME -- -------------------------------------------------------- alter table jsh_depot_head add purchase_status varchar(1) DEFAULT NULL COMMENT '采购状态,0未采购、2完成采购、3部分采购' after status; alter table jsh_system_config add purchase_by_sale_flag varchar(1) DEFAULT '0' COMMENT '以销定购启用标记,0未启用,1启用' after minus_stock_flag; -update jsh_depot_head set purchase_status='0'; \ No newline at end of file +update jsh_depot_head set purchase_status='0'; + +-- -------------------------------------------------------- +-- 时间 2022年05月28日 +-- by jishenghua +-- 给单据子表增加关联明细id +-- -------------------------------------------------------- +alter table jsh_depot_item add link_id bigint(20) DEFAULT NULL COMMENT '关联明细id' after expiration_date; \ No newline at end of file diff --git a/jshERP-boot/src/main/java/com/jsh/erp/controller/DepotItemController.java b/jshERP-boot/src/main/java/com/jsh/erp/controller/DepotItemController.java index dfc330f3e..f3e743f84 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/controller/DepotItemController.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/controller/DepotItemController.java @@ -207,12 +207,13 @@ public class DepotItemController { item.put("operNumber", diEx.getOperNumber()); item.put("basicNumber", diEx.getBasicNumber()); item.put("preNumber", diEx.getOperNumber()); //原数量 - item.put("finishNumber", depotItemService.getFinishNumber(diEx.getMaterialExtendId(), diEx.getHeaderId(), unitInfo, materialUnit, linkType)); //已入库|已出库 + item.put("finishNumber", depotItemService.getFinishNumber(diEx.getMaterialExtendId(), diEx.getId(), diEx.getHeaderId(), unitInfo, materialUnit, linkType)); //已入库|已出库 item.put("purchaseDecimal", diEx.getPurchaseDecimal()); //采购价 item.put("unitPrice", diEx.getUnitPrice()); item.put("taxUnitPrice", diEx.getTaxUnitPrice()); item.put("allPrice", diEx.getAllPrice()); item.put("remark", diEx.getRemark()); + item.put("linkId", diEx.getLinkId()); item.put("depotId", diEx.getDepotId() == null ? "" : diEx.getDepotId()); item.put("depotName", diEx.getDepotId() == null ? "" : diEx.getDepotName()); item.put("anotherDepotId", diEx.getAnotherDepotId() == null ? "" : diEx.getAnotherDepotId()); diff --git a/jshERP-boot/src/main/java/com/jsh/erp/datasource/entities/DepotItem.java b/jshERP-boot/src/main/java/com/jsh/erp/datasource/entities/DepotItem.java index 32d7530f2..21cccfc29 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/datasource/entities/DepotItem.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/datasource/entities/DepotItem.java @@ -46,6 +46,8 @@ public class DepotItem { private Date expirationDate; + private Long linkId; + private Long tenantId; private String deleteFlag; @@ -218,6 +220,14 @@ public class DepotItem { this.expirationDate = expirationDate; } + public Long getLinkId() { + return linkId; + } + + public void setLinkId(Long linkId) { + this.linkId = linkId; + } + public Long getTenantId() { return tenantId; } diff --git a/jshERP-boot/src/main/java/com/jsh/erp/datasource/entities/DepotItemExample.java b/jshERP-boot/src/main/java/com/jsh/erp/datasource/entities/DepotItemExample.java index d9aa74dc7..357c71a37 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/datasource/entities/DepotItemExample.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/datasource/entities/DepotItemExample.java @@ -1426,6 +1426,66 @@ public class DepotItemExample { return (Criteria) this; } + public Criteria andLinkIdIsNull() { + addCriterion("link_id is null"); + return (Criteria) this; + } + + public Criteria andLinkIdIsNotNull() { + addCriterion("link_id is not null"); + return (Criteria) this; + } + + public Criteria andLinkIdEqualTo(Long value) { + addCriterion("link_id =", value, "linkId"); + return (Criteria) this; + } + + public Criteria andLinkIdNotEqualTo(Long value) { + addCriterion("link_id <>", value, "linkId"); + return (Criteria) this; + } + + public Criteria andLinkIdGreaterThan(Long value) { + addCriterion("link_id >", value, "linkId"); + return (Criteria) this; + } + + public Criteria andLinkIdGreaterThanOrEqualTo(Long value) { + addCriterion("link_id >=", value, "linkId"); + return (Criteria) this; + } + + public Criteria andLinkIdLessThan(Long value) { + addCriterion("link_id <", value, "linkId"); + return (Criteria) this; + } + + public Criteria andLinkIdLessThanOrEqualTo(Long value) { + addCriterion("link_id <=", value, "linkId"); + return (Criteria) this; + } + + public Criteria andLinkIdIn(List values) { + addCriterion("link_id in", values, "linkId"); + return (Criteria) this; + } + + public Criteria andLinkIdNotIn(List values) { + addCriterion("link_id not in", values, "linkId"); + return (Criteria) this; + } + + public Criteria andLinkIdBetween(Long value1, Long value2) { + addCriterion("link_id between", value1, value2, "linkId"); + return (Criteria) this; + } + + public Criteria andLinkIdNotBetween(Long value1, Long value2) { + addCriterion("link_id not between", value1, value2, "linkId"); + 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 e5830bd2a..6a619df70 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 @@ -143,11 +143,13 @@ public interface DepotItemMapperEx { BigDecimal getFinishNumber( @Param("meId") Long meId, + @Param("linkId") Long linkId, @Param("linkNumber") String linkNumber, @Param("goToType") String goToType); BigDecimal getRealFinishNumber( @Param("meId") Long meId, + @Param("linkId") Long linkId, @Param("linkNumber") String linkNumber, @Param("currentHeaderId") Long currentHeaderId, @Param("goToType") String goToType); 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 1db376975..95e339764 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 @@ -259,12 +259,12 @@ public class DepotItemService { * @return * @throws Exception */ - public DepotItem getPreItemByHeaderIdAndMaterial(String linkNumber, Long meId)throws Exception { + public DepotItem getPreItemByHeaderIdAndMaterial(String linkNumber, Long meId, Long linkId)throws Exception { DepotItem depotItem = new DepotItem(); try{ DepotHead depotHead = depotHeadService.getDepotHead(linkNumber); DepotItemExample example = new DepotItemExample(); - example.createCriteria().andHeaderIdEqualTo(depotHead.getId()).andMaterialExtendIdEqualTo(meId).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); + example.createCriteria().andHeaderIdEqualTo(depotHead.getId()).andMaterialExtendIdEqualTo(meId).andIdEqualTo(linkId).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); List list = depotItemMapper.selectByExample(example); if(list!=null && list.size()>0) { depotItem = list.get(0); @@ -430,6 +430,9 @@ public class DepotItemService { if (StringUtil.isExist(rowObj.get("sku"))) { depotItem.setSku(rowObj.getString("sku")); } + if (StringUtil.isExist(rowObj.get("linkId"))) { + depotItem.setLinkId(rowObj.getLong("linkId")); + } //以下进行单位换算 Unit unitInfo = materialService.findUnit(materialExtend.getMaterialId()); //查询计量单位信息 if (StringUtil.isExist(rowObj.get("operNumber"))) { @@ -467,9 +470,9 @@ public class DepotItemService { String unit = rowObj.get("unit").toString(); Long preHeaderId = depotHeadService.getDepotHead(depotHead.getLinkNumber()).getId(); //前一个单据的数量 - BigDecimal preNumber = getPreItemByHeaderIdAndMaterial(depotHead.getLinkNumber(), depotItem.getMaterialExtendId()).getOperNumber(); + BigDecimal preNumber = getPreItemByHeaderIdAndMaterial(depotHead.getLinkNumber(), depotItem.getMaterialExtendId(), depotItem.getLinkId()).getOperNumber(); //除去此单据之外的已入库|已出库 - BigDecimal realFinishNumber = getRealFinishNumber(depotItem.getMaterialExtendId(), preHeaderId, headerId, unitInfo, unit); + BigDecimal realFinishNumber = getRealFinishNumber(depotItem.getMaterialExtendId(), depotItem.getLinkId(), preHeaderId, headerId, unitInfo, unit); if(depotItem.getOperNumber().add(realFinishNumber).compareTo(preNumber)>0) { throw new BusinessRunTimeException(ExceptionConstants.DEPOT_HEAD_NUMBER_NEED_EDIT_FAILED_CODE, String.format(ExceptionConstants.DEPOT_HEAD_NUMBER_NEED_EDIT_FAILED_MSG, barCode)); @@ -853,7 +856,8 @@ public class DepotItemService { } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public BigDecimal getFinishNumber(Long meId, Long headerId, Unit unitInfo, String materialUnit, String linkType) { + public BigDecimal getFinishNumber(Long meId, Long id, Long headerId, Unit unitInfo, String materialUnit, String linkType) { + Long linkId = id; String goToType = ""; DepotHead depotHead =depotHeadMapper.selectByPrimaryKey(headerId); String linkNumber = depotHead.getNumber(); //订单号 @@ -869,7 +873,7 @@ public class DepotItemService { goToType = BusinessConstants.SUB_TYPE_SALES; } } - BigDecimal count = depotItemMapperEx.getFinishNumber(meId, linkNumber, goToType); + BigDecimal count = depotItemMapperEx.getFinishNumber(meId, linkId, linkNumber, goToType); //根据多单位情况进行数量的转换 if(materialUnit.equals(unitInfo.getOtherUnit()) && unitInfo.getRatio() != 0) { count = count.divide(BigDecimal.valueOf(unitInfo.getRatio()),2,BigDecimal.ROUND_HALF_UP); @@ -886,6 +890,7 @@ public class DepotItemService { /** * 除去此单据之外的已入库|已出库 * @param meId + * @param linkId * @param preHeaderId * @param currentHeaderId * @param unitInfo @@ -893,7 +898,7 @@ public class DepotItemService { * @return */ @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public BigDecimal getRealFinishNumber(Long meId, Long preHeaderId, Long currentHeaderId, Unit unitInfo, String materialUnit) { + public BigDecimal getRealFinishNumber(Long meId, Long linkId, Long preHeaderId, Long currentHeaderId, Unit unitInfo, String materialUnit) { String goToType = ""; DepotHead depotHead =depotHeadMapper.selectByPrimaryKey(preHeaderId); String linkNumber = depotHead.getNumber(); //订单号 @@ -903,7 +908,7 @@ public class DepotItemService { if(BusinessConstants.SUB_TYPE_SALES_ORDER.equals(depotHead.getSubType())) { goToType = BusinessConstants.SUB_TYPE_SALES; } - BigDecimal count = depotItemMapperEx.getRealFinishNumber(meId, linkNumber, currentHeaderId, goToType); + BigDecimal count = depotItemMapperEx.getRealFinishNumber(meId, linkId, linkNumber, currentHeaderId, goToType); //根据多单位情况进行数量的转换 if(materialUnit.equals(unitInfo.getOtherUnit()) && unitInfo.getRatio() != 0) { count = count.divide(BigDecimal.valueOf(unitInfo.getRatio()),2,BigDecimal.ROUND_HALF_UP); diff --git a/jshERP-boot/src/main/resources/mapper_xml/DepotItemMapper.xml b/jshERP-boot/src/main/resources/mapper_xml/DepotItemMapper.xml index 2223a93c7..28748d35f 100644 --- a/jshERP-boot/src/main/resources/mapper_xml/DepotItemMapper.xml +++ b/jshERP-boot/src/main/resources/mapper_xml/DepotItemMapper.xml @@ -23,6 +23,7 @@ + @@ -88,7 +89,7 @@ id, header_id, material_id, material_extend_id, material_unit, sku, oper_number, basic_number, unit_price, tax_unit_price, all_price, remark, depot_id, another_depot_id, tax_rate, tax_money, tax_last_money, material_type, sn_list, batch_number, expiration_date, - tenant_id, delete_flag + link_id, tenant_id, delete_flag select ifnull(sum(di.basic_number),0) from jsh_depot_item di where di.material_extend_id=#{meId} + and di.link_id=#{linkId} and ifnull(di.delete_flag,'0') !='1' and di.header_id in @@ -615,6 +616,7 @@