Jelajahi Sumber

仓库删除限制,商品库存修改,pda版本更新接口放开

huang 4 minggu lalu
induk
melakukan
6be3284e4a

+ 5 - 0
src/main/java/com/jsh/erp/controller/DepotController.java

@@ -8,6 +8,7 @@ import com.jsh.erp.datasource.entities.Depot;
 import com.jsh.erp.datasource.entities.DepotEx;
 import com.jsh.erp.datasource.entities.MaterialInitialStock;
 import com.jsh.erp.service.DepotService;
+import com.jsh.erp.service.MaterialExtendService;
 import com.jsh.erp.service.MaterialService;
 import com.jsh.erp.service.UserBusinessService;
 import com.jsh.erp.utils.BaseResponseInfo;
@@ -49,6 +50,9 @@ public class DepotController extends BaseController {
     @Resource
     private MaterialService materialService;
 
+    @Resource
+    private MaterialExtendService materialExtendService;
+
     @GetMapping(value = "/info")
     @ApiOperation(value = "根据id获取信息")
     public String getList(@RequestParam("id") Long id,
@@ -93,6 +97,7 @@ public class DepotController extends BaseController {
     @DeleteMapping(value = "/delete")
     @ApiOperation(value = "删除")
     public String deleteResource(@RequestParam("id") Long id, HttpServletRequest request)throws Exception {
+
         Map<String, Object> objectMap = new HashMap<>();
         int delete = depotService.deleteDepot(id, request);
         return returnStr(objectMap, delete);

+ 7 - 0
src/main/java/com/jsh/erp/datasource/mappers/MaterialExtendMapperEx.java

@@ -1,5 +1,6 @@
 package com.jsh.erp.datasource.mappers;
 
+import com.jsh.erp.datasource.entities.DepotItem;
 import com.jsh.erp.datasource.entities.MaterialExtend;
 import com.jsh.erp.datasource.vo.MaterialExtendVo4List;
 import org.apache.ibatis.annotations.Param;
@@ -34,4 +35,10 @@ public interface MaterialExtendMapperEx {
     int specialUpdatePrice(MaterialExtend record);
 
     List<MaterialExtend> getBasicInfoByMid(@Param("materialId") Long materialId);
+
+    /**
+     * 根据仓库id查询子表数量
+     * 仓库删除校验
+     */
+    int getMaterialExtendCountByDepotIds(@Param("depotIds") String[] depotIds);
 }

+ 12 - 1
src/main/java/com/jsh/erp/datasource/vo/MaterialExcelVo.java

@@ -1,5 +1,16 @@
 package com.jsh.erp.datasource.vo;
 
 
-public class MaterialExcelVo {
+import com.jsh.erp.datasource.entities.Material;
+import com.jsh.erp.datasource.entities.MaterialExtend;
+import lombok.Data;
+
+/**
+ * 商品导入
+ */
+@Data
+public class MaterialExcelVo extends Material{
+
+    private MaterialExtend materialExtend;
+
 }

+ 4 - 3
src/main/java/com/jsh/erp/filter/LogCostFilter.java

@@ -14,7 +14,7 @@ import java.io.IOException;
 @WebFilter(filterName = "LogCostFilter", urlPatterns = {"/*"},
         initParams = {@WebInitParam(name = "filterPath",
                       value = "/user/login#" +
-                              "user/pdaLogin#" +
+                              "/user/pdaLogin#" +
                               "/user/weixinLogin#" +
                               "/user/weixinBind#" +
                               "/user/registerUser#" +
@@ -25,6 +25,8 @@ import java.io.IOException;
                               "/systemConfig/static#" +
                               "/api/plugin/wechat/weChat/share#" +
                               "/api/plugin/general-ledger/pdf/voucher#" +
+                              "/pda/downloadApk#" +
+                              "/pda/selectVersion#" +
                               "/api/plugin/tenant-statistics/tenantClean")})
 public class LogCostFilter implements Filter {
 
@@ -55,8 +57,7 @@ public class LogCostFilter implements Filter {
             return;
         }
         if (requestUrl != null && (requestUrl.contains("/doc.html") ||
-            requestUrl.contains("/user/pdaLogin") ||
-            requestUrl.contains("/user/login") || requestUrl.contains("/user/register") || requestUrl.contains("/user/randomImage")
+            requestUrl.contains("/user/login") || requestUrl.contains("/user/register")
             ||requestUrl.contains("/open-api"))) {
             chain.doFilter(request, response);
             return;

+ 5 - 0
src/main/java/com/jsh/erp/service/DepotItemService.java

@@ -153,6 +153,11 @@ public interface DepotItemService extends IService<DepotItem> {
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
     void updateCurrentUnitPrice(DepotItem depotItem) throws Exception;
 
+    /**
+     * 根据商品id、仓库id更新当前库存
+     * @param mId 商品id
+     * @param dId 仓库id
+     */
     void updateCurrentStockFun(Long mId, Long dId) throws Exception;
 
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)

+ 7 - 0
src/main/java/com/jsh/erp/service/DepotService.java

@@ -24,6 +24,9 @@ public interface DepotService extends IService<Depot> {
 
     List<Depot> getDepotListByIds(String ids)throws Exception;
 
+    /**
+     * 获取所有仓库
+     */
     List<Depot> getDepot()throws Exception;
 
     List<Depot> getAllList()throws Exception;
@@ -36,6 +39,10 @@ public interface DepotService extends IService<Depot> {
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
     int updateDepot(JSONObject obj, HttpServletRequest request) throws Exception;
 
+    /**
+     * 删除仓库
+     * @param id 仓库id
+     */
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
     int deleteDepot(Long id, HttpServletRequest request)throws Exception;
 

+ 4 - 0
src/main/java/com/jsh/erp/service/MaterialExtendService.java

@@ -20,6 +20,10 @@ public interface MaterialExtendService extends IService<MaterialExtend> {
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
     String saveDetials(JSONObject obj, String sortList, Long materialId, String type) throws Exception;
 
+    /**
+     *  添加商品子信息
+     * @param materialExtend 商品子信息
+     */
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
     int insertMaterialExtend(MaterialExtend materialExtend)throws Exception;
 

+ 5 - 1
src/main/java/com/jsh/erp/service/MaterialService.java

@@ -185,7 +185,11 @@ public interface MaterialService extends IService<Material> {
      */
     MaterialWarnListVo getMaterialWarn();
 
-    //导入表格
+    /**
+     * 导入商品信息
+     * @param file excel表格
+     * @return
+     */
     BaseResponseInfo importExcelTwo(MultipartFile file, HttpServletRequest request) throws Exception;
 
     /**

+ 6 - 6
src/main/java/com/jsh/erp/service/impl/DepotHeadServiceImpl.java

@@ -2024,6 +2024,12 @@ public class DepotHeadServiceImpl extends ServiceImpl<DepotHeadMapper, DepotHead
                 }
             }
             depotItem.setWarehousingUser(user.getId());
+            //基本单位数量*单价
+            depotItem.setAllPrice(depotItem.getBasicNumber().multiply(depotItem.getUnitPrice()));
+            //单价总额 + 税额
+            depotItem.setTaxLastMoney(depotItem.getAllPrice().add(depotItem.getTaxMoney()));
+            //添加单据子表
+            depotItemService.insertDepotItemWithObj(depotItem);
             if(BusinessConstants.DEPOTHEAD_TYPE_IN.equals(depotHead.getType())){
                 //表单入库,修改商品库存
                 materialExtend.setInventory(materialExtend.getInventory().add(depotItem.getBasicNumber()));
@@ -2033,12 +2039,6 @@ public class DepotHeadServiceImpl extends ServiceImpl<DepotHeadMapper, DepotHead
                 materialExtend.setInventory(materialExtend.getInventory().subtract(depotItem.getBasicNumber()));
                 materialExtendService.updateInventory("单据",depotItem.getId(),materialExtend);
             }
-            //基本单位数量*单价
-            depotItem.setAllPrice(depotItem.getBasicNumber().multiply(depotItem.getUnitPrice()));
-            //单价总额 + 税额
-            depotItem.setTaxLastMoney(depotItem.getAllPrice().add(depotItem.getTaxMoney()));
-            //添加单据子表
-            depotItemService.insertDepotItemWithObj(depotItem);
             //更新当前库存
             depotItemService.updateCurrentStock(depotItem);
             //更新当前成本价

+ 4 - 18
src/main/java/com/jsh/erp/service/impl/DepotItemServiceImpl.java

@@ -2,6 +2,7 @@ package com.jsh.erp.service.impl;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.jsh.erp.constants.BusinessConstants;
@@ -1329,12 +1330,6 @@ public class DepotItemServiceImpl extends ServiceImpl<DepotItemMapper, DepotItem
     @Override
     public void updateCurrentStockFun(Long mId, Long dId) throws Exception {
         if(mId!=null && dId!=null) {
-//            MaterialCurrentStockExample example = new MaterialCurrentStockExample();
-            //条件 添加商品id,仓库id ,删除状态
-//            example.createCriteria().andMaterialIdEqualTo(mId).andDepotIdEqualTo(dId)
-//                    .andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
-            //获取商品当前库存信息
-//            List<MaterialCurrentStock> list = materialCurrentStockMapper.selectByExample(example);
             //-先清除再插入,防止商品仓库变更,数据对不上
             materialCurrentStockMapper.delete(new LambdaQueryWrapperX<MaterialCurrentStock>().eq(MaterialCurrentStock::getMaterialId,mId).eqIfPresent(MaterialCurrentStock::getDepotId,dId));
             MaterialCurrentStock materialCurrentStock = new MaterialCurrentStock();
@@ -1342,22 +1337,13 @@ public class DepotItemServiceImpl extends ServiceImpl<DepotItemMapper, DepotItem
             materialCurrentStock.setDepotId(dId);
             //设置当前库存数量
             materialCurrentStock.setCurrentNumber(getStockByParam(dId,mId,null,null));
-//            if(list!=null && list.size()>0) {
-//                //当前库存信息存在,修改当前库存信息
-//                Long mcsId = list.get(0).getId();
-//                materialCurrentStock.setId(mcsId);
-//                materialCurrentStockMapper.updateByPrimaryKeySelective(materialCurrentStock);
-//            } else {
-                //当前库存信息不存在,新增当前库存信息
-                materialCurrentStockMapper.insertSelective(materialCurrentStock);
-//            }
+            //添加当前库存
+            materialCurrentStockMapper.insertSelective(materialCurrentStock);
+            //同步商品库存
             syncTescoSystemService.sycnTescoStock(mId);
         }
     }
 
-
-
-
     @Override
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
     public BigDecimal getFinishNumber(Long meId, Long id, Long headerId, Unit unitInfo, String materialUnit, String linkType) {

+ 11 - 0
src/main/java/com/jsh/erp/service/impl/DepotServiceImpl.java

@@ -10,6 +10,7 @@ import com.jsh.erp.datasource.mappers.*;
 import com.jsh.erp.datasource.vo.SpinnerVO;
 import com.jsh.erp.exception.BusinessRunTimeException;
 import com.jsh.erp.exception.JshException;
+import com.jsh.erp.query.QueryWrapperX;
 import com.jsh.erp.service.*;
 import com.jsh.erp.utils.PageUtils;
 import com.jsh.erp.utils.StringUtil;
@@ -48,6 +49,8 @@ public class DepotServiceImpl extends ServiceImpl<DepotMapper, Depot> implements
     private MaterialInitialStockMapperEx materialInitialStockMapperEx;
     @Resource
     private MaterialCurrentStockMapperEx materialCurrentStockMapperEx;
+    @Resource
+    private MaterialExtendMapperEx materialExtendMapperEx;
 
     @Override
     public List<SpinnerVO> depotSpinnerList() {
@@ -195,6 +198,14 @@ public class DepotServiceImpl extends ServiceImpl<DepotMapper, Depot> implements
             throw new BusinessRunTimeException(ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,
                     ExceptionConstants.DELETE_FORCE_CONFIRM_MSG);
         }
+        //校验商品子表
+        int count = materialExtendMapperEx.getMaterialExtendCountByDepotIds(idArray);
+        if(count > 0){
+            logger.error("异常码[{}],异常提示[{}],参数,DepotIds[{}]",
+                    ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids);
+            throw new BusinessRunTimeException(ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,
+                    ExceptionConstants.DELETE_FORCE_CONFIRM_MSG);
+        }
         try{
             //记录日志
             StringBuffer sb = new StringBuffer();

+ 5 - 1
src/main/java/com/jsh/erp/service/impl/MaterialExtendServiceImpl.java

@@ -274,12 +274,16 @@ public class MaterialExtendServiceImpl extends ServiceImpl<MaterialExtendMapper,
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
     public int insertMaterialExtend(MaterialExtend materialExtend)throws Exception {
         User user = userService.getCurrentUser();
+        //设置是否为默认单位
         materialExtend.setDeleteFlag(BusinessConstants.DELETE_FLAG_EXISTS);
+        //创建时间
         materialExtend.setCreateTime(new Date());
+        //修改时间
         materialExtend.setUpdateTime(new Date().getTime());
+        //创建用户
         materialExtend.setCreateSerial(user.getLoginName());
+        //修改用户
         materialExtend.setUpdateSerial(user.getLoginName());
-        materialExtend.setTenantId(user.getId());
         int result = 0;
         try{
             result= materialExtendMapper.insertSelective(materialExtend);

+ 96 - 104
src/main/java/com/jsh/erp/service/impl/MaterialServiceImpl.java

@@ -1730,13 +1730,6 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
         return vo;
     }
 
-    /**
-     * 导入表格
-     * @param file
-     * @param request
-     * @return
-     * @throws Exception
-     */
     @Override
     public BaseResponseInfo importExcelTwo(MultipartFile file, HttpServletRequest request) throws Exception {
         BaseResponseInfo info = new BaseResponseInfo();
@@ -1755,6 +1748,7 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
             Sheet src = workbook.getSheet(0);
             //获取真实的行数,剔除掉空白行
             int rightRows = ExcelUtils.getRightRows(src);
+            //获取所有仓库
             List<Depot> depotList= depotService.getDepot();
             int depotCount = depotList.size();
             Map<String, Long> depotMap = parseDepotToMap(depotList);
@@ -1767,33 +1761,6 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
             }
             for (int i = 2; i < rightRows; i++) {
                 String name = ExcelUtils.getContent(src, i, 0); //名称
-                String standard = ExcelUtils.getContent(src, i, 1); //规格
-                String model = ExcelUtils.getContent(src, i, 2); //型号
-                String color = ExcelUtils.getContent(src, i, 3); //颜色
-                String brand = ExcelUtils.getContent(src, i, 4); //品牌
-                String categoryName = ExcelUtils.getContent(src, i, 5); //类别
-                String weight = ExcelUtils.getContent(src, i, 6); //基础重量(kg)
-                String unit = ExcelUtils.getContent(src, i, 7); //基本单位
-                String manyUnit = ExcelUtils.getContent(src, i, 8); //副单位
-                String ratio = ExcelUtils.getContent(src, i, 9); //比例
-                String sku = 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); //最低售价
-                String enabled = ExcelUtils.getContent(src, i, 15); //状态
-                String enableSerialNumber = ExcelUtils.getContent(src, i, 16); //序列号
-                String productionDate = ExcelUtils.getContent(src, i, 17); //生产日期
-                String expiryNum = ExcelUtils.getContent(src, i, 18); //保质期天数
-                String supplier = ExcelUtils.getContent(src, i, 19); //供应商
-                String barCode = ExcelUtils.getContent(src, i, 20); //商品条码
-                String depotName = ExcelUtils.getContent(src, i, 21); //仓库名称
-                String position = ExcelUtils.getContent(src, i, 22); //仓位货架
-                String inventory = ExcelUtils.getContent(src,i,23);//库存
-                String otherField1 = ExcelUtils.getContent(src, i, 24); //自定义1
-                String otherField2 = ExcelUtils.getContent(src, i, 25); //自定义2
-                String otherField3 = ExcelUtils.getContent(src, i, 26); //自定义3
-                String remark = ExcelUtils.getContent(src, i, 27); //备注
                 //名称为空
                 if(StringUtil.isEmpty(name)) {
                     throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_NAME_EMPTY_CODE,
@@ -1804,21 +1771,21 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
                     throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_NAME_OVER_CODE,
                             String.format(ExceptionConstants.MATERIAL_NAME_OVER_MSG, i+1));
                 }
+                String standard = ExcelUtils.getContent(src, i, 1); //规格
                 //规格长度超出
                 if(StringUtil.isNotEmpty(standard) && standard.length()>100) {
                     throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_STANDARD_OVER_CODE,
                             String.format(ExceptionConstants.MATERIAL_STANDARD_OVER_MSG, i+1));
                 }
+                String model = ExcelUtils.getContent(src, i, 2); //型号
                 //型号长度超出
                 if(StringUtil.isNotEmpty(model) && model.length()>100) {
                     throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_MODEL_OVER_CODE,
                             String.format(ExceptionConstants.MATERIAL_MODEL_OVER_MSG, i+1));
                 }
-                //基本单位为空
-                if(StringUtil.isEmpty(unit)) {
-                    throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_UNIT_EMPTY_CODE,
-                            String.format(ExceptionConstants.MATERIAL_UNIT_EMPTY_MSG, i+1));
-                }
+                String color = ExcelUtils.getContent(src, i, 3); //颜色
+                String brand = ExcelUtils.getContent(src, i, 4); //品牌
+                String categoryName = ExcelUtils.getContent(src, i, 5); //类别
                 //类别为空
                 if(StringUtil.isEmpty(categoryName)) {
                     throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_Category_Name_EMPTY_CODE,
@@ -1831,8 +1798,46 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
                     throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_TYPE_NOT_DECIMAL_CODE,
                             String.format(ExceptionConstants.MATERIAL_TYPE_NOT_DECIMAL_MSG, i+1));
                 }
+                String weight = ExcelUtils.getContent(src, i, 6); //基础重量(kg)
+                if(StringUtil.isNotEmpty(weight)) {
+                    //校验基础重量是否是数字(含小数)
+                    if(!StringUtil.isPositiveBigDecimal(weight)) {
+                        throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_WEIGHT_NOT_DECIMAL_CODE,
+                                String.format(ExceptionConstants.MATERIAL_WEIGHT_NOT_DECIMAL_MSG, i+1));
+                    }
+                }
+                String unit = ExcelUtils.getContent(src, i, 7); //基本单位
+                //基本单位为空
+                if(StringUtil.isEmpty(unit)) {
+                    throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_UNIT_EMPTY_CODE,
+                            String.format(ExceptionConstants.MATERIAL_UNIT_EMPTY_MSG, i+1));
+                }
+                String manyUnit = ExcelUtils.getContent(src, i, 8); //副单位
+                String ratio = ExcelUtils.getContent(src, i, 9); //比例
+                String sku = 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); //最低售价
+                String enabled = ExcelUtils.getContent(src, i, 15); //状态
+                //状态格式错误
+                if(!"1".equals(enabled) && !"0".equals(enabled)) {
+                    throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_ENABLED_ERROR_CODE,
+                            String.format(ExceptionConstants.MATERIAL_ENABLED_ERROR_MSG, i+1));
+                }
+                String enableSerialNumber = ExcelUtils.getContent(src, i, 16); //序列号
+                String productionDate = ExcelUtils.getContent(src, i, 17); //生产日期
+                String expiryNum = ExcelUtils.getContent(src, i, 18); //保质期天数
+                if(StringUtil.isNotEmpty(expiryNum)) {
+                    //校验保质期是否是正整数
+                    if(!StringUtil.isPositiveLong(expiryNum)) {
+                        throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_EXPIRY_NUM_NOT_INTEGER_CODE,
+                                String.format(ExceptionConstants.MATERIAL_EXPIRY_NUM_NOT_INTEGER_MSG, i+1));
+                    }
+                }
+                String supplier = ExcelUtils.getContent(src, i, 19); //供应商
                 Long supplierId = null;
-                if (supplier != null && !supplier.isEmpty()){
+                if(StringUtil.isNotEmpty(supplier)) {
                     //根据供应商查询供应商id
                     Supplier s  = supplierService.getOne(new LambdaQueryWrapperX<Supplier>().eq(Supplier::getSupplier,supplier));
                     supplierId = s.getId();
@@ -1842,8 +1847,10 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
                                 String.format(ExceptionConstants.MATERIAL_SUPPLIER_NOT_DECIMAL_MSG, i+1));
                     }
                 }
+                String barCode = ExcelUtils.getContent(src, i, 20); //商品条码
+                String depotName = ExcelUtils.getContent(src, i, 21); //仓库名称
                 Long depotId = null;
-                if (depotName != null && !depotName.isEmpty()){
+                if(StringUtil.isNotEmpty(supplier)) {
                     //根据仓库名查询仓库id
                     depotId = depotMapperEx.selectByConditionDepot(depotName,null,null).get(0).getId();
                     if (depotId == null){
@@ -1852,6 +1859,12 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
                                 String.format(ExceptionConstants.MATERIAL_DEPOT_NOT_DECIMAL_MSG, i+1));
                     }
                 }
+                String position = ExcelUtils.getContent(src, i, 22); //仓位货架
+                String inventory = ExcelUtils.getContent(src,i,23);//库存
+                String otherField1 = ExcelUtils.getContent(src, i, 24); //自定义1
+                String otherField2 = ExcelUtils.getContent(src, i, 25); //自定义2
+                String otherField3 = ExcelUtils.getContent(src, i, 26); //自定义3
+                String remark = ExcelUtils.getContent(src, i, 27); //备注
                 MaterialWithInitStock m = new MaterialWithInitStock();
                 //设置商品名字、规格、型号、颜色、品牌、类型id
                 m.setName(name);
