zss
2023-08-11 24a1aa1d7470998522aa28b4abc728fff5bcbaf7
WMS--回单管理
已添加7个文件
已修改17个文件
872 ■■■■■ 文件已修改
framework/src/main/java/com/yuanchu/mom/exception/MyFileException.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/java/com/yuanchu/mom/handler/GlobalExceptionHandler.java 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/java/com/yuanchu/mom/utils/FileSaveUtil.java 74 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/resources/mapper/InspectUnacceptedMapper.xml 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/resources/mapper/RawInspectMapper.xml 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inventory-server/src/main/java/com/yuanchu/mom/controller/ConsignmentController.java 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inventory-server/src/main/java/com/yuanchu/mom/controller/ReceiptController.java 98 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inventory-server/src/main/java/com/yuanchu/mom/mapper/ConsignmentMapper.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inventory-server/src/main/java/com/yuanchu/mom/mapper/ReceiptMapper.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inventory-server/src/main/java/com/yuanchu/mom/pojo/ImportRepertory.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
inventory-server/src/main/java/com/yuanchu/mom/pojo/Receipt.java 105 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inventory-server/src/main/java/com/yuanchu/mom/service/ConsignmentService.java 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inventory-server/src/main/java/com/yuanchu/mom/service/ReceiptService.java 58 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inventory-server/src/main/java/com/yuanchu/mom/service/impl/ConsignmentServiceImpl.java 161 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inventory-server/src/main/java/com/yuanchu/mom/service/impl/ReceiptServiceImpl.java 100 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inventory-server/src/main/resources/mapper/ConsignmentMapper.xml 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inventory-server/src/main/resources/mapper/ImportRepertoryMapper.xml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inventory-server/src/main/resources/mapper/ReceiptMapper.xml 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inventory-server/src/main/resources/mapper/RepertoryMapper.xml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
sale-server/src/main/resources/mapper/SaleMapper.xml 30 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
standard-server/src/main/resources/mapper/OrdersMapper.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
system-run/src/main/java/com/yuanchu/mom/SystemRunApplication.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
system-run/src/main/resources/application-dev.yml 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
system-run/src/main/resources/application.yml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/java/com/yuanchu/mom/exception/MyFileException.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,18 @@
package com.yuanchu.mom.exception;
public class MyFileException extends RuntimeException{
    public MyFileException() {
    }
    public MyFileException(String message) {
        super(message);
    }
    public MyFileException(Throwable cause) {
        super(cause);
    }
    public MyFileException(String message, Throwable cause) {
        super(message, cause);
    }
}
framework/src/main/java/com/yuanchu/mom/handler/GlobalExceptionHandler.java
@@ -1,11 +1,15 @@
package com.yuanchu.mom.handler;
import com.yuanchu.mom.exception.MyFileException;
import com.yuanchu.mom.vo.Result;
import lombok.extern.slf4j.Slf4j;
import org.apache.tomcat.util.http.fileupload.impl.FileSizeLimitExceededException;
import org.apache.tomcat.util.http.fileupload.impl.SizeLimitExceededException;
import org.springframework.beans.ConversionNotSupportedException;
import org.springframework.beans.TypeMismatchException;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.http.converter.HttpMessageNotWritableException;
@@ -14,6 +18,7 @@
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.multipart.MultipartException;
import javax.servlet.http.HttpServletResponse;
import java.io.FileNotFoundException;
@@ -230,6 +235,35 @@
        return Result.fail(message);
    }
    @Value("${spring.servlet.multipart.max-file-size}")
    private String maxFileSize;
    @Value("${spring.servlet.multipart.max-request-size}")
    private String maxRequestSize;
    /**
     *文件过大报错提示
     */
    @ExceptionHandler({MultipartException.class})
    public Result<?> fileUploadExceptionHandler(MultipartException  e) {
        String msg;
        Throwable rootCause = e.getRootCause();
        if (rootCause instanceof FileSizeLimitExceededException) {
            msg="上传文件过大【单个文件大小不得超过" + maxFileSize + "】";
        }else if(rootCause instanceof SizeLimitExceededException){
            msg="上传文件过大【总上传大小不得超过" + maxRequestSize + "】";
        }else {
            msg="文件上传失败【服务器异常】";
        }
        return Result.fail(msg);
    }
    /** æ–‡ä»¶åŽç¼€åä¸é€šè¿‡è¿”回提示 */
    @ExceptionHandler({MyFileException.class})
    public Result<?> myFileException(Exception e) {
        return Result.fail("抱歉不支持【" + e.getMessage() +"】后缀的文件!");
    }
    /** å…¶ä»–错误 */
    /**
     * å…¶ä»–错误
framework/src/main/java/com/yuanchu/mom/utils/FileSaveUtil.java
@@ -1,10 +1,15 @@
package com.yuanchu.mom.utils;
import com.yuanchu.mom.exception.MyFileException;
import lombok.extern.slf4j.Slf4j;
import org.apache.tomcat.util.http.fileupload.IOUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.util.FileSystemUtils;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.PostConstruct;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -16,36 +21,66 @@
public class FileSaveUtil {
    // å–yml中的路径 + /
//    @Value("${file.path}")
    private String FILE_PATH;
    private static String FILE_PATH;
    private static String[] ALLOWED;
    @Value("${file.path}")
    private String file;
    @Value("${file.allowed}")
    private String[] allowed;
    @PostConstruct
    public void getFile() {
        FILE_PATH = this.file;
    }
    @PostConstruct
    public void getAllowed(){
        ALLOWED = this.allowed;
    }
    /**
     * å­˜å‚¨æ–‡ä»¶ä¸»å‡½æ•°
     * @param content æ–‡ä»¶äºŒè¿›åˆ¶æµ
     * @param originalFilename æ–‡ä»¶åç§°
     * @param file æ–‡ä»¶äºŒè¿›åˆ¶æµ
     * @return è¿”回文件名称用于存储数据库
     */
    public String StoreFile(byte[] content, String originalFilename) {
    public static String StoreFile(MultipartFile file) {
        String originalFilename = file.getOriginalFilename();
        // ç”Ÿæˆéšæœºåç§°ï¼šæ—¶é—´_随机6位数字
        String FileName = System.currentTimeMillis() + "_" + MyUtil.getNumber(6);
        String suffix = originalFilename.substring(originalFilename.lastIndexOf("."));
        String suffix = null;
        if (originalFilename != null) {
            suffix = originalFilename.substring(originalFilename.lastIndexOf("."));
            // å¦‚果后缀名不通过抛出异常
            if (!isFileAllowed(suffix)){
                throw  new MyFileException(suffix);
            }
        }
        // åç§°æ‹¼æŽ¥
        String fileName = FileName + suffix;
        // è¿›è¡Œå­˜å‚¨
        storeFileWithFileName(content, fileName);
        try {
            storeFileWithFileName(file.getBytes(), fileName);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        return fileName;
    }
    public static Boolean DeleteFile(String fileName) {
        return FileSystemUtils.deleteRecursively(new File(FILE_PATH + "/" + fileName));
    }
    /**
     * å­˜å‚¨æ–‡ä»¶å‡½æ•°
     * @param content æ–‡ä»¶äºŒè¿›åˆ¶æµ
     * @param fileName æ–‡ä»¶åç§°
     */
    private void storeFileWithFileName(byte[] content, String fileName) {
    private static void storeFileWithFileName(byte[] content, String fileName) {
        // å­˜å‚¨è·¯å¾„
        String path = FILE_PATH + java.io.File.separatorChar;
        String path = FILE_PATH + File.separatorChar;
        // ç›®å½•不存在则创建
        java.io.File file = new java.io.File(path);
        File file = new File(path);
        if (!file.exists()) {
            file.mkdirs();
        }
@@ -57,4 +92,21 @@
            MyUtil.PrintLog("存储文件异常:" + e);
        }
    }
    /**
     * åˆ¤æ–­æ–‡ä»¶æ˜¯å¦è¢«å…è®¸ä¸Šä¼ 
     *
     * @param fileName æ–‡ä»¶å
     * @return å…è®¸true, å¦åˆ™false
     */
    private static boolean isFileAllowed(String fileName) {
        // èŽ·å–åŽç¼€å
        String suffixName = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();
        for (String allow : ALLOWED) {
            if (allow.equals(suffixName)) {
                return true;
            }
        }
        return false;
    }
}
inspect-server/src/main/resources/mapper/InspectUnacceptedMapper.xml
@@ -2,7 +2,7 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.yuanchu.mom.mapper.InspectUnacceptedMapper">
    <select id="selectUnRawInspectsList" resultType="java.util.Map">
        select
        select ru.id
        DATE_FORMAT(form_time, '%Y-%m-%d') '来料日期',
        reason,
        code,
@@ -29,9 +29,11 @@
        </if>
        and ru.state=1
        </where>
        order by ru.id desc
    </select>
    <select id="selectInsList" resultType="java.util.Map">
        select DATE_FORMAT(fi.create_time, '%Y-%m-%d') '来料日期',
        select ru.id
        DATE_FORMAT(fi.create_time, '%Y-%m-%d') '来料日期',
        reason,
        material_code,
        name,
@@ -59,5 +61,6 @@
            and ru.type=#{type}
        </if>
        and ru.state=1
        order by ru.id desc
    </select>
</mapper>
inspect-server/src/main/resources/mapper/RawInspectMapper.xml
@@ -3,7 +3,6 @@
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yuanchu.mom.mapper.RawInspectMapper">
    <resultMap id="BaseResultMap" type="com.yuanchu.mom.pojo.RawInspect">
        <id property="id" column="id" jdbcType="INTEGER"/>
        <result property="code" column="code" jdbcType="VARCHAR"/>
@@ -21,8 +20,9 @@
        <result property="formTime" column="form_time" jdbcType="DATE"/>
    </resultMap>
    <select id="selectRawInspectsByLimit" resultType="com.yuanchu.mom.pojo.RawInspect">
        select id, code, name, specifications, unit, number, ins_state, judge_state, ins_time, user_name, create_time, form_time
        from raw_inspect
        select id, code, name, specifications, unit, number, ins_state, judge_state, ins_time, user_name, create_time,
        form_time
        from mom_ocean.raw_inspect
        where state = 1
        <if test="formTime!=null and formTime!=''">
            and form_time = #{formTime}
@@ -36,6 +36,7 @@
        <if test="judgeState!=2">
            and judge_state = #{judgeState}
        </if>
        order by id desc
        limit #{pageSize},#{countSize}
    </select>
</mapper>
inventory-server/src/main/java/com/yuanchu/mom/controller/ConsignmentController.java
@@ -1,8 +1,8 @@
package com.yuanchu.mom.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuanchu.mom.pojo.dto.ConsignmentDto;
import com.yuanchu.mom.service.SaleService;
import com.yuanchu.mom.utils.JackSonUtil;
@@ -17,6 +17,8 @@
import com.yuanchu.mom.service.ConsignmentService;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
@@ -44,7 +46,7 @@
            @ApiImplicitParam(name = "orderNumber", value = "订单编号", dataTypeClass = String.class, required = true)
    })
    @GetMapping("/selSale")
    public Result selSale(String orderNumber )  {
    public Result selSale(String orderNumber) {
        return Result.success(saleService.selSale(orderNumber));
    }
@@ -55,5 +57,42 @@
        return Result.success(consignmentService.addCon(data.get("name").replaceAll("\"", ""), consignmentDto));
    }
    @ApiOperation(value = "查询发货记录列表")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "pageSize", value = "页数", dataTypeClass = Integer.class, required = true),
            @ApiImplicitParam(name = "countSize", value = "条数/页", dataTypeClass = Integer.class, required = true),
            @ApiImplicitParam(name = "name", value = "产品名称", dataTypeClass = String.class),
            @ApiImplicitParam(name = "specifications", value = "产品型号", dataTypeClass = String.class),
            @ApiImplicitParam(name = "time", value = "发货日期", dataTypeClass = String.class)
    })
    @GetMapping("/selectAllCon")
    public Result selectAllCon(int pageSize, int countSize, String name, String specifications, String time) {
        IPage<Map<String, Object>> consignmentPage = consignmentService.selectAllCon(new Page<Object>(pageSize, countSize), name, specifications, time);
        Map<String, Object> map = new HashMap<>();
        map.put("total", consignmentPage.getTotal());
        map.put("row", consignmentPage.getRecords());
        return Result.success(map);
    }
    @ApiOperation(value = "根据发货id删除")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "id", value = "发货id", dataTypeClass = Integer.class, required = true)
    })
    @PostMapping("/delCon")
    public Result delCon(Integer id) {
        consignmentService.delCon(id);
        return Result.success();
    }
    @ApiOperation(value = "批量删除")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "ids", value = "ids", dataTypeClass = Integer.class, dataType = "List", required = true)
    })
    @PostMapping("/delAllCon")
    public Result delAllCon(@RequestParam("ids") List<Integer> ids) {
        consignmentService.delAllCon(ids);
        return Result.success();
    }
}
inventory-server/src/main/java/com/yuanchu/mom/controller/ReceiptController.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,98 @@
package com.yuanchu.mom.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuanchu.mom.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import com.yuanchu.mom.service.ReceiptService;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * å›žå•表(Receipt)表控制层
 *
 * @author zss
 * @since 2023-08-11 10:08:54
 */
