Jelajahi Sumber

二期: bug修改

huang 12 jam lalu
induk
melakukan
a18d733b47

+ 3 - 1
docs/new_sql.sql

@@ -227,7 +227,9 @@ ALTER TABLE jsh_material_category
 ALTER TABLE jsh_material
   ADD COLUMN expiry_num INT DEFAULT NULL COMMENT '保质期天数',
   ADD COLUMN default_purchase_decimal DECIMAL(24,2) DEFAULT NULL COMMENT '默认采购价格',
-  ADD COLUMN default_wholesale_decimal DECIMAL(24,2) DEFAULT NULL COMMENT '默认销售价格';
+  ADD COLUMN default_wholesale_decimal DECIMAL(24,2) DEFAULT NULL COMMENT '默认销售价格',
+  ADD COLUMN reminder VARCHAR(255) DEFAULT NULL COMMENT '商品提醒';
+
 
 -- 供应商信息表  新增供应商编码,是否支持售后,售后规则
 ALTER TABLE jsh_supplier

+ 2 - 15
src/main/java/com/jsh/erp/controller/MaterialCategoryController.java

@@ -9,10 +9,7 @@ import com.jsh.erp.datasource.entities.MaterialCategory;
 import com.jsh.erp.datasource.vo.TreeNode;
 import com.jsh.erp.service.MaterialCategoryService;
 
-import com.jsh.erp.utils.BaseResponseInfo;
-import com.jsh.erp.utils.Constants;
-import com.jsh.erp.utils.ErpInfo;
-import com.jsh.erp.utils.StringUtil;
+import com.jsh.erp.utils.*;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.slf4j.Logger;
@@ -166,21 +163,11 @@ public class MaterialCategoryController extends BaseController {
     }
     /**
      * 获取商品类别树数据
-     * @Param:
-     * @return com.alibaba.fastjson.JSONArray
      */
     @RequestMapping(value = "/getMaterialCategoryTree")
     @ApiOperation(value = "获取商品类别树数据")
     public JSONArray getMaterialCategoryTree(@RequestParam("id") Long id) throws Exception{
-       JSONArray arr=new JSONArray();
        List<TreeNode> materialCategoryTree = materialCategoryService.getMaterialCategoryTree(id);
-       if(materialCategoryTree!=null&&materialCategoryTree.size()>0){
-           for(TreeNode node:materialCategoryTree){
-               String str=JSON.toJSONString(node);
-               JSONObject obj=JSON.parseObject(str);
-               arr.add(obj) ;
-           }
-       }
-        return arr;
+        return TreeNodeUtils.conversion(materialCategoryTree);
     }
 }

+ 0 - 1
src/main/java/com/jsh/erp/controller/MaterialController.java

@@ -2,7 +2,6 @@ package com.jsh.erp.controller;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
-import com.jsh.erp.base.AjaxResult;
 import com.jsh.erp.base.BaseController;
 import com.jsh.erp.base.TableDataInfo;
 import com.jsh.erp.datasource.dto.MaterialDto;

+ 14 - 11
src/main/java/com/jsh/erp/controller/OrganizationController.java

@@ -10,6 +10,7 @@ import com.jsh.erp.service.OrganizationService;
 import com.jsh.erp.service.UserService;
 import com.jsh.erp.utils.BaseResponseInfo;
 import com.jsh.erp.utils.ErpInfo;
