cuilei
2025-05-26 89dcf021bcb3c3393e03e2ebcb4b26e54aa360ad
工具管理-出库流水代码生成及工具出库接口
已添加10个文件
已修改5个文件
804 ■■■■■ 文件已修改
lxzn-module-tms/src/main/java/org/jeecg/modules/tms/controller/OutStoreDetailController.java 179 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-tms/src/main/java/org/jeecg/modules/tms/controller/OutboundOrderController.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-tms/src/main/java/org/jeecg/modules/tms/entity/OutStoreDetail.java 87 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-tms/src/main/java/org/jeecg/modules/tms/entity/OutboundDetail.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-tms/src/main/java/org/jeecg/modules/tms/entity/dto/OutBoundRequestDto.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-tms/src/main/java/org/jeecg/modules/tms/entity/vo/OutStoreDetailVo.java 78 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-tms/src/main/java/org/jeecg/modules/tms/enums/OutBillStatus.java 21 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-tms/src/main/java/org/jeecg/modules/tms/enums/OutStorehouseType.java 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-tms/src/main/java/org/jeecg/modules/tms/enums/ToolCirculationStatus.java 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-tms/src/main/java/org/jeecg/modules/tms/mapper/OutStoreDetailMapper.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-tms/src/main/java/org/jeecg/modules/tms/mapper/xml/OutStoreDetailMapper.xml 79 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-tms/src/main/java/org/jeecg/modules/tms/service/IOutStoreDetailService.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-tms/src/main/java/org/jeecg/modules/tms/service/IOutboundOrderService.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-tms/src/main/java/org/jeecg/modules/tms/service/impl/OutStoreDetailServiceImpl.java 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-tms/src/main/java/org/jeecg/modules/tms/service/impl/OutboundOrderServiceImpl.java 175 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-tms/src/main/java/org/jeecg/modules/tms/controller/OutStoreDetailController.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,179 @@
package org.jeecg.modules.tms.controller;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.tms.entity.OutStoreDetail;
import org.jeecg.modules.tms.entity.vo.OutStoreDetailVo;
import org.jeecg.modules.tms.service.IOutStoreDetailService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.jeecg.common.system.base.controller.JeecgController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import com.alibaba.fastjson.JSON;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.aspect.annotation.AutoLog;
 /**
 * @Description: å·¥å…·å‡ºåº“流水
 * @Author: jeecg-boot
 * @Date:   2025-05-23
 * @Version: V1.0
 */
@Api(tags="工具出库流水")
@RestController
@RequestMapping("/tms/outStoreDetail")
@Slf4j
public class OutStoreDetailController extends JeecgController<OutStoreDetail, IOutStoreDetailService> {
    @Autowired
    private IOutStoreDetailService outStoreDetailService;
    /**
     * åˆ†é¡µåˆ—表查询
     *
     * @param outStoreDetail
     * @param pageNo
     * @param pageSize
     * @param req
     * @return
     */
    //@AutoLog(value = "工具出库流水-分页列表查询")
    @ApiOperation(value="工具出库流水-分页列表查询", notes="工具出库流水-分页列表查询")
    @GetMapping(value = "/list")
    public Result<IPage<OutStoreDetailVo>> queryPageList(OutStoreDetail outStoreDetail,
                                                         @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
                                                         @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
                                                         HttpServletRequest req) {
        Map<String, String[]> parameterMap = req.getParameterMap();
        QueryWrapper<OutStoreDetail> queryWrapper = QueryGenerator.initQueryWrapper(outStoreDetail, parameterMap);
        Page<OutStoreDetailVo> page = new Page<>(pageNo, pageSize);
        IPage<OutStoreDetailVo> pageList = outStoreDetailService.queryPageList(page, parameterMap);
        return Result.OK(pageList);
    }
    /**
     *   æ·»åŠ 
     *
     * @param outStoreDetail
     * @return
     */
    @AutoLog(value = "工具出库流水-添加")
    @ApiOperation(value="工具出库流水-添加", notes="工具出库流水-添加")
    //@RequiresPermissions("org.jeecg.modules:tms_out_store_detail:add")
    @PostMapping(value = "/add")
    public Result<String> add(@RequestBody OutStoreDetail outStoreDetail) {
        outStoreDetailService.save(outStoreDetail);
        return Result.OK("添加成功!");
    }
    /**
     *  ç¼–辑
     *
     * @param outStoreDetail
     * @return
     */
    @AutoLog(value = "工具出库流水-编辑")
    @ApiOperation(value="工具出库流水-编辑", notes="工具出库流水-编辑")
    //@RequiresPermissions("org.jeecg.modules:tms_out_store_detail:edit")
    @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
    public Result<String> edit(@RequestBody OutStoreDetail outStoreDetail) {
        outStoreDetailService.updateById(outStoreDetail);
        return Result.OK("编辑成功!");
    }
    /**
     *   é€šè¿‡id删除
     *
     * @param id
     * @return
     */
    @AutoLog(value = "工具出库流水-通过id删除")
    @ApiOperation(value="工具出库流水-通过id删除", notes="工具出库流水-通过id删除")
    //@RequiresPermissions("org.jeecg.modules:tms_out_store_detail:delete")
    @DeleteMapping(value = "/delete")
    public Result<String> delete(@RequestParam(name="id",required=true) String id) {
        outStoreDetailService.removeById(id);
        return Result.OK("删除成功!");
    }
    /**
     *  æ‰¹é‡åˆ é™¤
     *
     * @param ids
     * @return
     */
    @AutoLog(value = "工具出库流水-批量删除")
    @ApiOperation(value="工具出库流水-批量删除", notes="工具出库流水-批量删除")
    //@RequiresPermissions("org.jeecg.modules:tms_out_store_detail:deleteBatch")
    @DeleteMapping(value = "/deleteBatch")
    public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
        this.outStoreDetailService.removeByIds(Arrays.asList(ids.split(",")));
        return Result.OK("批量删除成功!");
    }
    /**
     * é€šè¿‡id查询
     *
     * @param id
     * @return
     */
    //@AutoLog(value = "工具出库流水-通过id查询")
    @ApiOperation(value="工具出库流水-通过id查询", notes="工具出库流水-通过id查询")
    @GetMapping(value = "/queryById")
    public Result<OutStoreDetail> queryById(@RequestParam(name="id",required=true) String id) {
        OutStoreDetail outStoreDetail = outStoreDetailService.getById(id);
        if(outStoreDetail==null) {
            return Result.error("未找到对应数据");
        }
        return Result.OK(outStoreDetail);
    }
    /**
    * å¯¼å‡ºexcel
    *
    * @param request
    * @param outStoreDetail
    */
    //@RequiresPermissions("org.jeecg.modules:tms_out_store_detail:exportXls")
    @RequestMapping(value = "/exportXls")
    public ModelAndView exportXls(HttpServletRequest request, OutStoreDetail outStoreDetail) {
        return super.exportXls(request, outStoreDetail, OutStoreDetail.class, "工具出库流水");
    }
    /**
      * é€šè¿‡excel导入数据
    *
    * @param request
    * @param response
    * @return
    */
    //@RequiresPermissions("tms_out_store_detail:importExcel")
    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
        return super.importExcel(request, response, OutStoreDetail.class);
    }
}
lxzn-module-tms/src/main/java/org/jeecg/modules/tms/controller/OutboundOrderController.java
@@ -13,6 +13,7 @@
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.util.TranslateDictTextUtils;
import org.jeecg.modules.tms.entity.dto.OutBoundOrderFlowDto;
import org.jeecg.modules.tms.entity.dto.OutBoundRequestDto;
import org.jeecg.modules.tms.entity.dto.OutboundOrderAndDetailDto;
import org.jeecg.modules.tms.entity.vo.OutboundDetailVo;
import org.jeecg.modules.tms.enums.OutBillStatus;
@@ -177,6 +178,14 @@
        return Result.OK("操作成功");
     }
     @AutoLog(value = "申请单方式出库")
     @ApiOperation(value = "申请单方式出库", notes = "申请单方式出库")
     @PostMapping(value = "/outBound")
     public Result<?> outBound(@RequestBody List<OutBoundRequestDto> outBoundRequestList) {
        outboundOrderService.outBound(outBoundRequestList);
        return Result.OK("出库成功");
     }
    /**
     * é€šè¿‡id删除
     * @param id
lxzn-module-tms/src/main/java/org/jeecg/modules/tms/entity/OutStoreDetail.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,87 @@
package org.jeecg.modules.tms.entity;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableLogic;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.jeecg.common.aspect.annotation.Dict;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
 * @Description: å·¥å…·å‡ºåº“流水
 * @Author: jeecg-boot
 * @Date:   2025-05-23
 * @Version: V1.0
 */
@Data
@TableName("tms_out_store_detail")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="tms_out_store_detail对象", description="工具出库流水")
public class OutStoreDetail implements Serializable {
    private static final long serialVersionUID = 1L;
    /**主键*/
    @TableId(type = IdType.ASSIGN_ID)
    @ApiModelProperty(value = "主键")
    private String id;
    /**工具编码*/
    @Excel(name = "工具编码", width = 15)
    @ApiModelProperty(value = "工具编码")
    private String toolCode;
    /**工具编号*/
    @Excel(name = "工具编号", width = 15)
    @ApiModelProperty(value = "工具编号")
    private String toolId;
    /**出库类型*/
    @Excel(name = "出库类型", width = 15)
    @ApiModelProperty(value = "出库类型")
    private String outStorehouseType;
    /**库位号*/
    @Excel(name = "库位号", width = 15)
    @ApiModelProperty(value = "库位号")
    private String goodsShelvesCode;
    /**出库数量*/
    @Excel(name = "出库数量", width = 15)
    @ApiModelProperty(value = "出库数量")
    private BigDecimal outNumber;
    /**出库申请单号*/
    @Excel(name = "出库申请单号", width = 15)
    @ApiModelProperty(value = "出库申请单号")
    private String outStorehouseId;
    /**出库操作方式;1.按申请单 2.手工操作*/
    @Excel(name = "出库操作方式;1.按申请单 2.手工操作", width = 15)
    @ApiModelProperty(value = "出库操作方式;1.按申请单 2.手工操作")
    private String operateType;
    /**租户号*/
    @Excel(name = "租户号", width = 15)
    @ApiModelProperty(value = "租户号")
    private String tenantId;
    /**创建人*/
    @ApiModelProperty(value = "创建人")
    private String createBy;
    /**创建时间*/
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
    @ApiModelProperty(value = "创建时间")
    private Date createTime;
    /**更新人*/
    @ApiModelProperty(value = "更新人")
    private String updateBy;
    /**更新时间*/
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
    @ApiModelProperty(value = "更新时间")
    private Date updateTime;
}
lxzn-module-tms/src/main/java/org/jeecg/modules/tms/entity/OutboundDetail.java
@@ -36,11 +36,11 @@
    private String outStorehouseId;
    /**刀具编码*/
    @Excel(name = "刀具编码", width = 15)
    @ApiModelProperty(value = "刀具编码")
    @ApiModelProperty(value = "刀具编码(tms_base_tool表主键id)")
    private String toolCode;
    /**刀具编号*/
    @Excel(name = "刀具编号", width = 15)
    @ApiModelProperty(value = "刀具编号")
    @ApiModelProperty(value = "刀具编号(刀具唯一编码,管到把的属性)")
    private String toolId;
    /**申请出库数量*/
    @Excel(name = "申请出库数量", width = 15)
@@ -69,7 +69,7 @@
    @Excel(name = "出库状态;1.未出库;2.部分出库;3.出库完成", width = 15)
    @ApiModelProperty(value = "出库状态;1.未出库;2.部分出库;3.出库完成")
    @Dict(dicCode = "out_storehouse_status")
    private Integer status;
    private String status;
    /**租户号*/
    @Excel(name = "租户号", width = 15)
    @ApiModelProperty(value = "租户号")
lxzn-module-tms/src/main/java/org/jeecg/modules/tms/entity/dto/OutBoundRequestDto.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,19 @@
package org.jeecg.modules.tms.entity.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class OutBoundRequestDto {
    //出库申请单id
    @ApiModelProperty(value = "出库申请单id")
    private String outBoundOrderId;
    //出库申请明细id
    @ApiModelProperty(value = "出库申请明细id")
    private String outboundDetailId;
    //出库数量
    @ApiModelProperty(value = "出库数量")
    private BigDecimal outboundQuantity;
}
lxzn-module-tms/src/main/java/org/jeecg/modules/tms/entity/vo/OutStoreDetailVo.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,78 @@
package org.jeecg.modules.tms.entity.vo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecg.common.aspect.annotation.Dict;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
 * @Description: å·¥å…·å‡ºåº“流水
 * @Author: jeecg-boot
 * @Date:   2025-05-23
 * @Version: V1.0
 */
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="工具出库流水页面展示对象封装", description="工具出库流水页面展示对象封装")
public class OutStoreDetailVo implements Serializable {
    private static final long serialVersionUID = 1L;
    /**主键*/
    @ApiModelProperty(value = "主键")
    private String id;
    /**工具编码*/
    @ApiModelProperty(value = "工具编码")
    private String toolCode;
    /**工具编号*/
    @ApiModelProperty(value = "工具编号")
    private String toolId;
    /**出库类型*/
    @Dict(dicCode = "out_storehouse_type")
    @ApiModelProperty(value = "出库类型")
    private String outStorehouseType;
    /**库位号*/
    @ApiModelProperty(value = "库位号")
    private String goodsShelvesCode;
    /**出库数量*/
    @ApiModelProperty(value = "出库数量")
    private BigDecimal outNumber;
    /**出库申请单号*/
    @ApiModelProperty(value = "出库申请单号")
    private String outStorehouseId;
    /**出库操作方式;1.按申请单 2.手工操作*/
    @ApiModelProperty(value = "出库操作方式;1.按申请单 2.手工操作")
    private String operateType;
    /**创建人*/
    @ApiModelProperty(value = "创建人")
    private String createBy;
    /**创建时间*/
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
    @ApiModelProperty(value = "创建时间")
    private Date createTime;
    /**中文名称*/
    @ApiModelProperty(value = "中文名称")
    private String chineseName;
    /**型号/图号*/
    @ApiModelProperty(value = "型号/图号")
    private String toolModel;
    /**刀具材料*/
    @ApiModelProperty(value = "刀具材料")
    private String toolMaterial;
    /**零件材料*/
    @ApiModelProperty(value = "零件材料")
    private String partMaterial;
}
lxzn-module-tms/src/main/java/org/jeecg/modules/tms/enums/OutBillStatus.java
@@ -1,11 +1,14 @@
package org.jeecg.modules.tms.enums;
import lombok.Getter;
import java.util.Objects;
/**
 * å‡ºåº“单状态枚举类
 */
