部件入庫接口實現優化

This commit is contained in:
dzl 2025-05-23 16:58:57 +08:00
parent 5486d9ffc5
commit 9b33215a48

View File

@ -80,19 +80,19 @@ public class EbikeComponentServiceImpl implements EbikeComponentService {
String componentEnterRecordId = ebikeComponentEnterRecords.getComponentEnterRecordId();
if(params.getEbikeEcuEnterRecords().size()>0){
if (params.getEbikeEcuEnterRecords() != null && !params.getEbikeEcuEnterRecords().isEmpty()) {
// 删除原有的ECU入库记录并保存新的记录
deleteAndInsertEcuEnterRecords(componentEnterRecordId, params.getEbikeEcuEnterRecords(), stockInType, ebikeComponentTypeInfo, userId, orgId);
if (stockInType == 1) {
updateInventoryCount(ebikeComponentTypeInfo, orgId, params.getEbikeEcuEnterRecords().size(), 1);
}
}else if(params.getEbikeBatteryEnterRecords().size()>0){
} else if (params.getEbikeBatteryEnterRecords() != null && !params.getEbikeBatteryEnterRecords().isEmpty()) {
// 删除原有的电池入库记录并保存新的记录
deleteAndInsertBatteryRecords(componentEnterRecordId, params.getEbikeBatteryEnterRecords(), stockInType, ebikeComponentTypeInfo, userId, orgId);
if (stockInType == 1) {
updateInventoryCount(ebikeComponentTypeInfo, orgId, params.getEbikeBatteryEnterRecords().size(), 1);
}
}else if(params.getEbikeHelmetEnterRecords().size()>0){
} else if (params.getEbikeHelmetEnterRecords() != null && !params.getEbikeHelmetEnterRecords().isEmpty()) {
// 删除原有的头盔入库记录并保存新的记录
deleteAndInsertHelmetEnterRecords(componentEnterRecordId, params.getEbikeHelmetEnterRecords(), stockInType, ebikeComponentTypeInfo, userId, orgId);
if (stockInType == 1) {
@ -105,8 +105,9 @@ public class EbikeComponentServiceImpl implements EbikeComponentService {
updateInventoryCount(ebikeComponentTypeInfo, orgId, enterQuantity, 1);
}
}
return JsonResult.success(componentEnterRecordId);
return JsonResult.success("", componentEnterRecordId);
}
/*
获取用户Id
*/
@ -114,6 +115,7 @@ public class EbikeComponentServiceImpl implements EbikeComponentService {
StaffFeign staffFeign = getStaffFeignInfo();
return staffFeign.getStaffId().toString();
}
/*
获取组织Id
*/
@ -124,6 +126,7 @@ public class EbikeComponentServiceImpl implements EbikeComponentService {
/**
* 获取车辆部件类型表信息
*
* @param componentType
* @return
*/
@ -135,7 +138,7 @@ public class EbikeComponentServiceImpl implements EbikeComponentService {
EbikeComponentEnterRecords ebikeComponentEnterRecords = new EbikeComponentEnterRecords();
ebikeComponentEnterRecords.setOwningRegion(params.getOwningRegion());
ebikeComponentEnterRecords.setOrgId(orgId);
ebikeComponentEnterRecords.setComponentEnterRecordId(params.getComponentType());
ebikeComponentEnterRecords.setComponentType(params.getComponentType());
ebikeComponentEnterRecords.setEnterQuantity(params.getEnterQuantity());
ebikeComponentEnterRecords.setComponentPrice(ebikeComponentTypeInfo.getPrice());
ebikeComponentEnterRecords.setState(stockInType == 1 ? "1" : "0"); // 暂存为 0 入库为1
@ -178,6 +181,7 @@ public class EbikeComponentServiceImpl implements EbikeComponentService {
}
}
}
private void deleteAndInsertHelmetEnterRecords(String componentEnterRecordId, List<EbikeHelmetEnterRecords> ebikeHelmetEnterRecords, Integer stockInType, EbikeComponentTypeInfo ebikeComponentTypeInfo, String userId, Long orgId) {
// 删除原有的头盔入库记录
QueryWrapper query = new QueryWrapper();
@ -207,6 +211,7 @@ public class EbikeComponentServiceImpl implements EbikeComponentService {
}
}
}
private void saveComponentInventory(String ItemCode, String SerialNumber, EbikeComponentTypeInfo ebikeComponentTypeInfo, String userId, Long orgId, Integer state) {
EbikeComponentInventory ebikeComponentInventory = new EbikeComponentInventory();
ebikeComponentInventory.setItemCode(ItemCode);
@ -317,6 +322,7 @@ public class EbikeComponentServiceImpl implements EbikeComponentService {
int size = ebikeBatteryEnterRecords.size();
updateOtherComponentStock(componentType, size);
}
private void updateHelmetDetails(String componentEnterRecordId, String componentType, Integer state) {
// 具体更新头盔仓库明细状态和仓库总数量的逻辑
QueryWrapper query = new QueryWrapper();
@ -350,6 +356,7 @@ public class EbikeComponentServiceImpl implements EbikeComponentService {
int size = ebikeEcuEnterRecords.size();
updateOtherComponentStock(componentType, size);
}
private void updateOtherComponentStock(String componentType, Integer size) {
// 具体更新其他组件仓库总数量的逻辑
QueryWrapper query1 = new QueryWrapper();
@ -363,6 +370,7 @@ public class EbikeComponentServiceImpl implements EbikeComponentService {
/**
* 出库作废增加部件数量
*
* @param componentType
* @param size
*/
@ -376,8 +384,10 @@ public class EbikeComponentServiceImpl implements EbikeComponentService {
ebikeComponentInventorycountMapper.update(ebikeComponentInventorycount);
}
}
/**
* 部件出库出库暂存 stockInType 0或空 表示暂存1 表示入库
*
* @param params
* @return
*/
@ -436,6 +446,7 @@ public class EbikeComponentServiceImpl implements EbikeComponentService {
}
return JsonResult.success(componentOutRecordId);
}
private EbikeComponentOutRecords buildOutRecord(ReqComponentOutRecordDto params, EbikeComponentTypeInfo ebikeComponentTypeInfo, Integer stockInType, Long orgId) {
EbikeComponentOutRecords ebikeComponentOutRecords = new EbikeComponentOutRecords();
ebikeComponentOutRecords.setOwningRegion(params.getOwningRegion());
@ -447,6 +458,7 @@ public class EbikeComponentServiceImpl implements EbikeComponentService {
ebikeComponentOutRecords.setState(stockInType == 1 ? "1" : "0"); // 暂存为 0 出库库为1
return ebikeComponentOutRecords;
}
private void saveOrUpdateOutRecord(EbikeComponentOutRecords ebikeComponentOutRecords, String componentEnterRecordId, String userId) {
if (componentEnterRecordId == null) { // 新增
ebikeComponentOutRecords.setCreatedUser(userId);
@ -468,6 +480,7 @@ public class EbikeComponentServiceImpl implements EbikeComponentService {
}
}
}
private void deleteAndInsertEcuOutRecords(String componentOutRecordId, List<EbikeEcuOutRecords> outRecords, Integer stockInType, EbikeComponentTypeInfo ebikeComponentTypeInfo, String userId, Long orgId) {
// 删除原有的ECU入库记录
QueryWrapper query = new QueryWrapper();
@ -512,8 +525,10 @@ public class EbikeComponentServiceImpl implements EbikeComponentService {
}
}
}
/**
* 设备部件出库取消通用
*
* @param componentOutRecordId
* @return
*/
@ -527,8 +542,10 @@ public class EbikeComponentServiceImpl implements EbikeComponentService {
ebikeComponentOutRecordsMapper.update(ebikeComponentOutRecords);
return JsonResult.success("成功");
}
/**
* 设备部件出库作废 通用
*
* @param componentOutRecordId
* @return
*/
@ -561,6 +578,7 @@ public class EbikeComponentServiceImpl implements EbikeComponentService {
}
return JsonResult.success("成功");
}
private void updateBatteryOutDetails(String componentOutRecordId, String componentType, Integer state) {
// 具体更新电池仓库明细状态和仓库总数量的逻辑
QueryWrapper query = new QueryWrapper();
@ -593,6 +611,7 @@ public class EbikeComponentServiceImpl implements EbikeComponentService {
int size = ebikeHelmetOutRecords.size();
updateOtherOutComponentStock(componentType, size);
}
private void updateCentralControlOutDetails(String componentOutRecordId, String componentType, Integer state) {
// 具体更新中控仓库明细状态和仓库总数量的逻辑
QueryWrapper query = new QueryWrapper();
@ -609,6 +628,7 @@ public class EbikeComponentServiceImpl implements EbikeComponentService {
int size = ebikeEcuOutRecords.size();
updateOtherOutComponentStock(componentType, size);
}
public StaffFeign getStaffFeignInfo() {
String tokenValue = StpUtil.getTokenValue();
// 调用 Feign 客户端获取用户信息