@Api(tags = "WMS管理-->回单管理")
@RestController
@RequestMapping("/receipt")
public class ReceiptController {
    @Autowired
    private ReceiptService receiptService;
    @ApiOperation(value = "查询回单列表")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "pageSize", value = "页数", dataTypeClass = Integer.class, required = true),
            @ApiImplicitParam(name = "countSize", value = "条数/页", dataTypeClass = Integer.class, required = true),
            @ApiImplicitParam(name = "name", value = "产品名称", dataTypeClass = String.class),
            @ApiImplicitParam(name = "orderCode", value = "订单编号", dataTypeClass = String.class),
            @ApiImplicitParam(name = "type", value = "类型(为空=全部)", dataTypeClass = String.class),
            @ApiImplicitParam(name = "deliverTime", value = "发货日期", dataTypeClass = String.class)
    })
    @GetMapping("/selectAllRece")
    public Result selectAllRece(int pageSize, int countSize, String name, String orderCode, String type, String deliverTime) {
        IPage<Map<String, Object>> receiptPage = receiptService.selectAllRece(new Page<Object>(pageSize, countSize), name, orderCode, type, deliverTime);
        Map<String, Object> map = new HashMap<>();
        map.put("total", receiptPage.getTotal());
        map.put("row", receiptPage.getRecords());
        return Result.success(map);
    }
    @ApiOperation(value = "核销")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "id", value = "回单id", dataTypeClass = Integer.class, required = true)
    })
    @PostMapping("/delRece")
    public Result delRece(Integer id) {
        receiptService.delRece(id);
        return Result.success();
    }
    @ApiOperation(value = "批量核销")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "ids", value = "ids", dataTypeClass = Integer.class, dataType = "List", required = true)
    })
    @PostMapping("/delAllRece")
    public Result delAllRece(@RequestParam("ids") List<Integer> ids) {
        receiptService.delAllRece(ids);
        return Result.success();
    }
    @ApiOperation(value = "上传附件")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "id", value = "回单id", dataTypeClass = Integer.class, required = true),
            @ApiImplicitParam(name = "file", value = "回单文件", dataTypeClass = MultipartFile.class, required = true)
    })
    @PostMapping("/updRece")
    public Result updRece(Integer id,@RequestPart MultipartFile file) {
        receiptService.updRece(id, file);
        return Result.success();
    }
    @ApiOperation(value = "查看回单")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "id", value = "回单id", dataTypeClass = Integer.class, required = true)
    })
    @PostMapping("/selReceDatil")
    public ResponseEntity<byte[]> selReceDatil(Integer id) throws IOException {
        return receiptService.selReceDatil(id);
    }
}
inventory-server/src/main/java/com/yuanchu/mom/mapper/ConsignmentMapper.java
@@ -1,9 +1,12 @@
package com.yuanchu.mom.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuanchu.mom.pojo.Consignment;
import java.util.List;
import java.util.Map;
/**
 * æˆå“å‘货表(Consignment)表数据库访问层
@@ -15,5 +18,8 @@
    //查询所有发货记录
    List<Consignment> selectAll();
    //查询发货记录列表
    IPage<Map<String, Object>> selectAllCon(Page<Object> page, String name, String specifications, String time);
}
inventory-server/src/main/java/com/yuanchu/mom/mapper/ReceiptMapper.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,22 @@
package com.yuanchu.mom.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuanchu.mom.pojo.Receipt;
import java.util.Map;
/**
 * å›žå•表(Receipt)表数据库访问层
 *
 * @author zss
 * @since 2023-08-11 10:08:54
 */