+import com.jsh.erp.utils.TreeNodeUtils;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.slf4j.Logger;
@@ -148,16 +149,16 @@ public class OrganizationController {
     @GetMapping(value = "/getOrganizationTree")
     @ApiOperation(value = "获取机构树数据")
     public JSONArray getOrganizationTree(@RequestParam("id") Long id) throws Exception{
-       JSONArray arr=new JSONArray();
+       //JSONArray arr=new JSONArray();
        List<TreeNode> organizationTree= organizationService.getOrganizationTree(id);
-       if(organizationTree!=null&&organizationTree.size()>0){
+       /*if(organizationTree!=null&&organizationTree.size()>0){
            for(TreeNode node:organizationTree){
                String str=JSON.toJSONString(node);
                JSONObject obj=JSON.parseObject(str);
                arr.add(obj);
            }
-       }
-        return arr;
+       }*/
+        return TreeNodeUtils.conversion(organizationTree);
     }
 
     /**
@@ -174,13 +175,15 @@ public class OrganizationController {
         String roleType = userService.getRoleTypeByUserId(userId).getType();
         if(BusinessConstants.ROLE_TYPE_PUBLIC.equals(roleType)) {
             List<TreeNode> organizationTree = organizationService.getOrganizationTree(null);
-            if(organizationTree!=null && organizationTree.size()>0){
-                for(TreeNode node: organizationTree){
-                    String str = JSON.toJSONString(node);
-                    JSONObject obj = JSON.parseObject(str);
-                    arr.add(obj);
-                }
-            }
+            arr = TreeNodeUtils.conversion(organizationTree);
+//            if(organizationTree!=null && organizationTree.size()>0){
+//                for(TreeNode node: organizationTree){
+//                    String str = JSON.toJSONString(node);
+//                    JSONObject obj = JSON.parseObject(str);
+//                    arr.add(obj);
+//                }
+//            }
+
         }
         return arr;
     }

+ 7 - 11
src/main/java/com/jsh/erp/controller/pda/PdaController.java

@@ -19,9 +19,11 @@ import com.jsh.erp.datasource.pda.vo.*;
 import com.jsh.erp.datasource.vo.SpinnerVO;
 import com.jsh.erp.datasource.vo.TaskStocktakingVO;
 import com.jsh.erp.datasource.vo.TreeNode;
+import com.jsh.erp.exception.BusinessRunTimeException;
 import com.jsh.erp.query.LambdaQueryWrapperX;
 import com.jsh.erp.service.*;
 import com.jsh.erp.utils.StringUtil;
+import com.jsh.erp.utils.TreeNodeUtils;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiOperation;
@@ -181,16 +183,8 @@ public class PdaController extends BaseController {
     @ApiOperation(value = "获取商品类别树数据")
     @GetMapping(value = "/getMaterialCategoryTree")
     public JSONArray getMaterialCategoryTree(@RequestParam("id") Long id) throws Exception{
-        JSONArray arr=new JSONArray();
         List<TreeNode> materialCategoryTree = materialCategoryService.getMaterialCategoryTree(id);
-        if(materialCategoryTree!=null&&materialCategoryTree.size()>0){
-            for(TreeNode node:materialCategoryTree){
-                String str= JSON.toJSONString(node);
-                JSONObject obj=JSON.parseObject(str);
-                arr.add(obj) ;
-            }
-        }
-        return arr;
+        return TreeNodeUtils.conversion(materialCategoryTree);
     }
 
     @ApiOperation("开始任务")
@@ -266,9 +260,11 @@ public class PdaController extends BaseController {
     public AjaxResult orderSubmit(@RequestBody PDADepotHeadDTO pdaDepotHeadDTO) {
         try {
             depotHeadService.pdaOrderSubmit(pdaDepotHeadDTO);
-        } catch (Exception e) {
+        }catch (BusinessRunTimeException e) {
+            return AjaxResult.error(e.getMessage());
+        }catch (Exception e) {
             e.printStackTrace();
-            return AjaxResult.error();
+            return AjaxResult.error("入库失败");
         }
         return AjaxResult.success();
     }

+ 40 - 0
src/main/java/com/jsh/erp/datasource/entities/AuditProcess.java

@@ -0,0 +1,40 @@
+package com.jsh.erp.datasource.entities;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * 审核流程比表实体类
+ */
+@Data
+public class AuditProcess {
+
+    @ApiModelProperty("主键ID")
+    @TableId(type = IdType.AUTO)
+    private Long id;
+
+    @ApiModelProperty("流程名称")
+    private String name;
+
+    @ApiModelProperty("流程类型")
+    private String type;
+
+    @ApiModelProperty("描述")
+    private String description;
+
+    @ApiModelProperty("创建人")
+    private Long createBy;
+
+    @ApiModelProperty("创建时间")
+    private Date createTime;
+
+    @ApiModelProperty("删除标记,0.未删除,1.已删除")
+    private Boolean deletedFlag;
+
+
+
+}

+ 1 - 2
src/main/java/com/jsh/erp/datasource/entities/MaterialCategory.java

@@ -15,7 +15,6 @@ import java.util.Date;
 @TableName("jsh_material_category")
 public class MaterialCategory {
 
-
     @ApiModelProperty("主键id")
     private Long id;
 
@@ -50,7 +49,7 @@ public class MaterialCategory {
     private String deleteFlag;
 
     @ApiModelProperty("有效期阈值")
-    private int expiryThreshold;
+    private Integer expiryThreshold;
 
     public Long getId() {
         return id;

+ 2 - 0
src/main/java/com/jsh/erp/datasource/pda/dto/PDADepotHeadDTO.java

@@ -1,8 +1,10 @@
 package com.jsh.erp.datasource.pda.dto;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
+import java.util.Date;
 import java.util.List;
 
 @Data

+ 3 - 0
src/main/java/com/jsh/erp/datasource/pda/dto/PDADepotMaterialDto.java

@@ -23,4 +23,7 @@ public class PDADepotMaterialDto {
     @JsonFormat(pattern = "yyyy-MM-dd")
     private Date productionDate;
 
+    @ApiModelProperty("仓位货架")
+    private String position;
+
 }

+ 14 - 2
src/main/java/com/jsh/erp/service/MaterialCategoryService.java

@@ -1,6 +1,6 @@
 package com.jsh.erp.service;
 
-import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.jsh.erp.datasource.entities.MaterialCategory;
 import com.jsh.erp.datasource.vo.TreeNode;
@@ -11,13 +11,21 @@ import java.util.List;
 
 public interface MaterialCategoryService extends IService<MaterialCategory> {
 
-
+    /**
+     * 根据id查询商品类别
+     */
     MaterialCategory getMaterialCategory(long id)throws Exception;
 
+    /**
+     * 根据id集合查询商品类别
+     */
     List<MaterialCategory> getMaterialCategoryListByIds(String ids)throws Exception;
 
     List<MaterialCategory> getMaterialCategory()throws Exception;
 
+    /**
+     * 根据父类型ID查询全部子类型集合
+     */
     List<MaterialCategory> getAllList(Long parentId)throws Exception;
 
     List<MaterialCategory> getMCList(Long parentId)throws Exception;
@@ -59,6 +67,9 @@ public interface MaterialCategoryService extends IService<MaterialCategory> {
      */
     List<MaterialCategory> findById(Long id)throws Exception;
 
+    /**
+     * 获取商品类别树数据
+     */
     List<TreeNode> getMaterialCategoryTree(Long id) throws Exception;
 
     void  checkMaterialCategorySerialNo(MaterialCategory mc)throws Exception;
@@ -68,4 +79,5 @@ public interface MaterialCategoryService extends IService<MaterialCategory> {
      * @param name
      */
     Long getCategoryIdByName(String name);
+
 }

+ 3 - 0
src/main/java/com/jsh/erp/service/MaterialService.java

@@ -167,6 +167,9 @@ public interface MaterialService extends IService<Material> {
 
     String getBigUnitStock(BigDecimal stock, Long unitId) throws Exception;
 
+    /**
+     * 构造扩展信息
+     */
     String getMaterialOtherByParam(String[] mpArr, MaterialVo4Unit m);
 
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)

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

@@ -19,10 +19,7 @@ import com.jsh.erp.exception.JshException;
 import com.jsh.erp.query.LambdaQueryWrapperX;
 import com.jsh.erp.query.QueryWrapperX;
 import com.jsh.erp.service.*;
-import com.jsh.erp.utils.ExcelUtils;
-import com.jsh.erp.utils.PageUtils;
-import com.jsh.erp.utils.StringUtil;
-import com.jsh.erp.utils.Tools;
+import com.jsh.erp.utils.*;
 import jxl.Workbook;
 import jxl.write.WritableWorkbook;
 import org.slf4j.Logger;
@@ -92,6 +89,8 @@ public class DepotHeadServiceImpl extends ServiceImpl<DepotHeadMapper, DepotHead
     private SyncTescoSystemService syncTescoSystemService;
     @Resource
     private MaterialBatchService materialBatchService;
+    @Resource
+    private MaterialCategoryService materialCategoryService;
 
     /**
      * PDA查询订单
@@ -2013,6 +2012,27 @@ public class DepotHeadServiceImpl extends ServiceImpl<DepotHeadMapper, DepotHead
             MaterialExtend materialExtend = materialExtendService.getMaterialExtend(depotItem.getMaterialExtendId());
             //获取商品条码
             String barCode = materialExtend.getBarCode();
+            //校验商品保质期
+            if (depotHead.getType().equals("入库")){
+                //修改采购订单的生产日期和库位
+                depotItemService.update(new UpdateWrapper<DepotItem>().set("production_date",depotItem.getProductionDate())
+                                .set("position",depotItem.getPosition())
+                                .eq("id",depotItem.getId()));
+                //获取商品信息
+                Material m = materialService.getMaterial(materialExtend.getMaterialId());
+                //获取商品类别
+                MaterialCategory mc = materialCategoryService.getMaterialCategory(m.getCategoryId());
+                if (mc.getExpiryThreshold() != null && mc.getExpiryThreshold() > 0){
+                    //商品生产天数
+                    int productionDay = DateUtils.differentDaysByMillisecond(depotItem.getProductionDate(),new Date());
+                    //保质期剩余天数
+                    int day = depotItem.getExpiryNum() - productionDay;
+                    if (day < mc.getExpiryThreshold()){
+                        throw new BusinessRunTimeException(ExceptionConstants.SERVICE_SYSTEM_ERROR_CODE,
+                                "商品" + m.getName()  + "即将过期,不允许入库");
+                    }
+                }
+            }
             //修改原先采购订单实际入库数量
             //depotItemService.update(new UpdateWrapper<DepotItem>().set("actual_quantity_in_storage", materialMap.get(batchNumber).getMaterialNumber()).eq("id", depotItem.getId()));
             //设置单据主表id
@@ -2022,6 +2042,8 @@ public class DepotHeadServiceImpl extends ServiceImpl<DepotHeadMapper, DepotHead
             depotItem.setId(null);
             //设置实际入库数量
             depotItem.setOperNumber(materialMap.get(barCode).getMaterialNumber());
+            depotItem.setProductionDate(materialMap.get(barCode).getProductionDate());
+            depotItem.setPosition(materialMap.get(barCode).getPosition());
             //以下进行单位换算
             Unit unitInfo = materialService.findUnit(depotItem.getMaterialId()); //查询多单位信息
             if (StringUtil.isExist(depotItem.getOperNumber())) {

+ 3 - 5
src/main/java/com/jsh/erp/service/impl/MaterialBatchServiceImpl.java

@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.jsh.erp.datasource.entities.*;
 import com.jsh.erp.datasource.mappers.MaterialBatchMapper;
-import com.jsh.erp.datasource.mappers.MaterialCategoryMapperEx;
 import com.jsh.erp.datasource.vo.TaskStocktakingItemVO;
 import com.jsh.erp.exception.JshException;
 import com.jsh.erp.query.LambdaQueryWrapperX;
@@ -18,7 +17,6 @@ import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Date;
 import java.util.List;
@@ -42,10 +40,10 @@ public class MaterialBatchServiceImpl extends ServiceImpl<MaterialBatchMapper,Ma
     @Resource
     private InventoryLogService inventoryLogService;
 
-    @Resource
-    private MaterialService materialService;
-
 
+    /**
+     * 根据单据子表id生成商品批次数据
+     */
     @Override
     public void generateMaterialBatchByDepotItemId(DepotItem depotItem, Long supplierId) throws Exception {
         //获取条码信息

+ 5 - 2
src/main/java/com/jsh/erp/service/impl/MaterialCategoryServiceImpl.java

@@ -44,11 +44,14 @@ public class MaterialCategoryServiceImpl extends ServiceImpl<MaterialCategoryMap
     @Resource
     private MaterialMapperEx materialMapperEx;
 
+    /**
+     * 根据id查询商品类别
+     */
     @Override
     public MaterialCategory getMaterialCategory(long id)throws Exception {
-        MaterialCategory result=null;
+        MaterialCategory result = null;
         try{
-            result=materialCategoryMapper.selectByPrimaryKey(id);
+            result = materialCategoryMapper.selectByPrimaryKey(id);
         }catch(Exception e){
             JshException.readFail(logger, e);
         }

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

@@ -311,7 +311,6 @@ public class MaterialExtendServiceImpl extends ServiceImpl<MaterialExtendMapper,
                 this.insertMaterialExtend(materialExtend);
             }
         }
-
         //修改拓展行
         if (!updatedList.isEmpty()) {
             for (MaterialExtend materialExtend : updatedList) {

+ 12 - 23
src/main/java/com/jsh/erp/service/impl/MaterialServiceImpl.java

@@ -154,7 +154,6 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
             //类型不为空,获取类型id集合
             if(StringUtil.isNotEmpty(categoryId)){
                 idList = getListByParentId(Long.parseLong(categoryId));
-
             }
             PageUtils.startPage();
             list= materialMapperEx.selectByConditionMaterial(materialParam, standard, model, color, brand, mfrs, materialOther, weight, expiryNum,
@@ -206,26 +205,14 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
                 List<MaterialInitialStock> stockArr = material.getStock();
                 for (int i = 0; i < stockArr.size(); i++) {
                     MaterialInitialStock jsonObj = stockArr.get(i);
-                    //此时id为仓库id,仓库di、最低安全库存数量不为空
-                    if(jsonObj.getId() != null && jsonObj.getLowSafeStock() != null || jsonObj.getPosition() != null) {
-                        BigDecimal lowSafeStock = jsonObj.getLowSafeStock();
-                        BigDecimal highSafeStock = null;
-                        if(jsonObj.getHighSafeStock() != null) {
-                            highSafeStock = jsonObj.getHighSafeStock();
-                        }
+                    //此时id为仓库id,仓库id、最低安全库存数量、库位不为空
+                    if(jsonObj.getId() != null && jsonObj.getLowSafeStock() != null || jsonObj.getPosition() != null || jsonObj.getHighSafeStock() != null) {
                         Long depotId = jsonObj.getId();
                         jsonObj.setDepotId(depotId);
                         jsonObj.setMaterialId(mId);
                         jsonObj.setId(null);
-                        if(lowSafeStock != null || highSafeStock != null || jsonObj.getPosition() != null) {
-                            //设置初始库
-                            materialInitialStockMapper.insertSelective(jsonObj);
-                            //insertInitialStockByMaterialAndDepot(jsonObj);
-                            //设置当前库
-                            //insertCurrentStockByMaterialAndDepot(depotId, mId, parseBigDecimalEx(number));
-                            //更新当前库存
-                            //depotItemService.updateCurrentStockFun(mId, depotId);
-                        }
+                        //设置初始库
+                        materialInitialStockMapper.insertSelective(jsonObj);
                     }
                 }
             }
@@ -574,7 +561,7 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
             otherMaterialMap.putIfAbsent(me.getMaterialId(), me);
         }
         String nameStr = "名称*,规格,型号,颜色,品牌,类别,基础重量(kg),基本单位*,副单位,比例,多属性," +
-                "状态*,序列号,系统sku,商品条码,自定义1,自定义2,自定义3,备注";
+                "状态*,序列号,系统sku,商品条码,默认采购价,默认销售价,自定义1,自定义2,自定义3,备注";
         List<String> nameList = StringUtil.strToStringList(nameStr);
         //仓库列表
         List<Depot> depotList = depotService.getAllList();
@@ -612,12 +599,14 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
                 objs[12] = m.getEnableSerialNumber();
                 objs[13] = m.getSystemSku();
                 objs[14] = m.getBarCode();
-                objs[15] = m.getOtherField1();
-                objs[16] = m.getOtherField2();
-                objs[17] = m.getOtherField3();
-                objs[18] = m.getRemark();
+                objs[15] = m.getDefaultPurchaseDecimal().toString();
+                objs[16] = m.getDefaultWholesaleDecimal().toString();
+                objs[17] = m.getOtherField1();
+                objs[18] = m.getOtherField2();
+                objs[19] = m.getOtherField3();
+                objs[20] = m.getRemark();
                 //仓库期初库存
-                int i = 19;
+                int i = 21;
 //                for(Depot depot: depotList) {
 //                    BigDecimal number = misMap.get(m.getId() + "_" + depot.getId());
 //                    objs[i] = number == null ? "0" : number.setScale(2, BigDecimal.ROUND_HALF_UP).toString();

+ 28 - 0
src/main/java/com/jsh/erp/utils/TreeNodeUtils.java

@@ -0,0 +1,28 @@
+package com.jsh.erp.utils;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.jsh.erp.datasource.vo.TreeNode;
+
+import java.util.List;
+
+public class TreeNodeUtils {
+
+    /**
+     * 将树类型
+     * @param list
+     * @return
+     */
+    public static JSONArray conversion(List<TreeNode> list){
+        JSONArray arr=new JSONArray();
+        if(list != null && list.size()>0){
+            for(TreeNode node : list){
+                String str= JSON.toJSONString(node);
+                JSONObject obj=JSON.parseObject(str);
+                arr.add(obj) ;
+            }
+        }
+        return arr;
+    }
+}

+ 1 - 0
src/main/resources/mapper_xml/MaterialCategoryMapperEx.xml

@@ -83,6 +83,7 @@
         </if>
         order by sort asc
     </select>
+
     <insert id="addMaterialCategory" parameterType="com.jsh.erp.datasource.entities.MaterialCategory"
             useGeneratedKeys="true" keyProperty="id" keyColumn="id">
        insert into jsh_material_category

+ 1 - 1
src/main/resources/mapper_xml/MaterialMapperEx.xml

@@ -414,7 +414,7 @@
         and ifnull(m.delete_flag,'0') !='1'
     </select>
 
-    <select id="exportExcel" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultMap="ResultMapList">
+    <select id="exportExcel" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultType="com.jsh.erp.datasource.entities.MaterialVo4Unit">
         select m.*,u.name unitName, u.ratio, mc.name categoryName,me.bar_code,me.commodity_unit,me.purchase_decimal, me.commodity_decimal,
         me.wholesale_decimal, me.low_decimal, me.sku, me.production_date, me.expiry_num, me.supplier_id, me.bar_code, me.batch_number, me.depot_id, me.position
         from jsh_material m