diff --git a/jshERP-boot/docs/jsh_erp.sql b/jshERP-boot/docs/jsh_erp.sql index 632ee4f1..cddcdcf5 100644 --- a/jshERP-boot/docs/jsh_erp.sql +++ b/jshERP-boot/docs/jsh_erp.sql @@ -866,7 +866,11 @@ CREATE TABLE `jsh_unit` ( `name` varchar(50) DEFAULT NULL COMMENT '名称,支持多单位', `basic_unit` varchar(50) DEFAULT NULL COMMENT '基础单位', `other_unit` varchar(50) DEFAULT NULL COMMENT '副单位', + `other_unit_two` varchar(50) DEFAULT NULL COMMENT '副单位2', + `other_unit_three` varchar(50) DEFAULT NULL COMMENT '副单位3', `ratio` int(11) DEFAULT NULL COMMENT '比例', + `ratio_two` int(11) DEFAULT NULL COMMENT '比例2', + `ratio_three` int(11) DEFAULT NULL COMMENT '比例3', `tenant_id` bigint(20) DEFAULT NULL COMMENT '租户id', `delete_flag` varchar(1) DEFAULT '0' COMMENT '删除标记,0未删除,1删除', PRIMARY KEY (`id`) @@ -875,10 +879,10 @@ CREATE TABLE `jsh_unit` ( -- ---------------------------- -- Records of jsh_unit -- ---------------------------- -INSERT INTO `jsh_unit` VALUES ('15', '个,箱(1:12)', '个', '箱', '12', '63', '0'); -INSERT INTO `jsh_unit` VALUES ('19', '个,盒(1:15)', '个', '盒', '15', '63', '0'); -INSERT INTO `jsh_unit` VALUES ('20', '盒,箱(1:8)', '盒', '箱', '8', '63', '0'); -INSERT INTO `jsh_unit` VALUES ('21', '瓶,箱(1:12)', '瓶', '箱', '12', '63', '0'); +INSERT INTO `jsh_unit` VALUES ('15', '个,箱(1:12)', '个', '箱', null, null, '12', null, null, '63', '0'); +INSERT INTO `jsh_unit` VALUES ('19', '个,盒(1:15)', '个', '盒', null, null, '15', null, null, '63', '0'); +INSERT INTO `jsh_unit` VALUES ('20', '盒,箱(1:8)', '盒', '箱', null, null, '8', null, null, '63', '0'); +INSERT INTO `jsh_unit` VALUES ('21', '瓶,箱(1:12)', '瓶', '箱', null, null, '12', null, null, '63', '0'); -- ---------------------------- -- Table structure for jsh_user diff --git a/jshERP-boot/docs/数据库更新记录-首次安装请勿使用.txt b/jshERP-boot/docs/数据库更新记录-首次安装请勿使用.txt index 6eaec235..01a674f0 100644 --- a/jshERP-boot/docs/数据库更新记录-首次安装请勿使用.txt +++ b/jshERP-boot/docs/数据库更新记录-首次安装请勿使用.txt @@ -1297,4 +1297,14 @@ alter table jsh_user_business add tenant_id bigint(20) DEFAULT null COMMENT '租 update jsh_user_business ub left join jsh_user u on ub.key_id=u.id set ub.tenant_id=u.tenant_id where (ub.type='UserRole' or ub.type='UserDepot' or ub.type='UserCustomer') and u.tenant_id!=0; update jsh_user_business ub left join jsh_role r on ub.key_id=r.id set ub.tenant_id=r.tenant_id -where (ub.type='RoleFunctions') and r.tenant_id is not null; \ No newline at end of file +where (ub.type='RoleFunctions') and r.tenant_id is not null; + +-- -------------------------------------------------------- +-- 时间 2021年11月30日 +-- by jishenghua +-- 给计量单位表增加副单位2、副单位3、比例2、比例3 四个字段 +-- -------------------------------------------------------- +alter table jsh_unit add other_unit_two varchar(50) DEFAULT NULL COMMENT '副单位2' after other_unit; +alter table jsh_unit add other_unit_three varchar(50) DEFAULT NULL COMMENT '副单位3' after other_unit_two; +alter table jsh_unit add ratio_two int(11) DEFAULT NULL COMMENT '比例2' after ratio; +alter table jsh_unit add ratio_three int(11) DEFAULT NULL COMMENT '比例3' after ratio_two; \ 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 beb3fb5d..96ec7de2 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 @@ -138,17 +138,10 @@ public class DepotItemController { stock = depotItemService.getSkuStockByParam(depotId,materialVo4Unit.getMeId(),null,null); } else { stock = depotItemService.getStockByParam(depotId,materialVo4Unit.getId(),null,null); - String commodityUnit = materialVo4Unit.getCommodityUnit(); - Long unitId = materialVo4Unit.getUnitId(); - if(unitId!=null) { - Integer ratio = 1; - Unit unit = unitService.getUnit(unitId); - if(commodityUnit.equals(unit.getOtherUnit())){ - ratio = unit.getRatio(); - if(ratio!=0) { - stock = stock.divide(BigDecimal.valueOf(ratio),2,BigDecimal.ROUND_HALF_UP); //两位小数 - } - } + if(materialVo4Unit.getUnitId()!=null) { + Unit unit = unitService.getUnit(materialVo4Unit.getUnitId()); + String commodityUnit = materialVo4Unit.getCommodityUnit(); + stock = unitService.parseStockByUnit(stock, unit, commodityUnit); } } } @@ -197,20 +190,15 @@ public class DepotItemController { item.put("model", diEx.getMModel()); item.put("color", diEx.getMColor()); item.put("materialOther", getOtherInfo(mpArr, diEx)); - Integer ratio = diEx.getRatio(); BigDecimal stock; if(StringUtil.isNotEmpty(diEx.getSku())){ stock = depotItemService.getSkuStockByParam(diEx.getDepotId(),diEx.getMaterialExtendId(),null,null); } else { stock = depotItemService.getStockByParam(diEx.getDepotId(),diEx.getMaterialId(),null,null); - if(ratio!=null){ - BigDecimal ratioDecimal = new BigDecimal(ratio.toString()); - if(ratioDecimal.compareTo(BigDecimal.ZERO)!=0){ - String otherUnit = diEx.getOtherUnit(); - if(otherUnit.equals(diEx.getMaterialUnit())) { - stock = stock.divide(ratioDecimal,2,BigDecimal.ROUND_HALF_UP); //两位小数 - } - } + Unit unitInfo = materialService.findUnit(diEx.getMaterialId()); //查询计量单位信息 + if (StringUtil.isNotEmpty(unitInfo.getName())) { + String materialUnit = diEx.getMaterialUnit(); + stock = unitService.parseStockByUnit(stock, unitInfo, materialUnit); } } item.put("stock", stock); @@ -252,7 +240,6 @@ public class DepotItemController { return res; } - /** * 获取扩展信息 * diff --git a/jshERP-boot/src/main/java/com/jsh/erp/controller/MaterialController.java b/jshERP-boot/src/main/java/com/jsh/erp/controller/MaterialController.java index e2e3bf91..f6bc738e 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/controller/MaterialController.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/controller/MaterialController.java @@ -208,14 +208,11 @@ public class MaterialController { for (MaterialVo4Unit material : dataList) { JSONObject item = new JSONObject(); item.put("id", material.getMeId()); //商品扩展表的id - String ratio; //比例 + String ratioStr; //比例 if (material.getUnitId() == null || material.getUnitId().equals("")) { - ratio = ""; + ratioStr = ""; } else { - ratio = material.getUnitName(); - if(ratio!=null) { - ratio = ratio.substring(ratio.indexOf("(")); - } + ratioStr = "[多单位]"; } item.put("mBarCode", material.getmBarCode()); item.put("name", material.getName()); @@ -223,7 +220,7 @@ public class MaterialController { item.put("standard", material.getStandard()); item.put("model", material.getModel()); item.put("color", material.getColor()); - item.put("unit", material.getCommodityUnit() + ratio); + item.put("unit", material.getCommodityUnit() + ratioStr); item.put("sku", material.getSku()); item.put("enableSerialNumber", material.getEnableSerialNumber()); item.put("enableBatchNumber", material.getEnableBatchNumber()); @@ -234,11 +231,8 @@ public class MaterialController { stock = depotItemService.getStockByParam(depotId,material.getId(),null,null); if (material.getUnitId()!=null){ Unit unit = unitService.getUnit(material.getUnitId()); - if(material.getCommodityUnit().equals(unit.getOtherUnit())) { - if(unit.getRatio()!=0) { - stock = stock.divide(BigDecimal.valueOf(unit.getRatio()),2,BigDecimal.ROUND_HALF_UP); - } - } + String commodityUnit = material.getCommodityUnit(); + stock = unitService.parseStockByUnit(stock, unit, commodityUnit); } } item.put("stock", stock); @@ -578,11 +572,8 @@ public class MaterialController { stock = depotItemService.getStockByParam(mvo.getDepotId(), mvo.getId(), null, null); if (mvo.getUnitId() != null) { Unit unit = unitService.getUnit(mvo.getUnitId()); - if (mvo.getCommodityUnit().equals(unit.getOtherUnit())) { - if (unit.getRatio() != 0) { - stock = stock.divide(BigDecimal.valueOf(unit.getRatio()), 2, BigDecimal.ROUND_HALF_UP); - } - } + String commodityUnit = mvo.getCommodityUnit(); + stock = unitService.parseStockByUnit(stock, unit, commodityUnit); } } mvo.setStock(stock); diff --git a/jshERP-boot/src/main/java/com/jsh/erp/datasource/entities/Unit.java b/jshERP-boot/src/main/java/com/jsh/erp/datasource/entities/Unit.java index f5cc3acd..e5284b5f 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/datasource/entities/Unit.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/datasource/entities/Unit.java @@ -9,8 +9,16 @@ public class Unit { private String otherUnit; + private String otherUnitTwo; + + private String otherUnitThree; + private Integer ratio; + private Integer ratioTwo; + + private Integer ratioThree; + private Long tenantId; private String deleteFlag; @@ -47,6 +55,22 @@ public class Unit { this.otherUnit = otherUnit == null ? null : otherUnit.trim(); } + public String getOtherUnitTwo() { + return otherUnitTwo; + } + + public void setOtherUnitTwo(String otherUnitTwo) { + this.otherUnitTwo = otherUnitTwo == null ? null : otherUnitTwo.trim(); + } + + public String getOtherUnitThree() { + return otherUnitThree; + } + + public void setOtherUnitThree(String otherUnitThree) { + this.otherUnitThree = otherUnitThree == null ? null : otherUnitThree.trim(); + } + public Integer getRatio() { return ratio; } @@ -55,6 +79,22 @@ public class Unit { this.ratio = ratio; } + public Integer getRatioTwo() { + return ratioTwo; + } + + public void setRatioTwo(Integer ratioTwo) { + this.ratioTwo = ratioTwo; + } + + public Integer getRatioThree() { + return ratioThree; + } + + public void setRatioThree(Integer ratioThree) { + this.ratioThree = ratioThree; + } + public Long getTenantId() { return tenantId; } diff --git a/jshERP-boot/src/main/java/com/jsh/erp/datasource/entities/UnitExample.java b/jshERP-boot/src/main/java/com/jsh/erp/datasource/entities/UnitExample.java index eb03bc18..503ae7a8 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/datasource/entities/UnitExample.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/datasource/entities/UnitExample.java @@ -374,6 +374,146 @@ public class UnitExample { return (Criteria) this; } + public Criteria andOtherUnitTwoIsNull() { + addCriterion("other_unit_two is null"); + return (Criteria) this; + } + + public Criteria andOtherUnitTwoIsNotNull() { + addCriterion("other_unit_two is not null"); + return (Criteria) this; + } + + public Criteria andOtherUnitTwoEqualTo(String value) { + addCriterion("other_unit_two =", value, "otherUnitTwo"); + return (Criteria) this; + } + + public Criteria andOtherUnitTwoNotEqualTo(String value) { + addCriterion("other_unit_two <>", value, "otherUnitTwo"); + return (Criteria) this; + } + + public Criteria andOtherUnitTwoGreaterThan(String value) { + addCriterion("other_unit_two >", value, "otherUnitTwo"); + return (Criteria) this; + } + + public Criteria andOtherUnitTwoGreaterThanOrEqualTo(String value) { + addCriterion("other_unit_two >=", value, "otherUnitTwo"); + return (Criteria) this; + } + + public Criteria andOtherUnitTwoLessThan(String value) { + addCriterion("other_unit_two <", value, "otherUnitTwo"); + return (Criteria) this; + } + + public Criteria andOtherUnitTwoLessThanOrEqualTo(String value) { + addCriterion("other_unit_two <=", value, "otherUnitTwo"); + return (Criteria) this; + } + + public Criteria andOtherUnitTwoLike(String value) { + addCriterion("other_unit_two like", value, "otherUnitTwo"); + return (Criteria) this; + } + + public Criteria andOtherUnitTwoNotLike(String value) { + addCriterion("other_unit_two not like", value, "otherUnitTwo"); + return (Criteria) this; + } + + public Criteria andOtherUnitTwoIn(List values) { + addCriterion("other_unit_two in", values, "otherUnitTwo"); + return (Criteria) this; + } + + public Criteria andOtherUnitTwoNotIn(List values) { + addCriterion("other_unit_two not in", values, "otherUnitTwo"); + return (Criteria) this; + } + + public Criteria andOtherUnitTwoBetween(String value1, String value2) { + addCriterion("other_unit_two between", value1, value2, "otherUnitTwo"); + return (Criteria) this; + } + + public Criteria andOtherUnitTwoNotBetween(String value1, String value2) { + addCriterion("other_unit_two not between", value1, value2, "otherUnitTwo"); + return (Criteria) this; + } + + public Criteria andOtherUnitThreeIsNull() { + addCriterion("other_unit_three is null"); + return (Criteria) this; + } + + public Criteria andOtherUnitThreeIsNotNull() { + addCriterion("other_unit_three is not null"); + return (Criteria) this; + } + + public Criteria andOtherUnitThreeEqualTo(String value) { + addCriterion("other_unit_three =", value, "otherUnitThree"); + return (Criteria) this; + } + + public Criteria andOtherUnitThreeNotEqualTo(String value) { + addCriterion("other_unit_three <>", value, "otherUnitThree"); + return (Criteria) this; + } + + public Criteria andOtherUnitThreeGreaterThan(String value) { + addCriterion("other_unit_three >", value, "otherUnitThree"); + return (Criteria) this; + } + + public Criteria andOtherUnitThreeGreaterThanOrEqualTo(String value) { + addCriterion("other_unit_three >=", value, "otherUnitThree"); + return (Criteria) this; + } + + public Criteria andOtherUnitThreeLessThan(String value) { + addCriterion("other_unit_three <", value, "otherUnitThree"); + return (Criteria) this; + } + + public Criteria andOtherUnitThreeLessThanOrEqualTo(String value) { + addCriterion("other_unit_three <=", value, "otherUnitThree"); + return (Criteria) this; + } + + public Criteria andOtherUnitThreeLike(String value) { + addCriterion("other_unit_three like", value, "otherUnitThree"); + return (Criteria) this; + } + + public Criteria andOtherUnitThreeNotLike(String value) { + addCriterion("other_unit_three not like", value, "otherUnitThree"); + return (Criteria) this; + } + + public Criteria andOtherUnitThreeIn(List values) { + addCriterion("other_unit_three in", values, "otherUnitThree"); + return (Criteria) this; + } + + public Criteria andOtherUnitThreeNotIn(List values) { + addCriterion("other_unit_three not in", values, "otherUnitThree"); + return (Criteria) this; + } + + public Criteria andOtherUnitThreeBetween(String value1, String value2) { + addCriterion("other_unit_three between", value1, value2, "otherUnitThree"); + return (Criteria) this; + } + + public Criteria andOtherUnitThreeNotBetween(String value1, String value2) { + addCriterion("other_unit_three not between", value1, value2, "otherUnitThree"); + return (Criteria) this; + } + public Criteria andRatioIsNull() { addCriterion("ratio is null"); return (Criteria) this; @@ -434,6 +574,126 @@ public class UnitExample { return (Criteria) this; } + public Criteria andRatioTwoIsNull() { + addCriterion("ratio_two is null"); + return (Criteria) this; + } + + public Criteria andRatioTwoIsNotNull() { + addCriterion("ratio_two is not null"); + return (Criteria) this; + } + + public Criteria andRatioTwoEqualTo(Integer value) { + addCriterion("ratio_two =", value, "ratioTwo"); + return (Criteria) this; + } + + public Criteria andRatioTwoNotEqualTo(Integer value) { + addCriterion("ratio_two <>", value, "ratioTwo"); + return (Criteria) this; + } + + public Criteria andRatioTwoGreaterThan(Integer value) { + addCriterion("ratio_two >", value, "ratioTwo"); + return (Criteria) this; + } + + public Criteria andRatioTwoGreaterThanOrEqualTo(Integer value) { + addCriterion("ratio_two >=", value, "ratioTwo"); + return (Criteria) this; + } + + public Criteria andRatioTwoLessThan(Integer value) { + addCriterion("ratio_two <", value, "ratioTwo"); + return (Criteria) this; + } + + public Criteria andRatioTwoLessThanOrEqualTo(Integer value) { + addCriterion("ratio_two <=", value, "ratioTwo"); + return (Criteria) this; + } + + public Criteria andRatioTwoIn(List values) { + addCriterion("ratio_two in", values, "ratioTwo"); + return (Criteria) this; + } + + public Criteria andRatioTwoNotIn(List values) { + addCriterion("ratio_two not in", values, "ratioTwo"); + return (Criteria) this; + } + + public Criteria andRatioTwoBetween(Integer value1, Integer value2) { + addCriterion("ratio_two between", value1, value2, "ratioTwo"); + return (Criteria) this; + } + + public Criteria andRatioTwoNotBetween(Integer value1, Integer value2) { + addCriterion("ratio_two not between", value1, value2, "ratioTwo"); + return (Criteria) this; + } + + public Criteria andRatioThreeIsNull() { + addCriterion("ratio_three is null"); + return (Criteria) this; + } + + public Criteria andRatioThreeIsNotNull() { + addCriterion("ratio_three is not null"); + return (Criteria) this; + } + + public Criteria andRatioThreeEqualTo(Integer value) { + addCriterion("ratio_three =", value, "ratioThree"); + return (Criteria) this; + } + + public Criteria andRatioThreeNotEqualTo(Integer value) { + addCriterion("ratio_three <>", value, "ratioThree"); + return (Criteria) this; + } + + public Criteria andRatioThreeGreaterThan(Integer value) { + addCriterion("ratio_three >", value, "ratioThree"); + return (Criteria) this; + } + + public Criteria andRatioThreeGreaterThanOrEqualTo(Integer value) { + addCriterion("ratio_three >=", value, "ratioThree"); + return (Criteria) this; + } + + public Criteria andRatioThreeLessThan(Integer value) { + addCriterion("ratio_three <", value, "ratioThree"); + return (Criteria) this; + } + + public Criteria andRatioThreeLessThanOrEqualTo(Integer value) { + addCriterion("ratio_three <=", value, "ratioThree"); + return (Criteria) this; + } + + public Criteria andRatioThreeIn(List values) { + addCriterion("ratio_three in", values, "ratioThree"); + return (Criteria) this; + } + + public Criteria andRatioThreeNotIn(List values) { + addCriterion("ratio_three not in", values, "ratioThree"); + return (Criteria) this; + } + + public Criteria andRatioThreeBetween(Integer value1, Integer value2) { + addCriterion("ratio_three between", value1, value2, "ratioThree"); + return (Criteria) this; + } + + public Criteria andRatioThreeNotBetween(Integer value1, Integer value2) { + addCriterion("ratio_three not between", value1, value2, "ratioThree"); + 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/service/depotItem/DepotItemService.java b/jshERP-boot/src/main/java/com/jsh/erp/service/depotItem/DepotItemService.java index e662484e..ad0a57b6 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 @@ -382,12 +382,14 @@ public class DepotItemService { Unit unitInfo = materialService.findUnit(materialExtend.getMaterialId()); //查询计量单位信息 if (StringUtil.isNotEmpty(unitInfo.getName())) { String basicUnit = unitInfo.getBasicUnit(); //基本单位 - String otherUnit = unitInfo.getOtherUnit(); //副单位 - Integer ratio = unitInfo.getRatio(); //比例 if (unit.equals(basicUnit)) { //如果等于基础单位 depotItem.setBasicNumber(oNumber); //数量一致 - } else if (unit.equals(otherUnit)) { //如果等于副单位 - depotItem.setBasicNumber(oNumber.multiply(new BigDecimal(ratio)) ); //数量乘以比例 + } else if (unit.equals(unitInfo.getOtherUnit())) { //如果等于副单位 + depotItem.setBasicNumber(oNumber.multiply(new BigDecimal(unitInfo.getRatio())) ); //数量乘以比例 + } else if (unit.equals(unitInfo.getOtherUnitTwo())) { //如果等于副单位2 + depotItem.setBasicNumber(oNumber.multiply(new BigDecimal(unitInfo.getRatioTwo())) ); //数量乘以比例 + } else if (unit.equals(unitInfo.getOtherUnitThree())) { //如果等于副单位3 + depotItem.setBasicNumber(oNumber.multiply(new BigDecimal(unitInfo.getRatioThree())) ); //数量乘以比例 } } else { depotItem.setBasicNumber(oNumber); //其他情况 diff --git a/jshERP-boot/src/main/java/com/jsh/erp/service/unit/UnitService.java b/jshERP-boot/src/main/java/com/jsh/erp/service/unit/UnitService.java index 15b9029e..1682b9a6 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/service/unit/UnitService.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/service/unit/UnitService.java @@ -22,6 +22,7 @@ import org.springframework.web.context.request.ServletRequestAttributes; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -102,7 +103,7 @@ public class UnitService { Unit unit = JSONObject.parseObject(obj.toJSONString(), Unit.class); int result=0; try{ - unit.setName(unit.getBasicUnit() + "," + unit.getOtherUnit() + "(1:" + unit.getRatio() + ")"); + parseNameByUnit(unit); result=unitMapper.insertSelective(unit); logService.insertLog("计量单位", new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(unit.getName()).toString(), request); @@ -117,7 +118,7 @@ public class UnitService { Unit unit = JSONObject.parseObject(obj.toJSONString(), Unit.class); int result=0; try{ - unit.setName(unit.getBasicUnit() + "," + unit.getOtherUnit() + "(1:" + unit.getRatio() + ")"); + parseNameByUnit(unit); result=unitMapper.updateByPrimaryKeySelective(unit); logService.insertLog("计量单位", new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(unit.getName()).toString(), request); @@ -127,6 +128,21 @@ public class UnitService { return result; } + /** + * 根据单位信息生成名称的格式 + * @param unit + */ + private void parseNameByUnit(Unit unit) { + String unitName = unit.getBasicUnit() + "/" + "(" + unit.getOtherUnit() + "=" + unit.getRatio().toString() + unit.getBasicUnit() + ")"; + if(StringUtil.isNotEmpty(unit.getOtherUnitTwo()) && unit.getRatioTwo()!=null) { + unitName += "/" + "(" + unit.getOtherUnitTwo() + "=" + unit.getRatioTwo().toString() + unit.getBasicUnit() + ")"; + if(StringUtil.isNotEmpty(unit.getOtherUnitThree()) && unit.getRatioThree()!=null) { + unitName += "/" + "(" + unit.getOtherUnitThree() + "=" + unit.getRatioThree().toString() + unit.getBasicUnit() + ")"; + } + } + unit.setName(unitName); + } + @Transactional(value = "transactionManager", rollbackFor = Exception.class) public int deleteUnit(Long id, HttpServletRequest request)throws Exception { return batchDeleteUnitByIds(id.toString()); @@ -199,4 +215,24 @@ public class UnitService { } return unitId; } + + /** + * 根据多单位的比例进行库存换算(保留两位小数) + * @param stock + * @param unitInfo + * @param materialUnit + * @return + */ + public BigDecimal parseStockByUnit(BigDecimal stock, Unit unitInfo, String materialUnit) { + if(materialUnit.equals(unitInfo.getOtherUnit()) && unitInfo.getRatio() != 0) { + stock = stock.divide(BigDecimal.valueOf(unitInfo.getRatio()),2,BigDecimal.ROUND_HALF_UP); + } + if(materialUnit.equals(unitInfo.getOtherUnitTwo()) && unitInfo.getRatioTwo() != 0) { + stock = stock.divide(BigDecimal.valueOf(unitInfo.getRatioTwo()),2,BigDecimal.ROUND_HALF_UP); + } + if(materialUnit.equals(unitInfo.getOtherUnitThree()) && unitInfo.getRatioThree() != 0) { + stock = stock.divide(BigDecimal.valueOf(unitInfo.getRatioThree()),2,BigDecimal.ROUND_HALF_UP); + } + return stock; + } } diff --git a/jshERP-boot/src/main/resources/mapper_xml/DepotItemMapperEx.xml b/jshERP-boot/src/main/resources/mapper_xml/DepotItemMapperEx.xml index c655ac8a..2219c6e9 100644 --- a/jshERP-boot/src/main/resources/mapper_xml/DepotItemMapperEx.xml +++ b/jshERP-boot/src/main/resources/mapper_xml/DepotItemMapperEx.xml @@ -32,10 +32,6 @@ - - - - @@ -180,11 +176,10 @@ select @@ -103,11 +108,13 @@ insert into jsh_unit (id, name, basic_unit, - other_unit, ratio, tenant_id, - delete_flag) + other_unit, other_unit_two, other_unit_three, + ratio, ratio_two, ratio_three, + tenant_id, delete_flag) values (#{id,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{basicUnit,jdbcType=VARCHAR}, - #{otherUnit,jdbcType=VARCHAR}, #{ratio,jdbcType=INTEGER}, #{tenantId,jdbcType=BIGINT}, - #{deleteFlag,jdbcType=VARCHAR}) + #{otherUnit,jdbcType=VARCHAR}, #{otherUnitTwo,jdbcType=VARCHAR}, #{otherUnitThree,jdbcType=VARCHAR}, + #{ratio,jdbcType=INTEGER}, #{ratioTwo,jdbcType=INTEGER}, #{ratioThree,jdbcType=INTEGER}, + #{tenantId,jdbcType=BIGINT}, #{deleteFlag,jdbcType=VARCHAR}) insert into jsh_unit @@ -124,9 +131,21 @@ other_unit, + + other_unit_two, + + + other_unit_three, + ratio, + + ratio_two, + + + ratio_three, + tenant_id, @@ -147,9 +166,21 @@ #{otherUnit,jdbcType=VARCHAR}, + + #{otherUnitTwo,jdbcType=VARCHAR}, + + + #{otherUnitThree,jdbcType=VARCHAR}, + #{ratio,jdbcType=INTEGER}, + + #{ratioTwo,jdbcType=INTEGER}, + + + #{ratioThree,jdbcType=INTEGER}, + #{tenantId,jdbcType=BIGINT}, @@ -179,9 +210,21 @@ other_unit = #{record.otherUnit,jdbcType=VARCHAR}, + + other_unit_two = #{record.otherUnitTwo,jdbcType=VARCHAR}, + + + other_unit_three = #{record.otherUnitThree,jdbcType=VARCHAR}, + ratio = #{record.ratio,jdbcType=INTEGER}, + + ratio_two = #{record.ratioTwo,jdbcType=INTEGER}, + + + ratio_three = #{record.ratioThree,jdbcType=INTEGER}, + tenant_id = #{record.tenantId,jdbcType=BIGINT}, @@ -199,7 +242,11 @@ name = #{record.name,jdbcType=VARCHAR}, basic_unit = #{record.basicUnit,jdbcType=VARCHAR}, other_unit = #{record.otherUnit,jdbcType=VARCHAR}, + other_unit_two = #{record.otherUnitTwo,jdbcType=VARCHAR}, + other_unit_three = #{record.otherUnitThree,jdbcType=VARCHAR}, ratio = #{record.ratio,jdbcType=INTEGER}, + ratio_two = #{record.ratioTwo,jdbcType=INTEGER}, + ratio_three = #{record.ratioThree,jdbcType=INTEGER}, tenant_id = #{record.tenantId,jdbcType=BIGINT}, delete_flag = #{record.deleteFlag,jdbcType=VARCHAR} @@ -218,9 +265,21 @@ other_unit = #{otherUnit,jdbcType=VARCHAR}, + + other_unit_two = #{otherUnitTwo,jdbcType=VARCHAR}, + + + other_unit_three = #{otherUnitThree,jdbcType=VARCHAR}, + ratio = #{ratio,jdbcType=INTEGER}, + + ratio_two = #{ratioTwo,jdbcType=INTEGER}, + + + ratio_three = #{ratioThree,jdbcType=INTEGER}, + tenant_id = #{tenantId,jdbcType=BIGINT}, @@ -235,7 +294,11 @@ set name = #{name,jdbcType=VARCHAR}, basic_unit = #{basicUnit,jdbcType=VARCHAR}, other_unit = #{otherUnit,jdbcType=VARCHAR}, + other_unit_two = #{otherUnitTwo,jdbcType=VARCHAR}, + other_unit_three = #{otherUnitThree,jdbcType=VARCHAR}, ratio = #{ratio,jdbcType=INTEGER}, + ratio_two = #{ratioTwo,jdbcType=INTEGER}, + ratio_three = #{ratioThree,jdbcType=INTEGER}, tenant_id = #{tenantId,jdbcType=BIGINT}, delete_flag = #{deleteFlag,jdbcType=VARCHAR} where id = #{id,jdbcType=BIGINT}