public interface ReceiptMapper extends BaseMapper<Receipt> {
    //查询回单列表
    IPage<Map<String, Object>> selectAllRece(Page<Object> page, String name, String orderCode, String type, String deliverTime);
}
inventory-server/src/main/java/com/yuanchu/mom/pojo/ImportRepertory.java
@@ -78,9 +78,7 @@
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date createTime;
    /**
     * ${column.comment}
     **/
    @TableField(fill = FieldFill.INSERT_UPDATE)
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
inventory-server/src/main/java/com/yuanchu/mom/pojo/Receipt.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,105 @@
package com.yuanchu.mom.pojo;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
import java.io.Serializable;
/**
 * å›žå•表(Receipt)表实体类
 *
 * @author zss
 * @since 2023-08-11 10:08:55
 */
@Data
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false)
@Builder
@TableName("receipt")
public class Receipt implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * id
     **/
    @TableId(type = IdType.AUTO)
    private Integer id;
    /**
     * è®¢å•编号
     **/
    private String orderCode;
    /**
     * åˆåŒç¼–号(客户订单号)
     **/
    private String customerCode;
    /**
     * å®¢æˆ·åç§°
     **/
    private String proname;
    /**
     * åˆ°è´§åœ°å€
     **/
    private String adress;
    /**
     * åˆ°è´§è”系人
     **/
    private String name;
    /**
     * æ‰‹æœºå·
     **/
    private String phone;
    /**
     * æŠ¼è¿å•编号
     **/
    private String escortCode;
    /**
     * å‘货日期
     **/
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date deliverTime;
    /**
     * å‘货人
     **/
    private String userName;
    /**
     * çŠ¶æ€0:待回单;1:已回单
     **/
    private Integer type;
    @ApiModelProperty(value = "逻辑删除 æ­£å¸¸>=1,删除<=0", hidden = true)
    private Integer state;
    @TableField(fill = FieldFill.INSERT)
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date createTime;
    @TableField(fill = FieldFill.INSERT_UPDATE)
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date updateTime;
    /**
     * å›žå•照片url
     **/
    private String url;
}
inventory-server/src/main/java/com/yuanchu/mom/service/ConsignmentService.java
@@ -1,8 +1,13 @@
package com.yuanchu.mom.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yuanchu.mom.pojo.Consignment;
import com.yuanchu.mom.pojo.dto.ConsignmentDto;
import java.util.List;
import java.util.Map;
/**
 * æˆå“å‘货表(Consignment)表服务接口
@@ -18,5 +23,27 @@
     * @param consignmentDto
     */
    String addCon(String name, ConsignmentDto consignmentDto);
    /**
     * æŸ¥è¯¢å‘货记录列表
     * @param page
     * @param name
     * @param specifications
     * @param time
     * @return
     */
    IPage<Map<String, Object>> selectAllCon(Page<Object> page, String name, String specifications, String time);
    /**
     * æ ¹æ®id删除
     * @param id
     */
    void delCon(Integer id);
    /**
     * æ‰¹é‡åˆ é™¤
     * @param ids
     */
    void delAllCon(List<Integer> ids);
}
inventory-server/src/main/java/com/yuanchu/mom/service/ReceiptService.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,58 @@
package com.yuanchu.mom.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yuanchu.mom.pojo.Receipt;
import org.springframework.http.ResponseEntity;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.List;
import java.util.Map;
/**
 * å›žå•表(Receipt)表服务接口
 *
 * @author zss
 * @since 2023-08-11 10:08:54
 */
public interface ReceiptService extends IService<Receipt> {
    /**
     * æŸ¥è¯¢å›žå•列表
     * @param page
     * @param name
     * @param orderCode
     * @param type
     * @param deliverTime
     * @return
     */
    IPage<Map<String, Object>> selectAllRece(Page<Object> page, String name, String orderCode, String type, String deliverTime);
    /**
     * æ ¹æ®å›žå•id删除
     * @param id
     */
    void delRece(Integer id);
    /**
     * æ‰¹é‡åˆ é™¤
     * @param ids
     */
    void delAllRece(List<Integer> ids);
    /**
     * æ ¹æ®id修改状态
     * @param id
     */
    void updRece(Integer id, MultipartFile file);
    /**
     * æ ¹æ®id查看回单
     * @param id
     */
    ResponseEntity<byte[]> selReceDatil(Integer id) throws IOException;
}
inventory-server/src/main/java/com/yuanchu/mom/service/impl/ConsignmentServiceImpl.java
@@ -1,19 +1,26 @@
package com.yuanchu.mom.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yuanchu.mom.mapper.ConsignmentMapper;
import com.yuanchu.mom.mapper.ReceiptMapper;
import com.yuanchu.mom.mapper.RepertoryMapper;
import com.yuanchu.mom.pojo.Consignment;
import com.yuanchu.mom.pojo.Receipt;
import com.yuanchu.mom.pojo.Repertory;
import com.yuanchu.mom.pojo.dto.ConsignmentDto;
import com.yuanchu.mom.pojo.dto.ConsignmentDto2;
import com.yuanchu.mom.service.ConsignmentService;
import com.yuanchu.mom.utils.MyUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * æˆå“å‘货表(Consignment)表服务实现类
@@ -30,53 +37,131 @@
    @Resource
    RepertoryMapper repertoryMapper;
    @Resource
    ReceiptMapper receiptMapper;
    //新增成品发货
    @Override
    public String addCon(String name, ConsignmentDto consignmentDto) {
        //生成一个押运单编号
        String escortCode = MyUtil.getTimeSixNumberCode("YY");
        //如果该订单已经发过货了不能再发货
        List<Consignment> consignments = consignmentMapper.selectAll();
        for (Consignment consignment : consignments) {
            if (consignment.getCustomerCode().equals(consignmentDto.getCustomerCode())) {
                return "该合同订单已发过货,无法再次发货!";
            } else {
                /*新增成品发货*/
                List<ConsignmentDto2> messages = consignmentDto.getMessages();
                for (ConsignmentDto2 message : messages) {
                    //查询产品编码(通过在成品库存表中的产品名称,规格型号以及单位进行查找)
                    LambdaQueryWrapper<Repertory> queryWrapper = new LambdaQueryWrapper<>();
                    queryWrapper.eq(Repertory::getName, message.getName())
                            .eq(Repertory::getSpecifications, message.getSpecifications())
                            .eq(Repertory::getUnit, message.getUnit())
                            .eq(Repertory::getType, 0);
                    Repertory repertory = repertoryMapper.selectOne(queryWrapper);
                    //该成品的检验状态是已检验1才能进行发货
                    if (repertory.getCheckState() == 1) {
                        //该成品库存的数量大于等于发货的数量才能进行发货
                        if (repertory.getNumber() >= message.getNumber()) {
                            //构造成品发货实体类
                            Consignment consig = Consignment.builder()
                                    .customerCode(consignmentDto.getCustomerCode())
                                    .escortCode(MyUtil.getTimeSixNumberCode("YY"))
                                    .orderCode(consignmentDto.getOrderCode())
                                    .userName(name)
                                    .checkName(consignmentDto.getCheckName())
                                    .fitName(consignmentDto.getFitName())
                                    .name(message.getName())
                                    .specifications(message.getSpecifications())
                                    .unit(message.getUnit())
                                    .number(message.getNumber())
                                    .code(repertory.getCode())
                                    .build();
                            consignmentMapper.insert(consig);
                            /*减少对应的库存*/
                            repertory.setNumber(repertory.getNumber() - consig.getNumber());
                            repertoryMapper.updateById(repertory);
                        } else return "库存不足,无法发货!";
                    } else return "该产品还未检验,不能发货!";
        //如果没有发货表中没有数据也可以发货
        if (consignments.size()==0) {
            /*新增成品发货*/
            String mes1 = addConsign(name, consignmentDto, escortCode);
            return mes1;
        } else {
            for (Consignment consignment : consignments) {
                if (consignment.getCustomerCode().equals(consignmentDto.getCustomerCode())) {
                    return "该合同订单已发过货,无法再次发货!";
                } else {
                    /*新增成品发货*/
                    String mes2 = addConsign(name, consignmentDto, escortCode);
                    return mes2;
                }
            }
        }
        return null;
    }
    //查询发货记录列表
    @Override
    public IPage<Map<String, Object>> selectAllCon(Page<Object> page, String name, String specifications, String time) {
        return consignmentMapper.selectAllCon(page, name, specifications, time);
    }
    //根据id删除
    @Override
    public void delCon(Integer id) {
        //删除发货记录
        Consignment consignment = consignmentMapper.selectById(id);
        consignment.setState(0);
        consignmentMapper.updateById(consignment);
        //库存也要新增
        LambdaQueryWrapper<Repertory> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Repertory::getCode, consignment.getCode())
                .eq(Repertory::getName, consignment.getName())
                .eq(Repertory::getSpecifications, consignment.getSpecifications())
                .eq(Repertory::getUnit, consignment.getUnit())
                .eq(Repertory::getType, 0) //成品发货
                .eq(Repertory::getCheckState, 1); //只有已检验才能发货
        Repertory repertory = repertoryMapper.selectOne(queryWrapper);
        repertory.setNumber(repertory.getNumber() + consignment.getNumber());
        repertoryMapper.updateById(repertory);
    }
    //批量删除
    @Override
    public void delAllCon(List<Integer> ids) {
        List<Consignment> consignments = consignmentMapper.selectBatchIds(ids);
        for (Consignment consignment : consignments) {
            consignment.setState(0);
            //删除发货记录
            consignmentMapper.updateById(consignment);
            //库存新增
            LambdaQueryWrapper<Repertory> queryWrapper = new LambdaQueryWrapper<>();
            queryWrapper.eq(Repertory::getCode, consignment.getCode())
                    .eq(Repertory::getName, consignment.getName())
                    .eq(Repertory::getSpecifications, consignment.getSpecifications())
                    .eq(Repertory::getUnit, consignment.getUnit())
                    .eq(Repertory::getType, 0) //成品发货
                    .eq(Repertory::getCheckState, 1); //只有已检验才能发货
            Repertory repertory = repertoryMapper.selectOne(queryWrapper);
            repertory.setNumber(repertory.getNumber() + consignment.getNumber());
            repertoryMapper.updateById(repertory);
        }
    }
    //新增发货一系列操作
    private String addConsign(String name, ConsignmentDto consignmentDto, String escortCode) {
        /*新增成品发货*/
        List<ConsignmentDto2> messages = consignmentDto.getMessages();
        for (ConsignmentDto2 message : messages) {
            //查询产品编码(通过在成品库存表中的产品名称,规格型号以及单位进行查找)
            LambdaQueryWrapper<Repertory> queryWrapper = new LambdaQueryWrapper<>();
            queryWrapper.eq(Repertory::getName, message.getName())
                    .eq(Repertory::getSpecifications, message.getSpecifications())
                    .eq(Repertory::getUnit, message.getUnit())
                    .eq(Repertory::getType, 0);
            Repertory repertory = repertoryMapper.selectOne(queryWrapper);
            //该成品的检验状态是已检验1才能进行发货
            if (repertory.getCheckState() == 1) {
                //该成品库存的数量大于等于发货的数量才能进行发货
                if (repertory.getNumber() >= message.getNumber()) {
                    //构造成品发货实体类
                    Consignment consig = Consignment.builder()
                            .customerCode(consignmentDto.getCustomerCode())
                            .escortCode(escortCode)
                            .orderCode(consignmentDto.getOrderCode())
                            .userName(name)
                            .checkName(consignmentDto.getCheckName())
                            .fitName(consignmentDto.getFitName())
                            .name(message.getName())
                            .specifications(message.getSpecifications())
                            .unit(message.getUnit())
                            .number(message.getNumber())
                            .code(repertory.getCode())
                            .build();
                    consignmentMapper.insert(consig);
                    /*减少对应的库存*/
                    repertory.setNumber(repertory.getNumber() - consig.getNumber());
                    repertoryMapper.updateById(repertory);
                } else return "库存不足,无法发货!";
            } else return "该产品还未检验,不能发货!";
        }
        /*发货成功之后需要新增一张回单*/
        Receipt receipt = new Receipt();
        BeanUtils.copyProperties(consignmentDto, receipt);
        receipt.setName(consignmentDto.getUsername());//收货联系人
        receipt.setUserName(name);//发货人
        receipt.setEscortCode(escortCode);//押运单编号
        receipt.setDeliverTime(new Date());//发货日期
        receiptMapper.insert(receipt);
        return "发货成功!";
    }
}
inventory-server/src/main/java/com/yuanchu/mom/service/impl/ReceiptServiceImpl.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,100 @@
package com.yuanchu.mom.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yuanchu.mom.mapper.ReceiptMapper;
import com.yuanchu.mom.pojo.Receipt;
import com.yuanchu.mom.service.ReceiptService;
import com.yuanchu.mom.utils.FileSaveUtil;
import io.swagger.models.Response;
import org.apache.logging.log4j.util.Strings;
import org.springframework.core.io.FileSystemResource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.List;
import java.util.Map;
/**
 * å›žå•表(Receipt)表服务实现类
 *
 * @author zss
 * @since 2023-08-11 10:08:55
 */
@Service
public class ReceiptServiceImpl extends ServiceImpl<ReceiptMapper, Receipt> implements ReceiptService {
    @Resource
    ReceiptMapper receiptMapper;
    //查询回单列表
    @Override
    public IPage<Map<String, Object>> selectAllRece(Page<Object> page, String name, String orderCode, String type, String deliverTime) {
        return receiptMapper.selectAllRece(page, name, orderCode, type, deliverTime);
    }
    //根据id删除
    @Override
    public void delRece(Integer id) {
        Receipt receipt = receiptMapper.selectById(id);
        receipt.setState(0);
        receiptMapper.updateById(receipt);
    }
    //批量删除
    @Override
    public void delAllRece(List<Integer> ids) {
        List<Receipt> receipts = receiptMapper.selectBatchIds(ids);
        for (Receipt receipt : receipts) {
            receipt.setState(0);
            receiptMapper.updateById(receipt);
        }
    }
    //上传附件修改状态
    @Override
    public void updRece(Integer id, MultipartFile file) {
        if (ObjectUtils.isNotEmpty(file)) {
            Receipt receipt = receiptMapper.selectById(id);
            receipt.setUrl(FileSaveUtil.StoreFile(file));
            receipt.setType(1);
            receiptMapper.updateById(receipt);
        }
    }
    //根据id查看回单照片
    @Override
    public ResponseEntity<byte[]> selReceDatil(Integer id) throws IOException {
        String url = receiptMapper.selectById(id).getUrl();
        String path = "D:\\webapp\\images\\" + url;
        //获取图片格式后缀名
        String extension = getImageExtension(url);
        // è¯»å–本地图片文件,并将其转换为字节数组
        FileSystemResource imageResource = new FileSystemResource(path);
        byte[] bytes = Files.readAllBytes(imageResource.getFile().toPath());
        // è®¾ç½®HTTP头信息,告诉浏览器返回的是图片数据
        HttpHeaders headers = new HttpHeaders();
        headers.setContentType(new MediaType("image", extension));
        return new ResponseEntity<>(bytes, headers, HttpStatus.OK);
    }
    private String getImageExtension(String imageName) {
        // æ ¹æ®å›¾ç‰‡æ–‡ä»¶åèŽ·å–æ‰©å±•å
        int dotIndex = imageName.lastIndexOf('.');
        if (dotIndex > 0 && dotIndex < imageName.length() - 1) {
            return imageName.substring(dotIndex + 1);
        }
        return null;
    }
}
inventory-server/src/main/resources/mapper/ConsignmentMapper.xml
@@ -2,6 +2,32 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.yuanchu.mom.mapper.ConsignmentMapper">
    <select id="selectAll" resultType="com.yuanchu.mom.pojo.Consignment">
        select * from mom_ocean.consignment where state=1
        select *
        from mom_ocean.consignment
        where state = 1
    </select>
    <select id="selectAllCon" resultType="java.util.Map">
        select id,
               name,
               specifications,
               code,
               customer_code,
               unit,
               number,
               check_name,
               fit_name,
               user_name
        from mom_ocean.consignment
        where state=1
        <if test="name!=null and name!=''">
            and name like concat('%',#{name},'%')
        </if>
        <if test="specifications!=null and specifications!=''">
            and specifications like concat('%',#{specifications},'%')
        </if>
        <if test="time!=null and time!=''">
            and DATE_FORMAT(create_time, '%Y-%m-%d')=#{time}
        </if>
        order by id desc
    </select>
</mapper>
inventory-server/src/main/resources/mapper/ImportRepertoryMapper.xml
@@ -22,5 +22,6 @@
        <if test="time!=null and time!=''">
            and create_time=#{time}
        </if>
        order by id desc
    </select>
</mapper>
inventory-server/src/main/resources/mapper/ReceiptMapper.xml
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,32 @@
<?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.yuanchu.mom.mapper.ReceiptMapper">
    <select id="selectAllRece" resultType="java.util.Map">
        select id,
        order_code,
        customer_code,
        proname,
        adress,
        name,
        phone,
        escort_code,
        DATE_FORMAT(deliver_time,'%Y-%m-%d'),
        user_name,
        type
        from mom_ocean.receipt
        where state=1
        <if test="name!=null and name!=''">
            and name like concat('%',#{name},'%')
        </if>
        <if test="orderCode!=null and orderCode!=''">
            and order_code like concat('%',#{orderCode},'%')
        </if>
        <if test="type!=null and type!=''">
            and type=#{type}
        </if>
        <if test="deliverTime!=null and deliverTime!=''">
            and deliver_time=#{deliverTime}
        </if>
        order by id desc
    </select>
</mapper>
inventory-server/src/main/resources/mapper/RepertoryMapper.xml
@@ -28,6 +28,7 @@
            <if test="checkState!=null and checkState!=''">
                and check_state=#{checkState}
            </if>
            order by id desc
        </where>
    </select>
</mapper>
sale-server/src/main/resources/mapper/SaleMapper.xml
@@ -10,21 +10,19 @@
        type,
        DATE_FORMAT(delTime, '%Y-%m-%d') '交货日期'
        from mom_ocean.sale
        <where>
            state=1
            <if test="orderNumber!=null and orderNumber!=''">
                and order_number LIKE CONCAT('%',#{orderNumber},'%')
            </if>
            <if test="name!=null and name!=''">
                and name LIKE CONCAT('%',#{name},'%')
            </if>
            <if test="type!=null and type!=''">
                and type=#{type}
            </if>
            <if test="delTime!=null and delTime!=''">
                and DATE_FORMAT(delTime, '%Y-%m-%d')=#{delTime}
            </if>
        </where>
        where state=1
        <if test="orderNumber!=null and orderNumber!=''">
            and order_number like concat('%',#{orderNumber},'%')
        </if>
        <if test="name!=null and name!=''">
            and name LIKE CONCAT('%',#{name},'%')
        </if>
        <if test="type!=null and type!=''">
            and type=#{type}
        </if>
        <if test="delTime!=null and delTime!=''">
            and DATE_FORMAT(delTime, '%Y-%m-%d')=#{delTime}
        </if>
        order by id desc
    </select>
</mapper>
standard-server/src/main/resources/mapper/OrdersMapper.xml
@@ -2,7 +2,8 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.yuanchu.mom.mapper.OrdersMapper">
    <select id="selectAllOrder" resultType="java.util.Map">
        select order_code,
        select o.id,
        order_code,
        department,
        province,
        salesman,
@@ -31,6 +32,6 @@
            </if>
            and o.code=m.code
        </where>
        order by o.create_time desc
        order by o.id desc
    </select>
</mapper>
system-run/src/main/java/com/yuanchu/mom/SystemRunApplication.java
@@ -2,6 +2,7 @@
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
system-run/src/main/resources/application-dev.yml
@@ -18,7 +18,9 @@
# ç…§ç‰‡å­˜å‚¨è·¯å¾„+++++++++++++++++++++++++++运维需要配置+++++++++++++++++++++++++++
file:
  path: E:/webapp/images
  path: D:/webapp/images
  # ä¸Šä¼ æ–‡ä»¶å…è®¸çš„æ‰©å±•名
  allowed: png,jpg,jpeg,gif
mybatis-plus:
  type-aliases-package: com.yuanchu.mom.pojo
system-run/src/main/resources/application.yml
@@ -3,6 +3,10 @@
spring:
  profiles:
    active: dev
  servlet:
    multipart:
      max-file-size: 20MB # å•个文件大小
      max-request-size: 1024MB # ä¸€æ¬¡è¯·æ±‚文件总大小
mybatis-plus:
  type-aliases-package: com.yuanchu.mom.pojo