feat: 添加钢构包功能
This commit is contained in:
parent
1edeab2588
commit
c8655a7a8c
|
|
@ -96,6 +96,10 @@
|
|||
<version>2.17.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import com.nflg.wms.common.pojo.qo.EnableQO;
|
|||
import com.nflg.wms.common.pojo.qo.ModelAddQO;
|
||||
import com.nflg.wms.common.pojo.qo.ModelSearchQO;
|
||||
import com.nflg.wms.common.pojo.qo.ModelUpdateQO;
|
||||
import com.nflg.wms.common.pojo.vo.WmsModelSimpleVO;
|
||||
import com.nflg.wms.repository.entity.WmsModel;
|
||||
import com.nflg.wms.starter.BaseController;
|
||||
import jakarta.annotation.Resource;
|
||||
|
|
@ -76,6 +77,14 @@ public class ModelController extends BaseController {
|
|||
return ApiResult.success(modelControllerService.search(request));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取机型列表
|
||||
*/
|
||||
@GetMapping("getSimpleList")
|
||||
public ApiResult<List<WmsModelSimpleVO>> getSimpleList(){
|
||||
return ApiResult.success(modelControllerService.getSimpleList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入机型
|
||||
* @param file 文件
|
||||
|
|
|
|||
|
|
@ -0,0 +1,114 @@
|
|||
package com.nflg.wms.admin.controller;
|
||||
|
||||
import com.nflg.wms.admin.service.StructuralPackageControllerService;
|
||||
import com.nflg.wms.common.pojo.ApiResult;
|
||||
import com.nflg.wms.common.pojo.PageData;
|
||||
import com.nflg.wms.common.pojo.dto.PackageMaterialDTO;
|
||||
import com.nflg.wms.common.pojo.qo.*;
|
||||
import com.nflg.wms.common.pojo.vo.PackageVO;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 钢构包管理
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/package")
|
||||
public class StructuralPackageController {
|
||||
|
||||
@Resource
|
||||
private StructuralPackageControllerService packageControllerService;
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
@PostMapping("add")
|
||||
public ApiResult<Void> add(@Valid @RequestBody PackageAddQO request){
|
||||
packageControllerService.add(request);
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*/
|
||||
@PostMapping("update")
|
||||
public ApiResult<Void> update(@Valid @RequestBody PackageUpdateQO request){
|
||||
packageControllerService.update(request);
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 启用/禁用
|
||||
* @param request 请求参数
|
||||
*/
|
||||
@PostMapping("/enable")
|
||||
public ApiResult<Void> enable(@Valid @RequestBody EnableQO request){
|
||||
packageControllerService.enable(request);
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索
|
||||
* @param request 搜索参数
|
||||
*/
|
||||
@PostMapping("search")
|
||||
public ApiResult<PageData<PackageVO>> search(@Valid @RequestBody PackageSearchQO request){
|
||||
return ApiResult.success(packageControllerService.search(request));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取图纸历史记录
|
||||
* @param no SAP料号
|
||||
*/
|
||||
@GetMapping("/getHistory")
|
||||
public ApiResult<List<PackageVO>> getHistory(@Valid @RequestParam @NotBlank String no){
|
||||
return ApiResult.success(packageControllerService.getHistory(no));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取详细信息
|
||||
* @param id 包ID
|
||||
*/
|
||||
@GetMapping("/getInfo")
|
||||
public ApiResult<PackageVO> getInfo(@Valid @RequestParam @NotNull Long id){
|
||||
return ApiResult.success(packageControllerService.getInfo(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取老鼠图
|
||||
* @param request 搜索参数
|
||||
*/
|
||||
@PostMapping("getMaterials")
|
||||
public ApiResult<PageData<PackageMaterialDTO>> getMaterials(@Valid @RequestBody PackageMaterialSearchQO request){
|
||||
return ApiResult.success(packageControllerService.getMaterials(request));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出零件清单
|
||||
*/
|
||||
@GetMapping("exportMaterials")
|
||||
public void exportMaterials(HttpServletResponse response,@Valid @RequestParam @NotNull Long packageId) throws Exception {
|
||||
packageControllerService.exportMaterials(response,packageId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入零件清单
|
||||
* @param file 文件
|
||||
*/
|
||||
@Transactional
|
||||
@PostMapping("importMaterials")
|
||||
public ApiResult importMaterials(HttpServletResponse response,@Valid @RequestParam @NotNull Long packageId
|
||||
, @RequestParam(value = "file") MultipartFile file) throws IOException {
|
||||
return packageControllerService.importMaterials(response,packageId,file);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -13,6 +13,7 @@ import com.nflg.wms.common.pojo.qo.EnableQO;
|
|||
import com.nflg.wms.common.pojo.qo.ModelAddQO;
|
||||
import com.nflg.wms.common.pojo.qo.ModelSearchQO;
|
||||
import com.nflg.wms.common.pojo.qo.ModelUpdateQO;
|
||||
import com.nflg.wms.common.pojo.vo.WmsModelSimpleVO;
|
||||
import com.nflg.wms.common.util.DateTimeUtil;
|
||||
import com.nflg.wms.common.util.EecExcelUtil;
|
||||
import com.nflg.wms.common.util.UserUtil;
|
||||
|
|
@ -132,12 +133,7 @@ public class ModelControllerService {
|
|||
|
||||
public void exportSelect(HttpServletResponse response,List<Long> ids) throws IOException {
|
||||
List<WmsModel> users = CollectionUtil.isNotEmpty(ids)?modelService.listByIds(ids):new ArrayList<>();
|
||||
List<ModelExcelExportDTO> datas = users.stream().map(model -> {
|
||||
ModelExcelExportDTO dto = new ModelExcelExportDTO();
|
||||
dto.setNo(model.getNo());
|
||||
dto.setRemark(model.getRemark());
|
||||
return dto;
|
||||
}).collect(Collectors.toList());
|
||||
List<ModelExcelExportDTO> datas = users.stream().map(model -> Convert.convert(ModelExcelExportDTO.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));
|
||||
if (CollectionUtil.isEmpty(datas)){
|
||||
|
|
@ -149,4 +145,14 @@ public class ModelControllerService {
|
|||
.addSheet(new ListSheet<>(datas))
|
||||
.writeTo(response.getOutputStream());
|
||||
}
|
||||
|
||||
public List<WmsModelSimpleVO> getSimpleList() {
|
||||
return modelService.lambdaQuery()
|
||||
.select(WmsModel::getId, WmsModel::getNo)
|
||||
.eq(WmsModel::getEnable, true)
|
||||
.list()
|
||||
.stream()
|
||||
.map(model -> Convert.convert(WmsModelSimpleVO.class, model))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,206 @@
|
|||
package com.nflg.wms.admin.service;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.nflg.wms.common.constant.STATE;
|
||||
import com.nflg.wms.common.pojo.ApiResult;
|
||||
import com.nflg.wms.common.pojo.PageData;
|
||||
import com.nflg.wms.common.pojo.dto.PackageMaterialDTO;
|
||||
import com.nflg.wms.common.pojo.dto.PackageMaterialExcelExportDTO;
|
||||
import com.nflg.wms.common.pojo.dto.PackageMaterialExcelImportDTO;
|
||||
import com.nflg.wms.common.pojo.qo.*;
|
||||
import com.nflg.wms.common.pojo.vo.PackageVO;
|
||||
import com.nflg.wms.common.util.DateTimeUtil;
|
||||
import com.nflg.wms.common.util.EecExcelUtil;
|
||||
import com.nflg.wms.common.util.UserUtil;
|
||||
import com.nflg.wms.common.util.VUtil;
|
||||
import com.nflg.wms.repository.entity.WmsStructuralPackage;
|
||||
import com.nflg.wms.repository.service.IWmsStructuralPackageService;
|
||||
import com.nflg.wms.starter.service.FileUploadService;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.ttzero.excel.entity.ListSheet;
|
||||
import org.ttzero.excel.entity.Workbook;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
public class StructuralPackageControllerService {
|
||||
|
||||
@Resource
|
||||
private IWmsStructuralPackageService packageService;
|
||||
|
||||
@Resource
|
||||
private FileUploadService fileUploadService;
|
||||
|
||||
|
||||
@Transactional
|
||||
public void add(@Valid PackageAddQO request) {
|
||||
WmsStructuralPackage structuralPackage = Convert.convert(WmsStructuralPackage.class, request);
|
||||
structuralPackage.setCreateBy(UserUtil.getUserName());
|
||||
structuralPackage.setCreateTime(LocalDateTime.now());
|
||||
structuralPackage.setModelIds(StrUtil.join(",", request.getModelIds()));
|
||||
structuralPackage.setMaterials(JSONUtil.toJsonStr(request.getMaterials()));
|
||||
packageService.add(structuralPackage);
|
||||
}
|
||||
|
||||
public void update(@Valid PackageUpdateQO request) {
|
||||
WmsStructuralPackage structuralPackage = Convert.convert(WmsStructuralPackage.class, request);
|
||||
structuralPackage.setUpdateBy(UserUtil.getUserName());
|
||||
structuralPackage.setUpdateTime(LocalDateTime.now());
|
||||
structuralPackage.setModelIds(StrUtil.join(",", request.getModelIds()));
|
||||
structuralPackage.setMaterials(JSONUtil.toJsonStr(request.getMaterials()));
|
||||
packageService.update(structuralPackage);
|
||||
}
|
||||
|
||||
public void enable(@Valid EnableQO request) {
|
||||
packageService.enable(request);
|
||||
}
|
||||
|
||||
public IPage<PackageVO> search(@Valid PackageSearchQO request) {
|
||||
return packageService.search(request);
|
||||
}
|
||||
|
||||
public List<PackageVO> getHistory(@Valid @NotBlank String no) {
|
||||
return packageService.getHistory(no);
|
||||
}
|
||||
|
||||
public PackageVO getInfo(@Valid @NotNull Long id) {
|
||||
return packageService.getInfo(id);
|
||||
}
|
||||
|
||||
public PageData<PackageMaterialDTO> getMaterials(@Valid PackageMaterialSearchQO request) {
|
||||
return packageService.getMaterials(request);
|
||||
}
|
||||
|
||||
public void exportMaterials(HttpServletResponse response,Long packageId) throws IOException {
|
||||
PackageVO vo = packageService.getInfo(packageId);
|
||||
List<PackageMaterialExcelExportDTO> datas = vo.getMaterialList().stream().map(info -> Convert.convert(PackageMaterialExcelExportDTO.class, info)).collect(Collectors.toList());
|
||||
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
||||
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + URLEncoder.encode(vo.getNo()+"零件清单导出.xlsx", StandardCharsets.UTF_8));
|
||||
if (CollectionUtil.isEmpty(datas)){
|
||||
datas.add(new PackageMaterialExcelExportDTO()
|
||||
.setNo("(必填)零件编码")
|
||||
.setName("(必填)零件名称")
|
||||
.setStation("(必填)工位序号")
|
||||
.setTray("(必填)托盘序号")
|
||||
.setWeight(BigDecimal.ZERO)
|
||||
.setNum(BigDecimal.ZERO)
|
||||
.setVersion("(必填)图纸版本"));
|
||||
}
|
||||
new Workbook()
|
||||
.addSheet(new ListSheet<>(datas))
|
||||
.writeTo(response.getOutputStream());
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public ApiResult importMaterials(HttpServletResponse response, @Valid @NotNull Long packageId, MultipartFile file) throws IOException {
|
||||
PackageVO vo = packageService.getInfo(packageId);
|
||||
VUtil.trueThrowBusinessError(Objects.isNull(vo)).throwMessage("未找到该结构包");
|
||||
List<PackageMaterialExcelImportDTO> data = EecExcelUtil.getExcelContext(file.getInputStream(), PackageMaterialExcelImportDTO.class);
|
||||
VUtil.trueThrowBusinessError(CollectionUtil.isEmpty(data)).throwMessage("导入文件内容为空");
|
||||
if (checkAndImport(vo, data)) {
|
||||
return ApiResult.success();
|
||||
} else {
|
||||
try (ByteArrayOutputStream osOut = new ByteArrayOutputStream()) {
|
||||
new Workbook()
|
||||
.addSheet(new ListSheet<>(data))
|
||||
.writeTo(osOut);
|
||||
try (ByteArrayInputStream isIn = new ByteArrayInputStream(osOut.toByteArray())) {
|
||||
return ApiResult.error(STATE.DataNoCheckPass, "导入文件失败", fileUploadService.upload("temp/" + DateTimeUtil.format(LocalDate.now(), "yyyyMMdd") + "/" + IdUtil.fastUUID() + ".xlsx", isIn));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return ApiResult.error(STATE.BusinessError, "保存文件出错");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public boolean checkAndImport(PackageVO vo,List<PackageMaterialExcelImportDTO> data) {
|
||||
List<PackageMaterialDTO> materialDTOS = new ArrayList<>();
|
||||
for (PackageMaterialExcelImportDTO dto : data) {
|
||||
PackageMaterialDTO materialDTO = new PackageMaterialDTO();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (StrUtil.isBlank(dto.getNo())) {
|
||||
sb.append("零件编码不能为空;");
|
||||
} else {
|
||||
materialDTO.setNo(dto.getNo());
|
||||
}
|
||||
if (StrUtil.isBlank(dto.getName())) {
|
||||
sb.append("零件名称不能为空;");
|
||||
} else {
|
||||
materialDTO.setName(dto.getName());
|
||||
}
|
||||
if (StrUtil.isBlank(dto.getStation())) {
|
||||
sb.append("工位序号不能为空;");
|
||||
} else {
|
||||
materialDTO.setStation(dto.getStation());
|
||||
}
|
||||
if (StrUtil.isBlank(dto.getTray())) {
|
||||
sb.append("托盘序号不能为空;");
|
||||
} else {
|
||||
materialDTO.setTray(dto.getTray());
|
||||
}
|
||||
if (StrUtil.isBlank(dto.getNum())) {
|
||||
sb.append("数量不能为空;");
|
||||
}else if(!NumberUtils.isCreatable(dto.getNum())){
|
||||
sb.append("数量无效;");
|
||||
}
|
||||
else {
|
||||
materialDTO.setNum(new BigDecimal(dto.getNum()));
|
||||
}
|
||||
if (StrUtil.isBlank(dto.getWeight())) {
|
||||
sb.append("重量不能为空;");
|
||||
}else if(!NumberUtils.isCreatable(dto.getWeight())){
|
||||
sb.append("重量无效;");
|
||||
}
|
||||
else {
|
||||
materialDTO.setWeight(new BigDecimal(dto.getWeight()));
|
||||
}
|
||||
if (StrUtil.isBlank(dto.getVersion())) {
|
||||
sb.append("图纸版本不能为空;");
|
||||
} else {
|
||||
materialDTO.setVersion(dto.getVersion());
|
||||
}
|
||||
dto.setError(sb.toString());
|
||||
materialDTOS.add(materialDTO);
|
||||
}
|
||||
if (data.stream().noneMatch(it -> StrUtil.isNotBlank(it.getError()))) {
|
||||
List<PackageMaterialDTO> materials = new ArrayList<>(vo.getMaterialList());
|
||||
materials.removeIf(info -> materialDTOS.stream().anyMatch(it -> it.getNo().equals(info.getNo())));
|
||||
materials.addAll(materialDTOS);
|
||||
packageService.lambdaUpdate()
|
||||
.set(WmsStructuralPackage::getMaterials, JSONUtil.toJsonStr(materials))
|
||||
.set(WmsStructuralPackage::getUpdateBy, UserUtil.getUserName())
|
||||
.set(WmsStructuralPackage::getUpdateTime, LocalDateTime.now())
|
||||
.eq(WmsStructuralPackage::getId, vo.getId())
|
||||
.update();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
package com.nflg.wms.common.pojo.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class PackageMaterialDTO {
|
||||
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
private String no;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 工位
|
||||
*/
|
||||
private String station;
|
||||
|
||||
/**
|
||||
* 托盘
|
||||
*/
|
||||
private String tray;
|
||||
|
||||
/**
|
||||
* 数量
|
||||
*/
|
||||
private BigDecimal num;
|
||||
|
||||
/**
|
||||
* 重量
|
||||
*/
|
||||
private BigDecimal weight;
|
||||
|
||||
/**
|
||||
* 版本
|
||||
*/
|
||||
private String version;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private String createTime;
|
||||
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private String updateTime;
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
package com.nflg.wms.common.pojo.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.ttzero.excel.annotation.ExcelColumn;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class PackageMaterialExcelExportDTO {
|
||||
|
||||
/**
|
||||
* 零件编码
|
||||
*/
|
||||
@ExcelColumn("零件编码")
|
||||
private String no;
|
||||
|
||||
/**
|
||||
* 零件名称
|
||||
*/
|
||||
@ExcelColumn("零件名称")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 工位序号
|
||||
*/
|
||||
@ExcelColumn("工位序号")
|
||||
private String station;
|
||||
|
||||
/**
|
||||
* 托盘序号
|
||||
*/
|
||||
@ExcelColumn("托盘序号")
|
||||
private String tray;
|
||||
|
||||
/**
|
||||
* 数量
|
||||
*/
|
||||
@ExcelColumn("数量")
|
||||
private BigDecimal num;
|
||||
|
||||
/**
|
||||
* 单个重量
|
||||
*/
|
||||
@ExcelColumn("单个重量")
|
||||
private BigDecimal weight;
|
||||
|
||||
/**
|
||||
* 图纸版本
|
||||
*/
|
||||
@ExcelColumn("图纸版本")
|
||||
private String version;
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
package com.nflg.wms.common.pojo.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import org.ttzero.excel.annotation.ExcelColumn;
|
||||
|
||||
@Data
|
||||
public class PackageMaterialExcelImportDTO {
|
||||
|
||||
/**
|
||||
* 零件编码
|
||||
*/
|
||||
@ExcelColumn("零件编码")
|
||||
private String no;
|
||||
|
||||
/**
|
||||
* 零件名称
|
||||
*/
|
||||
@ExcelColumn("零件名称")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 工位序号
|
||||
*/
|
||||
@ExcelColumn("工位序号")
|
||||
private String station;
|
||||
|
||||
/**
|
||||
* 托盘序号
|
||||
*/
|
||||
@ExcelColumn("托盘序号")
|
||||
private String tray;
|
||||
|
||||
/**
|
||||
* 数量
|
||||
*/
|
||||
@ExcelColumn("数量")
|
||||
private String num;
|
||||
|
||||
/**
|
||||
* 单个重量
|
||||
*/
|
||||
@ExcelColumn("单个重量")
|
||||
private String weight;
|
||||
|
||||
/**
|
||||
* 图纸版本
|
||||
*/
|
||||
@ExcelColumn("图纸版本")
|
||||
private String version;
|
||||
|
||||
/**
|
||||
* 错误信息
|
||||
*/
|
||||
@ExcelColumn("错误信息")
|
||||
private String error;
|
||||
}
|
||||
|
|
@ -20,6 +20,11 @@ public class MaterialAddQO {
|
|||
@NotBlank
|
||||
private String describe;
|
||||
|
||||
/**
|
||||
* 图号
|
||||
*/
|
||||
private String drawingNo;
|
||||
|
||||
/**
|
||||
* 图片
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -0,0 +1,78 @@
|
|||
package com.nflg.wms.common.pojo.qo;
|
||||
|
||||
import com.nflg.wms.common.pojo.dto.PackageMaterialDTO;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class PackageAddQO {
|
||||
|
||||
/**
|
||||
* 编码
|
||||
*/
|
||||
@NotBlank
|
||||
private String no;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@NotBlank
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 图号
|
||||
*/
|
||||
@NotBlank
|
||||
private String drawingNo;
|
||||
|
||||
/**
|
||||
* 总重
|
||||
*/
|
||||
@NotNull
|
||||
private BigDecimal weight;
|
||||
|
||||
/**
|
||||
* 机型编号
|
||||
*/
|
||||
@NotEmpty
|
||||
private List<Long> modelIds;
|
||||
|
||||
/**
|
||||
* 种类
|
||||
*/
|
||||
@NotBlank
|
||||
private String cate;
|
||||
|
||||
/**
|
||||
* ECO
|
||||
*/
|
||||
private String eco;
|
||||
|
||||
/**
|
||||
* 版本号
|
||||
*/
|
||||
@NotNull
|
||||
private Integer version;
|
||||
|
||||
/**
|
||||
* 修改日志
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
@NotNull
|
||||
private Boolean enable;
|
||||
|
||||
/**
|
||||
* 零件清单
|
||||
*/
|
||||
@NotEmpty
|
||||
private List<PackageMaterialDTO> materials;
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package com.nflg.wms.common.pojo.qo;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PackageMaterialSearchQO extends PageQO {
|
||||
|
||||
/**
|
||||
* 钢构包id
|
||||
*/
|
||||
@NotNull
|
||||
private Long packageId;
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package com.nflg.wms.common.pojo.qo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PackageSearchQO extends PageQO {
|
||||
|
||||
/**
|
||||
* 钢构包料号/名称
|
||||
*/
|
||||
private String no;
|
||||
|
||||
private String eco;
|
||||
|
||||
/**
|
||||
* 机型id
|
||||
*/
|
||||
private Long modelId;
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package com.nflg.wms.common.pojo.qo;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PackageUpdateQO extends PackageAddQO{
|
||||
|
||||
@NotNull
|
||||
private Long id;
|
||||
}
|
||||
|
|
@ -21,6 +21,11 @@ public class MaterialVO {
|
|||
*/
|
||||
private String describe;
|
||||
|
||||
/**
|
||||
* 图号
|
||||
*/
|
||||
private String drawingNo;
|
||||
|
||||
/**
|
||||
* 图片
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -0,0 +1,106 @@
|
|||
package com.nflg.wms.common.pojo.vo;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.nflg.wms.common.pojo.dto.PackageMaterialDTO;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class PackageVO {
|
||||
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 编码
|
||||
*/
|
||||
private String no;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 图号
|
||||
*/
|
||||
private String drawingNo;
|
||||
|
||||
/**
|
||||
* 总重
|
||||
*/
|
||||
private BigDecimal weight;
|
||||
|
||||
/**
|
||||
* 种类
|
||||
*/
|
||||
private String cate;
|
||||
|
||||
/**
|
||||
* ECO
|
||||
*/
|
||||
private String eco;
|
||||
|
||||
/**
|
||||
* 版本号
|
||||
*/
|
||||
private Integer version;
|
||||
|
||||
/**
|
||||
* 修改日志
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
private Boolean enable;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 最后更新人
|
||||
*/
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 最后更新时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 机型编号
|
||||
*/
|
||||
private String modelNos;
|
||||
|
||||
/**
|
||||
* 零件清单
|
||||
*/
|
||||
@JsonIgnore
|
||||
private String materials;
|
||||
|
||||
/**
|
||||
* 零件清单
|
||||
*/
|
||||
private List<PackageMaterialDTO> materialList;
|
||||
|
||||
public List<PackageMaterialDTO> getMaterialList() {
|
||||
if (StrUtil.isBlank( materials)){
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return JSONUtil.toList(materials, PackageMaterialDTO.class);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package com.nflg.wms.common.pojo.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class WmsModelSimpleVO {
|
||||
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 机型编号
|
||||
*/
|
||||
private String no;
|
||||
}
|
||||
|
|
@ -40,6 +40,11 @@ public class WmsMaterial implements Serializable {
|
|||
*/
|
||||
private String describe;
|
||||
|
||||
/**
|
||||
* 图号
|
||||
*/
|
||||
private String drawingNo;
|
||||
|
||||
/**
|
||||
* 图片
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -0,0 +1,109 @@
|
|||
package com.nflg.wms.repository.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
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)
|
||||
@TableName("wms_structural_package")
|
||||
public class WmsStructuralPackage implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 编码
|
||||
*/
|
||||
private String no;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 图号
|
||||
*/
|
||||
private String drawingNo;
|
||||
|
||||
/**
|
||||
* 总重
|
||||
*/
|
||||
private BigDecimal weight;
|
||||
|
||||
/**
|
||||
* 机型编号
|
||||
*/
|
||||
private String modelIds;
|
||||
|
||||
/**
|
||||
* 种类
|
||||
*/
|
||||
private String cate;
|
||||
|
||||
/**
|
||||
* ECO
|
||||
*/
|
||||
private String eco;
|
||||
|
||||
/**
|
||||
* 版本号
|
||||
*/
|
||||
private Integer version;
|
||||
|
||||
/**
|
||||
* 修改日志
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
private Boolean enable;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 最后更新人
|
||||
*/
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 最后更新时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 零件清单
|
||||
*/
|
||||
private String materials;
|
||||
}
|
||||
|
|
@ -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.PackageSearchQO;
|
||||
import com.nflg.wms.common.pojo.vo.PackageVO;
|
||||
import com.nflg.wms.repository.entity.WmsStructuralPackage;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author 代码生成器生成
|
||||
* @since 2025
|
||||
*/
|
||||
public interface WmsStructuralPackageMapper extends BaseMapper<WmsStructuralPackage> {
|
||||
|
||||
IPage<PackageVO> search(PackageSearchQO request, Page<?> objectPage);
|
||||
|
||||
List<PackageVO> getHistory(String no);
|
||||
|
||||
PackageVO getInfo(Long id);
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
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.PageData;
|
||||
import com.nflg.wms.common.pojo.dto.PackageMaterialDTO;
|
||||
import com.nflg.wms.common.pojo.qo.EnableQO;
|
||||
import com.nflg.wms.common.pojo.qo.PackageMaterialSearchQO;
|
||||
import com.nflg.wms.common.pojo.qo.PackageSearchQO;
|
||||
import com.nflg.wms.common.pojo.vo.PackageVO;
|
||||
import com.nflg.wms.repository.entity.WmsStructuralPackage;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author 代码生成器生成
|
||||
* @since 2025
|
||||
*/
|
||||
public interface IWmsStructuralPackageService extends IService<WmsStructuralPackage> {
|
||||
|
||||
void add(WmsStructuralPackage structuralPackage);
|
||||
|
||||
void update(WmsStructuralPackage structuralPackage);
|
||||
|
||||
void enable(@Valid EnableQO request);
|
||||
|
||||
IPage<PackageVO> search(@Valid PackageSearchQO request);
|
||||
|
||||
List<PackageVO> getHistory(@Valid @NotBlank String no);
|
||||
|
||||
PackageVO getInfo(@Valid @NotNull Long id);
|
||||
|
||||
PageData<PackageMaterialDTO> getMaterials(@Valid PackageMaterialSearchQO request);
|
||||
}
|
||||
|
|
@ -0,0 +1,104 @@
|
|||
package com.nflg.wms.repository.service.impl;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
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.PageData;
|
||||
import com.nflg.wms.common.pojo.dto.PackageMaterialDTO;
|
||||
import com.nflg.wms.common.pojo.qo.EnableQO;
|
||||
import com.nflg.wms.common.pojo.qo.PackageMaterialSearchQO;
|
||||
import com.nflg.wms.common.pojo.qo.PackageSearchQO;
|
||||
import com.nflg.wms.common.pojo.vo.PackageVO;
|
||||
import com.nflg.wms.common.util.UserUtil;
|
||||
import com.nflg.wms.common.util.VUtil;
|
||||
import com.nflg.wms.repository.entity.WmsStructuralPackage;
|
||||
import com.nflg.wms.repository.mapper.WmsStructuralPackageMapper;
|
||||
import com.nflg.wms.repository.service.IAuditLogService;
|
||||
import com.nflg.wms.repository.service.IWmsStructuralPackageService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author 代码生成器生成
|
||||
* @since 2025
|
||||
*/
|
||||
@Service
|
||||
public class WmsStructuralPackageServiceImpl extends ServiceImpl<WmsStructuralPackageMapper, WmsStructuralPackage> implements IWmsStructuralPackageService {
|
||||
|
||||
@Resource
|
||||
private IAuditLogService auditLogService;
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void add(WmsStructuralPackage structuralPackage) {
|
||||
VUtil.trueThrowBusinessError(lambdaQuery().eq(WmsStructuralPackage::getNo, structuralPackage.getNo())
|
||||
.eq(WmsStructuralPackage::getVersion, structuralPackage.getVersion())
|
||||
.ne(Objects.nonNull(structuralPackage.getId()),WmsStructuralPackage::getId, structuralPackage.getId())
|
||||
.exists()).throwMessage("该版本的钢构包编码已存在");
|
||||
save(structuralPackage);
|
||||
auditLogService.addInsert(WmsStructuralPackage.class, structuralPackage,structuralPackage.getCreateBy());
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void update(WmsStructuralPackage structuralPackage) {
|
||||
WmsStructuralPackage old=getById(structuralPackage.getId());
|
||||
VUtil.trueThrowBusinessError(Objects.isNull(old)).throwMessage("该钢构包不存在");
|
||||
VUtil.trueThrowBusinessError(Objects.equals(structuralPackage.getVersion(),old.getVersion()))
|
||||
.throwMessage("更新数据必须修改版本号");
|
||||
structuralPackage.setId(null);
|
||||
add(structuralPackage);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void enable(EnableQO request) {
|
||||
WmsStructuralPackage old = getById(request.getId());
|
||||
VUtil.trueThrowBusinessError(Objects.isNull(old)).throwMessage("钢构包不存在");
|
||||
lambdaUpdate()
|
||||
.set(WmsStructuralPackage::getEnable, request.getEnable())
|
||||
.set(WmsStructuralPackage::getUpdateBy, UserUtil.getUserName())
|
||||
.set(WmsStructuralPackage::getUpdateTime, LocalDateTime.now())
|
||||
.eq(WmsStructuralPackage::getId, request.getId())
|
||||
.update();
|
||||
WmsStructuralPackage newInfo = getById(request.getId());
|
||||
auditLogService.addUpdate(WmsStructuralPackage.class, old, newInfo, UserUtil.getUserName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<PackageVO> search(PackageSearchQO request) {
|
||||
return baseMapper.search(request,new Page<>(request.getPage(),request.getPageSize()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PackageVO> getHistory(String no) {
|
||||
return baseMapper.getHistory(no);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackageVO getInfo(Long id) {
|
||||
return baseMapper.getInfo(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageData<PackageMaterialDTO> getMaterials(PackageMaterialSearchQO request) {
|
||||
WmsStructuralPackage info = getById(request.getPackageId());
|
||||
List<PackageMaterialDTO> materials = JSONUtil.toList(info.getMaterials(), PackageMaterialDTO.class);
|
||||
materials = materials.stream().skip(request.getPage() - 1).limit(request.getPageSize()).toList();
|
||||
return new PageData<PackageMaterialDTO>()
|
||||
.setPage(request.getPage())
|
||||
.setPageSize(request.getPageSize())
|
||||
.setTotal(materials.size())
|
||||
.setItems(materials);
|
||||
}
|
||||
}
|
||||
|
|
@ -4,11 +4,14 @@
|
|||
|
||||
<select id="search" resultType="com.nflg.wms.common.pojo.vo.MaterialVO">
|
||||
SELECT DISTINCT ON ("no") *
|
||||
FROM wmsMaterial
|
||||
FROM wms_material
|
||||
<where>
|
||||
<if test="request.no!=null and request.no!=''">
|
||||
and "no" like concat('%', #{request.no}, '%')
|
||||
</if>
|
||||
<if test="request.describe!=null and request.describe!=''">
|
||||
and describe like concat('%', #{request.describe}, '%')
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY "no",id DESC;
|
||||
</select>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,34 @@
|
|||
<?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.WmsStructuralPackageMapper">
|
||||
|
||||
<select id="search" resultType="com.nflg.wms.common.pojo.vo.PackageVO">
|
||||
SELECT DISTINCT ON ("no") id,"no","name",drawing_no,weight,cate,eco,version,remark,enable,create_by,create_time,update_by,update_time,get_modelnos(model_ids) as "modelNos"
|
||||
FROM wms_structural_package
|
||||
<where>
|
||||
<if test="request.no!=null and request.no!=''">
|
||||
and ("no" like concat('%', #{request.no}, '%') or "name" like concat('%', #{request.no}, '%'))
|
||||
</if>
|
||||
<if test="request.eco!=null and request.eco!=''">
|
||||
and eco like concat('%', #{request.eco}, '%')
|
||||
</if>
|
||||
<if test="request.modelId!=null">
|
||||
and find_in_set(#{request.modelId},model_ids)>0
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY "no",id DESC;
|
||||
</select>
|
||||
|
||||
<select id="getHistory" resultType="com.nflg.wms.common.pojo.vo.PackageVO">
|
||||
select id,"no","name",drawing_no,weight,cate,eco,version,remark,enable,create_by,create_time,update_by,update_time,get_modelnos(model_ids) as "modelNos"
|
||||
from wms_structural_package
|
||||
where no=#{no}
|
||||
order by id desc
|
||||
</select>
|
||||
|
||||
<select id="getInfo" resultType="com.nflg.wms.common.pojo.vo.PackageVO">
|
||||
select *,get_modelnos(model_ids) as "modelNos"
|
||||
from wms_structural_package
|
||||
where id=#{id}
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -33,7 +33,7 @@ public class CodeGeneratorTest {
|
|||
)
|
||||
.strategyConfig(builder -> {
|
||||
builder
|
||||
.addInclude("wms_storage_bin") //只生成指定表
|
||||
.addInclude("wms_structural_package") //只生成指定表
|
||||
.entityBuilder().idType(IdType.ASSIGN_ID)
|
||||
.enableLombok()
|
||||
.enableChainModel()
|
||||
|
|
|
|||
Loading…
Reference in New Issue