部件入庫接口實現優化
This commit is contained in:
parent
5486d9ffc5
commit
9b33215a48
@ -75,38 +75,39 @@ public class EbikeComponentServiceImpl implements EbikeComponentService {
|
|||||||
EbikeComponentTypeInfo ebikeComponentTypeInfo = getComponentTypeInfo(params.getComponentType()); // 获取部件信息
|
EbikeComponentTypeInfo ebikeComponentTypeInfo = getComponentTypeInfo(params.getComponentType()); // 获取部件信息
|
||||||
|
|
||||||
// 获取或新增部件记录
|
// 获取或新增部件记录
|
||||||
EbikeComponentEnterRecords ebikeComponentEnterRecords = buildEnterRecord(params, ebikeComponentTypeInfo,stockInType,orgId);
|
EbikeComponentEnterRecords ebikeComponentEnterRecords = buildEnterRecord(params, ebikeComponentTypeInfo, stockInType, orgId);
|
||||||
saveOrUpdateEnterRecord(ebikeComponentEnterRecords, params.getComponentEnterRecordId(), userId);
|
saveOrUpdateEnterRecord(ebikeComponentEnterRecords, params.getComponentEnterRecordId(), userId);
|
||||||
|
|
||||||
String componentEnterRecordId = ebikeComponentEnterRecords.getComponentEnterRecordId();
|
String componentEnterRecordId = ebikeComponentEnterRecords.getComponentEnterRecordId();
|
||||||
|
|
||||||
if(params.getEbikeEcuEnterRecords().size()>0){
|
if (params.getEbikeEcuEnterRecords() != null && !params.getEbikeEcuEnterRecords().isEmpty()) {
|
||||||
// 删除原有的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().size()>0){
|
} else if (params.getEbikeBatteryEnterRecords() != null && !params.getEbikeBatteryEnterRecords().isEmpty()) {
|
||||||
// 删除原有的电池入库记录并保存新的记录
|
// 删除原有的电池入库记录并保存新的记录
|
||||||
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().size()>0){
|
} else if (params.getEbikeHelmetEnterRecords() != null && !params.getEbikeHelmetEnterRecords().isEmpty()) {
|
||||||
// 删除原有的头盔入库记录并保存新的记录
|
// 删除原有的头盔入库记录并保存新的记录
|
||||||
deleteAndInsertHelmetEnterRecords(componentEnterRecordId, params.getEbikeHelmetEnterRecords(), stockInType, ebikeComponentTypeInfo, userId, orgId);
|
deleteAndInsertHelmetEnterRecords(componentEnterRecordId, params.getEbikeHelmetEnterRecords(), stockInType, ebikeComponentTypeInfo, userId, orgId);
|
||||||
if (stockInType == 1) {
|
if (stockInType == 1) {
|
||||||
updateInventoryCount(ebikeComponentTypeInfo, orgId, params.getEbikeHelmetEnterRecords().size(),1);
|
updateInventoryCount(ebikeComponentTypeInfo, orgId, params.getEbikeHelmetEnterRecords().size(), 1);
|
||||||
}
|
}
|
||||||
}else {
|
} else {
|
||||||
//部件数量 enterQuantity 更新部件库
|
//部件数量 enterQuantity 更新部件库
|
||||||
Integer enterQuantity = params.getEnterQuantity();
|
Integer enterQuantity = params.getEnterQuantity();
|
||||||
if (stockInType == 1) {
|
if (stockInType == 1) {
|
||||||
updateInventoryCount(ebikeComponentTypeInfo, orgId,enterQuantity,1);
|
updateInventoryCount(ebikeComponentTypeInfo, orgId, enterQuantity, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return JsonResult.success(componentEnterRecordId);
|
return JsonResult.success("", componentEnterRecordId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
获取用户Id
|
获取用户Id
|
||||||
*/
|
*/
|
||||||
@ -114,6 +115,7 @@ public class EbikeComponentServiceImpl implements EbikeComponentService {
|
|||||||
StaffFeign staffFeign = getStaffFeignInfo();
|
StaffFeign staffFeign = getStaffFeignInfo();
|
||||||
return staffFeign.getStaffId().toString();
|
return staffFeign.getStaffId().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
获取组织Id
|
获取组织Id
|
||||||
*/
|
*/
|
||||||
@ -124,6 +126,7 @@ public class EbikeComponentServiceImpl implements EbikeComponentService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取车辆部件类型表信息
|
* 获取车辆部件类型表信息
|
||||||
|
*
|
||||||
* @param componentType
|
* @param componentType
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -131,18 +134,18 @@ public class EbikeComponentServiceImpl implements EbikeComponentService {
|
|||||||
return ebikeComponentTypeInfoMapper.selectOneById(componentType);
|
return ebikeComponentTypeInfoMapper.selectOneById(componentType);
|
||||||
}
|
}
|
||||||
|
|
||||||
private EbikeComponentEnterRecords buildEnterRecord(ReqComponentEnterRecordDto params, EbikeComponentTypeInfo ebikeComponentTypeInfo,Integer stockInType,Long orgId) {
|
private EbikeComponentEnterRecords buildEnterRecord(ReqComponentEnterRecordDto params, EbikeComponentTypeInfo ebikeComponentTypeInfo, Integer stockInType, Long orgId) {
|
||||||
EbikeComponentEnterRecords ebikeComponentEnterRecords = new EbikeComponentEnterRecords();
|
EbikeComponentEnterRecords ebikeComponentEnterRecords = new EbikeComponentEnterRecords();
|
||||||
ebikeComponentEnterRecords.setOwningRegion(params.getOwningRegion());
|
ebikeComponentEnterRecords.setOwningRegion(params.getOwningRegion());
|
||||||
ebikeComponentEnterRecords.setOrgId(orgId);
|
ebikeComponentEnterRecords.setOrgId(orgId);
|
||||||
ebikeComponentEnterRecords.setComponentEnterRecordId(params.getComponentType());
|
ebikeComponentEnterRecords.setComponentType(params.getComponentType());
|
||||||
ebikeComponentEnterRecords.setEnterQuantity(params.getEnterQuantity());
|
ebikeComponentEnterRecords.setEnterQuantity(params.getEnterQuantity());
|
||||||
ebikeComponentEnterRecords.setComponentPrice(ebikeComponentTypeInfo.getPrice());
|
ebikeComponentEnterRecords.setComponentPrice(ebikeComponentTypeInfo.getPrice());
|
||||||
ebikeComponentEnterRecords.setState(stockInType==1 ? "1":"0"); // 暂存为 0 入库为1
|
ebikeComponentEnterRecords.setState(stockInType == 1 ? "1" : "0"); // 暂存为 0 入库为1
|
||||||
return ebikeComponentEnterRecords;
|
return ebikeComponentEnterRecords;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveOrUpdateEnterRecord(EbikeComponentEnterRecords ebikeComponentEnterRecords, String componentEnterRecordId,String userId) {
|
private void saveOrUpdateEnterRecord(EbikeComponentEnterRecords ebikeComponentEnterRecords, String componentEnterRecordId, String userId) {
|
||||||
if (componentEnterRecordId == null) { // 新增
|
if (componentEnterRecordId == null) { // 新增
|
||||||
ebikeComponentEnterRecords.setCreatedUser(userId);
|
ebikeComponentEnterRecords.setCreatedUser(userId);
|
||||||
ebikeComponentEnterRecords.setCreatedAt(LocalDateTime.now());
|
ebikeComponentEnterRecords.setCreatedAt(LocalDateTime.now());
|
||||||
@ -174,10 +177,11 @@ public class EbikeComponentServiceImpl implements EbikeComponentService {
|
|||||||
record.setComponentEnterRecordId(componentEnterRecordId);
|
record.setComponentEnterRecordId(componentEnterRecordId);
|
||||||
ebikeEcuEnterRecordsMapper.insert(record);
|
ebikeEcuEnterRecordsMapper.insert(record);
|
||||||
if (stockInType == 1) { // 仅在入库时执行
|
if (stockInType == 1) { // 仅在入库时执行
|
||||||
saveComponentInventory(record.getEcuSn(),record.getEcuCode(), ebikeComponentTypeInfo, userId, orgId,1);
|
saveComponentInventory(record.getEcuSn(), record.getEcuCode(), ebikeComponentTypeInfo, userId, orgId, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteAndInsertHelmetEnterRecords(String componentEnterRecordId, List<EbikeHelmetEnterRecords> ebikeHelmetEnterRecords, Integer stockInType, EbikeComponentTypeInfo ebikeComponentTypeInfo, String userId, Long orgId) {
|
private void deleteAndInsertHelmetEnterRecords(String componentEnterRecordId, List<EbikeHelmetEnterRecords> ebikeHelmetEnterRecords, Integer stockInType, EbikeComponentTypeInfo ebikeComponentTypeInfo, String userId, Long orgId) {
|
||||||
// 删除原有的头盔入库记录
|
// 删除原有的头盔入库记录
|
||||||
QueryWrapper query = new QueryWrapper();
|
QueryWrapper query = new QueryWrapper();
|
||||||
@ -188,7 +192,7 @@ public class EbikeComponentServiceImpl implements EbikeComponentService {
|
|||||||
record.setComponentEnterRecordId(componentEnterRecordId);
|
record.setComponentEnterRecordId(componentEnterRecordId);
|
||||||
ebikeHelmetEnterRecordsMapper.insert(record);
|
ebikeHelmetEnterRecordsMapper.insert(record);
|
||||||
if (stockInType == 1) { // 仅在入库时执行
|
if (stockInType == 1) { // 仅在入库时执行
|
||||||
saveComponentInventory(record.getHelmetCode(),"", ebikeComponentTypeInfo, userId, orgId,1);
|
saveComponentInventory(record.getHelmetCode(), "", ebikeComponentTypeInfo, userId, orgId, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -203,11 +207,12 @@ public class EbikeComponentServiceImpl implements EbikeComponentService {
|
|||||||
record.setComponentEnterRecordId(componentEnterRecordId);
|
record.setComponentEnterRecordId(componentEnterRecordId);
|
||||||
ebikeBatteryEnterRecordsMapper.insert(record);
|
ebikeBatteryEnterRecordsMapper.insert(record);
|
||||||
if (stockInType == 1) { // 仅在入库时执行
|
if (stockInType == 1) { // 仅在入库时执行
|
||||||
saveComponentInventory(record.getBatteryCode(),"", ebikeComponentTypeInfo, userId, orgId,1);
|
saveComponentInventory(record.getBatteryCode(), "", ebikeComponentTypeInfo, userId, orgId, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void saveComponentInventory(String ItemCode,String SerialNumber, EbikeComponentTypeInfo ebikeComponentTypeInfo, String userId, Long orgId,Integer state) {
|
|
||||||
|
private void saveComponentInventory(String ItemCode, String SerialNumber, EbikeComponentTypeInfo ebikeComponentTypeInfo, String userId, Long orgId, Integer state) {
|
||||||
EbikeComponentInventory ebikeComponentInventory = new EbikeComponentInventory();
|
EbikeComponentInventory ebikeComponentInventory = new EbikeComponentInventory();
|
||||||
ebikeComponentInventory.setItemCode(ItemCode);
|
ebikeComponentInventory.setItemCode(ItemCode);
|
||||||
ebikeComponentInventory.setSerialNumber(SerialNumber);
|
ebikeComponentInventory.setSerialNumber(SerialNumber);
|
||||||
@ -223,7 +228,7 @@ public class EbikeComponentServiceImpl implements EbikeComponentService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//入库记录更新数量 type 1 入库 2 出库
|
//入库记录更新数量 type 1 入库 2 出库
|
||||||
private void updateInventoryCount(EbikeComponentTypeInfo ebikeComponentTypeInfo, Long orgId, int size,Integer type) {
|
private void updateInventoryCount(EbikeComponentTypeInfo ebikeComponentTypeInfo, Long orgId, int size, Integer type) {
|
||||||
QueryWrapper query1 = new QueryWrapper();
|
QueryWrapper query1 = new QueryWrapper();
|
||||||
query1.eq("code", ebikeComponentTypeInfo.getId());
|
query1.eq("code", ebikeComponentTypeInfo.getId());
|
||||||
EbikeComponentInventorycount ebikeComponentInventorycount = ebikeComponentInventorycountMapper.selectOneByQuery(query1);
|
EbikeComponentInventorycount ebikeComponentInventorycount = ebikeComponentInventorycountMapper.selectOneByQuery(query1);
|
||||||
@ -238,9 +243,9 @@ public class EbikeComponentServiceImpl implements EbikeComponentService {
|
|||||||
ebikeComponentInventorycount.setCount(size);
|
ebikeComponentInventorycount.setCount(size);
|
||||||
ebikeComponentInventorycountMapper.insert(ebikeComponentInventorycount);
|
ebikeComponentInventorycountMapper.insert(ebikeComponentInventorycount);
|
||||||
} else {
|
} else {
|
||||||
if(type==1){//入库
|
if (type == 1) {//入库
|
||||||
ebikeComponentInventorycount.setCount(ebikeComponentInventorycount.getCount() + size);
|
ebikeComponentInventorycount.setCount(ebikeComponentInventorycount.getCount() + size);
|
||||||
}else {//出库
|
} else {//出库
|
||||||
ebikeComponentInventorycount.setCount(ebikeComponentInventorycount.getCount() - size);
|
ebikeComponentInventorycount.setCount(ebikeComponentInventorycount.getCount() - size);
|
||||||
}
|
}
|
||||||
ebikeComponentInventorycountMapper.update(ebikeComponentInventorycount);
|
ebikeComponentInventorycountMapper.update(ebikeComponentInventorycount);
|
||||||
@ -254,7 +259,7 @@ public class EbikeComponentServiceImpl implements EbikeComponentService {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public JsonResult<?> invalidateDevicePart(String componentEnterRecordId){
|
public JsonResult<?> invalidateDevicePart(String componentEnterRecordId) {
|
||||||
QueryWrapper query = new QueryWrapper();
|
QueryWrapper query = new QueryWrapper();
|
||||||
query.eq("component_enter_record_id", componentEnterRecordId);
|
query.eq("component_enter_record_id", componentEnterRecordId);
|
||||||
EbikeComponentEnterRecords ebikeComponentEnterRecords = ebikeComponentEnterRecordsMapper.selectOneByQuery(query);
|
EbikeComponentEnterRecords ebikeComponentEnterRecords = ebikeComponentEnterRecordsMapper.selectOneByQuery(query);
|
||||||
@ -290,7 +295,7 @@ public class EbikeComponentServiceImpl implements EbikeComponentService {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public JsonResult<?> cancelDevicePart(String componentEnterRecordId){
|
public JsonResult<?> cancelDevicePart(String componentEnterRecordId) {
|
||||||
QueryWrapper query = new QueryWrapper();
|
QueryWrapper query = new QueryWrapper();
|
||||||
query.eq("component_enter_record_id", componentEnterRecordId);
|
query.eq("component_enter_record_id", componentEnterRecordId);
|
||||||
EbikeComponentEnterRecords ebikeComponentEnterRecords = ebikeComponentEnterRecordsMapper.selectOneByQuery(query);
|
EbikeComponentEnterRecords ebikeComponentEnterRecords = ebikeComponentEnterRecordsMapper.selectOneByQuery(query);
|
||||||
@ -301,13 +306,13 @@ public class EbikeComponentServiceImpl implements EbikeComponentService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 方法实现
|
// 方法实现
|
||||||
private void updateBatteryDetails(String componentEnterRecordId,String componentType,Integer state) {
|
private void updateBatteryDetails(String componentEnterRecordId, String componentType, Integer state) {
|
||||||
// 具体更新电池仓库明细状态和仓库总数量的逻辑
|
// 具体更新电池仓库明细状态和仓库总数量的逻辑
|
||||||
QueryWrapper query = new QueryWrapper();
|
QueryWrapper query = new QueryWrapper();
|
||||||
query.eq("component_enter_record_id", componentEnterRecordId);
|
query.eq("component_enter_record_id", componentEnterRecordId);
|
||||||
List<EbikeBatteryEnterRecords> ebikeBatteryEnterRecords = ebikeBatteryEnterRecordsMapper.selectListWithRelationsByQuery(query);
|
List<EbikeBatteryEnterRecords> ebikeBatteryEnterRecords = ebikeBatteryEnterRecordsMapper.selectListWithRelationsByQuery(query);
|
||||||
for(EbikeBatteryEnterRecords record:ebikeBatteryEnterRecords){
|
for (EbikeBatteryEnterRecords record : ebikeBatteryEnterRecords) {
|
||||||
query = new QueryWrapper();
|
query = new QueryWrapper();
|
||||||
query.eq("item_code", record.getBatteryCode());
|
query.eq("item_code", record.getBatteryCode());
|
||||||
EbikeComponentInventory ebikeComponentInventory = ebikeComponentInventoryMapper.selectOneByQuery(query);
|
EbikeComponentInventory ebikeComponentInventory = ebikeComponentInventoryMapper.selectOneByQuery(query);
|
||||||
@ -315,15 +320,16 @@ public class EbikeComponentServiceImpl implements EbikeComponentService {
|
|||||||
ebikeComponentInventoryMapper.update(ebikeComponentInventory);
|
ebikeComponentInventoryMapper.update(ebikeComponentInventory);
|
||||||
}
|
}
|
||||||
int size = ebikeBatteryEnterRecords.size();
|
int size = ebikeBatteryEnterRecords.size();
|
||||||
updateOtherComponentStock(componentType,size);
|
updateOtherComponentStock(componentType, size);
|
||||||
}
|
}
|
||||||
private void updateHelmetDetails(String componentEnterRecordId,String componentType,Integer state) {
|
|
||||||
|
private void updateHelmetDetails(String componentEnterRecordId, String componentType, Integer state) {
|
||||||
// 具体更新头盔仓库明细状态和仓库总数量的逻辑
|
// 具体更新头盔仓库明细状态和仓库总数量的逻辑
|
||||||
QueryWrapper query = new QueryWrapper();
|
QueryWrapper query = new QueryWrapper();
|
||||||
query.eq("component_enter_record_id", componentEnterRecordId);
|
query.eq("component_enter_record_id", componentEnterRecordId);
|
||||||
|
|
||||||
List<EbikeHelmetEnterRecords> ebikeHelmetEnterRecords = ebikeHelmetEnterRecordsMapper.selectListWithRelationsByQuery(query);
|
List<EbikeHelmetEnterRecords> ebikeHelmetEnterRecords = ebikeHelmetEnterRecordsMapper.selectListWithRelationsByQuery(query);
|
||||||
for(EbikeHelmetEnterRecords record:ebikeHelmetEnterRecords){
|
for (EbikeHelmetEnterRecords record : ebikeHelmetEnterRecords) {
|
||||||
query = new QueryWrapper();
|
query = new QueryWrapper();
|
||||||
query.eq("item_code", record.getHelmetCode());
|
query.eq("item_code", record.getHelmetCode());
|
||||||
EbikeComponentInventory ebikeComponentInventory = ebikeComponentInventoryMapper.selectOneByQuery(query);
|
EbikeComponentInventory ebikeComponentInventory = ebikeComponentInventoryMapper.selectOneByQuery(query);
|
||||||
@ -331,15 +337,15 @@ public class EbikeComponentServiceImpl implements EbikeComponentService {
|
|||||||
ebikeComponentInventoryMapper.update(ebikeComponentInventory);
|
ebikeComponentInventoryMapper.update(ebikeComponentInventory);
|
||||||
}
|
}
|
||||||
int size = ebikeHelmetEnterRecords.size();
|
int size = ebikeHelmetEnterRecords.size();
|
||||||
updateOtherComponentStock(componentType,size);
|
updateOtherComponentStock(componentType, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateCentralControlDetails(String componentEnterRecordId,String componentType,Integer state) {
|
private void updateCentralControlDetails(String componentEnterRecordId, String componentType, Integer state) {
|
||||||
// 具体更新中控仓库明细状态和仓库总数量的逻辑
|
// 具体更新中控仓库明细状态和仓库总数量的逻辑
|
||||||
QueryWrapper query = new QueryWrapper();
|
QueryWrapper query = new QueryWrapper();
|
||||||
query.eq("component_enter_record_id", componentEnterRecordId);
|
query.eq("component_enter_record_id", componentEnterRecordId);
|
||||||
List<EbikeEcuEnterRecords> ebikeEcuEnterRecords = ebikeEcuEnterRecordsMapper.selectListWithRelationsByQuery(query);
|
List<EbikeEcuEnterRecords> ebikeEcuEnterRecords = ebikeEcuEnterRecordsMapper.selectListWithRelationsByQuery(query);
|
||||||
for(EbikeEcuEnterRecords record:ebikeEcuEnterRecords){
|
for (EbikeEcuEnterRecords record : ebikeEcuEnterRecords) {
|
||||||
query = new QueryWrapper();
|
query = new QueryWrapper();
|
||||||
query.eq("item_code", record.getEcuSn());
|
query.eq("item_code", record.getEcuSn());
|
||||||
query.eq("serial_number", record.getEcuCode());
|
query.eq("serial_number", record.getEcuCode());
|
||||||
@ -348,36 +354,40 @@ public class EbikeComponentServiceImpl implements EbikeComponentService {
|
|||||||
ebikeComponentInventoryMapper.update(ebikeComponentInventory);
|
ebikeComponentInventoryMapper.update(ebikeComponentInventory);
|
||||||
}
|
}
|
||||||
int size = ebikeEcuEnterRecords.size();
|
int size = ebikeEcuEnterRecords.size();
|
||||||
updateOtherComponentStock(componentType,size);
|
updateOtherComponentStock(componentType, size);
|
||||||
}
|
}
|
||||||
private void updateOtherComponentStock(String componentType,Integer size) {
|
|
||||||
|
private void updateOtherComponentStock(String componentType, Integer size) {
|
||||||
// 具体更新其他组件仓库总数量的逻辑
|
// 具体更新其他组件仓库总数量的逻辑
|
||||||
QueryWrapper query1 = new QueryWrapper();
|
QueryWrapper query1 = new QueryWrapper();
|
||||||
query1.eq("code", componentType);
|
query1.eq("code", componentType);
|
||||||
EbikeComponentInventorycount ebikeComponentInventorycount = ebikeComponentInventorycountMapper.selectOneByQuery(query1);
|
EbikeComponentInventorycount ebikeComponentInventorycount = ebikeComponentInventorycountMapper.selectOneByQuery(query1);
|
||||||
if(ebikeComponentInventorycount !=null){
|
if (ebikeComponentInventorycount != null) {
|
||||||
ebikeComponentInventorycount.setCount(ebikeComponentInventorycount.getCount()-size);
|
ebikeComponentInventorycount.setCount(ebikeComponentInventorycount.getCount() - size);
|
||||||
ebikeComponentInventorycountMapper.update(ebikeComponentInventorycount);
|
ebikeComponentInventorycountMapper.update(ebikeComponentInventorycount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 出库作废增加部件数量
|
* 出库作废增加部件数量
|
||||||
|
*
|
||||||
* @param componentType
|
* @param componentType
|
||||||
* @param size
|
* @param size
|
||||||
*/
|
*/
|
||||||
private void updateOtherOutComponentStock(String componentType,Integer size) {
|
private void updateOtherOutComponentStock(String componentType, Integer size) {
|
||||||
// 具体更新其他组件仓库总数量的逻辑
|
// 具体更新其他组件仓库总数量的逻辑
|
||||||
QueryWrapper query1 = new QueryWrapper();
|
QueryWrapper query1 = new QueryWrapper();
|
||||||
query1.eq("code", componentType);
|
query1.eq("code", componentType);
|
||||||
EbikeComponentInventorycount ebikeComponentInventorycount = ebikeComponentInventorycountMapper.selectOneByQuery(query1);
|
EbikeComponentInventorycount ebikeComponentInventorycount = ebikeComponentInventorycountMapper.selectOneByQuery(query1);
|
||||||
if(ebikeComponentInventorycount !=null){
|
if (ebikeComponentInventorycount != null) {
|
||||||
ebikeComponentInventorycount.setCount(ebikeComponentInventorycount.getCount()+size);
|
ebikeComponentInventorycount.setCount(ebikeComponentInventorycount.getCount() + size);
|
||||||
ebikeComponentInventorycountMapper.update(ebikeComponentInventorycount);
|
ebikeComponentInventorycountMapper.update(ebikeComponentInventorycount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部件出库(出库,暂存) (stockInType 0或空 表示暂存,1 表示入库。
|
* 部件出库(出库,暂存) (stockInType 0或空 表示暂存,1 表示入库。
|
||||||
|
*
|
||||||
* @param params
|
* @param params
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -400,43 +410,44 @@ public class EbikeComponentServiceImpl implements EbikeComponentService {
|
|||||||
Integer count = ebikeComponentInventorycount.getCount();
|
Integer count = ebikeComponentInventorycount.getCount();
|
||||||
String name = ebikeComponentInventorycount.getName();
|
String name = ebikeComponentInventorycount.getName();
|
||||||
// String brand = ebikeComponentInventorycount.getBrand();
|
// String brand = ebikeComponentInventorycount.getBrand();
|
||||||
if(count<outQuantity){
|
if (count < outQuantity) {
|
||||||
return JsonResult.failed(String.format("%s 的库存数量不足!剩余数量:%s",name, count));
|
return JsonResult.failed(String.format("%s 的库存数量不足!剩余数量:%s", name, count));
|
||||||
}
|
}
|
||||||
// 获取或新增部件记录
|
// 获取或新增部件记录
|
||||||
EbikeComponentOutRecords ebikeComponentOutRecords = buildOutRecord(params,ebikeComponentTypeInfo,stockInType,orgId);
|
EbikeComponentOutRecords ebikeComponentOutRecords = buildOutRecord(params, ebikeComponentTypeInfo, stockInType, orgId);
|
||||||
saveOrUpdateOutRecord(ebikeComponentOutRecords, params.getComponentOutRecordId(),userId);
|
saveOrUpdateOutRecord(ebikeComponentOutRecords, params.getComponentOutRecordId(), userId);
|
||||||
|
|
||||||
String componentOutRecordId = ebikeComponentOutRecords.getComponentOutRecordId();
|
String componentOutRecordId = ebikeComponentOutRecords.getComponentOutRecordId();
|
||||||
|
|
||||||
if(params.getEbikeEcuOutRecords().size()>0){
|
if (params.getEbikeEcuOutRecords().size() > 0) {
|
||||||
// 删除原有的ECU入库记录并保存新的记录
|
// 删除原有的ECU入库记录并保存新的记录
|
||||||
deleteAndInsertEcuOutRecords(componentOutRecordId, params.getEbikeEcuOutRecords(), stockInType, ebikeComponentTypeInfo, userId, orgId);
|
deleteAndInsertEcuOutRecords(componentOutRecordId, params.getEbikeEcuOutRecords(), stockInType, ebikeComponentTypeInfo, userId, orgId);
|
||||||
if (stockInType == 1) {
|
if (stockInType == 1) {
|
||||||
updateInventoryCount(ebikeComponentTypeInfo, orgId, params.getEbikeEcuOutRecords().size(),2);
|
updateInventoryCount(ebikeComponentTypeInfo, orgId, params.getEbikeEcuOutRecords().size(), 2);
|
||||||
}
|
}
|
||||||
}else if(params.getEbikeBatteryOutRecords().size()>0){
|
} else if (params.getEbikeBatteryOutRecords().size() > 0) {
|
||||||
// 删除原有的电池入库记录并保存新的记录
|
// 删除原有的电池入库记录并保存新的记录
|
||||||
deleteAndInsertBatteryOutRecords(componentOutRecordId, params.getEbikeBatteryOutRecords(), stockInType, ebikeComponentTypeInfo, userId, orgId);
|
deleteAndInsertBatteryOutRecords(componentOutRecordId, params.getEbikeBatteryOutRecords(), stockInType, ebikeComponentTypeInfo, userId, orgId);
|
||||||
if (stockInType == 1) {
|
if (stockInType == 1) {
|
||||||
updateInventoryCount(ebikeComponentTypeInfo, orgId, params.getEbikeBatteryOutRecords().size(),2);
|
updateInventoryCount(ebikeComponentTypeInfo, orgId, params.getEbikeBatteryOutRecords().size(), 2);
|
||||||
}
|
}
|
||||||
}else if(params.getEbikeHelmetOutRecords().size()>0){
|
} else if (params.getEbikeHelmetOutRecords().size() > 0) {
|
||||||
// 删除原有的头盔入库记录并保存新的记录
|
// 删除原有的头盔入库记录并保存新的记录
|
||||||
deleteAndInsertHelmetOutRecords(componentOutRecordId, params.getEbikeHelmetOutRecords(), stockInType, ebikeComponentTypeInfo, userId, orgId);
|
deleteAndInsertHelmetOutRecords(componentOutRecordId, params.getEbikeHelmetOutRecords(), stockInType, ebikeComponentTypeInfo, userId, orgId);
|
||||||
if (stockInType == 1) {
|
if (stockInType == 1) {
|
||||||
updateInventoryCount(ebikeComponentTypeInfo, orgId, params.getEbikeHelmetOutRecords().size(),2);
|
updateInventoryCount(ebikeComponentTypeInfo, orgId, params.getEbikeHelmetOutRecords().size(), 2);
|
||||||
}
|
}
|
||||||
}else {
|
} else {
|
||||||
//部件数量 enterQuantity 更新部件库
|
//部件数量 enterQuantity 更新部件库
|
||||||
Integer enterQuantity = params.getEnterQuantity();
|
Integer enterQuantity = params.getEnterQuantity();
|
||||||
if (stockInType == 1) {
|
if (stockInType == 1) {
|
||||||
updateInventoryCount(ebikeComponentTypeInfo, orgId,enterQuantity,2);
|
updateInventoryCount(ebikeComponentTypeInfo, orgId, enterQuantity, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return JsonResult.success(componentOutRecordId);
|
return JsonResult.success(componentOutRecordId);
|
||||||
}
|
}
|
||||||
private EbikeComponentOutRecords buildOutRecord(ReqComponentOutRecordDto params, EbikeComponentTypeInfo ebikeComponentTypeInfo,Integer stockInType,Long orgId) {
|
|
||||||
|
private EbikeComponentOutRecords buildOutRecord(ReqComponentOutRecordDto params, EbikeComponentTypeInfo ebikeComponentTypeInfo, Integer stockInType, Long orgId) {
|
||||||
EbikeComponentOutRecords ebikeComponentOutRecords = new EbikeComponentOutRecords();
|
EbikeComponentOutRecords ebikeComponentOutRecords = new EbikeComponentOutRecords();
|
||||||
ebikeComponentOutRecords.setOwningRegion(params.getOwningRegion());
|
ebikeComponentOutRecords.setOwningRegion(params.getOwningRegion());
|
||||||
ebikeComponentOutRecords.setOrgId(orgId);
|
ebikeComponentOutRecords.setOrgId(orgId);
|
||||||
@ -444,10 +455,11 @@ 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
|
ebikeComponentOutRecords.setState(stockInType == 1 ? "1" : "0"); // 暂存为 0 出库库为1
|
||||||
return ebikeComponentOutRecords;
|
return ebikeComponentOutRecords;
|
||||||
}
|
}
|
||||||
private void saveOrUpdateOutRecord(EbikeComponentOutRecords ebikeComponentOutRecords, String componentEnterRecordId,String userId) {
|
|
||||||
|
private void saveOrUpdateOutRecord(EbikeComponentOutRecords ebikeComponentOutRecords, String componentEnterRecordId, String userId) {
|
||||||
if (componentEnterRecordId == null) { // 新增
|
if (componentEnterRecordId == null) { // 新增
|
||||||
ebikeComponentOutRecords.setCreatedUser(userId);
|
ebikeComponentOutRecords.setCreatedUser(userId);
|
||||||
ebikeComponentOutRecords.setCreatedAt(LocalDateTime.now());
|
ebikeComponentOutRecords.setCreatedAt(LocalDateTime.now());
|
||||||
@ -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) {
|
private void deleteAndInsertEcuOutRecords(String componentOutRecordId, List<EbikeEcuOutRecords> outRecords, Integer stockInType, EbikeComponentTypeInfo ebikeComponentTypeInfo, String userId, Long orgId) {
|
||||||
// 删除原有的ECU入库记录
|
// 删除原有的ECU入库记录
|
||||||
QueryWrapper query = new QueryWrapper();
|
QueryWrapper query = new QueryWrapper();
|
||||||
@ -478,7 +491,7 @@ public class EbikeComponentServiceImpl implements EbikeComponentService {
|
|||||||
record.setComponentOutRecordId(componentOutRecordId);
|
record.setComponentOutRecordId(componentOutRecordId);
|
||||||
ebikeEcuOutRecordsMapper.insert(record);
|
ebikeEcuOutRecordsMapper.insert(record);
|
||||||
if (stockInType == 1) { // 仅在出库时执行
|
if (stockInType == 1) { // 仅在出库时执行
|
||||||
saveComponentInventory(record.getEcuSn(),record.getEcuCode(), ebikeComponentTypeInfo, userId, orgId,2);
|
saveComponentInventory(record.getEcuSn(), record.getEcuCode(), ebikeComponentTypeInfo, userId, orgId, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -493,7 +506,7 @@ public class EbikeComponentServiceImpl implements EbikeComponentService {
|
|||||||
record.setComponentOutRecordId(componentOutRecordId);
|
record.setComponentOutRecordId(componentOutRecordId);
|
||||||
ebikeHelmetOutRecordsMapper.insert(record);
|
ebikeHelmetOutRecordsMapper.insert(record);
|
||||||
if (stockInType == 1) { // 仅在出库时执行
|
if (stockInType == 1) { // 仅在出库时执行
|
||||||
saveComponentInventory(record.getHelmetCode(),"", ebikeComponentTypeInfo, userId, orgId,2);
|
saveComponentInventory(record.getHelmetCode(), "", ebikeComponentTypeInfo, userId, orgId, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -508,17 +521,19 @@ public class EbikeComponentServiceImpl implements EbikeComponentService {
|
|||||||
record.setComponentOutRecordId(componentOutRecordId);
|
record.setComponentOutRecordId(componentOutRecordId);
|
||||||
ebikeBatteryOutRecordsMapper.insert(record);
|
ebikeBatteryOutRecordsMapper.insert(record);
|
||||||
if (stockInType == 1) { // 仅在出库时执行
|
if (stockInType == 1) { // 仅在出库时执行
|
||||||
saveComponentInventory(record.getBatteryCode(),"", ebikeComponentTypeInfo, userId, orgId,2);
|
saveComponentInventory(record.getBatteryCode(), "", ebikeComponentTypeInfo, userId, orgId, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备部件出库取消(通用)
|
* 设备部件出库取消(通用)
|
||||||
|
*
|
||||||
* @param componentOutRecordId
|
* @param componentOutRecordId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public JsonResult<?> cancelOutDevicePart(String componentOutRecordId){
|
public JsonResult<?> cancelOutDevicePart(String componentOutRecordId) {
|
||||||
QueryWrapper query = new QueryWrapper();
|
QueryWrapper query = new QueryWrapper();
|
||||||
query.eq("component_out_record_id", componentOutRecordId);
|
query.eq("component_out_record_id", componentOutRecordId);
|
||||||
EbikeComponentOutRecords ebikeComponentOutRecords = ebikeComponentOutRecordsMapper.selectOneByQuery(query);
|
EbikeComponentOutRecords ebikeComponentOutRecords = ebikeComponentOutRecordsMapper.selectOneByQuery(query);
|
||||||
@ -527,14 +542,16 @@ public class EbikeComponentServiceImpl implements EbikeComponentService {
|
|||||||
ebikeComponentOutRecordsMapper.update(ebikeComponentOutRecords);
|
ebikeComponentOutRecordsMapper.update(ebikeComponentOutRecords);
|
||||||
return JsonResult.success("成功");
|
return JsonResult.success("成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备部件出库作废 (通用
|
* 设备部件出库作废 (通用
|
||||||
|
*
|
||||||
* @param componentOutRecordId
|
* @param componentOutRecordId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public JsonResult<?> invalidateOutDevicePart(String componentOutRecordId){
|
public JsonResult<?> invalidateOutDevicePart(String componentOutRecordId) {
|
||||||
QueryWrapper query = new QueryWrapper();
|
QueryWrapper query = new QueryWrapper();
|
||||||
query.eq("component_out_record_id", componentOutRecordId);
|
query.eq("component_out_record_id", componentOutRecordId);
|
||||||
EbikeComponentOutRecords ebikeComponentOutRecords = ebikeComponentOutRecordsMapper.selectOneByQuery(query);
|
EbikeComponentOutRecords ebikeComponentOutRecords = ebikeComponentOutRecordsMapper.selectOneByQuery(query);
|
||||||
@ -561,12 +578,13 @@ public class EbikeComponentServiceImpl implements EbikeComponentService {
|
|||||||
}
|
}
|
||||||
return JsonResult.success("成功");
|
return JsonResult.success("成功");
|
||||||
}
|
}
|
||||||
private void updateBatteryOutDetails(String componentOutRecordId,String componentType,Integer state) {
|
|
||||||
|
private void updateBatteryOutDetails(String componentOutRecordId, String componentType, Integer state) {
|
||||||
// 具体更新电池仓库明细状态和仓库总数量的逻辑
|
// 具体更新电池仓库明细状态和仓库总数量的逻辑
|
||||||
QueryWrapper query = new QueryWrapper();
|
QueryWrapper query = new QueryWrapper();
|
||||||
query.eq("component_out_record_id", componentOutRecordId);
|
query.eq("component_out_record_id", componentOutRecordId);
|
||||||
List<EbikeBatteryOutRecords> ebikeBatteryOutRecords = ebikeBatteryOutRecordsMapper.selectListWithRelationsByQuery(query);
|
List<EbikeBatteryOutRecords> ebikeBatteryOutRecords = ebikeBatteryOutRecordsMapper.selectListWithRelationsByQuery(query);
|
||||||
for(EbikeBatteryOutRecords record:ebikeBatteryOutRecords){
|
for (EbikeBatteryOutRecords record : ebikeBatteryOutRecords) {
|
||||||
query = new QueryWrapper();
|
query = new QueryWrapper();
|
||||||
query.eq("item_code", record.getBatteryCode());
|
query.eq("item_code", record.getBatteryCode());
|
||||||
EbikeComponentInventory ebikeComponentInventory = ebikeComponentInventoryMapper.selectOneByQuery(query);
|
EbikeComponentInventory ebikeComponentInventory = ebikeComponentInventoryMapper.selectOneByQuery(query);
|
||||||
@ -574,16 +592,16 @@ public class EbikeComponentServiceImpl implements EbikeComponentService {
|
|||||||
ebikeComponentInventoryMapper.update(ebikeComponentInventory);
|
ebikeComponentInventoryMapper.update(ebikeComponentInventory);
|
||||||
}
|
}
|
||||||
int size = ebikeBatteryOutRecords.size();
|
int size = ebikeBatteryOutRecords.size();
|
||||||
updateOtherOutComponentStock(componentType,size);
|
updateOtherOutComponentStock(componentType, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateHelmetOutDetails(String componentOutRecordId,String componentType,Integer state) {
|
private void updateHelmetOutDetails(String componentOutRecordId, String componentType, Integer state) {
|
||||||
// 具体更新头盔仓库明细状态和仓库总数量的逻辑
|
// 具体更新头盔仓库明细状态和仓库总数量的逻辑
|
||||||
QueryWrapper query = new QueryWrapper();
|
QueryWrapper query = new QueryWrapper();
|
||||||
query.eq("component_out_record_id", componentOutRecordId);
|
query.eq("component_out_record_id", componentOutRecordId);
|
||||||
|
|
||||||
List<EbikeHelmetOutRecords> ebikeHelmetOutRecords = ebikeHelmetOutRecordsMapper.selectListWithRelationsByQuery(query);
|
List<EbikeHelmetOutRecords> ebikeHelmetOutRecords = ebikeHelmetOutRecordsMapper.selectListWithRelationsByQuery(query);
|
||||||
for(EbikeHelmetOutRecords record:ebikeHelmetOutRecords){
|
for (EbikeHelmetOutRecords record : ebikeHelmetOutRecords) {
|
||||||
query = new QueryWrapper();
|
query = new QueryWrapper();
|
||||||
query.eq("item_code", record.getHelmetCode());
|
query.eq("item_code", record.getHelmetCode());
|
||||||
EbikeComponentInventory ebikeComponentInventory = ebikeComponentInventoryMapper.selectOneByQuery(query);
|
EbikeComponentInventory ebikeComponentInventory = ebikeComponentInventoryMapper.selectOneByQuery(query);
|
||||||
@ -591,14 +609,15 @@ public class EbikeComponentServiceImpl implements EbikeComponentService {
|
|||||||
ebikeComponentInventoryMapper.update(ebikeComponentInventory);
|
ebikeComponentInventoryMapper.update(ebikeComponentInventory);
|
||||||
}
|
}
|
||||||
int size = ebikeHelmetOutRecords.size();
|
int size = ebikeHelmetOutRecords.size();
|
||||||
updateOtherOutComponentStock(componentType,size);
|
updateOtherOutComponentStock(componentType, size);
|
||||||
}
|
}
|
||||||
private void updateCentralControlOutDetails(String componentOutRecordId,String componentType,Integer state) {
|
|
||||||
|
private void updateCentralControlOutDetails(String componentOutRecordId, String componentType, Integer state) {
|
||||||
// 具体更新中控仓库明细状态和仓库总数量的逻辑
|
// 具体更新中控仓库明细状态和仓库总数量的逻辑
|
||||||
QueryWrapper query = new QueryWrapper();
|
QueryWrapper query = new QueryWrapper();
|
||||||
query.eq("component_out_record_id", componentOutRecordId);
|
query.eq("component_out_record_id", componentOutRecordId);
|
||||||
List<EbikeEcuOutRecords> ebikeEcuOutRecords = ebikeEcuOutRecordsMapper.selectListWithRelationsByQuery(query);
|
List<EbikeEcuOutRecords> ebikeEcuOutRecords = ebikeEcuOutRecordsMapper.selectListWithRelationsByQuery(query);
|
||||||
for(EbikeEcuOutRecords record:ebikeEcuOutRecords){
|
for (EbikeEcuOutRecords record : ebikeEcuOutRecords) {
|
||||||
query = new QueryWrapper();
|
query = new QueryWrapper();
|
||||||
query.eq("item_code", record.getEcuSn());
|
query.eq("item_code", record.getEcuSn());
|
||||||
query.eq("serial_number", record.getEcuCode());
|
query.eq("serial_number", record.getEcuCode());
|
||||||
@ -607,8 +626,9 @@ public class EbikeComponentServiceImpl implements EbikeComponentService {
|
|||||||
ebikeComponentInventoryMapper.update(ebikeComponentInventory);
|
ebikeComponentInventoryMapper.update(ebikeComponentInventory);
|
||||||
}
|
}
|
||||||
int size = ebikeEcuOutRecords.size();
|
int size = ebikeEcuOutRecords.size();
|
||||||
updateOtherOutComponentStock(componentType,size);
|
updateOtherOutComponentStock(componentType, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
public StaffFeign getStaffFeignInfo() {
|
public StaffFeign getStaffFeignInfo() {
|
||||||
String tokenValue = StpUtil.getTokenValue();
|
String tokenValue = StpUtil.getTokenValue();
|
||||||
// 调用 Feign 客户端获取用户信息
|
// 调用 Feign 客户端获取用户信息
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user