风险预测提交

This commit is contained in:
pengjie 2024-06-18 16:00:55 +08:00
parent 34bd1679b4
commit c46e7a0505

View File

@ -0,0 +1,54 @@
package com.zhgd.xmgl.modules.xz.controller;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.wflow.workflow.bean.vo.ProcessInstanceVo;
import com.zhgd.jeecg.common.api.vo.Result;
import com.zhgd.xmgl.modules.worker.entity.WorkerInfo;
import com.zhgd.xmgl.modules.worker.service.IWorkerInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.MapUtils;
import org.flowable.engine.history.HistoricProcessInstance;
import org.flowable.engine.history.HistoricProcessInstanceQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/xmgl/xzRiskPrediction")
@Slf4j
@Api(tags = "星纵-风险预测")
public class XzRiskPredictionController {
@Autowired
private IWorkerInfoService workerInfoService;
@ApiOperation(value = "查询总项目的人员风险趋势分析", notes = "查询总项目的人员风险趋势分析", httpMethod = "GET")
@ApiImplicitParams({
@ApiImplicitParam(name = "projectSn", value = "项目SN", paramType = "query", required = true, dataType = "String"),
})
@GetMapping(value = "/getWorkerRiskByProject")
public Result<Map<String, Object>> getWorkerRiskByProject(@ApiIgnore @RequestParam HashMap<String, Object> param) {
String projectSn = MapUtils.getString(param, "projectSn");
Map<String, Object> resultMap = new HashMap<>();
List<WorkerInfo> list = workerInfoService.list(Wrappers.<WorkerInfo>lambdaQuery().eq(WorkerInfo::getProjectSn, projectSn));
resultMap.put("total", list.size());
long count = list.stream().filter(l -> StringUtils.isNotBlank(l.getBirthday()) && DateUtil.ageOfNow(l.getBirthday()) >= 50).count();
resultMap.put("age", count);
return Result.success(resultMap);
}
}