仓库配置编码自动生成,公司配置批量更新
This commit is contained in:
@@ -92,4 +92,10 @@ public class CompanyRelativityController {
|
||||
return success(BeanUtils.toBean(pageResult, CompanyRelaDeptDO.class));
|
||||
}
|
||||
|
||||
@PostMapping("/createOrUpdate-list")
|
||||
@Operation(summary = "批量创建更新公司关系")
|
||||
@PreAuthorize("@ss.hasPermission('base:company-relativity:create')")
|
||||
public CommonResult<List<CompanyRelativityRespVO>> createOrUpdataCompanyList(@Valid @RequestBody List<CompanyRelativitySaveReqVO> createReqVOS) {
|
||||
return success(companyRelativityService.createOrUpdataCompanyList(createReqVOS));
|
||||
}
|
||||
}
|
||||
@@ -35,4 +35,6 @@ public class ContactPageReqVO extends PageParam {
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
@Schema(description = "是否启用")
|
||||
private String isEnable;
|
||||
}
|
||||
@@ -44,4 +44,7 @@ public class ContactRespVO {
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "是否启用")
|
||||
@ExcelProperty("是否启用")
|
||||
private String isEnable;
|
||||
}
|
||||
@@ -33,4 +33,7 @@ public class ContactSaveReqVO {
|
||||
@NotEmpty(message = "联系地址不能为空")
|
||||
private String address;
|
||||
|
||||
@Schema(description = "是否启用")
|
||||
private String isEnable;
|
||||
|
||||
}
|
||||
@@ -59,6 +59,11 @@ public class ContactDO extends BusinessBaseDO {
|
||||
*/
|
||||
@TableField("ADR")
|
||||
private String address;
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
@TableField("IS_ENB")
|
||||
private String isEnable;
|
||||
/**
|
||||
* 公司编号
|
||||
*/
|
||||
|
||||
@@ -29,4 +29,5 @@ public interface WarehouseMapper extends BaseMapperX<WarehouseDO> {
|
||||
.orderByDesc(WarehouseDO::getId));
|
||||
}
|
||||
|
||||
String selectMaxCode();
|
||||
}
|
||||
@@ -62,4 +62,5 @@ public interface CompanyRelativityService {
|
||||
*/
|
||||
PageResult<CompanyRelaDeptDO> getCompanyRelativityPage(CompanyRelativityPageReqVO pageReqVO);
|
||||
|
||||
List<CompanyRelativityRespVO> createOrUpdataCompanyList(List<CompanyRelativitySaveReqVO> createReqVOS);
|
||||
}
|
||||
@@ -116,6 +116,43 @@ public class CompanyRelativityServiceImpl implements CompanyRelativityService {
|
||||
return new PageResult<>(pageList, (long) total);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CompanyRelativityRespVO> createOrUpdataCompanyList(List<CompanyRelativitySaveReqVO> createReqVOS) {
|
||||
if (CollUtil.isEmpty(createReqVOS)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<CompanyRelativityDO> insertList = new ArrayList<>();
|
||||
List<CompanyRelativityDO> updateList = new ArrayList<>();
|
||||
|
||||
// 分离需要插入和更新的数据
|
||||
for (CompanyRelativitySaveReqVO createReqVO : createReqVOS) {
|
||||
if (createReqVO.getId() == null) {
|
||||
// 插入
|
||||
CompanyRelativityDO companyRelativity = BeanUtils.toBean(createReqVO, CompanyRelativityDO.class);
|
||||
insertList.add(companyRelativity);
|
||||
} else {
|
||||
// 校验存在
|
||||
validateCompanyRelativityExists(createReqVO.getId());
|
||||
// 更新
|
||||
CompanyRelativityDO updateObj = BeanUtils.toBean(createReqVO, CompanyRelativityDO.class);
|
||||
updateList.add(updateObj);
|
||||
}
|
||||
}
|
||||
|
||||
// 批量插入
|
||||
if (CollUtil.isNotEmpty(insertList)) {
|
||||
companyRelativityMapper.insertBatch(insertList);
|
||||
}
|
||||
|
||||
// 批量更新
|
||||
if (CollUtil.isNotEmpty(updateList)) {
|
||||
companyRelativityMapper.updateBatch(updateList);
|
||||
}
|
||||
|
||||
return BeanUtils.toBean(createReqVOS, CompanyRelativityRespVO.class);
|
||||
}
|
||||
|
||||
private List<CompanyRelaDeptDO> buildTree(List<CompanyRelaDeptDO> list) {
|
||||
// 创建一个map用于存储所有节点,key为id,value为节点对象
|
||||
Map<Long, CompanyRelaDeptDO> nodeMap = new HashMap<>();
|
||||
|
||||
@@ -36,6 +36,17 @@ public class WarehouseServiceImpl implements WarehouseService {
|
||||
public WarehouseRespVO createWarehouse(WarehouseSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
WarehouseDO warehouse = BeanUtils.toBean(createReqVO, WarehouseDO.class);
|
||||
// 库位编码自动生成,格式 KW-0001,依次新增
|
||||
String maxCode = warehouseMapper.selectMaxCode();
|
||||
if (maxCode == null) {
|
||||
warehouse.setCoding("KW-0001");
|
||||
} else {
|
||||
String prefix = "KW-";
|
||||
String numberPart = maxCode.substring(prefix.length());
|
||||
int nextNumber = Integer.parseInt(numberPart) + 1;
|
||||
String nextCode = prefix + String.format("%04d", nextNumber);
|
||||
warehouse.setCoding(nextCode);
|
||||
}
|
||||
warehouseMapper.insert(warehouse);
|
||||
// 返回
|
||||
return BeanUtils.toBean(warehouse, WarehouseRespVO.class);
|
||||
|
||||
@@ -9,4 +9,7 @@
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
|
||||
<select id="selectMaxCode" resultType="java.lang.String">
|
||||
SELECT max(CDG) FROM SPLY_WEH
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user