feat(shipment): 添加物料同步功能并优化查询接口
- 新增 ShipmentMaterialSyncSaveQO 数据传输对象 - 实现 syncSave 接口支持物料批量同步保存和更新 - 实现 syncDelete 接口支持物料批量删除 - 优化 search 接口中数据库查询条件拼接逻辑 - 在网关配置中为物料同步接口添加免认证路径 - 移除 MaterialCodeController 中的无用导入包
This commit is contained in:
parent
7b31d1cf77
commit
ecdf0e0072
|
|
@ -0,0 +1,57 @@
|
|||
package com.nflg.wms.common.pojo.qo;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class ShipmentMaterialSyncSaveQO {
|
||||
|
||||
/**
|
||||
* 物料编号
|
||||
*/
|
||||
@NotBlank
|
||||
private String no;
|
||||
|
||||
/**
|
||||
* 物料描述
|
||||
*/
|
||||
@NotBlank
|
||||
private String describe;
|
||||
|
||||
/**
|
||||
* 物料描述英文
|
||||
*/
|
||||
private String describeEn;
|
||||
|
||||
/**
|
||||
* 图号
|
||||
*/
|
||||
private String drawingNo;
|
||||
|
||||
/**
|
||||
* 图片
|
||||
*/
|
||||
private String image;
|
||||
|
||||
/**
|
||||
* 重量
|
||||
*/
|
||||
private BigDecimal weight;
|
||||
|
||||
/**
|
||||
* 长度
|
||||
*/
|
||||
private BigDecimal length;
|
||||
|
||||
/**
|
||||
* 宽度
|
||||
*/
|
||||
private BigDecimal width;
|
||||
|
||||
/**
|
||||
* 高度
|
||||
*/
|
||||
private BigDecimal height;
|
||||
}
|
||||
|
|
@ -38,7 +38,7 @@ public class SaTokenConfigure {
|
|||
.setAuth(obj -> {
|
||||
// 登录校验 -- 拦截所有路由
|
||||
SaRouter.match("/**")
|
||||
.notMatch("/auth/**","/srm-receive/**", "**/actuator/**")
|
||||
.notMatch("/auth/**","/srm-receive/**", "/shipment/material/**","**/actuator/**")
|
||||
.check(r -> {
|
||||
String traceId = SaHolder.getRequest().getHeader(Constant.TRACE_ID_HEADER, IdUtil.getSnowflakeNextIdStr());
|
||||
MDC.put(Constant.TRACE_ID, traceId);
|
||||
|
|
|
|||
|
|
@ -5,8 +5,6 @@ import cn.hutool.core.convert.Convert;
|
|||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.nflg.wms.common.constant.STATE;
|
||||
import com.nflg.wms.common.exception.NflgException;
|
||||
import com.nflg.wms.common.pojo.ApiResult;
|
||||
import com.nflg.wms.common.pojo.PageData;
|
||||
import com.nflg.wms.common.pojo.qo.*;
|
||||
|
|
|
|||
|
|
@ -3,12 +3,14 @@ package com.nflg.wms.shipment.controller;
|
|||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.nflg.wms.common.pojo.ApiResult;
|
||||
import com.nflg.wms.common.pojo.PageData;
|
||||
import com.nflg.wms.common.pojo.dto.BomMaterialDTO;
|
||||
import com.nflg.wms.common.pojo.qo.ShipmentMaterialAddQO;
|
||||
import com.nflg.wms.common.pojo.qo.ShipmentMaterialSearchQO;
|
||||
import com.nflg.wms.common.pojo.qo.ShipmentMaterialSyncSaveQO;
|
||||
import com.nflg.wms.common.pojo.qo.ShipmentMaterialUpdateQO;
|
||||
import com.nflg.wms.common.util.UserUtil;
|
||||
import com.nflg.wms.common.util.VUtil;
|
||||
|
|
@ -19,6 +21,7 @@ import com.nflg.wms.starter.service.BomMaterialService;
|
|||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
|
@ -121,4 +124,55 @@ public class MaterialController extends BaseController {
|
|||
.page(new Page<>(request.getPage(), request.getPageSize()))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步-保存
|
||||
*/
|
||||
@Transactional
|
||||
@PostMapping("syncSave")
|
||||
public ApiResult<Void> syncSave(@Valid @RequestBody @NotEmpty List<ShipmentMaterialSyncSaveQO> datas) {
|
||||
List<WmsShipmentMaterial> dbMaterials = shipmentMaterialService.lambdaQuery()
|
||||
.in(WmsShipmentMaterial::getNo, datas.stream().map(ShipmentMaterialSyncSaveQO::getNo).toList())
|
||||
.list();
|
||||
dbMaterials.forEach(dbMaterial -> {
|
||||
ShipmentMaterialSyncSaveQO data = datas.stream()
|
||||
.filter(d -> d.getNo().equals(dbMaterial.getNo()))
|
||||
.findFirst()
|
||||
.get();
|
||||
dbMaterial.setDescribe(data.getDescribe());
|
||||
dbMaterial.setDescribeEn(data.getDescribeEn());
|
||||
dbMaterial.setDrawingNo(data.getDrawingNo());
|
||||
dbMaterial.setImage(data.getImage());
|
||||
dbMaterial.setWeight(data.getWeight());
|
||||
dbMaterial.setLength(data.getLength());
|
||||
dbMaterial.setWidth(data.getWidth());
|
||||
dbMaterial.setHeight(data.getHeight());
|
||||
dbMaterial.setUpdateBy(UserUtil.getUserName());
|
||||
dbMaterial.setUpdateTime(LocalDateTime.now());
|
||||
shipmentMaterialService.updateById(dbMaterial);
|
||||
});
|
||||
if (CollectionUtil.isNotEmpty(dbMaterials)){
|
||||
shipmentMaterialService.updateBatchById(dbMaterials);
|
||||
}
|
||||
datas.removeIf(data -> dbMaterials.stream().anyMatch(dbMaterial -> dbMaterial.getNo().equals(data.getNo())));
|
||||
if (CollectionUtil.isNotEmpty(datas)) {
|
||||
shipmentMaterialService.saveBatch(datas.stream().map(data -> {
|
||||
WmsShipmentMaterial material = Convert.convert(WmsShipmentMaterial.class, data);
|
||||
material.setCreateBy(UserUtil.getUserName());
|
||||
material.setCreateTime(LocalDateTime.now());
|
||||
return material;
|
||||
}).toList());
|
||||
}
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步-删除
|
||||
* @param nos 物料编号列表
|
||||
*/
|
||||
@PostMapping("syncDelete")
|
||||
public ApiResult<Void> syncDelete(@RequestBody @NotEmpty List<String> nos) {
|
||||
shipmentMaterialService.remove(new LambdaQueryWrapper<WmsShipmentMaterial>().in(WmsShipmentMaterial::getNo, nos));
|
||||
return ApiResult.success();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue