Commit 20e2d5a2 authored by wujiang's avatar wujiang

修改重复提交问题

parent 0251a0d4
......@@ -54,11 +54,12 @@ public class WorkOrderController extends BaseController {
* 新增施工派工工单
*
* @return
* @throws Exception
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/save")
@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());
model = workOrderServiceImpl.saveWorkOrder(model,userUnitInformationDto);
return ResponseHelper.buildResponse(model);
......
......@@ -25,6 +25,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.util.*;
import java.util.stream.Collectors;
/**
* 施工派工工单服务实现类
......@@ -110,7 +111,24 @@ public class WorkOrderServiceImpl extends BaseService<WorkOrderDto, WorkOrder, W
}
@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());
String code = NumberUtil.getCode(CodeEnum.派工单.getCode(), regionalCompanies.getCompanyCode(),
......@@ -126,9 +144,8 @@ public class WorkOrderServiceImpl extends BaseService<WorkOrderDto, WorkOrder, W
model.setAmosDealerOrgCode(userUnitInformationDto.getAmosDealerOrgCode());
workOrderMapper.insert(model);
// 保存派工单 电站信息
List<PeasantHousehold> peasantHouseholdId = model.getPeasantHouseholdId();
// 保存派工单 电站信息
List<ConstructionRecords> constructionRecordlist = new ArrayList<>();
List<WorkOrderPowerStation> li = new ArrayList<>();
for (PeasantHousehold peasantHousehold : peasantHouseholdId) {
......@@ -254,8 +271,8 @@ public class WorkOrderServiceImpl extends BaseService<WorkOrderDto, WorkOrder, W
@Transactional
public PowerStationConstructionData addOrUpdate(PowerStationConstructionData powerStationConstructionData) {
//如果不是提交进行单独保存
if(powerStationConstructionData.isCommitFlow()){
// 如果不是提交进行单独保存
if (powerStationConstructionData.isCommitFlow()) {
// if(powerStationConstructionData.getSequenceNbr()!=null){
// 修改施工电站状态
LambdaUpdateWrapper<WorkOrderPowerStation> up = new LambdaUpdateWrapper();
......@@ -295,28 +312,34 @@ public class WorkOrderServiceImpl extends BaseService<WorkOrderDto, WorkOrder, W
workOrderMapper.update(null, upq);
}
// 新增施工信息
// 防止重复添加
LambdaUpdateWrapper<PowerStationConstructionData> psc = new LambdaUpdateWrapper();
psc.eq(PowerStationConstructionData::getWorkOrderPowerStationId,
powerStationConstructionData.getWorkOrderPowerStationId());
psc.eq(PowerStationConstructionData::getWorkOrderId, powerStationConstructionData.getWorkOrderId());
powerStationConstructionDataService.saveOrUpdate(powerStationConstructionData, psc);
// powerStationConstructionDataService.saveOrUpdate(powerStationConstructionData);
// 增加操作日志
if (powerStationConstructionData.getSequenceNbr() != null) {
ConstructionRecords da = new ConstructionRecords(powerStationConstructionData.getRecUserName(), "编辑施工资料",
new Date(), "", powerStationConstructionData.getWorkOrderId(),
powerStationConstructionData.getWorkOrderPowerStationId(), null, "");
LambdaUpdateWrapper<ConstructionRecords> pcr = new LambdaUpdateWrapper<>();
pcr.eq(ConstructionRecords::getWorkOrderId, powerStationConstructionData.getWorkOrderId());
constructionRecordsServiceImpl.saveOrUpdate(da,pcr);
// 增加操作日志
if (powerStationConstructionData.getSequenceNbr() != null) {
ConstructionRecords da = new ConstructionRecords(powerStationConstructionData.getRecUserName(), "编辑施工资料",
new Date(), "", powerStationConstructionData.getWorkOrderId(),
powerStationConstructionData.getWorkOrderPowerStationId(), null, "");
constructionRecordsServiceImpl.save(da);
} else {
ConstructionRecords da = new ConstructionRecords(powerStationConstructionData.getRecUserName(), "新增施工资料",
new Date(), "", powerStationConstructionData.getWorkOrderId(),
powerStationConstructionData.getWorkOrderPowerStationId(), null, "");
LambdaUpdateWrapper<ConstructionRecords> pcr = new LambdaUpdateWrapper<>();
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{
......@@ -843,7 +866,7 @@ public class WorkOrderServiceImpl extends BaseService<WorkOrderDto, WorkOrder, W
// 防止重复提交
LambdaQueryWrapper<PowerStationEngineeringInfo> pse = new LambdaQueryWrapper<>();
pse.eq(PowerStationEngineeringInfo::getWorkOrderId, powerStationEngineeringInfo.getWorkOrderId());
//pse.eq(PowerStationEngineeringInfo::getWorkOrderPowerStationId,powerStationEngineeringInfo.getWorkOrderPowerStationId());
// pse.eq(PowerStationEngineeringInfo::getWorkOrderPowerStationId,powerStationEngineeringInfo.getWorkOrderPowerStationId());
// powerStationEngineeringInfoService.saveOrUpdate(powerStationEngineeringInfo);
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