@@ -1862,53 +1875,42 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
                 m.setCategoryId(categoryId);
                 //通过名称生成助记码
                 m.setMnemonic(PinYinUtil.getFirstLettersLo(name));
+                //设置单位、备注、基础重量
+                m.setUnit(unit);
+                m.setRemark(remark);
+                m.setWeight(new BigDecimal(weight));
+                //设置商品是否启用
+                m.setEnabled("1".equals(enabled));
+                //设置商品是否开启序列号
+                if(StringUtil.isNotEmpty(enableSerialNumber) && "1".equals(enableSerialNumber)) {
+                    m.setEnableSerialNumber("1");
+                } else {
+                    m.setEnableSerialNumber("0");
+                }
                 //获取类型编码
                 Long serial_no = categoryId == null ? null : materialCategoryService.getMaterialCategory(m.getCategoryId()).getSerialNo();
                 //设置系统sku
-                m.setSystemSku(serial_no + DateUtils.dateTimeNow());
-                if(StringUtil.isNotEmpty(weight)) {
-                    //校验基础重量是否是数字(含小数)
-                    if(!StringUtil.isPositiveBigDecimal(weight)) {
-                        throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_WEIGHT_NOT_DECIMAL_CODE,
-                                String.format(ExceptionConstants.MATERIAL_WEIGHT_NOT_DECIMAL_MSG, i+1));
-                    }
-                    m.setWeight(new BigDecimal(weight));
-                }
-                if(StringUtil.isNotEmpty(expiryNum)) {
-                    //校验保质期是否是正整数
-                    if(!StringUtil.isPositiveLong(expiryNum)) {
-                        throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_EXPIRY_NUM_NOT_INTEGER_CODE,
-                                String.format(ExceptionConstants.MATERIAL_EXPIRY_NUM_NOT_INTEGER_MSG, i+1));
-                    }
-                    //m.setExpiryNum(Integer.parseInt(expiryNum));
-                }
+                m.setSystemSku(serial_no + DateUtils.dateTimeNow() + RandomHelper.getRandomStr(6));
                 m.setOtherField1(StringUtil.isNotEmpty(otherField1)?otherField1:null);
                 m.setOtherField2(StringUtil.isNotEmpty(otherField2)?otherField2:null);
                 m.setOtherField3(StringUtil.isNotEmpty(otherField3)?otherField3:null);
                 m.setRemark(remark);
