Commit 827c2930 authored by wujiang's avatar wujiang

电站管理添加筛选

parent 6779394b
...@@ -33,6 +33,9 @@ public class PowerStationDto extends BaseDto { ...@@ -33,6 +33,9 @@ public class PowerStationDto extends BaseDto {
@ApiModelProperty(value = "服务代理商") @ApiModelProperty(value = "服务代理商")
private String serviceAgent; private String serviceAgent;
@ApiModelProperty(value = "区域公司")
private String regionalCompaniesName;
@ApiModelProperty(value = "电站类型") @ApiModelProperty(value = "电站类型")
private String powerStationType; private String powerStationType;
......
...@@ -19,5 +19,6 @@ public interface PowerStationMapper extends BaseMapper<PowerStation> { ...@@ -19,5 +19,6 @@ public interface PowerStationMapper extends BaseMapper<PowerStation> {
@UserEmpower(field ={"regional_companies_code"} ,dealerField={"a.developer_code","a.regional_companies_code","a.developer_user_id"} ,fieldConditions ={"in","in","in"}, relationship="and") @UserEmpower(field ={"regional_companies_code"} ,dealerField={"a.developer_code","a.regional_companies_code","a.developer_user_id"} ,fieldConditions ={"in","in","in"}, relationship="and")
List<PowerStationDto> queryPage(@Param("powerStationCode") String powerStationCode, List<PowerStationDto> queryPage(@Param("powerStationCode") String powerStationCode,
@Param("ownersName")String ownersName, @Param("ownersName")String ownersName,
@Param("serviceAgent")String serviceAgent); @Param("serviceAgent")String serviceAgent,
@Param("regionalCompaniesName")String regionalCompaniesName);
} }
...@@ -100,12 +100,14 @@ public class PowerStationController extends BaseController { ...@@ -100,12 +100,14 @@ public class PowerStationController extends BaseController {
public ResponseModel<Page<PowerStationDto>> queryForPage(@RequestParam(value = "current") int current, public ResponseModel<Page<PowerStationDto>> queryForPage(@RequestParam(value = "current") int current,
@RequestParam(value = "size") int size, @RequestParam(value = "size") int size,
@RequestParam(value = "powerStationCode",required = false)String powerStationCode, @RequestParam(value = "powerStationCode",required = false)String powerStationCode,
@RequestParam(value = "ownersName",required = false)String ownersName) { @RequestParam(value = "ownersName",required = false)String ownersName,
@RequestParam(value = "serviceAgent",required = false)String serviceAgent,
@RequestParam(value = "regionalCompaniesName",required = false)String regionalCompaniesName) {
Page<PowerStationDto> page = new Page<PowerStationDto>(); Page<PowerStationDto> page = new Page<PowerStationDto>();
page.setCurrent(current); page.setCurrent(current);
page.setSize(size); page.setSize(size);
AgencyUserModel userInfo = getUserInfo(); AgencyUserModel userInfo = getUserInfo();
return ResponseHelper.buildResponse(powerStationServiceImpl.queryForPowerStationUserRoles(page,powerStationCode,ownersName,userInfo)); return ResponseHelper.buildResponse(powerStationServiceImpl.queryForPowerStationUserRoles(page,powerStationCode,ownersName,userInfo,serviceAgent,regionalCompaniesName));
} }
/** /**
......
...@@ -25,6 +25,7 @@ import org.apache.poi.ss.formula.functions.T; ...@@ -25,6 +25,7 @@ import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestParam;
import org.typroject.tyboot.component.emq.EmqKeeper; import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.core.foundation.exception.BaseException; import org.typroject.tyboot.core.foundation.exception.BaseException;
import org.typroject.tyboot.core.rdbms.annotation.Condition; import org.typroject.tyboot.core.rdbms.annotation.Condition;
...@@ -45,7 +46,8 @@ import java.util.stream.Collectors; ...@@ -45,7 +46,8 @@ import java.util.stream.Collectors;
*/ */
@Service @Service
@Slf4j @Slf4j
public class PowerStationServiceImpl extends BaseService<PowerStationDto, PowerStation, PowerStationMapper> implements IPowerStationService { public class PowerStationServiceImpl extends BaseService<PowerStationDto, PowerStation, PowerStationMapper>
implements IPowerStationService {
@Autowired @Autowired
IdxFeginService idxFeginService; IdxFeginService idxFeginService;
...@@ -59,9 +61,9 @@ public class PowerStationServiceImpl extends BaseService<PowerStationDto, PowerS ...@@ -59,9 +61,9 @@ public class PowerStationServiceImpl extends BaseService<PowerStationDto, PowerS
@Autowired @Autowired
PeasantHouseholdServiceImpl peasantHouseholdService; PeasantHouseholdServiceImpl peasantHouseholdService;
private static final String IDX_REQUEST_STATE="200"; private static final String IDX_REQUEST_STATE = "200";
private static final String VERIFY_RESULT_YES="0"; private static final String VERIFY_RESULT_YES = "0";
private static final String VERIFY_RESULT_NO="1"; private static final String VERIFY_RESULT_NO = "1";
@Autowired @Autowired
WorkflowFeignClient workflowFeignClient; WorkflowFeignClient workflowFeignClient;
...@@ -84,8 +86,8 @@ public class PowerStationServiceImpl extends BaseService<PowerStationDto, PowerS ...@@ -84,8 +86,8 @@ public class PowerStationServiceImpl extends BaseService<PowerStationDto, PowerS
@Autowired @Autowired
WorkflowImpl workflow; WorkflowImpl workflow;
public Page<PowerStationDto> queryForPowerStationUserRoles(Page<PowerStationDto> page, String powerStationCode, String ownersName, AgencyUserModel userInfo){ public Page<PowerStationDto> queryForPowerStationUserRoles(Page<PowerStationDto> page, String powerStationCode,
String serviceAgent =null; String ownersName, AgencyUserModel userInfo, String serviceAgent, String regionalCompaniesName) {
// Map<Long, List<RoleModel>> orgRoles = userInfo.getOrgRoles(); // Map<Long, List<RoleModel>> orgRoles = userInfo.getOrgRoles();
// Collection<List<RoleModel>> roleModels = orgRoles.values(); // Collection<List<RoleModel>> roleModels = orgRoles.values();
// if(roleModels !=null){ // if(roleModels !=null){
...@@ -100,25 +102,25 @@ public class PowerStationServiceImpl extends BaseService<PowerStationDto, PowerS ...@@ -100,25 +102,25 @@ public class PowerStationServiceImpl extends BaseService<PowerStationDto, PowerS
// } // }
// } // }
//获取用户所在经销商单位 // 获取用户所在经销商单位
// UserUnitInformationDto userUnitInformationDto=personnelBusinessMapper.getUserUnitInformationDto(userInfo.getUserId()); // UserUnitInformationDto userUnitInformationDto=personnelBusinessMapper.getUserUnitInformationDto(userInfo.getUserId());
// //
// if(userUnitInformationDto!=null&&userUnitInformationDto.getAmosDealerName()!=null){ // if(userUnitInformationDto!=null&&userUnitInformationDto.getAmosDealerName()!=null){
// serviceAgent=userUnitInformationDto.getAmosDealerName(); // serviceAgent=userUnitInformationDto.getAmosDealerName();
// } // }
//return this.queryForPowerStationPage(page,powerStationCode,ownersName,serviceAgent); // return
return this.queryPage((int) page.getCurrent(), (int) page.getSize(),powerStationCode,ownersName,serviceAgent); // this.queryForPowerStationPage(page,powerStationCode,ownersName,serviceAgent);
return this.queryPage((int) page.getCurrent(), (int) page.getSize(), powerStationCode, ownersName,
serviceAgent,regionalCompaniesName);
} }
//查询电站审核记录 // 查询电站审核记录
public Page<PowerStationDto> queryPage(int current, int size, public Page<PowerStationDto> queryPage(int current, int size, String powerStationCode, String ownersName,
String powerStationCode, String serviceAgent,String regionalCompaniesName) {
String ownersName,String serviceAgent) {
PageHelper.startPage(current, size); PageHelper.startPage(current, size);
List<PowerStationDto> list= powerStationMapper.queryPage(powerStationCode,ownersName,serviceAgent); List<PowerStationDto> list = powerStationMapper.queryPage(powerStationCode, ownersName, serviceAgent,regionalCompaniesName);
PageInfo<PowerStationDto> pages = new PageInfo(list); PageInfo<PowerStationDto> pages = new PageInfo(list);
com.baomidou.mybatisplus.extension.plugins.pagination.Page<PowerStationDto> pagenew = new com.baomidou.mybatisplus.extension.plugins.pagination.Page<PowerStationDto>(); com.baomidou.mybatisplus.extension.plugins.pagination.Page<PowerStationDto> pagenew = new com.baomidou.mybatisplus.extension.plugins.pagination.Page<PowerStationDto>();
...@@ -130,28 +132,27 @@ public class PowerStationServiceImpl extends BaseService<PowerStationDto, PowerS ...@@ -130,28 +132,27 @@ public class PowerStationServiceImpl extends BaseService<PowerStationDto, PowerS
return pagenew; return pagenew;
} }
/** /**
* 分页查询 * 分页查询
*/ */
public Page<PowerStationDto> queryForPowerStationPage(Page<PowerStationDto> page,@Condition(Operator.like) String powerStationCode,@Condition(Operator.like) String ownersName,String serviceAgent) { public Page<PowerStationDto> queryForPowerStationPage(Page<PowerStationDto> page,
return this.queryForPage(page, "rec_date", false,powerStationCode,ownersName,serviceAgent); @Condition(Operator.like) String powerStationCode, @Condition(Operator.like) String ownersName,
String serviceAgent) {
return this.queryForPage(page, "rec_date", false, powerStationCode, ownersName, serviceAgent);
} }
/** /**
* 列表查询 示例 * 列表查询 示例
*/ */
public List<PowerStationDto> queryForPowerStationList() { public List<PowerStationDto> queryForPowerStationList() {
return this.queryForList("" , false); return this.queryForList("", false);
} }
@Override @Override
@Transactional @Transactional
public boolean savePowerStation(PowerStation powerStation, boolean flag,String name,String meg) { public boolean savePowerStation(PowerStation powerStation, boolean flag, String name, String meg) {
try{ try {
//流程节点code // 流程节点code
// if (flag) { // if (flag) {
// String flowTaskIdnext = this.getTaskNoAuth(powerStation.getProcessInstanceId()); // String flowTaskIdnext = this.getTaskNoAuth(powerStation.getProcessInstanceId());
// WorkDto workDto=this.getNodeInfoCode(flowTaskIdnext); // WorkDto workDto=this.getNodeInfoCode(flowTaskIdnext);
...@@ -162,50 +163,60 @@ public class PowerStationServiceImpl extends BaseService<PowerStationDto, PowerS ...@@ -162,50 +163,60 @@ public class PowerStationServiceImpl extends BaseService<PowerStationDto, PowerS
powerStation.setRecDate(new Date()); powerStation.setRecDate(new Date());
Boolean fl= this.saveOrUpdate(powerStation); Boolean fl = this.saveOrUpdate(powerStation);
PowerStationNodeEnum powerStationNodeEnum= PowerStationNodeEnum.getNodeByCode(powerStation.getNextProcessNode()); PowerStationNodeEnum powerStationNodeEnum = PowerStationNodeEnum
.getNodeByCode(powerStation.getNextProcessNode());
if (flag){
if (flag) {
ToDoTasks toDoTasks=null;
if(PowerStationNodeEnum.经销商上传图纸.getCode().equals(powerStationNodeEnum.getCode())||PowerStationNodeEnum.经销商审核.getCode().equals(powerStationNodeEnum.getCode())){ ToDoTasks toDoTasks = null;
//获取经销商orgcode if (PowerStationNodeEnum.经销商上传图纸.getCode().equals(powerStationNodeEnum.getCode())
PeasantHousehold peasantHouseholdd= peasantHouseholdService.getById(powerStation.getPeasantHouseholdId()); || PowerStationNodeEnum.经销商审核.getCode().equals(powerStationNodeEnum.getCode())) {
toDoTasks= new ToDoTasks ( TaskTypeStationEnum.电站审核.getCode(), powerStation.getSequenceNbr(), "用户"+name+"电站勘察待"+powerStationNodeEnum.getName(),peasantHouseholdd.getDeveloperCode()); // 获取经销商orgcode
if(PowerStationNodeEnum.经销商审核.getCode().equals(powerStationNodeEnum.getCode())){ PeasantHousehold peasantHouseholdd = peasantHouseholdService
toDoTasksServiceImpl.addToDoTasksByUserId(peasantHouseholdd.getDeveloperUserId(),toDoTasks,meg); .getById(powerStation.getPeasantHouseholdId());
}else{ toDoTasks = new ToDoTasks(TaskTypeStationEnum.电站审核.getCode(), powerStation.getSequenceNbr(),
toDoTasksServiceImpl.addToDoTasksByRole(powerStation.getNodeRole(),toDoTasks,meg); "用户" + name + "电站勘察待" + powerStationNodeEnum.getName(),
peasantHouseholdd.getDeveloperCode());
if (PowerStationNodeEnum.经销商审核.getCode().equals(powerStationNodeEnum.getCode())) {
toDoTasksServiceImpl.addToDoTasksByUserId(peasantHouseholdd.getDeveloperUserId(), toDoTasks,
meg);
} else {
toDoTasksServiceImpl.addToDoTasksByRole(powerStation.getNodeRole(), toDoTasks, meg);
} }
}else{ } else {
toDoTasks= new ToDoTasks ( TaskTypeStationEnum.电站审核.getCode(), powerStation.getSequenceNbr(), "用户"+name+"电站勘察待"+powerStationNodeEnum.getName(),null); toDoTasks = new ToDoTasks(TaskTypeStationEnum.电站审核.getCode(), powerStation.getSequenceNbr(),
toDoTasksServiceImpl.addToDoTasksByRole(powerStation.getNodeRole(),toDoTasks,meg); "用户" + name + "电站勘察待" + powerStationNodeEnum.getName(), null);
toDoTasksServiceImpl.addToDoTasksByRole(powerStation.getNodeRole(), toDoTasks, meg);
} }
}else{ } else {
LambdaQueryWrapper<ToDoTasks> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<ToDoTasks> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(ToDoTasks::getType, TaskTypeStationEnum.电站审核.getCode()); wrapper.eq(ToDoTasks::getType, TaskTypeStationEnum.电站审核.getCode());
wrapper.eq(ToDoTasks::getState, "待办"); wrapper.eq(ToDoTasks::getState, "待办");
wrapper.eq(ToDoTasks::getBusinessId, powerStation.getSequenceNbr()); wrapper.eq(ToDoTasks::getBusinessId, powerStation.getSequenceNbr());
ToDoTasks doTasks= toDoTasksMapper.selectOne(wrapper); ToDoTasks doTasks = toDoTasksMapper.selectOne(wrapper);
if(doTasks!=null){ if (doTasks != null) {
doTasks.setState("已办"); doTasks.setState("已办");
doTasks.setCompleteTime(new Date()); doTasks.setCompleteTime(new Date());
toDoTasksMapper.updateById(doTasks); toDoTasksMapper.updateById(doTasks);
emqKeeper.getMqttClient().publish("TASK_MESSAGE" ,JSON.toJSONString(doTasks).getBytes(), 2 ,false); emqKeeper.getMqttClient().publish("TASK_MESSAGE", JSON.toJSONString(doTasks).getBytes(), 2, false);
UserMessage userMessage= new UserMessage( doTasks.getType(), doTasks.getBusinessId(), doTasks.getAmosUserId(), new Date(), doTasks.getTaskName()+"已完成."+meg, doTasks.getAmosOrgCode()); UserMessage userMessage = new UserMessage(doTasks.getType(), doTasks.getBusinessId(),
doTasks.getAmosUserId(), new Date(), doTasks.getTaskName() + "已完成." + meg,
doTasks.getAmosOrgCode());
userMessageMapper.insert(userMessage); userMessageMapper.insert(userMessage);
emqKeeper.getMqttClient().publish("MY_MESSAGE" , JSON.toJSONString(userMessage).getBytes(), 2 ,false); emqKeeper.getMqttClient().publish("MY_MESSAGE", JSON.toJSONString(userMessage).getBytes(), 2,
false);
} }
} }
return fl; return fl;
}catch (Exception e){ } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
throw new BaseException("获取工作流节点失败!","400","获取工作流节点失败!"); throw new BaseException("获取工作流节点失败!", "400", "获取工作流节点失败!");
} }
} }
...@@ -219,18 +230,20 @@ public class PowerStationServiceImpl extends BaseService<PowerStationDto, PowerS ...@@ -219,18 +230,20 @@ public class PowerStationServiceImpl extends BaseService<PowerStationDto, PowerS
@Override @Override
@Transactional @Transactional
public String powerStationExamine(long pageId, String nodeCode, String stationId, String taskId, String planInstanceId, Map<String, Object> kv) { public String powerStationExamine(long pageId, String nodeCode, String stationId, String taskId,
String meg=""; String planInstanceId, Map<String, Object> kv) {
String meg = "";
// 1. 业务相关数据落表 // 1. 业务相关数据落表
PowerStation powerStation = this.baseMapper.selectById(stationId); PowerStation powerStation = this.baseMapper.selectById(stationId);
PowerStationNodeEnum nodeByCode = PowerStationNodeEnum.getNodeByCode(nodeCode); PowerStationNodeEnum nodeByCode = PowerStationNodeEnum.getNodeByCode(nodeCode);
String result = String.valueOf(kv.get("approvalStatus")); String result = String.valueOf(kv.get("approvalStatus"));
boolean flag = true; boolean flag = true;
if (PowerStationNodeEnum.设计上传图纸.getCode().equals(nodeCode)||PowerStationNodeEnum.经销商上传图纸.getCode().equals(nodeCode)) { if (PowerStationNodeEnum.设计上传图纸.getCode().equals(nodeCode)
|| PowerStationNodeEnum.经销商上传图纸.getCode().equals(nodeCode)) {
powerStation.setProcessStatus(PowerStationProcessStateEnum.进行中.getName()); powerStation.setProcessStatus(PowerStationProcessStateEnum.进行中.getName());
this.updateSeve(nodeCode,powerStation.getPeasantHouseholdId(),kv); this.updateSeve(nodeCode, powerStation.getPeasantHouseholdId(), kv);
} else { } else {
if (VERIFY_RESULT_NO.equals(result)) { if (VERIFY_RESULT_NO.equals(result)) {
...@@ -266,12 +279,13 @@ public class PowerStationServiceImpl extends BaseService<PowerStationDto, PowerS ...@@ -266,12 +279,13 @@ public class PowerStationServiceImpl extends BaseService<PowerStationDto, PowerS
break; break;
} }
} }
meg="任务明细:"+nodeByCode+(VERIFY_RESULT_YES.equals(result)?"通过":"不通过"); meg = "任务明细:" + nodeByCode + (VERIFY_RESULT_YES.equals(result) ? "通过" : "不通过");
// 2. 更新流程状态 // 2. 更新流程状态
String code = null; String code = null;
try{ try {
// 3. 工作流执行 // 3. 工作流执行
// FeignClientResult<String> submit = idxFeginService.submit(pageId, taskId, planInstanceId, null, null, null, kv); // FeignClientResult<String> submit = idxFeginService.submit(pageId, taskId,
// planInstanceId, null, null, null, kv);
// if (IDX_REQUEST_STATE.equals(String.valueOf(submit.getStatus()))) { // if (IDX_REQUEST_STATE.equals(String.valueOf(submit.getStatus()))) {
// code = submit.getResult(); // code = submit.getResult();
// log.info("流程执行成功:{}", code); // log.info("流程执行成功:{}", code);
...@@ -283,64 +297,63 @@ public class PowerStationServiceImpl extends BaseService<PowerStationDto, PowerS ...@@ -283,64 +297,63 @@ public class PowerStationServiceImpl extends BaseService<PowerStationDto, PowerS
// //
// } // }
// 执行工作流
//执行工作流 BasicGridAcceptance basicGridAcceptance = new BasicGridAcceptance();
BasicGridAcceptance basicGridAcceptance=new BasicGridAcceptance();
StandardDto standardDto = new StandardDto(); StandardDto standardDto = new StandardDto();
if (PowerStationNodeEnum.设计上传图纸.getCode().equals(nodeCode)||PowerStationNodeEnum.经销商上传图纸.getCode().equals(nodeCode)) { if (PowerStationNodeEnum.设计上传图纸.getCode().equals(nodeCode)
|| PowerStationNodeEnum.经销商上传图纸.getCode().equals(nodeCode)) {
standardDto.setComment(kv.get("approvalInfo")!=null?String.valueOf(kv.get("approvalInfo")):""); standardDto.setComment(kv.get("approvalInfo") != null ? String.valueOf(kv.get("approvalInfo")) : "");
standardDto.setResult("0"); standardDto.setResult("0");
standardDto.setTaskId(powerStation.getFlowTaskId()); standardDto.setTaskId(powerStation.getFlowTaskId());
VariableDto variable = new VariableDto(); VariableDto variable = new VariableDto();
variable.setApprovalStatus("0"); variable.setApprovalStatus("0");
variable.setComment(kv.get("approvalInfo")!=null?String.valueOf(kv.get("approvalInfo")):""); variable.setComment(kv.get("approvalInfo") != null ? String.valueOf(kv.get("approvalInfo")) : "");
variable.setOperationTime(String.valueOf(kv.get("approveDate"))); variable.setOperationTime(String.valueOf(kv.get("approveDate")));
variable.setOperator(""); variable.setOperator("");
standardDto.setVariable(variable); standardDto.setVariable(variable);
}else{ } else {
standardDto.setComment(kv.get("approvalInfo")!=null?String.valueOf(kv.get("approvalInfo")):""); standardDto.setComment(kv.get("approvalInfo") != null ? String.valueOf(kv.get("approvalInfo")) : "");
standardDto.setResult(String.valueOf(kv.get("approvalStatus"))); standardDto.setResult(String.valueOf(kv.get("approvalStatus")));
standardDto.setTaskId(powerStation.getFlowTaskId()); standardDto.setTaskId(powerStation.getFlowTaskId());
VariableDto variable = new VariableDto(); VariableDto variable = new VariableDto();
variable.setApprovalStatus(String.valueOf(kv.get("approvalStatus"))); variable.setApprovalStatus(String.valueOf(kv.get("approvalStatus")));
variable.setComment(kv.get("approvalInfo")!=null?String.valueOf(kv.get("approvalInfo")):""); variable.setComment(kv.get("approvalInfo") != null ? String.valueOf(kv.get("approvalInfo")) : "");
variable.setOperationTime(String.valueOf(kv.get("approveDate"))); variable.setOperationTime(String.valueOf(kv.get("approveDate")));
variable.setOperator(String.valueOf(kv.get("approveName"))); variable.setOperator(String.valueOf(kv.get("approveName")));
standardDto.setVariable(variable); standardDto.setVariable(variable);
} }
BasicGridAcceptance workBasicGridAcceptance = workflow.standard(basicGridAcceptance, standardDto,
BasicGridAcceptance workBasicGridAcceptance = workflow.standard(basicGridAcceptance, standardDto, requestContext.getUserId()); requestContext.getUserId());
powerStation.setFlowTaskId(basicGridAcceptance.getNextTaskId()); powerStation.setFlowTaskId(basicGridAcceptance.getNextTaskId());
powerStation.setNodeRole(basicGridAcceptance.getNextExecutorIds()); powerStation.setNodeRole(basicGridAcceptance.getNextExecutorIds());
powerStation.setNodeRouting(basicGridAcceptance.getNextNodeKey()!=null?PowerStationEnum.getNodeByKey(basicGridAcceptance.getNextNodeKey()):""); powerStation.setNodeRouting(basicGridAcceptance.getNextNodeKey() != null
? PowerStationEnum.getNodeByKey(basicGridAcceptance.getNextNodeKey())
: "");
powerStation.setNextProcessNode(basicGridAcceptance.getNextNodeKey()); powerStation.setNextProcessNode(basicGridAcceptance.getNextNodeKey());
powerStation.setPromoter(basicGridAcceptance.getPromoter()); powerStation.setPromoter(basicGridAcceptance.getPromoter());
powerStation.setNextExecuteUserIds(basicGridAcceptance.getNextExecuteUserIds()); powerStation.setNextExecuteUserIds(basicGridAcceptance.getNextExecuteUserIds());
powerStation.setNextNodeName(basicGridAcceptance.getNextNodeName()); powerStation.setNextNodeName(basicGridAcceptance.getNextNodeName());
powerStationService.savePowerStation(powerStation, flag,powerStation.getOwnersName(),meg); powerStationService.savePowerStation(powerStation, flag, powerStation.getOwnersName(), meg);
if(!flag){ if (!flag) {
//更新农户状态 // 更新农户状态
String peasantHouseholdId = powerStation.getPeasantHouseholdId(); String peasantHouseholdId = powerStation.getPeasantHouseholdId();
PeasantHousehold peasantHousehold = peasantHouseholdService.getBaseMapper().selectById(Long.valueOf(peasantHouseholdId)); PeasantHousehold peasantHousehold = peasantHouseholdService.getBaseMapper()
.selectById(Long.valueOf(peasantHouseholdId));
peasantHousehold.setSurveyOrNot(3); peasantHousehold.setSurveyOrNot(3);
peasantHousehold.setConstructionState(ArrivalStateeEnum.勘察完成.getCode()); peasantHousehold.setConstructionState(ArrivalStateeEnum.勘察完成.getCode());
peasantHouseholdService.saveOrUpdate(peasantHousehold); peasantHouseholdService.saveOrUpdate(peasantHousehold);
} }
//} // }
}catch (Exception e){ } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
throw new BaseException("获取工作流节点失败!","400","获取工作流节点失败!"); throw new BaseException("获取工作流节点失败!", "400", "获取工作流节点失败!");
} }
return code; return code;
// String meg=""; // String meg="";
// // 1. 业务相关数据落表 // // 1. 业务相关数据落表
// PowerStation powerStation = this.baseMapper.selectById(stationId); // PowerStation powerStation = this.baseMapper.selectById(stationId);
...@@ -419,68 +432,67 @@ public class PowerStationServiceImpl extends BaseService<PowerStationDto, PowerS ...@@ -419,68 +432,67 @@ public class PowerStationServiceImpl extends BaseService<PowerStationDto, PowerS
// return code; // return code;
} }
public WorkDto getNodeInfoCode(String flowTaskId) {
public WorkDto getNodeInfoCode(String flowTaskId){ WorkDto workDto = null;
WorkDto workDto=null; try {
try{ FeignClientResult<JSONObject> jSONObject = workflowFeignClient.getNodeInfo(flowTaskId);
FeignClientResult<JSONObject> jSONObject= workflowFeignClient.getNodeInfo(flowTaskId); if (IDX_REQUEST_STATE.equals(String.valueOf(jSONObject.getStatus()))) {
if(IDX_REQUEST_STATE.equals(String.valueOf(jSONObject.getStatus()))){ JSONObject js = jSONObject.getResult();
JSONObject js=jSONObject.getResult(); if (js == null) {
if(js==null){ throw new BaseException("获取工作流节点失败!", "400", "获取工作流节点失败!");
throw new BaseException("获取工作流节点失败!","400","获取工作流节点失败!");
} }
LinkedHashMap taskInfo= js.get("taskInfo")!=null?(LinkedHashMap)js.get("taskInfo"):null; LinkedHashMap taskInfo = js.get("taskInfo") != null ? (LinkedHashMap) js.get("taskInfo") : null;
String nextProcessNode=taskInfo!=null?taskInfo.get("taskDefinitionKey").toString():null; String nextProcessNode = taskInfo != null ? taskInfo.get("taskDefinitionKey").toString() : null;
List<LinkedHashMap> executor= js.get("executor")!=null?( List<LinkedHashMap>)js.get("executor"):null; List<LinkedHashMap> executor = js.get("executor") != null ? (List<LinkedHashMap>) js.get("executor")
String nodeRole=null; : null;
if(!executor.isEmpty()){ String nodeRole = null;
List<String> idList = executor.stream().map(e->e.get("groupId").toString()).collect(Collectors.toList()); if (!executor.isEmpty()) {
nodeRole=StringUtils.join(idList,","); List<String> idList = executor.stream().map(e -> e.get("groupId").toString())
.collect(Collectors.toList());
nodeRole = StringUtils.join(idList, ",");
} }
LinkedHashMap extensionInfo= js.get("extensionInfo")!=null?(LinkedHashMap)js.get("extensionInfo"):null; LinkedHashMap extensionInfo = js.get("extensionInfo") != null ? (LinkedHashMap) js.get("extensionInfo")
String nodeRouting=extensionInfo!=null?extensionInfo.get("nodeRole").toString():null; : null;
workDto=new WorkDto(nodeRouting, nodeRole, nextProcessNode); String nodeRouting = extensionInfo != null ? extensionInfo.get("nodeRole").toString() : null;
workDto = new WorkDto(nodeRouting, nodeRole, nextProcessNode);
} }
return workDto; return workDto;
}catch (Exception e){ } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
throw new BaseException("获取工作流节点失败!","400","获取工作流节点失败!"); throw new BaseException("获取工作流节点失败!", "400", "获取工作流节点失败!");
} }
} }
public String getTaskNoAuth(String processInstanceId){ public String getTaskNoAuth(String processInstanceId) {
String flowTaskId=null; String flowTaskId = null;
try{ try {
JSONObject jSONObject= workflowFeignClient.getTaskNoAuth(processInstanceId); JSONObject jSONObject = workflowFeignClient.getTaskNoAuth(processInstanceId);
if(IDX_REQUEST_STATE.equals(String.valueOf(jSONObject.get("code")))){ if (IDX_REQUEST_STATE.equals(String.valueOf(jSONObject.get("code")))) {
LinkedHashMap jsd= jSONObject.get("data")!=null?(LinkedHashMap)jSONObject.get("data"):null; LinkedHashMap jsd = jSONObject.get("data") != null ? (LinkedHashMap) jSONObject.get("data") : null;
flowTaskId=jsd!=null?jsd.get("id").toString():null; flowTaskId = jsd != null ? jsd.get("id").toString() : null;
} }
if(flowTaskId==null){ if (flowTaskId == null) {
throw new BaseException("获取工作流节点失败!","400","获取工作流节点失败!"); throw new BaseException("获取工作流节点失败!", "400", "获取工作流节点失败!");
} }
return flowTaskId; return flowTaskId;
}catch (Exception e){ } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
throw new BaseException("获取工作流节点失败!","400","获取工作流节点失败!"); throw new BaseException("获取工作流节点失败!", "400", "获取工作流节点失败!");
} }
} }
// 设计信息填充 // 设计信息填充
public void updateSeve(String nodeCode, String peasantHouseholdId, Map<String, Object> kv) {
public void updateSeve(String nodeCode,String peasantHouseholdId, Map<String, Object> kv ){
LambdaQueryWrapper<DesignInformation> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<DesignInformation> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(DesignInformation::getPeasantHouseholdId, peasantHouseholdId); wrapper.eq(DesignInformation::getPeasantHouseholdId, peasantHouseholdId);
DesignInformation designInformation=designInformationMapper.selectOne(wrapper); DesignInformation designInformation = designInformationMapper.selectOne(wrapper);
if(designInformation!=null){ if (designInformation != null) {
DesignInformation designInformationnew=this.mapToBean(kv,DesignInformation.class); DesignInformation designInformationnew = this.mapToBean(kv, DesignInformation.class);
if (PowerStationNodeEnum.经销商上传图纸.getCode().equals(nodeCode)) { if (PowerStationNodeEnum.经销商上传图纸.getCode().equals(nodeCode)) {
designInformation.setPeasantHouseholdId(peasantHouseholdId); designInformation.setPeasantHouseholdId(peasantHouseholdId);
...@@ -489,7 +501,7 @@ public void updateSeve(String nodeCode,String peasantHouseholdId, Map<String, Ob ...@@ -489,7 +501,7 @@ public void updateSeve(String nodeCode,String peasantHouseholdId, Map<String, Ob
designInformation.setConnectionLine(designInformationnew.getConnectionLine()); designInformation.setConnectionLine(designInformationnew.getConnectionLine());
designInformation.setOnceLine(designInformationnew.getOnceLine()); designInformation.setOnceLine(designInformationnew.getOnceLine());
designInformationMapper.updateById(designInformation); designInformationMapper.updateById(designInformation);
}else{ } else {
// designInformationnew.setTypicalDiagram(designInformationnew.getTypicalDiagram()); // designInformationnew.setTypicalDiagram(designInformationnew.getTypicalDiagram());
designInformationnew.setPeasantHouseholdId(peasantHouseholdId); designInformationnew.setPeasantHouseholdId(peasantHouseholdId);
designInformationnew.setComponentLayout(designInformation.getComponentLayout()); designInformationnew.setComponentLayout(designInformation.getComponentLayout());
...@@ -504,32 +516,30 @@ public void updateSeve(String nodeCode,String peasantHouseholdId, Map<String, Ob ...@@ -504,32 +516,30 @@ public void updateSeve(String nodeCode,String peasantHouseholdId, Map<String, Ob
designInformationnew.setCable(designInformation.getCable()); designInformationnew.setCable(designInformation.getCable());
designInformationMapper.updateById(designInformationnew); designInformationMapper.updateById(designInformationnew);
} }
}else{ } else {
DesignInformation designInformationnew=this.mapToBean(kv,DesignInformation.class); DesignInformation designInformationnew = this.mapToBean(kv, DesignInformation.class);
designInformationnew.setTypicalDiagram((List<Object>)kv.get("typicalDiagram")) ; designInformationnew.setTypicalDiagram((List<Object>) kv.get("typicalDiagram"));
designInformationnew.setPeasantHouseholdId(peasantHouseholdId); designInformationnew.setPeasantHouseholdId(peasantHouseholdId);
designInformationMapper.insert(designInformationnew); designInformationMapper.insert(designInformationnew);
} }
} }
public <T> T mapToBean(Map<String, Object> map, Class<T> clazz) { public <T> T mapToBean(Map<String, Object> map, Class<T> clazz) {
ObjectMapper objectMapper= new ObjectMapper(); ObjectMapper objectMapper = new ObjectMapper();
T bean =null; T bean = null;
try { try {
bean = clazz.newInstance(); bean = clazz.newInstance();
bean = objectMapper.convertValue(map,clazz); bean = objectMapper.convertValue(map, clazz);
}catch (Exception e){ } catch (Exception e) {
throw new BaseException(" 数据转化异常!","400","数据转化异常!"); throw new BaseException(" 数据转化异常!", "400", "数据转化异常!");
} }
return bean; return bean;
} }
// private CollectionToList(Collection<? extends E> c){ // private CollectionToList(Collection<? extends E> c){
// Object[] objects = c.toArray(); // Object[] objects = c.toArray();
// } // }
......
...@@ -2,6 +2,7 @@ package com.yeejoin.amos.boot.module.jxiop.biz.controller; ...@@ -2,6 +2,7 @@ package com.yeejoin.amos.boot.module.jxiop.biz.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils; import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.jxiop.biz.Enum.SmartAnalyseEnum;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.FullViewRecallDataDTO; import com.yeejoin.amos.boot.module.jxiop.biz.dto.FullViewRecallDataDTO;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.FullViewRecallInfoDTO; import com.yeejoin.amos.boot.module.jxiop.biz.dto.FullViewRecallInfoDTO;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanHealthLevel; import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanHealthLevel;
...@@ -52,6 +53,44 @@ public class KafkaAnalyseController { ...@@ -52,6 +53,44 @@ public class KafkaAnalyseController {
IdxBizFanHealthIndexMapper idxBizFanHealthIndexMapper; IdxBizFanHealthIndexMapper idxBizFanHealthIndexMapper;
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false) @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "获取执行结果", notes = "获取执行结果")
@GetMapping(value = "/isRun")
public ResponseModel<String> isRun(@RequestParam(required = true) String key) {
String result = "非法key值";
if (kafkaTopicConsumer.equals(key) || kafkaTopicConsumerPv.equals(key) || kafkaTopicConsumerGKHFFan.equals(key)
|| kafkaTopicConsumerGKHFPv.equals(key) || kafkaTopicConsumerZXZFan.equals(key)
|| kafkaTopicConsumerZXZPv.equals(key)) {
if (redisUtils.hasKey(key)) {
result = "正在计算中";
} else {
result = "未计算";
}
}
return ResponseHelper.buildResponse(result);
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "获取执行结果", notes = "获取执行结果")
@GetMapping(value = "/start")
public ResponseModel<Object> start(@RequestParam(required = true) String key) {
String result = "非法key值";
if (kafkaTopicConsumer.equals(key)) {
return getFanConditionVariables();
} else if (kafkaTopicConsumerPv.equals(key)) {
return getPvConditionVariables();
} else if (kafkaTopicConsumerGKHFFan.equals(key)) {
return getFanConditionVariablesGKHF();
} else if (kafkaTopicConsumerGKHFPv.equals(key)) {
return getPvConditionVariablesPvGKFX();
} else if (kafkaTopicConsumerZXZFan.equals(key)) {
return getFanConditionVariablesZXZ();
} else if (kafkaTopicConsumerZXZPv.equals(key)) {
return getPvConditionVariablesZXZ();
}
return ResponseHelper.buildResponse(result);
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@PostMapping(value = "/getFanConditionVariables") @PostMapping(value = "/getFanConditionVariables")
@ApiOperation(httpMethod = "POST", value = "计算相关性分析 - 风机 - 新", notes = "计算相关性分析 - 风机 - 新") @ApiOperation(httpMethod = "POST", value = "计算相关性分析 - 风机 - 新", notes = "计算相关性分析 - 风机 - 新")
public ResponseModel<Object> getFanConditionVariables() { public ResponseModel<Object> getFanConditionVariables() {
...@@ -140,28 +179,35 @@ public class KafkaAnalyseController { ...@@ -140,28 +179,35 @@ public class KafkaAnalyseController {
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY) @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "全景诊断回溯") @ApiOperation(value = "全景诊断回溯")
@GetMapping("/getFullViewRecall") @GetMapping("/getFullViewRecall")
public ResponseModel<List<FullViewRecallInfoDTO>> getFullViewRecall(@RequestParam(required = false, value = "analysisType") String analysisType) { public ResponseModel<List<FullViewRecallInfoDTO>> getFullViewRecall(
@RequestParam(required = false, value = "analysisType") String analysisType) {
List<String> gatewayIds = this.getGatewayIds(); List<String> gatewayIds = this.getGatewayIds();
List<Map<String, Object>> stationIndexInfo = idxBizFanHealthIndexMapper.getStationIndexInfoByParam(analysisType, gatewayIds); List<Map<String, Object>> stationIndexInfo = idxBizFanHealthIndexMapper.getStationIndexInfoByParam(analysisType,
Map<String, Double> stationHealthIndexMap = stationIndexInfo.stream().collect(Collectors.toMap(t -> t.get("station").toString(), t -> Double.parseDouble(t.get("healthIndex").toString()))); gatewayIds);
Map<String, Double> stationHealthIndexMap = stationIndexInfo.stream().collect(Collectors
.toMap(t -> t.get("station").toString(), t -> Double.parseDouble(t.get("healthIndex").toString())));
List<Map<String, Object>> equipmentIndexInfo = idxBizFanHealthIndexMapper.getEquipmentIndexInfoByParam(analysisType, gatewayIds);
Map<String, Double> equipmentIndexInfoMap = equipmentIndexInfo.stream().collect(Collectors.toMap(t -> t.get("equipmentName").toString(), t -> Double.parseDouble(t.get("healthIndex").toString()))); List<Map<String, Object>> equipmentIndexInfo = idxBizFanHealthIndexMapper
.getEquipmentIndexInfoByParam(analysisType, gatewayIds);
Map<String, Double> equipmentIndexInfoMap = equipmentIndexInfo.stream().collect(Collectors.toMap(
List<Map<String, Object>> subSystemIndexInfo = idxBizFanHealthIndexMapper.getSubSystemIndexInfoByParam(analysisType, gatewayIds); t -> t.get("equipmentName").toString(), t -> Double.parseDouble(t.get("healthIndex").toString())));
Map<String, Double> subSystemIndexInfoMap = subSystemIndexInfo.stream().collect(Collectors.toMap(t -> t.get("subSystem").toString(), t -> Double.parseDouble(t.get("healthIndex").toString())));
List<Map<String, Object>> subSystemIndexInfo = idxBizFanHealthIndexMapper
.getSubSystemIndexInfoByParam(analysisType, gatewayIds);
List<Map<String, Object>> pointNameIndexInfo = idxBizFanHealthIndexMapper.getPointNameIndexInfoByParam(analysisType, gatewayIds); Map<String, Double> subSystemIndexInfoMap = subSystemIndexInfo.stream().collect(Collectors
Map<String, Double> pointNameIndexInfoMap = pointNameIndexInfo.stream().collect(Collectors.toMap(t -> t.get("gatewayIndexAddress").toString(), t -> Double.parseDouble(t.get("healthIndex").toString()))); .toMap(t -> t.get("subSystem").toString(), t -> Double.parseDouble(t.get("healthIndex").toString())));
List<Map<String, Object>> pointNameIndexInfo = idxBizFanHealthIndexMapper
.getPointNameIndexInfoByParam(analysisType, gatewayIds);
Map<String, Double> pointNameIndexInfoMap = pointNameIndexInfo.stream()
.collect(Collectors.toMap(t -> t.get("gatewayIndexAddress").toString(),
t -> Double.parseDouble(t.get("healthIndex").toString())));
List<IdxBizFanHealthLevel> healthLevelInfoList = idxBizFanHealthIndexMapper.getHealthLevelInfoList(gatewayIds); List<IdxBizFanHealthLevel> healthLevelInfoList = idxBizFanHealthIndexMapper.getHealthLevelInfoList(gatewayIds);
List<FullViewRecallDataDTO> list = idxBizFanHealthIndexMapper.getFullViewRecall(gatewayIds); List<FullViewRecallDataDTO> list = idxBizFanHealthIndexMapper.getFullViewRecall(gatewayIds);
Map<String, Map<String, Map<String, Map<String, Map<String, List<FullViewRecallDataDTO>>>>>> resultMap = list.stream() Map<String, Map<String, Map<String, Map<String, Map<String, List<FullViewRecallDataDTO>>>>>> resultMap = list
.stream()
.collect(Collectors.groupingBy(FullViewRecallDataDTO::getArea, .collect(Collectors.groupingBy(FullViewRecallDataDTO::getArea,
Collectors.groupingBy(FullViewRecallDataDTO::getStation, Collectors.groupingBy(FullViewRecallDataDTO::getStation,
Collectors.groupingBy(FullViewRecallDataDTO::getEquipmentName, Collectors.groupingBy(FullViewRecallDataDTO::getEquipmentName,
...@@ -172,7 +218,8 @@ public class KafkaAnalyseController { ...@@ -172,7 +218,8 @@ public class KafkaAnalyseController {
int stationInt = 1; int stationInt = 1;
int equipmentInt = 1; int equipmentInt = 1;
int subSystemInt = 1; int subSystemInt = 1;
Double healthScoreInfo = idxBizFanHealthIndexMapper.getHealthScoreInfoByParam(null, null, analysisType).doubleValue(); Double healthScoreInfo = idxBizFanHealthIndexMapper.getHealthScoreInfoByParam(null, null, analysisType)
.doubleValue();
healthScoreInfo = Double.parseDouble(df.format(healthScoreInfo)); healthScoreInfo = Double.parseDouble(df.format(healthScoreInfo));
LambdaQueryWrapper<IdxBizFanHealthLevel> query = new LambdaQueryWrapper<>(); LambdaQueryWrapper<IdxBizFanHealthLevel> query = new LambdaQueryWrapper<>();
...@@ -193,11 +240,13 @@ public class KafkaAnalyseController { ...@@ -193,11 +240,13 @@ public class KafkaAnalyseController {
allMapDto.setChildren(new ArrayList<>()); allMapDto.setChildren(new ArrayList<>());
allMapDto.setParentKey("0"); allMapDto.setParentKey("0");
for (Map.Entry<String, Map<String, Map<String, Map<String, Map<String, List<FullViewRecallDataDTO>>>>>> areaMap : resultMap.entrySet()) { for (Map.Entry<String, Map<String, Map<String, Map<String, Map<String, List<FullViewRecallDataDTO>>>>>> areaMap : resultMap
.entrySet()) {
Double areaLowScore = null; Double areaLowScore = null;
Double areaHighScore = null; Double areaHighScore = null;
Double areaHealthScoreInfo = idxBizFanHealthIndexMapper.getHealthScoreInfoByParam(areaMap.getKey(), null, analysisType).doubleValue(); Double areaHealthScoreInfo = idxBizFanHealthIndexMapper
.getHealthScoreInfoByParam(areaMap.getKey(), null, analysisType).doubleValue();
areaHealthScoreInfo = Double.parseDouble(df.format(areaHealthScoreInfo)); areaHealthScoreInfo = Double.parseDouble(df.format(areaHealthScoreInfo));
LambdaQueryWrapper<IdxBizFanHealthLevel> areaQuery = new LambdaQueryWrapper<>(); LambdaQueryWrapper<IdxBizFanHealthLevel> areaQuery = new LambdaQueryWrapper<>();
areaQuery.isNull(IdxBizFanHealthLevel::getStatus); areaQuery.isNull(IdxBizFanHealthLevel::getStatus);
...@@ -215,7 +264,8 @@ public class KafkaAnalyseController { ...@@ -215,7 +264,8 @@ public class KafkaAnalyseController {
allMapDto.getChildren().add(areaMapDto); allMapDto.getChildren().add(areaMapDto);
areaInt++; areaInt++;
List<FullViewRecallInfoDTO> areaMapList = new ArrayList<>(); List<FullViewRecallInfoDTO> areaMapList = new ArrayList<>();
for (Map.Entry<String, Map<String, Map<String, Map<String, List<FullViewRecallDataDTO>>>>> stationMap : areaMap.getValue().entrySet()) { for (Map.Entry<String, Map<String, Map<String, Map<String, List<FullViewRecallDataDTO>>>>> stationMap : areaMap
.getValue().entrySet()) {
Double stationLowScore = null; Double stationLowScore = null;
Double stationHighScore = null; Double stationHighScore = null;
if (areaLowScore == null && areaHighScore == null) { if (areaLowScore == null && areaHighScore == null) {
...@@ -257,8 +307,8 @@ public class KafkaAnalyseController { ...@@ -257,8 +307,8 @@ public class KafkaAnalyseController {
stationDto.setParentKey(areaMapDto.getKey()); stationDto.setParentKey(areaMapDto.getKey());
areaMapDto.getChildren().add(stationDto); areaMapDto.getChildren().add(stationDto);
stationInt++; stationInt++;
for (Map.Entry<String, Map<String, Map<String, List<FullViewRecallDataDTO>>>> equipmentMap : stationMap.getValue().entrySet()) { for (Map.Entry<String, Map<String, Map<String, List<FullViewRecallDataDTO>>>> equipmentMap : stationMap
.getValue().entrySet()) {
if (stationLowScore == null && stationHighScore == null) { if (stationLowScore == null && stationHighScore == null) {
stationLowScore = equipmentIndexInfoMap.getOrDefault(equipmentMap.getKey(), 100.0); stationLowScore = equipmentIndexInfoMap.getOrDefault(equipmentMap.getKey(), 100.0);
...@@ -276,27 +326,32 @@ public class KafkaAnalyseController { ...@@ -276,27 +326,32 @@ public class KafkaAnalyseController {
equipmentMapDto.setKey(stationDto.getKey() + "-" + equipmentInt); equipmentMapDto.setKey(stationDto.getKey() + "-" + equipmentInt);
equipmentMapDto.setName(equipmentMap.getKey()); equipmentMapDto.setName(equipmentMap.getKey());
equipmentMapDto.setScoreRange(""); equipmentMapDto.setScoreRange("");
IdxBizFanHealthLevel levelInfo = getHealthLevelByScore(healthLevelInfoList, stationMap.getKey(), "设备", equipmentIndexInfoMap.getOrDefault(equipmentMap.getKey(), 100.0)); IdxBizFanHealthLevel levelInfo = getHealthLevelByScore(healthLevelInfoList, stationMap.getKey(),
"设备", equipmentIndexInfoMap.getOrDefault(equipmentMap.getKey(), 100.0));
equipmentMapDto.setStatus(levelInfo.getHealthLevel()); equipmentMapDto.setStatus(levelInfo.getHealthLevel());
equipmentMapDto.setScore(equipmentIndexInfoMap.getOrDefault(equipmentMap.getKey(), 100.0)); equipmentMapDto.setScore(equipmentIndexInfoMap.getOrDefault(equipmentMap.getKey(), 100.0));
equipmentMapDto.setParentKey(stationDto.getKey()); equipmentMapDto.setParentKey(stationDto.getKey());
stationDto.getChildren().add(equipmentMapDto); stationDto.getChildren().add(equipmentMapDto);
equipmentInt++; equipmentInt++;
for (Map.Entry<String, Map<String, List<FullViewRecallDataDTO>>> subSystemMap : equipmentMap.getValue().entrySet()) { for (Map.Entry<String, Map<String, List<FullViewRecallDataDTO>>> subSystemMap : equipmentMap
.getValue().entrySet()) {
FullViewRecallInfoDTO subSystemMapDto = new FullViewRecallInfoDTO(); FullViewRecallInfoDTO subSystemMapDto = new FullViewRecallInfoDTO();
subSystemMapDto.setKey(equipmentMapDto.getKey() + "-" + subSystemInt); subSystemMapDto.setKey(equipmentMapDto.getKey() + "-" + subSystemInt);
subSystemMapDto.setName(subSystemMap.getKey()); subSystemMapDto.setName(subSystemMap.getKey());
subSystemMapDto.setScoreRange(""); subSystemMapDto.setScoreRange("");
// subSystemMapDto.setStatus(null); // subSystemMapDto.setStatus(null);
IdxBizFanHealthLevel levelInfoZxt = getHealthLevelByScore(healthLevelInfoList, stationMap.getKey(), "子系统", subSystemIndexInfoMap.getOrDefault(subSystemMap.getKey(), 100.0)); IdxBizFanHealthLevel levelInfoZxt = getHealthLevelByScore(healthLevelInfoList,
stationMap.getKey(), "子系统",
subSystemIndexInfoMap.getOrDefault(subSystemMap.getKey(), 100.0));
subSystemMapDto.setStatus(levelInfoZxt.getHealthLevel()); subSystemMapDto.setStatus(levelInfoZxt.getHealthLevel());
subSystemMapDto.setScore(subSystemIndexInfoMap.getOrDefault(subSystemMap.getKey(), 100.0)); subSystemMapDto.setScore(subSystemIndexInfoMap.getOrDefault(subSystemMap.getKey(), 100.0));
subSystemMapDto.setParentKey(equipmentMapDto.getKey()); subSystemMapDto.setParentKey(equipmentMapDto.getKey());
equipmentMapDto.getChildren().add(subSystemMapDto); equipmentMapDto.getChildren().add(subSystemMapDto);
subSystemInt++; subSystemInt++;
for (Map.Entry<String, List<FullViewRecallDataDTO>> pointNameMap : subSystemMap.getValue().entrySet()) { for (Map.Entry<String, List<FullViewRecallDataDTO>> pointNameMap : subSystemMap.getValue()
.entrySet()) {
FullViewRecallInfoDTO pointNameMapDto = new FullViewRecallInfoDTO(); FullViewRecallInfoDTO pointNameMapDto = new FullViewRecallInfoDTO();
pointNameMapDto.setKey(subSystemMapDto.getKey() + "-" + pointNameInt); pointNameMapDto.setKey(subSystemMapDto.getKey() + "-" + pointNameInt);
pointNameMapDto.setName(pointNameMap.getKey()); pointNameMapDto.setName(pointNameMap.getKey());
...@@ -305,10 +360,15 @@ public class KafkaAnalyseController { ...@@ -305,10 +360,15 @@ public class KafkaAnalyseController {
pointNameMapDto.setScoreRange(""); pointNameMapDto.setScoreRange("");
IdxBizFanHealthLevel levelInfoBL = getHealthLevelByScore(healthLevelInfoList, stationMap.getKey(), "测点", pointNameIndexInfoMap.getOrDefault(fullViewRecallDataDTO.getStation() + "_" + fullViewRecallDataDTO.getIndexAddress(), 100.0)); IdxBizFanHealthLevel levelInfoBL = getHealthLevelByScore(healthLevelInfoList,
stationMap.getKey(), "测点",
pointNameIndexInfoMap.getOrDefault(fullViewRecallDataDTO.getStation() + "_"
+ fullViewRecallDataDTO.getIndexAddress(), 100.0));
pointNameMapDto.setStatus(levelInfoBL.getHealthLevel()); pointNameMapDto.setStatus(levelInfoBL.getHealthLevel());
pointNameMapDto.setScore(pointNameIndexInfoMap.getOrDefault(fullViewRecallDataDTO.getStation() + "_" + fullViewRecallDataDTO.getIndexAddress(), 100.0)); pointNameMapDto.setScore(pointNameIndexInfoMap.getOrDefault(
fullViewRecallDataDTO.getStation() + "_" + fullViewRecallDataDTO.getIndexAddress(),
100.0));
pointNameMapDto.setParentKey(subSystemMapDto.getKey()); pointNameMapDto.setParentKey(subSystemMapDto.getKey());
subSystemMapDto.getChildren().add(pointNameMapDto); subSystemMapDto.getChildren().add(pointNameMapDto);
...@@ -327,13 +387,14 @@ public class KafkaAnalyseController { ...@@ -327,13 +387,14 @@ public class KafkaAnalyseController {
return ResponseHelper.buildResponse(resultList); return ResponseHelper.buildResponse(resultList);
} }
private IdxBizFanHealthLevel getHealthLevelByScore(List<IdxBizFanHealthLevel> healthLevelInfoList, String station,
private IdxBizFanHealthLevel getHealthLevelByScore(List<IdxBizFanHealthLevel> healthLevelInfoList, String station, String type, Double score) { String type, Double score) {
IdxBizFanHealthLevel resultDto = new IdxBizFanHealthLevel(); IdxBizFanHealthLevel resultDto = new IdxBizFanHealthLevel();
String stationType = "风电站"; String stationType = "风电站";
List<IdxBizFanHealthLevel> collect = healthLevelInfoList.stream().filter(item -> item.getAnalysisObjType().contains(station)).collect(Collectors.toList()); List<IdxBizFanHealthLevel> collect = healthLevelInfoList.stream()
.filter(item -> item.getAnalysisObjType().contains(station)).collect(Collectors.toList());
for (IdxBizFanHealthLevel item : collect) { for (IdxBizFanHealthLevel item : collect) {
if (item.getAnalysisObjType().contains("子阵")) { if (item.getAnalysisObjType().contains("子阵")) {
stationType = "光伏站"; stationType = "光伏站";
...@@ -341,23 +402,28 @@ public class KafkaAnalyseController { ...@@ -341,23 +402,28 @@ public class KafkaAnalyseController {
} }
} }
for (IdxBizFanHealthLevel item : collect) { for (IdxBizFanHealthLevel item : collect) {
if (type.equals("设备") && stationType.equals("风电站") && item.getAnalysisObjType().contains(type) && score >= item.getGroupLowerLimit() && score <= item.getGroupUpperLimit()) { if (type.equals("设备") && stationType.equals("风电站") && item.getAnalysisObjType().contains(type)
&& score >= item.getGroupLowerLimit() && score <= item.getGroupUpperLimit()) {
resultDto = item; resultDto = item;
break; break;
} }
if (type.equals("子系统") && stationType.equals("风电站") && item.getAnalysisObjType().contains(type) && score >= item.getGroupLowerLimit() && score <= item.getGroupUpperLimit()) { if (type.equals("子系统") && stationType.equals("风电站") && item.getAnalysisObjType().contains(type)
&& score >= item.getGroupLowerLimit() && score <= item.getGroupUpperLimit()) {
resultDto = item; resultDto = item;
break; break;
} }
if (type.equals("测点") && item.getAnalysisObjType().contains(type) && score >= item.getGroupLowerLimit() && score <= item.getGroupUpperLimit()) { if (type.equals("测点") && item.getAnalysisObjType().contains(type) && score >= item.getGroupLowerLimit()
&& score <= item.getGroupUpperLimit()) {
resultDto = item; resultDto = item;
break; break;
} }
if (type.equals("设备") && stationType.equals("光伏站") && item.getAnalysisObjType().contains("子阵") && score >= item.getGroupLowerLimit() && score <= item.getGroupUpperLimit()) { if (type.equals("设备") && stationType.equals("光伏站") && item.getAnalysisObjType().contains("子阵")
&& score >= item.getGroupLowerLimit() && score <= item.getGroupUpperLimit()) {
resultDto = item; resultDto = item;
break; break;
} }
if (type.equals("子系统") && stationType.equals("光伏站") && item.getAnalysisObjType().contains("设备") && score >= item.getGroupLowerLimit() && score <= item.getGroupUpperLimit()) { if (type.equals("子系统") && stationType.equals("光伏站") && item.getAnalysisObjType().contains("设备")
&& score >= item.getGroupLowerLimit() && score <= item.getGroupUpperLimit()) {
resultDto = item; resultDto = item;
break; break;
} }
...@@ -373,22 +439,28 @@ public class KafkaAnalyseController { ...@@ -373,22 +439,28 @@ public class KafkaAnalyseController {
return permissions; return permissions;
} }
private List<FullViewRecallInfoDTO> getFullViewRecallResultByCurrentUser(List<FullViewRecallInfoDTO> fullViewRecallInfoDTOS) { private List<FullViewRecallInfoDTO> getFullViewRecallResultByCurrentUser(
List<FullViewRecallInfoDTO> fullViewRecallInfoDTOS) {
List<FullViewRecallInfoDTO> result = new ArrayList<>(); List<FullViewRecallInfoDTO> result = new ArrayList<>();
if (fullViewRecallInfoDTOS.size() > 0) { if (fullViewRecallInfoDTOS.size() > 0) {
String rootNodeName = permissionService.getCurrentUserPersmissions(); String rootNodeName = permissionService.getCurrentUserPersmissions();
if (rootNodeName.equals("all")) { if (rootNodeName.equals("all")) {
return fullViewRecallInfoDTOS; return fullViewRecallInfoDTOS;
} else { } else {
List<String> stringList = Arrays.asList(rootNodeName,rootNodeName.replace("片区","区域"),rootNodeName.replace("区域","片区"),rootNodeName.replace("电站","电场"),rootNodeName.replace("电场","电站")); List<String> stringList = Arrays.asList(rootNodeName, rootNodeName.replace("片区", "区域"),
List<FullViewRecallInfoDTO> fullViewRecallInfoDTOS1 = fullViewRecallInfoDTOS.get(0).getChildren().stream().filter(item -> stringList.contains(item.getName())).collect(Collectors.toList()); rootNodeName.replace("区域", "片区"), rootNodeName.replace("电站", "电场"),
rootNodeName.replace("电场", "电站"));
List<FullViewRecallInfoDTO> fullViewRecallInfoDTOS1 = fullViewRecallInfoDTOS.get(0).getChildren()
.stream().filter(item -> stringList.contains(item.getName())).collect(Collectors.toList());
if (fullViewRecallInfoDTOS1.size() > 0) { if (fullViewRecallInfoDTOS1.size() > 0) {
return fullViewRecallInfoDTOS1; return fullViewRecallInfoDTOS1;
} else { } else {
List<FullViewRecallInfoDTO> fullViewRecallInfoDTOS2 = fullViewRecallInfoDTOS.get(0).getChildren(); List<FullViewRecallInfoDTO> fullViewRecallInfoDTOS2 = fullViewRecallInfoDTOS.get(0).getChildren();
for (FullViewRecallInfoDTO fullViewRecallInfoDTO : fullViewRecallInfoDTOS2) { for (FullViewRecallInfoDTO fullViewRecallInfoDTO : fullViewRecallInfoDTOS2) {
List<FullViewRecallInfoDTO> fullViewRecallInfoDTOS3=fullViewRecallInfoDTO.getChildren().stream().filter(item -> stringList.contains(item.getName())).collect(Collectors.toList()); List<FullViewRecallInfoDTO> fullViewRecallInfoDTOS3 = fullViewRecallInfoDTO.getChildren()
if (fullViewRecallInfoDTOS3.size()>0){ .stream().filter(item -> stringList.contains(item.getName()))
.collect(Collectors.toList());
if (fullViewRecallInfoDTOS3.size() > 0) {
return fullViewRecallInfoDTOS3; return fullViewRecallInfoDTOS3;
} }
} }
......
...@@ -13,20 +13,21 @@ import java.util.Date; ...@@ -13,20 +13,21 @@ import java.util.Date;
public interface Constant { public interface Constant {
// 风电相关性消费者 // 风电相关性消费者
String kafkaTopicConsumer = "FanConditionVariables"; String kafkaTopicConsumer = "FAN_XGX";
// 光伏相关性消费者 // 光伏相关性消费者
String kafkaTopicConsumerPv = "PvConditionVariables"; String kafkaTopicConsumerPv = "PV_XGX";
// 风电 工况区间划分 // 风电 工况区间划分
String kafkaTopicConsumerGKHFFan = "FanConditionVariablesGKHF"; String kafkaTopicConsumerGKHFFan = "FAN_QJHF";
// 光伏 工况区间划分 // 光伏 工况区间划分
String kafkaTopicConsumerGKHFPv = "PvConditionVariablesGKHF"; String kafkaTopicConsumerGKHFPv = "PV_QJHF";
// 风电 中心值计算 // 风电 中心值计算
String kafkaTopicConsumerZXZFan = "FanConditionVariablesGZXZ"; String kafkaTopicConsumerZXZFan = "FAN_ZXZ";
// 光伏 中心值计算 // 光伏 中心值计算
String kafkaTopicConsumerZXZPv = "PvConditionVariablesZXZ"; String kafkaTopicConsumerZXZPv = "PV_ZXZ";
} }
...@@ -53,14 +53,12 @@ public class KafkaConsumerService { ...@@ -53,14 +53,12 @@ public class KafkaConsumerService {
@Autowired @Autowired
private IdxBizFanPointVarCorrelationServiceImpl idxBizFanPointVarCorrelationService; private IdxBizFanPointVarCorrelationServiceImpl idxBizFanPointVarCorrelationService;
@Autowired @Autowired
private IdxBizPvPointVarCorrelationServiceImpl idxBizPvPointVarCorrelationService; private IdxBizPvPointVarCorrelationServiceImpl idxBizPvPointVarCorrelationService;
@Autowired @Autowired
IdxBizFanPointProcessVariableClassificationServiceImpl idxBizFanPointProcessVariableClassificationService; IdxBizFanPointProcessVariableClassificationServiceImpl idxBizFanPointProcessVariableClassificationService;
@Autowired @Autowired
IdxBizPvPointProcessVariableClassificationServiceImpl idxBizPvPointProcessVariableClassificationService; IdxBizPvPointProcessVariableClassificationServiceImpl idxBizPvPointProcessVariableClassificationService;
...@@ -77,20 +75,19 @@ public class KafkaConsumerService { ...@@ -77,20 +75,19 @@ public class KafkaConsumerService {
IdxBizPvPointVarCentralValueMapper idxBizPvPointVarCentralValueMapper; IdxBizPvPointVarCentralValueMapper idxBizPvPointVarCentralValueMapper;
// 相关性 // 相关性
@Value("${base.url.XGX:http://139.9.171.247:8052/intelligent-analysis/correlation}") @Value("${base.url.XGX:http://10.20.1.29:8052/intelligent-analysis/correlation}")
private String baseUrlXGX; private String baseUrlXGX;
// 工况划分 // 工况划分
@Value("${base.url.GKHF:http://139.9.171.247:8052/intelligent-analysis/working-condition-division}") @Value("${base.url.GKHF:http://10.20.1.29:8052/intelligent-analysis/working-condition-division}")
private String baseUrlGKHF; private String baseUrlGKHF;
@Value("${base.url.ZXZ:http://172.16.3.29:8052/intelligent-analysis/central-value}") @Value("${base.url.ZXZ:http://10.20.1.29:8052/intelligent-analysis/central-value}")
private String zxzJsUrlFanBySF; private String zxzJsUrlFanBySF;
@Value("${spring.kafka.consumer.max-poll-records:30}") @Value("${spring.kafka.consumer.max-poll-records:30}")
private Integer threadNum = 30; private Integer threadNum = 30;
@Value("${last.month.num:12}") @Value("${last.month.num:12}")
private Integer lastMonthNum; private Integer lastMonthNum;
...@@ -99,17 +96,17 @@ public class KafkaConsumerService { ...@@ -99,17 +96,17 @@ public class KafkaConsumerService {
BlockingQueue<PointData> queue = new LinkedBlockingQueue<>(); BlockingQueue<PointData> queue = new LinkedBlockingQueue<>();
public KafkaConsumerService() { public KafkaConsumerService() {
for (int i = 0 ; i < threadNum; i++) { for (int i = 0; i < threadNum; i++) {
service.execute(new Runnable() { service.execute(new Runnable() {
@Override @Override
public void run() { public void run() {
while(true) { while (true) {
try { try {
PointData pointsData = queue.take(); PointData pointsData = queue.take();
List<ConsumerRecord<String, String>> consumerRecords = pointsData.getConsumerRecords(); List<ConsumerRecord<String, String>> consumerRecords = pointsData.getConsumerRecords();
Table table = pointsData.getTable(); Table table = pointsData.getTable();
if ("xgxFanConsumer".equals(pointsData.getOperatorType())){ if ("xgxFanConsumer".equals(pointsData.getOperatorType())) {
execFanCorrelation(consumerRecords, table); execFanCorrelation(consumerRecords, table);
} else if ("xgxPvConsumer".equals(pointsData.getOperatorType())) { } else if ("xgxPvConsumer".equals(pointsData.getOperatorType())) {
execPvCorrelation(consumerRecords, table); execPvCorrelation(consumerRecords, table);
...@@ -122,6 +119,7 @@ public class KafkaConsumerService { ...@@ -122,6 +119,7 @@ public class KafkaConsumerService {
} else if ("ZXZPvConsumer".equals(pointsData.getOperatorType())) { } else if ("ZXZPvConsumer".equals(pointsData.getOperatorType())) {
consumerRecordsZXZPv(consumerRecords, pointsData); consumerRecordsZXZPv(consumerRecords, pointsData);
} }
Thread.sleep(1000);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -132,16 +130,17 @@ public class KafkaConsumerService { ...@@ -132,16 +130,17 @@ public class KafkaConsumerService {
} }
} }
private void consumerRecordsZXZFan(List<ConsumerRecord<String, String>> consumerRecords, PointData pointsData) {
private void consumerRecordsZXZFan(List<ConsumerRecord<String, String>> consumerRecords, PointData pointsData ) { redisUtils.expire(kafkaTopicConsumerZXZFan, 600);
Table table = pointsData.getTable(); Table table = pointsData.getTable();
Map<String, List<IdxBizFanPointProcessVariableClassification>> zxzIds = pointsData.getZxzIds(); Map<String, List<IdxBizFanPointProcessVariableClassification>> zxzIds = pointsData.getZxzIds();
for (String id : zxzIds.keySet()) { for (String id : zxzIds.keySet()) {
List<IdxBizFanPointProcessVariableClassification> variableClassificationList = zxzIds.get(id); List<IdxBizFanPointProcessVariableClassification> variableClassificationList = zxzIds.get(id);
String analysisVariableId = id; String analysisVariableId = id;
List<IdxBizFanPointProcessVariableClassification> processVariableList = variableClassificationList.stream().filter(v -> !id.equals(v.getSequenceNbr().toString())).collect(Collectors.toList()); List<IdxBizFanPointProcessVariableClassification> processVariableList = variableClassificationList.stream()
IdxBizFanPointProcessVariableClassification analysisVariable = variableClassificationList.stream().filter(v -> id.equals(v.getSequenceNbr().toString())).findFirst().get(); .filter(v -> !id.equals(v.getSequenceNbr().toString())).collect(Collectors.toList());
IdxBizFanPointProcessVariableClassification analysisVariable = variableClassificationList.stream()
.filter(v -> id.equals(v.getSequenceNbr().toString())).findFirst().get();
// if (analysisVariable.getEquipmentName().equals("W2500#14风机") && analysisVariable.getPointName().equals("桨距角")) { // if (analysisVariable.getEquipmentName().equals("W2500#14风机") && analysisVariable.getPointName().equals("桨距角")) {
// log.info("抓包数据:{}", JSON.toJSONString(analysisVariable)); // log.info("抓包数据:{}", JSON.toJSONString(analysisVariable));
...@@ -153,7 +152,8 @@ public class KafkaConsumerService { ...@@ -153,7 +152,8 @@ public class KafkaConsumerService {
Table dataTable = Table.create(); Table dataTable = Table.create();
int minRow = 0; int minRow = 0;
for (IdxBizFanPointProcessVariableClassification processVariable : processVariableList) { for (IdxBizFanPointProcessVariableClassification processVariable : processVariableList) {
Selection selection = table.stringColumn("id").isEqualTo(processVariable.getIndexAddress() + "_" + processVariable.getGatewayId()); Selection selection = table.stringColumn("id")
.isEqualTo(processVariable.getIndexAddress() + "_" + processVariable.getGatewayId());
DoubleColumn values = table.where(selection).doubleColumn("value"); DoubleColumn values = table.where(selection).doubleColumn("value");
// 获取最小数据长度 // 获取最小数据长度
if (index == 1) { if (index == 1) {
...@@ -177,7 +177,8 @@ public class KafkaConsumerService { ...@@ -177,7 +177,8 @@ public class KafkaConsumerService {
index++; index++;
} }
Selection selection = table.stringColumn("id").isEqualTo(analysisVariable.getIndexAddress() + "_" + analysisVariable.getGatewayId()); Selection selection = table.stringColumn("id")
.isEqualTo(analysisVariable.getIndexAddress() + "_" + analysisVariable.getGatewayId());
DoubleColumn values = table.where(selection).doubleColumn("value"); DoubleColumn values = table.where(selection).doubleColumn("value");
values.setName("analysisVariable"); values.setName("analysisVariable");
dataTable = getDataTable(dataTable, values); dataTable = getDataTable(dataTable, values);
...@@ -190,25 +191,39 @@ public class KafkaConsumerService { ...@@ -190,25 +191,39 @@ public class KafkaConsumerService {
data1.put(column, dataTable.doubleColumn(column).asDoubleArray()); data1.put(column, dataTable.doubleColumn(column).asDoubleArray());
} }
Map<String,Object> requestMap = new HashMap<>(); Map<String, Object> requestMap = new HashMap<>();
requestMap.put("data1", data1); requestMap.put("data1", data1);
requestMap.put("data2", data2); requestMap.put("data2", data2);
String response = HttpUtil.createPost(zxzJsUrlFanBySF).body(JSON.toJSONString(requestMap)).execute().body(); String response = HttpUtil.createPost(zxzJsUrlFanBySF).body(JSON.toJSONString(requestMap)).execute().body();
if (response.contains("stdDev")) { if (response.contains("stdDev")) {
idxBizFanPointVarCentralValueMapper.delete(new QueryWrapper<IdxBizFanPointVarCentralValue>().eq("ANALYSIS_POINT_ID", analysisVariableId)); idxBizFanPointVarCentralValueMapper.delete(
new QueryWrapper<IdxBizFanPointVarCentralValue>().eq("ANALYSIS_POINT_ID", analysisVariableId));
JSONObject jsonObject = JSON.parseObject(response); JSONObject jsonObject = JSON.parseObject(response);
int length = jsonObject.getJSONArray("stdDev").size() > 64 ? 64 : jsonObject.getJSONArray("stdDev").size(); int length = jsonObject.getJSONArray("stdDev").size() > 64 ? 64
: jsonObject.getJSONArray("stdDev").size();
List<IdxBizFanPointVarCentralValue> insertList = new ArrayList<>(); List<IdxBizFanPointVarCentralValue> insertList = new ArrayList<>();
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
IdxBizFanPointVarCentralValue idxBizFanPointVarCentralValue = new IdxBizFanPointVarCentralValue(); IdxBizFanPointVarCentralValue idxBizFanPointVarCentralValue = new IdxBizFanPointVarCentralValue();
idxBizFanPointVarCentralValue.setProcess1Min(ObjectUtils.isNull(jsonObject.getJSONArray("process1Min").get(i)) ? null : jsonObject.getJSONArray("process1Min").getDoubleValue(i)); idxBizFanPointVarCentralValue
idxBizFanPointVarCentralValue.setProcess2Min(ObjectUtils.isNull(jsonObject.getJSONArray("process2Min").get(i)) ? null : jsonObject.getJSONArray("process2Min").getDoubleValue(i)); .setProcess1Min(ObjectUtils.isNull(jsonObject.getJSONArray("process1Min").get(i)) ? null
idxBizFanPointVarCentralValue.setProcess3Min(ObjectUtils.isNull(jsonObject.getJSONArray("process3Min").get(i)) ? null : jsonObject.getJSONArray("process3Min").getDoubleValue(i)); : jsonObject.getJSONArray("process1Min").getDoubleValue(i));
idxBizFanPointVarCentralValue.setProcess1Max(ObjectUtils.isNull(jsonObject.getJSONArray("process1Max").get(i)) ? null : jsonObject.getJSONArray("process1Max").getDoubleValue(i)); idxBizFanPointVarCentralValue
idxBizFanPointVarCentralValue.setPorcess2Max(ObjectUtils.isNull(jsonObject.getJSONArray("process2Max").get(i)) ? null : jsonObject.getJSONArray("process2Max").getDoubleValue(i)); .setProcess2Min(ObjectUtils.isNull(jsonObject.getJSONArray("process2Min").get(i)) ? null
idxBizFanPointVarCentralValue.setProcess3Max(ObjectUtils.isNull(jsonObject.getJSONArray("process3Max").get(i)) ? null : jsonObject.getJSONArray("process3Max").getDoubleValue(i)); : jsonObject.getJSONArray("process2Min").getDoubleValue(i));
idxBizFanPointVarCentralValue
.setProcess3Min(ObjectUtils.isNull(jsonObject.getJSONArray("process3Min").get(i)) ? null
: jsonObject.getJSONArray("process3Min").getDoubleValue(i));
idxBizFanPointVarCentralValue
.setProcess1Max(ObjectUtils.isNull(jsonObject.getJSONArray("process1Max").get(i)) ? null
: jsonObject.getJSONArray("process1Max").getDoubleValue(i));
idxBizFanPointVarCentralValue
.setPorcess2Max(ObjectUtils.isNull(jsonObject.getJSONArray("process2Max").get(i)) ? null
: jsonObject.getJSONArray("process2Max").getDoubleValue(i));
idxBizFanPointVarCentralValue
.setProcess3Max(ObjectUtils.isNull(jsonObject.getJSONArray("process3Max").get(i)) ? null
: jsonObject.getJSONArray("process3Max").getDoubleValue(i));
idxBizFanPointVarCentralValue.setAnalysisPointId(analysisVariableId); idxBizFanPointVarCentralValue.setAnalysisPointId(analysisVariableId);
idxBizFanPointVarCentralValue.setAnalysisPointName(analysisVariable.getPointName()); idxBizFanPointVarCentralValue.setAnalysisPointName(analysisVariable.getPointName());
idxBizFanPointVarCentralValue.setProcessPoint1Id(data1.get("processVariable1Id").toString()); idxBizFanPointVarCentralValue.setProcessPoint1Id(data1.get("processVariable1Id").toString());
...@@ -217,8 +232,12 @@ public class KafkaConsumerService { ...@@ -217,8 +232,12 @@ public class KafkaConsumerService {
idxBizFanPointVarCentralValue.setProcessPoint2Name(processVariableList.get(1).getPointName()); idxBizFanPointVarCentralValue.setProcessPoint2Name(processVariableList.get(1).getPointName());
idxBizFanPointVarCentralValue.setProcessPoint3Id(data1.get("processVariable3Id").toString()); idxBizFanPointVarCentralValue.setProcessPoint3Id(data1.get("processVariable3Id").toString());
idxBizFanPointVarCentralValue.setProcessPoint3Name(processVariableList.get(2).getPointName()); idxBizFanPointVarCentralValue.setProcessPoint3Name(processVariableList.get(2).getPointName());
idxBizFanPointVarCentralValue.setAnalysisStdDev(ObjectUtils.isNull(jsonObject.getJSONArray("stdDev").get(i)) ? null : jsonObject.getJSONArray("stdDev").getDoubleValue(i)); idxBizFanPointVarCentralValue
idxBizFanPointVarCentralValue.setAnalysisCenterValue(ObjectUtils.isNull(jsonObject.getJSONArray("centerValue").get(i)) ? null : jsonObject.getJSONArray("centerValue").getDoubleValue(i)); .setAnalysisStdDev(ObjectUtils.isNull(jsonObject.getJSONArray("stdDev").get(i)) ? null
: jsonObject.getJSONArray("stdDev").getDoubleValue(i));
idxBizFanPointVarCentralValue.setAnalysisCenterValue(
ObjectUtils.isNull(jsonObject.getJSONArray("centerValue").get(i)) ? null
: jsonObject.getJSONArray("centerValue").getDoubleValue(i));
idxBizFanPointVarCentralValue.setArae(analysisVariable.getArae()); idxBizFanPointVarCentralValue.setArae(analysisVariable.getArae());
idxBizFanPointVarCentralValue.setStation(analysisVariable.getStation()); idxBizFanPointVarCentralValue.setStation(analysisVariable.getStation());
idxBizFanPointVarCentralValue.setSubSystem(analysisVariable.getSubSystem()); idxBizFanPointVarCentralValue.setSubSystem(analysisVariable.getSubSystem());
...@@ -230,15 +249,14 @@ public class KafkaConsumerService { ...@@ -230,15 +249,14 @@ public class KafkaConsumerService {
idxBizFanPointVarCentralValueService.saveBatch(insertList); idxBizFanPointVarCentralValueService.saveBatch(insertList);
} }
} }
redisUtils.expire(kafkaTopicConsumerZXZFan, 600);
} }
//redisUtils.del(kafkaTopicConsumerZXZFan);
} }
private Table getDataTable(Table dataTable, DoubleColumn values) { private Table getDataTable(Table dataTable, DoubleColumn values) {
if (!dataTable.isEmpty() && dataTable.rowCount() < values.size()) { if (!dataTable.isEmpty() && dataTable.rowCount() < values.size()) {
dataTable.addColumns(values.inRange(0, dataTable.rowCount())); dataTable.addColumns(values.inRange(0, dataTable.rowCount()));
} else if (!dataTable.isEmpty() && dataTable.rowCount() > values.size()){ } else if (!dataTable.isEmpty() && dataTable.rowCount() > values.size()) {
dataTable = dataTable.inRange(0, values.size()); dataTable = dataTable.inRange(0, values.size());
dataTable.addColumns(values); dataTable.addColumns(values);
} else { } else {
...@@ -248,13 +266,17 @@ public class KafkaConsumerService { ...@@ -248,13 +266,17 @@ public class KafkaConsumerService {
} }
private void execPvCorrelation(List<ConsumerRecord<String, String>> consumerRecords, Table table) { private void execPvCorrelation(List<ConsumerRecord<String, String>> consumerRecords, Table table) {
redisUtils.expire(kafkaTopicConsumerPv, 600);
consumerRecords.parallelStream().forEach(record -> { consumerRecords.parallelStream().forEach(record -> {
Optional<?> kafkaMessage = Optional.ofNullable(record.value()); Optional<?> kafkaMessage = Optional.ofNullable(record.value());
if (kafkaMessage.isPresent()) { if (kafkaMessage.isPresent()) {
IdxBizPvPointVarCorrelation pvPointVarCorrelation = JSON.parseObject(kafkaMessage.get().toString(), IdxBizPvPointVarCorrelation.class); IdxBizPvPointVarCorrelation pvPointVarCorrelation = JSON.parseObject(kafkaMessage.get().toString(),
Selection selection = table.stringColumn("id").isEqualTo(pvPointVarCorrelation.getAnalysisIndexAddress() + "_" + pvPointVarCorrelation.getAnalysisGatewayId()); IdxBizPvPointVarCorrelation.class);
Selection selection = table.stringColumn("id").isEqualTo(pvPointVarCorrelation.getAnalysisIndexAddress()
+ "_" + pvPointVarCorrelation.getAnalysisGatewayId());
double[] data1 = table.where(selection).doubleColumn("value").asDoubleArray(); double[] data1 = table.where(selection).doubleColumn("value").asDoubleArray();
selection = table.stringColumn("id").isEqualTo(pvPointVarCorrelation.getProcessIndexAddress() + "_" + pvPointVarCorrelation.getProcessGatewayId()); selection = table.stringColumn("id").isEqualTo(pvPointVarCorrelation.getProcessIndexAddress() + "_"
+ pvPointVarCorrelation.getProcessGatewayId());
double[] data2 = table.where(selection).doubleColumn("value").asDoubleArray(); double[] data2 = table.where(selection).doubleColumn("value").asDoubleArray();
int shortestLength = Math.min(data1.length, data2.length); int shortestLength = Math.min(data1.length, data2.length);
...@@ -268,7 +290,8 @@ public class KafkaConsumerService { ...@@ -268,7 +290,8 @@ public class KafkaConsumerService {
if (response.contains("correlation") && !response.contains("warning")) { if (response.contains("correlation") && !response.contains("warning")) {
com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(response); com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(response);
pvPointVarCorrelation.setCorrelationCoefficient(jsonObject.getDoubleValue("correlation")); pvPointVarCorrelation.setCorrelationCoefficient(jsonObject.getDoubleValue("correlation"));
log.info("------------------------------------------光伏相关性::计算成功,待更新表数据----------------------------------------"); log.info(
"------------------------------------------光伏相关性::计算成功,待更新表数据----------------------------------------");
} else { } else {
pvPointVarCorrelation.setCorrelationCoefficient(0.0); pvPointVarCorrelation.setCorrelationCoefficient(0.0);
} }
...@@ -277,17 +300,22 @@ public class KafkaConsumerService { ...@@ -277,17 +300,22 @@ public class KafkaConsumerService {
idxBizPvPointVarCorrelationService.saveOrUpdate(pvPointVarCorrelation); idxBizPvPointVarCorrelationService.saveOrUpdate(pvPointVarCorrelation);
} }
}); });
redisUtils.expire(kafkaTopicConsumerPv, 600); //redisUtils.del(kafkaTopicConsumerPv);
} }
private void execFanCorrelation(List<ConsumerRecord<String, String>> consumerRecords, Table table) { private void execFanCorrelation(List<ConsumerRecord<String, String>> consumerRecords, Table table) {
redisUtils.expire(kafkaTopicConsumer, 600);
consumerRecords.parallelStream().forEach(record -> { consumerRecords.parallelStream().forEach(record -> {
Optional<?> kafkaMessage = Optional.ofNullable(record.value()); Optional<?> kafkaMessage = Optional.ofNullable(record.value());
if (kafkaMessage.isPresent()) { if (kafkaMessage.isPresent()) {
IdxBizFanPointVarCorrelation fanPointVarCorrelation = JSON.parseObject(kafkaMessage.get().toString(), IdxBizFanPointVarCorrelation.class); IdxBizFanPointVarCorrelation fanPointVarCorrelation = JSON.parseObject(kafkaMessage.get().toString(),
Selection selection = table.stringColumn("id").isEqualTo(fanPointVarCorrelation.getAnalysisIndexAddress() + "_" + fanPointVarCorrelation.getAnalysisGatewayId()); IdxBizFanPointVarCorrelation.class);
Selection selection = table.stringColumn("id")
.isEqualTo(fanPointVarCorrelation.getAnalysisIndexAddress() + "_"
+ fanPointVarCorrelation.getAnalysisGatewayId());
double[] data1 = table.where(selection).doubleColumn("value").asDoubleArray(); double[] data1 = table.where(selection).doubleColumn("value").asDoubleArray();
selection = table.stringColumn("id").isEqualTo(fanPointVarCorrelation.getProcessIndexAddress() + "_" + fanPointVarCorrelation.getProcessGatewayId()); selection = table.stringColumn("id").isEqualTo(fanPointVarCorrelation.getProcessIndexAddress() + "_"
+ fanPointVarCorrelation.getProcessGatewayId());
double[] data2 = table.where(selection).doubleColumn("value").asDoubleArray(); double[] data2 = table.where(selection).doubleColumn("value").asDoubleArray();
int shortestLength = Math.min(data1.length, data2.length); int shortestLength = Math.min(data1.length, data2.length);
...@@ -301,7 +329,8 @@ public class KafkaConsumerService { ...@@ -301,7 +329,8 @@ public class KafkaConsumerService {
if (response.contains("correlation") && !response.contains("warning")) { if (response.contains("correlation") && !response.contains("warning")) {
com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(response); com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(response);
fanPointVarCorrelation.setCorrelationCoefficient(jsonObject.getDoubleValue("correlation")); fanPointVarCorrelation.setCorrelationCoefficient(jsonObject.getDoubleValue("correlation"));
log.info("------------------------------------------风机相关性::计算成功,待更新表数据----------------------------------------"); log.info(
"------------------------------------------风机相关性::计算成功,待更新表数据----------------------------------------");
} else { } else {
fanPointVarCorrelation.setCorrelationCoefficient(0.0); fanPointVarCorrelation.setCorrelationCoefficient(0.0);
} }
...@@ -310,7 +339,7 @@ public class KafkaConsumerService { ...@@ -310,7 +339,7 @@ public class KafkaConsumerService {
idxBizFanPointVarCorrelationService.saveOrUpdate(fanPointVarCorrelation); idxBizFanPointVarCorrelationService.saveOrUpdate(fanPointVarCorrelation);
} }
}); });
redisUtils.expire(kafkaTopicConsumer, 600); //redisUtils.del(kafkaTopicConsumer);
} }
public static double[] subset(double[] array, int length) { public static double[] subset(double[] array, int length) {
...@@ -332,26 +361,28 @@ public class KafkaConsumerService { ...@@ -332,26 +361,28 @@ public class KafkaConsumerService {
private Map<String, List<IdxBizPvPointProcessVariableClassification>> zxzPvIds; private Map<String, List<IdxBizPvPointProcessVariableClassification>> zxzPvIds;
public PointData(List<ConsumerRecord<String, String>> consumerRecords, Table table, String operatorType) { public PointData(List<ConsumerRecord<String, String>> consumerRecords, Table table, String operatorType) {
this.consumerRecords = consumerRecords; this.consumerRecords = consumerRecords;
this.table = table; this.table = table;
this.operatorType = operatorType; this.operatorType = operatorType;
} }
public PointData(List<ConsumerRecord<String, String>> consumerRecords, Table table, String operatorType, Map<String, List<IdxBizFanPointProcessVariableClassification>> zxzIds) { public PointData(List<ConsumerRecord<String, String>> consumerRecords, Table table, String operatorType,
Map<String, List<IdxBizFanPointProcessVariableClassification>> zxzIds) {
this.consumerRecords = consumerRecords; this.consumerRecords = consumerRecords;
this.table = table; this.table = table;
this.operatorType = operatorType; this.operatorType = operatorType;
this.zxzIds = zxzIds; this.zxzIds = zxzIds;
} }
public PointData(List<ConsumerRecord<String, String>> consumerRecords, Table table, String operatorType, Map<String, List<IdxBizPvPointProcessVariableClassification>> zxzPvIds, String notString) { public PointData(List<ConsumerRecord<String, String>> consumerRecords, Table table, String operatorType,
Map<String, List<IdxBizPvPointProcessVariableClassification>> zxzPvIds, String notString) {
this.consumerRecords = consumerRecords; this.consumerRecords = consumerRecords;
this.table = table; this.table = table;
this.operatorType = operatorType; this.operatorType = operatorType;
this.zxzPvIds = zxzPvIds; this.zxzPvIds = zxzPvIds;
} }
public Map<String, List<IdxBizPvPointProcessVariableClassification>> getZxzIdsPv() { public Map<String, List<IdxBizPvPointProcessVariableClassification>> getZxzIdsPv() {
return zxzPvIds; return zxzPvIds;
} }
...@@ -372,6 +403,7 @@ public class KafkaConsumerService { ...@@ -372,6 +403,7 @@ public class KafkaConsumerService {
return table; return table;
} }
} }
/** /**
* 批量消费kafka消息 【风电站 相关性】 * 批量消费kafka消息 【风电站 相关性】
* *
...@@ -386,7 +418,8 @@ public class KafkaConsumerService { ...@@ -386,7 +418,8 @@ public class KafkaConsumerService {
consumerRecords.stream().forEach(record -> { consumerRecords.stream().forEach(record -> {
Optional<?> kafkaMessage = Optional.ofNullable(record.value()); Optional<?> kafkaMessage = Optional.ofNullable(record.value());
if (kafkaMessage.isPresent()) { if (kafkaMessage.isPresent()) {
IdxBizFanPointVarCorrelation fanPointVarCorrelation = JSON.parseObject(kafkaMessage.get().toString(), IdxBizFanPointVarCorrelation.class); IdxBizFanPointVarCorrelation fanPointVarCorrelation = JSON
.parseObject(kafkaMessage.get().toString(), IdxBizFanPointVarCorrelation.class);
Set<String> idSet = null; Set<String> idSet = null;
if (gatewayPoints.containsKey(fanPointVarCorrelation.getAnalysisGatewayId())) { if (gatewayPoints.containsKey(fanPointVarCorrelation.getAnalysisGatewayId())) {
idSet = gatewayPoints.get(fanPointVarCorrelation.getAnalysisGatewayId()); idSet = gatewayPoints.get(fanPointVarCorrelation.getAnalysisGatewayId());
...@@ -419,7 +452,8 @@ public class KafkaConsumerService { ...@@ -419,7 +452,8 @@ public class KafkaConsumerService {
consumerRecords.stream().forEach(record -> { consumerRecords.stream().forEach(record -> {
Optional<?> kafkaMessage = Optional.ofNullable(record.value()); Optional<?> kafkaMessage = Optional.ofNullable(record.value());
if (kafkaMessage.isPresent()) { if (kafkaMessage.isPresent()) {
IdxBizPvPointVarCorrelation pvPointVarCorrelation = JSON.parseObject(kafkaMessage.get().toString(), IdxBizPvPointVarCorrelation.class); IdxBizPvPointVarCorrelation pvPointVarCorrelation = JSON.parseObject(kafkaMessage.get().toString(),
IdxBizPvPointVarCorrelation.class);
Set<String> idSet = null; Set<String> idSet = null;
if (gatewayPoints.containsKey(pvPointVarCorrelation.getAnalysisGatewayId())) { if (gatewayPoints.containsKey(pvPointVarCorrelation.getAnalysisGatewayId())) {
idSet = gatewayPoints.get(pvPointVarCorrelation.getAnalysisGatewayId()); idSet = gatewayPoints.get(pvPointVarCorrelation.getAnalysisGatewayId());
...@@ -437,8 +471,9 @@ public class KafkaConsumerService { ...@@ -437,8 +471,9 @@ public class KafkaConsumerService {
} }
} }
private void buildZXZExecData(List<ConsumerRecord<String, String>> consumerRecords,
private void buildZXZExecData(List<ConsumerRecord<String, String>> consumerRecords, Map<String, Set<String>> gatewayPoints, Map<String, List<IdxBizFanPointProcessVariableClassification>> zxzIds, String xgxPvConsumer) { Map<String, Set<String>> gatewayPoints,
Map<String, List<IdxBizFanPointProcessVariableClassification>> zxzIds, String xgxPvConsumer) {
for (String gatewayId : gatewayPoints.keySet()) { for (String gatewayId : gatewayPoints.keySet()) {
String join = String.join(",", gatewayPoints.get(gatewayId)); String join = String.join(",", gatewayPoints.get(gatewayId));
List<IndicatorData> indicatorData = indicatorDataMapper.selectByAddresses(join, gatewayId); List<IndicatorData> indicatorData = indicatorDataMapper.selectByAddresses(join, gatewayId);
...@@ -458,7 +493,8 @@ public class KafkaConsumerService { ...@@ -458,7 +493,8 @@ public class KafkaConsumerService {
} }
} }
private void buildExecData(List<ConsumerRecord<String, String>> consumerRecords, Map<String, Set<String>> gatewayPoints, String xgxPvConsumer) { private void buildExecData(List<ConsumerRecord<String, String>> consumerRecords,
Map<String, Set<String>> gatewayPoints, String xgxPvConsumer) {
for (String gatewayId : gatewayPoints.keySet()) { for (String gatewayId : gatewayPoints.keySet()) {
String join = String.join(",", gatewayPoints.get(gatewayId)); String join = String.join(",", gatewayPoints.get(gatewayId));
List<IndicatorData> indicatorData = indicatorDataMapper.selectByAddresses(join, gatewayId); List<IndicatorData> indicatorData = indicatorDataMapper.selectByAddresses(join, gatewayId);
...@@ -478,7 +514,6 @@ public class KafkaConsumerService { ...@@ -478,7 +514,6 @@ public class KafkaConsumerService {
} }
} }
/** /**
* 批量消费kafka消息 【风电 工况划分 】 * 批量消费kafka消息 【风电 工况划分 】
* *
...@@ -493,7 +528,8 @@ public class KafkaConsumerService { ...@@ -493,7 +528,8 @@ public class KafkaConsumerService {
consumerRecords.stream().forEach(record -> { consumerRecords.stream().forEach(record -> {
Optional<?> kafkaMessage = Optional.ofNullable(record.value()); Optional<?> kafkaMessage = Optional.ofNullable(record.value());
if (kafkaMessage.isPresent()) { if (kafkaMessage.isPresent()) {
IdxBizFanPointProcessVariableClassification fanPointProcessVariable = JSON.parseObject(kafkaMessage.get().toString(), IdxBizFanPointProcessVariableClassification.class); IdxBizFanPointProcessVariableClassification fanPointProcessVariable = JSON.parseObject(
kafkaMessage.get().toString(), IdxBizFanPointProcessVariableClassification.class);
Set<String> idSet = null; Set<String> idSet = null;
if (gatewayPoints.containsKey(fanPointProcessVariable.getGatewayId())) { if (gatewayPoints.containsKey(fanPointProcessVariable.getGatewayId())) {
idSet = gatewayPoints.get(fanPointProcessVariable.getGatewayId()); idSet = gatewayPoints.get(fanPointProcessVariable.getGatewayId());
...@@ -510,26 +546,30 @@ public class KafkaConsumerService { ...@@ -510,26 +546,30 @@ public class KafkaConsumerService {
} }
} }
/** /**
* 风电 工况划分 处理 * 风电 工况划分 处理
*
* @param consumerRecords * @param consumerRecords
* @param table * @param table
* @return * @return
*/ */
boolean consumerRecordsGKFXFan(List<ConsumerRecord<String, String>> consumerRecords, Table table) { boolean consumerRecordsGKFXFan(List<ConsumerRecord<String, String>> consumerRecords, Table table) {
redisUtils.expire(kafkaTopicConsumerGKHFFan, 600);
try { try {
consumerRecords.parallelStream().forEach(record -> { consumerRecords.parallelStream().forEach(record -> {
Optional<?> kafkaMessage = Optional.ofNullable(record.value()); Optional<?> kafkaMessage = Optional.ofNullable(record.value());
if (kafkaMessage.isPresent()) { if (kafkaMessage.isPresent()) {
IdxBizFanPointProcessVariableClassification fanPointVarCorrelation = JSON.parseObject(kafkaMessage.get().toString(), IdxBizFanPointProcessVariableClassification.class); IdxBizFanPointProcessVariableClassification fanPointVarCorrelation = JSON.parseObject(
kafkaMessage.get().toString(), IdxBizFanPointProcessVariableClassification.class);
HashMap<String, Object> resultMap = new HashMap<>(); HashMap<String, Object> resultMap = new HashMap<>();
Selection selection = table.stringColumn("id").isEqualTo(fanPointVarCorrelation.getIndexAddress() + "_" + fanPointVarCorrelation.getGatewayId()); Selection selection = table.stringColumn("id").isEqualTo(
fanPointVarCorrelation.getIndexAddress() + "_" + fanPointVarCorrelation.getGatewayId());
double[] data1 = table.where(selection).doubleColumn("value").asDoubleArray(); double[] data1 = table.where(selection).doubleColumn("value").asDoubleArray();
resultMap.put("processVariable", data1); resultMap.put("processVariable", data1);
resultMap.put("processVariableId", fanPointVarCorrelation.getSequenceNbr()); resultMap.put("processVariableId", fanPointVarCorrelation.getSequenceNbr());
String response = HttpUtil.createPost(baseUrlGKHF).body(JSON.toJSONString(resultMap)).execute().body(); String response = HttpUtil.createPost(baseUrlGKHF).body(JSON.toJSONString(resultMap)).execute()
.body();
if (response.contains("intervalValue1") && response.contains("processVariableId")) { if (response.contains("intervalValue1") && response.contains("processVariableId")) {
com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(response); com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(response);
...@@ -539,7 +579,8 @@ public class KafkaConsumerService { ...@@ -539,7 +579,8 @@ public class KafkaConsumerService {
fanPointVarCorrelation.setIntervalValue3(jsonObject.getDoubleValue("intervalValue3")); fanPointVarCorrelation.setIntervalValue3(jsonObject.getDoubleValue("intervalValue3"));
fanPointVarCorrelation.setIntervalValue2(jsonObject.getDoubleValue("intervalValue2")); fanPointVarCorrelation.setIntervalValue2(jsonObject.getDoubleValue("intervalValue2"));
fanPointVarCorrelation.setIntervalValue1(jsonObject.getDoubleValue("intervalValue1")); fanPointVarCorrelation.setIntervalValue1(jsonObject.getDoubleValue("intervalValue1"));
log.info("------------------------------------------光伏相关性::计算成功,待更新表数据----------------------------------------"); log.info(
"------------------------------------------风电工况划分::计算成功,待更新表数据----------------------------------------");
} else { } else {
fanPointVarCorrelation.setIntervalValue5(0.0); fanPointVarCorrelation.setIntervalValue5(0.0);
fanPointVarCorrelation.setIntervalValue4(0.0); fanPointVarCorrelation.setIntervalValue4(0.0);
...@@ -555,13 +596,11 @@ public class KafkaConsumerService { ...@@ -555,13 +596,11 @@ public class KafkaConsumerService {
} catch (Exception e) { } catch (Exception e) {
log.error("kafka失败,当前失败的批次"); log.error("kafka失败,当前失败的批次");
} finally { } finally {
redisUtils.expire(kafkaTopicConsumerGKHFFan, 600); /////redisUtils.del(kafkaTopicConsumerGKHFFan);
} }
return true; return true;
} }
/** /**
* 批量消费kafka消息 【光伏 工况划分 】 * 批量消费kafka消息 【光伏 工况划分 】
* *
...@@ -577,7 +616,8 @@ public class KafkaConsumerService { ...@@ -577,7 +616,8 @@ public class KafkaConsumerService {
consumerRecords.stream().forEach(record -> { consumerRecords.stream().forEach(record -> {
Optional<?> kafkaMessage = Optional.ofNullable(record.value()); Optional<?> kafkaMessage = Optional.ofNullable(record.value());
if (kafkaMessage.isPresent()) { if (kafkaMessage.isPresent()) {
IdxBizPvPointProcessVariableClassification pvPointProcessVariable = JSON.parseObject(kafkaMessage.get().toString(), IdxBizPvPointProcessVariableClassification.class); IdxBizPvPointProcessVariableClassification pvPointProcessVariable = JSON.parseObject(
kafkaMessage.get().toString(), IdxBizPvPointProcessVariableClassification.class);
Set<String> idSet = null; Set<String> idSet = null;
if (gatewayPoints.containsKey(pvPointProcessVariable.getGatewayId())) { if (gatewayPoints.containsKey(pvPointProcessVariable.getGatewayId())) {
idSet = gatewayPoints.get(pvPointProcessVariable.getGatewayId()); idSet = gatewayPoints.get(pvPointProcessVariable.getGatewayId());
...@@ -594,26 +634,29 @@ public class KafkaConsumerService { ...@@ -594,26 +634,29 @@ public class KafkaConsumerService {
} }
} }
/** /**
* 风电 工况划分 处理 * 风电 工况划分 处理
*
* @param consumerRecords * @param consumerRecords
* @return * @return
*/ */
boolean consumerRecordsGKFXPv(List<ConsumerRecord<String, String>> consumerRecords, Table table) { boolean consumerRecordsGKFXPv(List<ConsumerRecord<String, String>> consumerRecords, Table table) {
redisUtils.expire(kafkaTopicConsumerGKHFPv, 600);
try { try {
consumerRecords.parallelStream().forEach(record -> { consumerRecords.parallelStream().forEach(record -> {
Optional<?> kafkaMessage = Optional.ofNullable(record.value()); Optional<?> kafkaMessage = Optional.ofNullable(record.value());
if (kafkaMessage.isPresent()) { if (kafkaMessage.isPresent()) {
IdxBizPvPointProcessVariableClassification pvPointVarCorrelation = JSON.parseObject(kafkaMessage.get().toString(), IdxBizPvPointProcessVariableClassification.class); IdxBizPvPointProcessVariableClassification pvPointVarCorrelation = JSON.parseObject(
kafkaMessage.get().toString(), IdxBizPvPointProcessVariableClassification.class);
HashMap<String, Object> resultMap = new HashMap<>(); HashMap<String, Object> resultMap = new HashMap<>();
Selection selection = table.stringColumn("id").isEqualTo(pvPointVarCorrelation.getIndexAddress() + "_" + pvPointVarCorrelation.getGatewayId()); Selection selection = table.stringColumn("id").isEqualTo(
pvPointVarCorrelation.getIndexAddress() + "_" + pvPointVarCorrelation.getGatewayId());
double[] data1 = table.where(selection).doubleColumn("value").asDoubleArray(); double[] data1 = table.where(selection).doubleColumn("value").asDoubleArray();
resultMap.put("processVariable", data1); resultMap.put("processVariable", data1);
resultMap.put("processVariableId", pvPointVarCorrelation.getSequenceNbr()); resultMap.put("processVariableId", pvPointVarCorrelation.getSequenceNbr());
String response = HttpUtil.createPost(baseUrlGKHF).body(JSON.toJSONString(resultMap)).execute().body(); String response = HttpUtil.createPost(baseUrlGKHF).body(JSON.toJSONString(resultMap)).execute()
.body();
if (response.contains("intervalValue1") && response.contains("processVariableId")) { if (response.contains("intervalValue1") && response.contains("processVariableId")) {
com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(response); com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(response);
...@@ -623,7 +666,8 @@ public class KafkaConsumerService { ...@@ -623,7 +666,8 @@ public class KafkaConsumerService {
pvPointVarCorrelation.setIntervalValue3(jsonObject.getDoubleValue("intervalValue3")); pvPointVarCorrelation.setIntervalValue3(jsonObject.getDoubleValue("intervalValue3"));
pvPointVarCorrelation.setIntervalValue2(jsonObject.getDoubleValue("intervalValue2")); pvPointVarCorrelation.setIntervalValue2(jsonObject.getDoubleValue("intervalValue2"));
pvPointVarCorrelation.setIntervalValue1(jsonObject.getDoubleValue("intervalValue1")); pvPointVarCorrelation.setIntervalValue1(jsonObject.getDoubleValue("intervalValue1"));
log.info("------------------------------------------光伏相关性::计算成功,待更新表数据----------------------------------------"); log.info(
"------------------------------------------光伏工况划分::计算成功,待更新表数据----------------------------------------");
} else { } else {
pvPointVarCorrelation.setIntervalValue5(0.0); pvPointVarCorrelation.setIntervalValue5(0.0);
pvPointVarCorrelation.setIntervalValue4(0.0); pvPointVarCorrelation.setIntervalValue4(0.0);
...@@ -639,19 +683,11 @@ public class KafkaConsumerService { ...@@ -639,19 +683,11 @@ public class KafkaConsumerService {
} catch (Exception e) { } catch (Exception e) {
log.error("kafka失败,当前失败的批次"); log.error("kafka失败,当前失败的批次");
} finally { } finally {
redisUtils.expire(kafkaTopicConsumerGKHFPv, 600); ////redisUtils.del(kafkaTopicConsumerGKHFPv);
} }
return true; return true;
} }
/** /**
* 批量消费kafka消息 【风电 中心值 】 * 批量消费kafka消息 【风电 中心值 】
* *
...@@ -667,15 +703,25 @@ public class KafkaConsumerService { ...@@ -667,15 +703,25 @@ public class KafkaConsumerService {
consumerRecords.stream().forEach(record -> { consumerRecords.stream().forEach(record -> {
Optional<?> kafkaMessage = Optional.ofNullable(record.value()); Optional<?> kafkaMessage = Optional.ofNullable(record.value());
if (kafkaMessage.isPresent()) { if (kafkaMessage.isPresent()) {
IdxBizFanPointProcessVariableClassification fanPointProcessVariable = JSON.parseObject(kafkaMessage.get().toString(), IdxBizFanPointProcessVariableClassification.class); IdxBizFanPointProcessVariableClassification fanPointProcessVariable = JSON.parseObject(
kafkaMessage.get().toString(), IdxBizFanPointProcessVariableClassification.class);
List<IdxBizFanPointVarCorrelation> gongkuangList = idxBizFanPointVarCorrelationService.list(new QueryWrapper<IdxBizFanPointVarCorrelation>().eq("ANALYSIS_GATEWAY_ID", fanPointProcessVariable.getGatewayId()).eq("ANALYSIS_POINT_ID", fanPointProcessVariable.getSequenceNbr()).orderByDesc("CORRELATION_COEFFICIENT").last("limit 3"));
List<String> processPointIds = gongkuangList.stream().map(idxBizFanPointVarCorrelation -> idxBizFanPointVarCorrelation.getProcessPointId().toString()).collect(Collectors.toList()); List<IdxBizFanPointVarCorrelation> gongkuangList = idxBizFanPointVarCorrelationService
List<IdxBizFanPointProcessVariableClassification> idxBizFanPointProcessVariableClassificationList = idxBizFanPointProcessVariableClassificationService.list(new QueryWrapper<IdxBizFanPointProcessVariableClassification>().in("SEQUENCE_NBR", processPointIds)); .list(new QueryWrapper<IdxBizFanPointVarCorrelation>()
.eq("ANALYSIS_GATEWAY_ID", fanPointProcessVariable.getGatewayId())
.eq("ANALYSIS_POINT_ID", fanPointProcessVariable.getSequenceNbr())
.orderByDesc("CORRELATION_COEFFICIENT").last("limit 3"));
List<String> processPointIds = gongkuangList.stream().map(
idxBizFanPointVarCorrelation -> idxBizFanPointVarCorrelation.getProcessPointId().toString())
.collect(Collectors.toList());
List<IdxBizFanPointProcessVariableClassification> idxBizFanPointProcessVariableClassificationList = idxBizFanPointProcessVariableClassificationService
.list(new QueryWrapper<IdxBizFanPointProcessVariableClassification>().in("SEQUENCE_NBR",
processPointIds));
idxBizFanPointProcessVariableClassificationList.add(fanPointProcessVariable); idxBizFanPointProcessVariableClassificationList.add(fanPointProcessVariable);
zxzIds.put(fanPointProcessVariable.getSequenceNbr(), idxBizFanPointProcessVariableClassificationList); zxzIds.put(fanPointProcessVariable.getSequenceNbr(),
idxBizFanPointProcessVariableClassificationList);
idxBizFanPointProcessVariableClassificationList.forEach(item -> { idxBizFanPointProcessVariableClassificationList.forEach(item -> {
Set<String> idSet = null; Set<String> idSet = null;
...@@ -696,13 +742,6 @@ public class KafkaConsumerService { ...@@ -696,13 +742,6 @@ public class KafkaConsumerService {
} }
} }
/** /**
* 批量消费kafka消息 【光伏 中心值 】 * 批量消费kafka消息 【光伏 中心值 】
* *
...@@ -718,11 +757,20 @@ public class KafkaConsumerService { ...@@ -718,11 +757,20 @@ public class KafkaConsumerService {
consumerRecords.stream().forEach(record -> { consumerRecords.stream().forEach(record -> {
Optional<?> kafkaMessage = Optional.ofNullable(record.value()); Optional<?> kafkaMessage = Optional.ofNullable(record.value());
if (kafkaMessage.isPresent()) { if (kafkaMessage.isPresent()) {
IdxBizPvPointProcessVariableClassification pvPointProcessVariable = JSON.parseObject(kafkaMessage.get().toString(), IdxBizPvPointProcessVariableClassification.class); IdxBizPvPointProcessVariableClassification pvPointProcessVariable = JSON.parseObject(
kafkaMessage.get().toString(), IdxBizPvPointProcessVariableClassification.class);
List<IdxBizPvPointVarCorrelation> gongkuangList = idxBizPvPointVarCorrelationService.list(new QueryWrapper<IdxBizPvPointVarCorrelation>().eq("ANALYSIS_GATEWAY_ID", pvPointProcessVariable.getGatewayId()).eq("ANALYSIS_POINT_ID", pvPointProcessVariable.getSequenceNbr()).orderByDesc("CORRELATION_COEFFICIENT").last("limit 3"));
List<String> processPointIds = gongkuangList.stream().map(idxBizFanPointVarCorrelation -> idxBizFanPointVarCorrelation.getProcessPointId().toString()).collect(Collectors.toList()); List<IdxBizPvPointVarCorrelation> gongkuangList = idxBizPvPointVarCorrelationService
List<IdxBizPvPointProcessVariableClassification> idxBizPvPointProcessVariableClassificationList = idxBizPvPointProcessVariableClassificationService.list(new QueryWrapper<IdxBizPvPointProcessVariableClassification>().in("SEQUENCE_NBR", processPointIds)); .list(new QueryWrapper<IdxBizPvPointVarCorrelation>()
.eq("ANALYSIS_GATEWAY_ID", pvPointProcessVariable.getGatewayId())
.eq("ANALYSIS_POINT_ID", pvPointProcessVariable.getSequenceNbr())
.orderByDesc("CORRELATION_COEFFICIENT").last("limit 3"));
List<String> processPointIds = gongkuangList.stream().map(
idxBizFanPointVarCorrelation -> idxBizFanPointVarCorrelation.getProcessPointId().toString())
.collect(Collectors.toList());
List<IdxBizPvPointProcessVariableClassification> idxBizPvPointProcessVariableClassificationList = idxBizPvPointProcessVariableClassificationService
.list(new QueryWrapper<IdxBizPvPointProcessVariableClassification>().in("SEQUENCE_NBR",
processPointIds));
idxBizPvPointProcessVariableClassificationList.add(pvPointProcessVariable); idxBizPvPointProcessVariableClassificationList.add(pvPointProcessVariable);
...@@ -747,8 +795,9 @@ public class KafkaConsumerService { ...@@ -747,8 +795,9 @@ public class KafkaConsumerService {
} }
} }
private void buildZXZPvExecData(List<ConsumerRecord<String, String>> consumerRecords,
private void buildZXZPvExecData(List<ConsumerRecord<String, String>> consumerRecords, Map<String, Set<String>> gatewayPoints, Map<String, List<IdxBizPvPointProcessVariableClassification>> zxzIds, String xgxPvConsumer) { Map<String, Set<String>> gatewayPoints,
Map<String, List<IdxBizPvPointProcessVariableClassification>> zxzIds, String xgxPvConsumer) {
for (String gatewayId : gatewayPoints.keySet()) { for (String gatewayId : gatewayPoints.keySet()) {
String join = String.join(",", gatewayPoints.get(gatewayId)); String join = String.join(",", gatewayPoints.get(gatewayId));
List<IndicatorData> indicatorData = indicatorDataMapper.selectByAddresses(join, gatewayId); List<IndicatorData> indicatorData = indicatorDataMapper.selectByAddresses(join, gatewayId);
...@@ -768,21 +817,24 @@ public class KafkaConsumerService { ...@@ -768,21 +817,24 @@ public class KafkaConsumerService {
} }
} }
/** /**
* 中心值 - 光伏 * 中心值 - 光伏
*
* @param consumerRecords * @param consumerRecords
* @param pointsData * @param pointsData
*/ */
private void consumerRecordsZXZPv(List<ConsumerRecord<String, String>> consumerRecords, PointData pointsData ) { private void consumerRecordsZXZPv(List<ConsumerRecord<String, String>> consumerRecords, PointData pointsData) {
redisUtils.expire(kafkaTopicConsumerZXZPv, 600);
Table table = pointsData.getTable(); Table table = pointsData.getTable();
Map<String, List<IdxBizPvPointProcessVariableClassification>> zxzIds = pointsData.getZxzIdsPv(); Map<String, List<IdxBizPvPointProcessVariableClassification>> zxzIds = pointsData.getZxzIdsPv();
for (String id : zxzIds.keySet()) { for (String id : zxzIds.keySet()) {
List<IdxBizPvPointProcessVariableClassification> variableClassificationList = zxzIds.get(id); List<IdxBizPvPointProcessVariableClassification> variableClassificationList = zxzIds.get(id);
String analysisVariableId = id; String analysisVariableId = id;
List<IdxBizPvPointProcessVariableClassification> processVariableList = variableClassificationList.stream().filter(v -> !id.equals(v.getSequenceNbr().toString())).collect(Collectors.toList()); List<IdxBizPvPointProcessVariableClassification> processVariableList = variableClassificationList.stream()
IdxBizPvPointProcessVariableClassification analysisVariable = variableClassificationList.stream().filter(v -> id.equals(v.getSequenceNbr().toString())).findFirst().get(); .filter(v -> !id.equals(v.getSequenceNbr().toString())).collect(Collectors.toList());
IdxBizPvPointProcessVariableClassification analysisVariable = variableClassificationList.stream()
.filter(v -> id.equals(v.getSequenceNbr().toString())).findFirst().get();
Map<String, Object> data1 = new HashMap<>(); Map<String, Object> data1 = new HashMap<>();
Map<String, Object> data2 = new HashMap<>(); Map<String, Object> data2 = new HashMap<>();
...@@ -790,7 +842,8 @@ public class KafkaConsumerService { ...@@ -790,7 +842,8 @@ public class KafkaConsumerService {
Table dataTable = Table.create(); Table dataTable = Table.create();
int minRow = 0; int minRow = 0;
for (IdxBizPvPointProcessVariableClassification processVariable : processVariableList) { for (IdxBizPvPointProcessVariableClassification processVariable : processVariableList) {
Selection selection = table.stringColumn("id").isEqualTo(processVariable.getIndexAddress() + "_" + processVariable.getGatewayId()); Selection selection = table.stringColumn("id")
.isEqualTo(processVariable.getIndexAddress() + "_" + processVariable.getGatewayId());
DoubleColumn values = table.where(selection).doubleColumn("value"); DoubleColumn values = table.where(selection).doubleColumn("value");
// 获取最小数据长度 // 获取最小数据长度
if (index == 1) { if (index == 1) {
...@@ -813,7 +866,8 @@ public class KafkaConsumerService { ...@@ -813,7 +866,8 @@ public class KafkaConsumerService {
index++; index++;
} }
Selection selection = table.stringColumn("id").isEqualTo(analysisVariable.getIndexAddress() + "_" + analysisVariable.getGatewayId()); Selection selection = table.stringColumn("id")
.isEqualTo(analysisVariable.getIndexAddress() + "_" + analysisVariable.getGatewayId());
DoubleColumn values = table.where(selection).doubleColumn("value"); DoubleColumn values = table.where(selection).doubleColumn("value");
values.setName("analysisVariable"); values.setName("analysisVariable");
dataTable = getDataTable(dataTable, values); dataTable = getDataTable(dataTable, values);
...@@ -827,25 +881,39 @@ public class KafkaConsumerService { ...@@ -827,25 +881,39 @@ public class KafkaConsumerService {
data1.put(column, dataTable.doubleColumn(column).asDoubleArray()); data1.put(column, dataTable.doubleColumn(column).asDoubleArray());
} }
Map<String,Object> requestMap = new HashMap<>(); Map<String, Object> requestMap = new HashMap<>();
requestMap.put("data1", data1); requestMap.put("data1", data1);
requestMap.put("data2", data2); requestMap.put("data2", data2);
String response = HttpUtil.createPost(zxzJsUrlFanBySF).body(JSON.toJSONString(requestMap)).execute().body(); String response = HttpUtil.createPost(zxzJsUrlFanBySF).body(JSON.toJSONString(requestMap)).execute().body();
if (response.contains("stdDev")) { if (response.contains("stdDev")) {
idxBizPvPointVarCentralValueMapper.delete(new QueryWrapper<IdxBizPvPointVarCentralValue>().eq("ANALYSIS_POINT_ID", analysisVariable.getSequenceNbr())); idxBizPvPointVarCentralValueMapper.delete(new QueryWrapper<IdxBizPvPointVarCentralValue>()
.eq("ANALYSIS_POINT_ID", analysisVariable.getSequenceNbr()));
JSONObject jsonObject = JSON.parseObject(response); JSONObject jsonObject = JSON.parseObject(response);
int length = jsonObject.getJSONArray("stdDev").size() > 64 ? 64 : jsonObject.getJSONArray("stdDev").size(); int length = jsonObject.getJSONArray("stdDev").size() > 64 ? 64
: jsonObject.getJSONArray("stdDev").size();
List<IdxBizPvPointVarCentralValue> insertList = new ArrayList<>(); List<IdxBizPvPointVarCentralValue> insertList = new ArrayList<>();
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
IdxBizPvPointVarCentralValue idxBizPvPointVarCentralValue = new IdxBizPvPointVarCentralValue(); IdxBizPvPointVarCentralValue idxBizPvPointVarCentralValue = new IdxBizPvPointVarCentralValue();
idxBizPvPointVarCentralValue.setProcess1Min(ObjectUtils.isNull(jsonObject.getJSONArray("process1Min").get(i)) ? null : jsonObject.getJSONArray("process1Min").getDoubleValue(i)); idxBizPvPointVarCentralValue
idxBizPvPointVarCentralValue.setProcess2Min(ObjectUtils.isNull(jsonObject.getJSONArray("process2Min").get(i)) ? null : jsonObject.getJSONArray("process2Min").getDoubleValue(i)); .setProcess1Min(ObjectUtils.isNull(jsonObject.getJSONArray("process1Min").get(i)) ? null
idxBizPvPointVarCentralValue.setProcess3Min(ObjectUtils.isNull(jsonObject.getJSONArray("process3Min").get(i)) ? null : jsonObject.getJSONArray("process3Min").getDoubleValue(i)); : jsonObject.getJSONArray("process1Min").getDoubleValue(i));
idxBizPvPointVarCentralValue.setProcess1Max(ObjectUtils.isNull(jsonObject.getJSONArray("process1Max").get(i)) ? null : jsonObject.getJSONArray("process1Max").getDoubleValue(i)); idxBizPvPointVarCentralValue
idxBizPvPointVarCentralValue.setProcess2Max(ObjectUtils.isNull(jsonObject.getJSONArray("process2Max").get(i)) ? null : jsonObject.getJSONArray("process2Max").getDoubleValue(i)); .setProcess2Min(ObjectUtils.isNull(jsonObject.getJSONArray("process2Min").get(i)) ? null
idxBizPvPointVarCentralValue.setProcess3Max(ObjectUtils.isNull(jsonObject.getJSONArray("process3Max").get(i)) ? null : jsonObject.getJSONArray("process3Max").getDoubleValue(i)); : jsonObject.getJSONArray("process2Min").getDoubleValue(i));
idxBizPvPointVarCentralValue
.setProcess3Min(ObjectUtils.isNull(jsonObject.getJSONArray("process3Min").get(i)) ? null
: jsonObject.getJSONArray("process3Min").getDoubleValue(i));
idxBizPvPointVarCentralValue
.setProcess1Max(ObjectUtils.isNull(jsonObject.getJSONArray("process1Max").get(i)) ? null
: jsonObject.getJSONArray("process1Max").getDoubleValue(i));
idxBizPvPointVarCentralValue
.setProcess2Max(ObjectUtils.isNull(jsonObject.getJSONArray("process2Max").get(i)) ? null
: jsonObject.getJSONArray("process2Max").getDoubleValue(i));
idxBizPvPointVarCentralValue
.setProcess3Max(ObjectUtils.isNull(jsonObject.getJSONArray("process3Max").get(i)) ? null
: jsonObject.getJSONArray("process3Max").getDoubleValue(i));
idxBizPvPointVarCentralValue.setAnalysisPointId(jsonObject.getString("analysisVariableId")); idxBizPvPointVarCentralValue.setAnalysisPointId(jsonObject.getString("analysisVariableId"));
idxBizPvPointVarCentralValue.setAnalysisPointIdName(analysisVariable.getPointName()); idxBizPvPointVarCentralValue.setAnalysisPointIdName(analysisVariable.getPointName());
idxBizPvPointVarCentralValue.setProcessPoint1Id(jsonObject.getString("processVariable1Id")); idxBizPvPointVarCentralValue.setProcessPoint1Id(jsonObject.getString("processVariable1Id"));
...@@ -854,8 +922,12 @@ public class KafkaConsumerService { ...@@ -854,8 +922,12 @@ public class KafkaConsumerService {
idxBizPvPointVarCentralValue.setProcessPoint2IdName(processVariableList.get(1).getPointName()); idxBizPvPointVarCentralValue.setProcessPoint2IdName(processVariableList.get(1).getPointName());
idxBizPvPointVarCentralValue.setProcessPoint3Id(jsonObject.getString("processVariable3Id")); idxBizPvPointVarCentralValue.setProcessPoint3Id(jsonObject.getString("processVariable3Id"));
idxBizPvPointVarCentralValue.setProcessPoint3IdName(processVariableList.get(2).getPointName()); idxBizPvPointVarCentralValue.setProcessPoint3IdName(processVariableList.get(2).getPointName());
idxBizPvPointVarCentralValue.setAnalysisStdDev(ObjectUtils.isNull(jsonObject.getJSONArray("stdDev").get(i)) ? null : jsonObject.getJSONArray("stdDev").getDoubleValue(i)); idxBizPvPointVarCentralValue
idxBizPvPointVarCentralValue.setAnalysisCenterValue(ObjectUtils.isNull(jsonObject.getJSONArray("centerValue").get(i)) ? null : jsonObject.getJSONArray("centerValue").getDoubleValue(i)); .setAnalysisStdDev(ObjectUtils.isNull(jsonObject.getJSONArray("stdDev").get(i)) ? null
: jsonObject.getJSONArray("stdDev").getDoubleValue(i));
idxBizPvPointVarCentralValue.setAnalysisCenterValue(
ObjectUtils.isNull(jsonObject.getJSONArray("centerValue").get(i)) ? null
: jsonObject.getJSONArray("centerValue").getDoubleValue(i));
idxBizPvPointVarCentralValue.setArae(analysisVariable.getArae()); idxBizPvPointVarCentralValue.setArae(analysisVariable.getArae());
idxBizPvPointVarCentralValue.setStation(analysisVariable.getStation()); idxBizPvPointVarCentralValue.setStation(analysisVariable.getStation());
idxBizPvPointVarCentralValue.setSubarray(analysisVariable.getSubarray()); idxBizPvPointVarCentralValue.setSubarray(analysisVariable.getSubarray());
...@@ -869,32 +941,12 @@ public class KafkaConsumerService { ...@@ -869,32 +941,12 @@ public class KafkaConsumerService {
} }
} }
redisUtils.expire(kafkaTopicConsumerZXZPv, 600); //redisUtils.del(kafkaTopicConsumerZXZPv);
} }
/** /**
* 风电处理消息 - 弃用 * 风电处理消息 - 弃用
*
* @param consumerRecord * @param consumerRecord
* @return * @return
*/ */
...@@ -903,15 +955,22 @@ public class KafkaConsumerService { ...@@ -903,15 +955,22 @@ public class KafkaConsumerService {
try { try {
Optional<?> kafkaMessage = Optional.ofNullable(consumerRecord.value()); Optional<?> kafkaMessage = Optional.ofNullable(consumerRecord.value());
if (kafkaMessage.isPresent()) { if (kafkaMessage.isPresent()) {
IdxBizFanPointVarCorrelation fanPointVarCorrelation = JSON.parseObject(kafkaMessage.get().toString(), IdxBizFanPointVarCorrelation.class); IdxBizFanPointVarCorrelation fanPointVarCorrelation = JSON.parseObject(kafkaMessage.get().toString(),
IdxBizFanPointVarCorrelation.class);
List<IndicatorData> tdengineData1 = indicatorDataMapper.selectDataById(fanPointVarCorrelation.getAnalysisIndexAddress() + "_" + fanPointVarCorrelation.getAnalysisGatewayId()); List<IndicatorData> tdengineData1 = indicatorDataMapper
.selectDataById(fanPointVarCorrelation.getAnalysisIndexAddress() + "_"
+ fanPointVarCorrelation.getAnalysisGatewayId());
// List<IndicatorData> tdengineData1 = indicatorDataMapper.selectDataByAddressAndtimeNotDate(fanPointVarCorrelation.getAnalysisIndexAddress(), fanPointVarCorrelation.getAnalysisGatewayId()); // List<IndicatorData> tdengineData1 = indicatorDataMapper.selectDataByAddressAndtimeNotDate(fanPointVarCorrelation.getAnalysisIndexAddress(), fanPointVarCorrelation.getAnalysisGatewayId());
List<IndicatorData> tdengineData2 = indicatorDataMapper.selectDataById(fanPointVarCorrelation.getProcessIndexAddress() + "_" + fanPointVarCorrelation.getProcessGatewayId()); List<IndicatorData> tdengineData2 = indicatorDataMapper
.selectDataById(fanPointVarCorrelation.getProcessIndexAddress() + "_"
+ fanPointVarCorrelation.getProcessGatewayId());
// List<IndicatorData> tdengineData2 = indicatorDataMapper.selectDataByAddressAndtimeNotDate(fanPointVarCorrelation.getProcessIndexAddress(), fanPointVarCorrelation.getProcessGatewayId()); // List<IndicatorData> tdengineData2 = indicatorDataMapper.selectDataByAddressAndtimeNotDate(fanPointVarCorrelation.getProcessIndexAddress(), fanPointVarCorrelation.getProcessGatewayId());
List<Double> data1 = tdengineData1.stream().map(t -> Double.parseDouble(t.getValue())).collect(Collectors.toList()); List<Double> data1 = tdengineData1.stream().map(t -> Double.parseDouble(t.getValue()))
List<Double> data2 = tdengineData2.stream().map(t -> Double.parseDouble(t.getValue())).collect(Collectors.toList()); .collect(Collectors.toList());
List<Double> data2 = tdengineData2.stream().map(t -> Double.parseDouble(t.getValue()))
.collect(Collectors.toList());
// List<Double> data1 = new ArrayList<>(); // List<Double> data1 = new ArrayList<>();
// List<Double> data2 = new ArrayList<>(); // List<Double> data2 = new ArrayList<>();
...@@ -940,7 +999,8 @@ public class KafkaConsumerService { ...@@ -940,7 +999,8 @@ public class KafkaConsumerService {
if (response.contains("correlation") && !response.contains("warning")) { if (response.contains("correlation") && !response.contains("warning")) {
com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(response); com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(response);
fanPointVarCorrelation.setCorrelationCoefficient(jsonObject.getDoubleValue("correlation")); fanPointVarCorrelation.setCorrelationCoefficient(jsonObject.getDoubleValue("correlation"));
log.info("------------------------------------------风机相关性::计算成功,待更新表数据----------------------------------------"); log.info(
"------------------------------------------风机相关性::计算成功,待更新表数据----------------------------------------");
} else { } else {
fanPointVarCorrelation.setCorrelationCoefficient(0.0); fanPointVarCorrelation.setCorrelationCoefficient(0.0);
} }
...@@ -948,7 +1008,8 @@ public class KafkaConsumerService { ...@@ -948,7 +1008,8 @@ public class KafkaConsumerService {
idxBizFanPointVarCorrelationService.saveOrUpdate(fanPointVarCorrelation); idxBizFanPointVarCorrelationService.saveOrUpdate(fanPointVarCorrelation);
log.info("表数据已更新"); log.info("表数据已更新");
log.info("----------------------------风机相关性--------------分析变量与工况变量相关性分析算法结束----------------------------------------"); log.info(
"----------------------------风机相关性--------------分析变量与工况变量相关性分析算法结束----------------------------------------");
log.info("kafka消费zhTestGroup消息{}", consumerRecord); log.info("kafka消费zhTestGroup消息{}", consumerRecord);
} }
} catch (Exception e) { } catch (Exception e) {
...@@ -961,21 +1022,28 @@ public class KafkaConsumerService { ...@@ -961,21 +1022,28 @@ public class KafkaConsumerService {
/** /**
* 风电 工况划分 处理 -弃用 * 风电 工况划分 处理 -弃用
*
* @param consumerRecord * @param consumerRecord
* @return * @return
*/ */
boolean consumerRecordsGKFXFan(ConsumerRecord<String, String> consumerRecord) { boolean consumerRecordsGKFXFan(ConsumerRecord<String, String> consumerRecord) {
try { try {
String startTime = DateUtils.convertDateToString(DateUtil.offsetMonth(new Date(), -lastMonthNum), DateUtils.DATE_TIME_PATTERN); String startTime = DateUtils.convertDateToString(DateUtil.offsetMonth(new Date(), -lastMonthNum),
String endTime = DateUtils.convertDateToString(DateUtils.getCurrentDayEndTime(new Date()), DateUtils.DATE_TIME_PATTERN); DateUtils.DATE_TIME_PATTERN);
String endTime = DateUtils.convertDateToString(DateUtils.getCurrentDayEndTime(new Date()),
DateUtils.DATE_TIME_PATTERN);
Optional<?> kafkaMessage = Optional.ofNullable(consumerRecord.value()); Optional<?> kafkaMessage = Optional.ofNullable(consumerRecord.value());
if (kafkaMessage.isPresent()) { if (kafkaMessage.isPresent()) {
IdxBizFanPointProcessVariableClassification fanPointVarCorrelation = JSON.parseObject(kafkaMessage.get().toString(), IdxBizFanPointProcessVariableClassification.class); IdxBizFanPointProcessVariableClassification fanPointVarCorrelation = JSON
List<IndicatorData> tdengineData1 = indicatorDataMapper.selectDataByAddressAndtime(fanPointVarCorrelation.getIndexAddress(), startTime, endTime, fanPointVarCorrelation.getGatewayId()); .parseObject(kafkaMessage.get().toString(), IdxBizFanPointProcessVariableClassification.class);
List<IndicatorData> tdengineData1 = indicatorDataMapper.selectDataByAddressAndtime(
fanPointVarCorrelation.getIndexAddress(), startTime, endTime,
fanPointVarCorrelation.getGatewayId());
HashMap<String, Object> resultMap = new HashMap<>(); HashMap<String, Object> resultMap = new HashMap<>();
resultMap.put("processVariable", tdengineData1.stream().map(t -> Double.parseDouble(t.getValue())).collect(Collectors.toList())); resultMap.put("processVariable",
tdengineData1.stream().map(t -> Double.parseDouble(t.getValue())).collect(Collectors.toList()));
resultMap.put("processVariableId", fanPointVarCorrelation.getSequenceNbr()); resultMap.put("processVariableId", fanPointVarCorrelation.getSequenceNbr());
String response = HttpUtil.createPost(baseUrlGKHF).body(JSON.toJSONString(resultMap)).execute().body(); String response = HttpUtil.createPost(baseUrlGKHF).body(JSON.toJSONString(resultMap)).execute().body();
...@@ -987,7 +1055,8 @@ public class KafkaConsumerService { ...@@ -987,7 +1055,8 @@ public class KafkaConsumerService {
fanPointVarCorrelation.setIntervalValue3(jsonObject.getDoubleValue("intervalValue3")); fanPointVarCorrelation.setIntervalValue3(jsonObject.getDoubleValue("intervalValue3"));
fanPointVarCorrelation.setIntervalValue2(jsonObject.getDoubleValue("intervalValue2")); fanPointVarCorrelation.setIntervalValue2(jsonObject.getDoubleValue("intervalValue2"));
fanPointVarCorrelation.setIntervalValue1(jsonObject.getDoubleValue("intervalValue1")); fanPointVarCorrelation.setIntervalValue1(jsonObject.getDoubleValue("intervalValue1"));
log.info("------------------------------------------光伏相关性::计算成功,待更新表数据----------------------------------------"); log.info(
"------------------------------------------光伏相关性::计算成功,待更新表数据----------------------------------------");
} else { } else {
fanPointVarCorrelation.setIntervalValue5(0.0); fanPointVarCorrelation.setIntervalValue5(0.0);
fanPointVarCorrelation.setIntervalValue4(0.0); fanPointVarCorrelation.setIntervalValue4(0.0);
...@@ -1007,25 +1076,32 @@ public class KafkaConsumerService { ...@@ -1007,25 +1076,32 @@ public class KafkaConsumerService {
return true; return true;
} }
/** /**
* 光伏处理消息 - 弃用 * 光伏处理消息 - 弃用
*
* @param consumerRecord * @param consumerRecord
* @return * @return
*/ */
boolean consumerRecordsPv(ConsumerRecord<String, String> consumerRecord) { boolean consumerRecordsPv(ConsumerRecord<String, String> consumerRecord) {
String startTime = DateUtils.convertDateToString(DateUtil.offsetMonth(new Date(), -lastMonthNum), DateUtils.DATE_TIME_PATTERN); String startTime = DateUtils.convertDateToString(DateUtil.offsetMonth(new Date(), -lastMonthNum),
String endTime = DateUtils.convertDateToString(DateUtils.getCurrentDayEndTime(new Date()), DateUtils.DATE_TIME_PATTERN); DateUtils.DATE_TIME_PATTERN);
String endTime = DateUtils.convertDateToString(DateUtils.getCurrentDayEndTime(new Date()),
DateUtils.DATE_TIME_PATTERN);
try { try {
Optional<?> kafkaMessage = Optional.ofNullable(consumerRecord.value()); Optional<?> kafkaMessage = Optional.ofNullable(consumerRecord.value());
if (kafkaMessage.isPresent()) { if (kafkaMessage.isPresent()) {
IdxBizPvPointVarCorrelation pvPointVarCorrelation = JSON.parseObject(kafkaMessage.get().toString(), IdxBizPvPointVarCorrelation.class); IdxBizPvPointVarCorrelation pvPointVarCorrelation = JSON.parseObject(kafkaMessage.get().toString(),
List<IndicatorData> tdengineData1 = indicatorDataMapper.selectDataByAddressAndtimeNew(pvPointVarCorrelation.getAnalysisIndexAddress().toString(), startTime, endTime, pvPointVarCorrelation.getAnalysisGatewayId(), pvPointVarCorrelation.getProcessGatewayId(), pvPointVarCorrelation.getProcessIndexAddress()); IdxBizPvPointVarCorrelation.class);
List<IndicatorData> tdengineData1 = indicatorDataMapper.selectDataByAddressAndtimeNew(
pvPointVarCorrelation.getAnalysisIndexAddress().toString(), startTime, endTime,
pvPointVarCorrelation.getAnalysisGatewayId(), pvPointVarCorrelation.getProcessGatewayId(),
pvPointVarCorrelation.getProcessIndexAddress());
List<Double> data1 = new ArrayList<>(); List<Double> data1 = new ArrayList<>();
List<Double> data2 = new ArrayList<>(); List<Double> data2 = new ArrayList<>();
tdengineData1.forEach(item -> { tdengineData1.forEach(item -> {
if (item.getAddress().equals(pvPointVarCorrelation.getAnalysisIndexAddress()) && item.getGatewayId().equals(pvPointVarCorrelation.getAnalysisGatewayId())) { if (item.getAddress().equals(pvPointVarCorrelation.getAnalysisIndexAddress())
&& item.getGatewayId().equals(pvPointVarCorrelation.getAnalysisGatewayId())) {
data1.add(Double.parseDouble(item.getValue())); data1.add(Double.parseDouble(item.getValue()));
} else { } else {
data2.add(Double.parseDouble(item.getValue())); data2.add(Double.parseDouble(item.getValue()));
...@@ -1049,7 +1125,8 @@ public class KafkaConsumerService { ...@@ -1049,7 +1125,8 @@ public class KafkaConsumerService {
if (response.contains("correlation") && !response.contains("warning")) { if (response.contains("correlation") && !response.contains("warning")) {
com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(response); com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(response);
pvPointVarCorrelation.setCorrelationCoefficient(jsonObject.getDoubleValue("correlation")); pvPointVarCorrelation.setCorrelationCoefficient(jsonObject.getDoubleValue("correlation"));
log.info("------------------------------------------光伏相关性::计算成功,待更新表数据----------------------------------------"); log.info(
"------------------------------------------光伏相关性::计算成功,待更新表数据----------------------------------------");
} else { } else {
pvPointVarCorrelation.setCorrelationCoefficient(0.0); pvPointVarCorrelation.setCorrelationCoefficient(0.0);
} }
...@@ -1067,23 +1144,30 @@ public class KafkaConsumerService { ...@@ -1067,23 +1144,30 @@ public class KafkaConsumerService {
return true; return true;
} }
/** /**
* 光伏 工况划分 处理 - 弃用 * 光伏 工况划分 处理 - 弃用
*
* @param consumerRecord * @param consumerRecord
* @return * @return
*/ */
boolean consumerRecordsGKFXPv(ConsumerRecord<String, String> consumerRecord) { boolean consumerRecordsGKFXPv(ConsumerRecord<String, String> consumerRecord) {
try {String startTime = DateUtils.convertDateToString(DateUtil.offsetMonth(new Date(), -lastMonthNum), DateUtils.DATE_TIME_PATTERN); try {
String endTime = DateUtils.convertDateToString(DateUtils.getCurrentDayEndTime(new Date()), DateUtils.DATE_TIME_PATTERN); String startTime = DateUtils.convertDateToString(DateUtil.offsetMonth(new Date(), -lastMonthNum),
DateUtils.DATE_TIME_PATTERN);
String endTime = DateUtils.convertDateToString(DateUtils.getCurrentDayEndTime(new Date()),
DateUtils.DATE_TIME_PATTERN);
Optional<?> kafkaMessage = Optional.ofNullable(consumerRecord.value()); Optional<?> kafkaMessage = Optional.ofNullable(consumerRecord.value());
if (kafkaMessage.isPresent()) { if (kafkaMessage.isPresent()) {
IdxBizPvPointProcessVariableClassification pvPointVarCorrelation = JSON.parseObject(kafkaMessage.get().toString(), IdxBizPvPointProcessVariableClassification.class); IdxBizPvPointProcessVariableClassification pvPointVarCorrelation = JSON
List<IndicatorData> tdengineData1 = indicatorDataMapper.selectDataByAddressAndtime(pvPointVarCorrelation.getIndexAddress(), startTime, endTime, pvPointVarCorrelation.getGatewayId()); .parseObject(kafkaMessage.get().toString(), IdxBizPvPointProcessVariableClassification.class);
List<IndicatorData> tdengineData1 = indicatorDataMapper.selectDataByAddressAndtime(
pvPointVarCorrelation.getIndexAddress(), startTime, endTime,
pvPointVarCorrelation.getGatewayId());
HashMap<String, Object> resultMap = new HashMap<>(); HashMap<String, Object> resultMap = new HashMap<>();
resultMap.put("processVariable", tdengineData1.stream().map(t -> Double.parseDouble(t.getValue())).collect(Collectors.toList())); resultMap.put("processVariable",
tdengineData1.stream().map(t -> Double.parseDouble(t.getValue())).collect(Collectors.toList()));
resultMap.put("processVariableId", pvPointVarCorrelation.getSequenceNbr()); resultMap.put("processVariableId", pvPointVarCorrelation.getSequenceNbr());
String response = HttpUtil.createPost(baseUrlGKHF).body(JSON.toJSONString(resultMap)).execute().body(); String response = HttpUtil.createPost(baseUrlGKHF).body(JSON.toJSONString(resultMap)).execute().body();
...@@ -1095,7 +1179,8 @@ public class KafkaConsumerService { ...@@ -1095,7 +1179,8 @@ public class KafkaConsumerService {
pvPointVarCorrelation.setIntervalValue3(jsonObject.getDoubleValue("intervalValue3")); pvPointVarCorrelation.setIntervalValue3(jsonObject.getDoubleValue("intervalValue3"));
pvPointVarCorrelation.setIntervalValue2(jsonObject.getDoubleValue("intervalValue2")); pvPointVarCorrelation.setIntervalValue2(jsonObject.getDoubleValue("intervalValue2"));
pvPointVarCorrelation.setIntervalValue1(jsonObject.getDoubleValue("intervalValue1")); pvPointVarCorrelation.setIntervalValue1(jsonObject.getDoubleValue("intervalValue1"));
log.info("------------------------------------------光伏相关性::计算成功,待更新表数据----------------------------------------"); log.info(
"------------------------------------------光伏相关性::计算成功,待更新表数据----------------------------------------");
} else { } else {
pvPointVarCorrelation.setIntervalValue5(0.0); pvPointVarCorrelation.setIntervalValue5(0.0);
pvPointVarCorrelation.setIntervalValue4(0.0); pvPointVarCorrelation.setIntervalValue4(0.0);
...@@ -1115,7 +1200,4 @@ public class KafkaConsumerService { ...@@ -1115,7 +1200,4 @@ public class KafkaConsumerService {
return true; return true;
} }
} }
package com.yeejoin.amos.boot.module.jxiop.biz.service.impl; package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import cn.hutool.core.util.DesensitizedUtil; import cn.hutool.core.util.DesensitizedUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
...@@ -63,22 +62,22 @@ import java.util.stream.Collectors; ...@@ -63,22 +62,22 @@ import java.util.stream.Collectors;
*/ */
@Slf4j @Slf4j
@Service @Service
public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBasic, PersonBasicMapper> implements IPersonBasicService { public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBasic, PersonBasicMapper>
implements IPersonBasicService {
@Autowired @Autowired
PersonBasicMapper personBasicMapper; PersonBasicMapper personBasicMapper;
// 人员账号信息service
//人员账号信息service
@Autowired @Autowired
PersonAccountServiceImpl personAccountService; PersonAccountServiceImpl personAccountService;
//人员归属信息service // 人员归属信息service
@Autowired @Autowired
PersonAscriptionServiceImpl personAscriptionService; PersonAscriptionServiceImpl personAscriptionService;
//人员资质信息service // 人员资质信息service
@Autowired @Autowired
PersonCertificateServiceImpl personCertificateService; PersonCertificateServiceImpl personCertificateService;
//人员教育信息 // 人员教育信息
@Autowired @Autowired
PersonSkillEducationServiceImpl personSkillEducationService; PersonSkillEducationServiceImpl personSkillEducationService;
@Value("${amos.secret.key}") @Value("${amos.secret.key}")
...@@ -95,7 +94,6 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa ...@@ -95,7 +94,6 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa
@Autowired @Autowired
protected EmqKeeper emqKeeper; protected EmqKeeper emqKeeper;
@Autowired @Autowired
private AgencyuserFeign agencyuserFeign; private AgencyuserFeign agencyuserFeign;
...@@ -107,18 +105,16 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa ...@@ -107,18 +105,16 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa
*/ */
public static final String RYFM_DATA_MQTT_TOPIC = "ryfm/data/analysis"; public static final String RYFM_DATA_MQTT_TOPIC = "ryfm/data/analysis";
/** /**
* 人员红黄码恢复为绿码 * 人员红黄码恢复为绿码
*/ */
public static final String RYFM_GREEN = "ryfm/person/green"; public static final String RYFM_GREEN = "ryfm/person/green";
private String UPDATE = "UPDATE";
private String INSERT = "INSERT";
private String UPDATE="UPDATE";
private String INSERT="INSERT";
@Autowired @Autowired
PersonAccountFedMapper personAccountFedMapper; PersonAccountFedMapper personAccountFedMapper;
/** /**
* 分页查询 * 分页查询
*/ */
...@@ -140,7 +136,8 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa ...@@ -140,7 +136,8 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
Map<String, String> collect = elevatorCategory.stream().collect(Collectors.toMap(DictionarieValueModel::getDictDataKey, DictionarieValueModel::getDictDataDesc)); Map<String, String> collect = elevatorCategory.stream().collect(
Collectors.toMap(DictionarieValueModel::getDictDataKey, DictionarieValueModel::getDictDataDesc));
redisUtils.set(Constants.JXIOP_DICT_POST, collect); redisUtils.set(Constants.JXIOP_DICT_POST, collect);
List<DictionarieValueModel> elevator = null; List<DictionarieValueModel> elevator = null;
...@@ -149,14 +146,15 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa ...@@ -149,14 +146,15 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
Map<String, String> collect2 = elevator.stream().collect(Collectors.toMap(DictionarieValueModel::getDictDataKey, DictionarieValueModel::getDictDataDesc)); Map<String, String> collect2 = elevator.stream().collect(
Collectors.toMap(DictionarieValueModel::getDictDataKey, DictionarieValueModel::getDictDataDesc));
redisUtils.set(Constants.JXIOP_DICT_CERTIFICATES, collect2); redisUtils.set(Constants.JXIOP_DICT_CERTIFICATES, collect2);
} }
public RiskBizInfoVo fetchData(PersonBasic personBasic, PersonAccount personAccount, String content) { public RiskBizInfoVo fetchData(PersonBasic personBasic, PersonAccount personAccount, String content) {
RiskBizInfoVo riskBizInfoVo = new RiskBizInfoVo(); RiskBizInfoVo riskBizInfoVo = new RiskBizInfoVo();
riskBizInfoVo.setWarningObjectName(personAccount.getProjectName() + personBasic.getPostName() + personAccount.getName()); riskBizInfoVo.setWarningObjectName(
personAccount.getProjectName() + personBasic.getPostName() + personAccount.getName());
riskBizInfoVo.setWarningObjectCode(String.valueOf(personBasic.getSequenceNbr())); riskBizInfoVo.setWarningObjectCode(String.valueOf(personBasic.getSequenceNbr()));
riskBizInfoVo.setSourceAttribution(personBasic.getProjectOrgCode()); riskBizInfoVo.setSourceAttribution(personBasic.getProjectOrgCode());
riskBizInfoVo.setSourceAttributionDesc(personAccount.getProjectName()); riskBizInfoVo.setSourceAttributionDesc(personAccount.getProjectName());
...@@ -172,7 +170,6 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa ...@@ -172,7 +170,6 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa
return riskBizInfoVo; return riskBizInfoVo;
} }
/** /**
* 新增 * 新增
*/ */
...@@ -186,15 +183,15 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa ...@@ -186,15 +183,15 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa
// 证书临期信息 // 证书临期信息
Map<String, String> certificatesMap = (Map<String, String>) redisUtils.get(Constants.JXIOP_DICT_CERTIFICATES); Map<String, String> certificatesMap = (Map<String, String>) redisUtils.get(Constants.JXIOP_DICT_CERTIFICATES);
//获取人员基本信息数据 // 获取人员基本信息数据
PersonUser personUser = model.getPersonUser(); PersonUser personUser = model.getPersonUser();
//获取人员账号信息 // 获取人员账号信息
PersonAccount personAccount = model.getPersonAccount(); PersonAccount personAccount = model.getPersonAccount();
personUser.setPhone(personAccount.getPhoneNum()); personUser.setPhone(personAccount.getPhoneNum());
//人员基础信息 // 人员基础信息
PersonBasic personBasic = new PersonBasic(); PersonBasic personBasic = new PersonBasic();
BeanUtils.copyProperties(personUser, personBasic); BeanUtils.copyProperties(personUser, personBasic);
//默认红码 // 默认红码
personBasic.setQrcodeColor(QrcodeColorEnum.RED.getCode()); personBasic.setQrcodeColor(QrcodeColorEnum.RED.getCode());
personBasic.setQrcodeDesc("证书不全"); personBasic.setQrcodeDesc("证书不全");
// 该岗位应获得的证书 // 该岗位应获得的证书
...@@ -206,7 +203,7 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa ...@@ -206,7 +203,7 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa
} }
} }
List<String> list = new ArrayList(list2); List<String> list = new ArrayList(list2);
//人员资质信息 // 人员资质信息
Integer isInMonth = 0; Integer isInMonth = 0;
Integer isOver = 0; Integer isOver = 0;
CertificationInfo personCertificate = model.getPersonCertificate(); CertificationInfo personCertificate = model.getPersonCertificate();
...@@ -218,16 +215,17 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa ...@@ -218,16 +215,17 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa
if (CollectionUtils.isNotEmpty(personCertificate.getCertificationInfo())) { if (CollectionUtils.isNotEmpty(personCertificate.getCertificationInfo())) {
for (PersonCertificate item : personCertificate.getCertificationInfo()) { for (PersonCertificate item : personCertificate.getCertificationInfo()) {
if (StringUtils.isNotEmpty(item.getValidPeriod()) && !Objects.isNull(item.getCertificateTime())) { if (StringUtils.isNotEmpty(item.getValidPeriod()) && !Objects.isNull(item.getCertificateTime())) {
int validPeriod = StringUtils.isEmpty(item.getValidPeriod()) ? 3 : Integer.parseInt(item.getValidPeriod()); int validPeriod = StringUtils.isEmpty(item.getValidPeriod()) ? 3
: Integer.parseInt(item.getValidPeriod());
Date date = DateUtils.dateAddYears(item.getCertificateTime(), validPeriod); Date date = DateUtils.dateAddYears(item.getCertificateTime(), validPeriod);
if (list.contains(item.getCertificateName()) && if (list.contains(item.getCertificateName()) && DateUtils.dateCompare(date, new Date()) == -1) {
DateUtils.dateCompare(date, new Date()) == -1) {
isOver = 1; isOver = 1;
overCertificateList.add(item.getCertificateName()); overCertificateList.add(item.getCertificateName());
} }
if (list.contains(item.getCertificateName()) && if (list.contains(item.getCertificateName())
DateUtils.dateBetweenIncludeToday(new Date(), date) < Integer.valueOf(certificatesMap.get(item.getCertificateName())) && && DateUtils.dateBetweenIncludeToday(new Date(), date) < Integer
DateUtils.dateCompare(date, new Date()) == 1) { .valueOf(certificatesMap.get(item.getCertificateName()))
&& DateUtils.dateCompare(date, new Date()) == 1) {
isInMonth = 1; isInMonth = 1;
inMonthCertificateList.add(item.getCertificateName()); inMonthCertificateList.add(item.getCertificateName());
} }
...@@ -239,13 +237,13 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa ...@@ -239,13 +237,13 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa
List<String> noCertificateList = new ArrayList<>(list); List<String> noCertificateList = new ArrayList<>(list);
List<String> strings = new ArrayList<>(); List<String> strings = new ArrayList<>();
if (CollectionUtils.isNotEmpty(overCertificateList)) { if (CollectionUtils.isNotEmpty(overCertificateList)) {
strings.add("过期证书:" + String.join("," , overCertificateList)); strings.add("过期证书:" + String.join(",", overCertificateList));
} }
if (CollectionUtils.isNotEmpty(inMonthCertificateList)) { if (CollectionUtils.isNotEmpty(inMonthCertificateList)) {
strings.add("临期证书:" + String.join("," , inMonthCertificateList)); strings.add("临期证书:" + String.join(",", inMonthCertificateList));
} }
if (CollectionUtils.isNotEmpty(noCertificateList)) { if (CollectionUtils.isNotEmpty(noCertificateList)) {
strings.add("缺少证书:" + String.join("," , noCertificateList)); strings.add("缺少证书:" + String.join(",", noCertificateList));
} }
String join = ""; String join = "";
if (CollectionUtils.isNotEmpty(strings)) { if (CollectionUtils.isNotEmpty(strings)) {
...@@ -267,12 +265,11 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa ...@@ -267,12 +265,11 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa
personBasic.setQrcodeDate(new Date()); personBasic.setQrcodeDate(new Date());
} }
CompanyModel companyModel = new CompanyModel(); CompanyModel companyModel = new CompanyModel();
//单位 // 单位
companyModel = this.getCompanyModel(personAccount.getProjectId()); companyModel = this.getCompanyModel(personAccount.getProjectId());
personBasic.setProjectOrgCode(companyModel.getOrgCode()); personBasic.setProjectOrgCode(companyModel.getOrgCode());
if (personUser.getNativePlace() != null) {
if (personUser.getNativePlace()!=null) {
personBasic.setNativePlace(JSON.toJSONString(personUser.getNativePlace())); personBasic.setNativePlace(JSON.toJSONString(personUser.getNativePlace()));
} }
this.baseMapper.insert(personBasic); this.baseMapper.insert(personBasic);
...@@ -287,7 +284,8 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa ...@@ -287,7 +284,8 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa
bizMessage.setBizInfo(riskBizInfoVo); bizMessage.setBizInfo(riskBizInfoVo);
bizMessage.setTraceId(String.valueOf(personBasic.getSequenceNbr())); bizMessage.setTraceId(String.valueOf(personBasic.getSequenceNbr()));
try { try {
emqKeeper.getMqttClient().publish(RYFM_DATA_MQTT_TOPIC, JSON.toJSONString(bizMessage).getBytes(StandardCharsets.UTF_8), 2, false); emqKeeper.getMqttClient().publish(RYFM_DATA_MQTT_TOPIC,
JSON.toJSONString(bizMessage).getBytes(StandardCharsets.UTF_8), 2, false);
} catch (MqttException e) { } catch (MqttException e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -298,27 +296,28 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa ...@@ -298,27 +296,28 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa
personCertificateService.save(item); personCertificateService.save(item);
}); });
} }
//人员技能学历信息 // 人员技能学历信息
PersonSkillEducation personSkillEducation = new PersonSkillEducation(); PersonSkillEducation personSkillEducation = new PersonSkillEducation();
BeanUtils.copyProperties(personUser, personSkillEducation); BeanUtils.copyProperties(personUser, personSkillEducation);
personSkillEducation.setPersonId(personBasic.getSequenceNbr()); personSkillEducation.setPersonId(personBasic.getSequenceNbr());
personSkillEducationService.save(personSkillEducation); personSkillEducationService.save(personSkillEducation);
//人员账号信息 // 人员账号信息
personAccount.setPersonId(personBasic.getSequenceNbr()); personAccount.setPersonId(personBasic.getSequenceNbr());
personAccount.setPassword(DesUtil.encode(personAccount.getPassword(), secretKey)); personAccount.setPassword(DesUtil.encode(personAccount.getPassword(), secretKey));
personAccount.setSecondaryPassword(DesUtil.encode(personAccount.getSecondaryPassword(), secretKey)); personAccount.setSecondaryPassword(DesUtil.encode(personAccount.getSecondaryPassword(), secretKey));
personAccountService.save(personAccount); personAccountService.save(personAccount);
//新增平台账号 // 新增平台账号
//组装数据 // 组装数据
AgencyUserModel usd = new AgencyUserModel(); AgencyUserModel usd = new AgencyUserModel();
//应用 // 应用
usd.setAppCodes(personAccount.getApplication()); usd.setAppCodes(personAccount.getApplication());
//手机号 // 手机号
usd.setMobile(personUser.getPhone()); usd.setMobile(personUser.getPhone());
//角色 // 角色
Map<Long, List<Long>> map = new HashMap<>(); Map<Long, List<Long>> map = new HashMap<>();
List<Long> cdids = personAccount.getRoles().stream().map(s -> Long.parseLong(s.trim())).collect(Collectors.toList()); //测点数组 List<Long> cdids = personAccount.getRoles().stream().map(s -> Long.parseLong(s.trim()))
.collect(Collectors.toList()); // 测点数组
if (personAccount.getDepartmentId() != null) { if (personAccount.getDepartmentId() != null) {
map.put(personAccount.getDepartmentId(), cdids); map.put(personAccount.getDepartmentId(), cdids);
...@@ -326,31 +325,31 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa ...@@ -326,31 +325,31 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa
map.put(personAccount.getProjectId(), cdids); map.put(personAccount.getProjectId(), cdids);
} }
usd.setOrgRoleSeqs(map); usd.setOrgRoleSeqs(map);
//密码 // 密码
usd.setPassword(personAccount.getPassword()); usd.setPassword(personAccount.getPassword());
//二次密码 // 二次密码
usd.setRePassword(personAccount.getSecondaryPassword()); usd.setRePassword(personAccount.getSecondaryPassword());
//用户名 // 用户名
usd.setRealName(personAccount.getName()); usd.setRealName(personAccount.getName());
//账号 // 账号
usd.setUserName(personAccount.getAccountName()); usd.setUserName(personAccount.getAccountName());
usd.setLockStatus("UNLOCK"); usd.setLockStatus("UNLOCK");
//新增平台用户 // 新增平台用户
AgencyUserModel agencyUserModel = this.setcreateUser(usd); AgencyUserModel agencyUserModel = this.setcreateUser(usd);
//设置userID // 设置userID
usd.setUserId(agencyUserModel.getUserId()); usd.setUserId(agencyUserModel.getUserId());
//设置工号 // 设置工号
usd.setUserName(personAccount.getJobNumber()); usd.setUserName(personAccount.getJobNumber());
//创建支持工号登录 // 创建支持工号登录
this.createLoginInfo(usd); this.createLoginInfo(usd);
//查询部门 // 查询部门
DepartmentModel departmentModel = null; DepartmentModel departmentModel = null;
if (personAccount.getDepartmentId() != null) { if (personAccount.getDepartmentId() != null) {
departmentModel = this.getdepartmentModel(personAccount.getDepartmentId()); departmentModel = this.getdepartmentModel(personAccount.getDepartmentId());
} }
if (departmentModel != null) { if (departmentModel != null) {
//personBasic.setProjectOrgCode(departmentModel.getOrgCode()); // personBasic.setProjectOrgCode(departmentModel.getOrgCode());
personAccount.setProjectDepartmentName(departmentModel.getDepartmentName()); personAccount.setProjectDepartmentName(departmentModel.getDepartmentName());
} }
// personBasic.setProjectOrgCode(companyModel.getOrgCode()); // personBasic.setProjectOrgCode(companyModel.getOrgCode());
...@@ -363,7 +362,7 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa ...@@ -363,7 +362,7 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa
personAccount.setProjectName(companyModel.getCompanyName()); personAccount.setProjectName(companyModel.getCompanyName());
// this.personBasicMapper.updateById(personBasic); // this.personBasicMapper.updateById(personBasic);
this.personAccountService.updateById(personAccount); this.personAccountService.updateById(personAccount);
//----------------------------权限表中新增数据----------------------------- // ----------------------------权限表中新增数据-----------------------------
StdUserEmpower stdUserEmpower = new StdUserEmpower(); StdUserEmpower stdUserEmpower = new StdUserEmpower();
stdUserEmpower.setPermissionType("YTH"); stdUserEmpower.setPermissionType("YTH");
stdUserEmpower.setRecDate(new Date()); stdUserEmpower.setRecDate(new Date());
...@@ -371,23 +370,23 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa ...@@ -371,23 +370,23 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa
stdUserEmpower.setAmosUserId(personAccount.getPuserId()); stdUserEmpower.setAmosUserId(personAccount.getPuserId());
userEmpowerMapper.insert(stdUserEmpower); userEmpowerMapper.insert(stdUserEmpower);
//----------------------------户用管理端区域公司--------------------------- // ----------------------------户用管理端区域公司---------------------------
StdUserEmpower stdUserEmpowerhygf = new StdUserEmpower(); StdUserEmpower stdUserEmpowerhygf = new StdUserEmpower();
List<CompanyModel> co= userEmpowerMapper.getCompanyBoList("region",null,null); List<CompanyModel> co = userEmpowerMapper.getCompanyBoList("region", null, null);
List<String> re= personAccount.getRegionalCompaniesSeq(); List<String> re = personAccount.getRegionalCompaniesSeq();
String flag=personAccount.getRegionalCompaniesSeqFlag(); String flag = personAccount.getRegionalCompaniesSeqFlag();
if(flag!=null&&!flag.isEmpty()){ if (flag != null && !flag.isEmpty()) {
if(flag.equals("all")){ if (flag.equals("all")) {
List<String> all=new ArrayList<>(); List<String> all = new ArrayList<>();
all.add("all"); all.add("all");
stdUserEmpowerhygf.setAmosOrgCode(all); stdUserEmpowerhygf.setAmosOrgCode(all);
}else{ } else {
stdUserEmpowerhygf.setAmosOrgCode(re); stdUserEmpowerhygf.setAmosOrgCode(re);
} }
} }
List<String> exre= personAccount.getExternalRegionalCompaniesSeq(); List<String> exre = personAccount.getExternalRegionalCompaniesSeq();
// if(exre!=null&&!exre.isEmpty()){ // if(exre!=null&&!exre.isEmpty()){
// List<String> pexre=new ArrayList<>(); // List<String> pexre=new ArrayList<>();
// List<CompanyModel> exreco = co.stream().filter(product -> !"area".equals(product.getLevel())).collect(Collectors.toList()); // List<CompanyModel> exreco = co.stream().filter(product -> !"area".equals(product.getLevel())).collect(Collectors.toList());
...@@ -404,29 +403,23 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa ...@@ -404,29 +403,23 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa
stdUserEmpowerhygf.setAmosUserId(personAccount.getPuserId()); stdUserEmpowerhygf.setAmosUserId(personAccount.getPuserId());
userEmpowerMapper.insert(stdUserEmpowerhygf); userEmpowerMapper.insert(stdUserEmpowerhygf);
// ----------------------------权限表中新增数据-----------------------------
//----------------------------权限表中新增数据-----------------------------
PersonAccountFed personAccountFed = new PersonAccountFed(); PersonAccountFed personAccountFed = new PersonAccountFed();
BeanUtils.copyProperties(personAccount, personAccountFed); BeanUtils.copyProperties(personAccount, personAccountFed);
personAccountFed.setSyncState(0); personAccountFed.setSyncState(0);
personAccountFed.setSyncDate(new Date()); personAccountFed.setSyncDate(new Date());
personAccountFedMapper.insert(personAccountFed); personAccountFedMapper.insert(personAccountFed);
Map<String, Object> data=new HashMap<>(); Map<String, Object> data = new HashMap<>();
data.put("SEQUENCE_NBR",agencyUserModel.getSequenceNbr()); data.put("SEQUENCE_NBR", agencyUserModel.getSequenceNbr());
ProduceMsg produceMsg= new ProduceMsg(data, INSERT,agencyUserModel.getUserId()); ProduceMsg produceMsg = new ProduceMsg(data, INSERT, agencyUserModel.getUserId());
querueProduce.produceMsg(JSON.toJSONString(produceMsg)); querueProduce.produceMsg(JSON.toJSONString(produceMsg));
} }
@Transactional @Transactional
public PersonDto updatePerson(PersonDto model, HttpServletRequest httpServletRequest, Long sequenceNbr) throws ParseException { public PersonDto updatePerson(PersonDto model, HttpServletRequest httpServletRequest, Long sequenceNbr)
throws ParseException {
if (!redisUtils.hasKey(Constants.JXIOP_DICT_POST) || !redisUtils.hasKey(Constants.JXIOP_DICT_CERTIFICATES)) { if (!redisUtils.hasKey(Constants.JXIOP_DICT_POST) || !redisUtils.hasKey(Constants.JXIOP_DICT_CERTIFICATES)) {
addRedisPostAndCerInfo(); addRedisPostAndCerInfo();
...@@ -436,35 +429,36 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa ...@@ -436,35 +429,36 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa
// 证书临期信息 // 证书临期信息
Map<String, String> certificatesMap = (Map<String, String>) redisUtils.get(Constants.JXIOP_DICT_CERTIFICATES); Map<String, String> certificatesMap = (Map<String, String>) redisUtils.get(Constants.JXIOP_DICT_CERTIFICATES);
//获取人员基本信息数据 // 获取人员基本信息数据
PersonUser personUser = model.getPersonUser(); PersonUser personUser = model.getPersonUser();
//获取人员账号信息 // 获取人员账号信息
PersonAccount personAccount = model.getPersonAccount(); PersonAccount personAccount = model.getPersonAccount();
PersonAccount oldpersonAccount = new PersonAccount(); PersonAccount oldpersonAccount = new PersonAccount();
personUser.setPhone(personAccount.getPhoneNum()); personUser.setPhone(personAccount.getPhoneNum());
//人员基础信息 // 人员基础信息
PersonBasic personBasic = personBasicMapper.selectById(sequenceNbr); PersonBasic personBasic = personBasicMapper.selectById(sequenceNbr);
personBasic.setSequenceNbr(sequenceNbr); personBasic.setSequenceNbr(sequenceNbr);
personAccount.setPassword(DesUtil.encode(personAccount.getPassword(), secretKey)); personAccount.setPassword(DesUtil.encode(personAccount.getPassword(), secretKey));
personAccount.setSecondaryPassword(DesUtil.encode(personAccount.getSecondaryPassword(), secretKey)); personAccount.setSecondaryPassword(DesUtil.encode(personAccount.getSecondaryPassword(), secretKey));
//人员归属信息 // 人员归属信息
PersonSkillEducation personSkillEducation = new PersonSkillEducation(); PersonSkillEducation personSkillEducation = new PersonSkillEducation();
BeanUtils.copyProperties(personUser, personSkillEducation); BeanUtils.copyProperties(personUser, personSkillEducation);
personSkillEducation.setPersonId(personBasic.getSequenceNbr()); personSkillEducation.setPersonId(personBasic.getSequenceNbr());
PersonSkillEducation personSkillEducationd = personSkillEducationService.getOne(new QueryWrapper<PersonSkillEducation>().eq("person_id", personBasic.getSequenceNbr())); PersonSkillEducation personSkillEducationd = personSkillEducationService
.getOne(new QueryWrapper<PersonSkillEducation>().eq("person_id", personBasic.getSequenceNbr()));
personSkillEducation.setSequenceNbr(personSkillEducationd.getSequenceNbr()); personSkillEducation.setSequenceNbr(personSkillEducationd.getSequenceNbr());
personSkillEducationService.updateById(personSkillEducation); personSkillEducationService.updateById(personSkillEducation);
//获取人员资质信息 // 获取人员资质信息
CertificationInfo personCertificate = model.getPersonCertificate(); CertificationInfo personCertificate = model.getPersonCertificate();
LambdaUpdateWrapper<PersonCertificate> wrapper = new LambdaUpdateWrapper<>(); LambdaUpdateWrapper<PersonCertificate> wrapper = new LambdaUpdateWrapper<>();
wrapper.eq(PersonCertificate::getPersonId, personBasic.getSequenceNbr()); wrapper.eq(PersonCertificate::getPersonId, personBasic.getSequenceNbr());
personCertificateService.remove(wrapper); personCertificateService.remove(wrapper);
//默认红码 // 默认红码
// personBasic.setQrcodeColor(QrcodeColorEnum.RED.getCode()); // personBasic.setQrcodeColor(QrcodeColorEnum.RED.getCode());
// 该岗位应获得的证书 // 该岗位应获得的证书
List<String> list2 = new ArrayList<>(); List<String> list2 = new ArrayList<>();
...@@ -475,7 +469,7 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa ...@@ -475,7 +469,7 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa
} }
} }
List<String> list = new ArrayList(list2); List<String> list = new ArrayList(list2);
//人员资质信息 // 人员资质信息
Integer isInMonth = 0; Integer isInMonth = 0;
Integer isOver = 0; Integer isOver = 0;
// 过期的证书 // 过期的证书
...@@ -485,16 +479,17 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa ...@@ -485,16 +479,17 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa
if (CollectionUtils.isNotEmpty(personCertificate.getCertificationInfo())) { if (CollectionUtils.isNotEmpty(personCertificate.getCertificationInfo())) {
for (PersonCertificate item : personCertificate.getCertificationInfo()) { for (PersonCertificate item : personCertificate.getCertificationInfo()) {
if (StringUtils.isNotEmpty(item.getValidPeriod()) && !Objects.isNull(item.getCertificateTime())) { if (StringUtils.isNotEmpty(item.getValidPeriod()) && !Objects.isNull(item.getCertificateTime())) {
int validPeriod = StringUtils.isEmpty(item.getValidPeriod()) ? 3 : Integer.parseInt(item.getValidPeriod()); int validPeriod = StringUtils.isEmpty(item.getValidPeriod()) ? 3
: Integer.parseInt(item.getValidPeriod());
Date date = DateUtils.dateAddYears(item.getCertificateTime(), validPeriod); Date date = DateUtils.dateAddYears(item.getCertificateTime(), validPeriod);
if (list.contains(item.getCertificateName()) && if (list.contains(item.getCertificateName()) && DateUtils.dateCompare(date, new Date()) == -1) {
DateUtils.dateCompare(date, new Date()) == -1) {
isOver = 1; isOver = 1;
overCertificateList.add(item.getCertificateName()); overCertificateList.add(item.getCertificateName());
} }
if (list.contains(item.getCertificateName()) && if (list.contains(item.getCertificateName())
DateUtils.dateBetweenIncludeToday(new Date(), date) < Integer.valueOf(certificatesMap.get(item.getCertificateName())) && && DateUtils.dateBetweenIncludeToday(new Date(), date) < Integer
DateUtils.dateCompare(date, new Date()) == 1) { .valueOf(certificatesMap.get(item.getCertificateName()))
&& DateUtils.dateCompare(date, new Date()) == 1) {
isInMonth = 1; isInMonth = 1;
inMonthCertificateList.add(item.getCertificateName()); inMonthCertificateList.add(item.getCertificateName());
} }
...@@ -509,13 +504,13 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa ...@@ -509,13 +504,13 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa
List<String> strings = new ArrayList<>(); List<String> strings = new ArrayList<>();
if (CollectionUtils.isNotEmpty(overCertificateList)) { if (CollectionUtils.isNotEmpty(overCertificateList)) {
strings.add("过期证书:" + String.join("," , overCertificateList)); strings.add("过期证书:" + String.join(",", overCertificateList));
} }
if (CollectionUtils.isNotEmpty(inMonthCertificateList)) { if (CollectionUtils.isNotEmpty(inMonthCertificateList)) {
strings.add("临期证书:" + String.join("," , inMonthCertificateList)); strings.add("临期证书:" + String.join(",", inMonthCertificateList));
} }
if (CollectionUtils.isNotEmpty(noCertificateList)) { if (CollectionUtils.isNotEmpty(noCertificateList)) {
strings.add("缺少证书:" + String.join("," , noCertificateList)); strings.add("缺少证书:" + String.join(",", noCertificateList));
} }
String join = ""; String join = "";
...@@ -525,7 +520,7 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa ...@@ -525,7 +520,7 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa
String missingCertificateOld = personBasic.getMissingCertificate(); String missingCertificateOld = personBasic.getMissingCertificate();
personBasic.setMissingCertificate(join); personBasic.setMissingCertificate(join);
CompanyModel companyModel = new CompanyModel(); CompanyModel companyModel = new CompanyModel();
//单位 // 单位
companyModel = this.getCompanyModel(personAccount.getProjectId()); companyModel = this.getCompanyModel(personAccount.getProjectId());
String qrcodeColorOld = personBasic.getQrcodeColor(); String qrcodeColorOld = personBasic.getQrcodeColor();
...@@ -545,23 +540,21 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa ...@@ -545,23 +540,21 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa
personBasic.setProjectOrgCode(companyModel.getOrgCode()); personBasic.setProjectOrgCode(companyModel.getOrgCode());
personAccount.setProjectName(companyModel.getCompanyName()); personAccount.setProjectName(companyModel.getCompanyName());
// 人员账号信息
//人员账号信息
personAccount.setPersonId(sequenceNbr); personAccount.setPersonId(sequenceNbr);
oldpersonAccount=personAccountService.getById(personAccount.getSequenceNbr()); oldpersonAccount = personAccountService.getById(personAccount.getSequenceNbr());
personAccountService.updateById(personAccount); personAccountService.updateById(personAccount);
//新增平台账号 // 新增平台账号
//组装数据 // 组装数据
AgencyUserModel usd = new AgencyUserModel(); AgencyUserModel usd = new AgencyUserModel();
//应用 // 应用
usd.setAppCodes(personAccount.getApplication()); usd.setAppCodes(personAccount.getApplication());
//手机号 // 手机号
usd.setMobile(personUser.getPhone()); usd.setMobile(personUser.getPhone());
//角色 // 角色
Map<Long, List<Long>> map = new HashMap<>(); Map<Long, List<Long>> map = new HashMap<>();
List<Long> cdids = personAccount.getRoles().stream().map(s -> Long.parseLong(s.trim())).collect(Collectors.toList()); //测点数组 List<Long> cdids = personAccount.getRoles().stream().map(s -> Long.parseLong(s.trim()))
.collect(Collectors.toList()); // 测点数组
if (personAccount.getDepartmentId() != null) { if (personAccount.getDepartmentId() != null) {
map.put(personAccount.getDepartmentId(), cdids); map.put(personAccount.getDepartmentId(), cdids);
...@@ -569,34 +562,34 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa ...@@ -569,34 +562,34 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa
map.put(personAccount.getProjectId(), cdids); map.put(personAccount.getProjectId(), cdids);
} }
usd.setOrgRoleSeqs(map); usd.setOrgRoleSeqs(map);
//密码 // 密码
usd.setPassword(personAccount.getPassword()); usd.setPassword(personAccount.getPassword());
//二次密码 // 二次密码
usd.setRePassword(personAccount.getSecondaryPassword()); usd.setRePassword(personAccount.getSecondaryPassword());
//用户名 // 用户名
usd.setRealName(personAccount.getName()); usd.setRealName(personAccount.getName());
//账号 // 账号
usd.setUserName(personAccount.getAccountName()); usd.setUserName(personAccount.getAccountName());
usd.setLockStatus("UNLOCK"); usd.setLockStatus("UNLOCK");
usd.setUserId(personAccount.getPuserId()); usd.setUserId(personAccount.getPuserId());
usd.setOriginalPassword(oldpersonAccount.getPassword()); usd.setOriginalPassword(oldpersonAccount.getPassword());
//新增平台用户 // 新增平台用户
AgencyUserModel agencyUserModel = this.updateuser(personAccount.getPuserId(), usd); AgencyUserModel agencyUserModel = this.updateuser(personAccount.getPuserId(), usd);
log.info("更新平台账户信息::"+ JSONObject.toJSONString(usd)); log.info("更新平台账户信息::" + JSONObject.toJSONString(usd));
//设置userID // 设置userID
usd.setUserId(agencyUserModel.getUserId()); usd.setUserId(agencyUserModel.getUserId());
//设置工号 // 设置工号
usd.setUserName(personAccount.getJobNumber()); usd.setUserName(personAccount.getJobNumber());
//创建支持工号登录 // 创建支持工号登录
this.updateLoginInfo(oldpersonAccount.getJobNumber(),usd); this.updateLoginInfo(oldpersonAccount.getJobNumber(), usd);
//查询部门 // 查询部门
DepartmentModel departmentModel = null; DepartmentModel departmentModel = null;
if (personAccount.getDepartmentId() != null) { if (personAccount.getDepartmentId() != null) {
departmentModel = this.getdepartmentModel(personAccount.getDepartmentId()); departmentModel = this.getdepartmentModel(personAccount.getDepartmentId());
} }
BeanUtils.copyProperties(personUser, personBasic, "qrcodeDesc", "qrcodeColor"); BeanUtils.copyProperties(personUser, personBasic, "qrcodeDesc", "qrcodeColor");
if (departmentModel != null) { if (departmentModel != null) {
//personBasic.setProjectOrgCode(departmentModel.getOrgCode()); // personBasic.setProjectOrgCode(departmentModel.getOrgCode());
personAccount.setProjectDepartmentName(departmentModel.getDepartmentName()); personAccount.setProjectDepartmentName(departmentModel.getDepartmentName());
} }
personBasic.setProjectOrgCode(companyModel.getOrgCode()); personBasic.setProjectOrgCode(companyModel.getOrgCode());
...@@ -609,8 +602,7 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa ...@@ -609,8 +602,7 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa
if (!join.equals(missingCertificateOld)) { if (!join.equals(missingCertificateOld)) {
personBasic.setRecDate(new Date()); personBasic.setRecDate(new Date());
this.personBasicMapper.updateById(personBasic); this.personBasicMapper.updateById(personBasic);
if (("证书不全".equals(personBasic.getQrcodeDesc()) || if (("证书不全".equals(personBasic.getQrcodeDesc()) || "证书临期".equals(personBasic.getQrcodeDesc()))) {
"证书临期".equals(personBasic.getQrcodeDesc()))) {
BizMessage bizMessage = new BizMessage(); BizMessage bizMessage = new BizMessage();
bizMessage.setIndexKey("RYFM"); bizMessage.setIndexKey("RYFM");
bizMessage.setIndexValue(personBasic.getPostName() + personBasic.getQrcodeDesc()); bizMessage.setIndexValue(personBasic.getPostName() + personBasic.getQrcodeDesc());
...@@ -618,7 +610,8 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa ...@@ -618,7 +610,8 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa
bizMessage.setBizInfo(riskBizInfoVo); bizMessage.setBizInfo(riskBizInfoVo);
bizMessage.setDataSource("人员赋码"); bizMessage.setDataSource("人员赋码");
try { try {
emqKeeper.getMqttClient().publish(PersonBasicServiceImpl.RYFM_DATA_MQTT_TOPIC, JSON.toJSONString(bizMessage).getBytes(StandardCharsets.UTF_8), 2, false); emqKeeper.getMqttClient().publish(PersonBasicServiceImpl.RYFM_DATA_MQTT_TOPIC,
JSON.toJSONString(bizMessage).getBytes(StandardCharsets.UTF_8), 2, false);
} catch (MqttException e) { } catch (MqttException e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -631,7 +624,8 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa ...@@ -631,7 +624,8 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa
personMap.put("sourceAttributionDesc", personAccount.getProjectName()); personMap.put("sourceAttributionDesc", personAccount.getProjectName());
personMap.put("warningSourceType", "人员赋码"); personMap.put("warningSourceType", "人员赋码");
try { try {
emqKeeper.getMqttClient().publish(PersonBasicServiceImpl.RYFM_GREEN, JSON.toJSONString(personMap).getBytes(StandardCharsets.UTF_8), 2, false); emqKeeper.getMqttClient().publish(PersonBasicServiceImpl.RYFM_GREEN,
JSON.toJSONString(personMap).getBytes(StandardCharsets.UTF_8), 2, false);
} catch (MqttException e) { } catch (MqttException e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -639,37 +633,39 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa ...@@ -639,37 +633,39 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa
} else { } else {
this.personBasicMapper.updateById(personBasic); this.personBasicMapper.updateById(personBasic);
} }
StdUserEmpower stdUserEmpower = userEmpowerMapper.selectOne(new QueryWrapper<StdUserEmpower>().eq("amos_user_id", personAccount.getPuserId()).eq("permission_type", "YTH")); StdUserEmpower stdUserEmpower = userEmpowerMapper.selectOne(new QueryWrapper<StdUserEmpower>()
if(ObjectUtils.isEmpty(stdUserEmpower)){ .eq("amos_user_id", personAccount.getPuserId()).eq("permission_type", "YTH"));
if (ObjectUtils.isEmpty(stdUserEmpower)) {
stdUserEmpower = new StdUserEmpower(); stdUserEmpower = new StdUserEmpower();
stdUserEmpower.setRecDate(new Date()); stdUserEmpower.setRecDate(new Date());
stdUserEmpower.setPermissionType("YTH"); stdUserEmpower.setPermissionType("YTH");
stdUserEmpower.setAmosOrgCode(Arrays.asList(personAccount.getYthPermission())); stdUserEmpower.setAmosOrgCode(Arrays.asList(personAccount.getYthPermission()));
stdUserEmpower.setAmosUserId(personAccount.getPuserId()); stdUserEmpower.setAmosUserId(personAccount.getPuserId());
userEmpowerMapper.insert(stdUserEmpower); userEmpowerMapper.insert(stdUserEmpower);
}else { } else {
stdUserEmpower.setAmosOrgCode(Arrays.asList(personAccount.getYthPermission())); stdUserEmpower.setAmosOrgCode(Arrays.asList(personAccount.getYthPermission()));
stdUserEmpower.setRecDate(new Date()); stdUserEmpower.setRecDate(new Date());
userEmpowerMapper.updateById(stdUserEmpower); userEmpowerMapper.updateById(stdUserEmpower);
} }
//户用角色权限 // 户用角色权限
StdUserEmpower stdUserEmpowerhygf = userEmpowerMapper.selectOne(new QueryWrapper<StdUserEmpower>().eq("amos_user_id", personAccount.getPuserId()).eq("permission_type", "HYGF")); StdUserEmpower stdUserEmpowerhygf = userEmpowerMapper.selectOne(new QueryWrapper<StdUserEmpower>()
if(ObjectUtils.isEmpty(stdUserEmpowerhygf)){ .eq("amos_user_id", personAccount.getPuserId()).eq("permission_type", "HYGF"));
stdUserEmpowerhygf=new StdUserEmpower(); if (ObjectUtils.isEmpty(stdUserEmpowerhygf)) {
List<CompanyModel> co= userEmpowerMapper.getCompanyBoList("region",null,null); stdUserEmpowerhygf = new StdUserEmpower();
List<String> re= personAccount.getRegionalCompaniesSeq(); List<CompanyModel> co = userEmpowerMapper.getCompanyBoList("region", null, null);
String flag=personAccount.getRegionalCompaniesSeqFlag(); List<String> re = personAccount.getRegionalCompaniesSeq();
if(flag!=null&&!flag.isEmpty()){ String flag = personAccount.getRegionalCompaniesSeqFlag();
if(flag.equals("all")){ if (flag != null && !flag.isEmpty()) {
List<String> all=new ArrayList<>(); if (flag.equals("all")) {
List<String> all = new ArrayList<>();
all.add("all"); all.add("all");
stdUserEmpowerhygf.setAmosOrgCode(all); stdUserEmpowerhygf.setAmosOrgCode(all);
}else{ } else {
stdUserEmpowerhygf.setAmosOrgCode(re); stdUserEmpowerhygf.setAmosOrgCode(re);
} }
} }
List<String> exre= personAccount.getExternalRegionalCompaniesSeq(); List<String> exre = personAccount.getExternalRegionalCompaniesSeq();
// if(exre!=null&&!exre.isEmpty()){ // if(exre!=null&&!exre.isEmpty()){
// List<String> pexre=new ArrayList<>(); // List<String> pexre=new ArrayList<>();
// List<CompanyModel> exreco = co.stream().filter(product -> !"area".equals(product.getLevel())).collect(Collectors.toList()); // List<CompanyModel> exreco = co.stream().filter(product -> !"area".equals(product.getLevel())).collect(Collectors.toList());
...@@ -685,22 +681,22 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa ...@@ -685,22 +681,22 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa
stdUserEmpowerhygf.setRecDate(new Date()); stdUserEmpowerhygf.setRecDate(new Date());
stdUserEmpowerhygf.setAmosUserId(personAccount.getPuserId()); stdUserEmpowerhygf.setAmosUserId(personAccount.getPuserId());
userEmpowerMapper.insert(stdUserEmpowerhygf); userEmpowerMapper.insert(stdUserEmpowerhygf);
}else { } else {
// List<CompanyModel> co= userEmpowerMapper.getCompanyBoList("region",null,null); // List<CompanyModel> co= userEmpowerMapper.getCompanyBoList("region",null,null);
List<String> re= personAccount.getRegionalCompaniesSeq(); List<String> re = personAccount.getRegionalCompaniesSeq();
String flag=personAccount.getRegionalCompaniesSeqFlag(); String flag = personAccount.getRegionalCompaniesSeqFlag();
if(flag!=null&&!flag.isEmpty()){ if (flag != null && !flag.isEmpty()) {
if(flag.equals("all")){ if (flag.equals("all")) {
List<String> all=new ArrayList<>(); List<String> all = new ArrayList<>();
all.add("all"); all.add("all");
stdUserEmpowerhygf.setAmosOrgCode(all); stdUserEmpowerhygf.setAmosOrgCode(all);
}else{ } else {
stdUserEmpowerhygf.setAmosOrgCode(re); stdUserEmpowerhygf.setAmosOrgCode(re);
} }
}else{ } else {
stdUserEmpowerhygf.setAmosOrgCode(re); stdUserEmpowerhygf.setAmosOrgCode(re);
} }
List<String> exre= personAccount.getExternalRegionalCompaniesSeq(); List<String> exre = personAccount.getExternalRegionalCompaniesSeq();
// if(exre!=null&&!exre.isEmpty()){ // if(exre!=null&&!exre.isEmpty()){
// List<String> pexre=new ArrayList<>(); // List<String> pexre=new ArrayList<>();
// List<CompanyModel> exreco = co.stream().filter(product -> !"area".equals(product.getLevel())).collect(Collectors.toList()); // List<CompanyModel> exreco = co.stream().filter(product -> !"area".equals(product.getLevel())).collect(Collectors.toList());
...@@ -725,31 +721,31 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa ...@@ -725,31 +721,31 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa
personAccountFed.setSyncDate(new Date()); personAccountFed.setSyncDate(new Date());
personAccountFedMapper.updateById(personAccountFed); personAccountFedMapper.updateById(personAccountFed);
Map<String, Object> data=new HashMap<>(); Map<String, Object> data = new HashMap<>();
data.put("SEQUENCE_NBR",agencyUserModel.getSequenceNbr()); data.put("SEQUENCE_NBR", agencyUserModel.getSequenceNbr());
ProduceMsg produceMsg= new ProduceMsg(data, UPDATE,agencyUserModel.getUserId()); ProduceMsg produceMsg = new ProduceMsg(data, UPDATE, agencyUserModel.getUserId());
querueProduce.produceMsg(JSON.toJSONString(produceMsg)); querueProduce.produceMsg(JSON.toJSONString(produceMsg));
return model; return model;
} }
@Transactional @Transactional
public PersonDto getPerson(Long sequenceNbr,String type) { public PersonDto getPerson(Long sequenceNbr, String type) {
PersonDto personDto = new PersonDto(); PersonDto personDto = new PersonDto();
PersonUser personUser = new PersonUser(); PersonUser personUser = new PersonUser();
QueryWrapper<PersonBasic> wrapper1 = new QueryWrapper(); QueryWrapper<PersonBasic> wrapper1 = new QueryWrapper();
wrapper1.eq("sequence_nbr", sequenceNbr); wrapper1.eq("sequence_nbr", sequenceNbr);
wrapper1.eq("is_delete", 0); wrapper1.eq("is_delete", 0);
//人员基础信息 // 人员基础信息
PersonBasic personBasic = this.getOne(wrapper1); PersonBasic personBasic = this.getOne(wrapper1);
BeanUtils.copyProperties(personBasic, personUser); BeanUtils.copyProperties(personBasic, personUser);
//人员技能学历信息 // 人员技能学历信息
QueryWrapper<PersonSkillEducation> wrapper2 = new QueryWrapper(); QueryWrapper<PersonSkillEducation> wrapper2 = new QueryWrapper();
wrapper2.eq("person_id", sequenceNbr); wrapper2.eq("person_id", sequenceNbr);
PersonSkillEducation personSkillEducation = personSkillEducationService.getOne(wrapper2); PersonSkillEducation personSkillEducation = personSkillEducationService.getOne(wrapper2);
BeanUtils.copyProperties(personSkillEducation, personUser); BeanUtils.copyProperties(personSkillEducation, personUser);
//人员资质信息 // 人员资质信息
LambdaQueryWrapper<PersonCertificate> personCertificateLambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<PersonCertificate> personCertificateLambdaQueryWrapper = new LambdaQueryWrapper<>();
personCertificateLambdaQueryWrapper.eq(PersonCertificate::getPersonId, sequenceNbr); personCertificateLambdaQueryWrapper.eq(PersonCertificate::getPersonId, sequenceNbr);
List<PersonCertificate> list = personCertificateService.list(personCertificateLambdaQueryWrapper); List<PersonCertificate> list = personCertificateService.list(personCertificateLambdaQueryWrapper);
...@@ -758,40 +754,41 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa ...@@ -758,40 +754,41 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa
QueryWrapper<PersonAccount> wrapper4 = new QueryWrapper(); QueryWrapper<PersonAccount> wrapper4 = new QueryWrapper();
wrapper4.eq("person_id", sequenceNbr); wrapper4.eq("person_id", sequenceNbr);
//人员账号信息 // 人员账号信息
PersonAccount personAccount = personAccountService.getOne(wrapper4); PersonAccount personAccount = personAccountService.getOne(wrapper4);
personAccount.setPhoneNum(personBasic.getPhone()); personAccount.setPhoneNum(personBasic.getPhone());
//对于密码进行解密 // 对于密码进行解密
if("look".equals(type)){ if ("look".equals(type)) {
personAccount.setIdNumber(DesensitizedUtil.idCardNum(personAccount.getIdNumber(),0,4)); personAccount.setIdNumber(DesensitizedUtil.idCardNum(personAccount.getIdNumber(), 0, 4));
}else{ } else {
personAccount.setPassword(DesUtil.decode(personAccount.getPassword(), secretKey)); personAccount.setPassword(DesUtil.decode(personAccount.getPassword(), secretKey));
personAccount.setSecondaryPassword(DesUtil.decode(personAccount.getSecondaryPassword(), secretKey)); personAccount.setSecondaryPassword(DesUtil.decode(personAccount.getSecondaryPassword(), secretKey));
} }
if (personBasic.getNativePlace() != null) { if (personBasic.getNativePlace() != null) {
personUser.setNativePlace(JSON.parseArray(personBasic.getNativePlace(), Integer.class)); personUser.setNativePlace(JSON.parseArray(personBasic.getNativePlace(), Integer.class));
} }
StdUserEmpower stdUserEmpower = userEmpowerMapper.selectOne(new QueryWrapper<StdUserEmpower>().eq("amos_user_id", personAccount.getPuserId()).eq("permission_type", "YTH")); StdUserEmpower stdUserEmpower = userEmpowerMapper.selectOne(new QueryWrapper<StdUserEmpower>()
if(!ObjectUtils.isEmpty(stdUserEmpower)){ .eq("amos_user_id", personAccount.getPuserId()).eq("permission_type", "YTH"));
if (!ObjectUtils.isEmpty(stdUserEmpower)) {
personAccount.setYthPermission(stdUserEmpower.getAmosOrgCode().get(0)); personAccount.setYthPermission(stdUserEmpower.getAmosOrgCode().get(0));
} }
StdUserEmpower stdUserEmpowerhygf = userEmpowerMapper.selectOne(new QueryWrapper<StdUserEmpower>()
.eq("amos_user_id", personAccount.getPuserId()).eq("permission_type", "HYGF"));
if (!ObjectUtils.isEmpty(stdUserEmpowerhygf)) {
if (stdUserEmpowerhygf.getAmosOrgCode() == null || stdUserEmpowerhygf.getAmosOrgCode().size() == 0) {
StdUserEmpower stdUserEmpowerhygf = userEmpowerMapper.selectOne(new QueryWrapper<StdUserEmpower>().eq("amos_user_id", personAccount.getPuserId()).eq("permission_type", "HYGF"));
if(!ObjectUtils.isEmpty(stdUserEmpowerhygf)){
if(stdUserEmpowerhygf.getAmosOrgCode()==null||stdUserEmpowerhygf.getAmosOrgCode().size()==0){
// List<String> list2 = new ArrayList<>(); // List<String> list2 = new ArrayList<>();
// list2.add("all"); // list2.add("all");
personAccount.setRegionalCompaniesSeq(null); personAccount.setRegionalCompaniesSeq(null);
}else if(stdUserEmpowerhygf.getAmosOrgCode().size()==1&&stdUserEmpowerhygf.getAmosOrgCode().get(0).equals("all")){ } else if (stdUserEmpowerhygf.getAmosOrgCode().size() == 1
&& stdUserEmpowerhygf.getAmosOrgCode().get(0).equals("all")) {
personAccount.setRegionalCompaniesSeqFlag("all"); personAccount.setRegionalCompaniesSeqFlag("all");
personAccount.setRegionalCompaniesSeq(null); personAccount.setRegionalCompaniesSeq(null);
}else{ } else {
personAccount.setRegionalCompaniesSeqFlag("no"); personAccount.setRegionalCompaniesSeqFlag("no");
personAccount.setRegionalCompaniesSeq(stdUserEmpowerhygf.getAmosOrgCode()); personAccount.setRegionalCompaniesSeq(stdUserEmpowerhygf.getAmosOrgCode());
...@@ -809,7 +806,7 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa ...@@ -809,7 +806,7 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa
@Transactional @Transactional
public int deletePerson(String[] ids) { public int deletePerson(String[] ids) {
//查询所有平台用户 // 查询所有平台用户
QueryWrapper<PersonAccount> wrapper = new QueryWrapper(); QueryWrapper<PersonAccount> wrapper = new QueryWrapper();
wrapper.in("person_id", ids); wrapper.in("person_id", ids);
List<PersonAccount> list = personAccountService.list(wrapper); List<PersonAccount> list = personAccountService.list(wrapper);
...@@ -819,19 +816,20 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa ...@@ -819,19 +816,20 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa
userid.add(personAccount.getPuserId()); userid.add(personAccount.getPuserId());
// loginId.add(personAccount.getJobNumber()); // loginId.add(personAccount.getJobNumber());
} }
//删除平台 // 删除平台
int deleteResult = personBasicMapper.deleteList(ids); int deleteResult = personBasicMapper.deleteList(ids);
this.deleuser(String.join(",", userid)); this.deleuser(String.join(",", userid));
//// this.deleteLoginInfo(String.join(",", loginId)); //// this.deleteLoginInfo(String.join(",", loginId));
// this.deleteLoginInfo(loginId.get(1)); // this.deleteLoginInfo(loginId.get(1));
QueryWrapper<PersonAccountFed> wrapper1 = new QueryWrapper(); QueryWrapper<PersonAccountFed> wrapper1 = new QueryWrapper();
wrapper1.in("person_id",ids); wrapper1.in("person_id", ids);
personAccountFedMapper.delete(wrapper1); personAccountFedMapper.delete(wrapper1);
userEmpowerMapper.delete(new QueryWrapper<StdUserEmpower>().in("amos_user_id", userid).eq("permission_type", "YTH")); userEmpowerMapper
.delete(new QueryWrapper<StdUserEmpower>().in("amos_user_id", userid).eq("permission_type", "YTH"));
return deleteResult; return deleteResult;
} }
//新增平台用户 // 新增平台用户
private AgencyUserModel setcreateUser(AgencyUserModel userDto) { private AgencyUserModel setcreateUser(AgencyUserModel userDto) {
FeignClientResult<AgencyUserModel> amosUser = Privilege.agencyUserClient.create(userDto); FeignClientResult<AgencyUserModel> amosUser = Privilege.agencyUserClient.create(userDto);
...@@ -846,21 +844,30 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa ...@@ -846,21 +844,30 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa
} }
return user; return user;
} }
private LoginInfoModel createLoginInfo(AgencyUserModel userDto) { private LoginInfoModel createLoginInfo(AgencyUserModel userDto) {
FeignClientResult<LoginInfoModel> amosLoginfo = null; FeignClientResult<LoginInfoModel> amosLoginfo = null;
try { try {
amosLoginfo = Privilege.agencyUserClient.createLoginInfo(userDto); amosLoginfo = Privilege.agencyUserClient.createLoginInfo(userDto);
} catch (Exception e) { } catch (Exception e) {
FeignClientResult<List<String>> cResult = Privilege.agencyUserClient.multDeleteUser(userDto.getUserId(),true); FeignClientResult<List<String>> cResult = Privilege.agencyUserClient.multDeleteUser(userDto.getUserId(),
true);
throw new RuntimeException(e); throw new RuntimeException(e);
} }
return amosLoginfo.getResult(); return amosLoginfo.getResult();
} }
//修改平台用户 // 修改平台用户
private AgencyUserModel updateuser(String userId, AgencyUserModel userDto) { private AgencyUserModel updateuser(String userId, AgencyUserModel userDto) {
FeignClientResult<AgencyUserModel> amosUser = Privilege.agencyUserClient.update(userDto, userId); FeignClientResult<AgencyUserModel> amosUser = null;
FeignClientResult<AgencyUserModel> amosUser1 = Privilege.agencyUserClient.modifyPassword(userId,userDto); FeignClientResult<AgencyUserModel> amosUser1 = null;
try {
amosUser = Privilege.agencyUserClient.update(userDto, userId);
amosUser1 = Privilege.agencyUserClient.modifyPassword(userId, userDto);
} catch (Exception e) {
e.printStackTrace();
}
AgencyUserModel user = new AgencyUserModel(); AgencyUserModel user = new AgencyUserModel();
if (!ObjectUtils.isEmpty(amosUser)) { if (!ObjectUtils.isEmpty(amosUser)) {
if (amosUser.getStatus() == 200) { if (amosUser.getStatus() == 200) {
...@@ -878,16 +885,18 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa ...@@ -878,16 +885,18 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa
} }
return user; return user;
} }
private LoginInfoModel updateLoginInfo(String loginId,AgencyUserModel userDto) {
private LoginInfoModel updateLoginInfo(String loginId, AgencyUserModel userDto) {
FeignClientResult<LoginInfoModel> amosLoginfo = null; FeignClientResult<LoginInfoModel> amosLoginfo = null;
try { try {
amosLoginfo = Privilege.agencyUserClient.updateLoginInfo(userDto,loginId); amosLoginfo = Privilege.agencyUserClient.updateLoginInfo(userDto, loginId);
//amosLoginfo = agencyuserFeign.updateLoginInfo(userDto, loginId); // amosLoginfo = agencyuserFeign.updateLoginInfo(userDto, loginId);
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
return amosLoginfo.getResult(); return amosLoginfo.getResult();
} }
private DepartmentModel getdepartmentModel(Long departmentId) { private DepartmentModel getdepartmentModel(Long departmentId) {
FeignClientResult<DepartmentModel> de = Privilege.departmentClient.seleteOne(departmentId); FeignClientResult<DepartmentModel> de = Privilege.departmentClient.seleteOne(departmentId);
...@@ -918,7 +927,7 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa ...@@ -918,7 +927,7 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa
} }
private void deleuser(String userid) { private void deleuser(String userid) {
FeignClientResult<List<String>> cResult = Privilege.agencyUserClient.multDeleteUser(userid,true); FeignClientResult<List<String>> cResult = Privilege.agencyUserClient.multDeleteUser(userid, true);
if (!ObjectUtils.isEmpty(cResult)) { if (!ObjectUtils.isEmpty(cResult)) {
if (cResult.getStatus() != 200) { if (cResult.getStatus() != 200) {
...@@ -936,20 +945,16 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa ...@@ -936,20 +945,16 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa
} }
return amosLoginfo.getResult(); return amosLoginfo.getResult();
} }
/** /**
* 分页查询 * 分页查询
*/ */
public Page<UserMapperDto> queryPage(Page<UserMapperDto> page, public Page<UserMapperDto> queryPage(Page<UserMapperDto> page, String name, String accountName, String projectName,
String name, String orgCode) {
String accountName,
String projectName, String orgCode) { List<UserMapperDto> list = personBasicMapper.queryPage((page.getCurrent() - 1) * page.getSize(), page.getSize(),
name, accountName, projectName, orgCode);
List<UserMapperDto> list = personBasicMapper.queryPage((page.getCurrent() - 1) * page.getSize(), page.getSize(), name, List<UserMapperDto> listcount = personBasicMapper.queryPagecount(name, accountName, projectName, orgCode);
accountName,
projectName, orgCode);
List<UserMapperDto> listcount = personBasicMapper.queryPagecount(name,
accountName,
projectName, orgCode);
page.setTotal(listcount.size()); page.setTotal(listcount.size());
page.setRecords(list); page.setRecords(list);
return page; return page;
...@@ -965,7 +970,6 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa ...@@ -965,7 +970,6 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa
return resultList; return resultList;
} }
// public Page<Map<String, Object>> getPersonYardByPage(String parentCode, // public Page<Map<String, Object>> getPersonYardByPage(String parentCode,
// Integer current, // Integer current,
// Integer size, // Integer size,
......
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