IntelligentRecognition/ah-jjsp-service/.svn/pristine/33/33dcdfe48283d39f7298ae118ab...

783 lines
32 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.sercurityControl.proteam.dutyTask.service;
import com.alibaba.nacos.common.utils.CollectionUtils;
import com.github.pagehelper.PageInfo;
import com.securityControl.common.core.utils.StringUtils;
import com.securityControl.common.core.utils.aes.StringHelper;
import com.securityControl.common.core.web.domain.AjaxResult;
import com.sercurityControl.proteam.dutyTask.domain.*;
import com.sercurityControl.proteam.dutyTask.mapper.SuperStatisticsMapper;
import com.sercurityControl.proteam.dutyTask.mapper.TodayTaskMapper;
import com.sercurityControl.proteam.util.DateTimeHelper;
import com.sercurityControl.proteam.util.OssUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import javax.annotation.Resource;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* 值班任务-违章统计业务逻辑层
*/
@Service(value = "SuperStatisticsService")
@Slf4j
public class SuperStatisticsServiceImpl implements SuperStatisticsService {
@Resource(name = "SuperStatisticsMapper")
private SuperStatisticsMapper mapper;
@Resource(name = "TodayTaskMapper")
private TodayTaskMapper todayTaskMapper;
@Autowired
private OssUtil ossUtil;
@Override
public PageInfo<NoticeVioEntity> getSuperStatisticsList(NoticeVioEntity noticeVioEntity) {
if (StringUtils.isNotBlank(noticeVioEntity.getOrg())) {
String[] orgArr = noticeVioEntity.getOrg().split(",");
List<String> orgList = Arrays.asList(orgArr);
noticeVioEntity.setOrgList(orgList);
}
if (StringUtils.isNotBlank(noticeVioEntity.getLevelId())) {
String[] levelIdArr = noticeVioEntity.getLevelId().split(",");
List<String> levelIdList = Arrays.asList(levelIdArr);
noticeVioEntity.setLevelIdList(levelIdList);
}
if (StringUtils.isNotBlank(noticeVioEntity.getProName())) {
String[] proNameArr = noticeVioEntity.getProName().split(",");
List<String> proNameList = Arrays.asList(proNameArr);
noticeVioEntity.setProNameList(proNameList);
}
if (StringUtils.isNotBlank(noticeVioEntity.getRiskLevel())) {
String[] riskLevelArr = noticeVioEntity.getRiskLevel().split(",");
List<String> riskLevelList = Arrays.asList(riskLevelArr);
noticeVioEntity.setRiskLevelList(riskLevelList);
}
if (StringUtils.isNotBlank(noticeVioEntity.getStatus())) {
String[] statusArr = noticeVioEntity.getStatus().split(",");
List<String> statusList = Arrays.asList(statusArr);
noticeVioEntity.setStatusList(statusList);
}
List<NoticeVioEntity> list = mapper.getSuperStatisticsList(noticeVioEntity);
list.forEach(item -> {
String teamLeader = null;
if (StringUtils.isNotBlank(item.getTeamId())) {
teamLeader = mapper.getTeamLeader(item.getTeamId(), 1);
} else {
teamLeader = mapper.getTeamLeader(item.getClassId(), 2);
}
item.setTeamLeader(teamLeader);
// String imgPath = item.getImgPath();
// if (StringUtils.isNotBlank(imgPath)) {
// String[] imgArr = imgPath.split(",");
// item.setImgNum(imgArr.length);
// } else {
// item.setImgNum(0);
// }
});
PageInfo<NoticeVioEntity> pageInfo = new PageInfo<>(list);
return pageInfo;
}
@Override
public PageInfo<NoticeVioEntity> getHandViolationList(NoticeVioEntity entity) {
List<NoticeVioEntity> list = mapper.getHandViolationList(entity);
PageInfo<NoticeVioEntity> pageInfo = new PageInfo<>(list);
return pageInfo;
}
@Override
public NoticeVioEntity getNoticeVoiById(String id) {
return mapper.getNoticeVoiById(id);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void editNoticeVioAndImg(NoticeVioEntity entity, List<NoticeVioImgEntity> list) {
mapper.editNoticeVio(entity);
if (CollectionUtils.isNotEmpty(list)) {
list.forEach(item -> {
item.setNotiId(entity.getId());
});
todayTaskMapper.addNoticeVioImg(list);
}
if (StringUtils.isNotBlank(entity.getDelImgIdList())) {
String[] delImgIdArr = entity.getDelImgIdList().split(",");
List<String> delImgIdList = Arrays.asList(delImgIdArr);
mapper.delNoticeVioImg(delImgIdList, entity.getId());
}
String[] vioUsersArr = entity.getVioUsers().split(",");
String[] idNumberArr = entity.getIdNumber().split(",");
String[] scoreArr = entity.getScore().split(",");
String[] oldIdNumberArr = entity.getOldIdNumber().split(",");
String[] oldScoreArr = entity.getOldScore().split(",");
List<NoticePeoEntity> newNoticePeoList = new ArrayList<>();
List<NoticePeoEntity> oldNoticePeoList = new ArrayList<>();
// 修改的违章人员
for (int i = 0; i < idNumberArr.length; i++) {
for (int j = 0; j < oldIdNumberArr.length; j++) {
if (Objects.equals(idNumberArr[i], oldIdNumberArr[j]) && !Objects.equals(scoreArr[i], oldScoreArr[j])) {
NoticePeoEntity noticePeoEntity = new NoticePeoEntity();
noticePeoEntity.setName(vioUsersArr[i]);
noticePeoEntity.setIdNumber(idNumberArr[i]);
noticePeoEntity.setScore(scoreArr[i]);
noticePeoEntity.setClassId(entity.getClassId());
noticePeoEntity.setNotiId(entity.getId());
oldNoticePeoList.add(noticePeoEntity);
}
}
}
if (CollectionUtils.isNotEmpty(oldNoticePeoList)) {
mapper.editNoticePeo(oldNoticePeoList, entity.getId());
}
// 删除的违章人员
List<String> delPeo = getDelOrAdd(Arrays.asList(oldIdNumberArr), Arrays.asList(idNumberArr));
if (CollectionUtils.isNotEmpty(delPeo)) {
mapper.delNoticePeo(delPeo, entity.getId());
}
// 新增的违章人员
List<String> addPeo = getDelOrAdd(Arrays.asList(idNumberArr), Arrays.asList(oldIdNumberArr));
if (CollectionUtils.isNotEmpty(addPeo)) {
for (int i = 0; i < idNumberArr.length; i++) {
for (int j = 0; j < addPeo.size(); j++) {
if (idNumberArr[i] == addPeo.get(j)) {
NoticePeoEntity noticePeoEntity = new NoticePeoEntity();
noticePeoEntity.setName(vioUsersArr[i]);
noticePeoEntity.setIdNumber(idNumberArr[i]);
noticePeoEntity.setScore(scoreArr[i]);
noticePeoEntity.setClassId(entity.getClassId());
noticePeoEntity.setNotiId(entity.getId());
newNoticePeoList.add(noticePeoEntity);
}
}
}
todayTaskMapper.insertTeamBlack(newNoticePeoList);
todayTaskMapper.addNoticePeo(newNoticePeoList);
}
}
/**
* @return java.util.List<java.lang.String>
* @Author ccw
* @Description 方法主要用于返回list1中有的数据而list2没有的当list1和list2数据相同时返回空的list
* @Date 16:45 2022/5/11
* @Param [list1, list2]
*/
public static List<String> getDelOrAdd(List<String> list1, List<String> list2) {
//空间换时间 降低时间复杂度
Map<Object, Object> tempMap = new HashMap<>(16);
for (String str : list2) {
tempMap.put(str, str);
}
//LinkedList 频繁添加删除 也可以ArrayList容量初始化为List1.size(),防止数据量过大时频繁扩容以及数组复制
List<String> resList = new LinkedList<>();
for (String str : list1) {
if (!tempMap.containsKey(str)) {
resList.add(str);
}
}
return resList;
}
@Override
public void delNoticeVoiById(String id, String type) {
//删除违章单、人员信息、图片
mapper.delNoticeVoiById(id, 1);
mapper.delNoticeVoiById(id, 2);
mapper.delNoticeVoiById(id, 3);
if (Objects.equals("2", type)) { // 删除整改信息
mapper.delNoticeVoiById(id, 4);
}
}
@Override
public PageInfo<VoiTypeEntity> getVoiTypeList(VoiTypeEntity voiTypeEntity) {
if (StringUtils.isNotBlank(voiTypeEntity.getCode())) {
String[] codeArr = voiTypeEntity.getCode().split(",");
List<String> codeList = Arrays.asList(codeArr);
voiTypeEntity.setCodeList(codeList);
}
List<VoiTypeEntity> list = mapper.getVoiTypeList(voiTypeEntity);
PageInfo<VoiTypeEntity> pageInfo = new PageInfo<>(list);
return pageInfo;
}
@Override
public int voiTypeIsExist(String code) {
return mapper.voiTypeIsExist(code);
}
@Override
public int getVoiTypePid() {
return mapper.getVoiTypePid();
}
@Override
@Transactional(rollbackFor = Exception.class)
public void addVoiType(VoiTypeEntity voiTypeEntity) {
mapper.addVoiType(voiTypeEntity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void updateVoiType(VoiTypeEntity voiTypeEntity) {
mapper.updateVoiType(voiTypeEntity);
}
@Override
public VoiTypeEntity getVoiTypeById(String param) {
return mapper.getVoiTypeById(param);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delVoiTypeById(String param) {
mapper.delVoiTypeById(param);
}
@Override
public PageInfo<VoiInfoEntity> getVoiInfoList(VoiInfoEntity voiInfoEntity) {
List<VoiInfoEntity> list = mapper.getVoiInfoList(voiInfoEntity);
PageInfo<VoiInfoEntity> pageInfo = new PageInfo<>(list);
return pageInfo;
}
@Override
public int voiInfoIsExist(VoiInfoEntity voiInfoEntity) {
return mapper.voiInfoIsExist(voiInfoEntity);
}
@Override
public void addVoiInfo(VoiInfoEntity voiInfoEntity) {
String[] notiInfoArr = voiInfoEntity.getNotiInfo().split(";");
List<VoiInfoEntity> list = new ArrayList<>();
for (String notiInfo : notiInfoArr) {
VoiInfoEntity entity = new VoiInfoEntity();
entity.setNotiInfo(notiInfo);
entity.setVoiTypeId(voiInfoEntity.getVoiTypeId());
list.add(entity);
}
mapper.addVoiInfo(list);
}
@Override
public void updateVoiInfo(VoiInfoEntity voiInfoEntity) {
mapper.updateVoiInfo(voiInfoEntity);
}
@Override
public VoiInfoEntity getVoiInfoById(String param) {
return mapper.getVoiInfoById(param);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delVoiInfoById(String param) {
mapper.delVoiInfoById(param);
}
@Override
public int isHasVoiInfo(String param) {
return mapper.isHasVoiInfo(param);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void addImportVoiInfo(List<VoiInfoEntity> list) {
mapper.addVoiInfo(list);
}
@Override
public List<Map<String, Object>> getTicketNo(String param, String currentUserId, String isSup) {
return mapper.getTicketNo(param, currentUserId, isSup);
}
@Override
public NoticeVioEntity getNoticeVoiRectById(String id) {
NoticeVioEntity entity = mapper.getNoticeVoiRectById(id);
try {
List<UserPeopleVo> userList = mapper.getNoticeVoPeople(id);
entity.setUserList(userList);
// entity.setBase64List(ossUtil.getBase64List(entity.getImgPath(),1));
List<NoticeVoiRectEntity> list = mapper.getVoiRectList(id, "1");
// list.forEach(item->{
// item.setBase64List(ossUtil.getBase64List(item.getImagePath(),1));
// });
entity.setList(list);
} catch (Exception e) {
log.error(e.toString(), e);
}
return entity;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void addNoticeVioRectAndImg(NoticeVoiRectEntity entity, NoticeVioEntity vioEntity, List<NoticeVioImgEntity> list) {
if (StringHelper.isNotEmpty(entity.getUsersParam())) {
updateUser(entity);
}
int num = mapper.updateNoticeVio(vioEntity);
mapper.addNoticeVioRect(entity);
list.forEach(item -> {
item.setId(entity.getId());
});
mapper.addNoticeVioRectImg(list);
}
/**
* 修改用户
*
* @param vo
*/
public void updateUser(NoticeVoiRectEntity vo) {
try {
String[] idNumbers = vo.getUsersParam().split(",");
String[] userNames = vo.getNamesParam().split(",");
int num = mapper.delNoticePeos(vo.getClassParam(), vo.getNotiId());
if (num > 0) {
List<NoticePeoEntity> list = new ArrayList<>();
for (int i = 0; i < idNumbers.length; i++) {
NoticePeoEntity entity = new NoticePeoEntity();
entity.setNotiId(vo.getNotiId());
entity.setScore(vo.getScoreParam());
entity.setIdNumber(idNumbers[i]);
entity.setName(userNames[i]);
entity.setClassId(vo.getClassParam());
list.add(entity);
}
todayTaskMapper.addNoticePeo(list);
}
} catch (Exception e) {
log.error(e.toString(), e);
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public void rectCheck(NoticeVoiRectEntity entity) {
if (Objects.equals("3", entity.getStatus())) { // 申诉被驳回/整改被驳回 重置地市整改状态
entity.setIsAppeal(null);
} else if (Objects.equals("5", entity.getStatus())) {
entity.setCreateTime(DateTimeHelper.getNowTime());
}
mapper.rectCheck(entity, 1);
mapper.rectCheck(entity, 2);
}
@Override
public Map<String, Object> getNoticeSheet(NoticeVioEntity entity) throws ParseException {
Map<String, Object> map = new HashMap<>(16);
NoticeVioEntity noticeVioEntity = mapper.getVoiNotice(entity);
noticeVioEntity.setProName(noticeVioEntity.getProName() + setTeamValue(noticeVioEntity.getTeamName()));
String serNo = noticeVioEntity.getSerNo();
if (Integer.parseInt(noticeVioEntity.getSerNo()) < 10) {
serNo = "0" + noticeVioEntity.getSerNo();
}
String createTime = "";
Date date = new SimpleDateFormat("yyyy-MM-dd").parse(noticeVioEntity.getCreateTime());
createTime = new SimpleDateFormat("yyyy年MM月dd日").format(date);
noticeVioEntity.setSerNo(noticeVioEntity.getCreateTime().replaceAll("-", "") + "-" + serNo);
noticeVioEntity.setCreateTime(createTime);
// noticeVioEntity.setBase64List(ossUtil.getBase64List(noticeVioEntity.getImgPath(),1));
if (Objects.equals("5", noticeVioEntity.getStatus())) {
String createTime2 = "";
NoticeVoiRectEntity noticeVoiRectEntity = mapper.getVoiNoticeRect(entity);
Date date2 = new SimpleDateFormat("yyyy-MM-dd").parse(noticeVoiRectEntity.getRectFinshTime());
createTime2 = new SimpleDateFormat("yyyy.MM.dd").format(date2);
noticeVoiRectEntity.setRectFinshTime(createTime2);
noticeVoiRectEntity.setStatus("已整改");
// noticeVoiRectEntity.setBase64List(ossUtil.getBase64List(noticeVoiRectEntity.getImagePath(),1));
map.put("noticeVoiRectEntity", noticeVoiRectEntity);
}
NoticeVioEntity noticeVioEntity2 = mapper.getNoticeSheet2(entity);
if (Objects.nonNull(noticeVioEntity2)) {
noticeVioEntity.setWorkContent(noticeVioEntity2.getWorkContent());
noticeVioEntity.setSgUnit(noticeVioEntity2.getSgUnit());
noticeVioEntity.setJlUnit(noticeVioEntity2.getJlUnit());
}
map.put("noticeVioEntity", noticeVioEntity);
return map;
}
@Override
public List<Map<String, Object>> getOrgNumAndRate(NoticeVioEntity noticeVioEntity) {
if (StringUtils.isNotBlank(noticeVioEntity.getOrg())) {
String[] orgArr = noticeVioEntity.getOrg().split(",");
List<String> orgList = Arrays.asList(orgArr);
noticeVioEntity.setOrgList(orgList);
}
if (StringUtils.isNotBlank(noticeVioEntity.getLevelId())) {
String[] levelIdArr = noticeVioEntity.getLevelId().split(",");
List<String> levelIdList = Arrays.asList(levelIdArr);
noticeVioEntity.setLevelIdList(levelIdList);
}
if (StringUtils.isNotBlank(noticeVioEntity.getProName())) {
String[] proNameArr = noticeVioEntity.getProName().split(",");
List<String> proNameList = Arrays.asList(proNameArr);
noticeVioEntity.setProNameList(proNameList);
}
if (StringUtils.isNotBlank(noticeVioEntity.getRiskLevel())) {
String[] riskLevelArr = noticeVioEntity.getRiskLevel().split(",");
List<String> riskLevelList = Arrays.asList(riskLevelArr);
noticeVioEntity.setRiskLevelList(riskLevelList);
}
if (StringUtils.isNotBlank(noticeVioEntity.getStatus())) {
String[] statusArr = noticeVioEntity.getStatus().split(",");
List<String> statusList = Arrays.asList(statusArr);
noticeVioEntity.setStatusList(statusList);
}
List<Map<String, Object>> list = mapper.getOrgNumAndRate(noticeVioEntity);
int totalNum = 0;
for (Map<String, Object> map : list) {
totalNum += Integer.parseInt(String.valueOf(map.get("num")));
}
DecimalFormat decimalFormat = new DecimalFormat("0.00%");
for (Map<String, Object> map : list) {
if (totalNum == 0 || Integer.parseInt(String.valueOf(map.get("num"))) == 0) {
map.put("rate", "0.00%");
} else {
map.put("rate", decimalFormat.format(Integer.parseInt(String.valueOf(map.get("num"))) * 1.0 / totalNum * 1.0));
}
}
return list;
}
@Override
public PageInfo<NoticeVioEntity> getVoiRecordList(NoticeVioEntity noticeVioEntity) {
List<NoticeVioEntity> list = mapper.getVoiRecordList(noticeVioEntity);
PageInfo<NoticeVioEntity> pageInfo = new PageInfo<>(list);
return pageInfo;
}
/**
* @return java.lang.String
* @author cw chen
* @description 设置班组名称
* @Param value
* @date 2023-06-12 10:41
*/
public static String setTeamValue(String value) {
if (StringUtils.isNotBlank(value)) {
return "" + value + "";
}
return "";
}
@Override
@Transactional(rollbackFor = Exception.class)
public void refreshNoticeVoiData() {
List<NoticeVioEntity> list = mapper.getNoticeVoiData();
if (CollectionUtils.isNotEmpty(list)) {
list.forEach(item -> {
mapper.updateNoticeVoiInfo(item);
});
}
}
@Override
public Map<String, Object> getViolationTypeList(NoticeVioEntity noticeVioEntity) {
if (StringUtils.isNotBlank(noticeVioEntity.getOrg())) {
String[] orgArr = noticeVioEntity.getOrg().split(",");
List<String> orgList = Arrays.asList(orgArr);
noticeVioEntity.setOrgList(orgList);
}
if (StringUtils.isNotBlank(noticeVioEntity.getLevelId())) {
String[] levelIdArr = noticeVioEntity.getLevelId().split(",");
List<String> levelIdList = Arrays.asList(levelIdArr);
noticeVioEntity.setLevelIdList(levelIdList);
}
if (StringUtils.isNotBlank(noticeVioEntity.getProName())) {
String[] proNameArr = noticeVioEntity.getProName().split(",");
List<String> proNameList = Arrays.asList(proNameArr);
noticeVioEntity.setProNameList(proNameList);
}
if (StringUtils.isNotBlank(noticeVioEntity.getRiskLevel())) {
String[] riskLevelArr = noticeVioEntity.getRiskLevel().split(",");
List<String> riskLevelList = Arrays.asList(riskLevelArr);
noticeVioEntity.setRiskLevelList(riskLevelList);
}
if (StringUtils.isNotBlank(noticeVioEntity.getStatus())) {
String[] statusArr = noticeVioEntity.getStatus().split(",");
List<String> statusList = Arrays.asList(statusArr);
noticeVioEntity.setStatusList(statusList);
}
Map<String, Object> map = new HashMap<>(16);
List<Map<String, Object>> typeList = new ArrayList<>();
List<Map<String, Object>> levelIdList = new ArrayList<>();
String[] strArr = {"建议整改", "一般违章", "严重违章", "装置违章", "管理违章", "行为违章"};
for (int i = 0; i < strArr.length; i++) {
Map<String, Object> map1 = new HashMap<>(16);
noticeVioEntity.setStatisticsType(strArr[i]);
noticeVioEntity.setType("2");
if (i < 3) {
noticeVioEntity.setType("1");
}
List<Map<String, Object>> list = mapper.getViolationTypeList(noticeVioEntity);
map1.put("name", strArr[i]);
map1.put("value", Integer.parseInt(list.get(0).get("num").toString()));
if (i < 3) {
typeList.add(map1);
} else {
levelIdList.add(map1);
}
}
map.put("typeList", typeList);
map.put("levelIdList", levelIdList);
return map;
}
@Override
public PageInfo<NoticeVioEntity> getProVoiRecordList(NoticeVioEntity noticeVioEntity) {
List<NoticeVioEntity> list = mapper.getProVoiRecordList(noticeVioEntity);
PageInfo<NoticeVioEntity> pageInfo = new PageInfo<>(list);
return pageInfo;
}
@Override
public List<Map<String, String>> getBasicInfo(String classId) {
List<Map<String, String>> list = null;
try {
list = mapper.getBasicInfo(classId);
} catch (Exception e) {
log.error("获取 施工单位、监理单位、班组负责人及电话", e);
}
return list;
}
@Override
public List<String> getVoiImgs(String id) {
List<String> list = new ArrayList<>();
try {
list = mapper.getVoiImgs(id);
} catch (Exception e) {
log.error("获取违章照片", e);
}
return list;
}
@Override
public NoticeVioEntity getNoticeSheet2(NoticeVioEntity entity) {
return mapper.getNoticeSheet2(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public AjaxResult checkVoiStatus(NoticeVioEntity dto) {
try {
if (Objects.equals("8", dto.getStatus())) {
dto.setRemark(DateTimeHelper.getNowTime() + "@" + dto.getRemark());
}else if(Objects.equals("11", dto.getStatus())){
dto.setStatus("1");
dto.setResource("1");
}
mapper.checkVoiStatus(dto);
} catch (Exception e) {
log.error("值长审核 违章单", e);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return AjaxResult.error();
}
return AjaxResult.success();
}
@Override
@Transactional(rollbackFor = Exception.class)
public AjaxResult rebackVoiStatus(NoticeVioEntity dto) {
try {
mapper.rebackVoiStatus(dto);
} catch (Exception e) {
log.error("违章单回撤", e);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return AjaxResult.error();
}
return AjaxResult.success();
}
@Override
public List<NoticeVioEntity> getVoiCheckLists(NoticeVioEntity vo) {
List<NoticeVioEntity> list = new ArrayList<>();
try {
if (StringUtils.isNotEmpty(vo.getCreateTime())) {
String[] dateArr = vo.getCreateTime().split(" - ");
vo.setCreateTime(dateArr[0]);
vo.setEndTime(dateArr[1]);
} else {
vo.setCreateTime(DateTimeHelper.getNowDate());
vo.setEndTime(DateTimeHelper.getNowDate());
}
list = mapper.getVoiCheckLists(vo);
return list;
} catch (Exception e) {
log.error("违章审核记录列表", e);
}
return list;
}
@Override
public AjaxResult getTypeChildList(String typeId) {
List<Map<String, String>> list = new ArrayList<>();
list = mapper.getTypeChildList(typeId);
return AjaxResult.success(list);
}
@Override
public AjaxResult getTeamVoiNum(String classId, String teamLeaderNumber,String teamId) {
Map<String, Object> map = new HashMap<>();
try {
if (StringUtils.isEmpty(teamId)) {
teamId = mapper.getTeamLeaderNumber(classId);
}
List<Map<String, String>> list = mapper.getTeamVoiNum(teamId, 1);
// 违章类型、违章等级
List<String> voiLevelList = mapper.getVoiDist("voi_level");
List<String> voiTypeList = mapper.getVoiDist("voi_type");
for (String voiType : voiTypeList) {
List<Map<String, String>> typeChildList = mapper.getTypeChildList(voiType);
List<Map<String, Object>> childTypeListMap = totalVoiNum2(list, typeChildList);
if(Objects.equals(voiType,"管理违章")){
map.put("manage_voi",childTypeListMap);
}else if(Objects.equals(voiType,"行为违章")){
map.put("active_voi",childTypeListMap);
}else if(Objects.equals(voiType,"装置违章")){
map.put("device_voi",childTypeListMap);
}
}
List<Map<String, Object>> levelNumList = totalVoiNum(list, voiLevelList, "level");
List<Map<String, Object>> typeNumList = totalVoiNum(list, voiTypeList, "type");
map.put("levelNumList",levelNumList);
map.put("typeNumList",typeNumList);
} catch (Exception e) {
log.error("查询班组历史违章记录违章类型数量/违章等级数量");
}
return AjaxResult.success(map);
}
public List<Map<String, Object>> totalVoiNum(List<Map<String, String>> list, List<String> voiList, String voiType) {
List<Map<String, Object>> dataList = new ArrayList<>();
for (String voi : voiList) {
Map<String, Object> map = new HashMap<>();
map.put("name", voi);
int num = 0;
if (CollectionUtils.isNotEmpty(list)) {
for (Map<String, String> stringMap : list) {
String voiStr = String.valueOf(stringMap.get(voiType));
if (Objects.equals(voiStr, voi)) {
num++;
}
}
}
map.put("value", num);
dataList.add(map);
}
return dataList;
}
public List<Map<String, Object>> totalVoiNum2(List<Map<String, String>> list, List<Map<String, String>> voiList) {
List<Map<String, Object>> dataList = new ArrayList<>();
for (Map<String, String> map : voiList) {
Map<String, Object> dataMap = new HashMap<>();
String childTypeName = String.valueOf(map.get("name"));
dataMap.put("name", childTypeName);
int num = 0;
if (CollectionUtils.isNotEmpty(list)) {
for (Map<String, String> stringMap : list) {
String voiStr = String.valueOf(stringMap.get("childType"));
if (Objects.equals(voiStr, childTypeName)) {
num++;
}
}
}
dataMap.put("value", num);
dataList.add(dataMap);
}
return dataList;
}
@Override
public PageInfo<NoticeVioEntity> getTeamVoiHistory(NoticeVioEntity noticeVioEntity) {
if (StringUtils.isEmpty(noticeVioEntity.getTeamLeaderNumber())) {
String teamLeaderNumber = mapper.getTeamLeaderNumber(noticeVioEntity.getClassId());
noticeVioEntity.setTeamLeaderNumber(teamLeaderNumber);
}
List<NoticeVioEntity> list = mapper.getTeamVoiHistory(noticeVioEntity);
PageInfo<NoticeVioEntity> pageInfo = new PageInfo<>(list);
return pageInfo;
}
@Override
public AjaxResult getChildTypeList(NoticeVioEntity noticeVioEntity) {
Map<String, Object> map = new HashMap<>();
try {
if (StringUtils.isNotBlank(noticeVioEntity.getOrg())) {
String[] orgArr = noticeVioEntity.getOrg().split(",");
List<String> orgList = Arrays.asList(orgArr);
noticeVioEntity.setOrgList(orgList);
}
if (StringUtils.isNotBlank(noticeVioEntity.getLevelId())) {
String[] levelIdArr = noticeVioEntity.getLevelId().split(",");
List<String> levelIdList = Arrays.asList(levelIdArr);
noticeVioEntity.setLevelIdList(levelIdList);
}
if (StringUtils.isNotBlank(noticeVioEntity.getProName())) {
String[] proNameArr = noticeVioEntity.getProName().split(",");
List<String> proNameList = Arrays.asList(proNameArr);
noticeVioEntity.setProNameList(proNameList);
}
if (StringUtils.isNotBlank(noticeVioEntity.getRiskLevel())) {
String[] riskLevelArr = noticeVioEntity.getRiskLevel().split(",");
List<String> riskLevelList = Arrays.asList(riskLevelArr);
noticeVioEntity.setRiskLevelList(riskLevelList);
}
if (StringUtils.isNotBlank(noticeVioEntity.getStatus())) {
String[] statusArr = noticeVioEntity.getStatus().split(",");
List<String> statusList = Arrays.asList(statusArr);
noticeVioEntity.setStatusList(statusList);
}
List<Map<String, String>> list = mapper.getChildTypeList(noticeVioEntity);
// 违章类型、违章等级
List<String> voiLevelList = mapper.getVoiDist("voi_level");
List<String> voiTypeList = mapper.getVoiDist("voi_type");
for (String voiType : voiTypeList) {
List<Map<String, String>> typeChildList = mapper.getTypeChildList(voiType);
List<Map<String, Object>> childTypeListMap = totalVoiNum2(list, typeChildList);
if(Objects.equals(voiType,"管理违章")){
map.put("manage_voi",childTypeListMap);
}else if(Objects.equals(voiType,"行为违章")){
map.put("active_voi",childTypeListMap);
}else if(Objects.equals(voiType,"装置违章")){
map.put("device_voi",childTypeListMap);
}
}
List<Map<String, Object>> levelNumList = totalVoiNum(list, voiLevelList, "level");
List<Map<String, Object>> typeNumList = totalVoiNum(list, voiTypeList, "type");
map.put("levelNumList",levelNumList);
map.put("typeNumList",typeNumList);
} catch (Exception e) {
log.error("",e);
}
return AjaxResult.success(map);
}
@Override
public PageInfo<NoticeVioEntity> getVioNoticeByDirector(NoticeVioEntity noticeVioEntity) {
List<NoticeVioEntity> list = mapper.getVioNoticeByDirector(noticeVioEntity);
PageInfo<NoticeVioEntity> pageInfo = new PageInfo<>(list);
return pageInfo;
}
}