表单提交

This commit is contained in:
hzj
2024-05-13 14:55:33 +08:00
parent d814600c85
commit 14fe1a7537
28 changed files with 1679 additions and 35 deletions

View File

@@ -0,0 +1,25 @@
package com.njcn.supervision.service.dev;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.supervision.pojo.param.user.SupervisionDevMainReportParam;
import com.njcn.supervision.pojo.po.dev.SupervisionDevMainReportPO;
import java.util.List;
/**
*
* Description:
* Date: 2024/5/10 18:10【需求编号】
*
* @author clam
* @version V1.0.0
*/
public interface SupervisionDevMainReportPOService extends IService<SupervisionDevMainReportPO>{
String addDevReport(SupervisionDevMainReportParam supervisionDevMainReportParam);
boolean auditDevReport(SupervisionDevMainReportParam.SupervisionDevMainReportParamUpdate supervisionDevMainReportParamUpdate);
Boolean removeDevReport(List<String> ids);
}

View File

@@ -0,0 +1,16 @@
package com.njcn.supervision.service.dev;
import com.njcn.supervision.pojo.po.dev.SupervisionTempDeviceReport;
import com.baomidou.mybatisplus.extension.service.IService;
/**
*
* Description:
* Date: 2024/5/11 14:07【需求编号】
*
* @author clam
* @version V1.0.0
*/
public interface SupervisionTempDeviceReportService extends IService<SupervisionTempDeviceReport>{
}

View File

@@ -0,0 +1,16 @@
package com.njcn.supervision.service.dev;
import com.njcn.supervision.pojo.po.dev.SupervisionTempLineReport;
import com.baomidou.mybatisplus.extension.service.IService;
/**
*
* Description:
* Date: 2024/5/11 14:07【需求编号】
*
* @author clam
* @version V1.0.0
*/
public interface SupervisionTempLineReportService extends IService<SupervisionTempLineReport>{
}

View File

@@ -0,0 +1,132 @@
package com.njcn.supervision.service.dev.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.bpm.api.BpmProcessFeignClient;
import com.njcn.bpm.pojo.dto.BpmProcessInstanceCreateReqDTO;
import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.supervision.enums.FlowStatusEnum;
import com.njcn.supervision.mapper.dev.SupervisionDevMainReportPOMapper;
import com.njcn.supervision.pojo.param.user.SupervisionDevMainReportParam;
import com.njcn.supervision.pojo.param.user.SupervisionTempDeviceReportParam;
import com.njcn.supervision.pojo.param.user.SupervisionTempLineReportParam;
import com.njcn.supervision.pojo.po.dev.SupervisionDevMainReportPO;
import com.njcn.supervision.pojo.po.dev.SupervisionTempDeviceReport;
import com.njcn.supervision.pojo.po.dev.SupervisionTempLineReport;
import com.njcn.supervision.service.dev.SupervisionDevMainReportPOService;
import com.njcn.supervision.service.dev.SupervisionTempDeviceReportService;
import com.njcn.supervision.service.dev.SupervisionTempLineReportService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
*
* Description:
* Date: 2024/5/10 18:10【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Service
@RequiredArgsConstructor
public class SupervisionDevMainReportPOServiceImpl extends ServiceImpl<SupervisionDevMainReportPOMapper, SupervisionDevMainReportPO> implements SupervisionDevMainReportPOService {
/**
* 用户信息建档对应的流程定义 KEY
*/
//todo 修改成建设阶段流程图key
public static final String PROCESS_KEY = "build_user_info";
private final BpmProcessFeignClient bpmProcessFeignClient;
private final SupervisionTempDeviceReportService supervisionTempDeviceReportService;
private final SupervisionTempLineReportService supervisionTempLineReportService;
@Override
@Transactional(rollbackFor = Exception.class)
public String addDevReport(SupervisionDevMainReportParam supervisionDevMainReportParam) {
//判断干扰源用户是否绑定
checkUserId(supervisionDevMainReportParam, false);
SupervisionDevMainReportPO supervisionDevMainReportPO = new SupervisionDevMainReportPO();
BeanUtils.copyProperties(supervisionDevMainReportParam, supervisionDevMainReportPO);
supervisionDevMainReportPO.setState(DataStateEnum.ENABLE.getCode());
this.save(supervisionDevMainReportPO);
String id = supervisionDevMainReportPO.getId();
//存储临时终端信息
SupervisionTempDeviceReportParam supervisionTempDeviceReportParam = supervisionDevMainReportParam.getSupervisionTempDeviceReportParam();
SupervisionTempDeviceReport supervisionTempDeviceReportPO = new SupervisionTempDeviceReport();
BeanUtils.copyProperties(supervisionTempDeviceReportParam, supervisionTempDeviceReportPO);
supervisionTempDeviceReportPO.setId(id);
supervisionTempDeviceReportService.save(supervisionTempDeviceReportPO);
//存储临时监测点信息
SupervisionTempLineReportParam supervisionTempLineReportParam = supervisionDevMainReportParam.getSupervisionTempLineReportParam();
SupervisionTempLineReport supervisionTempLineReport = new SupervisionTempLineReport();
BeanUtils.copyProperties(supervisionTempLineReportParam, supervisionTempLineReport);
supervisionTempDeviceReportPO.setId(id);
supervisionTempLineReportService.save(supervisionTempLineReport);
// 发起 BPM 流程
Map<String, Object> processInstanceVariables = new HashMap<>();
BpmProcessInstanceCreateReqDTO bpmProcessInstanceCreateReqDTO = new BpmProcessInstanceCreateReqDTO();
bpmProcessInstanceCreateReqDTO.setProcessDefinitionKey(PROCESS_KEY);
bpmProcessInstanceCreateReqDTO.setBusinessKey(id);
bpmProcessInstanceCreateReqDTO.setStartUserSelectAssignees(supervisionDevMainReportParam.getStartUserSelectAssignees());
bpmProcessInstanceCreateReqDTO.setVariables(processInstanceVariables);
String processInstanceId = bpmProcessFeignClient.createProcessInstance(supervisionDevMainReportPO.getCreateBy(),bpmProcessInstanceCreateReqDTO).getData();
// 将工作流的编号,更新到流程单中
supervisionDevMainReportPO.setProcessInstanceId(processInstanceId);
this.baseMapper.updateById(supervisionDevMainReportPO);
return id;
}
@Override
public boolean auditDevReport(SupervisionDevMainReportParam.SupervisionDevMainReportParamUpdate supervisionDevMainReportParamUpdate) {
return true;
}
@Override
public Boolean removeDevReport(List<String> ids) {
// this.lambdaUpdate().set(SupervisionDevMainReportPO::getState,)
return true;
}
/**
* @Description: 判断干扰源用户是否绑定设备,如果重复则提示干扰源用户已经设备
* @Param: supervisionDevMainReportParam终端详情 isExcludeSelf是否排除自己一般新增不排除更新时需要排除自己
* @return: void
* @Author: clam
* @Date: 2024/5/11
*/
private void checkUserId(SupervisionDevMainReportParam supervisionDevMainReportParam, boolean isExcludeSelf) {
LambdaQueryWrapper<SupervisionDevMainReportPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper
.eq(SupervisionDevMainReportPO::getUserId, supervisionDevMainReportParam.getUserId())
.eq(SupervisionDevMainReportPO::getState, DataStateEnum.ENABLE.getCode());
//更新的时候,需排除当前记录
if (isExcludeSelf) {
lambdaQueryWrapper.ne(SupervisionDevMainReportPO::getId, supervisionDevMainReportParam.getId());
}
List<SupervisionDevMainReportPO> list = this.baseMapper.selectList(lambdaQueryWrapper);
if (CollectionUtil.isNotEmpty(list)) {
//过滤已取消的申请
list = list.stream()
.filter(userReportPO -> !userReportPO.getStatus().equals(FlowStatusEnum.CANCEL.getCode()))
.collect(Collectors.toList());
//如果还存在,则说明有人申请过了
if (CollectionUtil.isNotEmpty(list)) {
throw new BusinessException(supervisionDevMainReportParam.getUserName().concat(",扰源用户").concat(list.get(0).getReporter()).concat("绑定"));
}
}
}
}

