feat: 添加图纸功能
This commit is contained in:
parent
1c2867b0ef
commit
829d750000
|
|
@ -0,0 +1,73 @@
|
||||||
|
package com.nflg.wms.admin.controller;
|
||||||
|
|
||||||
|
import com.nflg.wms.admin.service.MaterialControllerService;
|
||||||
|
import com.nflg.wms.common.pojo.ApiResult;
|
||||||
|
import com.nflg.wms.common.pojo.PageData;
|
||||||
|
import com.nflg.wms.common.pojo.qo.MaterialAddQO;
|
||||||
|
import com.nflg.wms.common.pojo.qo.MaterialSearchQO;
|
||||||
|
import com.nflg.wms.common.pojo.qo.MaterialUpdateQO;
|
||||||
|
import com.nflg.wms.common.pojo.vo.MaterialVO;
|
||||||
|
import com.nflg.wms.starter.BaseController;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 图纸管理
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/material")
|
||||||
|
public class MaterialController extends BaseController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private MaterialControllerService materialControllerService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增图纸
|
||||||
|
*/
|
||||||
|
@PostMapping("add")
|
||||||
|
public ApiResult<Void> add(@Valid @RequestBody MaterialAddQO request){
|
||||||
|
materialControllerService.add(request);
|
||||||
|
return ApiResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新图纸
|
||||||
|
*/
|
||||||
|
@PostMapping("update")
|
||||||
|
public ApiResult<Void> update(@Valid @RequestBody MaterialUpdateQO request){
|
||||||
|
materialControllerService.update(request);
|
||||||
|
return ApiResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 搜索图纸
|
||||||
|
* @param request 搜索参数
|
||||||
|
*/
|
||||||
|
@PostMapping("search")
|
||||||
|
public ApiResult<PageData<MaterialVO>> search(@Valid @RequestBody MaterialSearchQO request){
|
||||||
|
return ApiResult.success(materialControllerService.search(request));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取图纸历史记录
|
||||||
|
* @param no SAP料号
|
||||||
|
*/
|
||||||
|
@GetMapping("/getHistory")
|
||||||
|
public ApiResult<List<MaterialVO>> getHistory(@Valid @RequestParam @NotBlank String no){
|
||||||
|
return ApiResult.success(materialControllerService.getHistory(no));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出未设置物料清单
|
||||||
|
*/
|
||||||
|
@PostMapping("export")
|
||||||
|
public void exportNotSet(HttpServletResponse response) throws Exception {
|
||||||
|
materialControllerService.exportNotSet(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,80 @@
|
||||||
|
package com.nflg.wms.admin.service;
|
||||||
|
|
||||||
|
import cn.hutool.core.convert.Convert;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.nflg.wms.common.pojo.dto.MaterialExcelExportDTO;
|
||||||
|
import com.nflg.wms.common.pojo.qo.MaterialAddQO;
|
||||||
|
import com.nflg.wms.common.pojo.qo.MaterialSearchQO;
|
||||||
|
import com.nflg.wms.common.pojo.qo.MaterialUpdateQO;
|
||||||
|
import com.nflg.wms.common.pojo.vo.MaterialVO;
|
||||||
|
import com.nflg.wms.common.util.UserUtil;
|
||||||
|
import com.nflg.wms.common.util.VUtil;
|
||||||
|
import com.nflg.wms.repository.entity.Material;
|
||||||
|
import com.nflg.wms.repository.service.IMaterialService;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.ttzero.excel.entity.ListSheet;
|
||||||
|
import org.ttzero.excel.entity.Workbook;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class MaterialControllerService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private IMaterialService materialService;
|
||||||
|
|
||||||
|
public void add(@Valid MaterialAddQO request) {
|
||||||
|
Material material = Convert.convert(Material.class, request);
|
||||||
|
material.setCreateBy(UserUtil.getUserName());
|
||||||
|
material.setCreateTime(LocalDateTime.now());
|
||||||
|
materialService.add(material);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update(@Valid MaterialUpdateQO request) {
|
||||||
|
Material old = materialService.getById(request.getId());
|
||||||
|
VUtil.trueThrowBusinessError(Objects.isNull(old)).throwMessage("数据不存在!");
|
||||||
|
Material material = Convert.convert(Material.class, request);
|
||||||
|
if (StrUtil.isNotBlank(old.getImage()) && Objects.nonNull(old.getWeight())) {
|
||||||
|
material.setVersion(old.getVersion() + 1);
|
||||||
|
material.setCreateBy(UserUtil.getUserName());
|
||||||
|
material.setCreateTime(LocalDateTime.now());
|
||||||
|
material.setId(null);
|
||||||
|
materialService.add(material);
|
||||||
|
}else {
|
||||||
|
material.setUpdateBy(UserUtil.getUserName());
|
||||||
|
material.setUpdateTime(LocalDateTime.now());
|
||||||
|
materialService.update(material);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IPage<MaterialVO> search(@Valid MaterialSearchQO request) {
|
||||||
|
return materialService.search(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MaterialVO> getHistory(@Valid @NotBlank String no) {
|
||||||
|
return materialService.getHistory(no);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void exportNotSet(HttpServletResponse response) throws IOException {
|
||||||
|
List<Material> materials = materialService.getNotSet();
|
||||||
|
List<MaterialExcelExportDTO> datas = materials.stream().map(model -> Convert.convert(MaterialExcelExportDTO.class, model)).collect(Collectors.toList());
|
||||||
|
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
||||||
|
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + URLEncoder.encode("未设置物料清单.xlsx", StandardCharsets.UTF_8));
|
||||||
|
new Workbook()
|
||||||
|
.addSheet(new ListSheet<>(datas).setRowHeight(100))
|
||||||
|
.writeTo(response.getOutputStream());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,73 @@
|
||||||
|
package com.nflg.wms.common.pojo.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
import org.ttzero.excel.annotation.ExcelColumn;
|
||||||
|
import org.ttzero.excel.annotation.MediaColumn;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public class MaterialExcelExportDTO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SAP料号
|
||||||
|
*/
|
||||||
|
@ExcelColumn("*SAP料号")
|
||||||
|
private String no;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物料描述
|
||||||
|
*/
|
||||||
|
@ExcelColumn("*物料描述")
|
||||||
|
private String describe;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 图片
|
||||||
|
*/
|
||||||
|
@MediaColumn
|
||||||
|
private String image;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前版本号
|
||||||
|
*/
|
||||||
|
@ExcelColumn("当前版本号")
|
||||||
|
private Integer version;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重量
|
||||||
|
*/
|
||||||
|
@ExcelColumn("重量")
|
||||||
|
private BigDecimal weight;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 长度
|
||||||
|
*/
|
||||||
|
@ExcelColumn("长度")
|
||||||
|
private BigDecimal length;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 宽度
|
||||||
|
*/
|
||||||
|
@ExcelColumn("宽度")
|
||||||
|
private BigDecimal width;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 高度
|
||||||
|
*/
|
||||||
|
@ExcelColumn("高度")
|
||||||
|
private BigDecimal height;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打包要求
|
||||||
|
*/
|
||||||
|
@ExcelColumn("打包要求")
|
||||||
|
private String requirement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
@ExcelColumn("备注")
|
||||||
|
private String remark;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,62 @@
|
||||||
|
package com.nflg.wms.common.pojo.qo;
|
||||||
|
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class MaterialAddQO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SAP料号
|
||||||
|
*/
|
||||||
|
@NotBlank
|
||||||
|
private String no;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物料描述
|
||||||
|
*/
|
||||||
|
@NotBlank
|
||||||
|
private String describe;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 图片
|
||||||
|
*/
|
||||||
|
@NotBlank
|
||||||
|
private String image;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重量
|
||||||
|
*/
|
||||||
|
@NotBlank
|
||||||
|
private BigDecimal weight;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 长度
|
||||||
|
*/
|
||||||
|
@NotBlank
|
||||||
|
private BigDecimal length;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 宽度
|
||||||
|
*/
|
||||||
|
@NotBlank
|
||||||
|
private BigDecimal width;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 高度
|
||||||
|
*/
|
||||||
|
@NotBlank
|
||||||
|
private BigDecimal height;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打包要求
|
||||||
|
*/
|
||||||
|
private String requirement;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.nflg.wms.common.pojo.qo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class MaterialSearchQO extends PageQO{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SAP料号
|
||||||
|
*/
|
||||||
|
private String no;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物料描述
|
||||||
|
*/
|
||||||
|
private String describe;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.nflg.wms.common.pojo.qo;
|
||||||
|
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class MaterialUpdateQO extends MaterialAddQO{
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private Long id;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,84 @@
|
||||||
|
package com.nflg.wms.common.pojo.vo;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class MaterialVO {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SAP料号
|
||||||
|
*/
|
||||||
|
private String no;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物料描述
|
||||||
|
*/
|
||||||
|
private String describe;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 图片
|
||||||
|
*/
|
||||||
|
private String image;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 图片类型
|
||||||
|
*/
|
||||||
|
private String imageType;
|
||||||
|
/**
|
||||||
|
* 当前版本号
|
||||||
|
*/
|
||||||
|
private Integer version;
|
||||||
|
/**
|
||||||
|
* 重量
|
||||||
|
*/
|
||||||
|
private BigDecimal weight;
|
||||||
|
/**
|
||||||
|
* 长度
|
||||||
|
*/
|
||||||
|
private BigDecimal length;
|
||||||
|
/**
|
||||||
|
* 宽度
|
||||||
|
*/
|
||||||
|
private BigDecimal width;
|
||||||
|
/**
|
||||||
|
* 高度
|
||||||
|
*/
|
||||||
|
private BigDecimal height;
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
private String remark;
|
||||||
|
/**
|
||||||
|
* 创建人
|
||||||
|
*/
|
||||||
|
private String createBy;
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
/**
|
||||||
|
* 最后更新人
|
||||||
|
*/
|
||||||
|
private String updateBy;
|
||||||
|
/**
|
||||||
|
* 最后更新时间
|
||||||
|
*/
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
/**
|
||||||
|
* 打包要求
|
||||||
|
*/
|
||||||
|
private String requirement;
|
||||||
|
|
||||||
|
public String getImageType(){
|
||||||
|
if (StrUtil.isBlank(image)){
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return image.substring(image.lastIndexOf("."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,102 @@
|
||||||
|
package com.nflg.wms.repository.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
*
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author 代码生成器生成
|
||||||
|
* @since 2025
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@ToString
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public class Material implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SAP料号
|
||||||
|
*/
|
||||||
|
private String no;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物料描述
|
||||||
|
*/
|
||||||
|
private String describe;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 图片
|
||||||
|
*/
|
||||||
|
private String image;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前版本号
|
||||||
|
*/
|
||||||
|
private Integer version;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重量
|
||||||
|
*/
|
||||||
|
private BigDecimal weight;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 长度
|
||||||
|
*/
|
||||||
|
private BigDecimal length;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 宽度
|
||||||
|
*/
|
||||||
|
private BigDecimal width;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 高度
|
||||||
|
*/
|
||||||
|
private BigDecimal height;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建人
|
||||||
|
*/
|
||||||
|
private String createBy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 最后更新人
|
||||||
|
*/
|
||||||
|
private String updateBy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 最后更新时间
|
||||||
|
*/
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打包要求
|
||||||
|
*/
|
||||||
|
private String requirement;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.nflg.wms.repository.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.nflg.wms.common.pojo.qo.MaterialSearchQO;
|
||||||
|
import com.nflg.wms.common.pojo.vo.MaterialVO;
|
||||||
|
import com.nflg.wms.repository.entity.Material;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author 代码生成器生成
|
||||||
|
* @since 2025
|
||||||
|
*/
|
||||||
|
public interface MaterialMapper extends BaseMapper<Material> {
|
||||||
|
|
||||||
|
IPage<MaterialVO> search(MaterialSearchQO request, Page<?> objectPage);
|
||||||
|
|
||||||
|
List<MaterialVO> getHistory(String no);
|
||||||
|
|
||||||
|
List<Material> getNotSet();
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.nflg.wms.repository.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.nflg.wms.common.pojo.qo.MaterialSearchQO;
|
||||||
|
import com.nflg.wms.common.pojo.vo.MaterialVO;
|
||||||
|
import com.nflg.wms.repository.entity.Material;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author 代码生成器生成
|
||||||
|
* @since 2025
|
||||||
|
*/
|
||||||
|
public interface IMaterialService extends IService<Material> {
|
||||||
|
|
||||||
|
void add(Material material);
|
||||||
|
|
||||||
|
void update(Material material);
|
||||||
|
|
||||||
|
IPage<MaterialVO> search(@Valid MaterialSearchQO request);
|
||||||
|
|
||||||
|
List<MaterialVO> getHistory(@Valid @NotBlank String no);
|
||||||
|
|
||||||
|
List<Material> getNotSet();
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,63 @@
|
||||||
|
package com.nflg.wms.repository.service.impl;
|
||||||
|
|
||||||
|
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.nflg.wms.common.pojo.qo.MaterialSearchQO;
|
||||||
|
import com.nflg.wms.common.pojo.vo.MaterialVO;
|
||||||
|
import com.nflg.wms.common.util.VUtil;
|
||||||
|
import com.nflg.wms.repository.entity.Material;
|
||||||
|
import com.nflg.wms.repository.mapper.MaterialMapper;
|
||||||
|
import com.nflg.wms.repository.service.IAuditLogService;
|
||||||
|
import com.nflg.wms.repository.service.IMaterialService;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author 代码生成器生成
|
||||||
|
* @since 2025
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> implements IMaterialService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private IAuditLogService auditLogService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void add(Material material) {
|
||||||
|
VUtil.trueThrowBusinessError(lambdaQuery().eq(Material::getNo, material.getNo()).exists())
|
||||||
|
.throwMessage("SAP料号已存在");
|
||||||
|
save(material);
|
||||||
|
auditLogService.addInsert(Material.class,material,material.getCreateBy());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(Material material) {
|
||||||
|
Material old = getById(material.getId());
|
||||||
|
material.setNo(null);
|
||||||
|
updateById(material);
|
||||||
|
Material newMaterial = getById(material.getId());
|
||||||
|
auditLogService.addUpdate(Material.class, old, newMaterial, material.getUpdateBy());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IPage<MaterialVO> search(MaterialSearchQO request) {
|
||||||
|
return baseMapper.search(request,new Page<>(request.getPage(),request.getPageSize()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<MaterialVO> getHistory(String no) {
|
||||||
|
return baseMapper.getHistory(no);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Material> getNotSet() {
|
||||||
|
return baseMapper.getNotSet();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
<?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.nflg.wms.repository.mapper.MaterialMapper">
|
||||||
|
|
||||||
|
<select id="search" resultType="com.nflg.wms.common.pojo.vo.MaterialVO">
|
||||||
|
SELECT DISTINCT ON ("no") *
|
||||||
|
FROM material
|
||||||
|
<where>
|
||||||
|
<if test="request.no!=null and request.no!=''">
|
||||||
|
and "no" like concat('%', #{request.no}, '%')
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
ORDER BY "no",id DESC;
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getHistory" resultType="com.nflg.wms.common.pojo.vo.MaterialVO">
|
||||||
|
select *
|
||||||
|
from material
|
||||||
|
where no=#{no}
|
||||||
|
order by id desc
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getNotSet" resultType="com.nflg.wms.repository.entity.Material">
|
||||||
|
SELECT *
|
||||||
|
FROM (
|
||||||
|
SELECT DISTINCT ON ("no") *
|
||||||
|
FROM material
|
||||||
|
ORDER BY "no", id DESC
|
||||||
|
) t
|
||||||
|
where image is null or weight is null
|
||||||
|
ORDER BY id
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
|
|
@ -33,7 +33,7 @@ public class CodeGeneratorTest {
|
||||||
)
|
)
|
||||||
.strategyConfig(builder -> {
|
.strategyConfig(builder -> {
|
||||||
builder
|
builder
|
||||||
.addInclude("v_user_supplier") //只生成指定表
|
.addInclude("material") //只生成指定表
|
||||||
.entityBuilder().idType(IdType.ASSIGN_ID)
|
.entityBuilder().idType(IdType.ASSIGN_ID)
|
||||||
.enableLombok()
|
.enableLombok()
|
||||||
.enableChainModel()
|
.enableChainModel()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue