From 748da238ab79af23649dae7c2508efc3adb6deb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A3=E5=9C=A3=E5=8D=8E?= <752718920@qq.com> Date: Sat, 6 Jun 2020 00:14:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=95=86=E5=93=81=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- erp_web/upload/excels/goods_template.xls | Bin 19968 -> 19968 bytes .../entities/MaterialWithInitStock.java | 12 ++ .../erp/service/material/MaterialService.java | 106 +++++++++++------- 3 files changed, 76 insertions(+), 42 deletions(-) diff --git a/erp_web/upload/excels/goods_template.xls b/erp_web/upload/excels/goods_template.xls index 2050712c9091deed997c669f7363be7aa186b4c4..1db5ee5c283c90339a0fb812975744b8ea33d58c 100644 GIT binary patch delta 1806 zcmY+FUrbw79LImB_qM&af4IG+qqi-r-G*fR(Je-lSQwX5tC($Nu!(UmLq~>ygD_ms zi6yAX{zP5*?H>t_=z|YDkyYbnVzLJlA51o9migd=OBQ`F#*8IGSVa7t)AqKU=KT5m z{@w3A_uSj*c{V-ImPTY}tgYVD9lwVsVPGPGC-H{c>W1jQ4D;n7_tKA8QxNw z@C((zA)3dWa^9FyllZL~z&&a;PB;U2Ty@~QlESkT_$S%xXuhQea(-8n9anTec54o{ z1^cuY1uYTz@EdIxUeyd%gB#i|7Nap(86X+|Z1@1?b-l`6K+^Pkk|5^=bIG&%jH%-`Nzq4*`f^lro5M$**Cbu7$$Isuy(qvimYsRYhbFGZeX^ zi)_59J3>{($h&aFjG2^pQ$%jX-}GR}U-W(jK;9V04Z^FV=I3?%IPEvE+wb6O7Qtnz zK3$-&AbuZQ*?GF={Y{>j-(b%cG7M(q@48Y{LfS7pS!v*xl|RXk#y|Wk_ikWM9lL@z zp6_sh4gxxUq2n&z*J z&(L)0y~Z9H*qOt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f*FC$GBLX~+uWvfq zM2vAb024GQ_|U?_0a{KRIXuOHC3Co~+rY=Vb(xfx!3(W8)4h>trHkDPD=@eeR4Gb? z6X2&+fI)v9yQqQRS74EN=ajl%0ym7Uz#j0xtM0mA1{uzI>sSE=t_SMaTOd8>)w;n4 zzFP|TNmQ3y_Xi*fKUWKaz`rt(B>ppK$O2t>dq3gftHo5?#-ES@MZN%3ZT#^X5WdyO z-?xE(_clm(awfJ|>*$r_En}dMP6l9^0D~a1sPjH#V3+aa(oi>(FxUL3;RaZTTNfh*2}S+&!Z zAQW?uK#0G`Nx@4Uxd;JtSUexU4OwV#m=d8z2e}EYBJ=?~OiWKTjz_mzd~UPnh?V8v zr2`*GX9`hUCO@()G||k9@Y|b(W(Td5!>=7rwbqv7vgITk=1Ms(I^K#L-iFJOQ>h@6 zuLWRrwV+agqk>pK8OS8*3pJ{LA9nq7b zzbGzH^Ig&JDNW^C0Yvf3OdF039lek>1@ZWWo4ZSm{mX)T`oWjJIC%}52d|f=Hcv7f X-IB#iTjuDBZGf)QLqlg6eW-r{v64NZ diff --git a/src/main/java/com/jsh/erp/datasource/entities/MaterialWithInitStock.java b/src/main/java/com/jsh/erp/datasource/entities/MaterialWithInitStock.java index 63efbd6c..85a4aa9b 100644 --- a/src/main/java/com/jsh/erp/datasource/entities/MaterialWithInitStock.java +++ b/src/main/java/com/jsh/erp/datasource/entities/MaterialWithInitStock.java @@ -1,5 +1,7 @@ package com.jsh.erp.datasource.entities; +import com.alibaba.fastjson.JSONObject; + import java.math.BigDecimal; import java.util.Map; @@ -7,6 +9,8 @@ public class MaterialWithInitStock extends Material { private Map stockMap; + private JSONObject materialExObj; + public Map getStockMap() { return stockMap; } @@ -14,4 +18,12 @@ public class MaterialWithInitStock extends Material { public void setStockMap(Map stockMap) { this.stockMap = stockMap; } + + public JSONObject getMaterialExObj() { + return materialExObj; + } + + public void setMaterialExObj(JSONObject materialExObj) { + this.materialExObj = materialExObj; + } } \ No newline at end of file diff --git a/src/main/java/com/jsh/erp/service/material/MaterialService.java b/src/main/java/com/jsh/erp/service/material/MaterialService.java index c2d85f1c..70489d4d 100644 --- a/src/main/java/com/jsh/erp/service/material/MaterialService.java +++ b/src/main/java/com/jsh/erp/service/material/MaterialService.java @@ -40,6 +40,8 @@ public class MaterialService { @Resource private MaterialMapper materialMapper; @Resource + private MaterialExtendMapper materialExtendMapper; + @Resource private MaterialMapperEx materialMapperEx; @Resource private MaterialExtendMapperEx materialExtendMapperEx; @@ -366,68 +368,63 @@ public class MaterialService { public BaseResponseInfo importExcel(Sheet src) throws Exception { List depotList= depotService.getDepot(); int depotCount = depotList.size(); - List mList = new ArrayList(); + List mList = new ArrayList<>(); 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); //单位 + String standard = ExcelUtils.getContent(src, i, 1); //规格 + String model = ExcelUtils.getContent(src, i, 2); //型号 + String color = ExcelUtils.getContent(src, i, 3); //颜色 + String categoryName = ExcelUtils.getContent(src, i, 4); //类别 + String safetyStock = ExcelUtils.getContent(src, i, 5); //安全存量 + String unit = ExcelUtils.getContent(src, i, 6); //基础单位 //校验名称、型号、单位是否为空 if(StringUtil.isNotEmpty(name) && StringUtil.isNotEmpty(model) && StringUtil.isNotEmpty(unit)) { MaterialWithInitStock m = new MaterialWithInitStock(); m.setName(name); + m.setStandard(standard); m.setModel(model); + m.setColor(color); 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); //销售价 + m.setUnit(unit); + String manyUnit = ExcelUtils.getContent(src, i, 7); //副单位 + String barCode = ExcelUtils.getContent(src, i, 8); //基础条码 + String manyBarCode = ExcelUtils.getContent(src, i, 9); //副条码 + String ratio = ExcelUtils.getContent(src, i, 10); //比例 + String purchaseDecimal = ExcelUtils.getContent(src, i, 11); //采购价 + String commodityDecimal = ExcelUtils.getContent(src, i, 12); //零售价 + String wholesaleDecimal = ExcelUtils.getContent(src, i, 13); //销售价 + String lowDecimal = ExcelUtils.getContent(src, i, 14); //最低售价 + JSONObject materialExObj = new JSONObject(); + JSONObject basicObj = new JSONObject(); + basicObj.put("barCode", barCode); + basicObj.put("commodityUnit", unit); + basicObj.put("purchaseDecimal", purchaseDecimal); + basicObj.put("commodityDecimal", commodityDecimal); + basicObj.put("wholesaleDecimal", wholesaleDecimal); + basicObj.put("lowDecimal", lowDecimal); + materialExObj.put("basic", basicObj); 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)); + otherObj.put("barCode", manyBarCode); + otherObj.put("commodityUnit", manyUnit); + otherObj.put("purchaseDecimal", parsePrice(purchaseDecimal,ratio)); + otherObj.put("commodityDecimal", parsePrice(commodityDecimal,ratio)); + otherObj.put("wholesaleDecimal", parsePrice(wholesaleDecimal,ratio)); + otherObj.put("lowDecimal", parsePrice(lowDecimal,ratio)); + materialExObj.put("other", otherObj); } - String enabled = ExcelUtils.getContent(src, i, 12); //状态 + m.setMaterialExObj(materialExObj); + String enabled = ExcelUtils.getContent(src, i, 15); //状态 m.setEnabled(enabled.equals("1")? true: false); //缓存各个仓库的库存信息 Map stockMap = new HashMap(); for(int j=1; j<=depotCount;j++) { - int col = 12+j; + int col = 15+j; if(col <= src.getColumns()){ String depotName = ExcelUtils.getContent(src, 1, col); //获取仓库名称 Long depotId = depotService.getIdByName(depotName); @@ -468,6 +465,31 @@ public class MaterialService { material.setId(mId); materialMapper.updateByPrimaryKeySelective(material); } + //给商品新增条码与价格相关信息 + User user = userService.getCurrentUser(); + JSONObject materialExObj = m.getMaterialExObj(); + if(StringUtil.isExist(materialExObj.get("basic"))){ + String basicStr = materialExObj.getString("basic"); + MaterialExtend basicMaterialExtend = JSONObject.parseObject(basicStr, MaterialExtend.class); + basicMaterialExtend.setMaterialId(mId); + basicMaterialExtend.setDefaultFlag("1"); + basicMaterialExtend.setCreateTime(new Date()); + basicMaterialExtend.setUpdateTime(new Date().getTime()); + basicMaterialExtend.setCreateSerial(user.getLoginName()); + basicMaterialExtend.setUpdateSerial(user.getLoginName()); + materialExtendMapper.insertSelective(basicMaterialExtend); + } + if(StringUtil.isExist(materialExObj.get("other"))) { + String otherStr = materialExObj.getString("other"); + MaterialExtend otherMaterialExtend = JSONObject.parseObject(otherStr, MaterialExtend.class); + otherMaterialExtend.setMaterialId(mId); + otherMaterialExtend.setDefaultFlag("0"); + otherMaterialExtend.setCreateTime(new Date()); + otherMaterialExtend.setUpdateTime(new Date().getTime()); + otherMaterialExtend.setCreateSerial(user.getLoginName()); + otherMaterialExtend.setUpdateSerial(user.getLoginName()); + materialExtendMapper.insertSelective(otherMaterialExtend); + } //给商品初始化库存 Map stockMap = m.getStockMap(); Long depotId = null;