Explorar el Código

物料出入库

zxz hace 2 años
padre
commit
f02ed1387a

+ 51 - 3
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/controller/MaterialWarehouseInOutController.java

@@ -1,9 +1,11 @@
 package com.yh.saas.plugin.yiliangyiyun.controller;
 
 
-import org.springframework.web.bind.annotation.RequestMapping;
-
-import org.springframework.web.bind.annotation.RestController;
+import com.baomidou.mybatisplus.plugins.Page;
+import com.yh.saas.plugin.yiliangyiyun.entity.MaterialWarehouseInOut;
+import com.yh.saas.plugin.yiliangyiyun.service.IMaterialWarehouseInOutService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
 
 /**
  * <p>
@@ -16,6 +18,52 @@ import org.springframework.web.bind.annotation.RestController;
 @RestController
 @RequestMapping("/materialWarehouseInOut")
 public class MaterialWarehouseInOutController {
+    @Autowired
+    private IMaterialWarehouseInOutService materialWarehouseInOutService;
+
+    /**
+     * 称毛重
+     * @param materialWarehouseInOut
+     */
+    @PostMapping("/api/addMaterial")
+    public String addMaterial(@RequestBody MaterialWarehouseInOut materialWarehouseInOut){
+        return materialWarehouseInOutService.addMaterial(materialWarehouseInOut);
+    }
+
+    /**
+     * 称皮重
+     * @param materialWarehouseInOut
+     */
+    @PostMapping("/api/editMaterial")
+    public String editMaterial(@RequestBody MaterialWarehouseInOut materialWarehouseInOut){
+        return materialWarehouseInOutService.editMaterial(materialWarehouseInOut);
+    }
+
+    /**
+     * 删除
+     * @param example
+     */
+    @PostMapping("/api/deleteMaterialInfo")
+    public void deleteMaterialInfo(@RequestBody MaterialWarehouseInOut example){
+        materialWarehouseInOutService.deleteMaterialInfo(example.getId());
+    }
 
+    /**
+     * 物料出入库记录
+     * @param materialWarehouseInOut
+     */
+    @GetMapping("/selectMaterialWarehousePage")
+    public Page<MaterialWarehouseInOut> selectMaterialWarehousePage(MaterialWarehouseInOut materialWarehouseInOut){
+        return materialWarehouseInOutService.selectMaterialWarehousePage(materialWarehouseInOut);
+    }
+    /**
+     * 查看
+     * @param id
+     * @return
+     */
+    @GetMapping("/getMaterialInfo")
+    public MaterialWarehouseInOut getMaterialInfo (String id){
+        return materialWarehouseInOutService.getMaterialInfo(id);
+    }
 }
 

+ 34 - 6
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/entity/MaterialWarehouseInOut.java

@@ -4,13 +4,16 @@ import java.util.Date;
 import java.io.Serializable;
 
 
+import com.baomidou.mybatisplus.annotations.TableField;
 import com.baomidou.mybatisplus.annotations.TableId;
 import com.baomidou.mybatisplus.annotations.TableName;
 import com.baomidou.mybatisplus.enums.IdType;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import com.yh.saas.common.support.entity.BaseModel;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
+import org.springframework.format.annotation.DateTimeFormat;
 
 /**
  * <p>
@@ -61,10 +64,6 @@ public class MaterialWarehouseInOut extends BaseModel<MaterialWarehouseInOut> {
      * 车牌号
      */
     private String carNo;
-    /**
-     * 物料名称key
-     */
-    private String itemNameKey;
     /**
      * 物料名称
      */
