IntelligentRecognition/ah-jjsp-service/.svn/pristine/b3/b3a820f6e0a2032c2aff22bd8af...

1455 lines
63 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.controller;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
import com.alibaba.fastjson2.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.securityControl.common.core.utils.StringUtils;
import com.securityControl.common.core.utils.aes.DateTimeHelper;
import com.securityControl.common.core.web.domain.AjaxResult;
import com.securityControl.common.log.annotation.Log;
import com.securityControl.common.log.enums.BusinessType;
import com.securityControl.common.log.enums.OperationType;
import com.securityControl.common.security.utils.SecurityUtils;
import com.securityControl.system.api.model.LoginUser;
import com.sercurityControl.proteam.dutyTask.domain.*;
import com.sercurityControl.proteam.dutyTask.service.SuperStatisticsService;
import com.sercurityControl.proteam.util.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.util.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;
import javax.annotation.Resource;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
/**
* 值班任务-违章统计控制层
*/
@RestController
@RequestMapping("/pot/superStatistics/")
@Slf4j
public class SuperStatisticsController extends BaseController {
Logger logger = LoggerFactory.getLogger(TodayTaskController.class);
@Resource(name = "SuperStatisticsService")
private SuperStatisticsService service;
@Resource(name = "testTaskExecutor")
private ThreadPoolTaskExecutor testTaskExecutor;
@Autowired
private HandleDataUtil handleDataUtil;
@Value("${file.upload_path}")
private String upload_path;
@Autowired
private OssUtil ossUtil;
/**
* @return java.util.Map<java.lang.String, java.lang.Object>
* @author cw chen
* @description 违章统计列表数据
* @Param params
* @Param page
* @Param limit
* @date 2022-12-19 16:33
*/
@PostMapping(value = "getSuperStatisticsList")
@Log(title = "违章统计", menu = "值班任务->违章统计", businessType = BusinessType.QUERY, details = "违章统计列表")
public Map<String, Object> getSuperStatisticsList(NoticeVioEntity noticeVioEntity) {
if (StringUtils.isBlank(noticeVioEntity.getCreateTime())) {
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
cal.set(Calendar.DAY_OF_MONTH, 1);
noticeVioEntity.setCreateTime(new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime()));
cal.roll(Calendar.DAY_OF_MONTH, -1);
noticeVioEntity.setEndTime(new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime()));
} else {
String[] dateArr = noticeVioEntity.getCreateTime().split(" - ");
noticeVioEntity.setCreateTime(dateArr[0]);
noticeVioEntity.setEndTime(dateArr[1]);
}
PageHelper.startPage(Integer.parseInt(noticeVioEntity.getPage()), Integer.parseInt(noticeVioEntity.getLimit()));
Map<String, Object> map = new HashMap<String, Object>(6);
try {
PageInfo<NoticeVioEntity> pageInfo = service.getSuperStatisticsList(noticeVioEntity);
map.put("code", 200);
map.put("msg", "获取数据成功");
map.put("count", pageInfo.getTotal());
map.put("curr", Integer.parseInt(noticeVioEntity.getPage()));
map.put("limit", Integer.parseInt(noticeVioEntity.getLimit()));
map.put("data", pageInfo.getList());
} catch (Exception e) {
map.put("data", null);
map.put("msg", "获取数据失败");
map.put("count", 0);
map.put("code", 500);
map.put("curr", Integer.parseInt(noticeVioEntity.getPage()));
map.put("limit", Integer.parseInt(noticeVioEntity.getLimit()));
logger.error(e.toString(), e);
}
return map;
}
/**
* 获取手动下发违章数据
*
* @param entity
* @return
*/
@PostMapping(value = "getHandViolationList")
public Map<String, Object> getHandViolationList(NoticeVioEntity entity) {
if (StringUtils.isBlank(entity.getCreateTime())) {
entity.setCreateTime(DateTimeHelper.getNowDate());
}
PageHelper.startPage(Integer.parseInt(entity.getPage()), Integer.parseInt(entity.getLimit()));
Map<String, Object> map = new HashMap<String, Object>(6);
try {
PageInfo<NoticeVioEntity> pageInfo = service.getHandViolationList(entity);
map.put("code", 200);
map.put("msg", "获取数据成功");
map.put("count", pageInfo.getTotal());
map.put("curr", Integer.parseInt(entity.getPage()));
map.put("limit", Integer.parseInt(entity.getLimit()));
map.put("data", pageInfo.getList());
} catch (Exception e) {
map.put("code", 500);
map.put("msg", "获取数据失败");
map.put("count", 0);
map.put("curr", Integer.parseInt(entity.getPage()));
map.put("limit", Integer.parseInt(entity.getLimit()));
map.put("data", null);
logger.error("数据获取失败", e);
}
return map;
}
/**
* @return com.securityControl.common.core.web.domain.AjaxResult
* @author cw chen
* @description 获取oss文件
* @Param imgPath
* @date 2023-03-31 15:32
*/
@PostMapping("getVoiImgList")
public AjaxResult getVoiImgList(String imgPath) {
List<String> base64List = new ArrayList<>();
try {
return AjaxResult.success("success", ossUtil.getBase64List(imgPath, 1));
} catch (Exception e) {
logger.error("获取oss文件", e);
return AjaxResult.error("服务异常,请稍后重试");
}
}
/**
* @return com.securityControl.common.core.web.domain.AjaxResult
* @author cw chen
* @description 根据违章单id获取违章单信息
* @Param params
* @date 2022-12-19 17:39
*/
@PostMapping(value = "getNoticeVoiById")
@Log(title = "违章统计", menu = "值班任务->违章统计", businessType = BusinessType.QUERY, details = "违章详情查看")
public AjaxResult getNoticeVoiById(String params) {
try {
NoticeVioEntity noticeVioEntity = service.getNoticeVoiById(params);
// noticeVioEntity.setBase64List(ossUtil.getBase64List(noticeVioEntity.getImgPath(),1));
return AjaxResult.success("success", noticeVioEntity);
} catch (Exception e) {
logger.error("数据获取失败", e);
return AjaxResult.error("error", null);
}
}
/**
* @return com.securityControl.common.core.web.domain.AjaxResult
* @author cw chen
* @description 修改违章单
* @Param request
* @Param files
* @date 2022-12-16 15:27
*/
@PostMapping(value = "editUploadNoticeVio", headers = "content-type=multipart/form-data")
@ResponseBody
@Log(title = "违章统计", menu = "值班任务->违章统计", businessType = BusinessType.UPDATE, details = "修改违章", grade = OperationType.UPDATE_BUSINESS)
public AjaxResult uploadNoticeVio(HttpServletRequest request, @RequestParam(value = "file[]", required = false) MultipartFile[] files) {
CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver();
MultipartHttpServletRequest multiReq = multipartResolver.resolveMultipart(request);
String params = multiReq.getParameter("params");
NoticeVioEntity entity = com.alibaba.fastjson2.JSON.parseObject(params, NoticeVioEntity.class);
if (StringUtils.isEmpty(entity.getVoiStatus())) {
entity.setVoiStatus("1");
}
List<NoticeVioImgEntity> list = new ArrayList<>();
try {
if (files != null) {
for (MultipartFile item : files) {
NoticeVioImgEntity imageEntity = new NoticeVioImgEntity();
// String imgId = ossUtil.fileUpload(item);
// imageEntity.setImagePath(imgId);
String imgPath = uploadImages(item);
imageEntity.setImagePath(imgPath);
imageEntity.setImageType("1");
list.add(imageEntity);
}
}
// 修改违章通知单记录
service.editNoticeVioAndImg(entity, list);
} catch (Exception e) {
logger.error("修改违章单", e);
return AjaxResult.error("error");
}
return AjaxResult.success("success");
}
private String uploadImages(MultipartFile item) {
String image = "";
try {
String fileName = IDUtils.createID() + ".jpg";
String mkdirsName = "noticeVio"; // 违章下发
String imageFiles = upload_path + File.separator + mkdirsName;
String path = imageFiles + File.separator + DateTimeHelper.getYear(new Date()) + File.separator + DateTimeHelper.getMonth(new Date()) + File.separator + fileName;
File file = new File(path);
//生成文件夹
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
// 存入临时文件
item.transferTo(file);
image = mkdirsName + File.separator + DateTimeHelper.getYear(new Date()) + File.separator + DateTimeHelper.getMonth(new Date()) + File.separator + fileName;
return image;
} catch (Exception e) {
logger.error(e.toString(), e);
}
return image;
}
/**
* @return com.securityControl.common.core.web.domain.AjaxResult
* @author cw chen
* @description 删除违章单
* @Param params type
* @date 2022-12-20 14:33
*/
@PostMapping("delNoticeVoiById")
@ResponseBody
@Log(title = "违章统计", menu = "值班任务->违章统计", businessType = BusinessType.DELETE, details = "删除违章", grade = OperationType.DELETE_BUSINESS)
public AjaxResult delNoticeVoiById(String params, String type) {
try {
service.delNoticeVoiById(params, type);
return AjaxResult.success("success");
} catch (Exception e) {
logger.error("删除数据", e);
return AjaxResult.error("服务异常,请稍后重试");
}
}
/**
* @return java.util.Map<java.lang.String, java.lang.Object>
* @author cw chen
* @description 违章类别列表
* @Param params
* @Param page
* @Param limit
* @date 2022-12-20 14:49
*/
@PostMapping(value = "getVoiTypeList")
@Log(title = "违章类别", menu = "值班任务->违章统计", businessType = BusinessType.QUERY, details = "违章类别列表")
public Map<String, Object> getVoiTypeList(VoiTypeEntity voiTypeEntity) {
PageHelper.startPage(Integer.parseInt(voiTypeEntity.getPage()), Integer.parseInt(voiTypeEntity.getLimit()));
Map<String, Object> map = new HashMap<String, Object>(16);
try {
PageInfo<VoiTypeEntity> pageInfo = service.getVoiTypeList(voiTypeEntity);
map.put("code", 200);
map.put("msg", "获取数据成功");
map.put("count", pageInfo.getTotal());
map.put("curr", Integer.parseInt(voiTypeEntity.getPage()));
map.put("limit", Integer.parseInt(voiTypeEntity.getLimit()));
map.put("data", pageInfo.getList());
} catch (Exception e) {
map.put("code", 500);
map.put("msg", "获取数据失败");
map.put("count", 0);
map.put("curr", Integer.parseInt(voiTypeEntity.getPage()));
map.put("limit", Integer.parseInt(voiTypeEntity.getLimit()));
map.put("data", null);
logger.error("数据获取失败", e);
}
return map;
}
/**
* @return com.securityControl.common.core.web.domain.AjaxResult
* @author cw chen
* @description 新增/修改违章类别
* @Param params
* @date 2022-12-20 15:26
*/
@PostMapping(value = "addOrUpdateVoiType")
@Log(title = "违章类别", menu = "值班任务->违章统计", businessType = BusinessType.QUERY, details = "新增/修改违章类别", grade = OperationType.ADD_BUSINESS)
public AjaxResult addOrUpdateVoiType(VoiTypeEntity voiTypeEntity) {
try {
int result = service.voiTypeIsExist(voiTypeEntity.getCode());
int pid = service.getVoiTypePid();
voiTypeEntity.setpId(pid + "");
if (StringUtils.isBlank(voiTypeEntity.getId())) {
// 新增
if (result > 0) {
return AjaxResult.error("违章类别已存在,请勿重复添加");
}
service.addVoiType(voiTypeEntity);
} else {
// 修改
boolean flag = voiTypeEntity.isFlag();
if (!flag) {
if (result > 0) {
return AjaxResult.error("违章类别已存在,请勿重复修改");
}
service.updateVoiType(voiTypeEntity);
} else {
service.updateVoiType(voiTypeEntity);
}
}
return AjaxResult.success("success");
} catch (Exception e) {
logger.error("新增/修改违章类别", e);
return AjaxResult.error("服务异常,请稍后重试");
}
}
/**
* @return com.securityControl.common.core.web.domain.AjaxResult
* @author cw chen
* @description 根据id获取违章类别
* @Param params
* @date 2022-12-20 15:47
*/
@PostMapping("getVoiTypeById")
@Log(title = "违章类别", menu = "值班任务->违章统计", businessType = BusinessType.QUERY, details = "违章类别详情查看")
public AjaxResult getVoiTypeById(String params) {
try {
VoiTypeEntity entity = service.getVoiTypeById(params);
return AjaxResult.success("success", entity);
} catch (Exception e) {
logger.error("根据id获取违章类别", e);
return AjaxResult.error("服务异常,请稍后重试", null);
}
}
/**
* @return com.securityControl.common.core.web.domain.AjaxResult
* @author cw chen
* @description 根据id删除违章类别
* @Param params
* @date 2022-12-20 15:47
*/
@PostMapping("delVoiTypeById")
@Log(title = "违章类别", menu = "值班任务->违章统计", businessType = BusinessType.DELETE, details = "删除违章类别", grade = OperationType.DELETE_BUSINESS)
public AjaxResult delVoiTypeById(String params) {
try {
int result = service.isHasVoiInfo(params);
if (result > 0) {
return AjaxResult.error("该违章类别下包含违章依据,无法删除");
}
service.delVoiTypeById(params);
return AjaxResult.success("success");
} catch (Exception e) {
logger.error("根据id删除违章类别", e);
return AjaxResult.error("服务异常,请稍后重试");
}
}
/**
* @return java.util.Map<java.lang.String, java.lang.Object>
* @author cw chen
* @description 违章依据列表
* @Param params
* @Param page
* @Param limit
* @date 2022-12-20 16:47
*/
@PostMapping(value = "getVoiInfoList")
@Log(title = "违章依据", menu = "值班任务->违章统计", businessType = BusinessType.QUERY, details = "违章依据列表")
public Map<String, Object> getVoiInfoList(VoiInfoEntity voiInfoEntity) {
PageHelper.startPage(Integer.parseInt(voiInfoEntity.getPage()), Integer.parseInt(voiInfoEntity.getLimit()));
Map<String, Object> map = new HashMap<String, Object>(16);
try {
PageInfo<VoiInfoEntity> pageInfo = service.getVoiInfoList(voiInfoEntity);
map.put("code", 200);
map.put("msg", "获取数据成功");
map.put("count", pageInfo.getTotal());
map.put("curr", Integer.parseInt(voiInfoEntity.getPage()));
map.put("limit", Integer.parseInt(voiInfoEntity.getLimit()));
map.put("data", pageInfo.getList());
} catch (Exception e) {
map.put("code", 500);
map.put("msg", "获取数据失败");
map.put("count", 0);
map.put("curr", Integer.parseInt(voiInfoEntity.getPage()));
map.put("limit", Integer.parseInt(voiInfoEntity.getLimit()));
map.put("data", null);
logger.error("数据获取失败", e);
}
return map;
}
/**
* @return com.securityControl.common.core.web.domain.AjaxResult
* @author cw chen
* @description 新增/修改违章依据
* @Param params
* @date 2022-12-20 15:26
*/
@PostMapping(value = "addOrUpdateVoiInfo")
@Log(title = "违章依据", menu = "值班任务->违章统计", businessType = BusinessType.INSERT, details = "新增/修改违章依据")
public AjaxResult addOrUpdateVoiInfo(VoiInfoEntity voiInfoEntity) {
try {
int result = service.voiInfoIsExist(voiInfoEntity);
if (StringUtils.isBlank(voiInfoEntity.getId())) {
// 新增
boolean flag = false;
String[] notiInfoArr = voiInfoEntity.getNotiInfo().split(";");
for (String notiInfo : notiInfoArr) {
VoiInfoEntity entity = new VoiInfoEntity();
entity.setNotiInfo(notiInfo);
entity.setVoiTypeId(voiInfoEntity.getVoiTypeId());
int result2 = service.voiInfoIsExist(entity);
if (result2 > 0) {
flag = true;
break;
}
}
if (flag) {
return AjaxResult.error("违章依据已存在,请勿重复添加");
}
service.addVoiInfo(voiInfoEntity);
} else {
// 修改
boolean flag = voiInfoEntity.isFlag();
if (!flag) {
if (result > 0) {
return AjaxResult.error("违章依据已存在,请勿重复修改");
}
service.updateVoiInfo(voiInfoEntity);
} else {
service.updateVoiInfo(voiInfoEntity);
}
}
return AjaxResult.success("success");
} catch (Exception e) {
logger.error("新增/修改违章依据", e);
return AjaxResult.error("服务异常,请稍后重试");
}
}
/**
* @return com.securityControl.common.core.web.domain.AjaxResult
* @author cw chen
* @description 根据id获取违章依据
* @Param params
* @date 2022-12-20 15:47
*/
@PostMapping("getVoiInfoById")
@Log(title = "违章依据", menu = "值班任务->违章统计", businessType = BusinessType.QUERY, details = "违章依据详情查看")
public AjaxResult getVoiInfoById(String params) {
try {
VoiInfoEntity entity = service.getVoiInfoById(params);
return AjaxResult.success("success", entity);
} catch (Exception e) {
logger.error("根据id获取违章依据", e);
return AjaxResult.error("服务异常,请稍后重试", null);
}
}
/**
* @return com.securityControl.common.core.web.domain.AjaxResult
* @author cw chen
* @description 根据id删除违章依据
* @Param params
* @date 2022-12-20 15:47
*/
@PostMapping("delVoiInfoById")
@Log(title = "违章依据", menu = "值班任务->违章统计", businessType = BusinessType.DELETE, details = "删除违章依据")
public AjaxResult delVoiInfoById(String params) {
try {
service.delVoiInfoById(params);
return AjaxResult.success("success");
} catch (Exception e) {
logger.error("根据id删除违章依据", e);
return AjaxResult.error("服务异常,请稍后重试");
}
}
/**
* @return void
* @author cw chen
* @description 违章依据模板下载
* @Param request
* @Param response
* @date 2022-12-21 9:29
*/
@GetMapping("downLoadExcelModel")
@Log(title = "违章依据", menu = "值班任务->违章统计", businessType = BusinessType.QUERY, details = "违章依据导入模板下载", grade = OperationType.DOWNLOAD_BUSINESS)
public void downLoadExcelModel(HttpServletRequest request, HttpServletResponse response) {
InputStream inputStream = null;
ServletOutputStream servletOutputStream = null;
try {
String path = "download/" + "voi-info-model.xlsx";
inputStream = this.getClass().getClassLoader().getResourceAsStream(path);
response.setContentType("application/vnd.ms-excel");
response.addHeader("Cache-Control", "no-cache, no-store, must-revalidate");
response.addHeader("charset", "utf-8");
response.addHeader("Pragma", "no-cache");
String encodeName = URLEncoder.encode("project_model.xlsx", StandardCharsets.UTF_8.toString());
response.setHeader("Content-Disposition", "attachment; filename=\"" + encodeName + "\"; filename*=utf-8''" + encodeName);
servletOutputStream = response.getOutputStream();
IOUtils.copy(inputStream, servletOutputStream);
response.flushBuffer();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (servletOutputStream != null) {
servletOutputStream.close();
}
if (inputStream != null) {
inputStream.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
/**
* @return void
* @author cw chen
* @description 违章依据导入
* @Param file
* @Param request
* @Param response
* @date 2022-12-21 9:45
*/
@PostMapping("/importExcel")
@Log(title = "违章依据", menu = "值班任务->违章统计", businessType = BusinessType.IMPORT, details = "导入违章依据", grade = OperationType.IMPORT_BUSINESS)
public void importExcel(MultipartFile file, HttpServletRequest request, HttpServletResponse response) {
try {
CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver();
MultipartHttpServletRequest multiReq = multipartResolver.resolveMultipart(request);
// 违章类型id
String voiTypeId = multiReq.getParameter("voiTypeId");
List<JSONObject> lstObj = (List<JSONObject>) ImportExcelHelper.readExcel(file, VoiInfoEntity.class);
List<VoiInfoEntity> list = new ArrayList<>();
List<JSONObject> lstError = new ArrayList<>();
// 验证表格中的数据是否重复
List<JSONObject> errList = dataIsRepeat(lstObj);
if (lstObj != null && lstObj.size() > 0) {
list = new ArrayList<>();
lstError = new ArrayList<>();
for (JSONObject obj : lstObj) {
if (StringUtils.isBlank(obj.getString("notiInfo"))) {
JSONObject error = new JSONObject();
error.put("errorRow", obj.getString("rowNo"));
error.put("errorLine", "违章依据");
error.put("errorData", "");
error.put("errorMsg", "违章依据不能为空");
lstError.add(error);
continue;
} else {
VoiInfoEntity o = new VoiInfoEntity();
o.setNotiInfo(obj.getString("notiInfo"));
o.setVoiTypeId(voiTypeId);
int result = service.voiInfoIsExist(o);
if (result > 0) {
JSONObject error = new JSONObject();
error.put("errorRow", obj.getString("rowNo"));
error.put("errorLine", "违章依据");
error.put("errorData", obj.getString("notiInfo"));
error.put("errorMsg", "违章依据已存在");
lstError.add(error);
} else {
list.add(o);
}
}
}
}
lstError.addAll(errList);
ResultModel resultModel = new ResultModel();
if (lstError != null && lstError.size() > 0) {
resultModel.setSuccess(false);
resultModel.setStatus(200);
resultModel.setMsg("导入成功");
resultModel.setData(lstError);
} else if (lstError.size() == 0) {
service.addImportVoiInfo(list);
resultModel.setSuccess(true);
resultModel.setStatus(200);
resultModel.setMsg("导入成功");
resultModel.setData(null);
}
sendJson(response, resultModel);
} catch (Exception ex) {
ex.printStackTrace();
resultModel = new ResultModel();
resultModel.setSuccess(false);
resultModel.setStatus(1000);
resultModel.setMsg("服务异常");
try {
sendJson(response, resultModel);
} catch (IOException e) {
e.printStackTrace();
}
}
}
/**
* @return java.util.List<com.alibaba.fastjson.JSONObject>
* @author cw chen
* @description 验证excel表中重复数据
* @Param lstObj
* @date 2022-11-22 15:41
*/
public List<JSONObject> dataIsRepeat(List<JSONObject> lstObj) throws ExecutionException, InterruptedException {
List<JSONObject> errorList = new ArrayList<JSONObject>();
List<String> list1 = new ArrayList<String>();
Future<List<JSONObject>> future = testTaskExecutor.submit(() -> {
List<JSONObject> errList1 = new ArrayList<JSONObject>();
for (JSONObject obj : lstObj) {
if (StringUtils.isNotBlank(obj.getString("notiInfo"))) {
list1.add(obj.getString("notiInfo"));
} else {
list1.add("");
}
}
List<JSONObject> same1 = same(list1);
same1.forEach(item -> {
List<Object> errorRow = new ArrayList<>();
String[] rowNos = item.getString("rowNo").split(",");
for (int i = 0; i < rowNos.length; i++) {
errorRow.add(lstObj.get(Integer.parseInt(rowNos[i]) - 1).getString("rowNo"));
}
JSONObject error = new JSONObject();
error.put("errorRow", StringUtils.join(errorRow, ","));
error.put("errorLine", "违章依据");
error.put("errorData", item.getString("data"));
error.put("errorMsg", "违章依据重复,重复行:" + StringUtils.join(errorRow, ","));
errList1.add(error);
});
return errList1;
});
errorList.addAll(future.get());
return errorList;
}
/**
* @return java.util.List<com.alibaba.fastjson.JSONObject>
* @author cw chen
* @description 获取重复数据及下标
* @Param list
* @date 2022-11-22 15:42
*/
public static List<JSONObject> same(List<String> list) {
List<JSONObject> errList = new ArrayList<JSONObject>();
Map<String, String> map = new HashMap<String, String>(16);
for (int i = 0; i < list.size(); i++) {
String key = list.get(i);
if (key == null || Objects.equals("", key)) {
continue;
}
String old = map.get(key);
if (old != null) {
map.put(key, old + "," + (i + 1));
} else {
map.put(key, "" + (i + 1));
}
}
Iterator<String> it = map.keySet().iterator();
while (it.hasNext()) {
String key = it.next();
String value = map.get(key);
if (value.indexOf(",") != -1) {
JSONObject error = new JSONObject();
error.put("data", key);
error.put("rowNo", value);
System.out.println(key + " 重复,行: " + value);
errList.add(error);
}
}
return errList;
}
/**
* @return com.securityControl.common.core.web.domain.AjaxResult
* @author cw chen
* @description 违章单选择作业票
* @Param params
* @date 2022-12-21 11:21
*/
@PostMapping(value = "getTicketNo")
public AjaxResult getTicketNo(String params, String currentUserId, String isSup) {
try {
List<Map<String, Object>> mapList = service.getTicketNo(params, currentUserId, isSup);
return AjaxResult.success("success", mapList);
} catch (Exception e) {
logger.error("违章单选择作业票", e);
return AjaxResult.error("error", null);
}
}
/**
* @return void
* @author cw chen
* @description 导出违章统计
* @Param request
* @Param response
* @Param params
* @date 2022-12-21 16:58
*/
@GetMapping("exportData")
@Log(title = "违章统计", menu = "值班任务->违章统计", businessType = BusinessType.EXPORT, details = "违章统计导出", grade = OperationType.EXPORT_BUSINESS)
public void exportData(HttpServletRequest request, HttpServletResponse response, NoticeVioEntity noticeVioEntity) {
if (StringUtils.isBlank(noticeVioEntity.getCreateTime())) {
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
cal.set(Calendar.DAY_OF_MONTH, 1);
noticeVioEntity.setCreateTime(new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime()));
cal.roll(Calendar.DAY_OF_MONTH, -1);
noticeVioEntity.setEndTime(new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime()));
} else {
String[] dateArr = noticeVioEntity.getCreateTime().split(" - ");
noticeVioEntity.setCreateTime(dateArr[0]);
noticeVioEntity.setEndTime(dateArr[1]);
}
if (Objects.equals("3", noticeVioEntity.getType())) {
List<String> dateList = com.sercurityControl.proteam.util.DateTimeHelper.getDateList(30);
noticeVioEntity.setCreateTime(dateList.get(29));
noticeVioEntity.setEndTime(dateList.get(0));
}
PageHelper.startPage(1, 10000000);
List<NoticeVioEntity> list = new ArrayList<>();
List<NoticeVioEntity2> list2 = new ArrayList<>();
try {
PageInfo<NoticeVioEntity> pageInfo = service.getSuperStatisticsList(noticeVioEntity);
list = pageInfo.getList();
for (int i = 0; i < list.size(); i++) {
list.get(i).setId((i + 1) + "");
List<Map<String, String>> listMap = service.getBasicInfo(list.get(i).getClassId());
if (CollectionUtils.isNotEmpty(listMap)) {
String contactPhone = listMap.get(0).get("contactPhone");
String jlUnit = listMap.get(0).get("jlUnit");
String sgdw = listMap.get(0).get("sgdw");
String jl = listMap.get(0).get("jl");
String sg = listMap.get(0).get("sg");
String yz = listMap.get(0).get("yz");
list.get(i).setContactPhone(StringUtils.isEmpty(contactPhone) ? null : contactPhone);
list.get(i).setJlUnit(StringUtils.isEmpty(jlUnit) ? null : jlUnit);
list.get(i).setSgUnit(StringUtils.isEmpty(sgdw) ? null : sgdw);
list.get(i).setJl(StringUtils.isEmpty(jl) ? null : jl);
list.get(i).setSg(StringUtils.isEmpty(sg) ? null : sg);
list.get(i).setYz(StringUtils.isEmpty(yz) ? null : yz);
}
}
// 导出EXCEL 带图片
if (!Objects.equals("1", noticeVioEntity.getType())) {
list2 = handleDataUtil.handleData(list, noticeVioEntity);
}
ExportParams exportParams = new ExportParams("违章统计", "违章统计", ExcelType.XSSF);
exportParams.setStyle(ExcelStyleUtil.class);
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, Objects.equals("1", noticeVioEntity.getType()) ? NoticeVioEntity.class : NoticeVioEntity2.class, Objects.equals("1", noticeVioEntity.getType()) ? list : list2);
response.setHeader("content-disposition", "attachment;fileName=" + URLEncoder.encode("违章统计" + ".xlsx", "UTF-8"));
ServletOutputStream outputStream = response.getOutputStream();
workbook.write(outputStream);
outputStream.close();
workbook.close();
} catch (Exception e) {
log.error(e.toString(),e);
logger.error("导出违章统计", e);
}
}
/**
* @return com.securityControl.common.core.web.domain.AjaxResult
* @author cw chen
* @description 地市监控中心--整改填报(违章单基本信息,以及历史整改填报信息)
* @Param params
* @date 2022-12-22 9:26
*/
@PostMapping(value = "getNoticeVoiRectById")
public AjaxResult getNoticeVoiRectById(String id) {
try {
NoticeVioEntity noticeVioEntity = service.getNoticeVoiRectById(id);
return AjaxResult.success("success", noticeVioEntity);
} catch (Exception e) {
logger.error("数据获取失败", e);
return AjaxResult.error("服务异常,请稍后重试", null);
}
}
/**
* @return com.securityControl.common.core.web.domain.AjaxResult
* @author cw chen
* @description 违章整改
* @Param request
* @Param files
* @date 2022-12-22 10:50
*/
@PostMapping(value = "uploadNoticeVioRect", headers = "content-type=multipart/form-data")
@ResponseBody
@Log(title = "违章统计", menu = "值班任务->违章统计", businessType = BusinessType.INSERT, details = "违章整改")
public AjaxResult uploadNoticeVioRect(HttpServletRequest request, @RequestParam(value = "file[]") MultipartFile[] files) {
CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver();
MultipartHttpServletRequest multiReq = multipartResolver.resolveMultipart(request);
String params = multiReq.getParameter("params");
String isAppeal = multiReq.getParameter("isAppeal");
String imgType = "2", status = "2";
if (Objects.equals("1", isAppeal)) {
imgType = "3";
status = "4";
}
NoticeVoiRectEntity entity = com.alibaba.fastjson2.JSON.parseObject(params, NoticeVoiRectEntity.class);
entity.setCreateDate(DateTimeHelper.getNowDate());
entity.setCreateTime(DateTimeHelper.getNowTime());
entity.setRectUser(SecurityUtils.getUserId() + "");
NoticeVioEntity vioEntity = new NoticeVioEntity();
if (StringUtils.isNotEmpty(entity.getSupType()) && Objects.equals(entity.getSupType(), "2")) {
status = "5";
}
vioEntity.setId(entity.getNotiId());
vioEntity.setIsAppeal(isAppeal);
vioEntity.setStatus(status);
vioEntity.setVioUsers(entity.getNamesParam());//整改人员名称
List<NoticeVioImgEntity> list = new ArrayList<>();
try {
if (files != null) {
for (MultipartFile item : files) {
NoticeVioImgEntity imageEntity = new NoticeVioImgEntity();
// String imgId = ossUtil.fileUpload(item);
// imageEntity.setImagePath(imgId);
String imgPath = uploadImage(item);
imageEntity.setImagePath(imgPath);
imageEntity.setImageType(imgType);
imageEntity.setNotiId(entity.getNotiId());
list.add(imageEntity);
}
}
// 添加违章整改
service.addNoticeVioRectAndImg(entity, vioEntity, list);
} catch (Exception e) {
logger.error("违章整改", e);
return AjaxResult.error("服务异常,请稍后重试");
}
return AjaxResult.success("success");
}
public String uploadImage(MultipartFile iteam) {
String imgPath = "";
try {
String fileName = null;
String originalFilename = iteam.getOriginalFilename();
String prefix = originalFilename.substring(originalFilename.lastIndexOf(".") + 1, originalFilename.length());
if (Objects.equals(prefix, "png") || Objects.equals(prefix, "jpg") || Objects.equals(prefix, "jpeg")) {
fileName = IDUtils.createID() + ".jpg";
} else if (Objects.equals(prefix, "doc") || Objects.equals(prefix, "docx")) {
fileName = IDUtils.createID() + ".docx";
} else if (Objects.equals(prefix, "pdf")) {
fileName = IDUtils.createID() + ".pdf";
}
String mkdirsName = "noticeVioRect"; // 违章整改
String imageFiles = upload_path + File.separator + mkdirsName;
String path = imageFiles + File.separator + DateTimeHelper.getYear(new Date()) + File.separator + DateTimeHelper.getMonth(new Date()) + File.separator + fileName;
File file = new File(path);
//生成文件夹
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
// 存入临时文件
iteam.transferTo(file);
imgPath = mkdirsName + File.separator + DateTimeHelper.getYear(new Date()) + File.separator + DateTimeHelper.getMonth(new Date()) + File.separator + fileName;
return imgPath;
} catch (Exception e) {
log.error(e.toString(), e);
}
return "";
}
/**
* @return com.securityControl.common.core.web.domain.AjaxResult
* @author cw chen
* @description 违章反馈审核/违章申诉审核
* @Param params
* @date 2022-12-22 13:58
*/
@PostMapping(value = "rectCheck")
@Log(title = "违章依据", menu = "值班任务->违章统计", businessType = BusinessType.UPDATE, details = "违章审核")
public AjaxResult rectCheck(NoticeVoiRectEntity entity) {
try {
service.rectCheck(entity);
return AjaxResult.success("success");
} catch (Exception e) {
logger.error("违章反馈审核/违章申诉审核", e);
return AjaxResult.error("服务异常,请稍后重试");
}
}
/**
* @return com.securityControl.common.core.web.domain.AjaxResult
* @author cw chen
* @description 违章统计-通知单
* @Param params
* @date 2022-12-30 10:33
*/
@PostMapping("getNoticeSheet")
@Log(title = "违章统计", menu = "值班任务->违章统计", businessType = BusinessType.QUERY, details = "违章通知单查看")
public AjaxResult getNoticeSheet(NoticeVioEntity entity) {
try {
Map<String, Object> map = service.getNoticeSheet(entity);
return AjaxResult.success("success", map);
} catch (Exception e) {
logger.error("通知单", e);
return AjaxResult.error("服务异常,请稍后重试", null);
}
}
/**
* @return void
* @author cw chen
* @description 下载通知单
* @Param request
* @Param response
* @Param params
* @date 2022-12-30 14:06
*/
@GetMapping("downLoadNoticeSheet")
@Log(title = "违章统计", menu = "值班任务->违章统计", businessType = BusinessType.EXPORT, details = "通知单导出")
public void downLoadNoticeSheet(HttpServletRequest request, HttpServletResponse response, NoticeVioEntity entity) {
Map<String, Object> data = new HashMap<>(16);
List<Map<String, String>> voiImgList = new ArrayList<>();
List<Map<String, String>> voiImgList2 = new ArrayList<>();
List<Map<String, String>> voiImgList3 = new ArrayList<>();
try {
Map<String, Object> map = service.getNoticeSheet(entity);
NoticeVioEntity noticeVioEntity2 = service.getNoticeSheet2(entity);
NoticeVioEntity noticeVioEntity = (NoticeVioEntity) map.get("noticeVioEntity");
if (Objects.nonNull(noticeVioEntity2)) {
data.put("sgUnit", setNullValue(noticeVioEntity2.getSgUnit()));
data.put("jlUnit", setNullValue(noticeVioEntity2.getJlUnit()));
data.put("workContent", setNullValue(noticeVioEntity2.getWorkContent()));
} else {
data.put("sgUnit", setNullValue(noticeVioEntity.getSgUnit()));
data.put("jlUnit", setNullValue(noticeVioEntity.getJlUnit()));
data.put("workContent", setNullValue(noticeVioEntity.getWorkContent()));
}
// 违章整改通知单(远程督查)赋值
data.put("serNo", noticeVioEntity.getSerNo());
data.put("proName", noticeVioEntity.getProName());
data.put("createTime", noticeVioEntity.getCreateTime());
data.put("org", noticeVioEntity.getOrg());
data.put("content", noticeVioEntity.getContent());
data.put("voiYj", noticeVioEntity.getVoiYj());
data.put("recRequirement", noticeVioEntity.getRecRequirement());
data.put("issuingUnit", noticeVioEntity.getIssuingUnit());
String[] imgPathArr = noticeVioEntity.getImgPath().split(",");
for (int i = 0; i < imgPathArr.length; i++) {
Map<String, String> paramsMap = new HashMap<>(16);
paramsMap.put("index", (10000 + i) + "");
if (StringUtils.isNotBlank(imgPathArr[i])) {
paramsMap.put("img", FreeMarkerUtil.getImageBase(upload_path + File.separator + imgPathArr[i]));
} else {
paramsMap.put("img", "");
}
voiImgList.add(paramsMap);
}
data.put("voiImgList", voiImgList);
String title = noticeVioEntity.getSerNo() + "违章整改反馈单" + "" + noticeVioEntity.getOrg() + "";
if (!Objects.equals("5", noticeVioEntity.getStatus())) {
WordUtils.exportMillCertificateWord(request, response, data, title, "dc_sheet.ftl");
} else {
// 违章整改反馈单赋值
NoticeVoiRectEntity noticeVoiRectEntity = (NoticeVoiRectEntity) map.get("noticeVoiRectEntity");
String cont = noticeVioEntity.getContent().substring(noticeVioEntity.getContent().indexOf("】") + 1, noticeVioEntity.getContent().length());
data.put("cont", cont);
data.put("rectExplain", noticeVoiRectEntity.getRectExplain());
data.put("unit", noticeVoiRectEntity.getDutyUnit());
data.put("us", noticeVoiRectEntity.getDutyUser());
data.put("time", noticeVoiRectEntity.getRectFinshTime());
data.put("contactPhone", noticeVoiRectEntity.getContactPhone());
data.put("status", noticeVoiRectEntity.getStatus());
String[] imgPathArr2 = noticeVoiRectEntity.getImagePath().split(",");
List<String> fileList = new ArrayList<>();
List<String> imgList = new ArrayList<>();
String ftlName = "rect_sheet_nofile.ftl";
for (int i = 0; i < imgPathArr2.length; i++) {
if (imgPathArr2[i].contains("docx")) {
Map<String, String> paramsMap = new HashMap<>(16);
paramsMap.put("index", (40000 + i) + "");
if (new File(upload_path + File.separator + imgPathArr2[i]).exists()) {
paramsMap.put("img", FileToBase64.convertToBase64(new File(upload_path + File.separator + imgPathArr2[i])));
voiImgList3.add(paramsMap);
}
ftlName = "rect_sheet_file.ftl";
fileList.add(imgPathArr2[i]);
} else {
imgList.add(imgPathArr2[i]);
}
}
if (imgPathArr.length >= imgList.size()) { // 督查照片数量 >= 整改照片
for (int i = 0; i < imgPathArr.length; i++) {
Map<String, String> paramsMap = new HashMap<>(16);
paramsMap.put("index", (20000 + i) + "");
paramsMap.put("img", FreeMarkerUtil.getImageBase(upload_path + File.separator + imgPathArr[i]));
if (i > imgList.size() - 1) {
paramsMap.put("img2", "");
paramsMap.put("index2", (30000 + i) + "");
} else {
paramsMap.put("img2", FreeMarkerUtil.getImageBase(upload_path + File.separator + imgList.get(i)));
paramsMap.put("index2", (30000 + i) + "");
}
voiImgList2.add(paramsMap);
}
} else { // 督查照片数量 < 整改照片
for (int i = 0; i < imgList.size(); i++) {
Map<String, String> paramsMap = new HashMap<>(16);
paramsMap.put("img2", FreeMarkerUtil.getImageBase(upload_path + File.separator + imgList.get(i)));
paramsMap.put("index2", (30000 + i) + "");
if (i > imgPathArr.length - 1) {
paramsMap.put("img", "");
paramsMap.put("index", (20000 + i) + "");
} else {
paramsMap.put("index", (20000 + i) + "");
paramsMap.put("img", FreeMarkerUtil.getImageBase(upload_path + File.separator + imgPathArr[i]));
}
voiImgList2.add(paramsMap);
}
}
data.put("voiImgList2", voiImgList2);
data.put("voiImgList3", voiImgList3);
WordUtils.exportMillCertificateWord(request, response, data, title, ftlName);
}
} catch (Exception e) {
logger.error("通知单下载", e);
}
}
/**
* @return com.securityControl.common.core.web.domain.AjaxResult
* @author cw chen
* @description 地市站班会数量和占比
* @Param params
* @date 2023-01-29 16:03
*/
@PostMapping(value = "getOrgNumAndRate")
public AjaxResult getOrgNumAndRate(NoticeVioEntity noticeVioEntity) {
if (StringUtils.isBlank(noticeVioEntity.getCreateTime())) {
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
cal.set(Calendar.DAY_OF_MONTH, 1);
noticeVioEntity.setCreateTime(new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime()));
cal.roll(Calendar.DAY_OF_MONTH, -1);
noticeVioEntity.setEndTime(new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime()));
} else {
String[] dateArr = noticeVioEntity.getCreateTime().split(" - ");
noticeVioEntity.setCreateTime(dateArr[0]);
noticeVioEntity.setEndTime(dateArr[1]);
}
try {
List<Map<String, Object>> list = service.getOrgNumAndRate(noticeVioEntity);
return AjaxResult.success(list);
} catch (Exception e) {
e.printStackTrace();
logger.error("地市站班会数量和占比", e);
return AjaxResult.success(null);
}
}
@PostMapping(value = "getVoiRecordList")
@Log(title = "今日站班会", menu = "值班任务->今日站班会", businessType = BusinessType.QUERY, details = "违章记录列表")
public Map<String, Object> getVoiRecordList(NoticeVioEntity noticeVioEntity) {
PageHelper.startPage(Integer.parseInt(noticeVioEntity.getPage()), Integer.parseInt(noticeVioEntity.getLimit()));
Map<String, Object> map = new HashMap<String, Object>(16);
try {
PageInfo<NoticeVioEntity> pageInfo = service.getVoiRecordList(noticeVioEntity);
map.put("code", 200);
map.put("msg", "获取数据成功");
map.put("count", pageInfo.getTotal());
map.put("curr", Integer.parseInt(noticeVioEntity.getPage()));
map.put("limit", Integer.parseInt(noticeVioEntity.getLimit()));
map.put("data", pageInfo.getList());
} catch (Exception e) {
map.put("code", 500);
map.put("msg", "获取数据失败");
map.put("count", 0);
map.put("curr", Integer.parseInt(noticeVioEntity.getPage()));
map.put("limit", Integer.parseInt(noticeVioEntity.getLimit()));
map.put("data", null);
logger.error("数据获取失败", e);
}
return map;
}
/**
* @return java.util.Map<java.lang.String, java.lang.Object>
* @author cw chen
* @description 今日站班会-工程累计违章
* @Param noticeVioEntity
* @date 2023-07-21 16:08
*/
@PostMapping(value = "getProVoiRecordList")
@Log(title = "今日站班会", menu = "值班任务->今日站班会", businessType = BusinessType.QUERY, details = "累计违章记录列表")
public Map<String, Object> getProVoiRecordList(NoticeVioEntity noticeVioEntity) {
if (StringUtils.isNotEmpty(noticeVioEntity.getCreateTime())) {
String[] dateArr = noticeVioEntity.getCreateTime().split(" - ");
noticeVioEntity.setCreateTime(dateArr[0]);
noticeVioEntity.setEndTime(dateArr[1]);
}
PageHelper.startPage(Integer.parseInt(noticeVioEntity.getPage()), Integer.parseInt(noticeVioEntity.getLimit()));
Map<String, Object> map = new HashMap<String, Object>(16);
try {
PageInfo<NoticeVioEntity> pageInfo = service.getProVoiRecordList(noticeVioEntity);
map.put("code", 200);
map.put("msg", "获取数据成功");
map.put("count", pageInfo.getTotal());
map.put("curr", Integer.parseInt(noticeVioEntity.getPage()));
map.put("limit", Integer.parseInt(noticeVioEntity.getLimit()));
map.put("data", pageInfo.getList());
} catch (Exception e) {
map.put("code", 500);
map.put("msg", "获取数据失败");
map.put("count", 0);
map.put("curr", Integer.parseInt(noticeVioEntity.getPage()));
map.put("limit", Integer.parseInt(noticeVioEntity.getLimit()));
map.put("data", null);
logger.error("数据获取失败", e);
}
return map;
}
/**
* @return void
* @author cw chen
* @description 整改附件下载查看
* @Param
* @date 2023-04-17 11:03
*/
@GetMapping(value = "uploadRectFile")
public void uploadRectFile(HttpServletRequest request, HttpServletResponse response, String fileName) {
try {
WordUtils.exportWord(request, response, fileName, upload_path + File.separator + fileName);
} catch (IOException e) {
logger.error("整改附件下载查看", e);
}
}
/**
* @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 "";
}
public static String setNullValue(String value) {
if (StringUtils.isNotBlank(value)) {
return value;
}
return "";
}
/**
* @return com.securityControl.common.core.web.domain.AjaxResult
* @author cw chen
* @description 刷新违章统计单数据
* @Param
* @date 2023-06-14 13:59
*/
@PostMapping(value = "refreshNoticeVoiData")
public AjaxResult refreshNoticeVoiData() {
try {
service.refreshNoticeVoiData();
return AjaxResult.success("刷新成功");
} catch (Exception e) {
logger.error("刷新违章统计单数据", e);
return AjaxResult.error("服务异常,请稍后重试");
}
}
/**
* @return com.securityControl.common.core.web.domain.AjaxResult
* @author cw chen
* @description 按照类型来统计违章数据
* @Param
* @date 2023-07-17 14:46
*/
@PostMapping("getViolationTypeList")
public AjaxResult getViolationTypeList(NoticeVioEntity noticeVioEntity) {
if (StringUtils.isBlank(noticeVioEntity.getCreateTime())) {
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
cal.set(Calendar.DAY_OF_MONTH, 1);
noticeVioEntity.setCreateTime(new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime()));
cal.roll(Calendar.DAY_OF_MONTH, -1);
noticeVioEntity.setEndTime(new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime()));
} else {
String[] dateArr = noticeVioEntity.getCreateTime().split(" - ");
noticeVioEntity.setCreateTime(dateArr[0]);
noticeVioEntity.setEndTime(dateArr[1]);
}
List<Map<String, Object>> typeList = new ArrayList<>();
List<Map<String, Object>> levelIdList = new ArrayList<>();
Map<String, Object> map = new HashMap<String, Object>(16);
try {
map = service.getViolationTypeList(noticeVioEntity);
} catch (Exception e) {
logger.error("按照类型来统计违章数据", e);
String[] strArr = {"建议整改", "一般违章", "严重违章", "装置违章", "管理违章", "行为违章"};
for (int i = 0; i < strArr.length; i++) {
HashMap<String, Object> map1 = new HashMap<>(16);
map1.put("name", strArr[i]);
map1.put("value", 0);
if (i < 3) {
typeList.add(map1);
} else {
levelIdList.add(map1);
}
}
map.put("typeList", typeList);
map.put("levelIdList", levelIdList);
}
return AjaxResult.success(map);
}
public static byte[] FileTobyte(File file) {
FileInputStream fileInputStream = null;
byte[] imgData = null;
try {
imgData = new byte[(int) file.length()];
//read file into bytes[]
fileInputStream = new FileInputStream(file);
fileInputStream.read(imgData);
} catch (IOException e) {
e.printStackTrace();
} finally {
if (fileInputStream != null) {
try {
fileInputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return imgData;
}
/**
* @param dto
* @return AjaxResult
* @description 值长审核 违章单
* @author cwchen
* @date 2024/1/18 15:37
*/
@PostMapping("checkVoiStatus")
public AjaxResult checkVoiStatus(NoticeVioEntity dto) {
return service.checkVoiStatus(dto);
}
/**
* @param dto
* @return AjaxResult
* @description 违章单回撤
* @author cwchen
* @date 2024/1/18 17:24
*/
@PostMapping("rebackVoiStatus")
public AjaxResult rebackVoiStatus(NoticeVioEntity dto) {
return service.rebackVoiStatus(dto);
}
@PostMapping(value = "getVoiCheckLists")
@Log(title = "违章审核记录列表", menu = "违章审核记录列表", businessType = BusinessType.QUERY, details = "违章审核记录列表")
public Map<String, Object> getVoiCheckLists(NoticeVioEntity vo) {
PageHelper.startPage(Integer.parseInt(vo.getPage()), Integer.parseInt(vo.getLimit()));
Map<String, Object> map = new HashMap<String, Object>(6);
List<NoticeVioEntity> voiCheckLists = service.getVoiCheckLists(vo);
PageInfo<NoticeVioEntity> pageInfo = new PageInfo<NoticeVioEntity>(voiCheckLists);
map.put("code", 200);
map.put("msg", "操作成功");
map.put("count", pageInfo.getTotal());
map.put("curr", vo.getPage());
map.put("limit", vo.getLimit());
map.put("data", pageInfo.getList());
return map;
}
/**
* 违章子类型下拉选
*
* @param params
* @return AjaxResult
* @description
* @author cwchen
* @date 2024/3/18 13:51
*/
@PostMapping(value = "getTypeChildList")
public AjaxResult getTypeChildList(String params) {
return service.getTypeChildList(params);
}
/**
* 查询班组历史违章记录
*
* @param classId
* @param teamLeaderNumber
* @return AjaxResult
* @description
* @author cwchen
* @date 2024/3/19 13:51
*/
@PostMapping(value = "getTeamVoiNum")
public AjaxResult getTeamVoiNum(String classId, String teamLeaderNumber,String teamId) {
return service.getTeamVoiNum(classId, teamLeaderNumber,teamId);
}
/**
* 获取班组历史违章记录
*
* @param noticeVioEntity
* @return Map<Object>
* @description
* @author cwchen
* @date 2024/3/19 17:42
*/
@PostMapping(value = "getTeamVoiHistory")
public Map<String, Object> getTeamVoiHistory(NoticeVioEntity noticeVioEntity) {
PageHelper.startPage(Integer.parseInt(noticeVioEntity.getPage()), Integer.parseInt(noticeVioEntity.getLimit()));
Map<String, Object> map = new HashMap<String, Object>(16);
try {
PageInfo<NoticeVioEntity> pageInfo = service.getTeamVoiHistory(noticeVioEntity);
map.put("code", 200);
map.put("msg", "获取数据成功");
map.put("count", pageInfo.getTotal());
map.put("curr", Integer.parseInt(noticeVioEntity.getPage()));
map.put("limit", Integer.parseInt(noticeVioEntity.getLimit()));
map.put("data", pageInfo.getList());
} catch (Exception e) {
map.put("code", 500);
map.put("msg", "获取数据失败");
map.put("count", 0);
map.put("curr", Integer.parseInt(noticeVioEntity.getPage()));
map.put("limit", Integer.parseInt(noticeVioEntity.getLimit()));
map.put("data", null);
logger.error("数据获取失败", e);
}
return map;
}
/**
* 获取违章子类型
*
* @param noticeVioEntity
* @return AjaxResult
* @description
* @author cwchen
* @date 2024/3/19 20:11
*/
@PostMapping(value = "getChildTypeList")
public AjaxResult getChildTypeList(NoticeVioEntity noticeVioEntity) {
if (StringUtils.isBlank(noticeVioEntity.getCreateTime())) {
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
cal.set(Calendar.DAY_OF_MONTH, 1);
noticeVioEntity.setCreateTime(new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime()));
cal.roll(Calendar.DAY_OF_MONTH, -1);
noticeVioEntity.setEndTime(new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime()));
} else {
String[] dateArr = noticeVioEntity.getCreateTime().split(" - ");
noticeVioEntity.setCreateTime(dateArr[0]);
noticeVioEntity.setEndTime(dateArr[1]);
}
return service.getChildTypeList(noticeVioEntity);
}
/**
* 获取违章通知 -> 提醒主任数据
* @param noticeVioEntity
* @return Map<Object>
* @description
* @author cwchen
* @date 2024/4/18 13:42
*/
@PostMapping(value = "getVioNoticeByDirector")
public Map<String, Object> getVioNoticeByDirector(NoticeVioEntity noticeVioEntity) {
PageHelper.startPage(Integer.parseInt(noticeVioEntity.getPage()), Integer.parseInt(noticeVioEntity.getLimit()));
Map<String, Object> map = new HashMap<String, Object>(6);
try {
LoginUser loginUser = SecurityUtils.getLoginUser();
log.info("当前用户角色:{}",loginUser.getSysUser().getRoleName());
if(loginUser!=null && loginUser.getSysUser() !=null && (
Objects.equals(loginUser.getSysUser().getRoleName(),"主任管理员") ||
Objects.equals(loginUser.getSysUser().getRoleName(),"博诺思管理员") ||
Objects.equals(loginUser.getSysUser().getRoleName(),"继远管理员")
)){
// 当前用户角色为主任管理员
noticeVioEntity.setIsDirector("1");
}else{
noticeVioEntity.setIsDirector("0");
}
PageInfo<NoticeVioEntity> pageInfo = service.getVioNoticeByDirector(noticeVioEntity);
map.put("code", 200);
map.put("msg", "获取数据成功");
map.put("count", pageInfo.getTotal());
map.put("curr", Integer.parseInt(noticeVioEntity.getPage()));
map.put("limit", Integer.parseInt(noticeVioEntity.getLimit()));
map.put("data", pageInfo.getList());
} catch (Exception e) {
map.put("data", null);
map.put("msg", "获取数据失败");
map.put("count", 0);
map.put("code", 500);
map.put("curr", Integer.parseInt(noticeVioEntity.getPage()));
map.put("limit", Integer.parseInt(noticeVioEntity.getLimit()));
logger.error(e.toString(), e);
}
return map;
}
}