根据是否整车绑定和出库类型设置状态
This commit is contained in:
parent
d75169a561
commit
b42a1d670e
@ -79,43 +79,19 @@ public class EbikeComponentServiceImpl implements EbikeComponentService {
|
|||||||
saveOrUpdateEnterRecord(ebikeComponentEnterRecords, params.getComponentEnterRecordId(), userId);
|
saveOrUpdateEnterRecord(ebikeComponentEnterRecords, params.getComponentEnterRecordId(), userId);
|
||||||
|
|
||||||
String componentEnterRecordId = ebikeComponentEnterRecords.getComponentEnterRecordId();
|
String componentEnterRecordId = ebikeComponentEnterRecords.getComponentEnterRecordId();
|
||||||
// 用于存储重复部件名称的集合
|
|
||||||
List<String> duplicatePartNames = new ArrayList<>();
|
|
||||||
if (params.getEbikeEcuEnterRecords() != null && !params.getEbikeEcuEnterRecords().isEmpty()) {
|
if (params.getEbikeEcuEnterRecords() != null && !params.getEbikeEcuEnterRecords().isEmpty()) {
|
||||||
// 遍历所有的EbikeEcuEnterRecords记录
|
|
||||||
for (EbikeEcuEnterRecords res : params.getEbikeEcuEnterRecords()) {
|
|
||||||
boolean isDuplicate = isDuplicateEntry(res.getEcuSn(),res.getEcuCode());
|
|
||||||
if (isDuplicate) {
|
|
||||||
// 如果是重复部件,则将部件名称添加到重复部件名称记录中
|
|
||||||
duplicatePartNames.add(res.getEcuSn()); // 假设 EcuSn 是部件名称
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 删除原有的ECU入库记录并保存新的记录
|
// 删除原有的ECU入库记录并保存新的记录
|
||||||
deleteAndInsertEcuEnterRecords(componentEnterRecordId, params.getEbikeEcuEnterRecords(), stockInType, ebikeComponentTypeInfo, userId, orgId);
|
deleteAndInsertEcuEnterRecords(componentEnterRecordId, params.getEbikeEcuEnterRecords(), stockInType, ebikeComponentTypeInfo, userId, orgId);
|
||||||
if (stockInType == 1) {
|
if (stockInType == 1) {
|
||||||
updateInventoryCount(ebikeComponentTypeInfo, orgId, params.getEbikeEcuEnterRecords().size(), 1);
|
updateInventoryCount(ebikeComponentTypeInfo, orgId, params.getEbikeEcuEnterRecords().size(), 1);
|
||||||
}
|
}
|
||||||
} else if (params.getEbikeBatteryEnterRecords() != null && !params.getEbikeBatteryEnterRecords().isEmpty()) {
|
} else if (params.getEbikeBatteryEnterRecords() != null && !params.getEbikeBatteryEnterRecords().isEmpty()) {
|
||||||
for (EbikeBatteryEnterRecords res : params.getEbikeBatteryEnterRecords()) {
|
|
||||||
boolean isDuplicate = isDuplicateEntry(res.getBatteryCode(),"");
|
|
||||||
if (isDuplicate) {
|
|
||||||
// 如果是重复部件,则将部件名称添加到重复部件名称记录中
|
|
||||||
duplicatePartNames.add(res.getBatteryCode()); // 假设 EcuSn 是部件名称
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 删除原有的电池入库记录并保存新的记录
|
// 删除原有的电池入库记录并保存新的记录
|
||||||
deleteAndInsertBatteryRecords(componentEnterRecordId, params.getEbikeBatteryEnterRecords(), stockInType, ebikeComponentTypeInfo, userId, orgId);
|
deleteAndInsertBatteryRecords(componentEnterRecordId, params.getEbikeBatteryEnterRecords(), stockInType, ebikeComponentTypeInfo, userId, orgId);
|
||||||
if (stockInType == 1) {
|
if (stockInType == 1) {
|
||||||
updateInventoryCount(ebikeComponentTypeInfo, orgId, params.getEbikeBatteryEnterRecords().size(), 1);
|
updateInventoryCount(ebikeComponentTypeInfo, orgId, params.getEbikeBatteryEnterRecords().size(), 1);
|
||||||
}
|
}
|
||||||
} else if (params.getEbikeHelmetEnterRecords() != null && !params.getEbikeHelmetEnterRecords().isEmpty()) {
|
} else if (params.getEbikeHelmetEnterRecords() != null && !params.getEbikeHelmetEnterRecords().isEmpty()) {
|
||||||
for (EbikeHelmetEnterRecords res : params.getEbikeHelmetEnterRecords()) {
|
|
||||||
boolean isDuplicate = isDuplicateEntry(res.getHelmetCode(),"");
|
|
||||||
if (isDuplicate) {
|
|
||||||
// 如果是重复部件,则将部件名称添加到重复部件名称记录中
|
|
||||||
duplicatePartNames.add(res.getHelmetCode()); // 假设 EcuSn 是部件名称
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 删除原有的头盔入库记录并保存新的记录
|
// 删除原有的头盔入库记录并保存新的记录
|
||||||
deleteAndInsertHelmetEnterRecords(componentEnterRecordId, params.getEbikeHelmetEnterRecords(), stockInType, ebikeComponentTypeInfo, userId, orgId);
|
deleteAndInsertHelmetEnterRecords(componentEnterRecordId, params.getEbikeHelmetEnterRecords(), stockInType, ebikeComponentTypeInfo, userId, orgId);
|
||||||
if (stockInType == 1) {
|
if (stockInType == 1) {
|
||||||
@ -128,12 +104,6 @@ public class EbikeComponentServiceImpl implements EbikeComponentService {
|
|||||||
updateInventoryCount(ebikeComponentTypeInfo, orgId, enterQuantity, 1);
|
updateInventoryCount(ebikeComponentTypeInfo, orgId, enterQuantity, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 如果有重复部件名称记录,则返回错误信息
|
|
||||||
if (!duplicatePartNames.isEmpty()) {
|
|
||||||
// 可以在错误信息中添加重复的部件名称
|
|
||||||
String duplicateParts = String.join(", ", duplicatePartNames);
|
|
||||||
return JsonResult.failed("以下部件已存在,不能重复入库: " + duplicateParts);
|
|
||||||
}
|
|
||||||
String componentOutRecordId = params.getComponentOutRecordId();
|
String componentOutRecordId = params.getComponentOutRecordId();
|
||||||
if(componentOutRecordId != null && !componentOutRecordId.isEmpty() && stockInType == 1 ){
|
if(componentOutRecordId != null && !componentOutRecordId.isEmpty() && stockInType == 1 ){
|
||||||
// 更新出库记录状态为 已归还
|
// 更新出库记录状态为 已归还
|
||||||
@ -576,6 +546,21 @@ public class EbikeComponentServiceImpl implements EbikeComponentService {
|
|||||||
return JsonResult.success(resComponentOutRecordInfoDto);
|
return JsonResult.success(resComponentOutRecordInfoDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JsonResult<?> validateComponentExistence(ReqValidateComponentExistenceDto params) {
|
||||||
|
try {
|
||||||
|
String componentCode = params.getComponentCode();
|
||||||
|
String componentType = params.getComponentType();
|
||||||
|
// 检查是否存在重复记录
|
||||||
|
boolean duplicateEntry = isDuplicateEntry(componentCode, componentType);
|
||||||
|
// 返回成功响应
|
||||||
|
return JsonResult.success(duplicateEntry);
|
||||||
|
} catch (Exception e) {
|
||||||
|
// 返回错误响应
|
||||||
|
return JsonResult.failed("验证过程发生异常,请稍后再试");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// 方法实现
|
// 方法实现
|
||||||
private void updateBatteryDetails(String componentEnterRecordId, String componentType, Integer state) {
|
private void updateBatteryDetails(String componentEnterRecordId, String componentType, Integer state) {
|
||||||
@ -646,7 +631,9 @@ public class EbikeComponentServiceImpl implements EbikeComponentService {
|
|||||||
ebikeComponentOutRecords.setOutQuantity(params.getOutQuantity());
|
ebikeComponentOutRecords.setOutQuantity(params.getOutQuantity());
|
||||||
ebikeComponentOutRecords.setOldComponentHandleOption(params.getOldComponentHandleOption());
|
ebikeComponentOutRecords.setOldComponentHandleOption(params.getOldComponentHandleOption());
|
||||||
ebikeComponentOutRecords.setEnterQuantity(params.getEnterQuantity());
|
ebikeComponentOutRecords.setEnterQuantity(params.getEnterQuantity());
|
||||||
ebikeComponentOutRecords.setState(stockInType == 1 ? "1" : "0"); // 暂存为 0 出库库为1
|
// 根据是否整车绑定和出库类型设置状态
|
||||||
|
String state = params.getIsWholeBinding() ? "3" : (stockInType == 1 ? "1" : "0");
|
||||||
|
ebikeComponentOutRecords.setState(state);
|
||||||
return ebikeComponentOutRecords;
|
return ebikeComponentOutRecords;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -821,10 +808,10 @@ public class EbikeComponentServiceImpl implements EbikeComponentService {
|
|||||||
ebikeComponentOutRecords.setState("2");
|
ebikeComponentOutRecords.setState("2");
|
||||||
ebikeComponentOutRecordsMapper.update(ebikeComponentOutRecords);
|
ebikeComponentOutRecordsMapper.update(ebikeComponentOutRecords);
|
||||||
}
|
}
|
||||||
public boolean isDuplicateEntry(String itemCode, String serialNumber) {
|
public boolean isDuplicateEntry(String itemCode,String componentType) {
|
||||||
QueryWrapper query = new QueryWrapper();
|
QueryWrapper query = new QueryWrapper();
|
||||||
query.eq("item_code", itemCode);
|
query.eq("item_code", itemCode);
|
||||||
query.eq("serial_number", serialNumber);
|
query.eq("component_type", componentType);
|
||||||
query.eq("state", 1); // 假设 1 表示已已入库
|
query.eq("state", 1); // 假设 1 表示已已入库
|
||||||
long count = ebikeComponentInventoryMapper.selectCountByQuery(query); // 查询符合条件的记录数
|
long count = ebikeComponentInventoryMapper.selectCountByQuery(query); // 查询符合条件的记录数
|
||||||
return count > 0; // 如果记录数大于 0,说明已经存在重复入库
|
return count > 0; // 如果记录数大于 0,说明已经存在重复入库
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user