@@ -82,7 +81,7 @@ public class MaterialWarehouseInOut extends BaseModel<MaterialWarehouseInOut> {
      */
     private String inOutFlag;
     /**
-     * 统计方式(1称重出库3计数出库
+     * 统计方式(1称重3计数)
      */
     private String deliveryMethod;
     /**
@@ -100,7 +99,7 @@ public class MaterialWarehouseInOut extends BaseModel<MaterialWarehouseInOut> {
     /**
      * 数量(个)
      */
-    private Long purchaseQuantity;
+    private Long materialQuantity;
     /**
      * 状态标识(1待称皮重3待称毛重5已入库7已出库)
      */
@@ -113,6 +112,35 @@ public class MaterialWarehouseInOut extends BaseModel<MaterialWarehouseInOut> {
      * 出入库日期
      */
     private Date inOutWarehouseDate;
+    /**
+     * 模糊查询
+     */
+    @TableField(exist = false)
+    private String searchKeyWord;
+    /**
+     * 开始时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @DateTimeFormat(pattern = "yyyy-MM-dd")
+    @TableField(exist = false)
+    private Date startDate;
+    /**
+     * 结束时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @DateTimeFormat(pattern = "yyyy-MM-dd")
+    @TableField(exist = false)
+    private Date endDate;
+    /**
+     * 查询类型(1入库3出库)
+     */
+    @TableField(exist = false)
+    private String searchType;
+    /**
+     * 仓库编号
+     */
+    @TableField(exist = false)
+    private String warehouseNo;
 
 
     @Override

+ 25 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/mapper/MaterialWarehouseInOutMapper.java

@@ -3,6 +3,9 @@ package com.yh.saas.plugin.yiliangyiyun.mapper;
 import com.yh.saas.plugin.yiliangyiyun.entity.MaterialWarehouseInOut;
 import com.baomidou.mybatisplus.mapper.BaseMapper;
 
+import java.util.List;
+import java.util.Map;
+
 /**
  * <p>
  * 记录物料出入库信息 Mapper 接口
@@ -12,5 +15,27 @@ import com.baomidou.mybatisplus.mapper.BaseMapper;
  * @since 2023-02-01
  */
 public interface MaterialWarehouseInOutMapper extends BaseMapper<MaterialWarehouseInOut> {
+    /**
+     * 根据条件查询物料出入库记录总数
+     *
+     * @param pageView
+     * @return
+     */
+    Integer getCountByCondition(Map<String, Object> pageView);
+
+    /**
+     * 根据条件查询物料出入库记录列表
+     *
+     * @param pageView
+     * @return
+     */
+    List<MaterialWarehouseInOut> getListByCondition(Map<String, Object> pageView);
 
+    /**
+     * 根据条件查询业务编号列表
+     *
+     * @param pageView
+     * @return
+     */
+    List<MaterialWarehouseInOut> getListByConditionNo(Map<String, Object> pageView);
 }

+ 45 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/IMaterialWarehouseInOutService.java

@@ -1,8 +1,11 @@
 package com.yh.saas.plugin.yiliangyiyun.service;
 
+import com.baomidou.mybatisplus.plugins.Page;
 import com.yh.saas.plugin.yiliangyiyun.entity.MaterialWarehouseInOut;
 import com.baomidou.mybatisplus.service.IService;
 
+import java.util.List;
+
 /**
  * <p>
  * 记录物料出入库信息 服务类
@@ -12,5 +15,47 @@ import com.baomidou.mybatisplus.service.IService;
  * @since 2023-02-01
  */
 public interface IMaterialWarehouseInOutService extends IService<MaterialWarehouseInOut> {
+    /**
+     * 查询业务编号
+     * @param
+     * @return
+     */
+    List<MaterialWarehouseInOut> selectMaterialNoList(MaterialWarehouseInOut materialWarehouseInOut);
+
+    /**
+     * 称毛重
+     *
+     * @param materialWarehouseInOut
+     * @return
+     */
+    String addMaterial(MaterialWarehouseInOut materialWarehouseInOut);
+
+    /**
+     * 称皮重
+     *
+     * @param materialWarehouseInOut
+     * @return
+     */
+    String editMaterial(MaterialWarehouseInOut materialWarehouseInOut);
+
+    /**
+     * 删除
+     * @param id
+     * @return
+     */
+    void deleteMaterialInfo(String id);
+
+    /**
+     * 物料出入库记录
+     * @param materialWarehouseInOut
+     * @return
+     */
+    Page<MaterialWarehouseInOut> selectMaterialWarehousePage(MaterialWarehouseInOut materialWarehouseInOut);
 
+    /**
+     * 查看
+     * @param id
+     * @return
+     */
+    MaterialWarehouseInOut getMaterialInfo(String id);
 }

+ 188 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/impl/MaterialWarehouseInOutServiceImpl.java

@@ -1,10 +1,22 @@
 package com.yh.saas.plugin.yiliangyiyun.service.impl;
 
+import com.baomidou.mybatisplus.plugins.Page;
+import com.google.common.collect.Lists;
+import com.winsea.svc.base.security.util.AuthSecurityUtils;
+import com.yh.saas.common.support.util.IdGenerator;
+import com.yh.saas.plugin.yiliangyiyun.constant.StatusEnum;
 import com.yh.saas.plugin.yiliangyiyun.entity.MaterialWarehouseInOut;
 import com.yh.saas.plugin.yiliangyiyun.mapper.MaterialWarehouseInOutMapper;
 import com.yh.saas.plugin.yiliangyiyun.service.IMaterialWarehouseInOutService;
 import com.baomidou.mybatisplus.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 /**
  * <p>
@@ -17,4 +29,180 @@ import org.springframework.stereotype.Service;
 @Service
 public class MaterialWarehouseInOutServiceImpl extends ServiceImpl<MaterialWarehouseInOutMapper, MaterialWarehouseInOut> implements IMaterialWarehouseInOutService {
 
+    /**
+     * 查询业务编号
+     * @param materialWarehouseInOut
+     * @return
+     */
+    @Override
+    public List<MaterialWarehouseInOut> selectMaterialNoList(MaterialWarehouseInOut materialWarehouseInOut) {
+        SimpleDateFormat f = new SimpleDateFormat("yyyyMMdd");//设置日期格式
+        String date = f.format(new Date(System.currentTimeMillis()));
+        Map<String, Object> pageView = new HashMap<>(7);
+        pageView.put("date", date);
+        pageView.put("warehouseNo", materialWarehouseInOut.getWarehouseNo());
+        pageView.put("inOutFlag", materialWarehouseInOut.getInOutFlag());
+        if("2".equals(materialWarehouseInOut.getInOutFlag())){
+            pageView.put("numberLetter", "WLRK");
+        }else{
+            pageView.put("numberLetter", "WLCK");
+        }
+        pageView.put("compId", materialWarehouseInOut.getCompId());
+        List<MaterialWarehouseInOut> dataList = baseMapper.getListByConditionNo(pageView);
+        return dataList;
+    }
+    /**
+     * 添加
+     * @param materialWarehouseInOut
+     * @return
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public String addMaterial(MaterialWarehouseInOut materialWarehouseInOut) {
+        //新增主键id
+        materialWarehouseInOut.setId(IdGenerator.generateUUID());
+        if(materialWarehouseInOut.getCompId() == null || materialWarehouseInOut.getCompId().isEmpty()){
+            materialWarehouseInOut.setCompId(AuthSecurityUtils.getStaffById(AuthSecurityUtils.getCurrentUserId()).getCompId());
+        }
+        //获取当前年月日
+        SimpleDateFormat f = new SimpleDateFormat("yyyyMMdd");//设置日期格式
+        String date = f.format(new Date(System.currentTimeMillis()));
+        //查询烘干入库信息数量包括已删除的集合
+        List<MaterialWarehouseInOut> materialNoList = this.selectMaterialNoList(materialWarehouseInOut);
+        //生成业务编号
+        if (materialNoList.size() > 0) {
+            //取第一条数据的编号
+            String n = materialNoList.get(0).getBusinessNo();
+            int intNumber = 0;
+            //截取编号后3位
+            intNumber = Integer.parseInt(n.substring(15));
+            intNumber++;
+            String Number = String.valueOf(intNumber);
+            for (int i = 0; i < 3; i++) {
+                Number = Number.length() < 3 ? "0" + Number : Number;
+            }
+            //编号自增
+            //入库编号
+            if("2".equals(materialWarehouseInOut.getInOutFlag())){
+                Number = "WLRK" + date + materialWarehouseInOut.getWarehouseNo() + Number;
+            }
+            //出库编号
+            else{
+                Number = "WLCK" + date + materialWarehouseInOut.getWarehouseNo() + Number;
+            }
+            materialWarehouseInOut.setBusinessNo(Number);
+        } else {
+            //如果当天数据为空,生成第一条数据
+            String Number = "";
+            if("2".equals(materialWarehouseInOut.getInOutFlag())) {
+                Number  = "WLRK" + date + materialWarehouseInOut.getWarehouseNo() + "001";
+            }else{
+                Number  = "WLCK" + date + materialWarehouseInOut.getWarehouseNo() + "001";
+            }
+            materialWarehouseInOut.setBusinessNo(Number);
+        }
+        //称重
+        if("1".equals(materialWarehouseInOut.getDeliveryMethod())){
+            //称重入库状态更新为待称皮重
+            if ("2".equals(materialWarehouseInOut.getInOutFlag())) {
+                materialWarehouseInOut.setStatus(StatusEnum.MATERIAL_TARE.getName());
+                materialWarehouseInOut.setStatusFlag(StatusEnum.MATERIAL_TARE.getFlag());
+            }
+            //称重出库状态更新为待称毛重
+            else {
+                materialWarehouseInOut.setStatus(StatusEnum.MATERIAL_GROSS.getName());
+                materialWarehouseInOut.setStatusFlag(StatusEnum.MATERIAL_GROSS.getFlag());
+            }
+        }
+        //计数
+        else{
+            //计数出库,状态更新为已出库
+            if ("1".equals(materialWarehouseInOut.getInOutFlag())) {
+                materialWarehouseInOut.setStatus(StatusEnum.ALREADY_OUT_MATERIAL.getName());
+                materialWarehouseInOut.setStatusFlag(StatusEnum.ALREADY_OUT_MATERIAL.getFlag());
+            }
+            //计数入库,状态更新为已入库
+            else{
+                materialWarehouseInOut.setStatus(StatusEnum.ALREADY_IN_MATERIAL.getName());
+                materialWarehouseInOut.setStatusFlag(StatusEnum.ALREADY_IN_MATERIAL.getFlag());
+            }
+        }
+
+        materialWarehouseInOut.setInOutWarehouseDate(new Date());
+        this.insert(materialWarehouseInOut);
+        return "ok";
+    }
+    /**
+     * 编辑
+     * @param materialWarehouseInOut
+     * @return
+     */
+    @Override
+    public String editMaterial(MaterialWarehouseInOut materialWarehouseInOut) {
+        //入库,状态更新为已入库
+        if("2".equals(materialWarehouseInOut.getInOutFlag())){
+            materialWarehouseInOut.setStatus(StatusEnum.ALREADY_IN_MATERIAL.getName());
+            materialWarehouseInOut.setStatusFlag(StatusEnum.ALREADY_IN_MATERIAL.getFlag());
+        }
+        //出库,状态更新为已出库
+        else {
+            materialWarehouseInOut.setStatus(StatusEnum.ALREADY_OUT_MATERIAL.getName());
+            materialWarehouseInOut.setStatusFlag(StatusEnum.ALREADY_OUT_MATERIAL.getFlag());
+        }
+        this.updateById(materialWarehouseInOut);
+        return "ok";
+    }
+    /**
+     * 删除
+     * @param id
+     * @return
+     */
+    @Override
+    public void deleteMaterialInfo(String id) {
+        MaterialWarehouseInOut materialWarehouseInOut = this.selectById(id);
+        if (materialWarehouseInOut != null) {
+            this.deleteById(materialWarehouseInOut.getId());
+        }
+    }
+
+    /**
+     * 物料出入库记录
+     * @param materialWarehouseInOut
+     * @return
+     */
+    @Override
+    public Page<MaterialWarehouseInOut> selectMaterialWarehousePage(MaterialWarehouseInOut materialWarehouseInOut) {
+        Map<String, Object> pageView = new HashMap<>();
+        pageView.put("startRecord", (materialWarehouseInOut.getCurrentPage() - 1)
+                * materialWarehouseInOut.getPageSize());
+        //公司id
+        pageView.put("baseId", materialWarehouseInOut.getBaseId());
+        pageView.put("startDate", materialWarehouseInOut.getStartDate());
+        pageView.put("endDate", materialWarehouseInOut.getEndDate());
+        pageView.put("searchType", materialWarehouseInOut.getSearchType());
+        pageView.put("inOutFlag", materialWarehouseInOut.getInOutFlag());
+        pageView.put("searchKeyWord", materialWarehouseInOut.getSearchKeyWord());
+        pageView.put("pageSize", materialWarehouseInOut.getPageSize());
+        pageView.put("currentPage", materialWarehouseInOut.getCurrentPage());
+        // 查询记录总数
+        Integer dataCount = baseMapper.getCountByCondition(pageView);
+        List<MaterialWarehouseInOut> dataList = baseMapper.getListByCondition(pageView);
+        Page<MaterialWarehouseInOut> page = new Page<>();
+        page.setRecords(dataList == null ? Lists.newArrayList() : dataList);
+        page.setTotal(dataCount == null ? 0 : dataCount);
+        page.setCurrent(materialWarehouseInOut.getCurrentPage());
+        page.setSize(materialWarehouseInOut.getPageSize());
+        return page;
+    }
+
+    /**
+     * 查看
+     * @param id
+     * @return
+     */
+    @Override
+    public MaterialWarehouseInOut getMaterialInfo(String id) {
+        MaterialWarehouseInOut materialWarehouseInOut = this.selectById(id);
+        return materialWarehouseInOut;
+    }
 }

+ 131 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/resources/mapper/MaterialWarehouseInOutMapper.xml

@@ -1,5 +1,136 @@
 <?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.yh.saas.plugin.yiliangyiyun.mapper.MaterialWarehouseInOutMapper">
+    <!-- 获得业务编号列表 -->
+    <select id="getListByConditionNo" parameterType="Map"
+            resultType="com.yh.saas.plugin.yiliangyiyun.entity.MaterialWarehouseInOut">
+        SELECT business_no from material_warehouse_in_out
+        WHERE comp_id = #{compId}
+        <if test="inOutFlag != null and inOutFlag != ''">
+            AND in_out_flag = #{inOutFlag}
+        </if>
+        <if test="numberLetter != null and numberLetter != ''">
+            <if test="date != null and date != ''">
+                <if test="warehouseNo != null and warehouseNo != ''">
+                    AND (lower(business_no) like lower(CONCAT('%',#{numberLetter}, + #{date}, + #{warehouseNo},'%')))
+                </if>
+            </if>
+        </if>
+        ORDER BY business_no DESC
+    </select>
 
+    <!-- 获得烘干入库记录总数 -->
+    <select id="getCountByCondition" parameterType="Map" resultType="java.lang.Integer">
+        SELECT
+        COUNT(id)
+        FROM material_warehouse_in_out
+        WHERE delete_flag = '0'
+        <if test="searchType != null and searchType != ''">
+            <!--待称皮重-->
+            <if test="searchType == 1">
+                AND status_flag = '1'
+            </if>
+            <!--待称毛重-->
+            <if test="searchType == 3">
+                AND status_flag = '3'
+            </if>
+        </if>
+        <if test="baseId != null and baseId != ''">
+            AND base_id = #{baseId}
+        </if>
+        <if test="inOutFlag != null and inOutFlag != ''">
+            <!--出库-->
+            <if test="inOutFlag == 1">
+                AND in_out_flag = '1'
+            </if>
+            <!--入库-->
+            <if test="inOutFlag == 2">
+                AND in_out_flag = '2'
+            </if>
+        </if>
+        <if test="searchKeyWord != null and searchKeyWord != ''">
+            AND (lower(car_no) like lower(CONCAT('%',#{searchKeyWord},'%'))
+            OR lower(item_name) like lower(CONCAT('%',#{searchKeyWord},'%'))
+            OR lower(gross_agent) like lower(CONCAT('%',#{searchKeyWord},'%'))
+            OR lower(tare_agent) like lower(CONCAT('%',#{searchKeyWord},'%')))
+        </if>
+        <if test="startDate != null">
+            AND (DATE_FORMAT(in_out_warehouse_date,"%Y%m%d") &gt;=
+            DATE_FORMAT(#{startDate},"%Y%m%d"))
+        </if>
+        <if test="endDate != null">
+            AND (DATE_FORMAT(in_out_warehouse_date,"%Y%m%d") &lt;=
+            DATE_FORMAT(#{endDate},"%Y%m%d"))
+        </if>
+    </select>
+
+    <!-- 获得物料出入库记录列表 -->
+    <select id="getListByCondition" parameterType="Map"
+            resultType="com.yh.saas.plugin.yiliangyiyun.entity.MaterialWarehouseInOut">
+        SELECT
+        id,
+        comp_id as compId,
+        base_id as baseId,
+        warehouse_name as warehouseName,
+        bin_number as binNumber,
+        business_no as businessNo,
+        car_no as carNo,
+        item_name as itemName,
+        gross_weight as grossWeight,
+        delivery_method as deliveryMethod,
+        in_out_flag as inOutFlag,
+        material_quantity as materialQuantity,
+        tare,
+        net_weight as netWeight,
+        status_flag as statusFlag,
+        status,
+        gross_agent as grossAgent,
+        tare_agent as tareAgent,
+        in_out_warehouse_date as inOutWarehouseDate,
+        update_date as updateDate,
+        create_date as createDate
+        FROM material_warehouse_in_out
+        WHERE delete_flag = '0'
+        <if test="searchType != null and searchType != ''">
+            <!--称皮重-->
+            <if test="searchType == 1">
+                AND status_flag = '1'
+            </if>
+            <!--称毛重-->
+            <if test="searchType == 3">
+                AND status_flag = '3'
+            </if>
+        </if>
+        <if test="baseId != null and baseId != ''">
+            AND base_id = #{baseId}
+        </if>
+        <if test="searchKeyWord != null and searchKeyWord != ''">
+            AND (lower(car_no) like lower(CONCAT('%',#{searchKeyWord},'%'))
+            OR lower(item_name) like lower(CONCAT('%',#{searchKeyWord},'%'))
+            OR lower(gross_agent) like lower(CONCAT('%',#{searchKeyWord},'%'))
+            OR lower(tare_agent) like lower(CONCAT('%',#{searchKeyWord},'%')))
+        </if>
+        <if test="inOutFlag != null and inOutFlag != ''">
+            <!--出库-->
+            <if test="inOutFlag == 1">
+                AND in_out_flag = '1'
+            </if>
+            <!--入库-->
+            <if test="inOutFlag == 2">
+                AND in_out_flag = '2'
+            </if>
+        </if>
+        <if test="startDate != null">
+            AND (DATE_FORMAT(in_out_warehouse_date,"%Y%m%d") &gt;=
+            DATE_FORMAT(#{startDate},"%Y%m%d"))
+        </if>
+        <if test="endDate != null">
+            AND (DATE_FORMAT(in_out_warehouse_date,"%Y%m%d") &lt;=
+            DATE_FORMAT(#{endDate},"%Y%m%d"))
+        </if>
+        ORDER BY in_out_warehouse_date DESC
+        <if test="currentPage != null and currentPage != ''">
+            LIMIT ${startRecord}, ${pageSize}
+        </if>
+    </select>
 </mapper>