@Getter
public enum OutBillStatus {
    /**
     * è‰ç¨¿çŠ¶æ€ï¼Œå€¼ä¸º1
@@ -39,24 +42,6 @@
    OutBillStatus(String value, String description) {
        this.value = value;
        this.description = description;
    }
    /**
     * èŽ·å–çŠ¶æ€å€¼
     *
     * @return çŠ¶æ€å€¼
     */
    public String getValue() {
        return value;
    }
    /**
     * èŽ·å–çŠ¶æ€æè¿°
     *
     * @return çŠ¶æ€æè¿°
     */
    public String getDescription() {
        return description;
    }
    /**
lxzn-module-tms/src/main/java/org/jeecg/modules/tms/enums/OutStorehouseType.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,29 @@
package org.jeecg.modules.tms.enums;
import lombok.Getter;
@Getter
public enum OutStorehouseType {
    TOOL_BORROW("1", "工具借用"),
    MAINTENANCE_OUTBOUND("2", "维修出库"),
    CALIBRATION_OUTBOUND("3", "检定出库"),
    GRINDING_OUTBOUND("4", "刃磨出库");
    private final String value;
    private final String description;
    OutStorehouseType(String value, String description) {
        this.value = value;
        this.description = description;
    }
    public static OutStorehouseType getByValue(String value) {
        for (OutStorehouseType type : OutStorehouseType.values()) {
            if (type.getValue().equals(value)) {
                return type;
            }
        }
        throw new IllegalArgumentException("Invalid enum value: " + value);
    }
}
lxzn-module-tms/src/main/java/org/jeecg/modules/tms/enums/ToolCirculationStatus.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,38 @@
package org.jeecg.modules.tms.enums;
import lombok.Getter;
/**
 * å·¥å…·æµé€šçŠ¶æ€æžšä¸¾
 */
@Getter
public enum ToolCirculationStatus {
    IN_STOCK("1", "在库"),
    BORROWED("2", "在借"),
    REPAIRING("3", "在修"),
    INSPECTING("4", "在检"),
    GRINDING("5", "在磨"),
    SCRAPPED("6", "报废");
    private final String value;
    private final String description;
    ToolCirculationStatus(String value, String description) {
        this.value = value;
        this.description = description;
    }
    /**
     * æ ¹æ®çŠ¶æ€å€¼èŽ·å–æžšä¸¾å®žä¾‹
     * @param status çŠ¶æ€å€¼
     * @return æžšä¸¾å®žä¾‹æˆ–null
     */
    public static ToolCirculationStatus fromStatus(String status) {
        for (ToolCirculationStatus value : values()) {
            if (value.getValue().equals(status)) {
                return value;
            }
        }
        return null;
    }
}
lxzn-module-tms/src/main/java/org/jeecg/modules/tms/mapper/OutStoreDetailMapper.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,25 @@
package org.jeecg.modules.tms.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.tms.entity.OutStoreDetail;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.tms.entity.vo.OutStoreDetailVo;
/**
 * @Description: å·¥å…·å‡ºåº“流水
 * @Author: jeecg-boot
 * @Date:   2025-05-23
 * @Version: V1.0
 */
public interface OutStoreDetailMapper extends BaseMapper<OutStoreDetail> {
    IPage<OutStoreDetailVo> queryPageList(Page<OutStoreDetailVo> page,
                                          @Param(Constants.WRAPPER) Wrapper<OutStoreDetailVo> queryWrapper);
}
lxzn-module-tms/src/main/java/org/jeecg/modules/tms/mapper/xml/OutStoreDetailMapper.xml
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,79 @@
<?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="org.jeecg.modules.tms.mapper.OutStoreDetailMapper">
    <select id="queryPageList" resultType="org.jeecg.modules.tms.entity.vo.OutStoreDetailVo">
        SELECT
            t1.id,
            t1.tool_code toolCode,
            t1.tool_id toolId,
            t1.out_storehouse_type outStorehouseType,
            t1.goods_shelves_code goodsShelvesCode,
            t1.out_number outNumber,
            t1.out_storehouse_id outStorehouseId,
            t1.operate_type operateType,
            t1.create_by createBy,
            t1.create_time createTime,
            t2.chinese_name chineseName,
            t2.tool_model toolModel,
            t2.parama_table_name paramaTableName,
        <choose>
            <when test="ew.paramNameValuePairs.paramaTableName == '1'">
                t4.tool_material toolMaterial,
                t4.part_material partMaterial
            </when>
            <when test="ew.paramNameValuePairs.paramaTableName == '2'">
                t5.tool_material toolMaterial,
                t5.part_material partMaterial
            </when>
            <when test="ew.paramNameValuePairs.paramaTableName == '3'">
                t6.tool_material toolMaterial,
                t6.part_material partMaterial
            </when>
            <when test="ew.paramNameValuePairs.paramaTableName == '4'">
                t7.tool_material toolMaterial,
                t7.part_material partMaterial
            </when>
            <when test="ew.paramNameValuePairs.paramaTableName == '5'">
                t8.tool_material toolMaterial,
                t8.part_material partMaterial
            </when>
            <when test="ew.paramNameValuePairs.paramaTableName == '6'">
                t9.tool_material toolMaterial,
                t9.part_material partMaterial
            </when>
            <otherwise>
                t10.tool_material toolMaterial,
                t10.part_material partMaterial
            </otherwise>
        </choose>
        FROM tms_out_store_detail t1
        LEFT JOIN tms_base_tools t2 on t1.tool_code = t2.id
        LEFT JOIN tms_tools_config_property t3 on t3.tool_code = t2.id
        LEFT JOIN tms_tools_classify t11 on t11.id = t2.classify_id
        <choose>
            <when test="ew.paramNameValuePairs.paramaTableName == '1'">
                LEFT JOIN tms_para_common_tool t4 on t4.tool_code = t2.id
            </when>
            <when test="ew.paramNameValuePairs.paramaTableName == '2'">
                LEFT JOIN tms_para_hole_tools t5 on t5.tool_code = t2.id
            </when>
            <when test="ew.paramNameValuePairs.paramaTableName == '3'">
                LEFT JOIN tms_para_threading_tool t6 on t6.tool_code = t2.id
            </when>
            <when test="ew.paramNameValuePairs.paramaTableName == '4'">
                LEFT JOIN tms_para_mill_tool t7 on t7.tool_code = t2.id
            </when>
            <when test="ew.paramNameValuePairs.paramaTableName == '5'">
                LEFT JOIN tms_para_turning_tools t8 on t8.tool_code = t2.id
            </when>
            <when test="ew.paramNameValuePairs.paramaTableName == '6'">
                LEFT JOIN tms_para_blade t9 on t9.tool_code = t2.id
            </when>
            <otherwise>
                LEFT JOIN tms_para_common_tool t10 on t10.tool_code = t2.id
            </otherwise>
        </choose>
        ${ew.customSqlSegment}
    </select>
</mapper>
lxzn-module-tms/src/main/java/org/jeecg/modules/tms/service/IOutStoreDetailService.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,20 @@
package org.jeecg.modules.tms.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jeecg.modules.tms.entity.OutStoreDetail;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.tms.entity.vo.OutStoreDetailVo;
import java.util.Map;
/**
 * @Description: å·¥å…·å‡ºåº“流水
 * @Author: jeecg-boot
 * @Date:   2025-05-23
 * @Version: V1.0
 */
public interface IOutStoreDetailService extends IService<OutStoreDetail> {
    IPage<OutStoreDetailVo> queryPageList(Page<OutStoreDetailVo> page, Map<String, String[]> parameterMap);
}
lxzn-module-tms/src/main/java/org/jeecg/modules/tms/service/IOutboundOrderService.java
@@ -6,6 +6,7 @@
import org.jeecg.modules.tms.entity.OutboundOrder;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.tms.entity.dto.OutBoundOrderFlowDto;
import org.jeecg.modules.tms.entity.dto.OutBoundRequestDto;
import org.jeecg.modules.tms.entity.dto.OutboundOrderAndDetailDto;
import org.springframework.beans.factory.annotation.Autowired;
import java.io.Serializable;
@@ -45,4 +46,6 @@
    void submit(String id);
    void approvalProcess(OutBoundOrderFlowDto outBoundOrderFlowDto);
    void outBound(List<OutBoundRequestDto> outBoundRequestList);
}
lxzn-module-tms/src/main/java/org/jeecg/modules/tms/service/impl/OutStoreDetailServiceImpl.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,36 @@
package org.jeecg.modules.tms.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jeecg.modules.tms.entity.OutStoreDetail;
import org.jeecg.modules.tms.entity.vo.OutStoreDetailVo;
import org.jeecg.modules.tms.mapper.OutStoreDetailMapper;
import org.jeecg.modules.tms.service.IOutStoreDetailService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.Map;
/**
 * @Description: å·¥å…·å‡ºåº“流水
 * @Author: jeecg-boot
 * @Date:   2025-05-23
 * @Version: V1.0
 */
