给多单位再增加两个副单位

This commit is contained in:
季圣华
2021-12-01 00:58:54 +08:00
parent c0ee413c8f
commit 5df71b26db
11 changed files with 449 additions and 61 deletions

View File

@@ -866,7 +866,11 @@ CREATE TABLE `jsh_unit` (
`name` varchar(50) DEFAULT NULL COMMENT '名称,支持多单位', `name` varchar(50) DEFAULT NULL COMMENT '名称,支持多单位',
`basic_unit` varchar(50) DEFAULT NULL COMMENT '基础单位', `basic_unit` varchar(50) DEFAULT NULL COMMENT '基础单位',
`other_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` 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', `tenant_id` bigint(20) DEFAULT NULL COMMENT '租户id',
`delete_flag` varchar(1) DEFAULT '0' COMMENT '删除标记0未删除1删除', `delete_flag` varchar(1) DEFAULT '0' COMMENT '删除标记0未删除1删除',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
@@ -875,10 +879,10 @@ CREATE TABLE `jsh_unit` (
-- ---------------------------- -- ----------------------------
-- Records of jsh_unit -- Records of jsh_unit
-- ---------------------------- -- ----------------------------
INSERT INTO `jsh_unit` VALUES ('15', '个,箱(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)', '', '', '15', '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)', '', '', '8', '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)', '', '', '12', '63', '0'); INSERT INTO `jsh_unit` VALUES ('21', '瓶,箱(1:12)', '', '', null, null, '12', null, null, '63', '0');
-- ---------------------------- -- ----------------------------
-- Table structure for jsh_user -- Table structure for jsh_user

View File

@@ -1298,3 +1298,13 @@ update jsh_user_business ub left join jsh_user u on ub.key_id=u.id set ub.tenant
where (ub.type='UserRole' or ub.type='UserDepot' or ub.type='UserCustomer') and u.tenant_id!=0; 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 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; 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;

View File

@@ -138,17 +138,10 @@ public class DepotItemController {
stock = depotItemService.getSkuStockByParam(depotId,materialVo4Unit.getMeId(),null,null); stock = depotItemService.getSkuStockByParam(depotId,materialVo4Unit.getMeId(),null,null);
} else { } else {
stock = depotItemService.getStockByParam(depotId,materialVo4Unit.getId(),null,null); stock = depotItemService.getStockByParam(depotId,materialVo4Unit.getId(),null,null);
String commodityUnit = materialVo4Unit.getCommodityUnit(); if(materialVo4Unit.getUnitId()!=null) {
Long unitId = materialVo4Unit.getUnitId(); Unit unit = unitService.getUnit(materialVo4Unit.getUnitId());
if(unitId!=null) { String commodityUnit = materialVo4Unit.getCommodityUnit();
Integer ratio = 1; stock = unitService.parseStockByUnit(stock, unit, commodityUnit);
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); //两位小数
}
}
} }
} }
} }
@@ -197,20 +190,15 @@ public class DepotItemController {
item.put("model", diEx.getMModel()); item.put("model", diEx.getMModel());
item.put("color", diEx.getMColor()); item.put("color", diEx.getMColor());
item.put("materialOther", getOtherInfo(mpArr, diEx)); item.put("materialOther", getOtherInfo(mpArr, diEx));
Integer ratio = diEx.getRatio();
BigDecimal stock; BigDecimal stock;
if(StringUtil.isNotEmpty(diEx.getSku())){ if(StringUtil.isNotEmpty(diEx.getSku())){
stock = depotItemService.getSkuStockByParam(diEx.getDepotId(),diEx.getMaterialExtendId(),null,null); stock = depotItemService.getSkuStockByParam(diEx.getDepotId(),diEx.getMaterialExtendId(),null,null);
} else { } else {
stock = depotItemService.getStockByParam(diEx.getDepotId(),diEx.getMaterialId(),null,null); stock = depotItemService.getStockByParam(diEx.getDepotId(),diEx.getMaterialId(),null,null);
if(ratio!=null){ Unit unitInfo = materialService.findUnit(diEx.getMaterialId()); //查询计量单位信息
BigDecimal ratioDecimal = new BigDecimal(ratio.toString()); if (StringUtil.isNotEmpty(unitInfo.getName())) {
if(ratioDecimal.compareTo(BigDecimal.ZERO)!=0){ String materialUnit = diEx.getMaterialUnit();
String otherUnit = diEx.getOtherUnit(); stock = unitService.parseStockByUnit(stock, unitInfo, materialUnit);
if(otherUnit.equals(diEx.getMaterialUnit())) {
stock = stock.divide(ratioDecimal,2,BigDecimal.ROUND_HALF_UP); //两位小数
}
}
} }
} }
item.put("stock", stock); item.put("stock", stock);
@@ -252,7 +240,6 @@ public class DepotItemController {
return res; return res;
} }
/** /**
* 获取扩展信息 * 获取扩展信息
* *

View File

@@ -208,14 +208,11 @@ public class MaterialController {
for (MaterialVo4Unit material : dataList) { for (MaterialVo4Unit material : dataList) {
JSONObject item = new JSONObject(); JSONObject item = new JSONObject();
item.put("id", material.getMeId()); //商品扩展表的id item.put("id", material.getMeId()); //商品扩展表的id
String ratio; //比例 String ratioStr; //比例
if (material.getUnitId() == null || material.getUnitId().equals("")) { if (material.getUnitId() == null || material.getUnitId().equals("")) {
ratio = ""; ratioStr = "";
} else { } else {
ratio = material.getUnitName(); ratioStr = "[多单位]";
if(ratio!=null) {
ratio = ratio.substring(ratio.indexOf("("));
}
} }
item.put("mBarCode", material.getmBarCode()); item.put("mBarCode", material.getmBarCode());
item.put("name", material.getName()); item.put("name", material.getName());
@@ -223,7 +220,7 @@ public class MaterialController {
item.put("standard", material.getStandard()); item.put("standard", material.getStandard());
item.put("model", material.getModel()); item.put("model", material.getModel());
item.put("color", material.getColor()); item.put("color", material.getColor());
item.put("unit", material.getCommodityUnit() + ratio); item.put("unit", material.getCommodityUnit() + ratioStr);
item.put("sku", material.getSku()); item.put("sku", material.getSku());
item.put("enableSerialNumber", material.getEnableSerialNumber()); item.put("enableSerialNumber", material.getEnableSerialNumber());
item.put("enableBatchNumber", material.getEnableBatchNumber()); item.put("enableBatchNumber", material.getEnableBatchNumber());
@@ -234,11 +231,8 @@ public class MaterialController {
stock = depotItemService.getStockByParam(depotId,material.getId(),null,null); stock = depotItemService.getStockByParam(depotId,material.getId(),null,null);
if (material.getUnitId()!=null){ if (material.getUnitId()!=null){
Unit unit = unitService.getUnit(material.getUnitId()); Unit unit = unitService.getUnit(material.getUnitId());
if(material.getCommodityUnit().equals(unit.getOtherUnit())) { String commodityUnit = material.getCommodityUnit();
if(unit.getRatio()!=0) { stock = unitService.parseStockByUnit(stock, unit, commodityUnit);
stock = stock.divide(BigDecimal.valueOf(unit.getRatio()),2,BigDecimal.ROUND_HALF_UP);
}
}
} }
} }
item.put("stock", stock); item.put("stock", stock);
@@ -578,11 +572,8 @@ public class MaterialController {
stock = depotItemService.getStockByParam(mvo.getDepotId(), mvo.getId(), null, null); stock = depotItemService.getStockByParam(mvo.getDepotId(), mvo.getId(), null, null);
if (mvo.getUnitId() != null) { if (mvo.getUnitId() != null) {
Unit unit = unitService.getUnit(mvo.getUnitId()); Unit unit = unitService.getUnit(mvo.getUnitId());
if (mvo.getCommodityUnit().equals(unit.getOtherUnit())) { String commodityUnit = mvo.getCommodityUnit();
if (unit.getRatio() != 0) { stock = unitService.parseStockByUnit(stock, unit, commodityUnit);
stock = stock.divide(BigDecimal.valueOf(unit.getRatio()), 2, BigDecimal.ROUND_HALF_UP);
}
}
} }
} }
mvo.setStock(stock); mvo.setStock(stock);

View File

@@ -9,8 +9,16 @@ public class Unit {
private String otherUnit; private String otherUnit;
private String otherUnitTwo;
private String otherUnitThree;
private Integer ratio; private Integer ratio;
private Integer ratioTwo;
private Integer ratioThree;
private Long tenantId; private Long tenantId;
private String deleteFlag; private String deleteFlag;
@@ -47,6 +55,22 @@ public class Unit {
this.otherUnit = otherUnit == null ? null : otherUnit.trim(); 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() { public Integer getRatio() {
return ratio; return ratio;
} }
@@ -55,6 +79,22 @@ public class Unit {
this.ratio = ratio; 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() { public Long getTenantId() {
return tenantId; return tenantId;
} }

View File

@@ -374,6 +374,146 @@ public class UnitExample {
return (Criteria) this; 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<String> values) {
addCriterion("other_unit_two in", values, "otherUnitTwo");
return (Criteria) this;
}
public Criteria andOtherUnitTwoNotIn(List<String> 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<String> values) {
addCriterion("other_unit_three in", values, "otherUnitThree");
return (Criteria) this;
}
public Criteria andOtherUnitThreeNotIn(List<String> 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() { public Criteria andRatioIsNull() {
addCriterion("ratio is null"); addCriterion("ratio is null");
return (Criteria) this; return (Criteria) this;
@@ -434,6 +574,126 @@ public class UnitExample {
return (Criteria) this; 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<Integer> values) {
addCriterion("ratio_two in", values, "ratioTwo");
return (Criteria) this;
}
public Criteria andRatioTwoNotIn(List<Integer> 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<Integer> values) {
addCriterion("ratio_three in", values, "ratioThree");
return (Criteria) this;
}
public Criteria andRatioThreeNotIn(List<Integer> 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() { public Criteria andTenantIdIsNull() {
addCriterion("tenant_id is null"); addCriterion("tenant_id is null");
return (Criteria) this; return (Criteria) this;

View File

@@ -382,12 +382,14 @@ public class DepotItemService {
Unit unitInfo = materialService.findUnit(materialExtend.getMaterialId()); //查询计量单位信息 Unit unitInfo = materialService.findUnit(materialExtend.getMaterialId()); //查询计量单位信息
if (StringUtil.isNotEmpty(unitInfo.getName())) { if (StringUtil.isNotEmpty(unitInfo.getName())) {
String basicUnit = unitInfo.getBasicUnit(); //基本单位 String basicUnit = unitInfo.getBasicUnit(); //基本单位
String otherUnit = unitInfo.getOtherUnit(); //副单位
Integer ratio = unitInfo.getRatio(); //比例
if (unit.equals(basicUnit)) { //如果等于基础单位 if (unit.equals(basicUnit)) { //如果等于基础单位
depotItem.setBasicNumber(oNumber); //数量一致 depotItem.setBasicNumber(oNumber); //数量一致
} else if (unit.equals(otherUnit)) { //如果等于副单位 } else if (unit.equals(unitInfo.getOtherUnit())) { //如果等于副单位
depotItem.setBasicNumber(oNumber.multiply(new BigDecimal(ratio)) ); //数量乘以比例 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 { } else {
depotItem.setBasicNumber(oNumber); //其他情况 depotItem.setBasicNumber(oNumber); //其他情况

View File

@@ -22,6 +22,7 @@ import org.springframework.web.context.request.ServletRequestAttributes;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@@ -102,7 +103,7 @@ public class UnitService {
Unit unit = JSONObject.parseObject(obj.toJSONString(), Unit.class); Unit unit = JSONObject.parseObject(obj.toJSONString(), Unit.class);
int result=0; int result=0;
try{ try{
unit.setName(unit.getBasicUnit() + "," + unit.getOtherUnit() + "(1:" + unit.getRatio() + ")"); parseNameByUnit(unit);
result=unitMapper.insertSelective(unit); result=unitMapper.insertSelective(unit);
logService.insertLog("计量单位", logService.insertLog("计量单位",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(unit.getName()).toString(), request); 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); Unit unit = JSONObject.parseObject(obj.toJSONString(), Unit.class);
int result=0; int result=0;
try{ try{
unit.setName(unit.getBasicUnit() + "," + unit.getOtherUnit() + "(1:" + unit.getRatio() + ")"); parseNameByUnit(unit);
result=unitMapper.updateByPrimaryKeySelective(unit); result=unitMapper.updateByPrimaryKeySelective(unit);
logService.insertLog("计量单位", logService.insertLog("计量单位",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(unit.getName()).toString(), request); new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(unit.getName()).toString(), request);
@@ -127,6 +128,21 @@ public class UnitService {
return result; 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) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteUnit(Long id, HttpServletRequest request)throws Exception { public int deleteUnit(Long id, HttpServletRequest request)throws Exception {
return batchDeleteUnitByIds(id.toString()); return batchDeleteUnitByIds(id.toString());
@@ -199,4 +215,24 @@ public class UnitService {
} }
return unitId; 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;
}
} }

View File

@@ -32,10 +32,6 @@
<result column="enable_batch_number" jdbcType="VARCHAR" property="enableBatchNumber" /> <result column="enable_batch_number" jdbcType="VARCHAR" property="enableBatchNumber" />
<result column="DepotName" jdbcType="VARCHAR" property="DepotName" /> <result column="DepotName" jdbcType="VARCHAR" property="DepotName" />
<result column="AnotherDepotName" jdbcType="VARCHAR" property="AnotherDepotName" /> <result column="AnotherDepotName" jdbcType="VARCHAR" property="AnotherDepotName" />
<result column="UnitId" jdbcType="BIGINT" property="UnitId" />
<result column="unit_name" jdbcType="VARCHAR" property="unitName" />
<result column="ratio" jdbcType="INTEGER" property="ratio" />
<result column="other_unit" jdbcType="INTEGER" property="otherUnit" />
<result column="barCode" jdbcType="VARCHAR" property="barCode" /> <result column="barCode" jdbcType="VARCHAR" property="barCode" />
</resultMap> </resultMap>
@@ -180,11 +176,10 @@
<select id="getDetailList" parameterType="com.jsh.erp.datasource.entities.DepotItemExample" resultMap="ResultWithInfoExMap"> <select id="getDetailList" parameterType="com.jsh.erp.datasource.entities.DepotItemExample" resultMap="ResultWithInfoExMap">
select di.*,m.name MName,m.model MModel,m.unit MaterialUnit,m.color MColor,m.standard MStandard,m.mfrs MMfrs, select di.*,m.name MName,m.model MModel,m.unit MaterialUnit,m.color MColor,m.standard MStandard,m.mfrs MMfrs,
m.other_field1 MOtherField1,m.other_field2 MOtherField2,m.other_field3 MOtherField3,m.enable_serial_number, m.enable_batch_number, m.other_field1 MOtherField1,m.other_field2 MOtherField2,m.other_field3 MOtherField3,m.enable_serial_number, m.enable_batch_number,
dp1.name DepotName,dp2.name AnotherDepotName, u.id UnitId, u.name unit_name, u.ratio, u.other_unit, me.bar_code barCode dp1.name DepotName,dp2.name AnotherDepotName, me.bar_code barCode
from jsh_depot_item di from jsh_depot_item di
left join jsh_material m on di.material_id=m.id and ifnull(m.delete_flag,'0') !='1' left join jsh_material m on di.material_id=m.id and ifnull(m.delete_flag,'0') !='1'
left join jsh_material_extend me on me.id=di.material_extend_id and ifnull(me.delete_Flag,'0') !='1' left join jsh_material_extend me on me.id=di.material_extend_id and ifnull(me.delete_Flag,'0') !='1'
left join jsh_unit u on m.unit_id = u.id and ifnull(u.delete_Flag,'0') !='1'
left join jsh_depot dp1 on di.depot_id=dp1.id and ifnull(dp1.delete_Flag,'0') !='1' left join jsh_depot dp1 on di.depot_id=dp1.id and ifnull(dp1.delete_Flag,'0') !='1'
left join jsh_depot dp2 on di.another_depot_id=dp2.id and ifnull(dp2.delete_Flag,'0') !='1' left join jsh_depot dp2 on di.another_depot_id=dp2.id and ifnull(dp2.delete_Flag,'0') !='1'
where di.header_id = #{headerId} where di.header_id = #{headerId}

View File

@@ -143,7 +143,7 @@
</foreach> </foreach>
</if> </if>
and ifnull(m.delete_flag,'0') !='1' and ifnull(m.delete_flag,'0') !='1'
ORDER BY m.id desc,me.default_flag desc ORDER BY m.id desc, me.default_flag desc, me.id asc
<if test="offset != null and rows != null"> <if test="offset != null and rows != null">
limit #{offset},#{rows} limit #{offset},#{rows}
</if> </if>

View File

@@ -6,7 +6,11 @@
<result column="name" jdbcType="VARCHAR" property="name" /> <result column="name" jdbcType="VARCHAR" property="name" />
<result column="basic_unit" jdbcType="VARCHAR" property="basicUnit" /> <result column="basic_unit" jdbcType="VARCHAR" property="basicUnit" />
<result column="other_unit" jdbcType="VARCHAR" property="otherUnit" /> <result column="other_unit" jdbcType="VARCHAR" property="otherUnit" />
<result column="other_unit_two" jdbcType="VARCHAR" property="otherUnitTwo" />
<result column="other_unit_three" jdbcType="VARCHAR" property="otherUnitThree" />
<result column="ratio" jdbcType="INTEGER" property="ratio" /> <result column="ratio" jdbcType="INTEGER" property="ratio" />
<result column="ratio_two" jdbcType="INTEGER" property="ratioTwo" />
<result column="ratio_three" jdbcType="INTEGER" property="ratioThree" />
<result column="tenant_id" jdbcType="BIGINT" property="tenantId" /> <result column="tenant_id" jdbcType="BIGINT" property="tenantId" />
<result column="delete_flag" jdbcType="VARCHAR" property="deleteFlag" /> <result column="delete_flag" jdbcType="VARCHAR" property="deleteFlag" />
</resultMap> </resultMap>
@@ -69,7 +73,8 @@
</where> </where>
</sql> </sql>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, name, basic_unit, other_unit, ratio, tenant_id, delete_flag id, name, basic_unit, other_unit, other_unit_two, other_unit_three, ratio, ratio_two,
ratio_three, tenant_id, delete_flag
</sql> </sql>
<select id="selectByExample" parameterType="com.jsh.erp.datasource.entities.UnitExample" resultMap="BaseResultMap"> <select id="selectByExample" parameterType="com.jsh.erp.datasource.entities.UnitExample" resultMap="BaseResultMap">
select select
@@ -103,11 +108,13 @@
</delete> </delete>
<insert id="insert" parameterType="com.jsh.erp.datasource.entities.Unit"> <insert id="insert" parameterType="com.jsh.erp.datasource.entities.Unit">
insert into jsh_unit (id, name, basic_unit, insert into jsh_unit (id, name, basic_unit,
other_unit, ratio, tenant_id, other_unit, other_unit_two, other_unit_three,
delete_flag) ratio, ratio_two, ratio_three,
tenant_id, delete_flag)
values (#{id,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{basicUnit,jdbcType=VARCHAR}, values (#{id,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{basicUnit,jdbcType=VARCHAR},
#{otherUnit,jdbcType=VARCHAR}, #{ratio,jdbcType=INTEGER}, #{tenantId,jdbcType=BIGINT}, #{otherUnit,jdbcType=VARCHAR}, #{otherUnitTwo,jdbcType=VARCHAR}, #{otherUnitThree,jdbcType=VARCHAR},
#{deleteFlag,jdbcType=VARCHAR}) #{ratio,jdbcType=INTEGER}, #{ratioTwo,jdbcType=INTEGER}, #{ratioThree,jdbcType=INTEGER},
#{tenantId,jdbcType=BIGINT}, #{deleteFlag,jdbcType=VARCHAR})
</insert> </insert>
<insert id="insertSelective" parameterType="com.jsh.erp.datasource.entities.Unit"> <insert id="insertSelective" parameterType="com.jsh.erp.datasource.entities.Unit">
insert into jsh_unit insert into jsh_unit
@@ -124,9 +131,21 @@
<if test="otherUnit != null"> <if test="otherUnit != null">
other_unit, other_unit,
</if> </if>
<if test="otherUnitTwo != null">
other_unit_two,
</if>
<if test="otherUnitThree != null">
other_unit_three,
</if>
<if test="ratio != null"> <if test="ratio != null">
ratio, ratio,
</if> </if>
<if test="ratioTwo != null">
ratio_two,
</if>
<if test="ratioThree != null">
ratio_three,
</if>
<if test="tenantId != null"> <if test="tenantId != null">
tenant_id, tenant_id,
</if> </if>
@@ -147,9 +166,21 @@
<if test="otherUnit != null"> <if test="otherUnit != null">
#{otherUnit,jdbcType=VARCHAR}, #{otherUnit,jdbcType=VARCHAR},
</if> </if>
<if test="otherUnitTwo != null">
#{otherUnitTwo,jdbcType=VARCHAR},
</if>
<if test="otherUnitThree != null">
#{otherUnitThree,jdbcType=VARCHAR},
</if>
<if test="ratio != null"> <if test="ratio != null">
#{ratio,jdbcType=INTEGER}, #{ratio,jdbcType=INTEGER},
</if> </if>
<if test="ratioTwo != null">
#{ratioTwo,jdbcType=INTEGER},
</if>
<if test="ratioThree != null">
#{ratioThree,jdbcType=INTEGER},
</if>
<if test="tenantId != null"> <if test="tenantId != null">
#{tenantId,jdbcType=BIGINT}, #{tenantId,jdbcType=BIGINT},
</if> </if>
@@ -179,9 +210,21 @@
<if test="record.otherUnit != null"> <if test="record.otherUnit != null">
other_unit = #{record.otherUnit,jdbcType=VARCHAR}, other_unit = #{record.otherUnit,jdbcType=VARCHAR},
</if> </if>
<if test="record.otherUnitTwo != null">
other_unit_two = #{record.otherUnitTwo,jdbcType=VARCHAR},
</if>
<if test="record.otherUnitThree != null">
other_unit_three = #{record.otherUnitThree,jdbcType=VARCHAR},
</if>
<if test="record.ratio != null"> <if test="record.ratio != null">
ratio = #{record.ratio,jdbcType=INTEGER}, ratio = #{record.ratio,jdbcType=INTEGER},
</if> </if>
<if test="record.ratioTwo != null">
ratio_two = #{record.ratioTwo,jdbcType=INTEGER},
</if>
<if test="record.ratioThree != null">
ratio_three = #{record.ratioThree,jdbcType=INTEGER},
</if>
<if test="record.tenantId != null"> <if test="record.tenantId != null">
tenant_id = #{record.tenantId,jdbcType=BIGINT}, tenant_id = #{record.tenantId,jdbcType=BIGINT},
</if> </if>
@@ -199,7 +242,11 @@
name = #{record.name,jdbcType=VARCHAR}, name = #{record.name,jdbcType=VARCHAR},
basic_unit = #{record.basicUnit,jdbcType=VARCHAR}, basic_unit = #{record.basicUnit,jdbcType=VARCHAR},
other_unit = #{record.otherUnit,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 = #{record.ratio,jdbcType=INTEGER},
ratio_two = #{record.ratioTwo,jdbcType=INTEGER},
ratio_three = #{record.ratioThree,jdbcType=INTEGER},
tenant_id = #{record.tenantId,jdbcType=BIGINT}, tenant_id = #{record.tenantId,jdbcType=BIGINT},
delete_flag = #{record.deleteFlag,jdbcType=VARCHAR} delete_flag = #{record.deleteFlag,jdbcType=VARCHAR}
<if test="_parameter != null"> <if test="_parameter != null">
@@ -218,9 +265,21 @@
<if test="otherUnit != null"> <if test="otherUnit != null">
other_unit = #{otherUnit,jdbcType=VARCHAR}, other_unit = #{otherUnit,jdbcType=VARCHAR},
</if> </if>
<if test="otherUnitTwo != null">
other_unit_two = #{otherUnitTwo,jdbcType=VARCHAR},
</if>
<if test="otherUnitThree != null">
other_unit_three = #{otherUnitThree,jdbcType=VARCHAR},
</if>
<if test="ratio != null"> <if test="ratio != null">
ratio = #{ratio,jdbcType=INTEGER}, ratio = #{ratio,jdbcType=INTEGER},
</if> </if>
<if test="ratioTwo != null">
ratio_two = #{ratioTwo,jdbcType=INTEGER},
</if>
<if test="ratioThree != null">
ratio_three = #{ratioThree,jdbcType=INTEGER},
</if>
<if test="tenantId != null"> <if test="tenantId != null">
tenant_id = #{tenantId,jdbcType=BIGINT}, tenant_id = #{tenantId,jdbcType=BIGINT},
</if> </if>
@@ -235,7 +294,11 @@
set name = #{name,jdbcType=VARCHAR}, set name = #{name,jdbcType=VARCHAR},
basic_unit = #{basicUnit,jdbcType=VARCHAR}, basic_unit = #{basicUnit,jdbcType=VARCHAR},
other_unit = #{otherUnit,jdbcType=VARCHAR}, other_unit = #{otherUnit,jdbcType=VARCHAR},
other_unit_two = #{otherUnitTwo,jdbcType=VARCHAR},
other_unit_three = #{otherUnitThree,jdbcType=VARCHAR},
ratio = #{ratio,jdbcType=INTEGER}, ratio = #{ratio,jdbcType=INTEGER},
ratio_two = #{ratioTwo,jdbcType=INTEGER},
ratio_three = #{ratioThree,jdbcType=INTEGER},
tenant_id = #{tenantId,jdbcType=BIGINT}, tenant_id = #{tenantId,jdbcType=BIGINT},
delete_flag = #{deleteFlag,jdbcType=VARCHAR} delete_flag = #{deleteFlag,jdbcType=VARCHAR}
where id = #{id,jdbcType=BIGINT} where id = #{id,jdbcType=BIGINT}