-                //状态格式错误
-                if(!"1".equals(enabled) && !"0".equals(enabled)) {
-                    throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_ENABLED_ERROR_CODE,
-                            String.format(ExceptionConstants.MATERIAL_ENABLED_ERROR_MSG, i+1));
-                }
-                //批量校验excel中有无重复商品,是指名称、规格、型号、颜色、单位、多属性
-                //batchCheckExistMaterialListByParam(mList, name, standard, model, color, unit, sku);
                 //设置商品拓展属性
                 JSONObject materialExObj = new JSONObject();
                 JSONObject basicObj = new JSONObject();
-                basicObj.put("commodityUnit", unit);
-                basicObj.put("sku", sku);
-                basicObj.put("purchaseDecimal", purchaseDecimal);
-                basicObj.put("commodityDecimal", commodityDecimal);
-                basicObj.put("wholesaleDecimal", wholesaleDecimal);
-                basicObj.put("lowDecimal", lowDecimal);
-                basicObj.put("productionDate",productionDate);
-                basicObj.put("expiryNum",expiryNum);
-                basicObj.put("supplierId",supplierId);
-                basicObj.put("barCode", barCode);
-                basicObj.put("inventory",inventory);
-                basicObj.put("depotId",depotId);
-                basicObj.put("position",position);
+                basicObj.put("commodityUnit", unit);    //商品单位
+                basicObj.put("sku", sku);   //商品属性
+                basicObj.put("purchaseDecimal", purchaseDecimal);   //采购价格
+                basicObj.put("commodityDecimal", commodityDecimal); //零售价格
+                basicObj.put("wholesaleDecimal", wholesaleDecimal); //销售价格
+                basicObj.put("lowDecimal", lowDecimal); //最低售价
+                basicObj.put("productionDate",productionDate); //生产日期
+                basicObj.put("expiryNum",expiryNum);    //保质期天数
+                basicObj.put("supplierId",supplierId); //供应商id
+                basicObj.put("barCode", barCode); //商品条码
+                basicObj.put("inventory",inventory); //库存
+                basicObj.put("depotId",depotId);    //仓库id
+                basicObj.put("position",position);  //仓位货架
                 materialExObj.put("basic", basicObj);
                 if(StringUtil.isNotEmpty(manyUnit) && StringUtil.isNotEmpty(ratio)){ //多单位
                     //校验比例是否是数字(含小数)
@@ -1921,46 +1923,31 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
                         m.setUnitId(unitId);
                         m.setUnit("");
                     }