@Service
public class OutStoreDetailServiceImpl extends ServiceImpl<OutStoreDetailMapper, OutStoreDetail> implements IOutStoreDetailService {
    @Override
    public IPage<OutStoreDetailVo> queryPageList(Page<OutStoreDetailVo> page, Map<String, String[]> parameterMap) {
        QueryWrapper<OutStoreDetailVo> queryWrapper = Wrappers.query();
        String[] classifyIds = parameterMap.get("classifyId");
        if (classifyIds != null && classifyIds.length > 0) {
            queryWrapper.eq("t11.classify_id", classifyIds[0]);
        }
        queryWrapper.orderByDesc("create_time");
        return this.baseMapper.queryPageList(page, queryWrapper);
    }
}
lxzn-module-tms/src/main/java/org/jeecg/modules/tms/service/impl/OutboundOrderServiceImpl.java
@@ -26,22 +26,25 @@
import org.jeecg.modules.flowable.service.IFlowDefinitionService;
import org.jeecg.modules.flowable.service.IFlowTaskService;
import org.jeecg.modules.system.service.ISysBusinessCodeRuleService;
import org.jeecg.modules.tms.entity.OutboundOrder;
import org.jeecg.modules.tms.entity.OutboundDetail;
import org.jeecg.modules.tms.entity.*;
import org.jeecg.modules.tms.entity.dto.OutBoundOrderFlowDto;
import org.jeecg.modules.tms.entity.dto.OutBoundRequestDto;
import org.jeecg.modules.tms.entity.dto.OutboundOrderAndDetailDto;
import org.jeecg.modules.tms.enums.OutBillStatus;
import org.jeecg.modules.tms.enums.OutBoundStatusEnum;
import org.jeecg.modules.tms.enums.OutStorehouseType;
import org.jeecg.modules.tms.enums.ToolCirculationStatus;
import org.jeecg.modules.tms.mapper.OutboundDetailMapper;
import org.jeecg.modules.tms.mapper.OutboundOrderMapper;
import org.jeecg.modules.tms.service.IOutboundDetailService;
import org.jeecg.modules.tms.service.IOutboundOrderService;
import org.jeecg.modules.tms.service.*;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
/**
 * @Description: tms_outbound_order
@@ -55,6 +58,12 @@
    @Autowired
    private IOutboundDetailService outboundDetailService;
    @Autowired
    private IToolLedgerService toolLedgerService;
    @Autowired
    private IToolLedgerDetailService toolLedgerDetailService;
    @Autowired
    private IOutStoreDetailService outStoreDetailService;
    @Autowired
    private ISysBusinessCodeRuleService businessCodeRuleService;
    @Autowired
@@ -207,9 +216,13 @@
        //根据任务完成结果更新申请单状态
        if (result.isSuccess()) {
            outboundOrder.setOrderStatus(outBoundOrderFlowDto.getStatus());
            if (OutBillStatus.APPROVED.getValue().equals(outBoundOrderFlowDto.getStatus())) {
                outboundOrder.setOutStatus(OutBoundStatusEnum.NOT_OUTBOUND.getValue());
                outboundOrder.setOrderStatus(OutBillStatus.APPROVED.getValue());
            }
            if (OutBillStatus.REJECTED.getValue().equals(outBoundOrderFlowDto.getStatus())) {
                //如果驳回,审批单状态回到草稿
                outboundOrder.setOrderStatus(OutBillStatus.DRAFT.getValue());
            }
            outboundOrder.setAuditDate(new Date());
            outboundOrder.setApprovalOpinion(outBoundOrderFlowDto.getApprovalOpinion());
@@ -217,6 +230,158 @@
        }
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void outBound(List<OutBoundRequestDto> outBoundRequestList) {
        //校验是否来自一个申请单
        if (!fromOneApply(outBoundRequestList)) {
            throw new JeecgBootException("出库明细必须来自同一出库申请单!");
        }
        //是否可出库校验
        if (!readyToOutbound(outBoundRequestList)) {
            throw new JeecgBootException("未经审批通过的申请单不能出库!");
        }
        //开始出库
        OutboundOrder outboundOrder = getById(outBoundRequestList.get(0).getOutBoundOrderId());
        List<String> detailIds = outBoundRequestList.stream().map(OutBoundRequestDto::getOutboundDetailId).collect(Collectors.toList());
        List<OutboundDetail> outboundDetailList = outboundDetailService.listByIds(detailIds);
        List<String> toolIdList = outboundDetailList.stream().map(OutboundDetail::getToolCode).collect(Collectors.toList());
        Map<String, BigDecimal> outBoundRequestMap = outBoundRequestList.stream()
                .collect(Collectors.toMap(OutBoundRequestDto::getOutboundDetailId, OutBoundRequestDto::getOutboundQuantity));
        //处理库存台账及台账明细
        Map<String, ToolLedger> toolLedgerMap = toolLedgerService.list(new LambdaQueryWrapper<ToolLedger>().in(ToolLedger::getToolId, toolIdList)).stream()
                .collect(Collectors.toMap(ToolLedger::getToolId, item -> item, (k1, k2) -> k1));
        LambdaQueryWrapper<ToolLedgerDetail> queryWrapper = new LambdaQueryWrapper<>();
        for (int i = 0; i < outboundDetailList.size(); i++) {
            if (i > 0) {
                queryWrapper.or();
            }
            OutboundDetail detail = outboundDetailList.get(i);
            queryWrapper.and(wrapper ->
                    wrapper.eq(ToolLedgerDetail::getToolCode, detail.getToolCode())
                            .eq(ToolLedgerDetail::getToolId, detail.getToolId()) //如果不管到把,该字段为空
            );
        }
        List<ToolLedgerDetail> toolLedgerDetailList = toolLedgerDetailService.list(queryWrapper);
        List<ToolLedger> toolLedgerUpdateList = CollectionUtil.newArrayList();
        List<ToolLedgerDetail> toolLedgerDetailUpdateList = CollectionUtil.newArrayList();
        List<OutStoreDetail> outStoreAddList = CollectionUtil.newArrayList();
        List<OutboundDetail> outboundDetailUpdateList = CollectionUtil.newArrayList();
        for (OutboundDetail detail : outboundDetailList) {
            //更新库存台账
            ToolLedger toolLedger = toolLedgerMap.get(detail.getToolCode());
            BigDecimal outboundQuantity = outBoundRequestMap.get(detail.getId());
            OutStorehouseType outStorehouseType = OutStorehouseType.getByValue(outboundOrder.getOutStorehouseType());
            switch (outStorehouseType) {
                case TOOL_BORROW:
                    toolLedger.setLendCount(toolLedger.getLendCount().add(outboundQuantity));
                    break;
                case MAINTENANCE_OUTBOUND:
                    toolLedger.setRepairCount(toolLedger.getRepairCount().add(outboundQuantity));
                    break;
                case CALIBRATION_OUTBOUND:
                    toolLedger.setDetectionCount(toolLedger.getDetectionCount().add(outboundQuantity));
                    break;
                case GRINDING_OUTBOUND:
                    toolLedger.setSharpeningCount(toolLedger.getSharpeningCount().add(outboundQuantity));
                    break;
                default:
                    throw new JeecgBootException("未知的出库类型!");
            }
            toolLedgerUpdateList.add(toolLedger);
            //更新台账明细
            toolLedgerDetailList.stream().filter(item -> item.getToolCode().equals(detail.getToolCode()) && item.getToolId().equals(detail.getToolId()))
                    .findFirst().ifPresent(item -> {
                        if (StrUtil.isNotBlank(item.getToolId())) {
                            item.setQuantity(BigDecimal.ZERO);
                            switch (outStorehouseType) {
                                case TOOL_BORROW:
                                    item.setStatus(ToolCirculationStatus.BORROWED.getValue());
                                    break;
                                case MAINTENANCE_OUTBOUND:
                                    item.setStatus(ToolCirculationStatus.REPAIRING.getValue());
                                    break;
                                case CALIBRATION_OUTBOUND:
                                    item.setStatus(ToolCirculationStatus.INSPECTING.getValue());
                                    break;
                                case GRINDING_OUTBOUND:
                                    item.setStatus(ToolCirculationStatus.GRINDING.getValue());
                                    break;
                                default:
                                    throw new JeecgBootException("未知的出库类型!");
                            }
                        } else {
                            item.setQuantity(item.getQuantity().subtract(outboundQuantity));
                        }
                        toolLedgerDetailUpdateList.add(item);
                    });
            //记录出库流水
            OutStoreDetail outStoreDetail = new OutStoreDetail()
                    .setToolCode(detail.getToolCode())
                    .setToolId(detail.getToolId())
                    .setOutStorehouseType(outboundOrder.getOutStorehouseType())
                    .setGoodsShelvesCode(detail.getOutboundLocation())
                    .setOutNumber(outboundQuantity)
                    .setOutStorehouseId(outboundOrder.getId())
                    .setOperateType("1");//1:按申请单
            outStoreAddList.add(outStoreDetail);
            //更新申请单明细
            detail.setOutActualCount(detail.getOutActualCount().add(outboundQuantity));
            detail.setOutboundTime(new Date());
            if (detail.getOutActualCount().compareTo(detail.getOutboundQuantity()) == 0) {
                detail.setStatus(OutBoundStatusEnum.COMPLETED.getValue());
            } else {
                detail.setStatus(OutBoundStatusEnum.PARTIAL_OUTBOUND.getValue());
            }
            outboundDetailUpdateList.add(detail);
        }
        toolLedgerService.updateBatchById(toolLedgerUpdateList);
        toolLedgerDetailService.updateBatchById(toolLedgerDetailUpdateList);
        outStoreDetailService.saveBatch(outStoreAddList);
        outboundDetailService.updateBatchById(outboundDetailUpdateList);
        //更新申请单
        boolean allMatch = outboundDetailService.list(new LambdaQueryWrapper<OutboundDetail>()
                        .eq(OutboundDetail::getOutStorehouseId, outboundOrder.getId()))
                .stream().filter(i -> !detailIds.contains(i.getId()))
                .allMatch(i -> i.getStatus().equals(OutBoundStatusEnum.COMPLETED.getValue()));
        List<OutboundDetail> partialOutboundList = outboundDetailUpdateList.stream()
                .filter(i -> !i.getStatus().equals(OutBoundStatusEnum.COMPLETED.getValue())).collect(Collectors.toList());
        if (allMatch && partialOutboundList.isEmpty()) {
            outboundOrder.setOutStatus(OutBoundStatusEnum.COMPLETED.getValue());
        } else {
            outboundOrder.setOutStatus(OutBoundStatusEnum.PARTIAL_OUTBOUND.getValue());
        }
        outboundOrder.setOutboundTime(new Date());
        updateById(outboundOrder);
    }
    private boolean fromOneApply(List<OutBoundRequestDto> outBoundRequestList) {
        long count = outBoundRequestList.stream().map(OutBoundRequestDto::getOutBoundOrderId).distinct().count();
        if (count > 1) {
            return false;
        }
        List<String> outDetailIds = outBoundRequestList.stream().map(OutBoundRequestDto::getOutboundDetailId).collect(Collectors.toList());
        String outboundDetailId = outBoundRequestList.get(0).getOutboundDetailId();
        OutboundDetail outboundDetail = outboundDetailService.getById(outboundDetailId);
        List<String> detailIds = outboundDetailService.list(new LambdaQueryWrapper<OutboundDetail>()
                .eq(OutboundDetail::getOutStorehouseId, outboundDetail.getOutStorehouseId())).stream()
                .map(OutboundDetail::getId).collect(Collectors.toList());
        return new HashSet<>(detailIds).containsAll(outDetailIds);
    }
    private boolean readyToOutbound(List<OutBoundRequestDto> outBoundRequestList) {
        String outBoundOrderId = outBoundRequestList.get(0).getOutBoundOrderId();
        OutboundOrder outboundOrder = getById(outBoundOrderId);
        return OutBillStatus.APPROVED.getValue().equals(outboundOrder.getOrderStatus());
    }
    public boolean triggerProcess(OutboundOrder outboundOrder) {
        flowCommonService.initActBusiness("单号为:" + outboundOrder.getOutNum() + " çš„出库申请,开始进行审批",
                outboundOrder.getId(), "outboundOrderServiceImpl", "tool_out_storage", null);