优化安全库存,调整为每个仓库的安全库存

This commit is contained in:
季圣华
2021-10-29 19:52:20 +08:00
parent 8f30705c79
commit 72e3e31c4a
13 changed files with 383 additions and 149 deletions

View File

@@ -10,7 +10,7 @@ Target Server Type : MYSQL
Target Server Version : 50704
File Encoding : 65001
Date: 2021-09-28 00:32:28
Date: 2021-10-29 18:44:03
*/
SET FOREIGN_KEY_CHECKS=0;
@@ -386,7 +386,6 @@ CREATE TABLE `jsh_material` (
`category_id` bigint(20) DEFAULT NULL COMMENT '产品类型id',
`name` varchar(50) DEFAULT NULL COMMENT '名称',
`mfrs` varchar(50) DEFAULT NULL COMMENT '制造商',
`safety_stock` decimal(24,6) DEFAULT NULL COMMENT '安全存量KG',
`model` varchar(50) DEFAULT NULL COMMENT '型号',
`standard` varchar(50) DEFAULT NULL COMMENT '规格',
`color` varchar(50) DEFAULT NULL COMMENT '颜色',
@@ -395,6 +394,7 @@ CREATE TABLE `jsh_material` (
`img_name` varchar(500) DEFAULT NULL COMMENT '图片名称',
`unit_id` bigint(20) DEFAULT NULL COMMENT '计量单位Id',
`expiry_num` int(10) DEFAULT NULL COMMENT '保质期天数',
`weight` decimal(24,6) DEFAULT NULL COMMENT '基础重量(kg)',
`enabled` bit(1) DEFAULT NULL COMMENT '启用 0-禁用 1-启用',
`other_field1` varchar(50) DEFAULT NULL COMMENT '自定义1',
`other_field2` varchar(50) DEFAULT NULL COMMENT '自定义2',
@@ -411,15 +411,15 @@ CREATE TABLE `jsh_material` (
-- ----------------------------
-- Records of jsh_material
-- ----------------------------
INSERT INTO `jsh_material` VALUES ('568', '17', '商品1', '制1', '100.000000', 'sp1', '', '', '', '', null, null, null, '', '', '', '', '0', '0', '63', '0');
INSERT INTO `jsh_material` VALUES ('569', '17', '商品2', '', '200.000000', 'sp2', '', '', '', '', null, null, null, '', '', '', '', '0', '0', '63', '0');
INSERT INTO `jsh_material` VALUES ('570', '17', '商品3', '', '300.000000', 'sp3', '', '', '', '', null, null, null, '', '', '', '', '0', '0', '63', '0');
INSERT INTO `jsh_material` VALUES ('577', null, '商品8', '', null, 'sp8', '', '', '', '', null, '15', null, '', '', '', '', '0', '0', '63', '0');
INSERT INTO `jsh_material` VALUES ('579', '21', '商品17', '', null, 'sp17', '', '', '', '', null, '15', null, '', '', '', '', '0', '0', '63', '0');
INSERT INTO `jsh_material` VALUES ('586', '17', '序列号商品测试', '', null, 'xlh123', '', '', '', '', null, null, null, '', '', '', '', '1', '0', '63', '0');
INSERT INTO `jsh_material` VALUES ('587', '17', '商品test1', '南通中远', null, '', 'test1', '', '', '', null, null, null, '', '', '', '', '0', '0', '63', '0');
INSERT INTO `jsh_material` VALUES ('588', '21', '商品200', 'fafda', '112.000000', 'weqwe', '300ml', '红色', '', 'aaaabbbbb', null, null, null, '', '', '', '', '0', '0', '63', '0');
INSERT INTO `jsh_material` VALUES ('619', null, '衣服', null, null, null, null, null, '', null, '', null, null, '', null, null, null, '0', '0', '63', '0');
INSERT INTO `jsh_material` VALUES ('568', '17', '商品1', '制1', 'sp1', '', '', '', '', null, null, null, null, '', '', '', '', '0', '0', '63', '0');
INSERT INTO `jsh_material` VALUES ('569', '17', '商品2', '', 'sp2', '', '', '', '', null, null, null, null, '', '', '', '', '0', '0', '63', '0');
INSERT INTO `jsh_material` VALUES ('570', '17', '商品3', '', 'sp3', '', '', '', '', null, null, null, null, '', '', '', '', '0', '0', '63', '0');
INSERT INTO `jsh_material` VALUES ('577', null, '商品8', '', 'sp8', '', '', '', '', null, '15', null, null, '', '', '', '', '0', '0', '63', '0');
INSERT INTO `jsh_material` VALUES ('579', '21', '商品17', '', 'sp17', '', '', '', '', null, '15', null, null, '', '', '', '', '0', '0', '63', '0');
INSERT INTO `jsh_material` VALUES ('586', '17', '序列号商品测试', '', 'xlh123', '', '', '', '', null, null, null, null, '', '', '', '', '1', '0', '63', '0');
INSERT INTO `jsh_material` VALUES ('587', '17', '商品test1', '南通中远', '', 'test1', '', '', '', null, null, null, null, '', '', '', '', '0', '0', '63', '0');
INSERT INTO `jsh_material` VALUES ('588', '21', '商品200', 'fafda', 'weqwe', '300ml', '红色', '', 'aaaabbbbb', null, null, null, null, '', '', '', '', '0', '0', '63', '0');
INSERT INTO `jsh_material` VALUES ('619', null, '衣服', null, null, null, null, '', null, '', null, null, null, '', null, null, null, '0', '0', '63', '0');
-- ----------------------------
-- Table structure for jsh_material_attribute
@@ -546,6 +546,8 @@ CREATE TABLE `jsh_material_initial_stock` (
`material_id` bigint(20) DEFAULT NULL COMMENT '产品id',
`depot_id` bigint(20) DEFAULT NULL COMMENT '仓库id',
`number` decimal(24,6) DEFAULT NULL COMMENT '初始库存数量',
`low_safe_stock` decimal(24,6) DEFAULT NULL COMMENT '最低库存数量',
`high_safe_stock` decimal(24,6) DEFAULT NULL COMMENT '最高库存数量',
`tenant_id` bigint(20) DEFAULT NULL COMMENT '租户id',
`delete_flag` varchar(1) DEFAULT '0' COMMENT '删除标记0未删除1删除',
PRIMARY KEY (`id`)
@@ -742,21 +744,21 @@ INSERT INTO `jsh_sequence` VALUES ('depot_number_seq', '1', '999999999999999999'
-- ----------------------------
DROP TABLE IF EXISTS `jsh_serial_number`;
CREATE TABLE `jsh_serial_number` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`material_id` bigint(20) DEFAULT NULL COMMENT '产品表id',
`depot_id` bigint(20) DEFAULT NULL COMMENT '仓库id',
`serial_number` varchar(64) DEFAULT NULL COMMENT '序列号',
`is_sell` varchar(1) DEFAULT '0' COMMENT '是否卖出0未卖出1卖出',
`remark` varchar(1024) DEFAULT NULL COMMENT '备注',
`delete_flag` varchar(1) DEFAULT '0' COMMENT '删除标记0未删除1删除',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`creator` bigint(20) DEFAULT NULL COMMENT '创建人',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
`updater` bigint(20) DEFAULT NULL COMMENT '更新人',
`in_bill_no` varchar(50) DEFAULT NULL COMMENT '入库单号',
`out_bill_no` varchar(50) DEFAULT NULL COMMENT '出库单号',
`tenant_id` bigint(20) DEFAULT NULL COMMENT '租户id',
PRIMARY KEY (`id`)
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`material_id` bigint(20) DEFAULT NULL COMMENT '产品表id',
`depot_id` bigint(20) DEFAULT NULL COMMENT '仓库id',
`serial_number` varchar(64) DEFAULT NULL COMMENT '序列号',
`is_sell` varchar(1) DEFAULT '0' COMMENT '是否卖出0未卖出1卖出',
`remark` varchar(1024) DEFAULT NULL COMMENT '备注',
`delete_flag` varchar(1) DEFAULT '0' COMMENT '删除标记0未删除1删除',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`creator` bigint(20) DEFAULT NULL COMMENT '创建人',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
`updater` bigint(20) DEFAULT NULL COMMENT '更新人',
`in_bill_no` varchar(50) DEFAULT NULL COMMENT '入库单号',
`out_bill_no` varchar(50) DEFAULT NULL COMMENT '出库单号',
`tenant_id` bigint(20) DEFAULT NULL COMMENT '租户id',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=110 DEFAULT CHARSET=utf8 COMMENT='序列号表';
-- ----------------------------

View File

@@ -1273,4 +1273,16 @@ delete from jsh_function where number='010104';
-- by jishenghua
-- 给租户表增加备注字段
-- --------------------------------------------------------
alter table jsh_tenant add remark varchar(500) DEFAULT NULL COMMENT '备注' after expire_time;
alter table jsh_tenant add remark varchar(500) DEFAULT NULL COMMENT '备注' after expire_time;
-- --------------------------------------------------------
-- 时间 2021年10月29日
-- by jishenghua
-- 给商品初始库存表增加最低库存数量、最高库存数量字段
-- 给商品表增加基础重量字段
-- 给商品表移除安全库存字段
-- --------------------------------------------------------
alter table jsh_material_initial_stock add low_safe_stock decimal(24,6) DEFAULT NULL COMMENT '最低库存数量' after number;
alter table jsh_material_initial_stock add high_safe_stock decimal(24,6) DEFAULT NULL COMMENT '最高库存数量' after low_safe_stock;
alter table jsh_material add weight decimal(24,6) DEFAULT NULL COMMENT '基础重量(kg)' after expiry_num;
alter table jsh_material drop column safety_stock;

View File

@@ -6,6 +6,8 @@ import com.jsh.erp.constants.BusinessConstants;
import com.jsh.erp.constants.ExceptionConstants;
import com.jsh.erp.datasource.entities.Depot;
import com.jsh.erp.datasource.entities.DepotEx;
import com.jsh.erp.datasource.entities.MaterialCurrentStock;
import com.jsh.erp.datasource.entities.MaterialInitialStock;
import com.jsh.erp.exception.BusinessRunTimeException;
import com.jsh.erp.service.depot.DepotService;
import com.jsh.erp.service.material.MaterialService;
@@ -153,6 +155,9 @@ public class DepotController {
BigDecimal currentStock = materialService.getCurrentStock(mId, depot.getId());
de.setInitStock(initStock);
de.setCurrentStock(currentStock);
MaterialInitialStock materialInitialStock = materialService.getSafeStock(mId, depot.getId());
de.setLowSafeStock(materialInitialStock.getLowSafeStock());
de.setHighSafeStock(materialInitialStock.getHighSafeStock());
} else {
de.setInitStock(BigDecimal.ZERO);
de.setCurrentStock(BigDecimal.ZERO);

View File

@@ -327,23 +327,22 @@ public class MaterialController {
try {
List<MaterialVo4Unit> dataList = materialService.findByAll(StringUtil.toNull(barCode), StringUtil.toNull(name),
StringUtil.toNull(standard), StringUtil.toNull(model), StringUtil.toNull(categoryId));
String[] names = {"名称", "类型", "型号", "安全存量", "单位", "零售价", "最低售价", "采购价", "销售价", "备注", "状态"};
String[] names = {"名称", "类型", "型号", "单位", "零售价", "最低售价", "采购价", "销售价", "备注", "状态"};
String title = "商品信息";
List<String[]> objects = new ArrayList<String[]>();
if (null != dataList) {
for (MaterialVo4Unit m : dataList) {
String[] objs = new String[11];
String[] objs = new String[10];
objs[0] = m.getName();
objs[1] = m.getCategoryName();
objs[2] = m.getModel();
objs[3] = m.getSafetyStock() == null? "" : m.getSafetyStock().toString();
objs[4] = m.getCommodityUnit();
objs[5] = m.getCommodityDecimal() == null? "" : m.getCommodityDecimal().toString();
objs[6] = m.getLowDecimal() == null? "" : m.getLowDecimal().toString();
objs[7] = m.getPurchaseDecimal() == null? "" : m.getPurchaseDecimal().toString();
objs[8] = m.getWholesaleDecimal() == null? "" : m.getWholesaleDecimal().toString();
objs[9] = m.getRemark();
objs[10] = m.getEnabled() ? "启用" : "禁用";
objs[3] = m.getCommodityUnit();
objs[4] = m.getCommodityDecimal() == null? "" : m.getCommodityDecimal().toString();
objs[5] = m.getLowDecimal() == null? "" : m.getLowDecimal().toString();
objs[6] = m.getPurchaseDecimal() == null? "" : m.getPurchaseDecimal().toString();
objs[7] = m.getWholesaleDecimal() == null? "" : m.getWholesaleDecimal().toString();
objs[8] = m.getRemark();
objs[9] = m.getEnabled() ? "启用" : "禁用";
objects.add(objs);
}
}

View File

@@ -19,4 +19,8 @@ public class DepotEx extends Depot{
private BigDecimal currentStock;
private BigDecimal lowSafeStock;
private BigDecimal highSafeStock;
}

View File

@@ -11,8 +11,6 @@ public class Material {
private String mfrs;
private BigDecimal safetyStock;
private String model;
private String standard;
@@ -29,6 +27,8 @@ public class Material {
private Integer expiryNum;
private BigDecimal weight;
private Boolean enabled;
private String otherField1;
@@ -77,14 +77,6 @@ public class Material {
this.mfrs = mfrs == null ? null : mfrs.trim();
}
public BigDecimal getSafetyStock() {
return safetyStock;
}
public void setSafetyStock(BigDecimal safetyStock) {
this.safetyStock = safetyStock;
}
public String getModel() {
return model;
}
@@ -149,6 +141,14 @@ public class Material {
this.expiryNum = expiryNum;
}
public BigDecimal getWeight() {
return weight;
}
public void setWeight(BigDecimal weight) {
this.weight = weight;
}
public Boolean getEnabled() {
return enabled;
}

View File

@@ -365,66 +365,6 @@ public class MaterialExample {
return (Criteria) this;
}
public Criteria andSafetyStockIsNull() {
addCriterion("safety_stock is null");
return (Criteria) this;
}
public Criteria andSafetyStockIsNotNull() {
addCriterion("safety_stock is not null");
return (Criteria) this;
}
public Criteria andSafetyStockEqualTo(BigDecimal value) {
addCriterion("safety_stock =", value, "safetyStock");
return (Criteria) this;
}
public Criteria andSafetyStockNotEqualTo(BigDecimal value) {
addCriterion("safety_stock <>", value, "safetyStock");
return (Criteria) this;
}
public Criteria andSafetyStockGreaterThan(BigDecimal value) {
addCriterion("safety_stock >", value, "safetyStock");
return (Criteria) this;
}
public Criteria andSafetyStockGreaterThanOrEqualTo(BigDecimal value) {
addCriterion("safety_stock >=", value, "safetyStock");
return (Criteria) this;
}
public Criteria andSafetyStockLessThan(BigDecimal value) {
addCriterion("safety_stock <", value, "safetyStock");
return (Criteria) this;
}
public Criteria andSafetyStockLessThanOrEqualTo(BigDecimal value) {
addCriterion("safety_stock <=", value, "safetyStock");
return (Criteria) this;
}
public Criteria andSafetyStockIn(List<BigDecimal> values) {
addCriterion("safety_stock in", values, "safetyStock");
return (Criteria) this;
}
public Criteria andSafetyStockNotIn(List<BigDecimal> values) {
addCriterion("safety_stock not in", values, "safetyStock");
return (Criteria) this;
}
public Criteria andSafetyStockBetween(BigDecimal value1, BigDecimal value2) {
addCriterion("safety_stock between", value1, value2, "safetyStock");
return (Criteria) this;
}
public Criteria andSafetyStockNotBetween(BigDecimal value1, BigDecimal value2) {
addCriterion("safety_stock not between", value1, value2, "safetyStock");
return (Criteria) this;
}
public Criteria andModelIsNull() {
addCriterion("model is null");
return (Criteria) this;
@@ -965,6 +905,66 @@ public class MaterialExample {
return (Criteria) this;
}
public Criteria andWeightIsNull() {
addCriterion("weight is null");
return (Criteria) this;
}
public Criteria andWeightIsNotNull() {
addCriterion("weight is not null");
return (Criteria) this;
}
public Criteria andWeightEqualTo(BigDecimal value) {
addCriterion("weight =", value, "weight");
return (Criteria) this;
}
public Criteria andWeightNotEqualTo(BigDecimal value) {
addCriterion("weight <>", value, "weight");
return (Criteria) this;
}
public Criteria andWeightGreaterThan(BigDecimal value) {
addCriterion("weight >", value, "weight");
return (Criteria) this;
}
public Criteria andWeightGreaterThanOrEqualTo(BigDecimal value) {
addCriterion("weight >=", value, "weight");
return (Criteria) this;
}
public Criteria andWeightLessThan(BigDecimal value) {
addCriterion("weight <", value, "weight");
return (Criteria) this;
}
public Criteria andWeightLessThanOrEqualTo(BigDecimal value) {
addCriterion("weight <=", value, "weight");
return (Criteria) this;
}
public Criteria andWeightIn(List<BigDecimal> values) {
addCriterion("weight in", values, "weight");
return (Criteria) this;
}
public Criteria andWeightNotIn(List<BigDecimal> values) {
addCriterion("weight not in", values, "weight");
return (Criteria) this;
}
public Criteria andWeightBetween(BigDecimal value1, BigDecimal value2) {
addCriterion("weight between", value1, value2, "weight");
return (Criteria) this;
}
public Criteria andWeightNotBetween(BigDecimal value1, BigDecimal value2) {
addCriterion("weight not between", value1, value2, "weight");
return (Criteria) this;
}
public Criteria andEnabledIsNull() {
addCriterion("enabled is null");
return (Criteria) this;

View File

@@ -11,6 +11,10 @@ public class MaterialInitialStock {
private BigDecimal number;
private BigDecimal lowSafeStock;
private BigDecimal highSafeStock;
private Long tenantId;
private String deleteFlag;
@@ -47,6 +51,22 @@ public class MaterialInitialStock {
this.number = number;
}
public BigDecimal getLowSafeStock() {
return lowSafeStock;
}
public void setLowSafeStock(BigDecimal lowSafeStock) {
this.lowSafeStock = lowSafeStock;
}
public BigDecimal getHighSafeStock() {
return highSafeStock;
}
public void setHighSafeStock(BigDecimal highSafeStock) {
this.highSafeStock = highSafeStock;
}
public Long getTenantId() {
return tenantId;
}

View File

@@ -345,6 +345,126 @@ public class MaterialInitialStockExample {
return (Criteria) this;
}
public Criteria andLowSafeStockIsNull() {
addCriterion("low_safe_stock is null");
return (Criteria) this;
}
public Criteria andLowSafeStockIsNotNull() {
addCriterion("low_safe_stock is not null");
return (Criteria) this;
}
public Criteria andLowSafeStockEqualTo(BigDecimal value) {
addCriterion("low_safe_stock =", value, "lowSafeStock");
return (Criteria) this;
}
public Criteria andLowSafeStockNotEqualTo(BigDecimal value) {
addCriterion("low_safe_stock <>", value, "lowSafeStock");
return (Criteria) this;
}
public Criteria andLowSafeStockGreaterThan(BigDecimal value) {
addCriterion("low_safe_stock >", value, "lowSafeStock");
return (Criteria) this;
}
public Criteria andLowSafeStockGreaterThanOrEqualTo(BigDecimal value) {
addCriterion("low_safe_stock >=", value, "lowSafeStock");
return (Criteria) this;
}
public Criteria andLowSafeStockLessThan(BigDecimal value) {
addCriterion("low_safe_stock <", value, "lowSafeStock");
return (Criteria) this;
}
public Criteria andLowSafeStockLessThanOrEqualTo(BigDecimal value) {
addCriterion("low_safe_stock <=", value, "lowSafeStock");
return (Criteria) this;
}
public Criteria andLowSafeStockIn(List<BigDecimal> values) {
addCriterion("low_safe_stock in", values, "lowSafeStock");
return (Criteria) this;
}
public Criteria andLowSafeStockNotIn(List<BigDecimal> values) {
addCriterion("low_safe_stock not in", values, "lowSafeStock");
return (Criteria) this;
}
public Criteria andLowSafeStockBetween(BigDecimal value1, BigDecimal value2) {
addCriterion("low_safe_stock between", value1, value2, "lowSafeStock");
return (Criteria) this;
}
public Criteria andLowSafeStockNotBetween(BigDecimal value1, BigDecimal value2) {
addCriterion("low_safe_stock not between", value1, value2, "lowSafeStock");
return (Criteria) this;
}
public Criteria andHighSafeStockIsNull() {
addCriterion("high_safe_stock is null");
return (Criteria) this;
}
public Criteria andHighSafeStockIsNotNull() {
addCriterion("high_safe_stock is not null");
return (Criteria) this;
}
public Criteria andHighSafeStockEqualTo(BigDecimal value) {
addCriterion("high_safe_stock =", value, "highSafeStock");
return (Criteria) this;
}
public Criteria andHighSafeStockNotEqualTo(BigDecimal value) {
addCriterion("high_safe_stock <>", value, "highSafeStock");
return (Criteria) this;
}
public Criteria andHighSafeStockGreaterThan(BigDecimal value) {
addCriterion("high_safe_stock >", value, "highSafeStock");
return (Criteria) this;
}
public Criteria andHighSafeStockGreaterThanOrEqualTo(BigDecimal value) {
addCriterion("high_safe_stock >=", value, "highSafeStock");
return (Criteria) this;
}
public Criteria andHighSafeStockLessThan(BigDecimal value) {
addCriterion("high_safe_stock <", value, "highSafeStock");
return (Criteria) this;
}
public Criteria andHighSafeStockLessThanOrEqualTo(BigDecimal value) {
addCriterion("high_safe_stock <=", value, "highSafeStock");
return (Criteria) this;
}
public Criteria andHighSafeStockIn(List<BigDecimal> values) {
addCriterion("high_safe_stock in", values, "highSafeStock");
return (Criteria) this;
}
public Criteria andHighSafeStockNotIn(List<BigDecimal> values) {
addCriterion("high_safe_stock not in", values, "highSafeStock");
return (Criteria) this;
}
public Criteria andHighSafeStockBetween(BigDecimal value1, BigDecimal value2) {
addCriterion("high_safe_stock between", value1, value2, "highSafeStock");
return (Criteria) this;
}
public Criteria andHighSafeStockNotBetween(BigDecimal value1, BigDecimal value2) {
addCriterion("high_safe_stock not between", value1, value2, "highSafeStock");
return (Criteria) this;
}
public Criteria andTenantIdIsNull() {
addCriterion("tenant_id is null");
return (Criteria) this;

View File

@@ -182,9 +182,17 @@ public class MaterialService {
JSONObject jsonObj = stockArr.getJSONObject(i);
if(jsonObj.get("id")!=null && jsonObj.get("initStock")!=null) {
String number = jsonObj.getString("initStock");
BigDecimal lowSafeStock = null;
BigDecimal highSafeStock = null;
if(jsonObj.get("lowSafeStock")!=null) {
lowSafeStock = jsonObj.getBigDecimal("lowSafeStock");
}
if(jsonObj.get("highSafeStock")!=null) {
highSafeStock = jsonObj.getBigDecimal("highSafeStock");
}
Long depotId = jsonObj.getLong("id");
if(StringUtil.isNotEmpty(number) && Double.valueOf(number)>0) {
insertInitialStockByMaterialAndDepot(depotId, mId, parseBigDecimalEx(number));
if(StringUtil.isNotEmpty(number) && Double.valueOf(number)>0 || lowSafeStock!=null || highSafeStock!=null) {
insertInitialStockByMaterialAndDepot(depotId, mId, parseBigDecimalEx(number), lowSafeStock, highSafeStock);
insertCurrentStockByMaterialAndDepot(depotId, mId, parseBigDecimalEx(number));
}
}
@@ -221,13 +229,21 @@ public class MaterialService {
JSONObject jsonObj = stockArr.getJSONObject(i);
if (jsonObj.get("id") != null && jsonObj.get("initStock") != null) {
String number = jsonObj.getString("initStock");
BigDecimal lowSafeStock = null;
BigDecimal highSafeStock = null;
if(jsonObj.get("lowSafeStock")!=null) {
lowSafeStock = jsonObj.getBigDecimal("lowSafeStock");
}
if(jsonObj.get("highSafeStock")!=null) {
highSafeStock = jsonObj.getBigDecimal("highSafeStock");
}
Long depotId = jsonObj.getLong("id");
//初始库存-先清除再插入
MaterialInitialStockExample example = new MaterialInitialStockExample();
example.createCriteria().andMaterialIdEqualTo(material.getId()).andDepotIdEqualTo(depotId);
materialInitialStockMapper.deleteByExample(example);
if (StringUtil.isNotEmpty(number) && Double.valueOf(number) > 0) {
insertInitialStockByMaterialAndDepot(depotId, material.getId(), parseBigDecimalEx(number));
if (StringUtil.isNotEmpty(number) && Double.valueOf(number) > 0 || lowSafeStock!=null || highSafeStock!=null) {
insertInitialStockByMaterialAndDepot(depotId, material.getId(), parseBigDecimalEx(number), lowSafeStock, highSafeStock);
}
//更新当前库存
depotItemService.updateCurrentStockFun(material.getId(), depotId);
@@ -468,7 +484,6 @@ public class MaterialService {
if(null!=categoryId){
m.setCategoryId(categoryId);
}
m.setSafetyStock(parseBigDecimalEx(safetyStock));
String manyUnit = ExcelUtils.getContent(src, i, 7); //副单位
String barCode = ExcelUtils.getContent(src, i, 8); //基础条码
String manyBarCode = ExcelUtils.getContent(src, i, 9); //副条码
@@ -598,7 +613,7 @@ public class MaterialService {
materialInitialStockMapper.deleteByExample(example);
if(stock!=null && stock.compareTo(BigDecimal.ZERO)!=0) {
depotId = depot.getId();
insertInitialStockByMaterialAndDepot(depotId, mId, stock);
insertInitialStockByMaterialAndDepot(depotId, mId, stock, null, null);
//更新当前库存
depotItemService.updateCurrentStockFun(mId, depotId);
}
@@ -663,11 +678,18 @@ public class MaterialService {
* @param stock
*/
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public void insertInitialStockByMaterialAndDepot(Long depotId, Long mId, BigDecimal stock){
public void insertInitialStockByMaterialAndDepot(Long depotId, Long mId, BigDecimal stock, BigDecimal lowSafeStock, BigDecimal highSafeStock){
MaterialInitialStock materialInitialStock = new MaterialInitialStock();
materialInitialStock.setDepotId(depotId);
materialInitialStock.setMaterialId(mId);
stock = stock == null? BigDecimal.ZERO: stock;
materialInitialStock.setNumber(stock);
if(lowSafeStock!=null) {
materialInitialStock.setLowSafeStock(lowSafeStock);
}
if(highSafeStock!=null) {
materialInitialStock.setHighSafeStock(highSafeStock);
}
materialInitialStockMapper.insertSelective(materialInitialStock); //存入初始库存
}
@@ -788,6 +810,24 @@ public class MaterialService {
return stock;
}
/**
* 根据商品和仓库获取安全库存信息
* @param materialId
* @param depotId
* @return
*/
public MaterialInitialStock getSafeStock(Long materialId, Long depotId) {
MaterialInitialStock materialInitialStock = new MaterialInitialStock();
MaterialInitialStockExample example = new MaterialInitialStockExample();
example.createCriteria().andMaterialIdEqualTo(materialId).andDepotIdEqualTo(depotId)
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
List<MaterialInitialStock> list = materialInitialStockMapper.selectByExample(example);
if(list!=null && list.size()>0) {
materialInitialStock = list.get(0);
}
return materialInitialStock;
}
public List<MaterialVo4Unit> getMaterialByMeId(Long meId) {
List<MaterialVo4Unit> result = new ArrayList<MaterialVo4Unit>();
try{

View File

@@ -421,10 +421,11 @@
<select id="findStockWarningCount" parameterType="com.jsh.erp.datasource.entities.DepotItemExample" resultMap="ResultStockWarningCount">
select m.id MId, m.name MName, me.bar_code, m.mfrs MMfrs, m.model MModel, m.standard MStandard,m.color MColor,
m.other_field1 MOtherField1,m.other_field2 MOtherField2,m.other_field3 MOtherField3,
m.unit MaterialUnit, u.name unit_name,mcs.current_number,ifnull(m.safety_stock,0) safetystock,
(ifnull(m.safety_stock,0)-mcs.current_number) linjieNumber
m.unit MaterialUnit, u.name unit_name,mcs.current_number,ifnull(mis.low_safe_stock,0) safetystock,
(ifnull(mis.low_safe_stock,0)-mcs.current_number) linjieNumber
from jsh_material m
left join jsh_material_extend me on me.material_id=m.id and ifnull(me.delete_Flag,'0') !='1'
left join jsh_material_initial_stock mis on mis.material_id=m.id and ifnull(mis.delete_Flag,'0') !='1'
left join jsh_material_current_stock mcs on mcs.material_id=m.id and ifnull(mcs.delete_Flag,'0') !='1'
left join jsh_depot_item di on di.material_id=m.id and ifnull(di.delete_Flag,'0') !='1'
left join jsh_depot_head dh on di.header_id=dh.id and ifnull(dh.delete_flag,'0') !='1'
@@ -432,7 +433,7 @@
where 1=1
and me.default_flag=1
and ifnull(m.delete_flag,'0') !='1'
and ifnull(m.safety_stock,0) > mcs.current_number
and ifnull(mis.low_safe_stock,0) > mcs.current_number
<if test="materialParam != null and materialParam !=''">
<bind name="bindKey" value="'%'+materialParam+'%'"/>
and (me.bar_code like #{bindKey} or m.name like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey})
@@ -452,6 +453,7 @@
(select m.id
from jsh_material m
left join jsh_material_extend me on me.material_id=m.id and ifnull(me.delete_Flag,'0') !='1'
left join jsh_material_initial_stock mis on mis.material_id=m.id and ifnull(mis.delete_Flag,'0') !='1'
left join jsh_material_current_stock mcs on mcs.material_id=m.id and ifnull(mcs.delete_Flag,'0') !='1'
left join jsh_depot_item di on di.material_id=m.id and ifnull(di.delete_Flag,'0') !='1'
left join jsh_depot_head dh on di.header_id=dh.id and ifnull(dh.delete_flag,'0') !='1'
@@ -459,7 +461,7 @@
where 1=1
and me.default_flag=1
and ifnull(m.delete_flag,'0') !='1'
and ifnull(m.safety_stock,0) > mcs.current_number
and ifnull(mis.low_safe_stock,0) > mcs.current_number
<if test="materialParam != null and materialParam !=''">
<bind name="bindKey" value="'%'+materialParam+'%'"/>
and (me.bar_code like #{bindKey} or m.name like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey})

View File

@@ -6,6 +6,8 @@
<result column="material_id" jdbcType="BIGINT" property="materialId" />
<result column="depot_id" jdbcType="BIGINT" property="depotId" />
<result column="number" jdbcType="DECIMAL" property="number" />
<result column="low_safe_stock" jdbcType="DECIMAL" property="lowSafeStock" />
<result column="high_safe_stock" jdbcType="DECIMAL" property="highSafeStock" />
<result column="tenant_id" jdbcType="BIGINT" property="tenantId" />
<result column="delete_flag" jdbcType="VARCHAR" property="deleteFlag" />
</resultMap>
@@ -68,7 +70,7 @@
</where>
</sql>
<sql id="Base_Column_List">
id, material_id, depot_id, number, tenant_id, delete_flag
id, material_id, depot_id, number, low_safe_stock, high_safe_stock, tenant_id, delete_flag
</sql>
<select id="selectByExample" parameterType="com.jsh.erp.datasource.entities.MaterialInitialStockExample" resultMap="BaseResultMap">
select
@@ -102,11 +104,11 @@
</delete>
<insert id="insert" parameterType="com.jsh.erp.datasource.entities.MaterialInitialStock">
insert into jsh_material_initial_stock (id, material_id, depot_id,
number, tenant_id, delete_flag
)
number, low_safe_stock, high_safe_stock,
tenant_id, delete_flag)
values (#{id,jdbcType=BIGINT}, #{materialId,jdbcType=BIGINT}, #{depotId,jdbcType=BIGINT},
#{number,jdbcType=DECIMAL}, #{tenantId,jdbcType=BIGINT}, #{deleteFlag,jdbcType=VARCHAR}
)
#{number,jdbcType=DECIMAL}, #{lowSafeStock,jdbcType=DECIMAL}, #{highSafeStock,jdbcType=DECIMAL},
#{tenantId,jdbcType=BIGINT}, #{deleteFlag,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.jsh.erp.datasource.entities.MaterialInitialStock">
insert into jsh_material_initial_stock
@@ -123,6 +125,12 @@
<if test="number != null">
number,
</if>
<if test="lowSafeStock != null">
low_safe_stock,
</if>
<if test="highSafeStock != null">
high_safe_stock,
</if>
<if test="tenantId != null">
tenant_id,
</if>
@@ -143,6 +151,12 @@
<if test="number != null">
#{number,jdbcType=DECIMAL},
</if>
<if test="lowSafeStock != null">
#{lowSafeStock,jdbcType=DECIMAL},
</if>
<if test="highSafeStock != null">
#{highSafeStock,jdbcType=DECIMAL},
</if>
<if test="tenantId != null">
#{tenantId,jdbcType=BIGINT},
</if>
@@ -172,6 +186,12 @@
<if test="record.number != null">
number = #{record.number,jdbcType=DECIMAL},
</if>
<if test="record.lowSafeStock != null">
low_safe_stock = #{record.lowSafeStock,jdbcType=DECIMAL},
</if>
<if test="record.highSafeStock != null">
high_safe_stock = #{record.highSafeStock,jdbcType=DECIMAL},
</if>
<if test="record.tenantId != null">
tenant_id = #{record.tenantId,jdbcType=BIGINT},
</if>
@@ -189,6 +209,8 @@
material_id = #{record.materialId,jdbcType=BIGINT},
depot_id = #{record.depotId,jdbcType=BIGINT},
number = #{record.number,jdbcType=DECIMAL},
low_safe_stock = #{record.lowSafeStock,jdbcType=DECIMAL},
high_safe_stock = #{record.highSafeStock,jdbcType=DECIMAL},
tenant_id = #{record.tenantId,jdbcType=BIGINT},
delete_flag = #{record.deleteFlag,jdbcType=VARCHAR}
<if test="_parameter != null">
@@ -207,6 +229,12 @@
<if test="number != null">
number = #{number,jdbcType=DECIMAL},
</if>
<if test="lowSafeStock != null">
low_safe_stock = #{lowSafeStock,jdbcType=DECIMAL},
</if>
<if test="highSafeStock != null">
high_safe_stock = #{highSafeStock,jdbcType=DECIMAL},
</if>
<if test="tenantId != null">
tenant_id = #{tenantId,jdbcType=BIGINT},
</if>
@@ -221,6 +249,8 @@
set material_id = #{materialId,jdbcType=BIGINT},
depot_id = #{depotId,jdbcType=BIGINT},
number = #{number,jdbcType=DECIMAL},
low_safe_stock = #{lowSafeStock,jdbcType=DECIMAL},
high_safe_stock = #{highSafeStock,jdbcType=DECIMAL},
tenant_id = #{tenantId,jdbcType=BIGINT},
delete_flag = #{deleteFlag,jdbcType=VARCHAR}
where id = #{id,jdbcType=BIGINT}

View File

@@ -6,7 +6,6 @@
<result column="category_id" jdbcType="BIGINT" property="categoryId" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="mfrs" jdbcType="VARCHAR" property="mfrs" />
<result column="safety_stock" jdbcType="DECIMAL" property="safetyStock" />
<result column="model" jdbcType="VARCHAR" property="model" />
<result column="standard" jdbcType="VARCHAR" property="standard" />
<result column="color" jdbcType="VARCHAR" property="color" />
@@ -15,6 +14,7 @@
<result column="img_name" jdbcType="VARCHAR" property="imgName" />
<result column="unit_id" jdbcType="BIGINT" property="unitId" />
<result column="expiry_num" jdbcType="INTEGER" property="expiryNum" />
<result column="weight" jdbcType="DECIMAL" property="weight" />
<result column="enabled" jdbcType="BIT" property="enabled" />
<result column="other_field1" jdbcType="VARCHAR" property="otherField1" />
<result column="other_field2" jdbcType="VARCHAR" property="otherField2" />
@@ -83,9 +83,9 @@
</where>
</sql>
<sql id="Base_Column_List">
id, category_id, name, mfrs, safety_stock, model, standard, color, unit, remark,
img_name, unit_id, expiry_num, enabled, other_field1, other_field2, other_field3,
enable_serial_number, enable_batch_number, tenant_id, delete_flag
id, category_id, name, mfrs, model, standard, color, unit, remark, img_name, unit_id,
expiry_num, weight, enabled, other_field1, other_field2, other_field3, enable_serial_number,
enable_batch_number, tenant_id, delete_flag
</sql>
<select id="selectByExample" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultMap="BaseResultMap">
select
@@ -119,18 +119,18 @@
</delete>
<insert id="insert" parameterType="com.jsh.erp.datasource.entities.Material">
insert into jsh_material (id, category_id, name,
mfrs, safety_stock, model,
standard, color, unit,
remark, img_name, unit_id,
expiry_num, enabled, other_field1,
mfrs, model, standard,
color, unit, remark,
img_name, unit_id, expiry_num,
weight, enabled, other_field1,
other_field2, other_field3, enable_serial_number,
enable_batch_number, tenant_id, delete_flag
)
values (#{id,jdbcType=BIGINT}, #{categoryId,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR},
#{mfrs,jdbcType=VARCHAR}, #{safetyStock,jdbcType=DECIMAL}, #{model,jdbcType=VARCHAR},
#{standard,jdbcType=VARCHAR}, #{color,jdbcType=VARCHAR}, #{unit,jdbcType=VARCHAR},
#{remark,jdbcType=VARCHAR}, #{imgName,jdbcType=VARCHAR}, #{unitId,jdbcType=BIGINT},
#{expiryNum,jdbcType=INTEGER}, #{enabled,jdbcType=BIT}, #{otherField1,jdbcType=VARCHAR},
#{mfrs,jdbcType=VARCHAR}, #{model,jdbcType=VARCHAR}, #{standard,jdbcType=VARCHAR},
#{color,jdbcType=VARCHAR}, #{unit,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR},
#{imgName,jdbcType=VARCHAR}, #{unitId,jdbcType=BIGINT}, #{expiryNum,jdbcType=INTEGER},
#{weight,jdbcType=DECIMAL}, #{enabled,jdbcType=BIT}, #{otherField1,jdbcType=VARCHAR},
#{otherField2,jdbcType=VARCHAR}, #{otherField3,jdbcType=VARCHAR}, #{enableSerialNumber,jdbcType=VARCHAR},
#{enableBatchNumber,jdbcType=VARCHAR}, #{tenantId,jdbcType=BIGINT}, #{deleteFlag,jdbcType=VARCHAR}
)
@@ -150,9 +150,6 @@
<if test="mfrs != null">
mfrs,
</if>
<if test="safetyStock != null">
safety_stock,
</if>
<if test="model != null">
model,
</if>
@@ -177,6 +174,9 @@
<if test="expiryNum != null">
expiry_num,
</if>
<if test="weight != null">
weight,
</if>
<if test="enabled != null">
enabled,
</if>
@@ -215,9 +215,6 @@
<if test="mfrs != null">
#{mfrs,jdbcType=VARCHAR},
</if>
<if test="safetyStock != null">
#{safetyStock,jdbcType=DECIMAL},
</if>
<if test="model != null">
#{model,jdbcType=VARCHAR},
</if>
@@ -242,6 +239,9 @@
<if test="expiryNum != null">
#{expiryNum,jdbcType=INTEGER},
</if>
<if test="weight != null">
#{weight,jdbcType=DECIMAL},
</if>
<if test="enabled != null">
#{enabled,jdbcType=BIT},
</if>
@@ -289,9 +289,6 @@
<if test="record.mfrs != null">
mfrs = #{record.mfrs,jdbcType=VARCHAR},
</if>
<if test="record.safetyStock != null">
safety_stock = #{record.safetyStock,jdbcType=DECIMAL},
</if>
<if test="record.model != null">
model = #{record.model,jdbcType=VARCHAR},
</if>
@@ -316,6 +313,9 @@
<if test="record.expiryNum != null">
expiry_num = #{record.expiryNum,jdbcType=INTEGER},
</if>
<if test="record.weight != null">
weight = #{record.weight,jdbcType=DECIMAL},
</if>
<if test="record.enabled != null">
enabled = #{record.enabled,jdbcType=BIT},
</if>
@@ -351,7 +351,6 @@
category_id = #{record.categoryId,jdbcType=BIGINT},
name = #{record.name,jdbcType=VARCHAR},
mfrs = #{record.mfrs,jdbcType=VARCHAR},
safety_stock = #{record.safetyStock,jdbcType=DECIMAL},
model = #{record.model,jdbcType=VARCHAR},
standard = #{record.standard,jdbcType=VARCHAR},
color = #{record.color,jdbcType=VARCHAR},
@@ -360,6 +359,7 @@
img_name = #{record.imgName,jdbcType=VARCHAR},
unit_id = #{record.unitId,jdbcType=BIGINT},
expiry_num = #{record.expiryNum,jdbcType=INTEGER},
weight = #{record.weight,jdbcType=DECIMAL},
enabled = #{record.enabled,jdbcType=BIT},
other_field1 = #{record.otherField1,jdbcType=VARCHAR},
other_field2 = #{record.otherField2,jdbcType=VARCHAR},
@@ -384,9 +384,6 @@
<if test="mfrs != null">
mfrs = #{mfrs,jdbcType=VARCHAR},
</if>
<if test="safetyStock != null">
safety_stock = #{safetyStock,jdbcType=DECIMAL},
</if>
<if test="model != null">
model = #{model,jdbcType=VARCHAR},
</if>
@@ -411,6 +408,9 @@
<if test="expiryNum != null">
expiry_num = #{expiryNum,jdbcType=INTEGER},
</if>
<if test="weight != null">
weight = #{weight,jdbcType=DECIMAL},
</if>
<if test="enabled != null">
enabled = #{enabled,jdbcType=BIT},
</if>
@@ -443,7 +443,6 @@
set category_id = #{categoryId,jdbcType=BIGINT},
name = #{name,jdbcType=VARCHAR},
mfrs = #{mfrs,jdbcType=VARCHAR},
safety_stock = #{safetyStock,jdbcType=DECIMAL},
model = #{model,jdbcType=VARCHAR},
standard = #{standard,jdbcType=VARCHAR},
color = #{color,jdbcType=VARCHAR},
@@ -452,6 +451,7 @@
img_name = #{imgName,jdbcType=VARCHAR},
unit_id = #{unitId,jdbcType=BIGINT},
expiry_num = #{expiryNum,jdbcType=INTEGER},
weight = #{weight,jdbcType=DECIMAL},
enabled = #{enabled,jdbcType=BIT},
other_field1 = #{otherField1,jdbcType=VARCHAR},
other_field2 = #{otherField2,jdbcType=VARCHAR},