优化商品模块

This commit is contained in:
季圣华
2019-11-28 23:10:12 +08:00
parent cc5617ad9c
commit 05858c6f71
20 changed files with 1939 additions and 97 deletions

View File

@@ -675,4 +675,25 @@ drop table jsh_app;
-- 时间2019年11月28日 -- 时间2019年11月28日
-- 单据编号表-改表名 -- 单据编号表-改表名
-- ---------------------------- -- ----------------------------
ALTER TABLE tbl_sequence RENAME TO jsh_sequence; ALTER TABLE tbl_sequence RENAME TO jsh_sequence;
-- ----------------------------
-- 增加产品初始库存表
-- 时间 2019-11-28
-- by jishenghua
-- ----------------------------
CREATE TABLE `jsh_material_stock` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键' ,
`material_id` bigint(20) NULL DEFAULT NULL COMMENT '产品id' ,
`depot_id` bigint(20) NULL DEFAULT NULL COMMENT '仓库id' ,
`number` decimal(24,6) NULL DEFAULT NULL COMMENT '初始库存数量' ,
`tenant_id` bigint(20) NULL DEFAULT NULL COMMENT '租户id' ,
`delete_fag` varchar(1) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '0' COMMENT '删除标记0未删除1删除' ,
PRIMARY KEY (`id`)
)
ENGINE=InnoDB
DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci
COMMENT='产品初始库存'
AUTO_INCREMENT=48
ROW_FORMAT=COMPACT
;

View File

@@ -13,6 +13,7 @@
<link type="text/css" rel="stylesheet" href="/css/material.css"/> <link type="text/css" rel="stylesheet" href="/css/material.css"/>
<script type="text/javascript" src="/js/easyui-1.3.5/jquery.easyui.min.js"></script> <script type="text/javascript" src="/js/easyui-1.3.5/jquery.easyui.min.js"></script>
<script type="text/javascript" src="/js/easyui-1.3.5/locale/easyui-lang-zh_CN.js"></script> <script type="text/javascript" src="/js/easyui-1.3.5/locale/easyui-lang-zh_CN.js"></script>
<script src="/js/handlebars.js"></script>
<script type="text/javascript" src="/js/common/outlook_in.js"></script> <script type="text/javascript" src="/js/common/outlook_in.js"></script>
<script type="text/javascript" src="/js/common/common.js"></script> <script type="text/javascript" src="/js/common/common.js"></script>
<script src="/js/common/jsherp.js"></script> <script src="/js/common/jsherp.js"></script>
@@ -125,11 +126,11 @@
</td> </td>
</tr> </tr>
<tr class="first-select-unit"> <tr class="first-select-unit">
<td style="height:30px;">首选出库单位</td> <td style="height:30px;">首选销售单位</td>
<td style="padding:5px"> <td style="padding:5px">
<select name="FirstOutUnit" id="FirstOutUnit" style="width:180px;height: 20px"></select> <select name="FirstOutUnit" id="FirstOutUnit" style="width:180px;height: 20px"></select>
</td> </td>
<td>首选入库单位</td> <td>首选采购单位</td>
<td style="padding:5px"> <td style="padding:5px">
<select name="FirstInUnit" id="FirstInUnit" style="width:180px;height: 20px"></select> <select name="FirstInUnit" id="FirstInUnit" style="width:180px;height: 20px"></select>
</td> </td>
@@ -237,6 +238,9 @@
</tr> </tr>
</table> </table>
</div> </div>
<div title="初始库存" style="padding:20px;">
<div id="initDepot"></div>
</div>
</div> </div>
</form> </form>
</div> </div>
@@ -251,18 +255,12 @@
closed="true" buttons="#dlg-buttons5" modal="true" collapsible="false" closable="true"> closed="true" buttons="#dlg-buttons5" modal="true" collapsible="false" closable="true">
<form id="importExcelFM" method="post" enctype="multipart/form-data" action="/material/importExcel"> <form id="importExcelFM" method="post" enctype="multipart/form-data" action="/material/importExcel">
<div class="fitem" style="padding:5px"> <div class="fitem" style="padding:5px">
<label>文件名称&nbsp;&nbsp;</label> <label>表格模板&nbsp;&nbsp;</label>
<input name="materialFile" id="materialFile" type="file" style="width: 230px;height: 20px"/> <span><a href="/upload/excels/goods_template.xls"><b>Excel模板下载</b></a></span>
</div> </div>
<div class="fitem" style="padding:5px"> <div class="fitem" style="padding:5px">
<label><b>导入注意</b>&nbsp;&nbsp;</label><span>(多单位清空下,价格请用斜线隔开)</span> <label>文件名称&nbsp;&nbsp;</label>
</div> <input name="materialFile" id="materialFile" type="file" style="width: 230px;height: 20px"/>
<div class="fitem" style="padding:5px;display: none;">
<label>是否审查&nbsp;&nbsp;</label>
<select id="isCheck" name="isCheck" style="width: 230px;height: 20px">
<option value="0">是</option>
<option value="1" selected="selected">否</option>
</select>
</div> </div>
<div id="dlg-buttons5"> <div id="dlg-buttons5">
<a href="javascript:void(0)" id="saveimport" class="easyui-linkbutton" iconCls="icon-ok">导入</a> <a href="javascript:void(0)" id="saveimport" class="easyui-linkbutton" iconCls="icon-ok">导入</a>
@@ -271,6 +269,7 @@
</div> </div>
</form> </form>
</div> </div>
<div id="forSelectMaterialCategoryDlg" class="easyui-dialog" style="width:380px;padding:10px 20px" <div id="forSelectMaterialCategoryDlg" class="easyui-dialog" style="width:380px;padding:10px 20px"
closed="true" modal="true" cache="false" collapsible="false" closable="true"> closed="true" modal="true" cache="false" collapsible="false" closable="true">
</div> </div>
@@ -517,14 +516,9 @@
columns: [[ columns: [[
{field: 'id', width: 35, align: "center", checkbox: true}, {field: 'id', width: 35, align: "center", checkbox: true},
{ {
title: '操作', field: 'op', align: "center", width: 60, formatter: function (value, rec) { title: '操作', field: 'op', align: "center", width: 60, formatter: function (value, rec, index) {
var str = ''; var str = '';
var rowInfo = rec.id + 'AaBb' + rec.name + 'AaBb' + rec.model + 'AaBb' + rec.color + 'AaBb' + rec.unit + 'AaBb' + rec.retailprice str += '<img title="编辑" src="/js/easyui-1.3.5/themes/icons/pencil.png" style="cursor: pointer;" onclick="editMaterial(\'' + index + '\');"/>&nbsp;&nbsp;&nbsp;';
+ 'AaBb' + rec.lowprice + 'AaBb' + rec.presetpriceone + 'AaBb' + rec.presetpricetwo + 'AaBb' + rec.remark + 'AaBb' + rec.standard
+ 'AaBb' + rec.color + 'AaBb' + rec.packing + 'AaBb' + rec.safetystock + 'AaBb' + rec.categoryid + 'AaBb' + rec.categoryName
+ 'AaBb' + rec.unitid + 'AaBb' + rec.unitName + 'AaBb' + rec.firstoutunit + 'AaBb' + rec.firstinunit
+ 'AaBb' + rec.mfrs + 'AaBb' + rec.otherfield1 + 'AaBb' + rec.otherfield2 + 'AaBb' + rec.otherfield3+ 'AaBb' + rec.enableserialnumber;
str += '<img title="编辑" src="/js/easyui-1.3.5/themes/icons/pencil.png" style="cursor: pointer;" onclick="editMaterial(\'' + rowInfo + '\');"/>&nbsp;&nbsp;&nbsp;';
str += '<img title="删除" src="/js/easyui-1.3.5/themes/icons/edit_remove.png" style="cursor: pointer;" onclick="deleteMaterial(' + rec.id + ');"/>'; str += '<img title="删除" src="/js/easyui-1.3.5/themes/icons/edit_remove.png" style="cursor: pointer;" onclick="deleteMaterial(' + rec.id + ');"/>';
return str; return str;
} }
@@ -1141,6 +1135,7 @@
oldManyUnit = ""; oldManyUnit = "";
materialID = 0; materialID = 0;
url = '/material/add'; url = '/material/add';
initDepotList(materialID); //加载仓库列表页面
} }
//检查商品名称是否存在 ++ 重名无法提示问题需要跟进 //检查商品名称是否存在 ++ 重名无法提示问题需要跟进
@@ -1245,6 +1240,17 @@
objInfo.UnitId = $("#manyUnit").val(); objInfo.UnitId = $("#manyUnit").val();
objInfo.CategoryId =$("#parentid").val(); objInfo.CategoryId =$("#parentid").val();
objInfo.PriceStrategy = JSON.stringify(priceStrategy); //价格列表 objInfo.PriceStrategy = JSON.stringify(priceStrategy); //价格列表
//初始库存信息
var stockArr = [];
$("#initDepot input").each(function () {
var id = $(this).attr("data-id");
var val = $(this).val();
var stockObj = {};
stockObj.depotId = id;
stockObj.number = val;
stockArr.push(stockObj);
});
objInfo.stock = JSON.stringify(stockArr);
$.ajax({ $.ajax({
type: "post", type: "post",
url: url, url: url,
@@ -1291,35 +1297,35 @@
} }
//编辑信息 //编辑信息
function editMaterial(materialTotalInfo) { function editMaterial(index) {
var materialInfo = materialTotalInfo.split("AaBb"); var rowsdata = $("#tableData").datagrid("getRows")[index];
bindMProperty(); //根据商品属性绑定 bindMProperty(); //根据商品属性绑定
$("#Name").focus().val(materialInfo[1]); $("#Name").focus().val(rowsdata.name);
$("#Color").focus().val(materialInfo[11]); $("#Color").focus().val(rowsdata.color);
$("#EnableSerialNumber").val(materialInfo[24]=='1'?'1':'0'); $("#EnableSerialNumber").val(rowsdata.enableserialnumber=='1'?'1':'0');
//商品类别id //商品类别id
$("#parentid").val(materialInfo[14] == "undefined" ? "" : materialInfo[14]); $("#parentid").val(rowsdata.categoryid);
//商品类别名称 //商品类别名称
$("#parentName").val(materialInfo[15] == "undefined" ? "" : materialInfo[15]); $("#parentName").val(rowsdata.categoryName);
mId = materialInfo[14]; mId = rowsdata.categoryid;
mName = materialInfo[15]; mName = rowsdata.categoryName;
$("#Packing").focus().val(materialInfo[12]); $("#Packing").focus().val(rowsdata.packing);
$("#SafetyStock").focus().val(materialInfo[13]=="undefined" ? "" : materialInfo[13]); $("#SafetyStock").focus().val(rowsdata.safetystock);
$("#Model").val(materialInfo[2]); $("#Model").val(rowsdata.model);
$("#Standard").val(materialInfo[10] == "undefined" ? "" : materialInfo[10]); $("#Standard").val(rowsdata.standard);
$("#Color").val(materialInfo[3] == "undefined" ? "" : materialInfo[3]); $("#Color").val(rowsdata.color);
$("#Mfrs").val(materialInfo[20] == "undefined" ? "" : materialInfo[20]); $("#Mfrs").val(rowsdata.mfrs);
$("#OtherField1").val(materialInfo[21] == "undefined" ? "" : materialInfo[21]); $("#OtherField1").val(rowsdata.otherfield1);
$("#OtherField2").val(materialInfo[22] == "undefined" ? "" : materialInfo[22]); $("#OtherField2").val(rowsdata.otherfield2);
$("#OtherField3").val(materialInfo[23] == "undefined" ? "" : materialInfo[23]); $("#OtherField3").val(rowsdata.otherfield3);
$("#Unit").val(materialInfo[4] == "undefined" ? "" : materialInfo[4]); $("#Unit").val(rowsdata.unit);
$("#RetailPrice").val(materialInfo[5] == "undefined" ? "" : materialInfo[5]); $("#RetailPrice").val(rowsdata.retailprice);
$("#LowPrice").val(materialInfo[6] == "undefined" ? "" : materialInfo[6]); $("#LowPrice").val(rowsdata.lowprice);
$("#PresetPriceOne").val(materialInfo[7] == "undefined" ? "" : materialInfo[7]); $("#PresetPriceOne").val(rowsdata.presetpriceone);
$("#PresetPriceTwo").val(materialInfo[8] == "undefined" ? "" : materialInfo[8]); $("#PresetPriceTwo").val(rowsdata.presetpricetwo);
$("#Remark").val(materialInfo[9]); $("#Remark").val(rowsdata.remark);
$("#manyUnit").val(materialInfo[16]); $("#manyUnit").val(rowsdata.unitid);
if (materialInfo[16] != "undefined") { if (rowsdata.unitid) {
$("#manyUnitCheck").prop("checked", true); $("#manyUnitCheck").prop("checked", true);
//当前为选中状态 //当前为选中状态
$("#Unit").hide(); $("#Unit").hide();
@@ -1336,10 +1342,10 @@
var basic = '<option value="' + arr[0] + '">' + arr[0] + '</option>'; var basic = '<option value="' + arr[0] + '">' + arr[0] + '</option>';
var other = '<option value="' + arr[1] + '">' + arr[1] + '</option>'; var other = '<option value="' + arr[1] + '">' + arr[1] + '</option>';
firstOptions = firstOptions + basic + other; firstOptions = firstOptions + basic + other;
$("#FirstOutUnit").empty().append('<option value="">(空)</option>').append(firstOptions); //首选出库单位 $("#FirstOutUnit").empty().append('<option value="">(空)</option>').append(firstOptions); //首选销售单位
$("#FirstInUnit").empty().append('<option value="">(空)</option>').append(firstOptions); //首选入库单位 $("#FirstInUnit").empty().append('<option value="">(空)</option>').append(firstOptions); //首选采购单位
$("#FirstOutUnit").val(materialInfo[18]);//首选出库单位 $("#FirstOutUnit").val(rowsdata.firstoutunit);//首选销售单位
$("#FirstInUnit").val(materialInfo[19]);//首选入库单位 $("#FirstInUnit").val(rowsdata.firstinunit);//首选采购单位
} }
} }
else { else {
@@ -1356,7 +1362,7 @@
$.ajax({ $.ajax({
url: '/material/findById', url: '/material/findById',
data: { data: {
id: materialInfo[0] id: rowsdata.id
}, },
type: "get", type: "get",
dataType: "json", dataType: "json",
@@ -1385,26 +1391,53 @@
} }
}); });
oldName = materialInfo[1]; oldName = rowsdata.name;
oldModel = materialInfo[2]; oldModel = rowsdata.model;
oldColor = materialInfo[11]; oldColor = rowsdata.color;
oldStandard = materialInfo[10]; oldStandard = rowsdata.standard;
oldMfrs = materialInfo[20]; oldMfrs = rowsdata.mfrs;
oldOtherField1 = materialInfo[21]; oldOtherField1 = rowsdata.otherfield1;
oldOtherField2 = materialInfo[22]; oldOtherField2 = rowsdata.otherfield2;
oldOtherField3 = materialInfo[23]; oldOtherField3 = rowsdata.otherfield3;
oldUnit = materialInfo[4]; oldUnit = rowsdata.unit;
oldManyUnit = materialInfo[16]; oldManyUnit = rowsdata.unitid;
$('#materialDlg').dialog('open').dialog('setTitle', '<img src="/js/easyui-1.3.5/themes/icons/pencil.png"/>&nbsp;编辑商品信息'); $('#materialDlg').dialog('open').dialog('setTitle', '<img src="/js/easyui-1.3.5/themes/icons/pencil.png"/>&nbsp;编辑商品信息');
$(".window-mask").css({width: webW, height: webH}); $(".window-mask").css({width: webW, height: webH});
materialID = materialInfo[0]; materialID = rowsdata.id;
//焦点在名称输入框==定焦在输入文字后面 //焦点在名称输入框==定焦在输入文字后面
$("#Name").val("").focus().val(materialInfo[1]); $("#Name").val("").focus().val(rowsdata.name);
//选中基本资料tab //选中基本资料tab
$("#materialFM #tt .tabs li").first().click(); $("#materialFM #tt .tabs li").first().click();
url = '/material/update?id=' + materialInfo[0]; url = '/material/update?id=' + rowsdata.id;
initDepotList(rowsdata.id); //加载仓库列表页面
} }
function initDepotList(mId) {
$.ajax({
type: "get",
url: "/depot/getAllListWithStock?mId=" + mId,
dataType: "json",
async: false,
success: function (res) {
if (res && res.code == 200) {
var json = {};
json.depotList = res.data;
$.ajax({
type: "get",
url: "../../../pages/template/init_depot_list.html?616",
async: false,
success: function (tem) {
if (tem) {
var template = Handlebars.compile(tem);
var htmlValue = template(json);
$("#initDepot").html(htmlValue);
}
}
});
}
}
});
}
//搜索处理 //搜索处理
$("#searchBtn").unbind().bind({ $("#searchBtn").unbind().bind({
@@ -1501,8 +1534,8 @@
var basic = '<option value="' + arr[0] + '">' + arr[0] + '</option>'; var basic = '<option value="' + arr[0] + '">' + arr[0] + '</option>';
var other = '<option value="' + arr[1] + '">' + arr[1] + '</option>'; var other = '<option value="' + arr[1] + '">' + arr[1] + '</option>';
firstOptions = firstOptions + basic + other; firstOptions = firstOptions + basic + other;
$("#FirstOutUnit").empty().append('<option value="">(空)</option>').append(firstOptions); //首选出库单位 $("#FirstOutUnit").empty().append('<option value="">(空)</option>').append(firstOptions); //首选销售单位
$("#FirstInUnit").empty().append('<option value="">(空)</option>').append(firstOptions); //首选入库单位 $("#FirstInUnit").empty().append('<option value="">(空)</option>').append(firstOptions); //首选采购单位
$("#basicUnit").text(arr[0]); $("#basicUnit").text(arr[0]);
$("#otherUnit").text(arr[1]); $("#otherUnit").text(arr[1]);
} }

View File

@@ -0,0 +1,10 @@
<table>
{{#depotList}}
<tr>
<td style="width:100px;float:left;">{{name}}</td>
<td>
<input type="text" id="depot{{id}}" data-id="{{id}}" style="height: 20px;" value="{{stock}}"/>
</td>
</tr>
{{/depotList}}
</table>

Binary file not shown.

View File

@@ -12,6 +12,7 @@ import com.jsh.erp.datasource.entities.Depot;
import com.jsh.erp.datasource.entities.DepotEx; import com.jsh.erp.datasource.entities.DepotEx;
import com.jsh.erp.exception.BusinessRunTimeException; import com.jsh.erp.exception.BusinessRunTimeException;
import com.jsh.erp.service.depot.DepotService; import com.jsh.erp.service.depot.DepotService;
import com.jsh.erp.service.material.MaterialService;
import com.jsh.erp.service.systemConfig.SystemConfigService; import com.jsh.erp.service.systemConfig.SystemConfigService;
import com.jsh.erp.service.userBusiness.UserBusinessService; import com.jsh.erp.service.userBusiness.UserBusinessService;
import com.jsh.erp.utils.*; import com.jsh.erp.utils.*;
@@ -23,6 +24,7 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.io.IOException; import java.io.IOException;
import java.math.BigDecimal;
import java.util.*; import java.util.*;
import static com.jsh.erp.utils.ResponseJsonUtil.returnJson; import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
@@ -44,6 +46,9 @@ public class DepotController {
@Resource @Resource
private SystemConfigService systemConfigService; private SystemConfigService systemConfigService;
@Resource
private MaterialService materialService;
@GetMapping(value = "/getAllList") @GetMapping(value = "/getAllList")
public BaseResponseInfo getAllList(HttpServletRequest request) throws Exception{ public BaseResponseInfo getAllList(HttpServletRequest request) throws Exception{
BaseResponseInfo res = new BaseResponseInfo(); BaseResponseInfo res = new BaseResponseInfo();
@@ -232,4 +237,33 @@ public class DepotController {
return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code); return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
} }
} }
@GetMapping(value = "/getAllListWithStock")
public BaseResponseInfo getAllList(@RequestParam("mId") Long mId,
HttpServletRequest request) {
BaseResponseInfo res = new BaseResponseInfo();
try {
List<Depot> list = depotService.getAllList();
List<DepotEx> depotList = new ArrayList<DepotEx>();
for(Depot depot: list) {
DepotEx de = new DepotEx();
if(mId!=0) {
BigDecimal stock = materialService.getInitStock(mId, depot.getId());
de.setStock(stock);
} else {
de.setStock(BigDecimal.ZERO);
}
de.setId(depot.getId());
de.setName(depot.getName());
depotList.add(de);
}
res.code = 200;
res.data = depotList;
} catch(Exception e){
e.printStackTrace();
res.code = 500;
res.data = "获取数据失败";
}
return res;
}
} }

View File

@@ -233,7 +233,7 @@ public class MaterialController {
} }
/** /**
* excel表格导入 * excel表格导入产品(含初始库存)
* @param materialFile * @param materialFile
* @param request * @param request
* @param response * @param response
@@ -257,30 +257,7 @@ public class MaterialController {
info.code = 400; info.code = 400;
info.data = data; info.data = data;
} }
//每行中数据顺序 "品名","类型","型号","安全存量","单位","零售价","最低售价","预计采购价","批发价","备注","状态" info = materialService.importExcel(src);
List<Material> mList = new ArrayList<Material>();
for (int i = 1; i < src.getRows(); i++) {
Material m = new Material();
m.setName(ExcelUtils.getContent(src, i, 0));
m.setCategoryid(1L); //根目录
m.setModel(ExcelUtils.getContent(src, i, 2));
String safetyStock = ExcelUtils.getContent(src, i, 3);
m.setSafetystock(parseBigDecimalEx(safetyStock));
m.setUnit(ExcelUtils.getContent(src, i, 4));
String retailprice = ExcelUtils.getContent(src, i, 5);
m.setRetailprice(parseBigDecimalEx(retailprice));
String lowPrice = ExcelUtils.getContent(src, i, 6);
m.setLowprice(parseBigDecimalEx(lowPrice));
String presetpriceone = ExcelUtils.getContent(src, i, 7);
m.setPresetpriceone(parseBigDecimalEx(presetpriceone));
String presetpricetwo = ExcelUtils.getContent(src, i, 8);
m.setPresetpricetwo(parseBigDecimalEx(presetpricetwo));
m.setRemark(ExcelUtils.getContent(src, i, 9));
String enabled = ExcelUtils.getContent(src, i, 10);
m.setEnabled(enabled.equals("启用")? true: false);
mList.add(m);
}
info = materialService.importExcel(mList);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
message = "导入失败"; message = "导入失败";

View File

@@ -1,5 +1,7 @@
package com.jsh.erp.datasource.entities; package com.jsh.erp.datasource.entities;
import java.math.BigDecimal;
/** /**
* Description * Description
* *
@@ -10,6 +12,8 @@ public class DepotEx extends Depot{
//负责人名字 //负责人名字
private String principalName; private String principalName;
private BigDecimal stock;
public String getPrincipalName() { public String getPrincipalName() {
return principalName; return principalName;
} }
@@ -17,4 +21,12 @@ public class DepotEx extends Depot{
public void setPrincipalName(String principalName) { public void setPrincipalName(String principalName) {
this.principalName = principalName; this.principalName = principalName;
} }
public BigDecimal getStock() {
return stock;
}
public void setStock(BigDecimal stock) {
this.stock = stock;
}
} }

View File

@@ -0,0 +1,197 @@
package com.jsh.erp.datasource.entities;
import java.math.BigDecimal;
public class MaterialStock {
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column jsh_material_stock.id
*
* @mbggenerated
*/
private Long id;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column jsh_material_stock.material_id
*
* @mbggenerated
*/
private Long materialId;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column jsh_material_stock.depot_id
*
* @mbggenerated
*/
private Long depotId;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column jsh_material_stock.number
*
* @mbggenerated
*/
private BigDecimal number;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column jsh_material_stock.tenant_id
*
* @mbggenerated
*/
private Long tenantId;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column jsh_material_stock.delete_fag
*
* @mbggenerated
*/
private String deleteFag;
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column jsh_material_stock.id
*
* @return the value of jsh_material_stock.id
*
* @mbggenerated
*/
public Long getId() {
return id;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column jsh_material_stock.id
*
* @param id the value for jsh_material_stock.id
*
* @mbggenerated
*/
public void setId(Long id) {
this.id = id;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column jsh_material_stock.material_id
*
* @return the value of jsh_material_stock.material_id
*
* @mbggenerated
*/
public Long getMaterialId() {
return materialId;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column jsh_material_stock.material_id
*
* @param materialId the value for jsh_material_stock.material_id
*
* @mbggenerated
*/
public void setMaterialId(Long materialId) {
this.materialId = materialId;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column jsh_material_stock.depot_id
*
* @return the value of jsh_material_stock.depot_id
*
* @mbggenerated
*/
public Long getDepotId() {
return depotId;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column jsh_material_stock.depot_id
*
* @param depotId the value for jsh_material_stock.depot_id
*
* @mbggenerated
*/
public void setDepotId(Long depotId) {
this.depotId = depotId;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column jsh_material_stock.number
*
* @return the value of jsh_material_stock.number
*
* @mbggenerated
*/
public BigDecimal getNumber() {
return number;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column jsh_material_stock.number
*
* @param number the value for jsh_material_stock.number
*
* @mbggenerated
*/
public void setNumber(BigDecimal number) {
this.number = number;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column jsh_material_stock.tenant_id
*
* @return the value of jsh_material_stock.tenant_id
*
* @mbggenerated
*/
public Long getTenantId() {
return tenantId;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column jsh_material_stock.tenant_id
*
* @param tenantId the value for jsh_material_stock.tenant_id
*
* @mbggenerated
*/
public void setTenantId(Long tenantId) {
this.tenantId = tenantId;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column jsh_material_stock.delete_fag
*
* @return the value of jsh_material_stock.delete_fag
*
* @mbggenerated
*/
public String getDeleteFag() {
return deleteFag;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column jsh_material_stock.delete_fag
*
* @param deleteFag the value for jsh_material_stock.delete_fag
*
* @mbggenerated
*/
public void setDeleteFag(String deleteFag) {
this.deleteFag = deleteFag == null ? null : deleteFag.trim();
}
}

View File

@@ -0,0 +1,673 @@
package com.jsh.erp.datasource.entities;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
public class MaterialStockExample {
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table jsh_material_stock
*
* @mbggenerated
*/
protected String orderByClause;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table jsh_material_stock
*
* @mbggenerated
*/
protected boolean distinct;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table jsh_material_stock
*
* @mbggenerated
*/
protected List<Criteria> oredCriteria;
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_material_stock
*
* @mbggenerated
*/
public MaterialStockExample() {
oredCriteria = new ArrayList<Criteria>();
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_material_stock
*
* @mbggenerated
*/
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_material_stock
*
* @mbggenerated
*/
public String getOrderByClause() {
return orderByClause;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_material_stock
*
* @mbggenerated
*/
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_material_stock
*
* @mbggenerated
*/
public boolean isDistinct() {
return distinct;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_material_stock
*
* @mbggenerated
*/
public List<Criteria> getOredCriteria() {
return oredCriteria;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_material_stock
*
* @mbggenerated
*/
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_material_stock
*
* @mbggenerated
*/
public Criteria or() {
Criteria criteria = createCriteriaInternal();
oredCriteria.add(criteria);
return criteria;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_material_stock
*
* @mbggenerated
*/
public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if (oredCriteria.size() == 0) {
oredCriteria.add(criteria);
}
return criteria;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_material_stock
*
* @mbggenerated
*/
protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria();
return criteria;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_material_stock
*
* @mbggenerated
*/
public void clear() {
oredCriteria.clear();
orderByClause = null;
distinct = false;
}
/**
* This class was generated by MyBatis Generator.
* This class corresponds to the database table jsh_material_stock
*
* @mbggenerated
*/
protected abstract static class GeneratedCriteria {
protected List<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<Criterion>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> getCriteria() {
return criteria;
}
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
}
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andIdIsNull() {
addCriterion("id is null");
return (Criteria) this;
}
public Criteria andIdIsNotNull() {
addCriterion("id is not null");
return (Criteria) this;
}
public Criteria andIdEqualTo(Long value) {
addCriterion("id =", value, "id");
return (Criteria) this;
}
public Criteria andIdNotEqualTo(Long value) {
addCriterion("id <>", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThan(Long value) {
addCriterion("id >", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThanOrEqualTo(Long value) {
addCriterion("id >=", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThan(Long value) {
addCriterion("id <", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThanOrEqualTo(Long value) {
addCriterion("id <=", value, "id");
return (Criteria) this;
}
public Criteria andIdIn(List<Long> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<Long> values) {
addCriterion("id not in", values, "id");
return (Criteria) this;
}
public Criteria andIdBetween(Long value1, Long value2) {
addCriterion("id between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andIdNotBetween(Long value1, Long value2) {
addCriterion("id not between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andMaterialIdIsNull() {
addCriterion("material_id is null");
return (Criteria) this;
}
public Criteria andMaterialIdIsNotNull() {
addCriterion("material_id is not null");
return (Criteria) this;
}
public Criteria andMaterialIdEqualTo(Long value) {
addCriterion("material_id =", value, "materialId");
return (Criteria) this;
}
public Criteria andMaterialIdNotEqualTo(Long value) {
addCriterion("material_id <>", value, "materialId");
return (Criteria) this;
}
public Criteria andMaterialIdGreaterThan(Long value) {
addCriterion("material_id >", value, "materialId");
return (Criteria) this;
}
public Criteria andMaterialIdGreaterThanOrEqualTo(Long value) {
addCriterion("material_id >=", value, "materialId");
return (Criteria) this;
}
public Criteria andMaterialIdLessThan(Long value) {
addCriterion("material_id <", value, "materialId");
return (Criteria) this;
}
public Criteria andMaterialIdLessThanOrEqualTo(Long value) {
addCriterion("material_id <=", value, "materialId");
return (Criteria) this;
}
public Criteria andMaterialIdIn(List<Long> values) {
addCriterion("material_id in", values, "materialId");
return (Criteria) this;
}
public Criteria andMaterialIdNotIn(List<Long> values) {
addCriterion("material_id not in", values, "materialId");
return (Criteria) this;
}
public Criteria andMaterialIdBetween(Long value1, Long value2) {
addCriterion("material_id between", value1, value2, "materialId");
return (Criteria) this;
}
public Criteria andMaterialIdNotBetween(Long value1, Long value2) {
addCriterion("material_id not between", value1, value2, "materialId");
return (Criteria) this;
}
public Criteria andDepotIdIsNull() {
addCriterion("depot_id is null");
return (Criteria) this;
}
public Criteria andDepotIdIsNotNull() {
addCriterion("depot_id is not null");
return (Criteria) this;
}
public Criteria andDepotIdEqualTo(Long value) {
addCriterion("depot_id =", value, "depotId");
return (Criteria) this;
}
public Criteria andDepotIdNotEqualTo(Long value) {
addCriterion("depot_id <>", value, "depotId");
return (Criteria) this;
}
public Criteria andDepotIdGreaterThan(Long value) {
addCriterion("depot_id >", value, "depotId");
return (Criteria) this;
}
public Criteria andDepotIdGreaterThanOrEqualTo(Long value) {
addCriterion("depot_id >=", value, "depotId");
return (Criteria) this;
}
public Criteria andDepotIdLessThan(Long value) {
addCriterion("depot_id <", value, "depotId");
return (Criteria) this;
}
public Criteria andDepotIdLessThanOrEqualTo(Long value) {
addCriterion("depot_id <=", value, "depotId");
return (Criteria) this;
}
public Criteria andDepotIdIn(List<Long> values) {
addCriterion("depot_id in", values, "depotId");
return (Criteria) this;
}
public Criteria andDepotIdNotIn(List<Long> values) {
addCriterion("depot_id not in", values, "depotId");
return (Criteria) this;
}
public Criteria andDepotIdBetween(Long value1, Long value2) {
addCriterion("depot_id between", value1, value2, "depotId");
return (Criteria) this;
}
public Criteria andDepotIdNotBetween(Long value1, Long value2) {
addCriterion("depot_id not between", value1, value2, "depotId");
return (Criteria) this;
}
public Criteria andNumberIsNull() {
addCriterion("number is null");
return (Criteria) this;
}
public Criteria andNumberIsNotNull() {
addCriterion("number is not null");
return (Criteria) this;
}
public Criteria andNumberEqualTo(BigDecimal value) {
addCriterion("number =", value, "number");
return (Criteria) this;
}
public Criteria andNumberNotEqualTo(BigDecimal value) {
addCriterion("number <>", value, "number");
return (Criteria) this;
}
public Criteria andNumberGreaterThan(BigDecimal value) {
addCriterion("number >", value, "number");
return (Criteria) this;
}
public Criteria andNumberGreaterThanOrEqualTo(BigDecimal value) {
addCriterion("number >=", value, "number");
return (Criteria) this;
}
public Criteria andNumberLessThan(BigDecimal value) {
addCriterion("number <", value, "number");
return (Criteria) this;
}
public Criteria andNumberLessThanOrEqualTo(BigDecimal value) {
addCriterion("number <=", value, "number");
return (Criteria) this;
}
public Criteria andNumberIn(List<BigDecimal> values) {
addCriterion("number in", values, "number");
return (Criteria) this;
}
public Criteria andNumberNotIn(List<BigDecimal> values) {
addCriterion("number not in", values, "number");
return (Criteria) this;
}
public Criteria andNumberBetween(BigDecimal value1, BigDecimal value2) {
addCriterion("number between", value1, value2, "number");
return (Criteria) this;
}
public Criteria andNumberNotBetween(BigDecimal value1, BigDecimal value2) {
addCriterion("number not between", value1, value2, "number");
return (Criteria) this;
}
public Criteria andTenantIdIsNull() {
addCriterion("tenant_id is null");
return (Criteria) this;
}
public Criteria andTenantIdIsNotNull() {
addCriterion("tenant_id is not null");
return (Criteria) this;
}
public Criteria andTenantIdEqualTo(Long value) {
addCriterion("tenant_id =", value, "tenantId");
return (Criteria) this;
}
public Criteria andTenantIdNotEqualTo(Long value) {
addCriterion("tenant_id <>", value, "tenantId");
return (Criteria) this;
}
public Criteria andTenantIdGreaterThan(Long value) {
addCriterion("tenant_id >", value, "tenantId");
return (Criteria) this;
}
public Criteria andTenantIdGreaterThanOrEqualTo(Long value) {
addCriterion("tenant_id >=", value, "tenantId");
return (Criteria) this;
}
public Criteria andTenantIdLessThan(Long value) {
addCriterion("tenant_id <", value, "tenantId");
return (Criteria) this;
}
public Criteria andTenantIdLessThanOrEqualTo(Long value) {
addCriterion("tenant_id <=", value, "tenantId");
return (Criteria) this;
}
public Criteria andTenantIdIn(List<Long> values) {
addCriterion("tenant_id in", values, "tenantId");
return (Criteria) this;
}
public Criteria andTenantIdNotIn(List<Long> values) {
addCriterion("tenant_id not in", values, "tenantId");
return (Criteria) this;
}
public Criteria andTenantIdBetween(Long value1, Long value2) {
addCriterion("tenant_id between", value1, value2, "tenantId");
return (Criteria) this;
}
public Criteria andTenantIdNotBetween(Long value1, Long value2) {
addCriterion("tenant_id not between", value1, value2, "tenantId");
return (Criteria) this;
}
public Criteria andDeleteFagIsNull() {
addCriterion("delete_fag is null");
return (Criteria) this;
}
public Criteria andDeleteFagIsNotNull() {
addCriterion("delete_fag is not null");
return (Criteria) this;
}
public Criteria andDeleteFagEqualTo(String value) {
addCriterion("delete_fag =", value, "deleteFag");
return (Criteria) this;
}
public Criteria andDeleteFagNotEqualTo(String value) {
addCriterion("delete_fag <>", value, "deleteFag");
return (Criteria) this;
}
public Criteria andDeleteFagGreaterThan(String value) {
addCriterion("delete_fag >", value, "deleteFag");
return (Criteria) this;
}
public Criteria andDeleteFagGreaterThanOrEqualTo(String value) {
addCriterion("delete_fag >=", value, "deleteFag");
return (Criteria) this;
}
public Criteria andDeleteFagLessThan(String value) {
addCriterion("delete_fag <", value, "deleteFag");
return (Criteria) this;
}
public Criteria andDeleteFagLessThanOrEqualTo(String value) {
addCriterion("delete_fag <=", value, "deleteFag");
return (Criteria) this;
}
public Criteria andDeleteFagLike(String value) {
addCriterion("delete_fag like", value, "deleteFag");
return (Criteria) this;
}
public Criteria andDeleteFagNotLike(String value) {
addCriterion("delete_fag not like", value, "deleteFag");
return (Criteria) this;
}
public Criteria andDeleteFagIn(List<String> values) {
addCriterion("delete_fag in", values, "deleteFag");
return (Criteria) this;
}
public Criteria andDeleteFagNotIn(List<String> values) {
addCriterion("delete_fag not in", values, "deleteFag");
return (Criteria) this;
}
public Criteria andDeleteFagBetween(String value1, String value2) {
addCriterion("delete_fag between", value1, value2, "deleteFag");
return (Criteria) this;
}
public Criteria andDeleteFagNotBetween(String value1, String value2) {
addCriterion("delete_fag not between", value1, value2, "deleteFag");
return (Criteria) this;
}
}
/**
* This class was generated by MyBatis Generator.
* This class corresponds to the database table jsh_material_stock
*
* @mbggenerated do_not_delete_during_merge
*/
public static class Criteria extends GeneratedCriteria {
protected Criteria() {
super();
}
}
/**
* This class was generated by MyBatis Generator.
* This class corresponds to the database table jsh_material_stock
*
* @mbggenerated
*/
public static class Criterion {
private String condition;
private Object value;
private Object secondValue;
private boolean noValue;
private boolean singleValue;
private boolean betweenValue;
private boolean listValue;
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
this.typeHandler = null;
this.noValue = true;
}
protected Criterion(String condition, Object value, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.typeHandler = typeHandler;
if (value instanceof List<?>) {
this.listValue = true;
} else {
this.singleValue = true;
}
}
protected Criterion(String condition, Object value) {
this(condition, value, null);
}
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.secondValue = secondValue;
this.typeHandler = typeHandler;
this.betweenValue = true;
}
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
}
}

View File

@@ -0,0 +1,17 @@
package com.jsh.erp.datasource.entities;
import java.math.BigDecimal;
import java.util.Map;
public class MaterialWithInitStock extends Material {
private Map<Long, BigDecimal> stockMap;
public Map<Long, BigDecimal> getStockMap() {
return stockMap;
}
public void setStockMap(Map<Long, BigDecimal> stockMap) {
this.stockMap = stockMap;
}
}

View File

@@ -59,4 +59,6 @@ public interface MaterialMapperEx {
List<Material> getMaterialListByCategoryIds(@Param("categoryIds") String[] categoryIds); List<Material> getMaterialListByCategoryIds(@Param("categoryIds") String[] categoryIds);
List<Material> getMaterialListByUnitIds(@Param("unitIds") String[] unitIds); List<Material> getMaterialListByUnitIds(@Param("unitIds") String[] unitIds);
int insertSelectiveEx(Material record);
} }

View File

@@ -0,0 +1,96 @@
package com.jsh.erp.datasource.mappers;
import com.jsh.erp.datasource.entities.MaterialStock;
import com.jsh.erp.datasource.entities.MaterialStockExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface MaterialStockMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_material_stock
*
* @mbggenerated
*/
int countByExample(MaterialStockExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_material_stock
*
* @mbggenerated
*/
int deleteByExample(MaterialStockExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_material_stock
*
* @mbggenerated
*/
int deleteByPrimaryKey(Long id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_material_stock
*
* @mbggenerated
*/
int insert(MaterialStock record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_material_stock
*
* @mbggenerated
*/
int insertSelective(MaterialStock record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_material_stock
*
* @mbggenerated
*/
List<MaterialStock> selectByExample(MaterialStockExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_material_stock
*
* @mbggenerated
*/
MaterialStock selectByPrimaryKey(Long id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_material_stock
*
* @mbggenerated
*/
int updateByExampleSelective(@Param("record") MaterialStock record, @Param("example") MaterialStockExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_material_stock
*
* @mbggenerated
*/
int updateByExample(@Param("record") MaterialStock record, @Param("example") MaterialStockExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_material_stock
*
* @mbggenerated
*/
int updateByPrimaryKeySelective(MaterialStock record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_material_stock
*
* @mbggenerated
*/
int updateByPrimaryKey(MaterialStock record);
}

View File

@@ -292,4 +292,19 @@ public class DepotService {
} }
return result; return result;
} }
/**
* 根据名称获取id
* @param name
*/
public Long getIdByName(String name){
Long id = 0L;
DepotExample example = new DepotExample();
example.createCriteria().andNameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
List<Depot> list = depotMapper.selectByExample(example);
if(list!=null && list.size()>0) {
id = list.get(0).getId();
}
return id;
}
} }

View File

@@ -663,10 +663,12 @@ public class DepotItemService {
* @return * @return
*/ */
public BigDecimal getStockByParam(Long depotId, Long mId, String beginTime, String endTime, Long tenantId){ public BigDecimal getStockByParam(Long depotId, Long mId, String beginTime, String endTime, Long tenantId){
//初始库存
BigDecimal initStock = materialService.getInitStockByMid(depotId, mId);
DepotItemVo4Stock stockObj = depotItemMapperEx.getStockByParam(depotId, mId, beginTime, endTime, tenantId); DepotItemVo4Stock stockObj = depotItemMapperEx.getStockByParam(depotId, mId, beginTime, endTime, tenantId);
BigDecimal intNum = stockObj.getInNum(); BigDecimal intNum = stockObj.getInNum();
BigDecimal outNum = stockObj.getOutNum(); BigDecimal outNum = stockObj.getOutNum();
return intNum.subtract(outNum); return initStock.add(intNum).subtract(outNum);
} }
/** /**

View File

@@ -1,5 +1,7 @@
package com.jsh.erp.service.material; package com.jsh.erp.service.material;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.jsh.erp.constants.BusinessConstants; import com.jsh.erp.constants.BusinessConstants;
@@ -8,13 +10,19 @@ import com.jsh.erp.datasource.entities.*;
import com.jsh.erp.datasource.mappers.DepotItemMapperEx; import com.jsh.erp.datasource.mappers.DepotItemMapperEx;
import com.jsh.erp.datasource.mappers.MaterialMapper; import com.jsh.erp.datasource.mappers.MaterialMapper;
import com.jsh.erp.datasource.mappers.MaterialMapperEx; import com.jsh.erp.datasource.mappers.MaterialMapperEx;
import com.jsh.erp.datasource.mappers.MaterialStockMapper;
import com.jsh.erp.exception.BusinessRunTimeException; import com.jsh.erp.exception.BusinessRunTimeException;
import com.jsh.erp.exception.JshException; import com.jsh.erp.exception.JshException;
import com.jsh.erp.service.depot.DepotService;
import com.jsh.erp.service.depotItem.DepotItemService; import com.jsh.erp.service.depotItem.DepotItemService;
import com.jsh.erp.service.log.LogService; import com.jsh.erp.service.log.LogService;
import com.jsh.erp.service.materialCategory.MaterialCategoryService;
import com.jsh.erp.service.unit.UnitService;
import com.jsh.erp.service.user.UserService; import com.jsh.erp.service.user.UserService;
import com.jsh.erp.utils.BaseResponseInfo; import com.jsh.erp.utils.BaseResponseInfo;
import com.jsh.erp.utils.ExcelUtils;
import com.jsh.erp.utils.StringUtil; import com.jsh.erp.utils.StringUtil;
import jxl.Sheet;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -24,6 +32,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.*; import java.util.*;
@Service @Service
@@ -42,6 +51,14 @@ public class MaterialService {
private DepotItemMapperEx depotItemMapperEx; private DepotItemMapperEx depotItemMapperEx;
@Resource @Resource
private DepotItemService depotItemService; private DepotItemService depotItemService;
@Resource
private MaterialCategoryService materialCategoryService;
@Resource
private UnitService unitService;
@Resource
private MaterialStockMapper materialStockMapper;
@Resource
private DepotService depotService;
public Material getMaterial(long id)throws Exception { public Material getMaterial(long id)throws Exception {
Material result=null; Material result=null;
@@ -125,6 +142,22 @@ public class MaterialService {
int result =0; int result =0;
try{ try{
result= materialMapper.insertSelective(material); result= materialMapper.insertSelective(material);
JSONObject mObj = JSON.parseObject(beanJson);
Long mId = material.getId();
if(mObj.get("stock")!=null) {
String stockStr = mObj.getString("stock");
JSONArray stockArr = JSONArray.parseArray(stockStr);
for(Object object: stockArr) {
JSONObject jsonObj = (JSONObject)object;
if(jsonObj.get("depotId")!=null && jsonObj.get("number")!=null) {
String number = jsonObj.getString("number");
Long depotId = jsonObj.getLong("depotId");
if(number!=null && Double.valueOf(number)>0) {
insertStockByMaterialAndDepot(depotId, mId, parseBigDecimalEx(number));
}
}
}
}
logService.insertLog("商品", BusinessConstants.LOG_OPERATION_TYPE_ADD, request); logService.insertLog("商品", BusinessConstants.LOG_OPERATION_TYPE_ADD, request);
}catch(Exception e){ }catch(Exception e){
JshException.writeFail(logger, e); JshException.writeFail(logger, e);
@@ -145,6 +178,25 @@ public class MaterialService {
} else { } else {
materialMapperEx.updateUnitIdNullByPrimaryKey(id); //将多单位置空 materialMapperEx.updateUnitIdNullByPrimaryKey(id); //将多单位置空
} }
JSONObject mObj = JSON.parseObject(beanJson);
if(mObj.get("stock")!=null) {
String stockStr = mObj.getString("stock");
JSONArray stockArr = JSONArray.parseArray(stockStr);
for (Object object : stockArr) {
JSONObject jsonObj = (JSONObject) object;
if (jsonObj.get("depotId") != null && jsonObj.get("number") != null) {
String number = jsonObj.getString("number");
Long depotId = jsonObj.getLong("depotId");
//先清除再插入
MaterialStockExample example = new MaterialStockExample();
example.createCriteria().andMaterialIdEqualTo(id).andDepotIdEqualTo(depotId);
materialStockMapper.deleteByExample(example);
if (number != null && Double.valueOf(number) > 0) {
insertStockByMaterialAndDepot(depotId, id, parseBigDecimalEx(number));
}
}
}
}
logService.insertLog("商品", logService.insertLog("商品",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(id).toString(), request); new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(id).toString(), request);
}catch(Exception e){ }catch(Exception e){
@@ -296,21 +348,127 @@ public class MaterialService {
} }
return resList; return resList;
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public BaseResponseInfo importExcel(List<Material> mList) throws Exception { public BaseResponseInfo importExcel(Sheet src) throws Exception {
List<Depot> depotList= depotService.getDepot();
int depotCount = depotList.size();
List<MaterialWithInitStock> mList = new ArrayList<MaterialWithInitStock>();
for (int i = 2; i < src.getRows(); i++) {
String name = ExcelUtils.getContent(src, i, 0); //名称
String model = ExcelUtils.getContent(src, i, 1); //型号
String categoryName = ExcelUtils.getContent(src, i, 2); //类型
String safetyStock = ExcelUtils.getContent(src, i, 3); //安全存量
String color = ExcelUtils.getContent(src, i, 4); //颜色
String unit = ExcelUtils.getContent(src, i, 5); //单位
//校验名称、型号、单位是否为空
if(StringUtil.isNotEmpty(name) && StringUtil.isNotEmpty(model) && StringUtil.isNotEmpty(unit)) {
MaterialWithInitStock m = new MaterialWithInitStock();
m.setName(name);
m.setModel(model);
Long categoryId = materialCategoryService.getCategoryIdByName(categoryName);
m.setCategoryid(categoryId);
m.setSafetystock(parseBigDecimalEx(safetyStock));
m.setColor(color);
String manyUnit = ExcelUtils.getContent(src, i, 6); //多单位
String ratio = ExcelUtils.getContent(src, i, 7); //比例
String retailPrice = ExcelUtils.getContent(src, i, 8); //零售价
String lowPrice = ExcelUtils.getContent(src, i, 9); //最低售价
String presetpriceone = ExcelUtils.getContent(src, i, 10); //预计采购价
String presetpricetwo = ExcelUtils.getContent(src, i, 11); //销售价
if(StringUtil.isNotEmpty(manyUnit.trim())){ //多单位
String manyUnitAll = unit + "," + manyUnit + "(1:" + ratio + ")";
Long unitId = unitService.getUnitIdByName(manyUnitAll);
m.setUnitid(unitId);
m.setFirstoutunit(unit); //首选出库单位
m.setFirstinunit(manyUnit); //首选入库单位
JSONArray arr = new JSONArray();
JSONObject basicObj = new JSONObject();
basicObj.put("Unit", unit);
basicObj.put("RetailPrice", retailPrice);
basicObj.put("LowPrice", lowPrice);
basicObj.put("PresetPriceOne", presetpriceone);
basicObj.put("PresetPriceTwo", presetpricetwo);
JSONObject basicObjEx = new JSONObject();
basicObjEx.put("basic", basicObj);
JSONObject otherObj = new JSONObject();
otherObj.put("Unit", manyUnit);
otherObj.put("RetailPrice", parsePrice(retailPrice,ratio));
otherObj.put("LowPrice", parsePrice(lowPrice,ratio));
otherObj.put("PresetPriceOne", parsePrice(presetpriceone,ratio));
otherObj.put("PresetPriceTwo", parsePrice(presetpricetwo,ratio));
JSONObject otherObjEx = new JSONObject();
otherObjEx.put("other", otherObj);
arr.add(basicObjEx);
arr.add(otherObjEx);
m.setPricestrategy(arr.toJSONString());
} else {
m.setUnit(unit);
m.setRetailprice(parseBigDecimalEx(retailPrice));
m.setLowprice(parseBigDecimalEx(lowPrice));
m.setPresetpriceone(parseBigDecimalEx(presetpriceone));
m.setPresetpricetwo(parseBigDecimalEx(presetpricetwo));
}
String enabled = ExcelUtils.getContent(src, i, 12); //状态
m.setEnabled(enabled.equals("1")? true: false);
//缓存各个仓库的库存信息
Map<Long, BigDecimal> stockMap = new HashMap<Long, BigDecimal>();
for(int j=1; j<=depotCount;j++) {
int col = 12+j;
if(col <= src.getColumns()){
String depotName = ExcelUtils.getContent(src, 1, col); //获取仓库名称
Long depotId = depotService.getIdByName(depotName);
if(depotId!=0L){
String stockStr = ExcelUtils.getContent(src, i, col);
if(StringUtil.isNotEmpty(stockStr)) {
stockMap.put(depotId, parseBigDecimalEx(stockStr));
}
}
}
}
m.setStockMap(stockMap);
mList.add(m);
}
}
logService.insertLog("商品", logService.insertLog("商品",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_IMPORT).append(mList.size()).append(BusinessConstants.LOG_DATA_UNIT).toString(), new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_IMPORT).append(mList.size()).append(BusinessConstants.LOG_DATA_UNIT).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
BaseResponseInfo info = new BaseResponseInfo(); BaseResponseInfo info = new BaseResponseInfo();
Map<String, Object> data = new HashMap<String, Object>(); Map<String, Object> data = new HashMap<String, Object>();
try { try {
for(Material m: mList) { Long mId = 0L;
materialMapper.insertSelective(m); for(MaterialWithInitStock m: mList) {
//判断该商品是否存在,如果不存在就新增,如果存在就更新
List<Material> materials = getMaterialListByParam(m.getName(),m.getModel(),m.getColor(),m.getStandard(),
m.getMfrs(),m.getUnit(),m.getUnitid());
if(materials.size()<=0) {
materialMapperEx.insertSelectiveEx(m);
mId = m.getId();
} else {
mId = materials.get(0).getId();
String materialJson = JSON.toJSONString(m);
Material material = JSONObject.parseObject(materialJson, Material.class);
material.setId(mId);
materialMapper.updateByPrimaryKeySelective(material);
}
//给商品初始化库存
Map<Long, BigDecimal> stockMap = m.getStockMap();
Long depotId = null;
for(Depot depot: depotList){
BigDecimal stock = stockMap.get(depot.getId());
//先清除再插入
MaterialStockExample example = new MaterialStockExample();
example.createCriteria().andMaterialIdEqualTo(mId).andDepotIdEqualTo(depot.getId());
materialStockMapper.deleteByExample(example);
if(stock!=null && stock.compareTo(BigDecimal.ZERO)!=0) {
depotId = depot.getId();
insertStockByMaterialAndDepot(depotId, mId, stock);
}
}
} }
info.code = 200; info.code = 200;
data.put("message", "成功"); data.put("message", "成功");
} catch (Exception e) { } catch (Exception e) {
JshException.writeFail(logger, e);
e.printStackTrace(); e.printStackTrace();
info.code = 500; info.code = 500;
data.put("message", e.getMessage()); data.put("message", e.getMessage());
@@ -319,6 +477,57 @@ public class MaterialService {
return info; return info;
} }
/**
* 根据条件返回产品列表
* @param name
* @param model
* @param color
* @param standard
* @param mfrs
* @param unit
* @param unitId
* @return
*/
private List<Material> getMaterialListByParam(String name, String model, String color,
String standard, String mfrs, String unit, Long unitId) {
MaterialExample example = new MaterialExample();
MaterialExample.Criteria criteria = example.createCriteria();
criteria.andNameEqualTo(name).andModelEqualTo(model);
if (StringUtil.isNotEmpty(color)) {
criteria.andColorEqualTo(color);
}
if (StringUtil.isNotEmpty(standard)) {
criteria.andStandardEqualTo(standard);
}
if (StringUtil.isNotEmpty(mfrs)) {
criteria.andMfrsEqualTo(mfrs);
}
if (StringUtil.isNotEmpty(unit)) {
criteria.andUnitEqualTo(unit);
}
if (unitId !=null) {
criteria.andUnitidEqualTo(unitId);
}
criteria.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
List<Material> list = materialMapper.selectByExample(example);
return list;
}
/**
* 写入初始库存
* @param depotId
* @param mId
* @param stock
*/
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public void insertStockByMaterialAndDepot(Long depotId, Long mId, BigDecimal stock){
MaterialStock materialStock = new MaterialStock();
materialStock.setDepotId(depotId);
materialStock.setMaterialId(mId);
materialStock.setNumber(stock);
materialStockMapper.insertSelective(materialStock); //存入初始库存
}
public List<Material> getMaterialEnableSerialNumberList(Map<String, Object> parameterMap)throws Exception { public List<Material> getMaterialEnableSerialNumberList(Map<String, Object> parameterMap)throws Exception {
List<Material> list =null; List<Material> list =null;
try{ try{
@@ -387,4 +596,66 @@ public class MaterialService {
return deleteTotal; return deleteTotal;
} }
public BigDecimal parseBigDecimalEx(String str) throws Exception{
if(!StringUtil.isEmpty(str)) {
return new BigDecimal(str);
} else {
return null;
}
}
public BigDecimal parsePrice(String price, String ratio) throws Exception{
if(StringUtil.isEmpty(price) || StringUtil.isEmpty(ratio)) {
return BigDecimal.ZERO;
} else {
BigDecimal pr=new BigDecimal(price);
BigDecimal r=new BigDecimal(ratio);
return pr.multiply(r);
}
}
/**
* 根据产品和仓库获取初始库存
* @param materialId
* @param depotId
* @return
*/
public BigDecimal getInitStock(Long materialId, Long depotId) {
BigDecimal stock = BigDecimal.ZERO;
MaterialStockExample example = new MaterialStockExample();
example.createCriteria().andMaterialIdEqualTo(materialId).andDepotIdEqualTo(depotId)
.andDeleteFagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
List<MaterialStock> list = materialStockMapper.selectByExample(example);
if(list!=null && list.size()>0) {
stock = list.get(0).getNumber();
}
return stock;
}
/**
* 根据产品获取初始库存
* @param materialId
* @return
*/
public BigDecimal getInitStockByMid(Long depotId, Long materialId) {
BigDecimal stock = BigDecimal.ZERO;
MaterialStockExample example = new MaterialStockExample();
if(depotId!=null) {
example.createCriteria().andMaterialIdEqualTo(materialId).andDepotIdEqualTo(depotId)
.andDeleteFagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
} else {
example.createCriteria().andMaterialIdEqualTo(materialId)
.andDeleteFagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
}
List<MaterialStock> list = materialStockMapper.selectByExample(example);
if(list!=null && list.size()>0) {
for(MaterialStock ms: list) {
if(ms!=null) {
stock = stock.add(ms.getNumber());
}
}
}
return stock;
}
} }

View File

@@ -388,4 +388,19 @@ public class MaterialCategoryService {
deleteTotal= batchDeleteMaterialCategoryByIds(ids); deleteTotal= batchDeleteMaterialCategoryByIds(ids);
return deleteTotal; return deleteTotal;
} }
/**
* 根据名称获取类型
* @param name
*/
public Long getCategoryIdByName(String name){
Long categoryId = 0l;
MaterialCategoryExample example = new MaterialCategoryExample();
example.createCriteria().andNameEqualTo(name).andStatusNotEqualTo(BusinessConstants.DELETE_TYPE_FORCE);
List<MaterialCategory> list = materialCategoryMapper.selectByExample(example);
if(list!=null && list.size()>0) {
categoryId = list.get(0).getId();
}
return categoryId;
}
} }

View File

@@ -208,4 +208,19 @@ public class UnitService {
deleteTotal= batchDeleteUnitByIds(ids); deleteTotal= batchDeleteUnitByIds(ids);
return deleteTotal; return deleteTotal;
} }
/**
* 根据名称获取类型
* @param name
*/
public Long getUnitIdByName(String name){
Long unitId = 0l;
UnitExample example = new UnitExample();
example.createCriteria().andUnameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
List<Unit> list = unitMapper.selectByExample(example);
if(list!=null && list.size()>0) {
unitId = list.get(0).getId();
}
return unitId;
}
} }

View File

@@ -174,5 +174,168 @@
and ifnull(delete_Flag,'0') !='1' and ifnull(delete_Flag,'0') !='1'
</select> </select>
<insert id="insertSelectiveEx" parameterType="com.jsh.erp.datasource.entities.Material"
useGeneratedKeys="true" keyProperty="id" keyColumn="id">
insert into jsh_material
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
Id,
</if>
<if test="categoryid != null">
CategoryId,
</if>
<if test="name != null">
Name,
</if>
<if test="mfrs != null">
Mfrs,
</if>
<if test="packing != null">
Packing,
</if>
<if test="safetystock != null">
SafetyStock,
</if>
<if test="model != null">
Model,
</if>
<if test="standard != null">
Standard,
</if>
<if test="color != null">
Color,
</if>
<if test="unit != null">
Unit,
</if>
<if test="remark != null">
Remark,
</if>
<if test="retailprice != null">
RetailPrice,
</if>
<if test="lowprice != null">
LowPrice,
</if>
<if test="presetpriceone != null">
PresetPriceOne,
</if>
<if test="presetpricetwo != null">
PresetPriceTwo,
</if>
<if test="unitid != null">
UnitId,
</if>
<if test="firstoutunit != null">
FirstOutUnit,
</if>
<if test="firstinunit != null">
FirstInUnit,
</if>
<if test="pricestrategy != null">
PriceStrategy,
</if>
<if test="enabled != null">
Enabled,
</if>
<if test="otherfield1 != null">
OtherField1,
</if>
<if test="otherfield2 != null">
OtherField2,
</if>
<if test="otherfield3 != null">
OtherField3,
</if>
<if test="enableserialnumber != null">
enableSerialNumber,
</if>
<if test="tenantId != null">
tenant_id,
</if>
<if test="deleteFlag != null">
delete_Flag,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=BIGINT},
</if>
<if test="categoryid != null">
#{categoryid,jdbcType=BIGINT},
</if>
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="mfrs != null">
#{mfrs,jdbcType=VARCHAR},
</if>
<if test="packing != null">
#{packing,jdbcType=DECIMAL},
</if>
<if test="safetystock != null">
#{safetystock,jdbcType=DECIMAL},
</if>
<if test="model != null">
#{model,jdbcType=VARCHAR},
</if>
<if test="standard != null">
#{standard,jdbcType=VARCHAR},
</if>
<if test="color != null">
#{color,jdbcType=VARCHAR},
</if>
<if test="unit != null">
#{unit,jdbcType=VARCHAR},
</if>
<if test="remark != null">
#{remark,jdbcType=VARCHAR},
</if>
<if test="retailprice != null">
#{retailprice,jdbcType=DECIMAL},
</if>
<if test="lowprice != null">
#{lowprice,jdbcType=DECIMAL},
</if>
<if test="presetpriceone != null">
#{presetpriceone,jdbcType=DECIMAL},
</if>
<if test="presetpricetwo != null">
#{presetpricetwo,jdbcType=DECIMAL},
</if>
<if test="unitid != null">
#{unitid,jdbcType=BIGINT},
</if>
<if test="firstoutunit != null">
#{firstoutunit,jdbcType=VARCHAR},
</if>
<if test="firstinunit != null">
#{firstinunit,jdbcType=VARCHAR},
</if>
<if test="pricestrategy != null">
#{pricestrategy,jdbcType=VARCHAR},
</if>
<if test="enabled != null">
#{enabled,jdbcType=BIT},
</if>
<if test="otherfield1 != null">
#{otherfield1,jdbcType=VARCHAR},
</if>
<if test="otherfield2 != null">
#{otherfield2,jdbcType=VARCHAR},
</if>
<if test="otherfield3 != null">
#{otherfield3,jdbcType=VARCHAR},
</if>
<if test="enableserialnumber != null">
#{enableserialnumber,jdbcType=VARCHAR},
</if>
<if test="tenantId != null">
#{tenantId,jdbcType=BIGINT},
</if>
<if test="deleteFlag != null">
#{deleteFlag,jdbcType=VARCHAR},
</if>
</trim>
</insert>
</mapper> </mapper>

View File

@@ -0,0 +1,288 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.jsh.erp.datasource.mappers.MaterialStockMapper" >
<resultMap id="BaseResultMap" type="com.jsh.erp.datasource.entities.MaterialStock" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<id column="id" property="id" jdbcType="BIGINT" />
<result column="material_id" property="materialId" jdbcType="BIGINT" />
<result column="depot_id" property="depotId" jdbcType="BIGINT" />
<result column="number" property="number" jdbcType="DECIMAL" />
<result column="tenant_id" property="tenantId" jdbcType="BIGINT" />
<result column="delete_fag" property="deleteFag" jdbcType="VARCHAR" />
</resultMap>
<sql id="Example_Where_Clause" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<where >
<foreach collection="oredCriteria" item="criteria" separator="or" >
<if test="criteria.valid" >
<trim prefix="(" suffix=")" prefixOverrides="and" >
<foreach collection="criteria.criteria" item="criterion" >
<choose >
<when test="criterion.noValue" >
and ${criterion.condition}
</when>
<when test="criterion.singleValue" >
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue" >
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue" >
and ${criterion.condition}
<foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<where >
<foreach collection="example.oredCriteria" item="criteria" separator="or" >
<if test="criteria.valid" >
<trim prefix="(" suffix=")" prefixOverrides="and" >
<foreach collection="criteria.criteria" item="criterion" >
<choose >
<when test="criterion.noValue" >
and ${criterion.condition}
</when>
<when test="criterion.singleValue" >
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue" >
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue" >
and ${criterion.condition}
<foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
id, material_id, depot_id, number, tenant_id, delete_fag
</sql>
<select id="selectByExample" resultMap="BaseResultMap" parameterType="com.jsh.erp.datasource.entities.MaterialStockExample" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<if test="distinct" >
distinct
</if>
<include refid="Base_Column_List" />
from jsh_material_stock
<if test="_parameter != null" >
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null" >
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<include refid="Base_Column_List" />
from jsh_material_stock
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
delete from jsh_material_stock
where id = #{id,jdbcType=BIGINT}
</delete>
<delete id="deleteByExample" parameterType="com.jsh.erp.datasource.entities.MaterialStockExample" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
delete from jsh_material_stock
<if test="_parameter != null" >
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="com.jsh.erp.datasource.entities.MaterialStock" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
insert into jsh_material_stock (id, material_id, depot_id,
number, tenant_id, delete_fag
)
values (#{id,jdbcType=BIGINT}, #{materialId,jdbcType=BIGINT}, #{depotId,jdbcType=BIGINT},
#{number,jdbcType=DECIMAL}, #{tenantId,jdbcType=BIGINT}, #{deleteFag,jdbcType=VARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="com.jsh.erp.datasource.entities.MaterialStock" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
insert into jsh_material_stock
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="materialId != null" >
material_id,
</if>
<if test="depotId != null" >
depot_id,
</if>
<if test="number != null" >
number,
</if>
<if test="tenantId != null" >
tenant_id,
</if>
<if test="deleteFag != null" >
delete_fag,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=BIGINT},
</if>
<if test="materialId != null" >
#{materialId,jdbcType=BIGINT},
</if>
<if test="depotId != null" >
#{depotId,jdbcType=BIGINT},
</if>
<if test="number != null" >
#{number,jdbcType=DECIMAL},
</if>
<if test="tenantId != null" >
#{tenantId,jdbcType=BIGINT},
</if>
<if test="deleteFag != null" >
#{deleteFag,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.jsh.erp.datasource.entities.MaterialStockExample" resultType="java.lang.Integer" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select count(*) from jsh_material_stock
<if test="_parameter != null" >
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update jsh_material_stock
<set >
<if test="record.id != null" >
id = #{record.id,jdbcType=BIGINT},
</if>
<if test="record.materialId != null" >
material_id = #{record.materialId,jdbcType=BIGINT},
</if>
<if test="record.depotId != null" >
depot_id = #{record.depotId,jdbcType=BIGINT},
</if>
<if test="record.number != null" >
number = #{record.number,jdbcType=DECIMAL},
</if>
<if test="record.tenantId != null" >
tenant_id = #{record.tenantId,jdbcType=BIGINT},
</if>
<if test="record.deleteFag != null" >
delete_fag = #{record.deleteFag,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null" >
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update jsh_material_stock
set id = #{record.id,jdbcType=BIGINT},
material_id = #{record.materialId,jdbcType=BIGINT},
depot_id = #{record.depotId,jdbcType=BIGINT},
number = #{record.number,jdbcType=DECIMAL},
tenant_id = #{record.tenantId,jdbcType=BIGINT},
delete_fag = #{record.deleteFag,jdbcType=VARCHAR}
<if test="_parameter != null" >
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.jsh.erp.datasource.entities.MaterialStock" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update jsh_material_stock
<set >
<if test="materialId != null" >
material_id = #{materialId,jdbcType=BIGINT},
</if>
<if test="depotId != null" >
depot_id = #{depotId,jdbcType=BIGINT},
</if>
<if test="number != null" >
number = #{number,jdbcType=DECIMAL},
</if>
<if test="tenantId != null" >
tenant_id = #{tenantId,jdbcType=BIGINT},
</if>
<if test="deleteFag != null" >
delete_fag = #{deleteFag,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.jsh.erp.datasource.entities.MaterialStock" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update jsh_material_stock
set material_id = #{materialId,jdbcType=BIGINT},
depot_id = #{depotId,jdbcType=BIGINT},
number = #{number,jdbcType=DECIMAL},
tenant_id = #{tenantId,jdbcType=BIGINT},
delete_fag = #{deleteFag,jdbcType=VARCHAR}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>

View File

@@ -51,6 +51,7 @@
<table tableName="jsh_inoutitem" domainObjectName="InOutItem"></table> <table tableName="jsh_inoutitem" domainObjectName="InOutItem"></table>
<table tableName="jsh_log" domainObjectName="Log"></table> <table tableName="jsh_log" domainObjectName="Log"></table>
<table tableName="jsh_material" domainObjectName="Material"></table> <table tableName="jsh_material" domainObjectName="Material"></table>
<table tableName="jsh_material_stock" domainObjectName="MaterialStock"></table>
<table tableName="jsh_materialcategory" domainObjectName="MaterialCategory"></table> <table tableName="jsh_materialcategory" domainObjectName="MaterialCategory"></table>
<table tableName="jsh_materialproperty" domainObjectName="MaterialProperty"></table> <table tableName="jsh_materialproperty" domainObjectName="MaterialProperty"></table>
<table tableName="jsh_person" domainObjectName="Person"></table> <table tableName="jsh_person" domainObjectName="Person"></table>