Commit 20e2d5a2 authored by wujiang's avatar wujiang

修改重复提交问题

parent 0251a0d4
...@@ -54,11 +54,12 @@ public class WorkOrderController extends BaseController { ...@@ -54,11 +54,12 @@ public class WorkOrderController extends BaseController {
* 新增施工派工工单 * 新增施工派工工单
* *
* @return * @return
* @throws Exception
*/ */
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/save") @PostMapping(value = "/save")
@ApiOperation(httpMethod = "POST", value = "新增施工派工工单", notes = "新增施工派工工单") @ApiOperation(httpMethod = "POST", value = "新增施工派工工单", notes = "新增施工派工工单")
public ResponseModel<WorkOrder> save(@RequestBody WorkOrder model) { public ResponseModel<WorkOrder> save(@RequestBody WorkOrder model) throws Exception {
UserUnitInformationDto userUnitInformationDto=personnelBusinessMapper.getUserUnitInformationDto( getUserInfo().getUserId()); UserUnitInformationDto userUnitInformationDto=personnelBusinessMapper.getUserUnitInformationDto( getUserInfo().getUserId());
model = workOrderServiceImpl.saveWorkOrder(model,userUnitInformationDto); model = workOrderServiceImpl.saveWorkOrder(model,userUnitInformationDto);
return ResponseHelper.buildResponse(model); return ResponseHelper.buildResponse(model);
......
...@@ -25,6 +25,7 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -25,6 +25,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
/** /**
* 施工派工工单服务实现类 * 施工派工工单服务实现类
...@@ -110,7 +111,24 @@ public class WorkOrderServiceImpl extends BaseService<WorkOrderDto, WorkOrder, W ...@@ -110,7 +111,24 @@ public class WorkOrderServiceImpl extends BaseService<WorkOrderDto, WorkOrder, W
} }
@Transactional @Transactional
public WorkOrder saveWorkOrder(WorkOrder model, UserUnitInformationDto userUnitInformationDto) { public WorkOrder saveWorkOrder(WorkOrder model, UserUnitInformationDto userUnitInformationDto) throws Exception {
// 校验电站已被选
List<PeasantHousehold> peasantHouseholdId = model.getPeasantHouseholdId();
List<PeasantHousehold> workorderPeasant = new ArrayList<>();
for (PeasantHousehold peasantHouse : peasantHouseholdId) {
int count = workOrderPowerStationServiceImpl.count(new LambdaQueryWrapper<WorkOrderPowerStation>()
.eq(WorkOrderPowerStation::getPeasantHouseholdId, peasantHouse.getSequenceNbr()));
if (count > 0) {
PeasantHousehold peasantHouseOne = peasantHouseholdMapper.selectById(peasantHouse.getSequenceNbr());
workorderPeasant.add(peasantHouseOne);
}
}
if (!workorderPeasant.isEmpty()) {
String names = workorderPeasant.stream().map(i -> i.getOwnersName()).collect(Collectors.joining(","));
throw new Exception("电站" + names + ",已被工单关联");
}
// 保存派工单 // 保存派工单
RegionalCompanies regionalCompanies = regionalCompaniesMapper.selectRegionName(model.getRegionCompanyId()); RegionalCompanies regionalCompanies = regionalCompaniesMapper.selectRegionName(model.getRegionCompanyId());
String code = NumberUtil.getCode(CodeEnum.派工单.getCode(), regionalCompanies.getCompanyCode(), String code = NumberUtil.getCode(CodeEnum.派工单.getCode(), regionalCompanies.getCompanyCode(),
...@@ -126,9 +144,8 @@ public class WorkOrderServiceImpl extends BaseService<WorkOrderDto, WorkOrder, W ...@@ -126,9 +144,8 @@ public class WorkOrderServiceImpl extends BaseService<WorkOrderDto, WorkOrder, W
model.setAmosDealerOrgCode(userUnitInformationDto.getAmosDealerOrgCode()); model.setAmosDealerOrgCode(userUnitInformationDto.getAmosDealerOrgCode());
workOrderMapper.insert(model); workOrderMapper.insert(model);
// 保存派工单 电站信息
List<PeasantHousehold> peasantHouseholdId = model.getPeasantHouseholdId();
// 保存派工单 电站信息
List<ConstructionRecords> constructionRecordlist = new ArrayList<>(); List<ConstructionRecords> constructionRecordlist = new ArrayList<>();
List<WorkOrderPowerStation> li = new ArrayList<>(); List<WorkOrderPowerStation> li = new ArrayList<>();
for (PeasantHousehold peasantHousehold : peasantHouseholdId) { for (PeasantHousehold peasantHousehold : peasantHouseholdId) {
...@@ -254,8 +271,8 @@ public class WorkOrderServiceImpl extends BaseService<WorkOrderDto, WorkOrder, W ...@@ -254,8 +271,8 @@ public class WorkOrderServiceImpl extends BaseService<WorkOrderDto, WorkOrder, W
@Transactional @Transactional
public PowerStationConstructionData addOrUpdate(PowerStationConstructionData powerStationConstructionData) { public PowerStationConstructionData addOrUpdate(PowerStationConstructionData powerStationConstructionData) {
//如果不是提交进行单独保存 // 如果不是提交进行单独保存
if(powerStationConstructionData.isCommitFlow()){ if (powerStationConstructionData.isCommitFlow()) {
// if(powerStationConstructionData.getSequenceNbr()!=null){ // if(powerStationConstructionData.getSequenceNbr()!=null){
// 修改施工电站状态 // 修改施工电站状态
LambdaUpdateWrapper<WorkOrderPowerStation> up = new LambdaUpdateWrapper(); LambdaUpdateWrapper<WorkOrderPowerStation> up = new LambdaUpdateWrapper();
...@@ -295,28 +312,34 @@ public class WorkOrderServiceImpl extends BaseService<WorkOrderDto, WorkOrder, W ...@@ -295,28 +312,34 @@ public class WorkOrderServiceImpl extends BaseService<WorkOrderDto, WorkOrder, W
workOrderMapper.update(null, upq); workOrderMapper.update(null, upq);
} }
// 新增施工信息
// 防止重复添加 // 增加操作日志
LambdaUpdateWrapper<PowerStationConstructionData> psc = new LambdaUpdateWrapper(); if (powerStationConstructionData.getSequenceNbr() != null) {
psc.eq(PowerStationConstructionData::getWorkOrderPowerStationId, ConstructionRecords da = new ConstructionRecords(powerStationConstructionData.getRecUserName(), "编辑施工资料",
powerStationConstructionData.getWorkOrderPowerStationId()); new Date(), "", powerStationConstructionData.getWorkOrderId(),
psc.eq(PowerStationConstructionData::getWorkOrderId, powerStationConstructionData.getWorkOrderId()); powerStationConstructionData.getWorkOrderPowerStationId(), null, "");
powerStationConstructionDataService.saveOrUpdate(powerStationConstructionData, psc); LambdaUpdateWrapper<ConstructionRecords> pcr = new LambdaUpdateWrapper<>();
// powerStationConstructionDataService.saveOrUpdate(powerStationConstructionData); pcr.eq(ConstructionRecords::getWorkOrderId, powerStationConstructionData.getWorkOrderId());
constructionRecordsServiceImpl.saveOrUpdate(da,pcr);
// 增加操作日志 } else {
if (powerStationConstructionData.getSequenceNbr() != null) { ConstructionRecords da = new ConstructionRecords(powerStationConstructionData.getRecUserName(), "新增施工资料",
ConstructionRecords da = new ConstructionRecords(powerStationConstructionData.getRecUserName(), "编辑施工资料", new Date(), "", powerStationConstructionData.getWorkOrderId(),
new Date(), "", powerStationConstructionData.getWorkOrderId(), powerStationConstructionData.getWorkOrderPowerStationId(), null, "");
powerStationConstructionData.getWorkOrderPowerStationId(), null, ""); LambdaUpdateWrapper<ConstructionRecords> pcr = new LambdaUpdateWrapper<>();
constructionRecordsServiceImpl.save(da); pcr.eq(ConstructionRecords::getWorkOrderId, powerStationConstructionData.getWorkOrderId());
constructionRecordsServiceImpl.saveOrUpdate(da,pcr);
}
// 新增施工信息
// 防止重复添加
LambdaUpdateWrapper<PowerStationConstructionData> psc = new LambdaUpdateWrapper<>();
// psc.eq(PowerStationConstructionData::getWorkOrderPowerStationId,
// powerStationConstructionData.getWorkOrderPowerStationId());
psc.eq(PowerStationConstructionData::getWorkOrderId, powerStationConstructionData.getWorkOrderId());
powerStationConstructionDataService.saveOrUpdate(powerStationConstructionData, psc);
// powerStationConstructionDataService.saveOrUpdate(powerStationConstructionData);
} else {
ConstructionRecords da = new ConstructionRecords(powerStationConstructionData.getRecUserName(), "新增施工资料",
new Date(), "", powerStationConstructionData.getWorkOrderId(),
powerStationConstructionData.getWorkOrderPowerStationId(), null, "");
constructionRecordsServiceImpl.save(da);
}
// }else{ // }else{
...@@ -843,7 +866,7 @@ public class WorkOrderServiceImpl extends BaseService<WorkOrderDto, WorkOrder, W ...@@ -843,7 +866,7 @@ public class WorkOrderServiceImpl extends BaseService<WorkOrderDto, WorkOrder, W
// 防止重复提交 // 防止重复提交
LambdaQueryWrapper<PowerStationEngineeringInfo> pse = new LambdaQueryWrapper<>(); LambdaQueryWrapper<PowerStationEngineeringInfo> pse = new LambdaQueryWrapper<>();
pse.eq(PowerStationEngineeringInfo::getWorkOrderId, powerStationEngineeringInfo.getWorkOrderId()); pse.eq(PowerStationEngineeringInfo::getWorkOrderId, powerStationEngineeringInfo.getWorkOrderId());
//pse.eq(PowerStationEngineeringInfo::getWorkOrderPowerStationId,powerStationEngineeringInfo.getWorkOrderPowerStationId()); // pse.eq(PowerStationEngineeringInfo::getWorkOrderPowerStationId,powerStationEngineeringInfo.getWorkOrderPowerStationId());
// powerStationEngineeringInfoService.saveOrUpdate(powerStationEngineeringInfo); // powerStationEngineeringInfoService.saveOrUpdate(powerStationEngineeringInfo);
powerStationEngineeringInfoService.saveOrUpdate(powerStationEngineeringInfo, pse); powerStationEngineeringInfoService.saveOrUpdate(powerStationEngineeringInfo, pse);
// 增加操作日志 // 增加操作日志
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment