商品编码根据类目自动编码 增加SKU

master
cez 2022-03-09 19:26:23 +08:00
parent 50e6e7ac9e
commit 5b3dd6b947
4 changed files with 78 additions and 60 deletions

View File

@ -214,30 +214,22 @@ public class MdGoodsController extends BaseController {
AjaxJson j = new AjaxJson(); AjaxJson j = new AjaxJson();
message = "商品信息添加成功"; message = "商品信息添加成功";
try { try {
MdGoodsEntity mdGoods1 = systemService.findUniqueByProperty(
MdGoodsEntity.class, "shpBianMa", mdGoods.getShpBianMa());
if(mdGoods1 ==null ){
if(StringUtil.isEmpty(mdGoods.getChlKongZhi()) ){ if(StringUtil.isEmpty(mdGoods.getChlKongZhi()) ){
mdGoods.setChlKongZhi("N"); mdGoods.setChlKongZhi("N");
}
if("N".equals(mdGoods.getChlKongZhi() )){
mdGoods.setChlShl("1"); mdGoods.setChlShl("1");
mdGoods.setJshDanWei(mdGoods.getShlDanWei()); mdGoods.setJshDanWei(mdGoods.getShlDanWei());
} }
try { try {
if(StringUtil.isEmpty(mdGoods.getZhlKgm())){ if(StringUtil.isEmpty(mdGoods.getZhlKgm())){
if(!StringUtil.isEmpty(mdGoods.getBzhiQi())){ if(!StringUtil.isEmpty(mdGoods.getBzhiQi())){
int bzhiq = Integer.parseInt(mdGoods.getBzhiQi()); int bzhiq = Integer.parseInt(mdGoods.getBzhiQi());
mdGoods.setZhlKgm(Integer.toString(bzhiq)); mdGoods.setZhlKgm(Integer.toString(bzhiq));
} }
} }
} catch (Exception e) { } catch (Exception e) {
// TODO: handle exception // TODO: handle exception
} }
if(StringUtil.isEmpty(mdGoods.getShpBianMa())){
//查询当前商品类型的商品数量 //查询当前商品类型的商品数量
Map<String, Object> countMap = systemService.findOneForJdbc("select right(shp_bian_ma,7) shp_bian_ma from md_goods where category_code =? and suo_shu_ke_hu = ? and shp_bian_ma like ? ORDER BY shp_bian_ma desc LIMIT 1",mdGoods.getCategoryCode(),mdGoods.getSuoShuKeHu(),mdGoods.getSuoShuKeHu()+mdGoods.getCategoryCode()+"%"); Map<String, Object> countMap = systemService.findOneForJdbc("select right(shp_bian_ma,7) shp_bian_ma from md_goods where category_code =? and suo_shu_ke_hu = ? and shp_bian_ma like ? ORDER BY shp_bian_ma desc LIMIT 1",mdGoods.getCategoryCode(),mdGoods.getSuoShuKeHu(),mdGoods.getSuoShuKeHu()+mdGoods.getCategoryCode()+"%");
if (countMap == null) { if (countMap == null) {
@ -254,10 +246,18 @@ public class MdGoodsController extends BaseController {
systemService.addLog(message, Globals.Log_Type_INSERT, systemService.addLog(message, Globals.Log_Type_INSERT,
Globals.Log_Leavel_INFO); Globals.Log_Leavel_INFO);
}else{ }else{
message = "商品编码或者条码已经存在"; MdGoodsEntity mdGoods1 = systemService.findUniqueByProperty(
MdGoodsEntity.class, "shpBianMa", mdGoods.getShpBianMa());
if(mdGoods1 != null){
message = "商品编码已经存在";
j.setSuccess(false); j.setSuccess(false);
}else{
mdGoodsService.save(mdGoods);
systemService.addLog(message, Globals.Log_Type_INSERT,
Globals.Log_Leavel_INFO);
} }
}
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
message = "商品信息添加失败"; message = "商品信息添加失败";
@ -447,13 +447,7 @@ public class MdGoodsController extends BaseController {
MdGoodsEntity.class, "shpBianMa", mdGoods.getShpBianMa()); MdGoodsEntity.class, "shpBianMa", mdGoods.getShpBianMa());
if(mdGoods1 ==null ){ if(mdGoods1 ==null ){
try { try {
//查询当前商品类型的商品数量 if(StringUtil.isEmpty(mdGoods.getShpBianMa())){//商品编码为空则自动编码
// Map<String, Object> map = systemService.findOneForJdbc("select ifnull(count(1),0) num from ba_goods_type where goods_type_code = ? order by create_date desc limit 1",mdGoods.getChpShuXing());
// if ((Long)map.get("num") <= 0L) {
// j.setSuccess(false);
// j.setMsg("产品属性错误:"+mdGoods.getChpShuXing());
// return j;
// }
if (StringUtils.isEmpty(mdGoods.getCategoryCode())) { if (StringUtils.isEmpty(mdGoods.getCategoryCode())) {
j.setSuccess(false); j.setSuccess(false);
j.setMsg("类目编码为空:"); j.setMsg("类目编码为空:");
@ -470,6 +464,8 @@ public class MdGoodsController extends BaseController {
mdGoods.setShpBianMa(mdGoods.getSuoShuKeHu()+mdGoods.getCategoryCode()+String.format("%07d", 1)); mdGoods.setShpBianMa(mdGoods.getSuoShuKeHu()+mdGoods.getCategoryCode()+String.format("%07d", 1));
} }
} }
}
if(StringUtil.isEmpty(mdGoods.getZhlKgm())){ if(StringUtil.isEmpty(mdGoods.getZhlKgm())){
if(!StringUtil.isEmpty(mdGoods.getBzhiQi())){ if(!StringUtil.isEmpty(mdGoods.getBzhiQi())){
@ -488,8 +484,6 @@ public class MdGoodsController extends BaseController {
} }
} catch (Exception e) { } catch (Exception e) {
// TODO: handle exception // TODO: handle exception
e.printStackTrace(); e.printStackTrace();

View File

@ -98,21 +98,21 @@ function counttiji(){
<span class="Validform_checktip" style="float:left;height:0px;"></span> <span class="Validform_checktip" style="float:left;height:0px;"></span>
<label class="Validform_label" style="display: none">价格</label> <label class="Validform_label" style="display: none">价格</label>
</div> </div>
<%-- </div>--%> </div>
<%-- <div class="row show-grid">--%> <div class="row show-grid">
<%-- <div class="col-xs-3 text-center">--%> <div class="col-xs-3 text-center">
<%-- <b style="color:red">商品编码</b>--%> <b style="color:red">商品编码</b>
<%-- </div>--%> </div>
<%-- <div class="col-xs-3">--%> <div class="col-xs-3">
<%-- <input id="shpBianMa" name="shpBianMa" type="text" class="form-control"--%> <input id="shpBianMa" name="shpBianMa" type="text" class="form-control"
<%-- ignore="checked"--%> ignore="checked"
<%-- datatype="*" required="required" />--%> datatype="*" required="required" />
<%-- <span class="Validform_checktip" style="float:left;height:0px;"></span>--%> <span class="Validform_checktip" style="float:left;height:0px;"></span>
<%-- <label class="Validform_label" style="display: none">商品编码</label>--%> <label class="Validform_label" style="display: none">商品编码</label>
<%-- </div>--%> </div>
<div class="col-xs-3 text-center"> <div class="col-xs-3 text-center">
<b >客户商品编码</b> <b >客户商品编码</b>
</div> </div>
@ -153,6 +153,18 @@ function counttiji(){
<span class="Validform_checktip" style="float:left;height:0px;"></span> <span class="Validform_checktip" style="float:left;height:0px;"></span>
<label class="Validform_label" style="display: none">商品品牌</label> <label class="Validform_label" style="display: none">商品品牌</label>
</div> </div>
<div class="col-xs-3 text-center">
<b >SKU</b>
</div>
<div class="col-xs-3">
<input id="sku" name="sku" type="text" class="form-control"
ignore="ignore"
/>
<span class="Validform_checktip" style="float:left;height:0px;"></span>
<label class="Validform_label" style="display: none">sku</label>
</div>
</div> </div>
<div class="row show-grid"> <div class="row show-grid">
<div class="col-xs-3 text-center"> <div class="col-xs-3 text-center">

View File

@ -157,6 +157,18 @@
<span class="Validform_checktip" style="float:left;height:0px;"></span> <span class="Validform_checktip" style="float:left;height:0px;"></span>
<label class="Validform_label" style="display: none">商品品牌</label> <label class="Validform_label" style="display: none">商品品牌</label>
</div> </div>
<div class="col-xs-3 text-center">
<b >SKU</b>
</div>
<div class="col-xs-3">
<input id="sku" name="sku" type="text" value='${mdGoodsPage.sku}' class="form-control"
ignore="ignore"
/>
<span class="Validform_checktip" style="float:left;height:0px;"></span>
<label class="Validform_label" style="display: none">sku</label>
</div>
<div class="row show-grid"> <div class="row show-grid">
<div class="col-xs-3 text-center"> <div class="col-xs-3 text-center">
<b style="color:red">商品类目</b> <b style="color:red">商品类目</b>

View File

@ -56,7 +56,7 @@
<t:dgCol title="长" field="chZhXiang" queryMode="group" width="80"></t:dgCol> <t:dgCol title="长" field="chZhXiang" queryMode="group" width="80"></t:dgCol>
<t:dgCol title="宽" field="kuZhXiang" queryMode="group" width="80"></t:dgCol> <t:dgCol title="宽" field="kuZhXiang" queryMode="group" width="80"></t:dgCol>
<t:dgCol title="高" field="gaoZhXiang" queryMode="group" width="80"></t:dgCol> <t:dgCol title="高" field="gaoZhXiang" queryMode="group" width="80"></t:dgCol>
<%--<t:dgCol title="基准温度" field="jiZhunwendu" queryMode="group" width="80"></t:dgCol>--%> <t:dgCol title="sku" field="sku" queryMode="group" width="80"></t:dgCol>
<t:dgCol title="商品描述" field="shpMiaoShu" hidden="true" queryMode="group" width="120"></t:dgCol> <t:dgCol title="商品描述" field="shpMiaoShu" hidden="true" queryMode="group" width="120"></t:dgCol>
<t:dgCol title="停用" field="zhuangTai" query="true" dictionary="sf_yn" width="120"></t:dgCol> <t:dgCol title="停用" field="zhuangTai" query="true" dictionary="sf_yn" width="120"></t:dgCol>
<t:dgFunOpt title="打印" funname="doprint(id)" urlclass="ace_button" /> <t:dgFunOpt title="打印" funname="doprint(id)" urlclass="ace_button" />