543 lines
20 KiB
Plaintext
543 lines
20 KiB
Plaintext
package com.sercurityControl.proteam.service.impl;
|
|
|
|
import com.alibaba.nacos.common.utils.CollectionUtils;
|
|
import com.alibaba.nacos.common.utils.UuidUtils;
|
|
import com.github.pagehelper.PageInfo;
|
|
import com.google.common.collect.Maps;
|
|
import com.securityControl.common.core.utils.StringUtils;
|
|
import com.securityControl.common.core.utils.aes.DateTimeHelper;
|
|
import com.securityControl.common.core.utils.aes.StringHelper;
|
|
import com.securityControl.common.core.web.controller.BaseController;
|
|
import com.securityControl.common.core.web.domain.AjaxResult;
|
|
import com.securityControl.common.security.utils.SecurityUtils;
|
|
import com.sercurityControl.proteam.domain.EarlyEntity;
|
|
import com.sercurityControl.proteam.domain.vo.UserHandleVo;
|
|
import com.sercurityControl.proteam.mapper.EarlyMapper;
|
|
import com.sercurityControl.proteam.service.EarlyService;
|
|
import com.sercurityControl.proteam.service.TeamService;
|
|
import com.sercurityControl.proteam.util.ExcelUtil;
|
|
import io.swagger.annotations.Api;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
|
|
/**
|
|
* @author bonus
|
|
* @data 2022/12/8 9:39
|
|
* @description 预警
|
|
*/
|
|
@Slf4j
|
|
@Service
|
|
public class EarlyServiceImpl implements EarlyService {
|
|
|
|
@Autowired
|
|
private EarlyMapper mapper;
|
|
|
|
/**
|
|
* 获取数量
|
|
*/
|
|
@Override
|
|
public AjaxResult getEarlyNum(EarlyEntity entity) {
|
|
Map<Integer, Integer> map = new HashMap<Integer, Integer>(6);
|
|
try {
|
|
map.put(0, mapper.getNoWorkByDayNum(entity));
|
|
map.put(1, mapper.getNewTeamNum(entity));
|
|
map.put(2, mapper.getNoWorkBySevenNum(entity));
|
|
map.put(3, mapper.getTeamByPerNum(entity));
|
|
map.put(4, mapper.getTeamByWorkNum(entity));
|
|
map.put(8, mapper.getTeamByJobNum(entity));
|
|
map.put(5, mapper.getFocusWorkNum(entity));
|
|
map.put(6, mapper.getBallByUnusualNum(entity));
|
|
map.put(7, mapper.getBallSignalNum(entity));
|
|
/*List<EarlyEntity> list = mapper.getBallSignal(entity);
|
|
if (CollectionUtils.isNotEmpty(list)) {
|
|
List<EarlyEntity> filterList = list.stream().filter(o -> new Double(o.getQjXh()) <= 30.0).collect(Collectors.toList());
|
|
map.put(7, filterList.size());
|
|
} else {
|
|
map.put(7, 0);
|
|
}*/
|
|
return AjaxResult.success(map);
|
|
} catch (Exception e) {
|
|
map.put(0, 0);
|
|
map.put(1, 0);
|
|
map.put(2, 0);
|
|
map.put(3, 0);
|
|
map.put(4, 0);
|
|
map.put(5, 0);
|
|
map.put(7, 0);
|
|
return AjaxResult.success(map);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 今日无施工
|
|
*
|
|
* @param entity 实体类
|
|
* @return 集合
|
|
*/
|
|
@Override
|
|
public List<EarlyEntity> getNoWorkByDay(EarlyEntity entity) {
|
|
if (StringUtils.isNotBlank(entity.getOrg())) {
|
|
String[] arr = entity.getOrg().split(",");
|
|
List<String> list = Arrays.asList(arr);
|
|
entity.setOrgList(list);
|
|
}
|
|
return mapper.getNoWorkByDay(entity);
|
|
}
|
|
|
|
/**
|
|
* 新进班组
|
|
*
|
|
* @param entity 实体类
|
|
* @return 集合
|
|
*/
|
|
@Override
|
|
public List<EarlyEntity> getNewTeam(EarlyEntity entity) {
|
|
if (StringUtils.isNotBlank(entity.getOrg())) {
|
|
String[] arr = entity.getOrg().split(",");
|
|
List<String> list = Arrays.asList(arr);
|
|
entity.setOrgList(list);
|
|
}
|
|
return mapper.getNewTeam(entity);
|
|
}
|
|
|
|
/**
|
|
* 七日无施工
|
|
*
|
|
* @param entity 实体类
|
|
* @return 集合
|
|
*/
|
|
@Override
|
|
public List<EarlyEntity> getNoWorkBySeven(EarlyEntity entity) {
|
|
if (StringUtils.isNotBlank(entity.getOrg())) {
|
|
String[] arr = entity.getOrg().split(",");
|
|
List<String> list = Arrays.asList(arr);
|
|
entity.setOrgList(list);
|
|
}
|
|
return mapper.getNoWorkBySeven(entity);
|
|
}
|
|
|
|
/**
|
|
* 重点关注
|
|
*
|
|
* @param entity 实体类
|
|
* @return 集合
|
|
*/
|
|
@Override
|
|
public List<EarlyEntity> getFocusWork(EarlyEntity entity) {
|
|
if (StringUtils.isNotBlank(entity.getOrg())) {
|
|
String[] arr = entity.getOrg().split(",");
|
|
List<String> list = Arrays.asList(arr);
|
|
entity.setOrgList(list);
|
|
}
|
|
return mapper.getFocusWork(entity);
|
|
}
|
|
|
|
/**
|
|
* 作业类型,工序变化
|
|
*
|
|
* @param entity 实体类
|
|
* @return 集合
|
|
*/
|
|
@Override
|
|
public List<EarlyEntity> getTeamByWork(EarlyEntity entity) {
|
|
if (StringUtils.isNotBlank(entity.getOrg())) {
|
|
String[] arr = entity.getOrg().split(",");
|
|
List<String> list = Arrays.asList(arr);
|
|
entity.setOrgList(list);
|
|
}
|
|
return mapper.getTeamByWork(entity);
|
|
}
|
|
|
|
/**
|
|
* 作业类型
|
|
*
|
|
* @param entity 实体类
|
|
* @return 集合
|
|
*/
|
|
@Override
|
|
public List<EarlyEntity> getTeamByJob(EarlyEntity entity) {
|
|
if (StringUtils.isNotBlank(entity.getOrg())) {
|
|
String[] arr = entity.getOrg().split(",");
|
|
List<String> list = Arrays.asList(arr);
|
|
entity.setOrgList(list);
|
|
}
|
|
return mapper.getTeamByJob(entity);
|
|
}
|
|
|
|
/**
|
|
* 球机异常
|
|
*
|
|
* @param entity 实体类
|
|
* @return 集合
|
|
*/
|
|
@Override
|
|
public List<EarlyEntity> getBallByUnusual(EarlyEntity entity) {
|
|
if (StringUtils.isNotBlank(entity.getOrg())) {
|
|
String[] arr = entity.getOrg().split(",");
|
|
List<String> list = Arrays.asList(arr);
|
|
entity.setOrgList(list);
|
|
}
|
|
if (StringUtils.isNotBlank(entity.getRiskLevel())) {
|
|
String[] arr = entity.getRiskLevel().split(",");
|
|
List<String> list = Arrays.asList(arr);
|
|
entity.setRiskList(list);
|
|
}
|
|
return mapper.getBallByUnusual(entity);
|
|
}
|
|
|
|
/**
|
|
* 文件导出
|
|
*
|
|
* @param entity 实体类
|
|
* @return 文件
|
|
*/
|
|
@Override
|
|
public Workbook exportToExcel(EarlyEntity entity) {
|
|
if (StringUtils.isNotBlank(entity.getOrg())) {
|
|
String[] arr = entity.getOrg().split(",");
|
|
List<String> list = Arrays.asList(arr);
|
|
entity.setOrgList(list);
|
|
}
|
|
if (StringUtils.isNotBlank(entity.getRiskLevel())) {
|
|
String[] arr = entity.getRiskLevel().split(",");
|
|
List<String> list = Arrays.asList(arr);
|
|
entity.setRiskList(list);
|
|
}
|
|
if (!StringUtils.isNotBlank(entity.getType())) {
|
|
entity.setType("0");
|
|
}
|
|
String[] arr;
|
|
List<EarlyEntity> list;
|
|
switch (Integer.parseInt(entity.getType())) {
|
|
case 1:
|
|
list = mapper.getNewTeam(entity);
|
|
for (EarlyEntity vo : list) {
|
|
vo.setFzrNum(null);
|
|
vo.setWarnType(null);
|
|
vo.setType(null);
|
|
vo.setPuid(null);
|
|
vo.setClassId(null);
|
|
vo.setTCode(null);
|
|
vo.setTdCode(null);
|
|
vo.setTwCode(null);
|
|
vo.setPassWay(null);
|
|
vo.setBidCode(null);
|
|
vo.setTime(null);
|
|
vo.setIsHl(null);
|
|
vo.setTzylx(null);
|
|
vo.setYzylx(null);
|
|
}
|
|
arr = new String[]{"建管单位", "工程名称", "班组长", "电话", "班组名称"};
|
|
break;
|
|
case 2:
|
|
list = mapper.getNoWorkBySeven(entity);
|
|
for (EarlyEntity vo : list) {
|
|
vo.setFzrNum(null);
|
|
vo.setWarnType(null);
|
|
vo.setType(null);
|
|
vo.setPuid(null);
|
|
vo.setClassId(null);
|
|
vo.setTCode(null);
|
|
vo.setTdCode(null);
|
|
vo.setTwCode(null);
|
|
vo.setPassWay(null);
|
|
vo.setBidCode(null);
|
|
vo.setTime(null);
|
|
vo.setIsHl(null);
|
|
vo.setTzylx(null);
|
|
vo.setYzylx(null);
|
|
}
|
|
arr = new String[]{"建管单位", "工程名称", "班组长", "电话", "班组名称"};
|
|
break;
|
|
case 3:
|
|
list = mapper.getTeamByPer(entity);
|
|
for (EarlyEntity vo : list) {
|
|
Map<String, Object> map = mapper.getWorkTeamPeopleNum(vo.getFzrNum());
|
|
if(map!=null && map.get("num")!=null){
|
|
String num = map.get("num").toString();
|
|
}else {
|
|
vo.setYNum("0");
|
|
}
|
|
vo.setFzrNum(null);
|
|
vo.setWarnType(null);
|
|
vo.setType(null);
|
|
vo.setPuid(null);
|
|
vo.setClassId(null);
|
|
vo.setTCode(null);
|
|
vo.setTdCode(null);
|
|
vo.setTwCode(null);
|
|
vo.setPassWay(null);
|
|
vo.setBidCode(null);
|
|
vo.setTime(null);
|
|
vo.setIsHl(null);
|
|
vo.setTzylx(null);
|
|
vo.setYzylx(null);
|
|
}
|
|
arr = new String[]{"建管单位", "工程名称", "工作内容", "班组长", "电话", "风险等级", "今日人数", "昨日人数"};
|
|
break;
|
|
case 4:
|
|
list = mapper.getTeamByWork(entity);
|
|
for (EarlyEntity vo : list) {
|
|
vo.setFzrNum(null);
|
|
vo.setWarnType(null);
|
|
vo.setType(null);
|
|
vo.setPuid(null);
|
|
vo.setClassId(null);
|
|
vo.setTCode(null);
|
|
vo.setTdCode(null);
|
|
vo.setTwCode(null);
|
|
vo.setPassWay(null);
|
|
vo.setBidCode(null);
|
|
vo.setTime(null);
|
|
vo.setIsHl(null);
|
|
vo.setTzylx(null);
|
|
vo.setYzylx(null);
|
|
}
|
|
arr = new String[]{"建管单位", "工程名称", "班组长", "电话", "班组名称", "风险等级", "今日工序", "昨日工序"};
|
|
break;
|
|
case 8:
|
|
list = mapper.getTeamByJob(entity);
|
|
for (EarlyEntity vo : list) {
|
|
vo.setFzrNum(null);
|
|
vo.setWarnType(null);
|
|
vo.setType(null);
|
|
vo.setPuid(null);
|
|
vo.setClassId(null);
|
|
vo.setTCode(null);
|
|
vo.setTdCode(null);
|
|
vo.setTwCode(null);
|
|
vo.setPassWay(null);
|
|
vo.setBidCode(null);
|
|
vo.setTgx(null);
|
|
vo.setYgx(null);
|
|
vo.setTime(null);
|
|
vo.setIsHl(null);
|
|
}
|
|
arr = new String[]{"建管单位", "工程名称", "班组长", "电话", "班组名称", "风险等级", "今日作业类型", "昨日作业类型"};
|
|
break;
|
|
case 5:
|
|
list = mapper.getFocusWork(entity);
|
|
for (EarlyEntity vo : list) {
|
|
vo.setFzrNum(null);
|
|
vo.setWarnType(null);
|
|
vo.setType(null);
|
|
vo.setPuid(null);
|
|
vo.setClassId(null);
|
|
vo.setTCode(null);
|
|
vo.setTdCode(null);
|
|
vo.setTwCode(null);
|
|
vo.setPassWay(null);
|
|
vo.setBidCode(null);
|
|
vo.setTgx(null);
|
|
vo.setYgx(null);
|
|
vo.setTime(null);
|
|
vo.setIsHl(null);
|
|
}
|
|
arr = new String[]{"建管单位", "工程名称", "工作内容", "班组长", "电话"};
|
|
break;
|
|
case 6:
|
|
list = mapper.getBallByUnusual(entity);
|
|
for (EarlyEntity vo : list) {
|
|
vo.setFzrNum(null);
|
|
vo.setWarnType(null);
|
|
vo.setType(null);
|
|
vo.setPuid(null);
|
|
vo.setClassId(null);
|
|
vo.setTCode(null);
|
|
vo.setTdCode(null);
|
|
vo.setTwCode(null);
|
|
vo.setPassWay(null);
|
|
vo.setBidCode(null);
|
|
vo.setTgx(null);
|
|
vo.setYgx(null);
|
|
vo.setTime(null);
|
|
vo.setIsHl(null);
|
|
}
|
|
arr = new String[]{"建管单位", "工程名称", "工作内容", "班组长", "电话", "风险等级", "监控"};
|
|
break;
|
|
case 7:
|
|
List<EarlyEntity> ballSignalList = mapper.getBallSignal(entity);
|
|
list = ballSignalList.stream().filter(o -> new Double(o.getQjXh()) <= 30.0).collect(Collectors.toList());
|
|
for (EarlyEntity vo : list) {
|
|
vo.setFzrNum(null);
|
|
vo.setWarnType(null);
|
|
vo.setType(null);
|
|
vo.setClassId(null);
|
|
vo.setTCode(null);
|
|
vo.setTdCode(null);
|
|
vo.setTwCode(null);
|
|
vo.setPassWay(null);
|
|
vo.setBidCode(null);
|
|
vo.setTgx(null);
|
|
vo.setYgx(null);
|
|
vo.setTime(null);
|
|
vo.setIsHl(null);
|
|
}
|
|
arr = new String[]{"建管单位", "工程名称", "班组长", "电话", "球机信号值", "设备编码", "球机PUID"};
|
|
break;
|
|
default:
|
|
list = mapper.getNoWorkByDay(entity);
|
|
for (EarlyEntity vo : list) {
|
|
vo.setFzrNum(null);
|
|
vo.setWarnType(null);
|
|
vo.setType(null);
|
|
vo.setPuid(null);
|
|
vo.setClassId(null);
|
|
vo.setTCode(null);
|
|
vo.setTdCode(null);
|
|
vo.setTwCode(null);
|
|
vo.setPassWay(null);
|
|
vo.setBidCode(null);
|
|
vo.setTgx(null);
|
|
vo.setYgx(null);
|
|
vo.setTime(null);
|
|
vo.setIsHl(null);
|
|
}
|
|
arr = new String[]{"建管单位", "工程名称", "工作内容", "班组长", "电话"};
|
|
break;
|
|
}
|
|
return ExcelUtil.writeToExcelByList(arr, list, EarlyEntity.class);
|
|
}
|
|
|
|
/**
|
|
* 人数变化大
|
|
*
|
|
* @param entity 实体类
|
|
* @return 集合
|
|
*/
|
|
@Override
|
|
public List<EarlyEntity> getTeamByPer(EarlyEntity entity) {
|
|
if (StringUtils.isNotBlank(entity.getOrg())) {
|
|
String[] arr = entity.getOrg().split(",");
|
|
List<String> list = Arrays.asList(arr);
|
|
entity.setOrgList(list);
|
|
}
|
|
if (StringUtils.isNotBlank(entity.getRiskLevel())) {
|
|
String[] arr = entity.getRiskLevel().split(",");
|
|
List<String> list = Arrays.asList(arr);
|
|
entity.setRiskList(list);
|
|
}
|
|
List<EarlyEntity> list = mapper.getTeamByPer(entity);
|
|
for (EarlyEntity vo : list) {
|
|
Map<String, Object> map = mapper.getWorkTeamPeopleNum(vo.getFzrNum());
|
|
if(map!=null && map.get("num")!=null){
|
|
String num = map.get("num").toString();
|
|
}else {
|
|
vo.setYNum("0");
|
|
}
|
|
|
|
}
|
|
return list;
|
|
}
|
|
|
|
@Override
|
|
public List<EarlyEntity> getBallSignal(EarlyEntity entity) {
|
|
if (StringUtils.isNotBlank(entity.getOrg())) {
|
|
String[] arr = entity.getOrg().split(",");
|
|
List<String> list = Arrays.asList(arr);
|
|
entity.setOrgList(list);
|
|
}
|
|
if (StringUtils.isNotBlank(entity.getRiskLevel())) {
|
|
String[] arr = entity.getRiskLevel().split(",");
|
|
List<String> list = Arrays.asList(arr);
|
|
entity.setRiskList(list);
|
|
}
|
|
List<EarlyEntity> list = mapper.getBallSignal(entity);
|
|
// List<EarlyEntity> filterList = list.stream().filter(o -> new Double(o.getQjXh()) <= 30.0).collect(Collectors.toList());
|
|
// new PageInfo(filterList);
|
|
return list;
|
|
}
|
|
|
|
/**
|
|
* 修改班组人员忽略状态
|
|
*
|
|
* @param entity 条件
|
|
* @return json
|
|
*/
|
|
@Override
|
|
public AjaxResult updateFzrData(EarlyEntity entity) {
|
|
entity.setTime(DateTimeHelper.getNowTime());
|
|
try {
|
|
mapper.updateFzrData(entity);
|
|
return AjaxResult.success("修改成功");
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
return AjaxResult.error("修改失败");
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public AjaxResult addUserHandel(UserHandleVo entity) {
|
|
try {
|
|
int num=mapper.getHandelNum(entity);
|
|
if(num>0){
|
|
return AjaxResult.success("操作失败");
|
|
}
|
|
if(StringHelper.isEmpty(entity.getId())){//
|
|
entity.setId(UuidUtils.generateUuid().toUpperCase());
|
|
entity.setCreateTime(DateTimeHelper.getNowTime());
|
|
}
|
|
entity.setIsHl("已核实");
|
|
entity.setUpdateTime(DateTimeHelper.getNowTime());
|
|
entity.setUser(SecurityUtils.getUserId().toString());
|
|
mapper.addUserHandel(entity);
|
|
return AjaxResult.success("操作成功");
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
return AjaxResult.error("操作失败");
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public Map<String,Object> getTodayWarnInfo(EarlyEntity entity) {
|
|
Map<String,Object> map= Maps.newHashMap();
|
|
try{
|
|
if(StringHelper.isNotEmpty(entity.getTimes())){
|
|
entity.setStartTime(entity.getTime().split(" - ")[0]);
|
|
entity.setEdnTime(entity.getTime().split(" - ")[1]);
|
|
}
|
|
String type=getRoundMath();
|
|
entity.setType(type);
|
|
//未施工 的预警
|
|
List<EarlyEntity> list1 = mapper.getTickeList(entity);
|
|
|
|
List<EarlyEntity> list = new ArrayList<>(list1);
|
|
// List<EarlyEntity> list1 = mapper.getNoWorkByDay(entity);//今日未施工
|
|
List<EarlyEntity> list2 = mapper.getTeamByPer(entity);//人数变化大
|
|
list.addAll(list2);
|
|
List<EarlyEntity> list3 = mapper.getTeamByWork(entity);//工序变化
|
|
list.addAll(list3);
|
|
List<EarlyEntity> list4 = mapper.getTeamByJob(entity);//作业类型变化
|
|
list.addAll(list4);
|
|
List<EarlyEntity> list5 = mapper.getBallByUnusual(entity);//球机异常
|
|
list.addAll(list5);
|
|
List<EarlyEntity> list6 = mapper.getBallSignal(entity);//球机信号差
|
|
list.addAll(list6);
|
|
int clNum= (int) list.stream().filter(earlyEntity -> StringHelper.isNotEmpty(earlyEntity.getHandleId())).count();
|
|
map.put("data",list);
|
|
map.put("allNum",list.size());
|
|
map.put("clNum",clNum);
|
|
}catch (Exception e){
|
|
log.error(e.toString(),e);
|
|
}
|
|
return map;
|
|
}
|
|
|
|
public String getRoundMath(){
|
|
try {
|
|
Random random=new Random();
|
|
int result=random.nextInt(5);
|
|
return result+1+"";
|
|
}catch (Exception e){
|
|
return "3";
|
|
}
|
|
}
|
|
}
|