-                    JSONObject otherObj = new JSONObject();
-                    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);
+//                    JSONObject otherObj = new JSONObject();
+//                    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);
                 } else {
                     m.setUnit(unit);
                     m.setUnitId(null);
                 }
                 m.setMaterialExObj(materialExObj);
-                //设置商品是否启用
-                m.setEnabled("1".equals(enabled));
-                //设置商品是否开启序列号
-                if(StringUtil.isNotEmpty(enableSerialNumber) && "1".equals(enableSerialNumber)) {
-                    m.setEnableSerialNumber("1");
-                } else {
-                    m.setEnableSerialNumber("0");
-                }
                 //设置库存
                 m.setStockMap(getStockMapCache(src, depotCount, depotMap, i));
                 mList.add(m);
             }
             //处理表单信息,转为对象集合
             List<Material> materialList = parseMapByExcelData(mList);
-            List<Long> deleteInitialStockMaterialIdList = new ArrayList<>();
-            List<Long> deleteCurrentStockMaterialIdList = new ArrayList<>();
-            List<MaterialInitialStock> insertInitialStockMaterialList = new ArrayList<>();
-            List<MaterialCurrentStock> insertCurrentStockMaterialList = new ArrayList<>();
-            //防止初始库存和当前库存出现重复
-            Map<String, String> materialDepotInitialMap = new HashMap<>();
-            Map<String, String> materialDepotCurrentMap = new HashMap<>();
             for (Material material : materialList) {
-                //添加商品
+                //添加商品信息
                 materialMapperEx.insertSelectiveEx(material);
-                //
-                Long mId = material.getId();
+                //添加商品子信息
                 for (MaterialExtend materialExtend : material.getList()) {
-                    materialExtend.setMaterialId(mId);
+                    //设置商品id
+                    materialExtend.setMaterialId( material.getId());
                     materialExtendService.insertMaterialExtend(materialExtend);
                 }
             }