View File

@@ -0,0 +1,21 @@
package com.njcn.supervision.service.dev.impl;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.supervision.mapper.dev.SupervisionTempDeviceReportMapper;
import com.njcn.supervision.pojo.po.dev.SupervisionTempDeviceReport;
import com.njcn.supervision.service.dev.SupervisionTempDeviceReportService;
/**
*
* Description:
* Date: 2024/5/11 14:07【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Service
public class SupervisionTempDeviceReportServiceImpl extends ServiceImpl<SupervisionTempDeviceReportMapper, SupervisionTempDeviceReport> implements SupervisionTempDeviceReportService{
}

View File

@@ -0,0 +1,21 @@
package com.njcn.supervision.service.dev.impl;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.supervision.mapper.dev.SupervisionTempLineReportMapper;
import com.njcn.supervision.pojo.po.dev.SupervisionTempLineReport;
import com.njcn.supervision.service.dev.SupervisionTempLineReportService;
/**
*
* Description:
* Date: 2024/5/11 14:07【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Service
public class SupervisionTempLineReportServiceImpl extends ServiceImpl<SupervisionTempLineReportMapper, SupervisionTempLineReport> implements SupervisionTempLineReportService{
}

View File

@@ -121,27 +121,37 @@ public class UserReportPOServiceImpl extends ServiceImpl<UserReportPOMapper, Use
@Override
public boolean auditUserReport(UserReportParam.UserReportUpdate userReportUpdate) {
//判断工程名称是否有重复的
checkProjectName(userReportUpdate, true);
String id = userReportUpdate.getId();
UserReportPO byId = this.getById(id);
BeanUtils.copyProperties(userReportUpdate, byId);
this.updateById(byId);
if (Objects.equals(userReportUpdate.getUserType(), "1") ||
Objects.equals(userReportUpdate.getUserType(), "2")) {
if (CollectionUtil.newArrayList(
UserNatureEnum.BUILD_POWER_GRID.getCode(),
UserNatureEnum.EXTEND_POWER_GRID.getCode()
).contains(byId.getUserType())) {
//电网工程类用户额外数据
UserReportProjectPO userReportProjectPO = userReportProjectPOService.getById(id);
BeanUtils.copyProperties(userReportUpdate.getUserReportProjectPO(), userReportProjectPO, getNullPropertyNames(userReportUpdate.getUserReportProjectPO()));
userReportProjectPOService.updateById(userReportProjectPO);
} else if (Objects.equals(userReportUpdate.getUserType(), "3") ||
Objects.equals(userReportUpdate.getUserType(), "4")) {
} else if ( CollectionUtil.newArrayList(
UserNatureEnum.BUILD_NON_LINEAR_LOAD.getCode(),
UserNatureEnum.EXTEND_NON_LINEAR_LOAD.getCode(),
UserNatureEnum.BUILD_NEW_ENERGY_POWER_STATION.getCode(),
UserNatureEnum.EXTEND_NEW_ENERGY_POWER_STATION.getCode()
).contains(byId.getUserType())) {
UserReportSubstationPO userReportSubstationPO = userReportSubstationPOService.getById(id);
BeanUtils.copyProperties(userReportUpdate.getUserReportSubstationPO(), userReportSubstationPO, getNullPropertyNames(userReportUpdate.getUserReportSubstationPO()));
userReportSubstationPOService.updateById(userReportSubstationPO);
} else if (Objects.equals(userReportUpdate.getUserType(), "5")) {
} else if (UserNatureEnum.SENSITIVE_USER.getCode().equals(byId.getUserType())) {
UserReportSensitivePO userReportSensitivePO = userReportSensitivePOService.getById(id);
BeanUtils.copyProperties(userReportUpdate.getUserReportSensitivePO(), userReportSensitivePO, getNullPropertyNames(userReportUpdate.getUserReportSensitivePO()));
userReportSensitivePOService.updateById(userReportSensitivePO);
}
return false;
return true;
}
/**