@@ -2069,6 +2056,10 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
                 material.setUnit(m.getUnit());
                 //计量单位Id
                 material.setUnitId(m.getUnitId());
+                //备注
+                material.setRemark(m.getRemark());
+                //基础重量
+                material.setWeight(m.getWeight());
                 //启用 0-禁用  1-启用
                 material.setEnabled(m.getEnabled());
                 //自定义1
@@ -2114,6 +2105,7 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
             materialExtend.setDepotId(basicObj.getLong("depotId"));
             //仓位货架
             materialExtend.setPosition(basicObj.getString("position"));
+            //库存
             materialExtend.setInventory(basicObj.getBigDecimal("inventory"));
             materialMap.get(str).getList().add(materialExtend);
         }

+ 10 - 0
src/main/resources/mapper_xml/MaterialExtendMapperEx.xml

@@ -82,4 +82,14 @@
         where material_id=#{materialId} and default_flag='1'
         and ifnull(delete_Flag,'0') !='1'
     </select>
+
+    <select id="getMaterialExtendCountByDepotIds" resultType="int">
+        SELECT COUNT(id) FROM jsh_material_extend
+        WHERE depot_id IN (
+        <foreach collection="depotIds" item="depotId" separator=",">
+            #{depotId}
+        </foreach>
+        )
+        AND IFNULL(delete_Flag,'0') != '1'
+    </select>
 </mapper>