diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java index 46bb487..d27afa9 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java @@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.plugins.Page; import com.casic.missiles.core.base.response.ResponseData; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.alarm.service.IAlarmJobService; import com.casic.missiles.core.common.service.ICommonPermissionService; import com.casic.missiles.core.datascope.DataScope; @@ -12,12 +13,14 @@ import com.casic.missiles.modular.system.warpper.AlarmJobWarpper; import com.casic.missiles.core.base.controller.BaseController; import com.casic.missiles.core.common.constant.factory.PageFactory; +import lombok.extern.slf4j.Slf4j; import org.hswebframework.expands.office.excel.ExcelIO; import org.json.JSONException; import org.json.JSONObject; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; @@ -29,6 +32,7 @@ import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.*; //import com.casic.missiles.core.base.response.ResponseData; @@ -40,6 +44,7 @@ * @Date 2019-05-17 10:48:36 */ @Controller +@Slf4j @RequestMapping("/job") public class AlarmJobController extends BaseController { @@ -65,6 +70,13 @@ private String templatePath; + /** + * 工单状态接口统计 + * + * @param httpServletRequest + * @return + * @throws ParseException + */ @RequestMapping(value = "/countByJobStatus") @ResponseBody public Object countByJobStatus(HttpServletRequest httpServletRequest) throws ParseException { @@ -117,7 +129,7 @@ } /** - * 获取分页列表 + * 获取工单分页列表 */ @RequestMapping(value = "/list") @ResponseBody @@ -164,30 +176,26 @@ */ @RequestMapping(value = "/searchList") @ResponseBody - public Object jobListSearch(String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime, String endTime, - String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, - String handleJobBeginTime, String handleJobEndTime, String shouldHandleBeginTime, String shouldHandleEndTime) { + public Object jobListSearch(@RequestBody JobListParam jobListParam) { Page> page = new PageFactory>().defaultPage("createTime", false); DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List> retList = new ArrayList<>(); if (alarmJobService.checkPcRole(currentUser.getRoleTips())) { // pc角色 - retList = alarmJobService.jobListSearch(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, - handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, dataScope, currentUser.getId()); + retList = alarmJobService.jobListSearch(page, jobListParam, dataScope, currentUser.getId()); } else { //app角色 long leaderId = 0L; if (currentUser.getRoleTips().contains(sLeader)) { // 组长,查组内全部 leaderId = currentUser.getId(); - if (ToolUtil.isNotEmpty(jobStatus)) { + if (ToolUtil.isNotEmpty(jobListParam.getJobStatus())) { //learder&&jobStatus=1,2,3时,关闭传入的sort,按sql排序(自己的排在前) - page.setOpenSort(!alarmJobService.checkJobStatus(jobStatus)); + page.setOpenSort(!alarmJobService.checkJobStatus(jobListParam.getJobStatus())); } } - retList = alarmJobService.jobListSearchApp(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, - handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, currentUser.getDeptId(), currentUser.getId(), leaderId); + retList = alarmJobService.jobListSearchApp(page, jobListParam, currentUser.getDeptId(), currentUser.getId(), leaderId); } new AlarmJobWarpper(retList).warp(); @@ -277,26 +285,24 @@ @RequestMapping(value = "/export") public void exportJob(HttpServletRequest httpServletRequest , HttpServletResponse httpServletResponse) throws IOException { - Page> page = new PageFactory>().defaultPage("createTime", false); page.setLimit(maxRowsExcel); page.setSize(maxRowsExcel); page.setSearchCount(false); page.setOffset(0); - String keywords = httpServletRequest.getParameter("keywords"); String beginTime = httpServletRequest.getParameter("beginTime"); String endTime = httpServletRequest.getParameter("endTime"); String jobStatusStr = httpServletRequest.getParameter("jobStatus"); String alarmTypeStr = httpServletRequest.getParameter("alarmType"); String alarmContentStr = httpServletRequest.getParameter("alarmContentType"); - - List> jobExpList = new ArrayList<>(); + log.debug("主题参数---------------" + keywords + "," + beginTime + "," + endTime + "," + jobStatusStr + "," + alarmTypeStr + "," + alarmContentStr); DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - jobExpList = alarmJobService.jobList(page, keywords, beginTime, endTime, jobStatusStr, alarmTypeStr, alarmContentStr, dataScope, currentUser.getId()); + List> jobExpList = alarmJobService.jobList(page, keywords, beginTime, endTime, jobStatusStr, alarmTypeStr, alarmContentStr, dataScope, currentUser.getId()); new AlarmJobWarpper(jobExpList).warp(); FileInputStream fileInputStream = null; + log.debug("----------------" + ToolUtil.isEmpty(jobExpList)); if (ToolUtil.isEmpty(jobExpList)) { fileInputStream = new FileInputStream(templatePath + "/jobRecEmpty.xlsx"); } else { @@ -305,12 +311,10 @@ try { httpServletResponse.setContentType("application/octet-stream"); httpServletResponse.addHeader("Content-Disposition", " attachment;filename=" + "jobOverview.xlsx"); - Map var = new HashMap<>(); var.put("标题", "工单一览表"); var.put("list", jobExpList); ExcelIO.writeTemplate(fileInputStream, httpServletResponse.getOutputStream(), var); - } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { @@ -328,11 +332,11 @@ */ @RequestMapping(value = "/getJob") @ResponseBody - public Object getJob(int id) { + public Object getJob(Long id) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - if (alarmJobService.getJob(id, currentUser.getId())){ + if (alarmJobService.getJob(id, currentUser.getId())) { return ResponseData.success(); } else { return ResponseData.error("接单失败"); @@ -344,10 +348,10 @@ */ @RequestMapping(value = "/confirmJob") @ResponseBody - public Object confirmJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "firstState", required = true) String firstState, - @RequestParam(value = "firstStatePhotos", required = true) String firstStatePhotos, - @RequestParam(value = "needHandle", required = true) String needHandle) { + public Object confirmJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "firstState", required = true) String firstState, + @RequestParam(value = "firstStatePhotos", required = true) String firstStatePhotos, + @RequestParam(value = "needHandle", required = true) String needHandle) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.confirmJob(id, currentUser.getId(), firstState, firstStatePhotos, needHandle)) { return ResponseData.success(); @@ -361,17 +365,19 @@ */ @RequestMapping(value = "/transferJob") @ResponseBody - public Object transferJob(@RequestParam(value = "id", required = true) int id, + public Object transferJob(@RequestParam(value = "id", required = true) Long id, @RequestParam(value = "transferPerson", required = true) String transferPerson) throws JSONException { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - String dbTime = iSysDictService.getDBtime(); +// String dbTime = iSysDictService.getDBtime(); + SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); +// String dbTime = iSysDictService.getDBtime(); + Date dbTime = new Date(); JSONObject jsonObject = new JSONObject(); jsonObject.put("from", currentUser.getName()); jsonObject.put("to", EhcacheConstant.retBean().getUsernameById(Long.valueOf(transferPerson))); - jsonObject.put("time", dbTime); - + jsonObject.put("time", dateFormat.format(dbTime)); if (alarmJobService.transferJob(id, Long.valueOf(transferPerson), jsonObject.toString())) { return ResponseData.success(); } else { @@ -384,9 +390,9 @@ */ @RequestMapping(value = "/saveJob") @ResponseBody - public Object saveJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "handleMessage", required = true) String handleMessage, - @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { + public Object saveJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "handleMessage", required = true) String handleMessage, + @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { if (alarmJobService.saveJob(id, handleMessage, handlePhotos)) { return ResponseData.success(); @@ -400,10 +406,9 @@ */ @RequestMapping(value = "/overJob") @ResponseBody - public Object overJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "handleMessage", required = true) String handleMessage, - @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { - + public Object overJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "handleMessage", required = true) String handleMessage, + @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.overJob(id, currentUser.getId(), handleMessage, handlePhotos)) { @@ -419,7 +424,7 @@ */ @RequestMapping(value = "/handleJob") @ResponseBody - public Object handleJob(@RequestParam(value = "id", required = true) int id) { + public Object handleJob(@RequestParam(value = "id", required = true) Long id) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.handleJob(id, currentUser.getId())) { return ResponseData.success(); @@ -433,12 +438,10 @@ */ @RequestMapping(value = "/info") @ResponseBody - public Object jobInfo(@RequestParam(value = "id", required = true) int id) { - + public Object jobInfo(@RequestParam(value = "id", required = true) long id) { DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List> retList = alarmJobService.jobInfo(id, dataScope, currentUser.getId()); - new AlarmJobWarpper(retList).warp(); return ResponseData.success(retList); } @@ -456,7 +459,7 @@ @RequestParam(value = "wellCode", required = true) String wellCode) { Map retMap = new HashMap<>(); try { - alarmJobService.updateSinkJob(id, URLDecoder.decode(msg, "UTF-8"),wellCode); + alarmJobService.updateSinkJob(id, URLDecoder.decode(msg, "UTF-8"), wellCode); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java index 46bb487..d27afa9 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java @@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.plugins.Page; import com.casic.missiles.core.base.response.ResponseData; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.alarm.service.IAlarmJobService; import com.casic.missiles.core.common.service.ICommonPermissionService; import com.casic.missiles.core.datascope.DataScope; @@ -12,12 +13,14 @@ import com.casic.missiles.modular.system.warpper.AlarmJobWarpper; import com.casic.missiles.core.base.controller.BaseController; import com.casic.missiles.core.common.constant.factory.PageFactory; +import lombok.extern.slf4j.Slf4j; import org.hswebframework.expands.office.excel.ExcelIO; import org.json.JSONException; import org.json.JSONObject; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; @@ -29,6 +32,7 @@ import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.*; //import com.casic.missiles.core.base.response.ResponseData; @@ -40,6 +44,7 @@ * @Date 2019-05-17 10:48:36 */ @Controller +@Slf4j @RequestMapping("/job") public class AlarmJobController extends BaseController { @@ -65,6 +70,13 @@ private String templatePath; + /** + * 工单状态接口统计 + * + * @param httpServletRequest + * @return + * @throws ParseException + */ @RequestMapping(value = "/countByJobStatus") @ResponseBody public Object countByJobStatus(HttpServletRequest httpServletRequest) throws ParseException { @@ -117,7 +129,7 @@ } /** - * 获取分页列表 + * 获取工单分页列表 */ @RequestMapping(value = "/list") @ResponseBody @@ -164,30 +176,26 @@ */ @RequestMapping(value = "/searchList") @ResponseBody - public Object jobListSearch(String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime, String endTime, - String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, - String handleJobBeginTime, String handleJobEndTime, String shouldHandleBeginTime, String shouldHandleEndTime) { + public Object jobListSearch(@RequestBody JobListParam jobListParam) { Page> page = new PageFactory>().defaultPage("createTime", false); DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List> retList = new ArrayList<>(); if (alarmJobService.checkPcRole(currentUser.getRoleTips())) { // pc角色 - retList = alarmJobService.jobListSearch(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, - handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, dataScope, currentUser.getId()); + retList = alarmJobService.jobListSearch(page, jobListParam, dataScope, currentUser.getId()); } else { //app角色 long leaderId = 0L; if (currentUser.getRoleTips().contains(sLeader)) { // 组长,查组内全部 leaderId = currentUser.getId(); - if (ToolUtil.isNotEmpty(jobStatus)) { + if (ToolUtil.isNotEmpty(jobListParam.getJobStatus())) { //learder&&jobStatus=1,2,3时,关闭传入的sort,按sql排序(自己的排在前) - page.setOpenSort(!alarmJobService.checkJobStatus(jobStatus)); + page.setOpenSort(!alarmJobService.checkJobStatus(jobListParam.getJobStatus())); } } - retList = alarmJobService.jobListSearchApp(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, - handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, currentUser.getDeptId(), currentUser.getId(), leaderId); + retList = alarmJobService.jobListSearchApp(page, jobListParam, currentUser.getDeptId(), currentUser.getId(), leaderId); } new AlarmJobWarpper(retList).warp(); @@ -277,26 +285,24 @@ @RequestMapping(value = "/export") public void exportJob(HttpServletRequest httpServletRequest , HttpServletResponse httpServletResponse) throws IOException { - Page> page = new PageFactory>().defaultPage("createTime", false); page.setLimit(maxRowsExcel); page.setSize(maxRowsExcel); page.setSearchCount(false); page.setOffset(0); - String keywords = httpServletRequest.getParameter("keywords"); String beginTime = httpServletRequest.getParameter("beginTime"); String endTime = httpServletRequest.getParameter("endTime"); String jobStatusStr = httpServletRequest.getParameter("jobStatus"); String alarmTypeStr = httpServletRequest.getParameter("alarmType"); String alarmContentStr = httpServletRequest.getParameter("alarmContentType"); - - List> jobExpList = new ArrayList<>(); + log.debug("主题参数---------------" + keywords + "," + beginTime + "," + endTime + "," + jobStatusStr + "," + alarmTypeStr + "," + alarmContentStr); DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - jobExpList = alarmJobService.jobList(page, keywords, beginTime, endTime, jobStatusStr, alarmTypeStr, alarmContentStr, dataScope, currentUser.getId()); + List> jobExpList = alarmJobService.jobList(page, keywords, beginTime, endTime, jobStatusStr, alarmTypeStr, alarmContentStr, dataScope, currentUser.getId()); new AlarmJobWarpper(jobExpList).warp(); FileInputStream fileInputStream = null; + log.debug("----------------" + ToolUtil.isEmpty(jobExpList)); if (ToolUtil.isEmpty(jobExpList)) { fileInputStream = new FileInputStream(templatePath + "/jobRecEmpty.xlsx"); } else { @@ -305,12 +311,10 @@ try { httpServletResponse.setContentType("application/octet-stream"); httpServletResponse.addHeader("Content-Disposition", " attachment;filename=" + "jobOverview.xlsx"); - Map var = new HashMap<>(); var.put("标题", "工单一览表"); var.put("list", jobExpList); ExcelIO.writeTemplate(fileInputStream, httpServletResponse.getOutputStream(), var); - } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { @@ -328,11 +332,11 @@ */ @RequestMapping(value = "/getJob") @ResponseBody - public Object getJob(int id) { + public Object getJob(Long id) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - if (alarmJobService.getJob(id, currentUser.getId())){ + if (alarmJobService.getJob(id, currentUser.getId())) { return ResponseData.success(); } else { return ResponseData.error("接单失败"); @@ -344,10 +348,10 @@ */ @RequestMapping(value = "/confirmJob") @ResponseBody - public Object confirmJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "firstState", required = true) String firstState, - @RequestParam(value = "firstStatePhotos", required = true) String firstStatePhotos, - @RequestParam(value = "needHandle", required = true) String needHandle) { + public Object confirmJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "firstState", required = true) String firstState, + @RequestParam(value = "firstStatePhotos", required = true) String firstStatePhotos, + @RequestParam(value = "needHandle", required = true) String needHandle) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.confirmJob(id, currentUser.getId(), firstState, firstStatePhotos, needHandle)) { return ResponseData.success(); @@ -361,17 +365,19 @@ */ @RequestMapping(value = "/transferJob") @ResponseBody - public Object transferJob(@RequestParam(value = "id", required = true) int id, + public Object transferJob(@RequestParam(value = "id", required = true) Long id, @RequestParam(value = "transferPerson", required = true) String transferPerson) throws JSONException { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - String dbTime = iSysDictService.getDBtime(); +// String dbTime = iSysDictService.getDBtime(); + SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); +// String dbTime = iSysDictService.getDBtime(); + Date dbTime = new Date(); JSONObject jsonObject = new JSONObject(); jsonObject.put("from", currentUser.getName()); jsonObject.put("to", EhcacheConstant.retBean().getUsernameById(Long.valueOf(transferPerson))); - jsonObject.put("time", dbTime); - + jsonObject.put("time", dateFormat.format(dbTime)); if (alarmJobService.transferJob(id, Long.valueOf(transferPerson), jsonObject.toString())) { return ResponseData.success(); } else { @@ -384,9 +390,9 @@ */ @RequestMapping(value = "/saveJob") @ResponseBody - public Object saveJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "handleMessage", required = true) String handleMessage, - @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { + public Object saveJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "handleMessage", required = true) String handleMessage, + @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { if (alarmJobService.saveJob(id, handleMessage, handlePhotos)) { return ResponseData.success(); @@ -400,10 +406,9 @@ */ @RequestMapping(value = "/overJob") @ResponseBody - public Object overJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "handleMessage", required = true) String handleMessage, - @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { - + public Object overJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "handleMessage", required = true) String handleMessage, + @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.overJob(id, currentUser.getId(), handleMessage, handlePhotos)) { @@ -419,7 +424,7 @@ */ @RequestMapping(value = "/handleJob") @ResponseBody - public Object handleJob(@RequestParam(value = "id", required = true) int id) { + public Object handleJob(@RequestParam(value = "id", required = true) Long id) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.handleJob(id, currentUser.getId())) { return ResponseData.success(); @@ -433,12 +438,10 @@ */ @RequestMapping(value = "/info") @ResponseBody - public Object jobInfo(@RequestParam(value = "id", required = true) int id) { - + public Object jobInfo(@RequestParam(value = "id", required = true) long id) { DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List> retList = alarmJobService.jobInfo(id, dataScope, currentUser.getId()); - new AlarmJobWarpper(retList).warp(); return ResponseData.success(retList); } @@ -456,7 +459,7 @@ @RequestParam(value = "wellCode", required = true) String wellCode) { Map retMap = new HashMap<>(); try { - alarmJobService.updateSinkJob(id, URLDecoder.decode(msg, "UTF-8"),wellCode); + alarmJobService.updateSinkJob(id, URLDecoder.decode(msg, "UTF-8"), wellCode); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java index 26a2ba7..df59231 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java @@ -52,6 +52,7 @@ @Autowired private IDeviceService deviceService; + @Value("${smartcity.office.maxRowsExcel}") private int maxRowsExcel; @Value("${smartcity.config.config-path}") @@ -182,7 +183,8 @@ @RequestMapping(value = "/cancelAlarmById") @ResponseBody public Object cancelAlarmById(@RequestParam(value = "alarmId",required = true) long alarmId){ - boolean isCancel = alarmRecordsService.cancelAlarmById(alarmId); + ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); + boolean isCancel = alarmRecordsService.cancelAlarm(alarmId,"4","手动消警",currentUser.getId()); if(isCancel){ return ResponseData.success(); }else { @@ -235,10 +237,10 @@ //根据查询条件查询alarm_record记录 DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); + ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List alarmRecords = alarmRecordsService.alarmListNoPage(dataScope, keywords, alarmType, alarmContent, beginTime, endTime, areaId); - for (AlarmRecords alarmRecord : alarmRecords) { - alarmRecordsService.cancelAlarmById(alarmRecord.getId()); + alarmRecordsService.cancelAlarm(alarmRecord.getJobId(),"4","手动消警",currentUser.getId()); } return ResponseData.success(); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java index 46bb487..d27afa9 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java @@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.plugins.Page; import com.casic.missiles.core.base.response.ResponseData; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.alarm.service.IAlarmJobService; import com.casic.missiles.core.common.service.ICommonPermissionService; import com.casic.missiles.core.datascope.DataScope; @@ -12,12 +13,14 @@ import com.casic.missiles.modular.system.warpper.AlarmJobWarpper; import com.casic.missiles.core.base.controller.BaseController; import com.casic.missiles.core.common.constant.factory.PageFactory; +import lombok.extern.slf4j.Slf4j; import org.hswebframework.expands.office.excel.ExcelIO; import org.json.JSONException; import org.json.JSONObject; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; @@ -29,6 +32,7 @@ import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.*; //import com.casic.missiles.core.base.response.ResponseData; @@ -40,6 +44,7 @@ * @Date 2019-05-17 10:48:36 */ @Controller +@Slf4j @RequestMapping("/job") public class AlarmJobController extends BaseController { @@ -65,6 +70,13 @@ private String templatePath; + /** + * 工单状态接口统计 + * + * @param httpServletRequest + * @return + * @throws ParseException + */ @RequestMapping(value = "/countByJobStatus") @ResponseBody public Object countByJobStatus(HttpServletRequest httpServletRequest) throws ParseException { @@ -117,7 +129,7 @@ } /** - * 获取分页列表 + * 获取工单分页列表 */ @RequestMapping(value = "/list") @ResponseBody @@ -164,30 +176,26 @@ */ @RequestMapping(value = "/searchList") @ResponseBody - public Object jobListSearch(String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime, String endTime, - String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, - String handleJobBeginTime, String handleJobEndTime, String shouldHandleBeginTime, String shouldHandleEndTime) { + public Object jobListSearch(@RequestBody JobListParam jobListParam) { Page> page = new PageFactory>().defaultPage("createTime", false); DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List> retList = new ArrayList<>(); if (alarmJobService.checkPcRole(currentUser.getRoleTips())) { // pc角色 - retList = alarmJobService.jobListSearch(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, - handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, dataScope, currentUser.getId()); + retList = alarmJobService.jobListSearch(page, jobListParam, dataScope, currentUser.getId()); } else { //app角色 long leaderId = 0L; if (currentUser.getRoleTips().contains(sLeader)) { // 组长,查组内全部 leaderId = currentUser.getId(); - if (ToolUtil.isNotEmpty(jobStatus)) { + if (ToolUtil.isNotEmpty(jobListParam.getJobStatus())) { //learder&&jobStatus=1,2,3时,关闭传入的sort,按sql排序(自己的排在前) - page.setOpenSort(!alarmJobService.checkJobStatus(jobStatus)); + page.setOpenSort(!alarmJobService.checkJobStatus(jobListParam.getJobStatus())); } } - retList = alarmJobService.jobListSearchApp(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, - handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, currentUser.getDeptId(), currentUser.getId(), leaderId); + retList = alarmJobService.jobListSearchApp(page, jobListParam, currentUser.getDeptId(), currentUser.getId(), leaderId); } new AlarmJobWarpper(retList).warp(); @@ -277,26 +285,24 @@ @RequestMapping(value = "/export") public void exportJob(HttpServletRequest httpServletRequest , HttpServletResponse httpServletResponse) throws IOException { - Page> page = new PageFactory>().defaultPage("createTime", false); page.setLimit(maxRowsExcel); page.setSize(maxRowsExcel); page.setSearchCount(false); page.setOffset(0); - String keywords = httpServletRequest.getParameter("keywords"); String beginTime = httpServletRequest.getParameter("beginTime"); String endTime = httpServletRequest.getParameter("endTime"); String jobStatusStr = httpServletRequest.getParameter("jobStatus"); String alarmTypeStr = httpServletRequest.getParameter("alarmType"); String alarmContentStr = httpServletRequest.getParameter("alarmContentType"); - - List> jobExpList = new ArrayList<>(); + log.debug("主题参数---------------" + keywords + "," + beginTime + "," + endTime + "," + jobStatusStr + "," + alarmTypeStr + "," + alarmContentStr); DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - jobExpList = alarmJobService.jobList(page, keywords, beginTime, endTime, jobStatusStr, alarmTypeStr, alarmContentStr, dataScope, currentUser.getId()); + List> jobExpList = alarmJobService.jobList(page, keywords, beginTime, endTime, jobStatusStr, alarmTypeStr, alarmContentStr, dataScope, currentUser.getId()); new AlarmJobWarpper(jobExpList).warp(); FileInputStream fileInputStream = null; + log.debug("----------------" + ToolUtil.isEmpty(jobExpList)); if (ToolUtil.isEmpty(jobExpList)) { fileInputStream = new FileInputStream(templatePath + "/jobRecEmpty.xlsx"); } else { @@ -305,12 +311,10 @@ try { httpServletResponse.setContentType("application/octet-stream"); httpServletResponse.addHeader("Content-Disposition", " attachment;filename=" + "jobOverview.xlsx"); - Map var = new HashMap<>(); var.put("标题", "工单一览表"); var.put("list", jobExpList); ExcelIO.writeTemplate(fileInputStream, httpServletResponse.getOutputStream(), var); - } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { @@ -328,11 +332,11 @@ */ @RequestMapping(value = "/getJob") @ResponseBody - public Object getJob(int id) { + public Object getJob(Long id) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - if (alarmJobService.getJob(id, currentUser.getId())){ + if (alarmJobService.getJob(id, currentUser.getId())) { return ResponseData.success(); } else { return ResponseData.error("接单失败"); @@ -344,10 +348,10 @@ */ @RequestMapping(value = "/confirmJob") @ResponseBody - public Object confirmJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "firstState", required = true) String firstState, - @RequestParam(value = "firstStatePhotos", required = true) String firstStatePhotos, - @RequestParam(value = "needHandle", required = true) String needHandle) { + public Object confirmJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "firstState", required = true) String firstState, + @RequestParam(value = "firstStatePhotos", required = true) String firstStatePhotos, + @RequestParam(value = "needHandle", required = true) String needHandle) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.confirmJob(id, currentUser.getId(), firstState, firstStatePhotos, needHandle)) { return ResponseData.success(); @@ -361,17 +365,19 @@ */ @RequestMapping(value = "/transferJob") @ResponseBody - public Object transferJob(@RequestParam(value = "id", required = true) int id, + public Object transferJob(@RequestParam(value = "id", required = true) Long id, @RequestParam(value = "transferPerson", required = true) String transferPerson) throws JSONException { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - String dbTime = iSysDictService.getDBtime(); +// String dbTime = iSysDictService.getDBtime(); + SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); +// String dbTime = iSysDictService.getDBtime(); + Date dbTime = new Date(); JSONObject jsonObject = new JSONObject(); jsonObject.put("from", currentUser.getName()); jsonObject.put("to", EhcacheConstant.retBean().getUsernameById(Long.valueOf(transferPerson))); - jsonObject.put("time", dbTime); - + jsonObject.put("time", dateFormat.format(dbTime)); if (alarmJobService.transferJob(id, Long.valueOf(transferPerson), jsonObject.toString())) { return ResponseData.success(); } else { @@ -384,9 +390,9 @@ */ @RequestMapping(value = "/saveJob") @ResponseBody - public Object saveJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "handleMessage", required = true) String handleMessage, - @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { + public Object saveJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "handleMessage", required = true) String handleMessage, + @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { if (alarmJobService.saveJob(id, handleMessage, handlePhotos)) { return ResponseData.success(); @@ -400,10 +406,9 @@ */ @RequestMapping(value = "/overJob") @ResponseBody - public Object overJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "handleMessage", required = true) String handleMessage, - @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { - + public Object overJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "handleMessage", required = true) String handleMessage, + @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.overJob(id, currentUser.getId(), handleMessage, handlePhotos)) { @@ -419,7 +424,7 @@ */ @RequestMapping(value = "/handleJob") @ResponseBody - public Object handleJob(@RequestParam(value = "id", required = true) int id) { + public Object handleJob(@RequestParam(value = "id", required = true) Long id) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.handleJob(id, currentUser.getId())) { return ResponseData.success(); @@ -433,12 +438,10 @@ */ @RequestMapping(value = "/info") @ResponseBody - public Object jobInfo(@RequestParam(value = "id", required = true) int id) { - + public Object jobInfo(@RequestParam(value = "id", required = true) long id) { DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List> retList = alarmJobService.jobInfo(id, dataScope, currentUser.getId()); - new AlarmJobWarpper(retList).warp(); return ResponseData.success(retList); } @@ -456,7 +459,7 @@ @RequestParam(value = "wellCode", required = true) String wellCode) { Map retMap = new HashMap<>(); try { - alarmJobService.updateSinkJob(id, URLDecoder.decode(msg, "UTF-8"),wellCode); + alarmJobService.updateSinkJob(id, URLDecoder.decode(msg, "UTF-8"), wellCode); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java index 26a2ba7..df59231 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java @@ -52,6 +52,7 @@ @Autowired private IDeviceService deviceService; + @Value("${smartcity.office.maxRowsExcel}") private int maxRowsExcel; @Value("${smartcity.config.config-path}") @@ -182,7 +183,8 @@ @RequestMapping(value = "/cancelAlarmById") @ResponseBody public Object cancelAlarmById(@RequestParam(value = "alarmId",required = true) long alarmId){ - boolean isCancel = alarmRecordsService.cancelAlarmById(alarmId); + ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); + boolean isCancel = alarmRecordsService.cancelAlarm(alarmId,"4","手动消警",currentUser.getId()); if(isCancel){ return ResponseData.success(); }else { @@ -235,10 +237,10 @@ //根据查询条件查询alarm_record记录 DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); + ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List alarmRecords = alarmRecordsService.alarmListNoPage(dataScope, keywords, alarmType, alarmContent, beginTime, endTime, areaId); - for (AlarmRecords alarmRecord : alarmRecords) { - alarmRecordsService.cancelAlarmById(alarmRecord.getId()); + alarmRecordsService.cancelAlarm(alarmRecord.getJobId(),"4","手动消警",currentUser.getId()); } return ResponseData.success(); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/model/JobListParam.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/model/JobListParam.java new file mode 100644 index 0000000..c83bff8 --- /dev/null +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/model/JobListParam.java @@ -0,0 +1,32 @@ +package com.casic.missiles.modular.alarm.model; + + +import lombok.Data; + +/** + * @author cz + * @date 2022-6-13 17:03 + */ +@Data +public class JobListParam { + /** + * 关键字 + */ + private String keywords; + /** + * 风险等级 + */ + private String alarmLevel; + private String alarmContent; + private String jobStatus; + private String beginTime; + private String endTime; + private String getJobBeginTime; + private String getJobEndTime; + private String shouldGetBeginTime; + private String shouldGetEndTime; + private String handleJobBeginTime; + private String handleJobEndTime; + private String shouldHandleBeginTime; + private String shouldHandleEndTime; +} diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java index 46bb487..d27afa9 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java @@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.plugins.Page; import com.casic.missiles.core.base.response.ResponseData; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.alarm.service.IAlarmJobService; import com.casic.missiles.core.common.service.ICommonPermissionService; import com.casic.missiles.core.datascope.DataScope; @@ -12,12 +13,14 @@ import com.casic.missiles.modular.system.warpper.AlarmJobWarpper; import com.casic.missiles.core.base.controller.BaseController; import com.casic.missiles.core.common.constant.factory.PageFactory; +import lombok.extern.slf4j.Slf4j; import org.hswebframework.expands.office.excel.ExcelIO; import org.json.JSONException; import org.json.JSONObject; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; @@ -29,6 +32,7 @@ import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.*; //import com.casic.missiles.core.base.response.ResponseData; @@ -40,6 +44,7 @@ * @Date 2019-05-17 10:48:36 */ @Controller +@Slf4j @RequestMapping("/job") public class AlarmJobController extends BaseController { @@ -65,6 +70,13 @@ private String templatePath; + /** + * 工单状态接口统计 + * + * @param httpServletRequest + * @return + * @throws ParseException + */ @RequestMapping(value = "/countByJobStatus") @ResponseBody public Object countByJobStatus(HttpServletRequest httpServletRequest) throws ParseException { @@ -117,7 +129,7 @@ } /** - * 获取分页列表 + * 获取工单分页列表 */ @RequestMapping(value = "/list") @ResponseBody @@ -164,30 +176,26 @@ */ @RequestMapping(value = "/searchList") @ResponseBody - public Object jobListSearch(String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime, String endTime, - String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, - String handleJobBeginTime, String handleJobEndTime, String shouldHandleBeginTime, String shouldHandleEndTime) { + public Object jobListSearch(@RequestBody JobListParam jobListParam) { Page> page = new PageFactory>().defaultPage("createTime", false); DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List> retList = new ArrayList<>(); if (alarmJobService.checkPcRole(currentUser.getRoleTips())) { // pc角色 - retList = alarmJobService.jobListSearch(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, - handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, dataScope, currentUser.getId()); + retList = alarmJobService.jobListSearch(page, jobListParam, dataScope, currentUser.getId()); } else { //app角色 long leaderId = 0L; if (currentUser.getRoleTips().contains(sLeader)) { // 组长,查组内全部 leaderId = currentUser.getId(); - if (ToolUtil.isNotEmpty(jobStatus)) { + if (ToolUtil.isNotEmpty(jobListParam.getJobStatus())) { //learder&&jobStatus=1,2,3时,关闭传入的sort,按sql排序(自己的排在前) - page.setOpenSort(!alarmJobService.checkJobStatus(jobStatus)); + page.setOpenSort(!alarmJobService.checkJobStatus(jobListParam.getJobStatus())); } } - retList = alarmJobService.jobListSearchApp(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, - handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, currentUser.getDeptId(), currentUser.getId(), leaderId); + retList = alarmJobService.jobListSearchApp(page, jobListParam, currentUser.getDeptId(), currentUser.getId(), leaderId); } new AlarmJobWarpper(retList).warp(); @@ -277,26 +285,24 @@ @RequestMapping(value = "/export") public void exportJob(HttpServletRequest httpServletRequest , HttpServletResponse httpServletResponse) throws IOException { - Page> page = new PageFactory>().defaultPage("createTime", false); page.setLimit(maxRowsExcel); page.setSize(maxRowsExcel); page.setSearchCount(false); page.setOffset(0); - String keywords = httpServletRequest.getParameter("keywords"); String beginTime = httpServletRequest.getParameter("beginTime"); String endTime = httpServletRequest.getParameter("endTime"); String jobStatusStr = httpServletRequest.getParameter("jobStatus"); String alarmTypeStr = httpServletRequest.getParameter("alarmType"); String alarmContentStr = httpServletRequest.getParameter("alarmContentType"); - - List> jobExpList = new ArrayList<>(); + log.debug("主题参数---------------" + keywords + "," + beginTime + "," + endTime + "," + jobStatusStr + "," + alarmTypeStr + "," + alarmContentStr); DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - jobExpList = alarmJobService.jobList(page, keywords, beginTime, endTime, jobStatusStr, alarmTypeStr, alarmContentStr, dataScope, currentUser.getId()); + List> jobExpList = alarmJobService.jobList(page, keywords, beginTime, endTime, jobStatusStr, alarmTypeStr, alarmContentStr, dataScope, currentUser.getId()); new AlarmJobWarpper(jobExpList).warp(); FileInputStream fileInputStream = null; + log.debug("----------------" + ToolUtil.isEmpty(jobExpList)); if (ToolUtil.isEmpty(jobExpList)) { fileInputStream = new FileInputStream(templatePath + "/jobRecEmpty.xlsx"); } else { @@ -305,12 +311,10 @@ try { httpServletResponse.setContentType("application/octet-stream"); httpServletResponse.addHeader("Content-Disposition", " attachment;filename=" + "jobOverview.xlsx"); - Map var = new HashMap<>(); var.put("标题", "工单一览表"); var.put("list", jobExpList); ExcelIO.writeTemplate(fileInputStream, httpServletResponse.getOutputStream(), var); - } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { @@ -328,11 +332,11 @@ */ @RequestMapping(value = "/getJob") @ResponseBody - public Object getJob(int id) { + public Object getJob(Long id) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - if (alarmJobService.getJob(id, currentUser.getId())){ + if (alarmJobService.getJob(id, currentUser.getId())) { return ResponseData.success(); } else { return ResponseData.error("接单失败"); @@ -344,10 +348,10 @@ */ @RequestMapping(value = "/confirmJob") @ResponseBody - public Object confirmJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "firstState", required = true) String firstState, - @RequestParam(value = "firstStatePhotos", required = true) String firstStatePhotos, - @RequestParam(value = "needHandle", required = true) String needHandle) { + public Object confirmJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "firstState", required = true) String firstState, + @RequestParam(value = "firstStatePhotos", required = true) String firstStatePhotos, + @RequestParam(value = "needHandle", required = true) String needHandle) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.confirmJob(id, currentUser.getId(), firstState, firstStatePhotos, needHandle)) { return ResponseData.success(); @@ -361,17 +365,19 @@ */ @RequestMapping(value = "/transferJob") @ResponseBody - public Object transferJob(@RequestParam(value = "id", required = true) int id, + public Object transferJob(@RequestParam(value = "id", required = true) Long id, @RequestParam(value = "transferPerson", required = true) String transferPerson) throws JSONException { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - String dbTime = iSysDictService.getDBtime(); +// String dbTime = iSysDictService.getDBtime(); + SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); +// String dbTime = iSysDictService.getDBtime(); + Date dbTime = new Date(); JSONObject jsonObject = new JSONObject(); jsonObject.put("from", currentUser.getName()); jsonObject.put("to", EhcacheConstant.retBean().getUsernameById(Long.valueOf(transferPerson))); - jsonObject.put("time", dbTime); - + jsonObject.put("time", dateFormat.format(dbTime)); if (alarmJobService.transferJob(id, Long.valueOf(transferPerson), jsonObject.toString())) { return ResponseData.success(); } else { @@ -384,9 +390,9 @@ */ @RequestMapping(value = "/saveJob") @ResponseBody - public Object saveJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "handleMessage", required = true) String handleMessage, - @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { + public Object saveJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "handleMessage", required = true) String handleMessage, + @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { if (alarmJobService.saveJob(id, handleMessage, handlePhotos)) { return ResponseData.success(); @@ -400,10 +406,9 @@ */ @RequestMapping(value = "/overJob") @ResponseBody - public Object overJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "handleMessage", required = true) String handleMessage, - @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { - + public Object overJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "handleMessage", required = true) String handleMessage, + @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.overJob(id, currentUser.getId(), handleMessage, handlePhotos)) { @@ -419,7 +424,7 @@ */ @RequestMapping(value = "/handleJob") @ResponseBody - public Object handleJob(@RequestParam(value = "id", required = true) int id) { + public Object handleJob(@RequestParam(value = "id", required = true) Long id) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.handleJob(id, currentUser.getId())) { return ResponseData.success(); @@ -433,12 +438,10 @@ */ @RequestMapping(value = "/info") @ResponseBody - public Object jobInfo(@RequestParam(value = "id", required = true) int id) { - + public Object jobInfo(@RequestParam(value = "id", required = true) long id) { DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List> retList = alarmJobService.jobInfo(id, dataScope, currentUser.getId()); - new AlarmJobWarpper(retList).warp(); return ResponseData.success(retList); } @@ -456,7 +459,7 @@ @RequestParam(value = "wellCode", required = true) String wellCode) { Map retMap = new HashMap<>(); try { - alarmJobService.updateSinkJob(id, URLDecoder.decode(msg, "UTF-8"),wellCode); + alarmJobService.updateSinkJob(id, URLDecoder.decode(msg, "UTF-8"), wellCode); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java index 26a2ba7..df59231 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java @@ -52,6 +52,7 @@ @Autowired private IDeviceService deviceService; + @Value("${smartcity.office.maxRowsExcel}") private int maxRowsExcel; @Value("${smartcity.config.config-path}") @@ -182,7 +183,8 @@ @RequestMapping(value = "/cancelAlarmById") @ResponseBody public Object cancelAlarmById(@RequestParam(value = "alarmId",required = true) long alarmId){ - boolean isCancel = alarmRecordsService.cancelAlarmById(alarmId); + ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); + boolean isCancel = alarmRecordsService.cancelAlarm(alarmId,"4","手动消警",currentUser.getId()); if(isCancel){ return ResponseData.success(); }else { @@ -235,10 +237,10 @@ //根据查询条件查询alarm_record记录 DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); + ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List alarmRecords = alarmRecordsService.alarmListNoPage(dataScope, keywords, alarmType, alarmContent, beginTime, endTime, areaId); - for (AlarmRecords alarmRecord : alarmRecords) { - alarmRecordsService.cancelAlarmById(alarmRecord.getId()); + alarmRecordsService.cancelAlarm(alarmRecord.getJobId(),"4","手动消警",currentUser.getId()); } return ResponseData.success(); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/model/JobListParam.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/model/JobListParam.java new file mode 100644 index 0000000..c83bff8 --- /dev/null +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/model/JobListParam.java @@ -0,0 +1,32 @@ +package com.casic.missiles.modular.alarm.model; + + +import lombok.Data; + +/** + * @author cz + * @date 2022-6-13 17:03 + */ +@Data +public class JobListParam { + /** + * 关键字 + */ + private String keywords; + /** + * 风险等级 + */ + private String alarmLevel; + private String alarmContent; + private String jobStatus; + private String beginTime; + private String endTime; + private String getJobBeginTime; + private String getJobEndTime; + private String shouldGetBeginTime; + private String shouldGetEndTime; + private String handleJobBeginTime; + private String handleJobEndTime; + private String shouldHandleBeginTime; + private String shouldHandleEndTime; +} diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java index d4db8ce..018d095 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java @@ -3,6 +3,7 @@ import com.baomidou.mybatisplus.plugins.Page; import com.baomidou.mybatisplus.service.IService; import com.casic.missiles.core.datascope.DataScope; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.system.dto.UserClientView; import com.casic.missiles.modular.system.model.AlarmJob; @@ -18,42 +19,60 @@ * @since 2019-05-17 */ public interface IAlarmJobService extends IService { - List> jobList( Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType,String alarmContent, DataScope dataScope,Long userId); - List> jobListApp( Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType,String alarmContent,Long deptId,Long userId,Long leaderId); + + List> jobList(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, DataScope dataScope, Long userId); + + List> jobListApp(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, Long deptId, Long userId, Long leaderId); // List jobListExport( Page page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType,String alarmContent, DataScope dataScope); - List> jobListDelayRe( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, DataScope dataScope,Long userId); - List> jobListDelayReApp( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, Long deptId,Long userId,Long leaderId); + List> jobListDelayRe(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId); - List> jobListDelayPro( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, DataScope dataScope,Long userId ); - List> jobListDelayProApp( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, Long deptId,Long userId,Long leaderId); + List> jobListDelayReApp(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, Long deptId, Long userId, Long leaderId); - List> jobListSearch(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime,String endTime, - String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, - String shouldHandleBeginTime, String shouldHandleEndTime, DataScope dataScope,Long userId); - List> jobListSearchApp(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime,String endTime, - String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, - String shouldHandleBeginTime, String shouldHandleEndTime, Long deptId, Long userId, Long leaderId); - List> jobInfo(int id, DataScope dataScope,Long personId); - boolean getJob(int id, long personId); - boolean confirmJob(int id,long personId,String firstState, String firstStatePhotos, String needHandle); - boolean transferJob(int id, long transferPerson,String flowRec); - boolean saveJob( int id,String handleMessage, String handlePhotos); - boolean overJob( int id,long personId, String handleMessage, String handlePhotos); - boolean overAlarm( int id); - boolean handleJob(int id,long personId); + List> jobListDelayPro(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId); - Map countByJobStatus(long deptId,int spanDays); - Map countMyJob(long userId,long deptId,int spanDays); + List> jobListDelayProApp(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, Long deptId, Long userId, Long leaderId); + + List> jobListSearch(Page> page, JobListParam jobListParam, DataScope dataScope, Long userId); + + List> jobListSearchApp(Page> page, JobListParam jobListParam, Long deptId, Long userId, Long leaderId); + + List> jobInfo(Long id, DataScope dataScope, Long personId); + + boolean getJob(Long id, long personId); + + boolean confirmJob(Long id, long personId, String firstState, String firstStatePhotos, String needHandle); + + boolean transferJob(Long id, long transferPerson, String flowRec); + + boolean saveJob(Long id, String handleMessage, String handlePhotos); + + boolean overJob(Long id, long personId, String handleMessage, String handlePhotos); + + boolean overAlarm(int id); + + boolean handleJob(Long id, long personId); + + Map countByJobStatus(long deptId, int spanDays); + + Map countMyJob(long userId, long deptId, int spanDays); boolean checkJobStatus(String jobStatus); + boolean checkPcRole(List roleTips); - Integer countByDataScope(DataScope dataScope,String alarmType, String jobStatus,String beginTime,String endTime); - Integer countByResponse(String alarmType,String jobStatus,Long deptId,String beginTime,String endTime); - Integer countByUser(String alarmType,String jobStatus,Long userId,String beginTime,String endTime); + Integer countByDataScope(DataScope dataScope, String alarmType, String jobStatus, String beginTime, String endTime); - void updateSinkJob(String id,String msg,String wellCode); + Integer countByResponse(String alarmType, String jobStatus, Long deptId, String beginTime, String endTime); + + Integer countByUser(String alarmType, String jobStatus, Long userId, String beginTime, String endTime); + + void updateSinkJob(String id, String msg, String wellCode); + List selectUserByWellCode(String wellCode); + String selectClientIdByUser(Long userId); + + AlarmJob saveData( String devCode, String wellCode, String devTypeName, String jobType); + } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java index 46bb487..d27afa9 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java @@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.plugins.Page; import com.casic.missiles.core.base.response.ResponseData; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.alarm.service.IAlarmJobService; import com.casic.missiles.core.common.service.ICommonPermissionService; import com.casic.missiles.core.datascope.DataScope; @@ -12,12 +13,14 @@ import com.casic.missiles.modular.system.warpper.AlarmJobWarpper; import com.casic.missiles.core.base.controller.BaseController; import com.casic.missiles.core.common.constant.factory.PageFactory; +import lombok.extern.slf4j.Slf4j; import org.hswebframework.expands.office.excel.ExcelIO; import org.json.JSONException; import org.json.JSONObject; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; @@ -29,6 +32,7 @@ import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.*; //import com.casic.missiles.core.base.response.ResponseData; @@ -40,6 +44,7 @@ * @Date 2019-05-17 10:48:36 */ @Controller +@Slf4j @RequestMapping("/job") public class AlarmJobController extends BaseController { @@ -65,6 +70,13 @@ private String templatePath; + /** + * 工单状态接口统计 + * + * @param httpServletRequest + * @return + * @throws ParseException + */ @RequestMapping(value = "/countByJobStatus") @ResponseBody public Object countByJobStatus(HttpServletRequest httpServletRequest) throws ParseException { @@ -117,7 +129,7 @@ } /** - * 获取分页列表 + * 获取工单分页列表 */ @RequestMapping(value = "/list") @ResponseBody @@ -164,30 +176,26 @@ */ @RequestMapping(value = "/searchList") @ResponseBody - public Object jobListSearch(String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime, String endTime, - String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, - String handleJobBeginTime, String handleJobEndTime, String shouldHandleBeginTime, String shouldHandleEndTime) { + public Object jobListSearch(@RequestBody JobListParam jobListParam) { Page> page = new PageFactory>().defaultPage("createTime", false); DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List> retList = new ArrayList<>(); if (alarmJobService.checkPcRole(currentUser.getRoleTips())) { // pc角色 - retList = alarmJobService.jobListSearch(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, - handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, dataScope, currentUser.getId()); + retList = alarmJobService.jobListSearch(page, jobListParam, dataScope, currentUser.getId()); } else { //app角色 long leaderId = 0L; if (currentUser.getRoleTips().contains(sLeader)) { // 组长,查组内全部 leaderId = currentUser.getId(); - if (ToolUtil.isNotEmpty(jobStatus)) { + if (ToolUtil.isNotEmpty(jobListParam.getJobStatus())) { //learder&&jobStatus=1,2,3时,关闭传入的sort,按sql排序(自己的排在前) - page.setOpenSort(!alarmJobService.checkJobStatus(jobStatus)); + page.setOpenSort(!alarmJobService.checkJobStatus(jobListParam.getJobStatus())); } } - retList = alarmJobService.jobListSearchApp(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, - handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, currentUser.getDeptId(), currentUser.getId(), leaderId); + retList = alarmJobService.jobListSearchApp(page, jobListParam, currentUser.getDeptId(), currentUser.getId(), leaderId); } new AlarmJobWarpper(retList).warp(); @@ -277,26 +285,24 @@ @RequestMapping(value = "/export") public void exportJob(HttpServletRequest httpServletRequest , HttpServletResponse httpServletResponse) throws IOException { - Page> page = new PageFactory>().defaultPage("createTime", false); page.setLimit(maxRowsExcel); page.setSize(maxRowsExcel); page.setSearchCount(false); page.setOffset(0); - String keywords = httpServletRequest.getParameter("keywords"); String beginTime = httpServletRequest.getParameter("beginTime"); String endTime = httpServletRequest.getParameter("endTime"); String jobStatusStr = httpServletRequest.getParameter("jobStatus"); String alarmTypeStr = httpServletRequest.getParameter("alarmType"); String alarmContentStr = httpServletRequest.getParameter("alarmContentType"); - - List> jobExpList = new ArrayList<>(); + log.debug("主题参数---------------" + keywords + "," + beginTime + "," + endTime + "," + jobStatusStr + "," + alarmTypeStr + "," + alarmContentStr); DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - jobExpList = alarmJobService.jobList(page, keywords, beginTime, endTime, jobStatusStr, alarmTypeStr, alarmContentStr, dataScope, currentUser.getId()); + List> jobExpList = alarmJobService.jobList(page, keywords, beginTime, endTime, jobStatusStr, alarmTypeStr, alarmContentStr, dataScope, currentUser.getId()); new AlarmJobWarpper(jobExpList).warp(); FileInputStream fileInputStream = null; + log.debug("----------------" + ToolUtil.isEmpty(jobExpList)); if (ToolUtil.isEmpty(jobExpList)) { fileInputStream = new FileInputStream(templatePath + "/jobRecEmpty.xlsx"); } else { @@ -305,12 +311,10 @@ try { httpServletResponse.setContentType("application/octet-stream"); httpServletResponse.addHeader("Content-Disposition", " attachment;filename=" + "jobOverview.xlsx"); - Map var = new HashMap<>(); var.put("标题", "工单一览表"); var.put("list", jobExpList); ExcelIO.writeTemplate(fileInputStream, httpServletResponse.getOutputStream(), var); - } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { @@ -328,11 +332,11 @@ */ @RequestMapping(value = "/getJob") @ResponseBody - public Object getJob(int id) { + public Object getJob(Long id) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - if (alarmJobService.getJob(id, currentUser.getId())){ + if (alarmJobService.getJob(id, currentUser.getId())) { return ResponseData.success(); } else { return ResponseData.error("接单失败"); @@ -344,10 +348,10 @@ */ @RequestMapping(value = "/confirmJob") @ResponseBody - public Object confirmJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "firstState", required = true) String firstState, - @RequestParam(value = "firstStatePhotos", required = true) String firstStatePhotos, - @RequestParam(value = "needHandle", required = true) String needHandle) { + public Object confirmJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "firstState", required = true) String firstState, + @RequestParam(value = "firstStatePhotos", required = true) String firstStatePhotos, + @RequestParam(value = "needHandle", required = true) String needHandle) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.confirmJob(id, currentUser.getId(), firstState, firstStatePhotos, needHandle)) { return ResponseData.success(); @@ -361,17 +365,19 @@ */ @RequestMapping(value = "/transferJob") @ResponseBody - public Object transferJob(@RequestParam(value = "id", required = true) int id, + public Object transferJob(@RequestParam(value = "id", required = true) Long id, @RequestParam(value = "transferPerson", required = true) String transferPerson) throws JSONException { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - String dbTime = iSysDictService.getDBtime(); +// String dbTime = iSysDictService.getDBtime(); + SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); +// String dbTime = iSysDictService.getDBtime(); + Date dbTime = new Date(); JSONObject jsonObject = new JSONObject(); jsonObject.put("from", currentUser.getName()); jsonObject.put("to", EhcacheConstant.retBean().getUsernameById(Long.valueOf(transferPerson))); - jsonObject.put("time", dbTime); - + jsonObject.put("time", dateFormat.format(dbTime)); if (alarmJobService.transferJob(id, Long.valueOf(transferPerson), jsonObject.toString())) { return ResponseData.success(); } else { @@ -384,9 +390,9 @@ */ @RequestMapping(value = "/saveJob") @ResponseBody - public Object saveJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "handleMessage", required = true) String handleMessage, - @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { + public Object saveJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "handleMessage", required = true) String handleMessage, + @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { if (alarmJobService.saveJob(id, handleMessage, handlePhotos)) { return ResponseData.success(); @@ -400,10 +406,9 @@ */ @RequestMapping(value = "/overJob") @ResponseBody - public Object overJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "handleMessage", required = true) String handleMessage, - @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { - + public Object overJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "handleMessage", required = true) String handleMessage, + @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.overJob(id, currentUser.getId(), handleMessage, handlePhotos)) { @@ -419,7 +424,7 @@ */ @RequestMapping(value = "/handleJob") @ResponseBody - public Object handleJob(@RequestParam(value = "id", required = true) int id) { + public Object handleJob(@RequestParam(value = "id", required = true) Long id) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.handleJob(id, currentUser.getId())) { return ResponseData.success(); @@ -433,12 +438,10 @@ */ @RequestMapping(value = "/info") @ResponseBody - public Object jobInfo(@RequestParam(value = "id", required = true) int id) { - + public Object jobInfo(@RequestParam(value = "id", required = true) long id) { DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List> retList = alarmJobService.jobInfo(id, dataScope, currentUser.getId()); - new AlarmJobWarpper(retList).warp(); return ResponseData.success(retList); } @@ -456,7 +459,7 @@ @RequestParam(value = "wellCode", required = true) String wellCode) { Map retMap = new HashMap<>(); try { - alarmJobService.updateSinkJob(id, URLDecoder.decode(msg, "UTF-8"),wellCode); + alarmJobService.updateSinkJob(id, URLDecoder.decode(msg, "UTF-8"), wellCode); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java index 26a2ba7..df59231 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java @@ -52,6 +52,7 @@ @Autowired private IDeviceService deviceService; + @Value("${smartcity.office.maxRowsExcel}") private int maxRowsExcel; @Value("${smartcity.config.config-path}") @@ -182,7 +183,8 @@ @RequestMapping(value = "/cancelAlarmById") @ResponseBody public Object cancelAlarmById(@RequestParam(value = "alarmId",required = true) long alarmId){ - boolean isCancel = alarmRecordsService.cancelAlarmById(alarmId); + ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); + boolean isCancel = alarmRecordsService.cancelAlarm(alarmId,"4","手动消警",currentUser.getId()); if(isCancel){ return ResponseData.success(); }else { @@ -235,10 +237,10 @@ //根据查询条件查询alarm_record记录 DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); + ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List alarmRecords = alarmRecordsService.alarmListNoPage(dataScope, keywords, alarmType, alarmContent, beginTime, endTime, areaId); - for (AlarmRecords alarmRecord : alarmRecords) { - alarmRecordsService.cancelAlarmById(alarmRecord.getId()); + alarmRecordsService.cancelAlarm(alarmRecord.getJobId(),"4","手动消警",currentUser.getId()); } return ResponseData.success(); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/model/JobListParam.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/model/JobListParam.java new file mode 100644 index 0000000..c83bff8 --- /dev/null +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/model/JobListParam.java @@ -0,0 +1,32 @@ +package com.casic.missiles.modular.alarm.model; + + +import lombok.Data; + +/** + * @author cz + * @date 2022-6-13 17:03 + */ +@Data +public class JobListParam { + /** + * 关键字 + */ + private String keywords; + /** + * 风险等级 + */ + private String alarmLevel; + private String alarmContent; + private String jobStatus; + private String beginTime; + private String endTime; + private String getJobBeginTime; + private String getJobEndTime; + private String shouldGetBeginTime; + private String shouldGetEndTime; + private String handleJobBeginTime; + private String handleJobEndTime; + private String shouldHandleBeginTime; + private String shouldHandleEndTime; +} diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java index d4db8ce..018d095 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java @@ -3,6 +3,7 @@ import com.baomidou.mybatisplus.plugins.Page; import com.baomidou.mybatisplus.service.IService; import com.casic.missiles.core.datascope.DataScope; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.system.dto.UserClientView; import com.casic.missiles.modular.system.model.AlarmJob; @@ -18,42 +19,60 @@ * @since 2019-05-17 */ public interface IAlarmJobService extends IService { - List> jobList( Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType,String alarmContent, DataScope dataScope,Long userId); - List> jobListApp( Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType,String alarmContent,Long deptId,Long userId,Long leaderId); + + List> jobList(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, DataScope dataScope, Long userId); + + List> jobListApp(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, Long deptId, Long userId, Long leaderId); // List jobListExport( Page page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType,String alarmContent, DataScope dataScope); - List> jobListDelayRe( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, DataScope dataScope,Long userId); - List> jobListDelayReApp( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, Long deptId,Long userId,Long leaderId); + List> jobListDelayRe(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId); - List> jobListDelayPro( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, DataScope dataScope,Long userId ); - List> jobListDelayProApp( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, Long deptId,Long userId,Long leaderId); + List> jobListDelayReApp(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, Long deptId, Long userId, Long leaderId); - List> jobListSearch(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime,String endTime, - String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, - String shouldHandleBeginTime, String shouldHandleEndTime, DataScope dataScope,Long userId); - List> jobListSearchApp(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime,String endTime, - String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, - String shouldHandleBeginTime, String shouldHandleEndTime, Long deptId, Long userId, Long leaderId); - List> jobInfo(int id, DataScope dataScope,Long personId); - boolean getJob(int id, long personId); - boolean confirmJob(int id,long personId,String firstState, String firstStatePhotos, String needHandle); - boolean transferJob(int id, long transferPerson,String flowRec); - boolean saveJob( int id,String handleMessage, String handlePhotos); - boolean overJob( int id,long personId, String handleMessage, String handlePhotos); - boolean overAlarm( int id); - boolean handleJob(int id,long personId); + List> jobListDelayPro(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId); - Map countByJobStatus(long deptId,int spanDays); - Map countMyJob(long userId,long deptId,int spanDays); + List> jobListDelayProApp(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, Long deptId, Long userId, Long leaderId); + + List> jobListSearch(Page> page, JobListParam jobListParam, DataScope dataScope, Long userId); + + List> jobListSearchApp(Page> page, JobListParam jobListParam, Long deptId, Long userId, Long leaderId); + + List> jobInfo(Long id, DataScope dataScope, Long personId); + + boolean getJob(Long id, long personId); + + boolean confirmJob(Long id, long personId, String firstState, String firstStatePhotos, String needHandle); + + boolean transferJob(Long id, long transferPerson, String flowRec); + + boolean saveJob(Long id, String handleMessage, String handlePhotos); + + boolean overJob(Long id, long personId, String handleMessage, String handlePhotos); + + boolean overAlarm(int id); + + boolean handleJob(Long id, long personId); + + Map countByJobStatus(long deptId, int spanDays); + + Map countMyJob(long userId, long deptId, int spanDays); boolean checkJobStatus(String jobStatus); + boolean checkPcRole(List roleTips); - Integer countByDataScope(DataScope dataScope,String alarmType, String jobStatus,String beginTime,String endTime); - Integer countByResponse(String alarmType,String jobStatus,Long deptId,String beginTime,String endTime); - Integer countByUser(String alarmType,String jobStatus,Long userId,String beginTime,String endTime); + Integer countByDataScope(DataScope dataScope, String alarmType, String jobStatus, String beginTime, String endTime); - void updateSinkJob(String id,String msg,String wellCode); + Integer countByResponse(String alarmType, String jobStatus, Long deptId, String beginTime, String endTime); + + Integer countByUser(String alarmType, String jobStatus, Long userId, String beginTime, String endTime); + + void updateSinkJob(String id, String msg, String wellCode); + List selectUserByWellCode(String wellCode); + String selectClientIdByUser(Long userId); + + AlarmJob saveData( String devCode, String wellCode, String devTypeName, String jobType); + } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java index 46e7dfe..6eecb2b 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.service.IService; import com.casic.missiles.modular.system.model.AlarmRecords; import com.casic.missiles.core.datascope.DataScope; +import org.apache.ibatis.annotations.Param; import java.util.List; import java.util.Map; @@ -26,4 +27,8 @@ boolean cancelAlarmById(long id); Integer insertAlarmRecord(AlarmRecords alarmRec); + + Boolean isOldAlarmRecord(String devCode,String MsgContent); + + Integer updateOldAlarmRecord(String devCode,String MsgContent); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java index 46bb487..d27afa9 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java @@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.plugins.Page; import com.casic.missiles.core.base.response.ResponseData; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.alarm.service.IAlarmJobService; import com.casic.missiles.core.common.service.ICommonPermissionService; import com.casic.missiles.core.datascope.DataScope; @@ -12,12 +13,14 @@ import com.casic.missiles.modular.system.warpper.AlarmJobWarpper; import com.casic.missiles.core.base.controller.BaseController; import com.casic.missiles.core.common.constant.factory.PageFactory; +import lombok.extern.slf4j.Slf4j; import org.hswebframework.expands.office.excel.ExcelIO; import org.json.JSONException; import org.json.JSONObject; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; @@ -29,6 +32,7 @@ import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.*; //import com.casic.missiles.core.base.response.ResponseData; @@ -40,6 +44,7 @@ * @Date 2019-05-17 10:48:36 */ @Controller +@Slf4j @RequestMapping("/job") public class AlarmJobController extends BaseController { @@ -65,6 +70,13 @@ private String templatePath; + /** + * 工单状态接口统计 + * + * @param httpServletRequest + * @return + * @throws ParseException + */ @RequestMapping(value = "/countByJobStatus") @ResponseBody public Object countByJobStatus(HttpServletRequest httpServletRequest) throws ParseException { @@ -117,7 +129,7 @@ } /** - * 获取分页列表 + * 获取工单分页列表 */ @RequestMapping(value = "/list") @ResponseBody @@ -164,30 +176,26 @@ */ @RequestMapping(value = "/searchList") @ResponseBody - public Object jobListSearch(String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime, String endTime, - String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, - String handleJobBeginTime, String handleJobEndTime, String shouldHandleBeginTime, String shouldHandleEndTime) { + public Object jobListSearch(@RequestBody JobListParam jobListParam) { Page> page = new PageFactory>().defaultPage("createTime", false); DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List> retList = new ArrayList<>(); if (alarmJobService.checkPcRole(currentUser.getRoleTips())) { // pc角色 - retList = alarmJobService.jobListSearch(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, - handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, dataScope, currentUser.getId()); + retList = alarmJobService.jobListSearch(page, jobListParam, dataScope, currentUser.getId()); } else { //app角色 long leaderId = 0L; if (currentUser.getRoleTips().contains(sLeader)) { // 组长,查组内全部 leaderId = currentUser.getId(); - if (ToolUtil.isNotEmpty(jobStatus)) { + if (ToolUtil.isNotEmpty(jobListParam.getJobStatus())) { //learder&&jobStatus=1,2,3时,关闭传入的sort,按sql排序(自己的排在前) - page.setOpenSort(!alarmJobService.checkJobStatus(jobStatus)); + page.setOpenSort(!alarmJobService.checkJobStatus(jobListParam.getJobStatus())); } } - retList = alarmJobService.jobListSearchApp(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, - handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, currentUser.getDeptId(), currentUser.getId(), leaderId); + retList = alarmJobService.jobListSearchApp(page, jobListParam, currentUser.getDeptId(), currentUser.getId(), leaderId); } new AlarmJobWarpper(retList).warp(); @@ -277,26 +285,24 @@ @RequestMapping(value = "/export") public void exportJob(HttpServletRequest httpServletRequest , HttpServletResponse httpServletResponse) throws IOException { - Page> page = new PageFactory>().defaultPage("createTime", false); page.setLimit(maxRowsExcel); page.setSize(maxRowsExcel); page.setSearchCount(false); page.setOffset(0); - String keywords = httpServletRequest.getParameter("keywords"); String beginTime = httpServletRequest.getParameter("beginTime"); String endTime = httpServletRequest.getParameter("endTime"); String jobStatusStr = httpServletRequest.getParameter("jobStatus"); String alarmTypeStr = httpServletRequest.getParameter("alarmType"); String alarmContentStr = httpServletRequest.getParameter("alarmContentType"); - - List> jobExpList = new ArrayList<>(); + log.debug("主题参数---------------" + keywords + "," + beginTime + "," + endTime + "," + jobStatusStr + "," + alarmTypeStr + "," + alarmContentStr); DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - jobExpList = alarmJobService.jobList(page, keywords, beginTime, endTime, jobStatusStr, alarmTypeStr, alarmContentStr, dataScope, currentUser.getId()); + List> jobExpList = alarmJobService.jobList(page, keywords, beginTime, endTime, jobStatusStr, alarmTypeStr, alarmContentStr, dataScope, currentUser.getId()); new AlarmJobWarpper(jobExpList).warp(); FileInputStream fileInputStream = null; + log.debug("----------------" + ToolUtil.isEmpty(jobExpList)); if (ToolUtil.isEmpty(jobExpList)) { fileInputStream = new FileInputStream(templatePath + "/jobRecEmpty.xlsx"); } else { @@ -305,12 +311,10 @@ try { httpServletResponse.setContentType("application/octet-stream"); httpServletResponse.addHeader("Content-Disposition", " attachment;filename=" + "jobOverview.xlsx"); - Map var = new HashMap<>(); var.put("标题", "工单一览表"); var.put("list", jobExpList); ExcelIO.writeTemplate(fileInputStream, httpServletResponse.getOutputStream(), var); - } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { @@ -328,11 +332,11 @@ */ @RequestMapping(value = "/getJob") @ResponseBody - public Object getJob(int id) { + public Object getJob(Long id) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - if (alarmJobService.getJob(id, currentUser.getId())){ + if (alarmJobService.getJob(id, currentUser.getId())) { return ResponseData.success(); } else { return ResponseData.error("接单失败"); @@ -344,10 +348,10 @@ */ @RequestMapping(value = "/confirmJob") @ResponseBody - public Object confirmJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "firstState", required = true) String firstState, - @RequestParam(value = "firstStatePhotos", required = true) String firstStatePhotos, - @RequestParam(value = "needHandle", required = true) String needHandle) { + public Object confirmJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "firstState", required = true) String firstState, + @RequestParam(value = "firstStatePhotos", required = true) String firstStatePhotos, + @RequestParam(value = "needHandle", required = true) String needHandle) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.confirmJob(id, currentUser.getId(), firstState, firstStatePhotos, needHandle)) { return ResponseData.success(); @@ -361,17 +365,19 @@ */ @RequestMapping(value = "/transferJob") @ResponseBody - public Object transferJob(@RequestParam(value = "id", required = true) int id, + public Object transferJob(@RequestParam(value = "id", required = true) Long id, @RequestParam(value = "transferPerson", required = true) String transferPerson) throws JSONException { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - String dbTime = iSysDictService.getDBtime(); +// String dbTime = iSysDictService.getDBtime(); + SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); +// String dbTime = iSysDictService.getDBtime(); + Date dbTime = new Date(); JSONObject jsonObject = new JSONObject(); jsonObject.put("from", currentUser.getName()); jsonObject.put("to", EhcacheConstant.retBean().getUsernameById(Long.valueOf(transferPerson))); - jsonObject.put("time", dbTime); - + jsonObject.put("time", dateFormat.format(dbTime)); if (alarmJobService.transferJob(id, Long.valueOf(transferPerson), jsonObject.toString())) { return ResponseData.success(); } else { @@ -384,9 +390,9 @@ */ @RequestMapping(value = "/saveJob") @ResponseBody - public Object saveJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "handleMessage", required = true) String handleMessage, - @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { + public Object saveJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "handleMessage", required = true) String handleMessage, + @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { if (alarmJobService.saveJob(id, handleMessage, handlePhotos)) { return ResponseData.success(); @@ -400,10 +406,9 @@ */ @RequestMapping(value = "/overJob") @ResponseBody - public Object overJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "handleMessage", required = true) String handleMessage, - @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { - + public Object overJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "handleMessage", required = true) String handleMessage, + @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.overJob(id, currentUser.getId(), handleMessage, handlePhotos)) { @@ -419,7 +424,7 @@ */ @RequestMapping(value = "/handleJob") @ResponseBody - public Object handleJob(@RequestParam(value = "id", required = true) int id) { + public Object handleJob(@RequestParam(value = "id", required = true) Long id) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.handleJob(id, currentUser.getId())) { return ResponseData.success(); @@ -433,12 +438,10 @@ */ @RequestMapping(value = "/info") @ResponseBody - public Object jobInfo(@RequestParam(value = "id", required = true) int id) { - + public Object jobInfo(@RequestParam(value = "id", required = true) long id) { DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List> retList = alarmJobService.jobInfo(id, dataScope, currentUser.getId()); - new AlarmJobWarpper(retList).warp(); return ResponseData.success(retList); } @@ -456,7 +459,7 @@ @RequestParam(value = "wellCode", required = true) String wellCode) { Map retMap = new HashMap<>(); try { - alarmJobService.updateSinkJob(id, URLDecoder.decode(msg, "UTF-8"),wellCode); + alarmJobService.updateSinkJob(id, URLDecoder.decode(msg, "UTF-8"), wellCode); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java index 26a2ba7..df59231 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java @@ -52,6 +52,7 @@ @Autowired private IDeviceService deviceService; + @Value("${smartcity.office.maxRowsExcel}") private int maxRowsExcel; @Value("${smartcity.config.config-path}") @@ -182,7 +183,8 @@ @RequestMapping(value = "/cancelAlarmById") @ResponseBody public Object cancelAlarmById(@RequestParam(value = "alarmId",required = true) long alarmId){ - boolean isCancel = alarmRecordsService.cancelAlarmById(alarmId); + ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); + boolean isCancel = alarmRecordsService.cancelAlarm(alarmId,"4","手动消警",currentUser.getId()); if(isCancel){ return ResponseData.success(); }else { @@ -235,10 +237,10 @@ //根据查询条件查询alarm_record记录 DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); + ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List alarmRecords = alarmRecordsService.alarmListNoPage(dataScope, keywords, alarmType, alarmContent, beginTime, endTime, areaId); - for (AlarmRecords alarmRecord : alarmRecords) { - alarmRecordsService.cancelAlarmById(alarmRecord.getId()); + alarmRecordsService.cancelAlarm(alarmRecord.getJobId(),"4","手动消警",currentUser.getId()); } return ResponseData.success(); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/model/JobListParam.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/model/JobListParam.java new file mode 100644 index 0000000..c83bff8 --- /dev/null +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/model/JobListParam.java @@ -0,0 +1,32 @@ +package com.casic.missiles.modular.alarm.model; + + +import lombok.Data; + +/** + * @author cz + * @date 2022-6-13 17:03 + */ +@Data +public class JobListParam { + /** + * 关键字 + */ + private String keywords; + /** + * 风险等级 + */ + private String alarmLevel; + private String alarmContent; + private String jobStatus; + private String beginTime; + private String endTime; + private String getJobBeginTime; + private String getJobEndTime; + private String shouldGetBeginTime; + private String shouldGetEndTime; + private String handleJobBeginTime; + private String handleJobEndTime; + private String shouldHandleBeginTime; + private String shouldHandleEndTime; +} diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java index d4db8ce..018d095 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java @@ -3,6 +3,7 @@ import com.baomidou.mybatisplus.plugins.Page; import com.baomidou.mybatisplus.service.IService; import com.casic.missiles.core.datascope.DataScope; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.system.dto.UserClientView; import com.casic.missiles.modular.system.model.AlarmJob; @@ -18,42 +19,60 @@ * @since 2019-05-17 */ public interface IAlarmJobService extends IService { - List> jobList( Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType,String alarmContent, DataScope dataScope,Long userId); - List> jobListApp( Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType,String alarmContent,Long deptId,Long userId,Long leaderId); + + List> jobList(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, DataScope dataScope, Long userId); + + List> jobListApp(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, Long deptId, Long userId, Long leaderId); // List jobListExport( Page page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType,String alarmContent, DataScope dataScope); - List> jobListDelayRe( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, DataScope dataScope,Long userId); - List> jobListDelayReApp( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, Long deptId,Long userId,Long leaderId); + List> jobListDelayRe(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId); - List> jobListDelayPro( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, DataScope dataScope,Long userId ); - List> jobListDelayProApp( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, Long deptId,Long userId,Long leaderId); + List> jobListDelayReApp(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, Long deptId, Long userId, Long leaderId); - List> jobListSearch(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime,String endTime, - String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, - String shouldHandleBeginTime, String shouldHandleEndTime, DataScope dataScope,Long userId); - List> jobListSearchApp(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime,String endTime, - String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, - String shouldHandleBeginTime, String shouldHandleEndTime, Long deptId, Long userId, Long leaderId); - List> jobInfo(int id, DataScope dataScope,Long personId); - boolean getJob(int id, long personId); - boolean confirmJob(int id,long personId,String firstState, String firstStatePhotos, String needHandle); - boolean transferJob(int id, long transferPerson,String flowRec); - boolean saveJob( int id,String handleMessage, String handlePhotos); - boolean overJob( int id,long personId, String handleMessage, String handlePhotos); - boolean overAlarm( int id); - boolean handleJob(int id,long personId); + List> jobListDelayPro(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId); - Map countByJobStatus(long deptId,int spanDays); - Map countMyJob(long userId,long deptId,int spanDays); + List> jobListDelayProApp(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, Long deptId, Long userId, Long leaderId); + + List> jobListSearch(Page> page, JobListParam jobListParam, DataScope dataScope, Long userId); + + List> jobListSearchApp(Page> page, JobListParam jobListParam, Long deptId, Long userId, Long leaderId); + + List> jobInfo(Long id, DataScope dataScope, Long personId); + + boolean getJob(Long id, long personId); + + boolean confirmJob(Long id, long personId, String firstState, String firstStatePhotos, String needHandle); + + boolean transferJob(Long id, long transferPerson, String flowRec); + + boolean saveJob(Long id, String handleMessage, String handlePhotos); + + boolean overJob(Long id, long personId, String handleMessage, String handlePhotos); + + boolean overAlarm(int id); + + boolean handleJob(Long id, long personId); + + Map countByJobStatus(long deptId, int spanDays); + + Map countMyJob(long userId, long deptId, int spanDays); boolean checkJobStatus(String jobStatus); + boolean checkPcRole(List roleTips); - Integer countByDataScope(DataScope dataScope,String alarmType, String jobStatus,String beginTime,String endTime); - Integer countByResponse(String alarmType,String jobStatus,Long deptId,String beginTime,String endTime); - Integer countByUser(String alarmType,String jobStatus,Long userId,String beginTime,String endTime); + Integer countByDataScope(DataScope dataScope, String alarmType, String jobStatus, String beginTime, String endTime); - void updateSinkJob(String id,String msg,String wellCode); + Integer countByResponse(String alarmType, String jobStatus, Long deptId, String beginTime, String endTime); + + Integer countByUser(String alarmType, String jobStatus, Long userId, String beginTime, String endTime); + + void updateSinkJob(String id, String msg, String wellCode); + List selectUserByWellCode(String wellCode); + String selectClientIdByUser(Long userId); + + AlarmJob saveData( String devCode, String wellCode, String devTypeName, String jobType); + } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java index 46e7dfe..6eecb2b 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.service.IService; import com.casic.missiles.modular.system.model.AlarmRecords; import com.casic.missiles.core.datascope.DataScope; +import org.apache.ibatis.annotations.Param; import java.util.List; import java.util.Map; @@ -26,4 +27,8 @@ boolean cancelAlarmById(long id); Integer insertAlarmRecord(AlarmRecords alarmRec); + + Boolean isOldAlarmRecord(String devCode,String MsgContent); + + Integer updateOldAlarmRecord(String devCode,String MsgContent); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java index fa6681d..943ebd7 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java @@ -7,12 +7,14 @@ import com.casic.missiles.core.common.service.ICommonUserService; import com.casic.missiles.modular.alarm.job.HandleAlarmJob; import com.casic.missiles.modular.alarm.job.getDelayJob; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.alarm.service.IAlarmJobService; import com.casic.missiles.core.datascope.DataScope; import com.casic.missiles.core.util.EhcacheConstant; import com.casic.missiles.core.util.ToolUtil; import com.casic.missiles.modular.system.dao.AlarmJobMapper; import com.casic.missiles.modular.system.dao.AlarmRecordsMapper; +import com.casic.missiles.modular.system.dto.DeviceTypeEnum; import com.casic.missiles.modular.system.dto.SelectDto; import com.casic.missiles.modular.system.dto.UserClientView; import com.casic.missiles.modular.system.model.AlarmJob; @@ -24,6 +26,8 @@ import com.casic.missiles.quartz.service.IQuartzManager; import com.gexin.rp.sdk.base.IPushResult; import com.google.gson.GsonBuilder; +import net.sf.ehcache.search.Query; +import net.sf.ehcache.search.expression.Criteria; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -48,6 +52,8 @@ public class AlarmJobServiceImpl extends ServiceImpl implements IAlarmJobService { private static final Logger logger = LoggerFactory.getLogger(AlarmJobServiceImpl.class); + public static final SimpleDateFormat sdf6 = new SimpleDateFormat("yyyyMMdd"); + private static Map deviceAlarmMap = new HashMap(); @Value("${smartcity.leaderRoleName}") private String sLeader; @@ -70,12 +76,14 @@ @Resource private IQuartzManager quartzManager; - @Autowired IBusWellInfoService busWellInfoService; + @Autowired + IBusWellInfoService busWellInfoService; @Override - public List> jobList(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, DataScope dataScope,Long userId) { + public List> jobList(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, DataScope dataScope, Long userId) { alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobList(page, keywords, beginTime, endTime, jobStatus, alarmType, alarmContent, dataScope,userId);return alarmJobList; + List> alarmJobList = this.baseMapper.jobList(page, keywords, beginTime, endTime, jobStatus, alarmType, alarmContent, dataScope, userId); + return alarmJobList; } @Override @@ -86,9 +94,9 @@ } @Override - public List> jobListDelayRe(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope,Long userId) { + public List> jobListDelayRe(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId) { alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListDelayRe(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope,userId); + List> alarmJobList = this.baseMapper.jobListDelayRe(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope, userId); return alarmJobList; } @@ -100,9 +108,9 @@ } @Override - public List> jobListDelayPro(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope,Long userId) { + public List> jobListDelayPro(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId) { alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListDelayPro(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope,userId); + List> alarmJobList = this.baseMapper.jobListDelayPro(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope, userId); return alarmJobList; } @@ -114,109 +122,115 @@ } @Override - public List> jobListSearch(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime, String endTime, String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, String shouldHandleBeginTime, String shouldHandleEndTime, DataScope dataScope,Long userId) { - alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListSearch(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, dataScope,userId); + public List> jobListSearch(Page> page, JobListParam jobListParam, DataScope dataScope, Long userId) { + jobListParam.setAlarmContent(converAlarmContent(jobListParam.getAlarmContent())); + List> alarmJobList = this.baseMapper.jobListSearch(page, jobListParam, dataScope, userId); return alarmJobList; } @Override - public List> jobListSearchApp(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime, String endTime, String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, String shouldHandleBeginTime, String shouldHandleEndTime, Long deptId, Long userId, Long leaderId) { - alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListSearchApp(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, deptId, userId, leaderId); + public List> jobListSearchApp(Page> page, JobListParam jobListParam, Long deptId, Long userId, Long leaderId) { + jobListParam.setAlarmContent(converAlarmContent(jobListParam.getAlarmContent())); + List> alarmJobList = this.baseMapper.jobListSearchApp(page, jobListParam.getKeywords(), + jobListParam.getAlarmLevel(), jobListParam.getAlarmContent(), jobListParam.getJobStatus(), jobListParam.getBeginTime(), + jobListParam.getEndTime(), jobListParam.getGetJobBeginTime(), jobListParam.getGetJobEndTime(), jobListParam.getShouldGetBeginTime(), + jobListParam.getShouldGetEndTime(), jobListParam.getHandleJobBeginTime(), jobListParam.getHandleJobEndTime(), jobListParam.getShouldHandleBeginTime(), + jobListParam.getShouldHandleEndTime(), deptId, userId, leaderId); return alarmJobList; } - private String converAlarmContent(String alarmContent){ - if(ToolUtil.isEmpty(alarmContent)){ + private String converAlarmContent(String alarmContent) { + if (ToolUtil.isEmpty(alarmContent)) { return alarmContent; - }else { + } else { return EhcacheConstant.retBean().getAlarmContentName(Integer.valueOf(alarmContent)); } } @Override - public List> jobInfo(int id, DataScope dataScope, Long personId) - { - List> job = this.baseMapper.jobInfo(id,dataScope,personId); + public List> jobInfo(Long id, DataScope dataScope, Long personId) { + List> job = this.baseMapper.jobInfo(id, dataScope, personId); return job; } @Override - public Map countByJobStatus(long deptId,int spanDays) { - return this.baseMapper.countByJobStatus(deptId,spanDays); + public Map countByJobStatus(long deptId, int spanDays) { + return this.baseMapper.countByJobStatus(deptId, spanDays); } @Override - public Map countMyJob(long userId,long deptId,int spanDays) { - return this.baseMapper.countMyJob(userId,deptId,spanDays); + public Map countMyJob(long userId, long deptId, int spanDays) { + return this.baseMapper.countMyJob(userId, deptId, spanDays); } @Override - public boolean getJob(int id, long personId) { + public boolean getJob(Long id, long personId) { Calendar now = Calendar.getInstance(); Date getTime = now.getTime(); - if(isWeekend(now)){ + if (isWeekend(now)) { now.add(Calendar.WEEK_OF_YEAR, 1); - now.set(Calendar.DAY_OF_WEEK ,Calendar.TUESDAY); - now.set(Calendar.HOUR_OF_DAY,8); - now.set(Calendar.MINUTE,0); - now.set(Calendar.SECOND,0); - }else { + now.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY); + now.set(Calendar.HOUR_OF_DAY, 8); + now.set(Calendar.MINUTE, 0); + now.set(Calendar.SECOND, 0); + } else { now.add(Calendar.HOUR, 24); - while(isWeekend(now)){ + while (isWeekend(now)) { now.add(Calendar.HOUR, 24); } } Date shouldHandleTime = now.getTime(); - if(Boolean.getBoolean(useOverTime)){ + if (Boolean.getBoolean(useOverTime)) { System.out.println(shouldHandleTime); String jobName = "getJobDelay" + id; - Map map = new HashMap<>(); - map.put("jobId",id); - map.put("iAlarmJobService",this); - map.put("iCommonUserService",iCommonUserService); - map.put("iQuartzManager",quartzManager); - map.put("webSocket",webSocket); - quartzManager.addJob(jobName,getDelayJob.class,shouldHandleTime,map); + Map map = new HashMap<>(); + map.put("jobId", id); + map.put("iAlarmJobService", this); + map.put("iCommonUserService", iCommonUserService); + map.put("iQuartzManager", quartzManager); + map.put("webSocket", webSocket); + quartzManager.addJob(jobName, getDelayJob.class, shouldHandleTime, map); } - return this.baseMapper.getJob(id,personId,getTime,shouldHandleTime); + return this.baseMapper.getJob(id, personId, getTime, shouldHandleTime); } - private boolean isWeekend(Calendar cal){ - if(cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY){ + private boolean isWeekend(Calendar cal) { + if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) { return true; - } else{ + } else { return false; } } @Override - public boolean confirmJob(int id,long personId, String firstState, String firstStatePhotos, String needHandle) { - if ("1".equals(needHandle)){ - return this.baseMapper.confirmJob(id,personId, firstState, firstStatePhotos, needHandle); + public boolean confirmJob(Long id, long personId, String firstState, String firstStatePhotos, String needHandle) { + if ("1".equals(needHandle)) { + return this.baseMapper.confirmJob(id, personId, firstState, firstStatePhotos, needHandle); } else { - return this.baseMapper.confirmOverJobAndAlarm(id, personId,firstState, firstStatePhotos); + return this.baseMapper.confirmOverJobAndAlarm(id, personId, firstState, firstStatePhotos); } } @Override - public boolean transferJob(int id, long transferPerson,String flowRec) { - return this.baseMapper.transferJob(id, transferPerson,flowRec); + public boolean transferJob(Long id, long transferPerson, String flowRec) { + return this.baseMapper.transferJob(id, transferPerson, flowRec); } @Override - public boolean saveJob(int id, String handleMessage, String handlePhotos) { + public boolean saveJob(Long id, String handleMessage, String handlePhotos) { return this.baseMapper.saveJob(id, handleMessage, handlePhotos); } @Override - public boolean overJob(int id,long personId, String handleMessage, String handlePhotos) { - return this.baseMapper.overJobAndAlarm(id, personId,handleMessage, handlePhotos); + public boolean overJob(Long id, long personId, String handleMessage, String handlePhotos) { + + return this.baseMapper.overJobAndAlarm(id, personId, handleMessage, handlePhotos); + // return this.baseMapper.overJob(id, personId,handleMessage, handlePhotos); } + @Override public boolean overAlarm(int jobId) { return this.baseMapper.overAlarm(jobId); @@ -224,15 +238,15 @@ } @Override - public boolean handleJob(int id,long personId) { - return this.baseMapper.handleJob(id,personId); + public boolean handleJob(Long id, long personId) { + return this.baseMapper.handleJob(id, personId); } @Override public boolean checkJobStatus(String jobStatus) { - if(ToolUtil.isEmpty(jobStatus)){ + if (ToolUtil.isEmpty(jobStatus)) { return false; - }else{ + } else { return "1".equals(jobStatus) || "2".equals(jobStatus) || "3".equals(jobStatus); } } @@ -243,10 +257,10 @@ } - public List selectRoles() { return this.baseMapper.selectRoles(); } + public List selectUseIds(List roleIds) { return this.baseMapper.selectUseIds(roleIds); } @@ -255,50 +269,50 @@ public boolean checkPcRole(List roleTips) { List roleList = new ArrayList<>(roleTips); Iterator it = roleList.iterator(); - while (it.hasNext()){ + while (it.hasNext()) { String role = it.next(); - if(role.equals(sApp)||role.equals(sLeader)||role.equals(sMember)){ + if (role.equals(sApp) || role.equals(sLeader) || role.equals(sMember)) { it.remove(); } } - return roleList.size()>0; + return roleList.size() > 0; } @Override - public Integer countByDataScope(DataScope dataScope, String alarmType, String jobStatus, String beginTime,String endTime) { - List> res = this.baseMapper.countByDataScope(dataScope,alarmType,jobStatus,beginTime,endTime); + public Integer countByDataScope(DataScope dataScope, String alarmType, String jobStatus, String beginTime, String endTime) { + List> res = this.baseMapper.countByDataScope(dataScope, alarmType, jobStatus, beginTime, endTime); return res.size(); } @Override - public Integer countByResponse(String alarmType, String jobStatus, Long deptId, String beginTime,String endTime) { - return this.baseMapper.countByResponse(alarmType,jobStatus,deptId,beginTime,endTime); + public Integer countByResponse(String alarmType, String jobStatus, Long deptId, String beginTime, String endTime) { + return this.baseMapper.countByResponse(alarmType, jobStatus, deptId, beginTime, endTime); } @Override - public Integer countByUser(String alarmType, String jobStatus, Long userId, String beginTime,String endTime) { - return this.baseMapper.countByUser(alarmType,jobStatus,userId,beginTime,endTime); + public Integer countByUser(String alarmType, String jobStatus, Long userId, String beginTime, String endTime) { + return this.baseMapper.countByUser(alarmType, jobStatus, userId, beginTime, endTime); } @Override - public void updateSinkJob(String id, String msg,String wellCode) { + public void updateSinkJob(String id, String msg, String wellCode) { List userClientViewList = new ArrayList<>(); List selectDtoList = selectRoles(); EntityWrapper busWellInfoEntityWrapper = new EntityWrapper<>(); - busWellInfoEntityWrapper.eq("WELL_CODE",wellCode); + busWellInfoEntityWrapper.eq("WELL_CODE", wellCode); BusWellInfo busWellInfo = busWellInfoService.selectOne(busWellInfoEntityWrapper); - if(busWellInfo!=null&&ToolUtil.isNotEmpty(busWellInfo.getDeptid())){ - List roleids= new ArrayList<>(); - for(SelectDto selectDto:selectDtoList){ - if(ToolUtil.isNotEmpty(selectDto.getName()) - && Arrays.asList(selectDto.getName().split(",")).contains(busWellInfo.getDeptid())){ + if (busWellInfo != null && ToolUtil.isNotEmpty(busWellInfo.getDeptid())) { + List roleids = new ArrayList<>(); + for (SelectDto selectDto : selectDtoList) { + if (ToolUtil.isNotEmpty(selectDto.getName()) + && Arrays.asList(selectDto.getName().split(",")).contains(busWellInfo.getDeptid())) { roleids.add(selectDto.getId()); } } - if(roleids.size()>0){ + if (roleids.size() > 0) { List useIds = selectUseIds(roleids); - for(Long useId:useIds){ + for (Long useId : useIds) { UserClientView userClientView = new UserClientView(); userClientView.setClientid(useId.toString()); userClientView.setId(useId.toString()); @@ -307,11 +321,11 @@ } } - if(!("null".equals(id))){ + if (!("null".equals(id))) { AlarmJob alarmJob = this.baseMapper.selectById(id); sendJob(id, alarmJob, userClientViewList);//推送工单至app和pc端 } - if(StringUtils.isNotBlank(msg)){ + if (StringUtils.isNotBlank(msg)) { sendAlarm(msg, userClientViewList);//推送告警至app和pc端 } @@ -386,7 +400,7 @@ } Date shouldHandleTime = now.getTime(); - if(Boolean.getBoolean(useOverTime)) { + if (Boolean.getBoolean(useOverTime)) { System.out.println(shouldHandleTime); String jobName = "getJobDelay" + id; Map map = new HashMap<>(); @@ -437,4 +451,40 @@ public String selectClientIdByUser(Long userId) { return this.baseMapper.selectClientIdByUser(userId); } + + + public AlarmJob saveData(String devCode, String wellCode, String devTypeName, String jobType) { + AlarmJob alarmJob = new AlarmJob(); + alarmJob.setDevcode(devCode); + alarmJob.setWellCode(wellCode); + alarmJob.setJobStatus("0"); + alarmJob.setCreateTime(new Date()); + alarmJob.setJobcode(this.produceJobCode(devTypeName)); + alarmJob.setJobType(jobType); + this.baseMapper.insert(alarmJob); + return alarmJob; + } + + /** + * 前缀+日期+4位流水号 + * + * @param devTypeName + * @return + */ + private String produceJobCode(String devTypeName) { + String pre = devTypeName; + String dataStr = sdf6.format(new Date()); + String fix = this.getJobCodeMaxSerial(pre + dataStr); + return StringUtils.isNotBlank(fix) ? pre + dataStr + String.format("%04d", Long.valueOf(fix) + 1L) : pre + dataStr + "0001"; + } + + + private String getJobCodeMaxSerial(String jobcode) { + String MaxSerialJobCode = this.baseMapper.getJobCodeMaxSerial(jobcode); + String fix = ""; + if (null != MaxSerialJobCode && MaxSerialJobCode.length() > 4) { + fix = MaxSerialJobCode.substring(MaxSerialJobCode.length() - 4); + } + return fix; + } } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java index 46bb487..d27afa9 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java @@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.plugins.Page; import com.casic.missiles.core.base.response.ResponseData; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.alarm.service.IAlarmJobService; import com.casic.missiles.core.common.service.ICommonPermissionService; import com.casic.missiles.core.datascope.DataScope; @@ -12,12 +13,14 @@ import com.casic.missiles.modular.system.warpper.AlarmJobWarpper; import com.casic.missiles.core.base.controller.BaseController; import com.casic.missiles.core.common.constant.factory.PageFactory; +import lombok.extern.slf4j.Slf4j; import org.hswebframework.expands.office.excel.ExcelIO; import org.json.JSONException; import org.json.JSONObject; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; @@ -29,6 +32,7 @@ import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.*; //import com.casic.missiles.core.base.response.ResponseData; @@ -40,6 +44,7 @@ * @Date 2019-05-17 10:48:36 */ @Controller +@Slf4j @RequestMapping("/job") public class AlarmJobController extends BaseController { @@ -65,6 +70,13 @@ private String templatePath; + /** + * 工单状态接口统计 + * + * @param httpServletRequest + * @return + * @throws ParseException + */ @RequestMapping(value = "/countByJobStatus") @ResponseBody public Object countByJobStatus(HttpServletRequest httpServletRequest) throws ParseException { @@ -117,7 +129,7 @@ } /** - * 获取分页列表 + * 获取工单分页列表 */ @RequestMapping(value = "/list") @ResponseBody @@ -164,30 +176,26 @@ */ @RequestMapping(value = "/searchList") @ResponseBody - public Object jobListSearch(String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime, String endTime, - String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, - String handleJobBeginTime, String handleJobEndTime, String shouldHandleBeginTime, String shouldHandleEndTime) { + public Object jobListSearch(@RequestBody JobListParam jobListParam) { Page> page = new PageFactory>().defaultPage("createTime", false); DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List> retList = new ArrayList<>(); if (alarmJobService.checkPcRole(currentUser.getRoleTips())) { // pc角色 - retList = alarmJobService.jobListSearch(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, - handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, dataScope, currentUser.getId()); + retList = alarmJobService.jobListSearch(page, jobListParam, dataScope, currentUser.getId()); } else { //app角色 long leaderId = 0L; if (currentUser.getRoleTips().contains(sLeader)) { // 组长,查组内全部 leaderId = currentUser.getId(); - if (ToolUtil.isNotEmpty(jobStatus)) { + if (ToolUtil.isNotEmpty(jobListParam.getJobStatus())) { //learder&&jobStatus=1,2,3时,关闭传入的sort,按sql排序(自己的排在前) - page.setOpenSort(!alarmJobService.checkJobStatus(jobStatus)); + page.setOpenSort(!alarmJobService.checkJobStatus(jobListParam.getJobStatus())); } } - retList = alarmJobService.jobListSearchApp(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, - handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, currentUser.getDeptId(), currentUser.getId(), leaderId); + retList = alarmJobService.jobListSearchApp(page, jobListParam, currentUser.getDeptId(), currentUser.getId(), leaderId); } new AlarmJobWarpper(retList).warp(); @@ -277,26 +285,24 @@ @RequestMapping(value = "/export") public void exportJob(HttpServletRequest httpServletRequest , HttpServletResponse httpServletResponse) throws IOException { - Page> page = new PageFactory>().defaultPage("createTime", false); page.setLimit(maxRowsExcel); page.setSize(maxRowsExcel); page.setSearchCount(false); page.setOffset(0); - String keywords = httpServletRequest.getParameter("keywords"); String beginTime = httpServletRequest.getParameter("beginTime"); String endTime = httpServletRequest.getParameter("endTime"); String jobStatusStr = httpServletRequest.getParameter("jobStatus"); String alarmTypeStr = httpServletRequest.getParameter("alarmType"); String alarmContentStr = httpServletRequest.getParameter("alarmContentType"); - - List> jobExpList = new ArrayList<>(); + log.debug("主题参数---------------" + keywords + "," + beginTime + "," + endTime + "," + jobStatusStr + "," + alarmTypeStr + "," + alarmContentStr); DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - jobExpList = alarmJobService.jobList(page, keywords, beginTime, endTime, jobStatusStr, alarmTypeStr, alarmContentStr, dataScope, currentUser.getId()); + List> jobExpList = alarmJobService.jobList(page, keywords, beginTime, endTime, jobStatusStr, alarmTypeStr, alarmContentStr, dataScope, currentUser.getId()); new AlarmJobWarpper(jobExpList).warp(); FileInputStream fileInputStream = null; + log.debug("----------------" + ToolUtil.isEmpty(jobExpList)); if (ToolUtil.isEmpty(jobExpList)) { fileInputStream = new FileInputStream(templatePath + "/jobRecEmpty.xlsx"); } else { @@ -305,12 +311,10 @@ try { httpServletResponse.setContentType("application/octet-stream"); httpServletResponse.addHeader("Content-Disposition", " attachment;filename=" + "jobOverview.xlsx"); - Map var = new HashMap<>(); var.put("标题", "工单一览表"); var.put("list", jobExpList); ExcelIO.writeTemplate(fileInputStream, httpServletResponse.getOutputStream(), var); - } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { @@ -328,11 +332,11 @@ */ @RequestMapping(value = "/getJob") @ResponseBody - public Object getJob(int id) { + public Object getJob(Long id) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - if (alarmJobService.getJob(id, currentUser.getId())){ + if (alarmJobService.getJob(id, currentUser.getId())) { return ResponseData.success(); } else { return ResponseData.error("接单失败"); @@ -344,10 +348,10 @@ */ @RequestMapping(value = "/confirmJob") @ResponseBody - public Object confirmJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "firstState", required = true) String firstState, - @RequestParam(value = "firstStatePhotos", required = true) String firstStatePhotos, - @RequestParam(value = "needHandle", required = true) String needHandle) { + public Object confirmJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "firstState", required = true) String firstState, + @RequestParam(value = "firstStatePhotos", required = true) String firstStatePhotos, + @RequestParam(value = "needHandle", required = true) String needHandle) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.confirmJob(id, currentUser.getId(), firstState, firstStatePhotos, needHandle)) { return ResponseData.success(); @@ -361,17 +365,19 @@ */ @RequestMapping(value = "/transferJob") @ResponseBody - public Object transferJob(@RequestParam(value = "id", required = true) int id, + public Object transferJob(@RequestParam(value = "id", required = true) Long id, @RequestParam(value = "transferPerson", required = true) String transferPerson) throws JSONException { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - String dbTime = iSysDictService.getDBtime(); +// String dbTime = iSysDictService.getDBtime(); + SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); +// String dbTime = iSysDictService.getDBtime(); + Date dbTime = new Date(); JSONObject jsonObject = new JSONObject(); jsonObject.put("from", currentUser.getName()); jsonObject.put("to", EhcacheConstant.retBean().getUsernameById(Long.valueOf(transferPerson))); - jsonObject.put("time", dbTime); - + jsonObject.put("time", dateFormat.format(dbTime)); if (alarmJobService.transferJob(id, Long.valueOf(transferPerson), jsonObject.toString())) { return ResponseData.success(); } else { @@ -384,9 +390,9 @@ */ @RequestMapping(value = "/saveJob") @ResponseBody - public Object saveJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "handleMessage", required = true) String handleMessage, - @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { + public Object saveJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "handleMessage", required = true) String handleMessage, + @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { if (alarmJobService.saveJob(id, handleMessage, handlePhotos)) { return ResponseData.success(); @@ -400,10 +406,9 @@ */ @RequestMapping(value = "/overJob") @ResponseBody - public Object overJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "handleMessage", required = true) String handleMessage, - @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { - + public Object overJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "handleMessage", required = true) String handleMessage, + @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.overJob(id, currentUser.getId(), handleMessage, handlePhotos)) { @@ -419,7 +424,7 @@ */ @RequestMapping(value = "/handleJob") @ResponseBody - public Object handleJob(@RequestParam(value = "id", required = true) int id) { + public Object handleJob(@RequestParam(value = "id", required = true) Long id) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.handleJob(id, currentUser.getId())) { return ResponseData.success(); @@ -433,12 +438,10 @@ */ @RequestMapping(value = "/info") @ResponseBody - public Object jobInfo(@RequestParam(value = "id", required = true) int id) { - + public Object jobInfo(@RequestParam(value = "id", required = true) long id) { DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List> retList = alarmJobService.jobInfo(id, dataScope, currentUser.getId()); - new AlarmJobWarpper(retList).warp(); return ResponseData.success(retList); } @@ -456,7 +459,7 @@ @RequestParam(value = "wellCode", required = true) String wellCode) { Map retMap = new HashMap<>(); try { - alarmJobService.updateSinkJob(id, URLDecoder.decode(msg, "UTF-8"),wellCode); + alarmJobService.updateSinkJob(id, URLDecoder.decode(msg, "UTF-8"), wellCode); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java index 26a2ba7..df59231 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java @@ -52,6 +52,7 @@ @Autowired private IDeviceService deviceService; + @Value("${smartcity.office.maxRowsExcel}") private int maxRowsExcel; @Value("${smartcity.config.config-path}") @@ -182,7 +183,8 @@ @RequestMapping(value = "/cancelAlarmById") @ResponseBody public Object cancelAlarmById(@RequestParam(value = "alarmId",required = true) long alarmId){ - boolean isCancel = alarmRecordsService.cancelAlarmById(alarmId); + ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); + boolean isCancel = alarmRecordsService.cancelAlarm(alarmId,"4","手动消警",currentUser.getId()); if(isCancel){ return ResponseData.success(); }else { @@ -235,10 +237,10 @@ //根据查询条件查询alarm_record记录 DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); + ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List alarmRecords = alarmRecordsService.alarmListNoPage(dataScope, keywords, alarmType, alarmContent, beginTime, endTime, areaId); - for (AlarmRecords alarmRecord : alarmRecords) { - alarmRecordsService.cancelAlarmById(alarmRecord.getId()); + alarmRecordsService.cancelAlarm(alarmRecord.getJobId(),"4","手动消警",currentUser.getId()); } return ResponseData.success(); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/model/JobListParam.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/model/JobListParam.java new file mode 100644 index 0000000..c83bff8 --- /dev/null +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/model/JobListParam.java @@ -0,0 +1,32 @@ +package com.casic.missiles.modular.alarm.model; + + +import lombok.Data; + +/** + * @author cz + * @date 2022-6-13 17:03 + */ +@Data +public class JobListParam { + /** + * 关键字 + */ + private String keywords; + /** + * 风险等级 + */ + private String alarmLevel; + private String alarmContent; + private String jobStatus; + private String beginTime; + private String endTime; + private String getJobBeginTime; + private String getJobEndTime; + private String shouldGetBeginTime; + private String shouldGetEndTime; + private String handleJobBeginTime; + private String handleJobEndTime; + private String shouldHandleBeginTime; + private String shouldHandleEndTime; +} diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java index d4db8ce..018d095 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java @@ -3,6 +3,7 @@ import com.baomidou.mybatisplus.plugins.Page; import com.baomidou.mybatisplus.service.IService; import com.casic.missiles.core.datascope.DataScope; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.system.dto.UserClientView; import com.casic.missiles.modular.system.model.AlarmJob; @@ -18,42 +19,60 @@ * @since 2019-05-17 */ public interface IAlarmJobService extends IService { - List> jobList( Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType,String alarmContent, DataScope dataScope,Long userId); - List> jobListApp( Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType,String alarmContent,Long deptId,Long userId,Long leaderId); + + List> jobList(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, DataScope dataScope, Long userId); + + List> jobListApp(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, Long deptId, Long userId, Long leaderId); // List jobListExport( Page page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType,String alarmContent, DataScope dataScope); - List> jobListDelayRe( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, DataScope dataScope,Long userId); - List> jobListDelayReApp( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, Long deptId,Long userId,Long leaderId); + List> jobListDelayRe(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId); - List> jobListDelayPro( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, DataScope dataScope,Long userId ); - List> jobListDelayProApp( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, Long deptId,Long userId,Long leaderId); + List> jobListDelayReApp(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, Long deptId, Long userId, Long leaderId); - List> jobListSearch(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime,String endTime, - String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, - String shouldHandleBeginTime, String shouldHandleEndTime, DataScope dataScope,Long userId); - List> jobListSearchApp(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime,String endTime, - String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, - String shouldHandleBeginTime, String shouldHandleEndTime, Long deptId, Long userId, Long leaderId); - List> jobInfo(int id, DataScope dataScope,Long personId); - boolean getJob(int id, long personId); - boolean confirmJob(int id,long personId,String firstState, String firstStatePhotos, String needHandle); - boolean transferJob(int id, long transferPerson,String flowRec); - boolean saveJob( int id,String handleMessage, String handlePhotos); - boolean overJob( int id,long personId, String handleMessage, String handlePhotos); - boolean overAlarm( int id); - boolean handleJob(int id,long personId); + List> jobListDelayPro(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId); - Map countByJobStatus(long deptId,int spanDays); - Map countMyJob(long userId,long deptId,int spanDays); + List> jobListDelayProApp(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, Long deptId, Long userId, Long leaderId); + + List> jobListSearch(Page> page, JobListParam jobListParam, DataScope dataScope, Long userId); + + List> jobListSearchApp(Page> page, JobListParam jobListParam, Long deptId, Long userId, Long leaderId); + + List> jobInfo(Long id, DataScope dataScope, Long personId); + + boolean getJob(Long id, long personId); + + boolean confirmJob(Long id, long personId, String firstState, String firstStatePhotos, String needHandle); + + boolean transferJob(Long id, long transferPerson, String flowRec); + + boolean saveJob(Long id, String handleMessage, String handlePhotos); + + boolean overJob(Long id, long personId, String handleMessage, String handlePhotos); + + boolean overAlarm(int id); + + boolean handleJob(Long id, long personId); + + Map countByJobStatus(long deptId, int spanDays); + + Map countMyJob(long userId, long deptId, int spanDays); boolean checkJobStatus(String jobStatus); + boolean checkPcRole(List roleTips); - Integer countByDataScope(DataScope dataScope,String alarmType, String jobStatus,String beginTime,String endTime); - Integer countByResponse(String alarmType,String jobStatus,Long deptId,String beginTime,String endTime); - Integer countByUser(String alarmType,String jobStatus,Long userId,String beginTime,String endTime); + Integer countByDataScope(DataScope dataScope, String alarmType, String jobStatus, String beginTime, String endTime); - void updateSinkJob(String id,String msg,String wellCode); + Integer countByResponse(String alarmType, String jobStatus, Long deptId, String beginTime, String endTime); + + Integer countByUser(String alarmType, String jobStatus, Long userId, String beginTime, String endTime); + + void updateSinkJob(String id, String msg, String wellCode); + List selectUserByWellCode(String wellCode); + String selectClientIdByUser(Long userId); + + AlarmJob saveData( String devCode, String wellCode, String devTypeName, String jobType); + } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java index 46e7dfe..6eecb2b 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.service.IService; import com.casic.missiles.modular.system.model.AlarmRecords; import com.casic.missiles.core.datascope.DataScope; +import org.apache.ibatis.annotations.Param; import java.util.List; import java.util.Map; @@ -26,4 +27,8 @@ boolean cancelAlarmById(long id); Integer insertAlarmRecord(AlarmRecords alarmRec); + + Boolean isOldAlarmRecord(String devCode,String MsgContent); + + Integer updateOldAlarmRecord(String devCode,String MsgContent); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java index fa6681d..943ebd7 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java @@ -7,12 +7,14 @@ import com.casic.missiles.core.common.service.ICommonUserService; import com.casic.missiles.modular.alarm.job.HandleAlarmJob; import com.casic.missiles.modular.alarm.job.getDelayJob; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.alarm.service.IAlarmJobService; import com.casic.missiles.core.datascope.DataScope; import com.casic.missiles.core.util.EhcacheConstant; import com.casic.missiles.core.util.ToolUtil; import com.casic.missiles.modular.system.dao.AlarmJobMapper; import com.casic.missiles.modular.system.dao.AlarmRecordsMapper; +import com.casic.missiles.modular.system.dto.DeviceTypeEnum; import com.casic.missiles.modular.system.dto.SelectDto; import com.casic.missiles.modular.system.dto.UserClientView; import com.casic.missiles.modular.system.model.AlarmJob; @@ -24,6 +26,8 @@ import com.casic.missiles.quartz.service.IQuartzManager; import com.gexin.rp.sdk.base.IPushResult; import com.google.gson.GsonBuilder; +import net.sf.ehcache.search.Query; +import net.sf.ehcache.search.expression.Criteria; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -48,6 +52,8 @@ public class AlarmJobServiceImpl extends ServiceImpl implements IAlarmJobService { private static final Logger logger = LoggerFactory.getLogger(AlarmJobServiceImpl.class); + public static final SimpleDateFormat sdf6 = new SimpleDateFormat("yyyyMMdd"); + private static Map deviceAlarmMap = new HashMap(); @Value("${smartcity.leaderRoleName}") private String sLeader; @@ -70,12 +76,14 @@ @Resource private IQuartzManager quartzManager; - @Autowired IBusWellInfoService busWellInfoService; + @Autowired + IBusWellInfoService busWellInfoService; @Override - public List> jobList(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, DataScope dataScope,Long userId) { + public List> jobList(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, DataScope dataScope, Long userId) { alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobList(page, keywords, beginTime, endTime, jobStatus, alarmType, alarmContent, dataScope,userId);return alarmJobList; + List> alarmJobList = this.baseMapper.jobList(page, keywords, beginTime, endTime, jobStatus, alarmType, alarmContent, dataScope, userId); + return alarmJobList; } @Override @@ -86,9 +94,9 @@ } @Override - public List> jobListDelayRe(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope,Long userId) { + public List> jobListDelayRe(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId) { alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListDelayRe(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope,userId); + List> alarmJobList = this.baseMapper.jobListDelayRe(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope, userId); return alarmJobList; } @@ -100,9 +108,9 @@ } @Override - public List> jobListDelayPro(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope,Long userId) { + public List> jobListDelayPro(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId) { alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListDelayPro(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope,userId); + List> alarmJobList = this.baseMapper.jobListDelayPro(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope, userId); return alarmJobList; } @@ -114,109 +122,115 @@ } @Override - public List> jobListSearch(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime, String endTime, String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, String shouldHandleBeginTime, String shouldHandleEndTime, DataScope dataScope,Long userId) { - alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListSearch(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, dataScope,userId); + public List> jobListSearch(Page> page, JobListParam jobListParam, DataScope dataScope, Long userId) { + jobListParam.setAlarmContent(converAlarmContent(jobListParam.getAlarmContent())); + List> alarmJobList = this.baseMapper.jobListSearch(page, jobListParam, dataScope, userId); return alarmJobList; } @Override - public List> jobListSearchApp(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime, String endTime, String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, String shouldHandleBeginTime, String shouldHandleEndTime, Long deptId, Long userId, Long leaderId) { - alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListSearchApp(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, deptId, userId, leaderId); + public List> jobListSearchApp(Page> page, JobListParam jobListParam, Long deptId, Long userId, Long leaderId) { + jobListParam.setAlarmContent(converAlarmContent(jobListParam.getAlarmContent())); + List> alarmJobList = this.baseMapper.jobListSearchApp(page, jobListParam.getKeywords(), + jobListParam.getAlarmLevel(), jobListParam.getAlarmContent(), jobListParam.getJobStatus(), jobListParam.getBeginTime(), + jobListParam.getEndTime(), jobListParam.getGetJobBeginTime(), jobListParam.getGetJobEndTime(), jobListParam.getShouldGetBeginTime(), + jobListParam.getShouldGetEndTime(), jobListParam.getHandleJobBeginTime(), jobListParam.getHandleJobEndTime(), jobListParam.getShouldHandleBeginTime(), + jobListParam.getShouldHandleEndTime(), deptId, userId, leaderId); return alarmJobList; } - private String converAlarmContent(String alarmContent){ - if(ToolUtil.isEmpty(alarmContent)){ + private String converAlarmContent(String alarmContent) { + if (ToolUtil.isEmpty(alarmContent)) { return alarmContent; - }else { + } else { return EhcacheConstant.retBean().getAlarmContentName(Integer.valueOf(alarmContent)); } } @Override - public List> jobInfo(int id, DataScope dataScope, Long personId) - { - List> job = this.baseMapper.jobInfo(id,dataScope,personId); + public List> jobInfo(Long id, DataScope dataScope, Long personId) { + List> job = this.baseMapper.jobInfo(id, dataScope, personId); return job; } @Override - public Map countByJobStatus(long deptId,int spanDays) { - return this.baseMapper.countByJobStatus(deptId,spanDays); + public Map countByJobStatus(long deptId, int spanDays) { + return this.baseMapper.countByJobStatus(deptId, spanDays); } @Override - public Map countMyJob(long userId,long deptId,int spanDays) { - return this.baseMapper.countMyJob(userId,deptId,spanDays); + public Map countMyJob(long userId, long deptId, int spanDays) { + return this.baseMapper.countMyJob(userId, deptId, spanDays); } @Override - public boolean getJob(int id, long personId) { + public boolean getJob(Long id, long personId) { Calendar now = Calendar.getInstance(); Date getTime = now.getTime(); - if(isWeekend(now)){ + if (isWeekend(now)) { now.add(Calendar.WEEK_OF_YEAR, 1); - now.set(Calendar.DAY_OF_WEEK ,Calendar.TUESDAY); - now.set(Calendar.HOUR_OF_DAY,8); - now.set(Calendar.MINUTE,0); - now.set(Calendar.SECOND,0); - }else { + now.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY); + now.set(Calendar.HOUR_OF_DAY, 8); + now.set(Calendar.MINUTE, 0); + now.set(Calendar.SECOND, 0); + } else { now.add(Calendar.HOUR, 24); - while(isWeekend(now)){ + while (isWeekend(now)) { now.add(Calendar.HOUR, 24); } } Date shouldHandleTime = now.getTime(); - if(Boolean.getBoolean(useOverTime)){ + if (Boolean.getBoolean(useOverTime)) { System.out.println(shouldHandleTime); String jobName = "getJobDelay" + id; - Map map = new HashMap<>(); - map.put("jobId",id); - map.put("iAlarmJobService",this); - map.put("iCommonUserService",iCommonUserService); - map.put("iQuartzManager",quartzManager); - map.put("webSocket",webSocket); - quartzManager.addJob(jobName,getDelayJob.class,shouldHandleTime,map); + Map map = new HashMap<>(); + map.put("jobId", id); + map.put("iAlarmJobService", this); + map.put("iCommonUserService", iCommonUserService); + map.put("iQuartzManager", quartzManager); + map.put("webSocket", webSocket); + quartzManager.addJob(jobName, getDelayJob.class, shouldHandleTime, map); } - return this.baseMapper.getJob(id,personId,getTime,shouldHandleTime); + return this.baseMapper.getJob(id, personId, getTime, shouldHandleTime); } - private boolean isWeekend(Calendar cal){ - if(cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY){ + private boolean isWeekend(Calendar cal) { + if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) { return true; - } else{ + } else { return false; } } @Override - public boolean confirmJob(int id,long personId, String firstState, String firstStatePhotos, String needHandle) { - if ("1".equals(needHandle)){ - return this.baseMapper.confirmJob(id,personId, firstState, firstStatePhotos, needHandle); + public boolean confirmJob(Long id, long personId, String firstState, String firstStatePhotos, String needHandle) { + if ("1".equals(needHandle)) { + return this.baseMapper.confirmJob(id, personId, firstState, firstStatePhotos, needHandle); } else { - return this.baseMapper.confirmOverJobAndAlarm(id, personId,firstState, firstStatePhotos); + return this.baseMapper.confirmOverJobAndAlarm(id, personId, firstState, firstStatePhotos); } } @Override - public boolean transferJob(int id, long transferPerson,String flowRec) { - return this.baseMapper.transferJob(id, transferPerson,flowRec); + public boolean transferJob(Long id, long transferPerson, String flowRec) { + return this.baseMapper.transferJob(id, transferPerson, flowRec); } @Override - public boolean saveJob(int id, String handleMessage, String handlePhotos) { + public boolean saveJob(Long id, String handleMessage, String handlePhotos) { return this.baseMapper.saveJob(id, handleMessage, handlePhotos); } @Override - public boolean overJob(int id,long personId, String handleMessage, String handlePhotos) { - return this.baseMapper.overJobAndAlarm(id, personId,handleMessage, handlePhotos); + public boolean overJob(Long id, long personId, String handleMessage, String handlePhotos) { + + return this.baseMapper.overJobAndAlarm(id, personId, handleMessage, handlePhotos); + // return this.baseMapper.overJob(id, personId,handleMessage, handlePhotos); } + @Override public boolean overAlarm(int jobId) { return this.baseMapper.overAlarm(jobId); @@ -224,15 +238,15 @@ } @Override - public boolean handleJob(int id,long personId) { - return this.baseMapper.handleJob(id,personId); + public boolean handleJob(Long id, long personId) { + return this.baseMapper.handleJob(id, personId); } @Override public boolean checkJobStatus(String jobStatus) { - if(ToolUtil.isEmpty(jobStatus)){ + if (ToolUtil.isEmpty(jobStatus)) { return false; - }else{ + } else { return "1".equals(jobStatus) || "2".equals(jobStatus) || "3".equals(jobStatus); } } @@ -243,10 +257,10 @@ } - public List selectRoles() { return this.baseMapper.selectRoles(); } + public List selectUseIds(List roleIds) { return this.baseMapper.selectUseIds(roleIds); } @@ -255,50 +269,50 @@ public boolean checkPcRole(List roleTips) { List roleList = new ArrayList<>(roleTips); Iterator it = roleList.iterator(); - while (it.hasNext()){ + while (it.hasNext()) { String role = it.next(); - if(role.equals(sApp)||role.equals(sLeader)||role.equals(sMember)){ + if (role.equals(sApp) || role.equals(sLeader) || role.equals(sMember)) { it.remove(); } } - return roleList.size()>0; + return roleList.size() > 0; } @Override - public Integer countByDataScope(DataScope dataScope, String alarmType, String jobStatus, String beginTime,String endTime) { - List> res = this.baseMapper.countByDataScope(dataScope,alarmType,jobStatus,beginTime,endTime); + public Integer countByDataScope(DataScope dataScope, String alarmType, String jobStatus, String beginTime, String endTime) { + List> res = this.baseMapper.countByDataScope(dataScope, alarmType, jobStatus, beginTime, endTime); return res.size(); } @Override - public Integer countByResponse(String alarmType, String jobStatus, Long deptId, String beginTime,String endTime) { - return this.baseMapper.countByResponse(alarmType,jobStatus,deptId,beginTime,endTime); + public Integer countByResponse(String alarmType, String jobStatus, Long deptId, String beginTime, String endTime) { + return this.baseMapper.countByResponse(alarmType, jobStatus, deptId, beginTime, endTime); } @Override - public Integer countByUser(String alarmType, String jobStatus, Long userId, String beginTime,String endTime) { - return this.baseMapper.countByUser(alarmType,jobStatus,userId,beginTime,endTime); + public Integer countByUser(String alarmType, String jobStatus, Long userId, String beginTime, String endTime) { + return this.baseMapper.countByUser(alarmType, jobStatus, userId, beginTime, endTime); } @Override - public void updateSinkJob(String id, String msg,String wellCode) { + public void updateSinkJob(String id, String msg, String wellCode) { List userClientViewList = new ArrayList<>(); List selectDtoList = selectRoles(); EntityWrapper busWellInfoEntityWrapper = new EntityWrapper<>(); - busWellInfoEntityWrapper.eq("WELL_CODE",wellCode); + busWellInfoEntityWrapper.eq("WELL_CODE", wellCode); BusWellInfo busWellInfo = busWellInfoService.selectOne(busWellInfoEntityWrapper); - if(busWellInfo!=null&&ToolUtil.isNotEmpty(busWellInfo.getDeptid())){ - List roleids= new ArrayList<>(); - for(SelectDto selectDto:selectDtoList){ - if(ToolUtil.isNotEmpty(selectDto.getName()) - && Arrays.asList(selectDto.getName().split(",")).contains(busWellInfo.getDeptid())){ + if (busWellInfo != null && ToolUtil.isNotEmpty(busWellInfo.getDeptid())) { + List roleids = new ArrayList<>(); + for (SelectDto selectDto : selectDtoList) { + if (ToolUtil.isNotEmpty(selectDto.getName()) + && Arrays.asList(selectDto.getName().split(",")).contains(busWellInfo.getDeptid())) { roleids.add(selectDto.getId()); } } - if(roleids.size()>0){ + if (roleids.size() > 0) { List useIds = selectUseIds(roleids); - for(Long useId:useIds){ + for (Long useId : useIds) { UserClientView userClientView = new UserClientView(); userClientView.setClientid(useId.toString()); userClientView.setId(useId.toString()); @@ -307,11 +321,11 @@ } } - if(!("null".equals(id))){ + if (!("null".equals(id))) { AlarmJob alarmJob = this.baseMapper.selectById(id); sendJob(id, alarmJob, userClientViewList);//推送工单至app和pc端 } - if(StringUtils.isNotBlank(msg)){ + if (StringUtils.isNotBlank(msg)) { sendAlarm(msg, userClientViewList);//推送告警至app和pc端 } @@ -386,7 +400,7 @@ } Date shouldHandleTime = now.getTime(); - if(Boolean.getBoolean(useOverTime)) { + if (Boolean.getBoolean(useOverTime)) { System.out.println(shouldHandleTime); String jobName = "getJobDelay" + id; Map map = new HashMap<>(); @@ -437,4 +451,40 @@ public String selectClientIdByUser(Long userId) { return this.baseMapper.selectClientIdByUser(userId); } + + + public AlarmJob saveData(String devCode, String wellCode, String devTypeName, String jobType) { + AlarmJob alarmJob = new AlarmJob(); + alarmJob.setDevcode(devCode); + alarmJob.setWellCode(wellCode); + alarmJob.setJobStatus("0"); + alarmJob.setCreateTime(new Date()); + alarmJob.setJobcode(this.produceJobCode(devTypeName)); + alarmJob.setJobType(jobType); + this.baseMapper.insert(alarmJob); + return alarmJob; + } + + /** + * 前缀+日期+4位流水号 + * + * @param devTypeName + * @return + */ + private String produceJobCode(String devTypeName) { + String pre = devTypeName; + String dataStr = sdf6.format(new Date()); + String fix = this.getJobCodeMaxSerial(pre + dataStr); + return StringUtils.isNotBlank(fix) ? pre + dataStr + String.format("%04d", Long.valueOf(fix) + 1L) : pre + dataStr + "0001"; + } + + + private String getJobCodeMaxSerial(String jobcode) { + String MaxSerialJobCode = this.baseMapper.getJobCodeMaxSerial(jobcode); + String fix = ""; + if (null != MaxSerialJobCode && MaxSerialJobCode.length() > 4) { + fix = MaxSerialJobCode.substring(MaxSerialJobCode.length() - 4); + } + return fix; + } } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmRecordsServiceImpl.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmRecordsServiceImpl.java index e0f0959..60fa41a 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmRecordsServiceImpl.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmRecordsServiceImpl.java @@ -16,7 +16,7 @@ /** *

- * 服务实现类 + * 服务实现类 *

* * @author casic123 @@ -27,12 +27,12 @@ @Override - public List> alarmList(Page> page, String keywords, String beginTime, String endTime, String status, String alarmType, String alarmContent, String areaId, DataScope dataScope) { + public List> alarmList(Page> page, String keywords, String beginTime, String endTime, String status, String alarmType, String alarmContent, String areaId, DataScope dataScope) { String sContent = null; - if (ToolUtil.isNotEmpty(alarmContent)){ + if (ToolUtil.isNotEmpty(alarmContent)) { sContent = EhcacheConstant.retBean().getAlarmContentName(Integer.valueOf(alarmContent)); } - return this.baseMapper.alarmList(page,keywords,beginTime,endTime,status,alarmType,sContent, areaId, dataScope); + return this.baseMapper.alarmList(page, keywords, beginTime, endTime, status, alarmType, sContent, areaId, dataScope); } /** @@ -41,15 +41,15 @@ @Override public List alarmListNoPage(DataScope dataScope, String keywords, String alarmType, String alarmContent, String beginTime, String endTime, String areaId) { String sContent = null; - if (ToolUtil.isNotEmpty(alarmContent)){ + if (ToolUtil.isNotEmpty(alarmContent)) { sContent = EhcacheConstant.retBean().getAlarmContentName(Integer.valueOf(alarmContent)); } - return this.baseMapper.alarmListNoPage(dataScope,keywords,alarmType,sContent,beginTime,endTime, areaId); + return this.baseMapper.alarmListNoPage(dataScope, keywords, alarmType, sContent, beginTime, endTime, areaId); } @Override public boolean cancelAlarm(long id, String jobStatus, String handleMessage, long personId) { - return this.baseMapper.cancelAlarm(id,jobStatus,handleMessage,personId); + return this.baseMapper.cancelAlarm(id, jobStatus, handleMessage, personId); } @Override @@ -62,4 +62,15 @@ // this.baseMapper.cancelAlarmByNewRecord(alarmRec.getDevcode(), alarmRec.getAlarmType()); return this.baseMapper.insert(alarmRec); } + + public Boolean isOldAlarmRecord(String devCode, String MsgContent) { + if (this.baseMapper.isOldAlarmRecord(devCode, MsgContent) == null) { + return false; + } + return true; + } + + public Integer updateOldAlarmRecord(String devCode, String MsgContent) { + return this.baseMapper.updateOldAlarmRecord(devCode, MsgContent); + } } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java index 46bb487..d27afa9 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java @@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.plugins.Page; import com.casic.missiles.core.base.response.ResponseData; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.alarm.service.IAlarmJobService; import com.casic.missiles.core.common.service.ICommonPermissionService; import com.casic.missiles.core.datascope.DataScope; @@ -12,12 +13,14 @@ import com.casic.missiles.modular.system.warpper.AlarmJobWarpper; import com.casic.missiles.core.base.controller.BaseController; import com.casic.missiles.core.common.constant.factory.PageFactory; +import lombok.extern.slf4j.Slf4j; import org.hswebframework.expands.office.excel.ExcelIO; import org.json.JSONException; import org.json.JSONObject; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; @@ -29,6 +32,7 @@ import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.*; //import com.casic.missiles.core.base.response.ResponseData; @@ -40,6 +44,7 @@ * @Date 2019-05-17 10:48:36 */ @Controller +@Slf4j @RequestMapping("/job") public class AlarmJobController extends BaseController { @@ -65,6 +70,13 @@ private String templatePath; + /** + * 工单状态接口统计 + * + * @param httpServletRequest + * @return + * @throws ParseException + */ @RequestMapping(value = "/countByJobStatus") @ResponseBody public Object countByJobStatus(HttpServletRequest httpServletRequest) throws ParseException { @@ -117,7 +129,7 @@ } /** - * 获取分页列表 + * 获取工单分页列表 */ @RequestMapping(value = "/list") @ResponseBody @@ -164,30 +176,26 @@ */ @RequestMapping(value = "/searchList") @ResponseBody - public Object jobListSearch(String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime, String endTime, - String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, - String handleJobBeginTime, String handleJobEndTime, String shouldHandleBeginTime, String shouldHandleEndTime) { + public Object jobListSearch(@RequestBody JobListParam jobListParam) { Page> page = new PageFactory>().defaultPage("createTime", false); DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List> retList = new ArrayList<>(); if (alarmJobService.checkPcRole(currentUser.getRoleTips())) { // pc角色 - retList = alarmJobService.jobListSearch(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, - handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, dataScope, currentUser.getId()); + retList = alarmJobService.jobListSearch(page, jobListParam, dataScope, currentUser.getId()); } else { //app角色 long leaderId = 0L; if (currentUser.getRoleTips().contains(sLeader)) { // 组长,查组内全部 leaderId = currentUser.getId(); - if (ToolUtil.isNotEmpty(jobStatus)) { + if (ToolUtil.isNotEmpty(jobListParam.getJobStatus())) { //learder&&jobStatus=1,2,3时,关闭传入的sort,按sql排序(自己的排在前) - page.setOpenSort(!alarmJobService.checkJobStatus(jobStatus)); + page.setOpenSort(!alarmJobService.checkJobStatus(jobListParam.getJobStatus())); } } - retList = alarmJobService.jobListSearchApp(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, - handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, currentUser.getDeptId(), currentUser.getId(), leaderId); + retList = alarmJobService.jobListSearchApp(page, jobListParam, currentUser.getDeptId(), currentUser.getId(), leaderId); } new AlarmJobWarpper(retList).warp(); @@ -277,26 +285,24 @@ @RequestMapping(value = "/export") public void exportJob(HttpServletRequest httpServletRequest , HttpServletResponse httpServletResponse) throws IOException { - Page> page = new PageFactory>().defaultPage("createTime", false); page.setLimit(maxRowsExcel); page.setSize(maxRowsExcel); page.setSearchCount(false); page.setOffset(0); - String keywords = httpServletRequest.getParameter("keywords"); String beginTime = httpServletRequest.getParameter("beginTime"); String endTime = httpServletRequest.getParameter("endTime"); String jobStatusStr = httpServletRequest.getParameter("jobStatus"); String alarmTypeStr = httpServletRequest.getParameter("alarmType"); String alarmContentStr = httpServletRequest.getParameter("alarmContentType"); - - List> jobExpList = new ArrayList<>(); + log.debug("主题参数---------------" + keywords + "," + beginTime + "," + endTime + "," + jobStatusStr + "," + alarmTypeStr + "," + alarmContentStr); DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - jobExpList = alarmJobService.jobList(page, keywords, beginTime, endTime, jobStatusStr, alarmTypeStr, alarmContentStr, dataScope, currentUser.getId()); + List> jobExpList = alarmJobService.jobList(page, keywords, beginTime, endTime, jobStatusStr, alarmTypeStr, alarmContentStr, dataScope, currentUser.getId()); new AlarmJobWarpper(jobExpList).warp(); FileInputStream fileInputStream = null; + log.debug("----------------" + ToolUtil.isEmpty(jobExpList)); if (ToolUtil.isEmpty(jobExpList)) { fileInputStream = new FileInputStream(templatePath + "/jobRecEmpty.xlsx"); } else { @@ -305,12 +311,10 @@ try { httpServletResponse.setContentType("application/octet-stream"); httpServletResponse.addHeader("Content-Disposition", " attachment;filename=" + "jobOverview.xlsx"); - Map var = new HashMap<>(); var.put("标题", "工单一览表"); var.put("list", jobExpList); ExcelIO.writeTemplate(fileInputStream, httpServletResponse.getOutputStream(), var); - } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { @@ -328,11 +332,11 @@ */ @RequestMapping(value = "/getJob") @ResponseBody - public Object getJob(int id) { + public Object getJob(Long id) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - if (alarmJobService.getJob(id, currentUser.getId())){ + if (alarmJobService.getJob(id, currentUser.getId())) { return ResponseData.success(); } else { return ResponseData.error("接单失败"); @@ -344,10 +348,10 @@ */ @RequestMapping(value = "/confirmJob") @ResponseBody - public Object confirmJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "firstState", required = true) String firstState, - @RequestParam(value = "firstStatePhotos", required = true) String firstStatePhotos, - @RequestParam(value = "needHandle", required = true) String needHandle) { + public Object confirmJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "firstState", required = true) String firstState, + @RequestParam(value = "firstStatePhotos", required = true) String firstStatePhotos, + @RequestParam(value = "needHandle", required = true) String needHandle) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.confirmJob(id, currentUser.getId(), firstState, firstStatePhotos, needHandle)) { return ResponseData.success(); @@ -361,17 +365,19 @@ */ @RequestMapping(value = "/transferJob") @ResponseBody - public Object transferJob(@RequestParam(value = "id", required = true) int id, + public Object transferJob(@RequestParam(value = "id", required = true) Long id, @RequestParam(value = "transferPerson", required = true) String transferPerson) throws JSONException { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - String dbTime = iSysDictService.getDBtime(); +// String dbTime = iSysDictService.getDBtime(); + SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); +// String dbTime = iSysDictService.getDBtime(); + Date dbTime = new Date(); JSONObject jsonObject = new JSONObject(); jsonObject.put("from", currentUser.getName()); jsonObject.put("to", EhcacheConstant.retBean().getUsernameById(Long.valueOf(transferPerson))); - jsonObject.put("time", dbTime); - + jsonObject.put("time", dateFormat.format(dbTime)); if (alarmJobService.transferJob(id, Long.valueOf(transferPerson), jsonObject.toString())) { return ResponseData.success(); } else { @@ -384,9 +390,9 @@ */ @RequestMapping(value = "/saveJob") @ResponseBody - public Object saveJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "handleMessage", required = true) String handleMessage, - @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { + public Object saveJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "handleMessage", required = true) String handleMessage, + @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { if (alarmJobService.saveJob(id, handleMessage, handlePhotos)) { return ResponseData.success(); @@ -400,10 +406,9 @@ */ @RequestMapping(value = "/overJob") @ResponseBody - public Object overJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "handleMessage", required = true) String handleMessage, - @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { - + public Object overJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "handleMessage", required = true) String handleMessage, + @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.overJob(id, currentUser.getId(), handleMessage, handlePhotos)) { @@ -419,7 +424,7 @@ */ @RequestMapping(value = "/handleJob") @ResponseBody - public Object handleJob(@RequestParam(value = "id", required = true) int id) { + public Object handleJob(@RequestParam(value = "id", required = true) Long id) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.handleJob(id, currentUser.getId())) { return ResponseData.success(); @@ -433,12 +438,10 @@ */ @RequestMapping(value = "/info") @ResponseBody - public Object jobInfo(@RequestParam(value = "id", required = true) int id) { - + public Object jobInfo(@RequestParam(value = "id", required = true) long id) { DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List> retList = alarmJobService.jobInfo(id, dataScope, currentUser.getId()); - new AlarmJobWarpper(retList).warp(); return ResponseData.success(retList); } @@ -456,7 +459,7 @@ @RequestParam(value = "wellCode", required = true) String wellCode) { Map retMap = new HashMap<>(); try { - alarmJobService.updateSinkJob(id, URLDecoder.decode(msg, "UTF-8"),wellCode); + alarmJobService.updateSinkJob(id, URLDecoder.decode(msg, "UTF-8"), wellCode); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java index 26a2ba7..df59231 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java @@ -52,6 +52,7 @@ @Autowired private IDeviceService deviceService; + @Value("${smartcity.office.maxRowsExcel}") private int maxRowsExcel; @Value("${smartcity.config.config-path}") @@ -182,7 +183,8 @@ @RequestMapping(value = "/cancelAlarmById") @ResponseBody public Object cancelAlarmById(@RequestParam(value = "alarmId",required = true) long alarmId){ - boolean isCancel = alarmRecordsService.cancelAlarmById(alarmId); + ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); + boolean isCancel = alarmRecordsService.cancelAlarm(alarmId,"4","手动消警",currentUser.getId()); if(isCancel){ return ResponseData.success(); }else { @@ -235,10 +237,10 @@ //根据查询条件查询alarm_record记录 DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); + ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List alarmRecords = alarmRecordsService.alarmListNoPage(dataScope, keywords, alarmType, alarmContent, beginTime, endTime, areaId); - for (AlarmRecords alarmRecord : alarmRecords) { - alarmRecordsService.cancelAlarmById(alarmRecord.getId()); + alarmRecordsService.cancelAlarm(alarmRecord.getJobId(),"4","手动消警",currentUser.getId()); } return ResponseData.success(); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/model/JobListParam.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/model/JobListParam.java new file mode 100644 index 0000000..c83bff8 --- /dev/null +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/model/JobListParam.java @@ -0,0 +1,32 @@ +package com.casic.missiles.modular.alarm.model; + + +import lombok.Data; + +/** + * @author cz + * @date 2022-6-13 17:03 + */ +@Data +public class JobListParam { + /** + * 关键字 + */ + private String keywords; + /** + * 风险等级 + */ + private String alarmLevel; + private String alarmContent; + private String jobStatus; + private String beginTime; + private String endTime; + private String getJobBeginTime; + private String getJobEndTime; + private String shouldGetBeginTime; + private String shouldGetEndTime; + private String handleJobBeginTime; + private String handleJobEndTime; + private String shouldHandleBeginTime; + private String shouldHandleEndTime; +} diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java index d4db8ce..018d095 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java @@ -3,6 +3,7 @@ import com.baomidou.mybatisplus.plugins.Page; import com.baomidou.mybatisplus.service.IService; import com.casic.missiles.core.datascope.DataScope; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.system.dto.UserClientView; import com.casic.missiles.modular.system.model.AlarmJob; @@ -18,42 +19,60 @@ * @since 2019-05-17 */ public interface IAlarmJobService extends IService { - List> jobList( Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType,String alarmContent, DataScope dataScope,Long userId); - List> jobListApp( Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType,String alarmContent,Long deptId,Long userId,Long leaderId); + + List> jobList(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, DataScope dataScope, Long userId); + + List> jobListApp(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, Long deptId, Long userId, Long leaderId); // List jobListExport( Page page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType,String alarmContent, DataScope dataScope); - List> jobListDelayRe( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, DataScope dataScope,Long userId); - List> jobListDelayReApp( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, Long deptId,Long userId,Long leaderId); + List> jobListDelayRe(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId); - List> jobListDelayPro( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, DataScope dataScope,Long userId ); - List> jobListDelayProApp( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, Long deptId,Long userId,Long leaderId); + List> jobListDelayReApp(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, Long deptId, Long userId, Long leaderId); - List> jobListSearch(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime,String endTime, - String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, - String shouldHandleBeginTime, String shouldHandleEndTime, DataScope dataScope,Long userId); - List> jobListSearchApp(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime,String endTime, - String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, - String shouldHandleBeginTime, String shouldHandleEndTime, Long deptId, Long userId, Long leaderId); - List> jobInfo(int id, DataScope dataScope,Long personId); - boolean getJob(int id, long personId); - boolean confirmJob(int id,long personId,String firstState, String firstStatePhotos, String needHandle); - boolean transferJob(int id, long transferPerson,String flowRec); - boolean saveJob( int id,String handleMessage, String handlePhotos); - boolean overJob( int id,long personId, String handleMessage, String handlePhotos); - boolean overAlarm( int id); - boolean handleJob(int id,long personId); + List> jobListDelayPro(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId); - Map countByJobStatus(long deptId,int spanDays); - Map countMyJob(long userId,long deptId,int spanDays); + List> jobListDelayProApp(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, Long deptId, Long userId, Long leaderId); + + List> jobListSearch(Page> page, JobListParam jobListParam, DataScope dataScope, Long userId); + + List> jobListSearchApp(Page> page, JobListParam jobListParam, Long deptId, Long userId, Long leaderId); + + List> jobInfo(Long id, DataScope dataScope, Long personId); + + boolean getJob(Long id, long personId); + + boolean confirmJob(Long id, long personId, String firstState, String firstStatePhotos, String needHandle); + + boolean transferJob(Long id, long transferPerson, String flowRec); + + boolean saveJob(Long id, String handleMessage, String handlePhotos); + + boolean overJob(Long id, long personId, String handleMessage, String handlePhotos); + + boolean overAlarm(int id); + + boolean handleJob(Long id, long personId); + + Map countByJobStatus(long deptId, int spanDays); + + Map countMyJob(long userId, long deptId, int spanDays); boolean checkJobStatus(String jobStatus); + boolean checkPcRole(List roleTips); - Integer countByDataScope(DataScope dataScope,String alarmType, String jobStatus,String beginTime,String endTime); - Integer countByResponse(String alarmType,String jobStatus,Long deptId,String beginTime,String endTime); - Integer countByUser(String alarmType,String jobStatus,Long userId,String beginTime,String endTime); + Integer countByDataScope(DataScope dataScope, String alarmType, String jobStatus, String beginTime, String endTime); - void updateSinkJob(String id,String msg,String wellCode); + Integer countByResponse(String alarmType, String jobStatus, Long deptId, String beginTime, String endTime); + + Integer countByUser(String alarmType, String jobStatus, Long userId, String beginTime, String endTime); + + void updateSinkJob(String id, String msg, String wellCode); + List selectUserByWellCode(String wellCode); + String selectClientIdByUser(Long userId); + + AlarmJob saveData( String devCode, String wellCode, String devTypeName, String jobType); + } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java index 46e7dfe..6eecb2b 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.service.IService; import com.casic.missiles.modular.system.model.AlarmRecords; import com.casic.missiles.core.datascope.DataScope; +import org.apache.ibatis.annotations.Param; import java.util.List; import java.util.Map; @@ -26,4 +27,8 @@ boolean cancelAlarmById(long id); Integer insertAlarmRecord(AlarmRecords alarmRec); + + Boolean isOldAlarmRecord(String devCode,String MsgContent); + + Integer updateOldAlarmRecord(String devCode,String MsgContent); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java index fa6681d..943ebd7 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java @@ -7,12 +7,14 @@ import com.casic.missiles.core.common.service.ICommonUserService; import com.casic.missiles.modular.alarm.job.HandleAlarmJob; import com.casic.missiles.modular.alarm.job.getDelayJob; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.alarm.service.IAlarmJobService; import com.casic.missiles.core.datascope.DataScope; import com.casic.missiles.core.util.EhcacheConstant; import com.casic.missiles.core.util.ToolUtil; import com.casic.missiles.modular.system.dao.AlarmJobMapper; import com.casic.missiles.modular.system.dao.AlarmRecordsMapper; +import com.casic.missiles.modular.system.dto.DeviceTypeEnum; import com.casic.missiles.modular.system.dto.SelectDto; import com.casic.missiles.modular.system.dto.UserClientView; import com.casic.missiles.modular.system.model.AlarmJob; @@ -24,6 +26,8 @@ import com.casic.missiles.quartz.service.IQuartzManager; import com.gexin.rp.sdk.base.IPushResult; import com.google.gson.GsonBuilder; +import net.sf.ehcache.search.Query; +import net.sf.ehcache.search.expression.Criteria; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -48,6 +52,8 @@ public class AlarmJobServiceImpl extends ServiceImpl implements IAlarmJobService { private static final Logger logger = LoggerFactory.getLogger(AlarmJobServiceImpl.class); + public static final SimpleDateFormat sdf6 = new SimpleDateFormat("yyyyMMdd"); + private static Map deviceAlarmMap = new HashMap(); @Value("${smartcity.leaderRoleName}") private String sLeader; @@ -70,12 +76,14 @@ @Resource private IQuartzManager quartzManager; - @Autowired IBusWellInfoService busWellInfoService; + @Autowired + IBusWellInfoService busWellInfoService; @Override - public List> jobList(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, DataScope dataScope,Long userId) { + public List> jobList(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, DataScope dataScope, Long userId) { alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobList(page, keywords, beginTime, endTime, jobStatus, alarmType, alarmContent, dataScope,userId);return alarmJobList; + List> alarmJobList = this.baseMapper.jobList(page, keywords, beginTime, endTime, jobStatus, alarmType, alarmContent, dataScope, userId); + return alarmJobList; } @Override @@ -86,9 +94,9 @@ } @Override - public List> jobListDelayRe(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope,Long userId) { + public List> jobListDelayRe(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId) { alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListDelayRe(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope,userId); + List> alarmJobList = this.baseMapper.jobListDelayRe(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope, userId); return alarmJobList; } @@ -100,9 +108,9 @@ } @Override - public List> jobListDelayPro(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope,Long userId) { + public List> jobListDelayPro(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId) { alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListDelayPro(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope,userId); + List> alarmJobList = this.baseMapper.jobListDelayPro(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope, userId); return alarmJobList; } @@ -114,109 +122,115 @@ } @Override - public List> jobListSearch(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime, String endTime, String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, String shouldHandleBeginTime, String shouldHandleEndTime, DataScope dataScope,Long userId) { - alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListSearch(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, dataScope,userId); + public List> jobListSearch(Page> page, JobListParam jobListParam, DataScope dataScope, Long userId) { + jobListParam.setAlarmContent(converAlarmContent(jobListParam.getAlarmContent())); + List> alarmJobList = this.baseMapper.jobListSearch(page, jobListParam, dataScope, userId); return alarmJobList; } @Override - public List> jobListSearchApp(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime, String endTime, String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, String shouldHandleBeginTime, String shouldHandleEndTime, Long deptId, Long userId, Long leaderId) { - alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListSearchApp(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, deptId, userId, leaderId); + public List> jobListSearchApp(Page> page, JobListParam jobListParam, Long deptId, Long userId, Long leaderId) { + jobListParam.setAlarmContent(converAlarmContent(jobListParam.getAlarmContent())); + List> alarmJobList = this.baseMapper.jobListSearchApp(page, jobListParam.getKeywords(), + jobListParam.getAlarmLevel(), jobListParam.getAlarmContent(), jobListParam.getJobStatus(), jobListParam.getBeginTime(), + jobListParam.getEndTime(), jobListParam.getGetJobBeginTime(), jobListParam.getGetJobEndTime(), jobListParam.getShouldGetBeginTime(), + jobListParam.getShouldGetEndTime(), jobListParam.getHandleJobBeginTime(), jobListParam.getHandleJobEndTime(), jobListParam.getShouldHandleBeginTime(), + jobListParam.getShouldHandleEndTime(), deptId, userId, leaderId); return alarmJobList; } - private String converAlarmContent(String alarmContent){ - if(ToolUtil.isEmpty(alarmContent)){ + private String converAlarmContent(String alarmContent) { + if (ToolUtil.isEmpty(alarmContent)) { return alarmContent; - }else { + } else { return EhcacheConstant.retBean().getAlarmContentName(Integer.valueOf(alarmContent)); } } @Override - public List> jobInfo(int id, DataScope dataScope, Long personId) - { - List> job = this.baseMapper.jobInfo(id,dataScope,personId); + public List> jobInfo(Long id, DataScope dataScope, Long personId) { + List> job = this.baseMapper.jobInfo(id, dataScope, personId); return job; } @Override - public Map countByJobStatus(long deptId,int spanDays) { - return this.baseMapper.countByJobStatus(deptId,spanDays); + public Map countByJobStatus(long deptId, int spanDays) { + return this.baseMapper.countByJobStatus(deptId, spanDays); } @Override - public Map countMyJob(long userId,long deptId,int spanDays) { - return this.baseMapper.countMyJob(userId,deptId,spanDays); + public Map countMyJob(long userId, long deptId, int spanDays) { + return this.baseMapper.countMyJob(userId, deptId, spanDays); } @Override - public boolean getJob(int id, long personId) { + public boolean getJob(Long id, long personId) { Calendar now = Calendar.getInstance(); Date getTime = now.getTime(); - if(isWeekend(now)){ + if (isWeekend(now)) { now.add(Calendar.WEEK_OF_YEAR, 1); - now.set(Calendar.DAY_OF_WEEK ,Calendar.TUESDAY); - now.set(Calendar.HOUR_OF_DAY,8); - now.set(Calendar.MINUTE,0); - now.set(Calendar.SECOND,0); - }else { + now.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY); + now.set(Calendar.HOUR_OF_DAY, 8); + now.set(Calendar.MINUTE, 0); + now.set(Calendar.SECOND, 0); + } else { now.add(Calendar.HOUR, 24); - while(isWeekend(now)){ + while (isWeekend(now)) { now.add(Calendar.HOUR, 24); } } Date shouldHandleTime = now.getTime(); - if(Boolean.getBoolean(useOverTime)){ + if (Boolean.getBoolean(useOverTime)) { System.out.println(shouldHandleTime); String jobName = "getJobDelay" + id; - Map map = new HashMap<>(); - map.put("jobId",id); - map.put("iAlarmJobService",this); - map.put("iCommonUserService",iCommonUserService); - map.put("iQuartzManager",quartzManager); - map.put("webSocket",webSocket); - quartzManager.addJob(jobName,getDelayJob.class,shouldHandleTime,map); + Map map = new HashMap<>(); + map.put("jobId", id); + map.put("iAlarmJobService", this); + map.put("iCommonUserService", iCommonUserService); + map.put("iQuartzManager", quartzManager); + map.put("webSocket", webSocket); + quartzManager.addJob(jobName, getDelayJob.class, shouldHandleTime, map); } - return this.baseMapper.getJob(id,personId,getTime,shouldHandleTime); + return this.baseMapper.getJob(id, personId, getTime, shouldHandleTime); } - private boolean isWeekend(Calendar cal){ - if(cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY){ + private boolean isWeekend(Calendar cal) { + if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) { return true; - } else{ + } else { return false; } } @Override - public boolean confirmJob(int id,long personId, String firstState, String firstStatePhotos, String needHandle) { - if ("1".equals(needHandle)){ - return this.baseMapper.confirmJob(id,personId, firstState, firstStatePhotos, needHandle); + public boolean confirmJob(Long id, long personId, String firstState, String firstStatePhotos, String needHandle) { + if ("1".equals(needHandle)) { + return this.baseMapper.confirmJob(id, personId, firstState, firstStatePhotos, needHandle); } else { - return this.baseMapper.confirmOverJobAndAlarm(id, personId,firstState, firstStatePhotos); + return this.baseMapper.confirmOverJobAndAlarm(id, personId, firstState, firstStatePhotos); } } @Override - public boolean transferJob(int id, long transferPerson,String flowRec) { - return this.baseMapper.transferJob(id, transferPerson,flowRec); + public boolean transferJob(Long id, long transferPerson, String flowRec) { + return this.baseMapper.transferJob(id, transferPerson, flowRec); } @Override - public boolean saveJob(int id, String handleMessage, String handlePhotos) { + public boolean saveJob(Long id, String handleMessage, String handlePhotos) { return this.baseMapper.saveJob(id, handleMessage, handlePhotos); } @Override - public boolean overJob(int id,long personId, String handleMessage, String handlePhotos) { - return this.baseMapper.overJobAndAlarm(id, personId,handleMessage, handlePhotos); + public boolean overJob(Long id, long personId, String handleMessage, String handlePhotos) { + + return this.baseMapper.overJobAndAlarm(id, personId, handleMessage, handlePhotos); + // return this.baseMapper.overJob(id, personId,handleMessage, handlePhotos); } + @Override public boolean overAlarm(int jobId) { return this.baseMapper.overAlarm(jobId); @@ -224,15 +238,15 @@ } @Override - public boolean handleJob(int id,long personId) { - return this.baseMapper.handleJob(id,personId); + public boolean handleJob(Long id, long personId) { + return this.baseMapper.handleJob(id, personId); } @Override public boolean checkJobStatus(String jobStatus) { - if(ToolUtil.isEmpty(jobStatus)){ + if (ToolUtil.isEmpty(jobStatus)) { return false; - }else{ + } else { return "1".equals(jobStatus) || "2".equals(jobStatus) || "3".equals(jobStatus); } } @@ -243,10 +257,10 @@ } - public List selectRoles() { return this.baseMapper.selectRoles(); } + public List selectUseIds(List roleIds) { return this.baseMapper.selectUseIds(roleIds); } @@ -255,50 +269,50 @@ public boolean checkPcRole(List roleTips) { List roleList = new ArrayList<>(roleTips); Iterator it = roleList.iterator(); - while (it.hasNext()){ + while (it.hasNext()) { String role = it.next(); - if(role.equals(sApp)||role.equals(sLeader)||role.equals(sMember)){ + if (role.equals(sApp) || role.equals(sLeader) || role.equals(sMember)) { it.remove(); } } - return roleList.size()>0; + return roleList.size() > 0; } @Override - public Integer countByDataScope(DataScope dataScope, String alarmType, String jobStatus, String beginTime,String endTime) { - List> res = this.baseMapper.countByDataScope(dataScope,alarmType,jobStatus,beginTime,endTime); + public Integer countByDataScope(DataScope dataScope, String alarmType, String jobStatus, String beginTime, String endTime) { + List> res = this.baseMapper.countByDataScope(dataScope, alarmType, jobStatus, beginTime, endTime); return res.size(); } @Override - public Integer countByResponse(String alarmType, String jobStatus, Long deptId, String beginTime,String endTime) { - return this.baseMapper.countByResponse(alarmType,jobStatus,deptId,beginTime,endTime); + public Integer countByResponse(String alarmType, String jobStatus, Long deptId, String beginTime, String endTime) { + return this.baseMapper.countByResponse(alarmType, jobStatus, deptId, beginTime, endTime); } @Override - public Integer countByUser(String alarmType, String jobStatus, Long userId, String beginTime,String endTime) { - return this.baseMapper.countByUser(alarmType,jobStatus,userId,beginTime,endTime); + public Integer countByUser(String alarmType, String jobStatus, Long userId, String beginTime, String endTime) { + return this.baseMapper.countByUser(alarmType, jobStatus, userId, beginTime, endTime); } @Override - public void updateSinkJob(String id, String msg,String wellCode) { + public void updateSinkJob(String id, String msg, String wellCode) { List userClientViewList = new ArrayList<>(); List selectDtoList = selectRoles(); EntityWrapper busWellInfoEntityWrapper = new EntityWrapper<>(); - busWellInfoEntityWrapper.eq("WELL_CODE",wellCode); + busWellInfoEntityWrapper.eq("WELL_CODE", wellCode); BusWellInfo busWellInfo = busWellInfoService.selectOne(busWellInfoEntityWrapper); - if(busWellInfo!=null&&ToolUtil.isNotEmpty(busWellInfo.getDeptid())){ - List roleids= new ArrayList<>(); - for(SelectDto selectDto:selectDtoList){ - if(ToolUtil.isNotEmpty(selectDto.getName()) - && Arrays.asList(selectDto.getName().split(",")).contains(busWellInfo.getDeptid())){ + if (busWellInfo != null && ToolUtil.isNotEmpty(busWellInfo.getDeptid())) { + List roleids = new ArrayList<>(); + for (SelectDto selectDto : selectDtoList) { + if (ToolUtil.isNotEmpty(selectDto.getName()) + && Arrays.asList(selectDto.getName().split(",")).contains(busWellInfo.getDeptid())) { roleids.add(selectDto.getId()); } } - if(roleids.size()>0){ + if (roleids.size() > 0) { List useIds = selectUseIds(roleids); - for(Long useId:useIds){ + for (Long useId : useIds) { UserClientView userClientView = new UserClientView(); userClientView.setClientid(useId.toString()); userClientView.setId(useId.toString()); @@ -307,11 +321,11 @@ } } - if(!("null".equals(id))){ + if (!("null".equals(id))) { AlarmJob alarmJob = this.baseMapper.selectById(id); sendJob(id, alarmJob, userClientViewList);//推送工单至app和pc端 } - if(StringUtils.isNotBlank(msg)){ + if (StringUtils.isNotBlank(msg)) { sendAlarm(msg, userClientViewList);//推送告警至app和pc端 } @@ -386,7 +400,7 @@ } Date shouldHandleTime = now.getTime(); - if(Boolean.getBoolean(useOverTime)) { + if (Boolean.getBoolean(useOverTime)) { System.out.println(shouldHandleTime); String jobName = "getJobDelay" + id; Map map = new HashMap<>(); @@ -437,4 +451,40 @@ public String selectClientIdByUser(Long userId) { return this.baseMapper.selectClientIdByUser(userId); } + + + public AlarmJob saveData(String devCode, String wellCode, String devTypeName, String jobType) { + AlarmJob alarmJob = new AlarmJob(); + alarmJob.setDevcode(devCode); + alarmJob.setWellCode(wellCode); + alarmJob.setJobStatus("0"); + alarmJob.setCreateTime(new Date()); + alarmJob.setJobcode(this.produceJobCode(devTypeName)); + alarmJob.setJobType(jobType); + this.baseMapper.insert(alarmJob); + return alarmJob; + } + + /** + * 前缀+日期+4位流水号 + * + * @param devTypeName + * @return + */ + private String produceJobCode(String devTypeName) { + String pre = devTypeName; + String dataStr = sdf6.format(new Date()); + String fix = this.getJobCodeMaxSerial(pre + dataStr); + return StringUtils.isNotBlank(fix) ? pre + dataStr + String.format("%04d", Long.valueOf(fix) + 1L) : pre + dataStr + "0001"; + } + + + private String getJobCodeMaxSerial(String jobcode) { + String MaxSerialJobCode = this.baseMapper.getJobCodeMaxSerial(jobcode); + String fix = ""; + if (null != MaxSerialJobCode && MaxSerialJobCode.length() > 4) { + fix = MaxSerialJobCode.substring(MaxSerialJobCode.length() - 4); + } + return fix; + } } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmRecordsServiceImpl.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmRecordsServiceImpl.java index e0f0959..60fa41a 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmRecordsServiceImpl.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmRecordsServiceImpl.java @@ -16,7 +16,7 @@ /** *

- * 服务实现类 + * 服务实现类 *

* * @author casic123 @@ -27,12 +27,12 @@ @Override - public List> alarmList(Page> page, String keywords, String beginTime, String endTime, String status, String alarmType, String alarmContent, String areaId, DataScope dataScope) { + public List> alarmList(Page> page, String keywords, String beginTime, String endTime, String status, String alarmType, String alarmContent, String areaId, DataScope dataScope) { String sContent = null; - if (ToolUtil.isNotEmpty(alarmContent)){ + if (ToolUtil.isNotEmpty(alarmContent)) { sContent = EhcacheConstant.retBean().getAlarmContentName(Integer.valueOf(alarmContent)); } - return this.baseMapper.alarmList(page,keywords,beginTime,endTime,status,alarmType,sContent, areaId, dataScope); + return this.baseMapper.alarmList(page, keywords, beginTime, endTime, status, alarmType, sContent, areaId, dataScope); } /** @@ -41,15 +41,15 @@ @Override public List alarmListNoPage(DataScope dataScope, String keywords, String alarmType, String alarmContent, String beginTime, String endTime, String areaId) { String sContent = null; - if (ToolUtil.isNotEmpty(alarmContent)){ + if (ToolUtil.isNotEmpty(alarmContent)) { sContent = EhcacheConstant.retBean().getAlarmContentName(Integer.valueOf(alarmContent)); } - return this.baseMapper.alarmListNoPage(dataScope,keywords,alarmType,sContent,beginTime,endTime, areaId); + return this.baseMapper.alarmListNoPage(dataScope, keywords, alarmType, sContent, beginTime, endTime, areaId); } @Override public boolean cancelAlarm(long id, String jobStatus, String handleMessage, long personId) { - return this.baseMapper.cancelAlarm(id,jobStatus,handleMessage,personId); + return this.baseMapper.cancelAlarm(id, jobStatus, handleMessage, personId); } @Override @@ -62,4 +62,15 @@ // this.baseMapper.cancelAlarmByNewRecord(alarmRec.getDevcode(), alarmRec.getAlarmType()); return this.baseMapper.insert(alarmRec); } + + public Boolean isOldAlarmRecord(String devCode, String MsgContent) { + if (this.baseMapper.isOldAlarmRecord(devCode, MsgContent) == null) { + return false; + } + return true; + } + + public Integer updateOldAlarmRecord(String devCode, String MsgContent) { + return this.baseMapper.updateOldAlarmRecord(devCode, MsgContent); + } } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/AlarmMapOverviewController.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/AlarmMapOverviewController.java index 9d60185..214c275 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/AlarmMapOverviewController.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/AlarmMapOverviewController.java @@ -8,14 +8,12 @@ import com.casic.missiles.core.exception.GunsExceptionEnum; import com.casic.missiles.core.base.response.SuccessResponseData; import com.casic.missiles.core.util.ToolUtil; -import com.casic.missiles.modular.system.constant.ModularDictConst; import com.casic.missiles.modular.system.dto.AlarmNowView; import com.casic.missiles.modular.system.dto.DeviceDto; import com.casic.missiles.modular.system.model.BusWellInfo; import com.casic.missiles.modular.system.service.IAlarmNowViewService; import com.casic.missiles.modular.system.service.IBusWellInfoService; import com.casic.missiles.modular.system.service.IDeviceService; -import com.casic.missiles.modular.system.service.impl.BusWellInfoServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java index 46bb487..d27afa9 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java @@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.plugins.Page; import com.casic.missiles.core.base.response.ResponseData; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.alarm.service.IAlarmJobService; import com.casic.missiles.core.common.service.ICommonPermissionService; import com.casic.missiles.core.datascope.DataScope; @@ -12,12 +13,14 @@ import com.casic.missiles.modular.system.warpper.AlarmJobWarpper; import com.casic.missiles.core.base.controller.BaseController; import com.casic.missiles.core.common.constant.factory.PageFactory; +import lombok.extern.slf4j.Slf4j; import org.hswebframework.expands.office.excel.ExcelIO; import org.json.JSONException; import org.json.JSONObject; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; @@ -29,6 +32,7 @@ import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.*; //import com.casic.missiles.core.base.response.ResponseData; @@ -40,6 +44,7 @@ * @Date 2019-05-17 10:48:36 */ @Controller +@Slf4j @RequestMapping("/job") public class AlarmJobController extends BaseController { @@ -65,6 +70,13 @@ private String templatePath; + /** + * 工单状态接口统计 + * + * @param httpServletRequest + * @return + * @throws ParseException + */ @RequestMapping(value = "/countByJobStatus") @ResponseBody public Object countByJobStatus(HttpServletRequest httpServletRequest) throws ParseException { @@ -117,7 +129,7 @@ } /** - * 获取分页列表 + * 获取工单分页列表 */ @RequestMapping(value = "/list") @ResponseBody @@ -164,30 +176,26 @@ */ @RequestMapping(value = "/searchList") @ResponseBody - public Object jobListSearch(String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime, String endTime, - String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, - String handleJobBeginTime, String handleJobEndTime, String shouldHandleBeginTime, String shouldHandleEndTime) { + public Object jobListSearch(@RequestBody JobListParam jobListParam) { Page> page = new PageFactory>().defaultPage("createTime", false); DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List> retList = new ArrayList<>(); if (alarmJobService.checkPcRole(currentUser.getRoleTips())) { // pc角色 - retList = alarmJobService.jobListSearch(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, - handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, dataScope, currentUser.getId()); + retList = alarmJobService.jobListSearch(page, jobListParam, dataScope, currentUser.getId()); } else { //app角色 long leaderId = 0L; if (currentUser.getRoleTips().contains(sLeader)) { // 组长,查组内全部 leaderId = currentUser.getId(); - if (ToolUtil.isNotEmpty(jobStatus)) { + if (ToolUtil.isNotEmpty(jobListParam.getJobStatus())) { //learder&&jobStatus=1,2,3时,关闭传入的sort,按sql排序(自己的排在前) - page.setOpenSort(!alarmJobService.checkJobStatus(jobStatus)); + page.setOpenSort(!alarmJobService.checkJobStatus(jobListParam.getJobStatus())); } } - retList = alarmJobService.jobListSearchApp(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, - handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, currentUser.getDeptId(), currentUser.getId(), leaderId); + retList = alarmJobService.jobListSearchApp(page, jobListParam, currentUser.getDeptId(), currentUser.getId(), leaderId); } new AlarmJobWarpper(retList).warp(); @@ -277,26 +285,24 @@ @RequestMapping(value = "/export") public void exportJob(HttpServletRequest httpServletRequest , HttpServletResponse httpServletResponse) throws IOException { - Page> page = new PageFactory>().defaultPage("createTime", false); page.setLimit(maxRowsExcel); page.setSize(maxRowsExcel); page.setSearchCount(false); page.setOffset(0); - String keywords = httpServletRequest.getParameter("keywords"); String beginTime = httpServletRequest.getParameter("beginTime"); String endTime = httpServletRequest.getParameter("endTime"); String jobStatusStr = httpServletRequest.getParameter("jobStatus"); String alarmTypeStr = httpServletRequest.getParameter("alarmType"); String alarmContentStr = httpServletRequest.getParameter("alarmContentType"); - - List> jobExpList = new ArrayList<>(); + log.debug("主题参数---------------" + keywords + "," + beginTime + "," + endTime + "," + jobStatusStr + "," + alarmTypeStr + "," + alarmContentStr); DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - jobExpList = alarmJobService.jobList(page, keywords, beginTime, endTime, jobStatusStr, alarmTypeStr, alarmContentStr, dataScope, currentUser.getId()); + List> jobExpList = alarmJobService.jobList(page, keywords, beginTime, endTime, jobStatusStr, alarmTypeStr, alarmContentStr, dataScope, currentUser.getId()); new AlarmJobWarpper(jobExpList).warp(); FileInputStream fileInputStream = null; + log.debug("----------------" + ToolUtil.isEmpty(jobExpList)); if (ToolUtil.isEmpty(jobExpList)) { fileInputStream = new FileInputStream(templatePath + "/jobRecEmpty.xlsx"); } else { @@ -305,12 +311,10 @@ try { httpServletResponse.setContentType("application/octet-stream"); httpServletResponse.addHeader("Content-Disposition", " attachment;filename=" + "jobOverview.xlsx"); - Map var = new HashMap<>(); var.put("标题", "工单一览表"); var.put("list", jobExpList); ExcelIO.writeTemplate(fileInputStream, httpServletResponse.getOutputStream(), var); - } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { @@ -328,11 +332,11 @@ */ @RequestMapping(value = "/getJob") @ResponseBody - public Object getJob(int id) { + public Object getJob(Long id) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - if (alarmJobService.getJob(id, currentUser.getId())){ + if (alarmJobService.getJob(id, currentUser.getId())) { return ResponseData.success(); } else { return ResponseData.error("接单失败"); @@ -344,10 +348,10 @@ */ @RequestMapping(value = "/confirmJob") @ResponseBody - public Object confirmJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "firstState", required = true) String firstState, - @RequestParam(value = "firstStatePhotos", required = true) String firstStatePhotos, - @RequestParam(value = "needHandle", required = true) String needHandle) { + public Object confirmJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "firstState", required = true) String firstState, + @RequestParam(value = "firstStatePhotos", required = true) String firstStatePhotos, + @RequestParam(value = "needHandle", required = true) String needHandle) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.confirmJob(id, currentUser.getId(), firstState, firstStatePhotos, needHandle)) { return ResponseData.success(); @@ -361,17 +365,19 @@ */ @RequestMapping(value = "/transferJob") @ResponseBody - public Object transferJob(@RequestParam(value = "id", required = true) int id, + public Object transferJob(@RequestParam(value = "id", required = true) Long id, @RequestParam(value = "transferPerson", required = true) String transferPerson) throws JSONException { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - String dbTime = iSysDictService.getDBtime(); +// String dbTime = iSysDictService.getDBtime(); + SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); +// String dbTime = iSysDictService.getDBtime(); + Date dbTime = new Date(); JSONObject jsonObject = new JSONObject(); jsonObject.put("from", currentUser.getName()); jsonObject.put("to", EhcacheConstant.retBean().getUsernameById(Long.valueOf(transferPerson))); - jsonObject.put("time", dbTime); - + jsonObject.put("time", dateFormat.format(dbTime)); if (alarmJobService.transferJob(id, Long.valueOf(transferPerson), jsonObject.toString())) { return ResponseData.success(); } else { @@ -384,9 +390,9 @@ */ @RequestMapping(value = "/saveJob") @ResponseBody - public Object saveJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "handleMessage", required = true) String handleMessage, - @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { + public Object saveJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "handleMessage", required = true) String handleMessage, + @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { if (alarmJobService.saveJob(id, handleMessage, handlePhotos)) { return ResponseData.success(); @@ -400,10 +406,9 @@ */ @RequestMapping(value = "/overJob") @ResponseBody - public Object overJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "handleMessage", required = true) String handleMessage, - @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { - + public Object overJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "handleMessage", required = true) String handleMessage, + @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.overJob(id, currentUser.getId(), handleMessage, handlePhotos)) { @@ -419,7 +424,7 @@ */ @RequestMapping(value = "/handleJob") @ResponseBody - public Object handleJob(@RequestParam(value = "id", required = true) int id) { + public Object handleJob(@RequestParam(value = "id", required = true) Long id) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.handleJob(id, currentUser.getId())) { return ResponseData.success(); @@ -433,12 +438,10 @@ */ @RequestMapping(value = "/info") @ResponseBody - public Object jobInfo(@RequestParam(value = "id", required = true) int id) { - + public Object jobInfo(@RequestParam(value = "id", required = true) long id) { DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List> retList = alarmJobService.jobInfo(id, dataScope, currentUser.getId()); - new AlarmJobWarpper(retList).warp(); return ResponseData.success(retList); } @@ -456,7 +459,7 @@ @RequestParam(value = "wellCode", required = true) String wellCode) { Map retMap = new HashMap<>(); try { - alarmJobService.updateSinkJob(id, URLDecoder.decode(msg, "UTF-8"),wellCode); + alarmJobService.updateSinkJob(id, URLDecoder.decode(msg, "UTF-8"), wellCode); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java index 26a2ba7..df59231 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java @@ -52,6 +52,7 @@ @Autowired private IDeviceService deviceService; + @Value("${smartcity.office.maxRowsExcel}") private int maxRowsExcel; @Value("${smartcity.config.config-path}") @@ -182,7 +183,8 @@ @RequestMapping(value = "/cancelAlarmById") @ResponseBody public Object cancelAlarmById(@RequestParam(value = "alarmId",required = true) long alarmId){ - boolean isCancel = alarmRecordsService.cancelAlarmById(alarmId); + ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); + boolean isCancel = alarmRecordsService.cancelAlarm(alarmId,"4","手动消警",currentUser.getId()); if(isCancel){ return ResponseData.success(); }else { @@ -235,10 +237,10 @@ //根据查询条件查询alarm_record记录 DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); + ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List alarmRecords = alarmRecordsService.alarmListNoPage(dataScope, keywords, alarmType, alarmContent, beginTime, endTime, areaId); - for (AlarmRecords alarmRecord : alarmRecords) { - alarmRecordsService.cancelAlarmById(alarmRecord.getId()); + alarmRecordsService.cancelAlarm(alarmRecord.getJobId(),"4","手动消警",currentUser.getId()); } return ResponseData.success(); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/model/JobListParam.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/model/JobListParam.java new file mode 100644 index 0000000..c83bff8 --- /dev/null +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/model/JobListParam.java @@ -0,0 +1,32 @@ +package com.casic.missiles.modular.alarm.model; + + +import lombok.Data; + +/** + * @author cz + * @date 2022-6-13 17:03 + */ +@Data +public class JobListParam { + /** + * 关键字 + */ + private String keywords; + /** + * 风险等级 + */ + private String alarmLevel; + private String alarmContent; + private String jobStatus; + private String beginTime; + private String endTime; + private String getJobBeginTime; + private String getJobEndTime; + private String shouldGetBeginTime; + private String shouldGetEndTime; + private String handleJobBeginTime; + private String handleJobEndTime; + private String shouldHandleBeginTime; + private String shouldHandleEndTime; +} diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java index d4db8ce..018d095 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java @@ -3,6 +3,7 @@ import com.baomidou.mybatisplus.plugins.Page; import com.baomidou.mybatisplus.service.IService; import com.casic.missiles.core.datascope.DataScope; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.system.dto.UserClientView; import com.casic.missiles.modular.system.model.AlarmJob; @@ -18,42 +19,60 @@ * @since 2019-05-17 */ public interface IAlarmJobService extends IService { - List> jobList( Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType,String alarmContent, DataScope dataScope,Long userId); - List> jobListApp( Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType,String alarmContent,Long deptId,Long userId,Long leaderId); + + List> jobList(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, DataScope dataScope, Long userId); + + List> jobListApp(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, Long deptId, Long userId, Long leaderId); // List jobListExport( Page page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType,String alarmContent, DataScope dataScope); - List> jobListDelayRe( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, DataScope dataScope,Long userId); - List> jobListDelayReApp( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, Long deptId,Long userId,Long leaderId); + List> jobListDelayRe(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId); - List> jobListDelayPro( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, DataScope dataScope,Long userId ); - List> jobListDelayProApp( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, Long deptId,Long userId,Long leaderId); + List> jobListDelayReApp(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, Long deptId, Long userId, Long leaderId); - List> jobListSearch(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime,String endTime, - String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, - String shouldHandleBeginTime, String shouldHandleEndTime, DataScope dataScope,Long userId); - List> jobListSearchApp(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime,String endTime, - String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, - String shouldHandleBeginTime, String shouldHandleEndTime, Long deptId, Long userId, Long leaderId); - List> jobInfo(int id, DataScope dataScope,Long personId); - boolean getJob(int id, long personId); - boolean confirmJob(int id,long personId,String firstState, String firstStatePhotos, String needHandle); - boolean transferJob(int id, long transferPerson,String flowRec); - boolean saveJob( int id,String handleMessage, String handlePhotos); - boolean overJob( int id,long personId, String handleMessage, String handlePhotos); - boolean overAlarm( int id); - boolean handleJob(int id,long personId); + List> jobListDelayPro(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId); - Map countByJobStatus(long deptId,int spanDays); - Map countMyJob(long userId,long deptId,int spanDays); + List> jobListDelayProApp(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, Long deptId, Long userId, Long leaderId); + + List> jobListSearch(Page> page, JobListParam jobListParam, DataScope dataScope, Long userId); + + List> jobListSearchApp(Page> page, JobListParam jobListParam, Long deptId, Long userId, Long leaderId); + + List> jobInfo(Long id, DataScope dataScope, Long personId); + + boolean getJob(Long id, long personId); + + boolean confirmJob(Long id, long personId, String firstState, String firstStatePhotos, String needHandle); + + boolean transferJob(Long id, long transferPerson, String flowRec); + + boolean saveJob(Long id, String handleMessage, String handlePhotos); + + boolean overJob(Long id, long personId, String handleMessage, String handlePhotos); + + boolean overAlarm(int id); + + boolean handleJob(Long id, long personId); + + Map countByJobStatus(long deptId, int spanDays); + + Map countMyJob(long userId, long deptId, int spanDays); boolean checkJobStatus(String jobStatus); + boolean checkPcRole(List roleTips); - Integer countByDataScope(DataScope dataScope,String alarmType, String jobStatus,String beginTime,String endTime); - Integer countByResponse(String alarmType,String jobStatus,Long deptId,String beginTime,String endTime); - Integer countByUser(String alarmType,String jobStatus,Long userId,String beginTime,String endTime); + Integer countByDataScope(DataScope dataScope, String alarmType, String jobStatus, String beginTime, String endTime); - void updateSinkJob(String id,String msg,String wellCode); + Integer countByResponse(String alarmType, String jobStatus, Long deptId, String beginTime, String endTime); + + Integer countByUser(String alarmType, String jobStatus, Long userId, String beginTime, String endTime); + + void updateSinkJob(String id, String msg, String wellCode); + List selectUserByWellCode(String wellCode); + String selectClientIdByUser(Long userId); + + AlarmJob saveData( String devCode, String wellCode, String devTypeName, String jobType); + } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java index 46e7dfe..6eecb2b 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.service.IService; import com.casic.missiles.modular.system.model.AlarmRecords; import com.casic.missiles.core.datascope.DataScope; +import org.apache.ibatis.annotations.Param; import java.util.List; import java.util.Map; @@ -26,4 +27,8 @@ boolean cancelAlarmById(long id); Integer insertAlarmRecord(AlarmRecords alarmRec); + + Boolean isOldAlarmRecord(String devCode,String MsgContent); + + Integer updateOldAlarmRecord(String devCode,String MsgContent); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java index fa6681d..943ebd7 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java @@ -7,12 +7,14 @@ import com.casic.missiles.core.common.service.ICommonUserService; import com.casic.missiles.modular.alarm.job.HandleAlarmJob; import com.casic.missiles.modular.alarm.job.getDelayJob; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.alarm.service.IAlarmJobService; import com.casic.missiles.core.datascope.DataScope; import com.casic.missiles.core.util.EhcacheConstant; import com.casic.missiles.core.util.ToolUtil; import com.casic.missiles.modular.system.dao.AlarmJobMapper; import com.casic.missiles.modular.system.dao.AlarmRecordsMapper; +import com.casic.missiles.modular.system.dto.DeviceTypeEnum; import com.casic.missiles.modular.system.dto.SelectDto; import com.casic.missiles.modular.system.dto.UserClientView; import com.casic.missiles.modular.system.model.AlarmJob; @@ -24,6 +26,8 @@ import com.casic.missiles.quartz.service.IQuartzManager; import com.gexin.rp.sdk.base.IPushResult; import com.google.gson.GsonBuilder; +import net.sf.ehcache.search.Query; +import net.sf.ehcache.search.expression.Criteria; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -48,6 +52,8 @@ public class AlarmJobServiceImpl extends ServiceImpl implements IAlarmJobService { private static final Logger logger = LoggerFactory.getLogger(AlarmJobServiceImpl.class); + public static final SimpleDateFormat sdf6 = new SimpleDateFormat("yyyyMMdd"); + private static Map deviceAlarmMap = new HashMap(); @Value("${smartcity.leaderRoleName}") private String sLeader; @@ -70,12 +76,14 @@ @Resource private IQuartzManager quartzManager; - @Autowired IBusWellInfoService busWellInfoService; + @Autowired + IBusWellInfoService busWellInfoService; @Override - public List> jobList(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, DataScope dataScope,Long userId) { + public List> jobList(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, DataScope dataScope, Long userId) { alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobList(page, keywords, beginTime, endTime, jobStatus, alarmType, alarmContent, dataScope,userId);return alarmJobList; + List> alarmJobList = this.baseMapper.jobList(page, keywords, beginTime, endTime, jobStatus, alarmType, alarmContent, dataScope, userId); + return alarmJobList; } @Override @@ -86,9 +94,9 @@ } @Override - public List> jobListDelayRe(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope,Long userId) { + public List> jobListDelayRe(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId) { alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListDelayRe(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope,userId); + List> alarmJobList = this.baseMapper.jobListDelayRe(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope, userId); return alarmJobList; } @@ -100,9 +108,9 @@ } @Override - public List> jobListDelayPro(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope,Long userId) { + public List> jobListDelayPro(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId) { alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListDelayPro(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope,userId); + List> alarmJobList = this.baseMapper.jobListDelayPro(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope, userId); return alarmJobList; } @@ -114,109 +122,115 @@ } @Override - public List> jobListSearch(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime, String endTime, String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, String shouldHandleBeginTime, String shouldHandleEndTime, DataScope dataScope,Long userId) { - alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListSearch(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, dataScope,userId); + public List> jobListSearch(Page> page, JobListParam jobListParam, DataScope dataScope, Long userId) { + jobListParam.setAlarmContent(converAlarmContent(jobListParam.getAlarmContent())); + List> alarmJobList = this.baseMapper.jobListSearch(page, jobListParam, dataScope, userId); return alarmJobList; } @Override - public List> jobListSearchApp(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime, String endTime, String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, String shouldHandleBeginTime, String shouldHandleEndTime, Long deptId, Long userId, Long leaderId) { - alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListSearchApp(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, deptId, userId, leaderId); + public List> jobListSearchApp(Page> page, JobListParam jobListParam, Long deptId, Long userId, Long leaderId) { + jobListParam.setAlarmContent(converAlarmContent(jobListParam.getAlarmContent())); + List> alarmJobList = this.baseMapper.jobListSearchApp(page, jobListParam.getKeywords(), + jobListParam.getAlarmLevel(), jobListParam.getAlarmContent(), jobListParam.getJobStatus(), jobListParam.getBeginTime(), + jobListParam.getEndTime(), jobListParam.getGetJobBeginTime(), jobListParam.getGetJobEndTime(), jobListParam.getShouldGetBeginTime(), + jobListParam.getShouldGetEndTime(), jobListParam.getHandleJobBeginTime(), jobListParam.getHandleJobEndTime(), jobListParam.getShouldHandleBeginTime(), + jobListParam.getShouldHandleEndTime(), deptId, userId, leaderId); return alarmJobList; } - private String converAlarmContent(String alarmContent){ - if(ToolUtil.isEmpty(alarmContent)){ + private String converAlarmContent(String alarmContent) { + if (ToolUtil.isEmpty(alarmContent)) { return alarmContent; - }else { + } else { return EhcacheConstant.retBean().getAlarmContentName(Integer.valueOf(alarmContent)); } } @Override - public List> jobInfo(int id, DataScope dataScope, Long personId) - { - List> job = this.baseMapper.jobInfo(id,dataScope,personId); + public List> jobInfo(Long id, DataScope dataScope, Long personId) { + List> job = this.baseMapper.jobInfo(id, dataScope, personId); return job; } @Override - public Map countByJobStatus(long deptId,int spanDays) { - return this.baseMapper.countByJobStatus(deptId,spanDays); + public Map countByJobStatus(long deptId, int spanDays) { + return this.baseMapper.countByJobStatus(deptId, spanDays); } @Override - public Map countMyJob(long userId,long deptId,int spanDays) { - return this.baseMapper.countMyJob(userId,deptId,spanDays); + public Map countMyJob(long userId, long deptId, int spanDays) { + return this.baseMapper.countMyJob(userId, deptId, spanDays); } @Override - public boolean getJob(int id, long personId) { + public boolean getJob(Long id, long personId) { Calendar now = Calendar.getInstance(); Date getTime = now.getTime(); - if(isWeekend(now)){ + if (isWeekend(now)) { now.add(Calendar.WEEK_OF_YEAR, 1); - now.set(Calendar.DAY_OF_WEEK ,Calendar.TUESDAY); - now.set(Calendar.HOUR_OF_DAY,8); - now.set(Calendar.MINUTE,0); - now.set(Calendar.SECOND,0); - }else { + now.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY); + now.set(Calendar.HOUR_OF_DAY, 8); + now.set(Calendar.MINUTE, 0); + now.set(Calendar.SECOND, 0); + } else { now.add(Calendar.HOUR, 24); - while(isWeekend(now)){ + while (isWeekend(now)) { now.add(Calendar.HOUR, 24); } } Date shouldHandleTime = now.getTime(); - if(Boolean.getBoolean(useOverTime)){ + if (Boolean.getBoolean(useOverTime)) { System.out.println(shouldHandleTime); String jobName = "getJobDelay" + id; - Map map = new HashMap<>(); - map.put("jobId",id); - map.put("iAlarmJobService",this); - map.put("iCommonUserService",iCommonUserService); - map.put("iQuartzManager",quartzManager); - map.put("webSocket",webSocket); - quartzManager.addJob(jobName,getDelayJob.class,shouldHandleTime,map); + Map map = new HashMap<>(); + map.put("jobId", id); + map.put("iAlarmJobService", this); + map.put("iCommonUserService", iCommonUserService); + map.put("iQuartzManager", quartzManager); + map.put("webSocket", webSocket); + quartzManager.addJob(jobName, getDelayJob.class, shouldHandleTime, map); } - return this.baseMapper.getJob(id,personId,getTime,shouldHandleTime); + return this.baseMapper.getJob(id, personId, getTime, shouldHandleTime); } - private boolean isWeekend(Calendar cal){ - if(cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY){ + private boolean isWeekend(Calendar cal) { + if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) { return true; - } else{ + } else { return false; } } @Override - public boolean confirmJob(int id,long personId, String firstState, String firstStatePhotos, String needHandle) { - if ("1".equals(needHandle)){ - return this.baseMapper.confirmJob(id,personId, firstState, firstStatePhotos, needHandle); + public boolean confirmJob(Long id, long personId, String firstState, String firstStatePhotos, String needHandle) { + if ("1".equals(needHandle)) { + return this.baseMapper.confirmJob(id, personId, firstState, firstStatePhotos, needHandle); } else { - return this.baseMapper.confirmOverJobAndAlarm(id, personId,firstState, firstStatePhotos); + return this.baseMapper.confirmOverJobAndAlarm(id, personId, firstState, firstStatePhotos); } } @Override - public boolean transferJob(int id, long transferPerson,String flowRec) { - return this.baseMapper.transferJob(id, transferPerson,flowRec); + public boolean transferJob(Long id, long transferPerson, String flowRec) { + return this.baseMapper.transferJob(id, transferPerson, flowRec); } @Override - public boolean saveJob(int id, String handleMessage, String handlePhotos) { + public boolean saveJob(Long id, String handleMessage, String handlePhotos) { return this.baseMapper.saveJob(id, handleMessage, handlePhotos); } @Override - public boolean overJob(int id,long personId, String handleMessage, String handlePhotos) { - return this.baseMapper.overJobAndAlarm(id, personId,handleMessage, handlePhotos); + public boolean overJob(Long id, long personId, String handleMessage, String handlePhotos) { + + return this.baseMapper.overJobAndAlarm(id, personId, handleMessage, handlePhotos); + // return this.baseMapper.overJob(id, personId,handleMessage, handlePhotos); } + @Override public boolean overAlarm(int jobId) { return this.baseMapper.overAlarm(jobId); @@ -224,15 +238,15 @@ } @Override - public boolean handleJob(int id,long personId) { - return this.baseMapper.handleJob(id,personId); + public boolean handleJob(Long id, long personId) { + return this.baseMapper.handleJob(id, personId); } @Override public boolean checkJobStatus(String jobStatus) { - if(ToolUtil.isEmpty(jobStatus)){ + if (ToolUtil.isEmpty(jobStatus)) { return false; - }else{ + } else { return "1".equals(jobStatus) || "2".equals(jobStatus) || "3".equals(jobStatus); } } @@ -243,10 +257,10 @@ } - public List selectRoles() { return this.baseMapper.selectRoles(); } + public List selectUseIds(List roleIds) { return this.baseMapper.selectUseIds(roleIds); } @@ -255,50 +269,50 @@ public boolean checkPcRole(List roleTips) { List roleList = new ArrayList<>(roleTips); Iterator it = roleList.iterator(); - while (it.hasNext()){ + while (it.hasNext()) { String role = it.next(); - if(role.equals(sApp)||role.equals(sLeader)||role.equals(sMember)){ + if (role.equals(sApp) || role.equals(sLeader) || role.equals(sMember)) { it.remove(); } } - return roleList.size()>0; + return roleList.size() > 0; } @Override - public Integer countByDataScope(DataScope dataScope, String alarmType, String jobStatus, String beginTime,String endTime) { - List> res = this.baseMapper.countByDataScope(dataScope,alarmType,jobStatus,beginTime,endTime); + public Integer countByDataScope(DataScope dataScope, String alarmType, String jobStatus, String beginTime, String endTime) { + List> res = this.baseMapper.countByDataScope(dataScope, alarmType, jobStatus, beginTime, endTime); return res.size(); } @Override - public Integer countByResponse(String alarmType, String jobStatus, Long deptId, String beginTime,String endTime) { - return this.baseMapper.countByResponse(alarmType,jobStatus,deptId,beginTime,endTime); + public Integer countByResponse(String alarmType, String jobStatus, Long deptId, String beginTime, String endTime) { + return this.baseMapper.countByResponse(alarmType, jobStatus, deptId, beginTime, endTime); } @Override - public Integer countByUser(String alarmType, String jobStatus, Long userId, String beginTime,String endTime) { - return this.baseMapper.countByUser(alarmType,jobStatus,userId,beginTime,endTime); + public Integer countByUser(String alarmType, String jobStatus, Long userId, String beginTime, String endTime) { + return this.baseMapper.countByUser(alarmType, jobStatus, userId, beginTime, endTime); } @Override - public void updateSinkJob(String id, String msg,String wellCode) { + public void updateSinkJob(String id, String msg, String wellCode) { List userClientViewList = new ArrayList<>(); List selectDtoList = selectRoles(); EntityWrapper busWellInfoEntityWrapper = new EntityWrapper<>(); - busWellInfoEntityWrapper.eq("WELL_CODE",wellCode); + busWellInfoEntityWrapper.eq("WELL_CODE", wellCode); BusWellInfo busWellInfo = busWellInfoService.selectOne(busWellInfoEntityWrapper); - if(busWellInfo!=null&&ToolUtil.isNotEmpty(busWellInfo.getDeptid())){ - List roleids= new ArrayList<>(); - for(SelectDto selectDto:selectDtoList){ - if(ToolUtil.isNotEmpty(selectDto.getName()) - && Arrays.asList(selectDto.getName().split(",")).contains(busWellInfo.getDeptid())){ + if (busWellInfo != null && ToolUtil.isNotEmpty(busWellInfo.getDeptid())) { + List roleids = new ArrayList<>(); + for (SelectDto selectDto : selectDtoList) { + if (ToolUtil.isNotEmpty(selectDto.getName()) + && Arrays.asList(selectDto.getName().split(",")).contains(busWellInfo.getDeptid())) { roleids.add(selectDto.getId()); } } - if(roleids.size()>0){ + if (roleids.size() > 0) { List useIds = selectUseIds(roleids); - for(Long useId:useIds){ + for (Long useId : useIds) { UserClientView userClientView = new UserClientView(); userClientView.setClientid(useId.toString()); userClientView.setId(useId.toString()); @@ -307,11 +321,11 @@ } } - if(!("null".equals(id))){ + if (!("null".equals(id))) { AlarmJob alarmJob = this.baseMapper.selectById(id); sendJob(id, alarmJob, userClientViewList);//推送工单至app和pc端 } - if(StringUtils.isNotBlank(msg)){ + if (StringUtils.isNotBlank(msg)) { sendAlarm(msg, userClientViewList);//推送告警至app和pc端 } @@ -386,7 +400,7 @@ } Date shouldHandleTime = now.getTime(); - if(Boolean.getBoolean(useOverTime)) { + if (Boolean.getBoolean(useOverTime)) { System.out.println(shouldHandleTime); String jobName = "getJobDelay" + id; Map map = new HashMap<>(); @@ -437,4 +451,40 @@ public String selectClientIdByUser(Long userId) { return this.baseMapper.selectClientIdByUser(userId); } + + + public AlarmJob saveData(String devCode, String wellCode, String devTypeName, String jobType) { + AlarmJob alarmJob = new AlarmJob(); + alarmJob.setDevcode(devCode); + alarmJob.setWellCode(wellCode); + alarmJob.setJobStatus("0"); + alarmJob.setCreateTime(new Date()); + alarmJob.setJobcode(this.produceJobCode(devTypeName)); + alarmJob.setJobType(jobType); + this.baseMapper.insert(alarmJob); + return alarmJob; + } + + /** + * 前缀+日期+4位流水号 + * + * @param devTypeName + * @return + */ + private String produceJobCode(String devTypeName) { + String pre = devTypeName; + String dataStr = sdf6.format(new Date()); + String fix = this.getJobCodeMaxSerial(pre + dataStr); + return StringUtils.isNotBlank(fix) ? pre + dataStr + String.format("%04d", Long.valueOf(fix) + 1L) : pre + dataStr + "0001"; + } + + + private String getJobCodeMaxSerial(String jobcode) { + String MaxSerialJobCode = this.baseMapper.getJobCodeMaxSerial(jobcode); + String fix = ""; + if (null != MaxSerialJobCode && MaxSerialJobCode.length() > 4) { + fix = MaxSerialJobCode.substring(MaxSerialJobCode.length() - 4); + } + return fix; + } } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmRecordsServiceImpl.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmRecordsServiceImpl.java index e0f0959..60fa41a 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmRecordsServiceImpl.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmRecordsServiceImpl.java @@ -16,7 +16,7 @@ /** *

- * 服务实现类 + * 服务实现类 *

* * @author casic123 @@ -27,12 +27,12 @@ @Override - public List> alarmList(Page> page, String keywords, String beginTime, String endTime, String status, String alarmType, String alarmContent, String areaId, DataScope dataScope) { + public List> alarmList(Page> page, String keywords, String beginTime, String endTime, String status, String alarmType, String alarmContent, String areaId, DataScope dataScope) { String sContent = null; - if (ToolUtil.isNotEmpty(alarmContent)){ + if (ToolUtil.isNotEmpty(alarmContent)) { sContent = EhcacheConstant.retBean().getAlarmContentName(Integer.valueOf(alarmContent)); } - return this.baseMapper.alarmList(page,keywords,beginTime,endTime,status,alarmType,sContent, areaId, dataScope); + return this.baseMapper.alarmList(page, keywords, beginTime, endTime, status, alarmType, sContent, areaId, dataScope); } /** @@ -41,15 +41,15 @@ @Override public List alarmListNoPage(DataScope dataScope, String keywords, String alarmType, String alarmContent, String beginTime, String endTime, String areaId) { String sContent = null; - if (ToolUtil.isNotEmpty(alarmContent)){ + if (ToolUtil.isNotEmpty(alarmContent)) { sContent = EhcacheConstant.retBean().getAlarmContentName(Integer.valueOf(alarmContent)); } - return this.baseMapper.alarmListNoPage(dataScope,keywords,alarmType,sContent,beginTime,endTime, areaId); + return this.baseMapper.alarmListNoPage(dataScope, keywords, alarmType, sContent, beginTime, endTime, areaId); } @Override public boolean cancelAlarm(long id, String jobStatus, String handleMessage, long personId) { - return this.baseMapper.cancelAlarm(id,jobStatus,handleMessage,personId); + return this.baseMapper.cancelAlarm(id, jobStatus, handleMessage, personId); } @Override @@ -62,4 +62,15 @@ // this.baseMapper.cancelAlarmByNewRecord(alarmRec.getDevcode(), alarmRec.getAlarmType()); return this.baseMapper.insert(alarmRec); } + + public Boolean isOldAlarmRecord(String devCode, String MsgContent) { + if (this.baseMapper.isOldAlarmRecord(devCode, MsgContent) == null) { + return false; + } + return true; + } + + public Integer updateOldAlarmRecord(String devCode, String MsgContent) { + return this.baseMapper.updateOldAlarmRecord(devCode, MsgContent); + } } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/AlarmMapOverviewController.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/AlarmMapOverviewController.java index 9d60185..214c275 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/AlarmMapOverviewController.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/AlarmMapOverviewController.java @@ -8,14 +8,12 @@ import com.casic.missiles.core.exception.GunsExceptionEnum; import com.casic.missiles.core.base.response.SuccessResponseData; import com.casic.missiles.core.util.ToolUtil; -import com.casic.missiles.modular.system.constant.ModularDictConst; import com.casic.missiles.modular.system.dto.AlarmNowView; import com.casic.missiles.modular.system.dto.DeviceDto; import com.casic.missiles.modular.system.model.BusWellInfo; import com.casic.missiles.modular.system.service.IAlarmNowViewService; import com.casic.missiles.modular.system.service.IBusWellInfoService; import com.casic.missiles.modular.system.service.IDeviceService; -import com.casic.missiles.modular.system.service.impl.BusWellInfoServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataReceiver.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataReceiver.java index 0013989..b3f23d5 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataReceiver.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataReceiver.java @@ -2,6 +2,7 @@ import com.casic.missiles.core.base.controller.BaseController; import com.casic.missiles.core.base.response.ResponseData; +import com.casic.missiles.modular.alarm.service.IAlarmJobService; import com.casic.missiles.modular.alarm.service.IAlarmRecordsService; import com.casic.missiles.modular.alarm.service.IAlarmRuleService; import com.casic.missiles.modular.system.dto.DeviceWellDto; @@ -9,6 +10,7 @@ import com.casic.missiles.modular.system.service.IDeviceService; import com.casic.missiles.modular.system.service.IGasFlowDataService; import lombok.extern.java.Log; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -38,6 +40,9 @@ @Resource private IAlarmRecordsService alarmRecordsService; + @Autowired + IAlarmJobService alarmJobService; + private DecimalFormat df2 = new DecimalFormat("0.00"); @RequestMapping(value = "/data/recv") @@ -117,6 +122,13 @@ alarmRecord.setAlarmTime(Calendar.getInstance().getTime()); alarmRecord.setStatus("1"); alarmRecord.setAlarmMessage("日用气量超阈值报警"); + if (alarmRecordsService.isOldAlarmRecord(gasFlowAddr, "日用气量超阈值报警")) { + alarmRecordsService.updateOldAlarmRecord(gasFlowAddr, "日用气量超阈值报警"); + } else { + AlarmJob alarmJob = alarmJobService.saveData(gasFlowAddr, wellDto.getWellCode(), "SLCX", "1"); + alarmRecord.setJobId(alarmJob.getId()); + } + alarmRecordsService.insertAlarmRecord(alarmRecord); // 向前端推送报警 } else { @@ -134,6 +146,13 @@ alarmRecord.setAlarmTime(Calendar.getInstance().getTime()); alarmRecord.setStatus("1"); alarmRecord.setAlarmMessage("日用气量超阈值预警"); + alarmRecord.setAlarmMessage("日用水量超阈值预警"); + if (alarmRecordsService.isOldAlarmRecord(gasFlowAddr, "日用水量超阈值预警")) { + alarmRecordsService.updateOldAlarmRecord(gasFlowAddr, "日用水量超阈值预警"); + } else { + AlarmJob alarmJob = alarmJobService.saveData(gasFlowAddr, wellDto.getWellCode(), "SLCX", "1"); + alarmRecord.setJobId(alarmJob.getId()); + } alarmRecordsService.insertAlarmRecord(alarmRecord); // 向前端推送报警 } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java index 46bb487..d27afa9 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java @@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.plugins.Page; import com.casic.missiles.core.base.response.ResponseData; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.alarm.service.IAlarmJobService; import com.casic.missiles.core.common.service.ICommonPermissionService; import com.casic.missiles.core.datascope.DataScope; @@ -12,12 +13,14 @@ import com.casic.missiles.modular.system.warpper.AlarmJobWarpper; import com.casic.missiles.core.base.controller.BaseController; import com.casic.missiles.core.common.constant.factory.PageFactory; +import lombok.extern.slf4j.Slf4j; import org.hswebframework.expands.office.excel.ExcelIO; import org.json.JSONException; import org.json.JSONObject; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; @@ -29,6 +32,7 @@ import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.*; //import com.casic.missiles.core.base.response.ResponseData; @@ -40,6 +44,7 @@ * @Date 2019-05-17 10:48:36 */ @Controller +@Slf4j @RequestMapping("/job") public class AlarmJobController extends BaseController { @@ -65,6 +70,13 @@ private String templatePath; + /** + * 工单状态接口统计 + * + * @param httpServletRequest + * @return + * @throws ParseException + */ @RequestMapping(value = "/countByJobStatus") @ResponseBody public Object countByJobStatus(HttpServletRequest httpServletRequest) throws ParseException { @@ -117,7 +129,7 @@ } /** - * 获取分页列表 + * 获取工单分页列表 */ @RequestMapping(value = "/list") @ResponseBody @@ -164,30 +176,26 @@ */ @RequestMapping(value = "/searchList") @ResponseBody - public Object jobListSearch(String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime, String endTime, - String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, - String handleJobBeginTime, String handleJobEndTime, String shouldHandleBeginTime, String shouldHandleEndTime) { + public Object jobListSearch(@RequestBody JobListParam jobListParam) { Page> page = new PageFactory>().defaultPage("createTime", false); DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List> retList = new ArrayList<>(); if (alarmJobService.checkPcRole(currentUser.getRoleTips())) { // pc角色 - retList = alarmJobService.jobListSearch(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, - handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, dataScope, currentUser.getId()); + retList = alarmJobService.jobListSearch(page, jobListParam, dataScope, currentUser.getId()); } else { //app角色 long leaderId = 0L; if (currentUser.getRoleTips().contains(sLeader)) { // 组长,查组内全部 leaderId = currentUser.getId(); - if (ToolUtil.isNotEmpty(jobStatus)) { + if (ToolUtil.isNotEmpty(jobListParam.getJobStatus())) { //learder&&jobStatus=1,2,3时,关闭传入的sort,按sql排序(自己的排在前) - page.setOpenSort(!alarmJobService.checkJobStatus(jobStatus)); + page.setOpenSort(!alarmJobService.checkJobStatus(jobListParam.getJobStatus())); } } - retList = alarmJobService.jobListSearchApp(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, - handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, currentUser.getDeptId(), currentUser.getId(), leaderId); + retList = alarmJobService.jobListSearchApp(page, jobListParam, currentUser.getDeptId(), currentUser.getId(), leaderId); } new AlarmJobWarpper(retList).warp(); @@ -277,26 +285,24 @@ @RequestMapping(value = "/export") public void exportJob(HttpServletRequest httpServletRequest , HttpServletResponse httpServletResponse) throws IOException { - Page> page = new PageFactory>().defaultPage("createTime", false); page.setLimit(maxRowsExcel); page.setSize(maxRowsExcel); page.setSearchCount(false); page.setOffset(0); - String keywords = httpServletRequest.getParameter("keywords"); String beginTime = httpServletRequest.getParameter("beginTime"); String endTime = httpServletRequest.getParameter("endTime"); String jobStatusStr = httpServletRequest.getParameter("jobStatus"); String alarmTypeStr = httpServletRequest.getParameter("alarmType"); String alarmContentStr = httpServletRequest.getParameter("alarmContentType"); - - List> jobExpList = new ArrayList<>(); + log.debug("主题参数---------------" + keywords + "," + beginTime + "," + endTime + "," + jobStatusStr + "," + alarmTypeStr + "," + alarmContentStr); DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - jobExpList = alarmJobService.jobList(page, keywords, beginTime, endTime, jobStatusStr, alarmTypeStr, alarmContentStr, dataScope, currentUser.getId()); + List> jobExpList = alarmJobService.jobList(page, keywords, beginTime, endTime, jobStatusStr, alarmTypeStr, alarmContentStr, dataScope, currentUser.getId()); new AlarmJobWarpper(jobExpList).warp(); FileInputStream fileInputStream = null; + log.debug("----------------" + ToolUtil.isEmpty(jobExpList)); if (ToolUtil.isEmpty(jobExpList)) { fileInputStream = new FileInputStream(templatePath + "/jobRecEmpty.xlsx"); } else { @@ -305,12 +311,10 @@ try { httpServletResponse.setContentType("application/octet-stream"); httpServletResponse.addHeader("Content-Disposition", " attachment;filename=" + "jobOverview.xlsx"); - Map var = new HashMap<>(); var.put("标题", "工单一览表"); var.put("list", jobExpList); ExcelIO.writeTemplate(fileInputStream, httpServletResponse.getOutputStream(), var); - } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { @@ -328,11 +332,11 @@ */ @RequestMapping(value = "/getJob") @ResponseBody - public Object getJob(int id) { + public Object getJob(Long id) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - if (alarmJobService.getJob(id, currentUser.getId())){ + if (alarmJobService.getJob(id, currentUser.getId())) { return ResponseData.success(); } else { return ResponseData.error("接单失败"); @@ -344,10 +348,10 @@ */ @RequestMapping(value = "/confirmJob") @ResponseBody - public Object confirmJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "firstState", required = true) String firstState, - @RequestParam(value = "firstStatePhotos", required = true) String firstStatePhotos, - @RequestParam(value = "needHandle", required = true) String needHandle) { + public Object confirmJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "firstState", required = true) String firstState, + @RequestParam(value = "firstStatePhotos", required = true) String firstStatePhotos, + @RequestParam(value = "needHandle", required = true) String needHandle) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.confirmJob(id, currentUser.getId(), firstState, firstStatePhotos, needHandle)) { return ResponseData.success(); @@ -361,17 +365,19 @@ */ @RequestMapping(value = "/transferJob") @ResponseBody - public Object transferJob(@RequestParam(value = "id", required = true) int id, + public Object transferJob(@RequestParam(value = "id", required = true) Long id, @RequestParam(value = "transferPerson", required = true) String transferPerson) throws JSONException { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - String dbTime = iSysDictService.getDBtime(); +// String dbTime = iSysDictService.getDBtime(); + SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); +// String dbTime = iSysDictService.getDBtime(); + Date dbTime = new Date(); JSONObject jsonObject = new JSONObject(); jsonObject.put("from", currentUser.getName()); jsonObject.put("to", EhcacheConstant.retBean().getUsernameById(Long.valueOf(transferPerson))); - jsonObject.put("time", dbTime); - + jsonObject.put("time", dateFormat.format(dbTime)); if (alarmJobService.transferJob(id, Long.valueOf(transferPerson), jsonObject.toString())) { return ResponseData.success(); } else { @@ -384,9 +390,9 @@ */ @RequestMapping(value = "/saveJob") @ResponseBody - public Object saveJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "handleMessage", required = true) String handleMessage, - @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { + public Object saveJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "handleMessage", required = true) String handleMessage, + @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { if (alarmJobService.saveJob(id, handleMessage, handlePhotos)) { return ResponseData.success(); @@ -400,10 +406,9 @@ */ @RequestMapping(value = "/overJob") @ResponseBody - public Object overJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "handleMessage", required = true) String handleMessage, - @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { - + public Object overJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "handleMessage", required = true) String handleMessage, + @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.overJob(id, currentUser.getId(), handleMessage, handlePhotos)) { @@ -419,7 +424,7 @@ */ @RequestMapping(value = "/handleJob") @ResponseBody - public Object handleJob(@RequestParam(value = "id", required = true) int id) { + public Object handleJob(@RequestParam(value = "id", required = true) Long id) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.handleJob(id, currentUser.getId())) { return ResponseData.success(); @@ -433,12 +438,10 @@ */ @RequestMapping(value = "/info") @ResponseBody - public Object jobInfo(@RequestParam(value = "id", required = true) int id) { - + public Object jobInfo(@RequestParam(value = "id", required = true) long id) { DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List> retList = alarmJobService.jobInfo(id, dataScope, currentUser.getId()); - new AlarmJobWarpper(retList).warp(); return ResponseData.success(retList); } @@ -456,7 +459,7 @@ @RequestParam(value = "wellCode", required = true) String wellCode) { Map retMap = new HashMap<>(); try { - alarmJobService.updateSinkJob(id, URLDecoder.decode(msg, "UTF-8"),wellCode); + alarmJobService.updateSinkJob(id, URLDecoder.decode(msg, "UTF-8"), wellCode); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java index 26a2ba7..df59231 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java @@ -52,6 +52,7 @@ @Autowired private IDeviceService deviceService; + @Value("${smartcity.office.maxRowsExcel}") private int maxRowsExcel; @Value("${smartcity.config.config-path}") @@ -182,7 +183,8 @@ @RequestMapping(value = "/cancelAlarmById") @ResponseBody public Object cancelAlarmById(@RequestParam(value = "alarmId",required = true) long alarmId){ - boolean isCancel = alarmRecordsService.cancelAlarmById(alarmId); + ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); + boolean isCancel = alarmRecordsService.cancelAlarm(alarmId,"4","手动消警",currentUser.getId()); if(isCancel){ return ResponseData.success(); }else { @@ -235,10 +237,10 @@ //根据查询条件查询alarm_record记录 DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); + ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List alarmRecords = alarmRecordsService.alarmListNoPage(dataScope, keywords, alarmType, alarmContent, beginTime, endTime, areaId); - for (AlarmRecords alarmRecord : alarmRecords) { - alarmRecordsService.cancelAlarmById(alarmRecord.getId()); + alarmRecordsService.cancelAlarm(alarmRecord.getJobId(),"4","手动消警",currentUser.getId()); } return ResponseData.success(); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/model/JobListParam.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/model/JobListParam.java new file mode 100644 index 0000000..c83bff8 --- /dev/null +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/model/JobListParam.java @@ -0,0 +1,32 @@ +package com.casic.missiles.modular.alarm.model; + + +import lombok.Data; + +/** + * @author cz + * @date 2022-6-13 17:03 + */ +@Data +public class JobListParam { + /** + * 关键字 + */ + private String keywords; + /** + * 风险等级 + */ + private String alarmLevel; + private String alarmContent; + private String jobStatus; + private String beginTime; + private String endTime; + private String getJobBeginTime; + private String getJobEndTime; + private String shouldGetBeginTime; + private String shouldGetEndTime; + private String handleJobBeginTime; + private String handleJobEndTime; + private String shouldHandleBeginTime; + private String shouldHandleEndTime; +} diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java index d4db8ce..018d095 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java @@ -3,6 +3,7 @@ import com.baomidou.mybatisplus.plugins.Page; import com.baomidou.mybatisplus.service.IService; import com.casic.missiles.core.datascope.DataScope; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.system.dto.UserClientView; import com.casic.missiles.modular.system.model.AlarmJob; @@ -18,42 +19,60 @@ * @since 2019-05-17 */ public interface IAlarmJobService extends IService { - List> jobList( Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType,String alarmContent, DataScope dataScope,Long userId); - List> jobListApp( Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType,String alarmContent,Long deptId,Long userId,Long leaderId); + + List> jobList(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, DataScope dataScope, Long userId); + + List> jobListApp(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, Long deptId, Long userId, Long leaderId); // List jobListExport( Page page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType,String alarmContent, DataScope dataScope); - List> jobListDelayRe( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, DataScope dataScope,Long userId); - List> jobListDelayReApp( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, Long deptId,Long userId,Long leaderId); + List> jobListDelayRe(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId); - List> jobListDelayPro( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, DataScope dataScope,Long userId ); - List> jobListDelayProApp( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, Long deptId,Long userId,Long leaderId); + List> jobListDelayReApp(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, Long deptId, Long userId, Long leaderId); - List> jobListSearch(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime,String endTime, - String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, - String shouldHandleBeginTime, String shouldHandleEndTime, DataScope dataScope,Long userId); - List> jobListSearchApp(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime,String endTime, - String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, - String shouldHandleBeginTime, String shouldHandleEndTime, Long deptId, Long userId, Long leaderId); - List> jobInfo(int id, DataScope dataScope,Long personId); - boolean getJob(int id, long personId); - boolean confirmJob(int id,long personId,String firstState, String firstStatePhotos, String needHandle); - boolean transferJob(int id, long transferPerson,String flowRec); - boolean saveJob( int id,String handleMessage, String handlePhotos); - boolean overJob( int id,long personId, String handleMessage, String handlePhotos); - boolean overAlarm( int id); - boolean handleJob(int id,long personId); + List> jobListDelayPro(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId); - Map countByJobStatus(long deptId,int spanDays); - Map countMyJob(long userId,long deptId,int spanDays); + List> jobListDelayProApp(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, Long deptId, Long userId, Long leaderId); + + List> jobListSearch(Page> page, JobListParam jobListParam, DataScope dataScope, Long userId); + + List> jobListSearchApp(Page> page, JobListParam jobListParam, Long deptId, Long userId, Long leaderId); + + List> jobInfo(Long id, DataScope dataScope, Long personId); + + boolean getJob(Long id, long personId); + + boolean confirmJob(Long id, long personId, String firstState, String firstStatePhotos, String needHandle); + + boolean transferJob(Long id, long transferPerson, String flowRec); + + boolean saveJob(Long id, String handleMessage, String handlePhotos); + + boolean overJob(Long id, long personId, String handleMessage, String handlePhotos); + + boolean overAlarm(int id); + + boolean handleJob(Long id, long personId); + + Map countByJobStatus(long deptId, int spanDays); + + Map countMyJob(long userId, long deptId, int spanDays); boolean checkJobStatus(String jobStatus); + boolean checkPcRole(List roleTips); - Integer countByDataScope(DataScope dataScope,String alarmType, String jobStatus,String beginTime,String endTime); - Integer countByResponse(String alarmType,String jobStatus,Long deptId,String beginTime,String endTime); - Integer countByUser(String alarmType,String jobStatus,Long userId,String beginTime,String endTime); + Integer countByDataScope(DataScope dataScope, String alarmType, String jobStatus, String beginTime, String endTime); - void updateSinkJob(String id,String msg,String wellCode); + Integer countByResponse(String alarmType, String jobStatus, Long deptId, String beginTime, String endTime); + + Integer countByUser(String alarmType, String jobStatus, Long userId, String beginTime, String endTime); + + void updateSinkJob(String id, String msg, String wellCode); + List selectUserByWellCode(String wellCode); + String selectClientIdByUser(Long userId); + + AlarmJob saveData( String devCode, String wellCode, String devTypeName, String jobType); + } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java index 46e7dfe..6eecb2b 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.service.IService; import com.casic.missiles.modular.system.model.AlarmRecords; import com.casic.missiles.core.datascope.DataScope; +import org.apache.ibatis.annotations.Param; import java.util.List; import java.util.Map; @@ -26,4 +27,8 @@ boolean cancelAlarmById(long id); Integer insertAlarmRecord(AlarmRecords alarmRec); + + Boolean isOldAlarmRecord(String devCode,String MsgContent); + + Integer updateOldAlarmRecord(String devCode,String MsgContent); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java index fa6681d..943ebd7 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java @@ -7,12 +7,14 @@ import com.casic.missiles.core.common.service.ICommonUserService; import com.casic.missiles.modular.alarm.job.HandleAlarmJob; import com.casic.missiles.modular.alarm.job.getDelayJob; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.alarm.service.IAlarmJobService; import com.casic.missiles.core.datascope.DataScope; import com.casic.missiles.core.util.EhcacheConstant; import com.casic.missiles.core.util.ToolUtil; import com.casic.missiles.modular.system.dao.AlarmJobMapper; import com.casic.missiles.modular.system.dao.AlarmRecordsMapper; +import com.casic.missiles.modular.system.dto.DeviceTypeEnum; import com.casic.missiles.modular.system.dto.SelectDto; import com.casic.missiles.modular.system.dto.UserClientView; import com.casic.missiles.modular.system.model.AlarmJob; @@ -24,6 +26,8 @@ import com.casic.missiles.quartz.service.IQuartzManager; import com.gexin.rp.sdk.base.IPushResult; import com.google.gson.GsonBuilder; +import net.sf.ehcache.search.Query; +import net.sf.ehcache.search.expression.Criteria; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -48,6 +52,8 @@ public class AlarmJobServiceImpl extends ServiceImpl implements IAlarmJobService { private static final Logger logger = LoggerFactory.getLogger(AlarmJobServiceImpl.class); + public static final SimpleDateFormat sdf6 = new SimpleDateFormat("yyyyMMdd"); + private static Map deviceAlarmMap = new HashMap(); @Value("${smartcity.leaderRoleName}") private String sLeader; @@ -70,12 +76,14 @@ @Resource private IQuartzManager quartzManager; - @Autowired IBusWellInfoService busWellInfoService; + @Autowired + IBusWellInfoService busWellInfoService; @Override - public List> jobList(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, DataScope dataScope,Long userId) { + public List> jobList(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, DataScope dataScope, Long userId) { alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobList(page, keywords, beginTime, endTime, jobStatus, alarmType, alarmContent, dataScope,userId);return alarmJobList; + List> alarmJobList = this.baseMapper.jobList(page, keywords, beginTime, endTime, jobStatus, alarmType, alarmContent, dataScope, userId); + return alarmJobList; } @Override @@ -86,9 +94,9 @@ } @Override - public List> jobListDelayRe(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope,Long userId) { + public List> jobListDelayRe(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId) { alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListDelayRe(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope,userId); + List> alarmJobList = this.baseMapper.jobListDelayRe(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope, userId); return alarmJobList; } @@ -100,9 +108,9 @@ } @Override - public List> jobListDelayPro(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope,Long userId) { + public List> jobListDelayPro(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId) { alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListDelayPro(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope,userId); + List> alarmJobList = this.baseMapper.jobListDelayPro(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope, userId); return alarmJobList; } @@ -114,109 +122,115 @@ } @Override - public List> jobListSearch(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime, String endTime, String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, String shouldHandleBeginTime, String shouldHandleEndTime, DataScope dataScope,Long userId) { - alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListSearch(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, dataScope,userId); + public List> jobListSearch(Page> page, JobListParam jobListParam, DataScope dataScope, Long userId) { + jobListParam.setAlarmContent(converAlarmContent(jobListParam.getAlarmContent())); + List> alarmJobList = this.baseMapper.jobListSearch(page, jobListParam, dataScope, userId); return alarmJobList; } @Override - public List> jobListSearchApp(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime, String endTime, String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, String shouldHandleBeginTime, String shouldHandleEndTime, Long deptId, Long userId, Long leaderId) { - alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListSearchApp(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, deptId, userId, leaderId); + public List> jobListSearchApp(Page> page, JobListParam jobListParam, Long deptId, Long userId, Long leaderId) { + jobListParam.setAlarmContent(converAlarmContent(jobListParam.getAlarmContent())); + List> alarmJobList = this.baseMapper.jobListSearchApp(page, jobListParam.getKeywords(), + jobListParam.getAlarmLevel(), jobListParam.getAlarmContent(), jobListParam.getJobStatus(), jobListParam.getBeginTime(), + jobListParam.getEndTime(), jobListParam.getGetJobBeginTime(), jobListParam.getGetJobEndTime(), jobListParam.getShouldGetBeginTime(), + jobListParam.getShouldGetEndTime(), jobListParam.getHandleJobBeginTime(), jobListParam.getHandleJobEndTime(), jobListParam.getShouldHandleBeginTime(), + jobListParam.getShouldHandleEndTime(), deptId, userId, leaderId); return alarmJobList; } - private String converAlarmContent(String alarmContent){ - if(ToolUtil.isEmpty(alarmContent)){ + private String converAlarmContent(String alarmContent) { + if (ToolUtil.isEmpty(alarmContent)) { return alarmContent; - }else { + } else { return EhcacheConstant.retBean().getAlarmContentName(Integer.valueOf(alarmContent)); } } @Override - public List> jobInfo(int id, DataScope dataScope, Long personId) - { - List> job = this.baseMapper.jobInfo(id,dataScope,personId); + public List> jobInfo(Long id, DataScope dataScope, Long personId) { + List> job = this.baseMapper.jobInfo(id, dataScope, personId); return job; } @Override - public Map countByJobStatus(long deptId,int spanDays) { - return this.baseMapper.countByJobStatus(deptId,spanDays); + public Map countByJobStatus(long deptId, int spanDays) { + return this.baseMapper.countByJobStatus(deptId, spanDays); } @Override - public Map countMyJob(long userId,long deptId,int spanDays) { - return this.baseMapper.countMyJob(userId,deptId,spanDays); + public Map countMyJob(long userId, long deptId, int spanDays) { + return this.baseMapper.countMyJob(userId, deptId, spanDays); } @Override - public boolean getJob(int id, long personId) { + public boolean getJob(Long id, long personId) { Calendar now = Calendar.getInstance(); Date getTime = now.getTime(); - if(isWeekend(now)){ + if (isWeekend(now)) { now.add(Calendar.WEEK_OF_YEAR, 1); - now.set(Calendar.DAY_OF_WEEK ,Calendar.TUESDAY); - now.set(Calendar.HOUR_OF_DAY,8); - now.set(Calendar.MINUTE,0); - now.set(Calendar.SECOND,0); - }else { + now.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY); + now.set(Calendar.HOUR_OF_DAY, 8); + now.set(Calendar.MINUTE, 0); + now.set(Calendar.SECOND, 0); + } else { now.add(Calendar.HOUR, 24); - while(isWeekend(now)){ + while (isWeekend(now)) { now.add(Calendar.HOUR, 24); } } Date shouldHandleTime = now.getTime(); - if(Boolean.getBoolean(useOverTime)){ + if (Boolean.getBoolean(useOverTime)) { System.out.println(shouldHandleTime); String jobName = "getJobDelay" + id; - Map map = new HashMap<>(); - map.put("jobId",id); - map.put("iAlarmJobService",this); - map.put("iCommonUserService",iCommonUserService); - map.put("iQuartzManager",quartzManager); - map.put("webSocket",webSocket); - quartzManager.addJob(jobName,getDelayJob.class,shouldHandleTime,map); + Map map = new HashMap<>(); + map.put("jobId", id); + map.put("iAlarmJobService", this); + map.put("iCommonUserService", iCommonUserService); + map.put("iQuartzManager", quartzManager); + map.put("webSocket", webSocket); + quartzManager.addJob(jobName, getDelayJob.class, shouldHandleTime, map); } - return this.baseMapper.getJob(id,personId,getTime,shouldHandleTime); + return this.baseMapper.getJob(id, personId, getTime, shouldHandleTime); } - private boolean isWeekend(Calendar cal){ - if(cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY){ + private boolean isWeekend(Calendar cal) { + if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) { return true; - } else{ + } else { return false; } } @Override - public boolean confirmJob(int id,long personId, String firstState, String firstStatePhotos, String needHandle) { - if ("1".equals(needHandle)){ - return this.baseMapper.confirmJob(id,personId, firstState, firstStatePhotos, needHandle); + public boolean confirmJob(Long id, long personId, String firstState, String firstStatePhotos, String needHandle) { + if ("1".equals(needHandle)) { + return this.baseMapper.confirmJob(id, personId, firstState, firstStatePhotos, needHandle); } else { - return this.baseMapper.confirmOverJobAndAlarm(id, personId,firstState, firstStatePhotos); + return this.baseMapper.confirmOverJobAndAlarm(id, personId, firstState, firstStatePhotos); } } @Override - public boolean transferJob(int id, long transferPerson,String flowRec) { - return this.baseMapper.transferJob(id, transferPerson,flowRec); + public boolean transferJob(Long id, long transferPerson, String flowRec) { + return this.baseMapper.transferJob(id, transferPerson, flowRec); } @Override - public boolean saveJob(int id, String handleMessage, String handlePhotos) { + public boolean saveJob(Long id, String handleMessage, String handlePhotos) { return this.baseMapper.saveJob(id, handleMessage, handlePhotos); } @Override - public boolean overJob(int id,long personId, String handleMessage, String handlePhotos) { - return this.baseMapper.overJobAndAlarm(id, personId,handleMessage, handlePhotos); + public boolean overJob(Long id, long personId, String handleMessage, String handlePhotos) { + + return this.baseMapper.overJobAndAlarm(id, personId, handleMessage, handlePhotos); + // return this.baseMapper.overJob(id, personId,handleMessage, handlePhotos); } + @Override public boolean overAlarm(int jobId) { return this.baseMapper.overAlarm(jobId); @@ -224,15 +238,15 @@ } @Override - public boolean handleJob(int id,long personId) { - return this.baseMapper.handleJob(id,personId); + public boolean handleJob(Long id, long personId) { + return this.baseMapper.handleJob(id, personId); } @Override public boolean checkJobStatus(String jobStatus) { - if(ToolUtil.isEmpty(jobStatus)){ + if (ToolUtil.isEmpty(jobStatus)) { return false; - }else{ + } else { return "1".equals(jobStatus) || "2".equals(jobStatus) || "3".equals(jobStatus); } } @@ -243,10 +257,10 @@ } - public List selectRoles() { return this.baseMapper.selectRoles(); } + public List selectUseIds(List roleIds) { return this.baseMapper.selectUseIds(roleIds); } @@ -255,50 +269,50 @@ public boolean checkPcRole(List roleTips) { List roleList = new ArrayList<>(roleTips); Iterator it = roleList.iterator(); - while (it.hasNext()){ + while (it.hasNext()) { String role = it.next(); - if(role.equals(sApp)||role.equals(sLeader)||role.equals(sMember)){ + if (role.equals(sApp) || role.equals(sLeader) || role.equals(sMember)) { it.remove(); } } - return roleList.size()>0; + return roleList.size() > 0; } @Override - public Integer countByDataScope(DataScope dataScope, String alarmType, String jobStatus, String beginTime,String endTime) { - List> res = this.baseMapper.countByDataScope(dataScope,alarmType,jobStatus,beginTime,endTime); + public Integer countByDataScope(DataScope dataScope, String alarmType, String jobStatus, String beginTime, String endTime) { + List> res = this.baseMapper.countByDataScope(dataScope, alarmType, jobStatus, beginTime, endTime); return res.size(); } @Override - public Integer countByResponse(String alarmType, String jobStatus, Long deptId, String beginTime,String endTime) { - return this.baseMapper.countByResponse(alarmType,jobStatus,deptId,beginTime,endTime); + public Integer countByResponse(String alarmType, String jobStatus, Long deptId, String beginTime, String endTime) { + return this.baseMapper.countByResponse(alarmType, jobStatus, deptId, beginTime, endTime); } @Override - public Integer countByUser(String alarmType, String jobStatus, Long userId, String beginTime,String endTime) { - return this.baseMapper.countByUser(alarmType,jobStatus,userId,beginTime,endTime); + public Integer countByUser(String alarmType, String jobStatus, Long userId, String beginTime, String endTime) { + return this.baseMapper.countByUser(alarmType, jobStatus, userId, beginTime, endTime); } @Override - public void updateSinkJob(String id, String msg,String wellCode) { + public void updateSinkJob(String id, String msg, String wellCode) { List userClientViewList = new ArrayList<>(); List selectDtoList = selectRoles(); EntityWrapper busWellInfoEntityWrapper = new EntityWrapper<>(); - busWellInfoEntityWrapper.eq("WELL_CODE",wellCode); + busWellInfoEntityWrapper.eq("WELL_CODE", wellCode); BusWellInfo busWellInfo = busWellInfoService.selectOne(busWellInfoEntityWrapper); - if(busWellInfo!=null&&ToolUtil.isNotEmpty(busWellInfo.getDeptid())){ - List roleids= new ArrayList<>(); - for(SelectDto selectDto:selectDtoList){ - if(ToolUtil.isNotEmpty(selectDto.getName()) - && Arrays.asList(selectDto.getName().split(",")).contains(busWellInfo.getDeptid())){ + if (busWellInfo != null && ToolUtil.isNotEmpty(busWellInfo.getDeptid())) { + List roleids = new ArrayList<>(); + for (SelectDto selectDto : selectDtoList) { + if (ToolUtil.isNotEmpty(selectDto.getName()) + && Arrays.asList(selectDto.getName().split(",")).contains(busWellInfo.getDeptid())) { roleids.add(selectDto.getId()); } } - if(roleids.size()>0){ + if (roleids.size() > 0) { List useIds = selectUseIds(roleids); - for(Long useId:useIds){ + for (Long useId : useIds) { UserClientView userClientView = new UserClientView(); userClientView.setClientid(useId.toString()); userClientView.setId(useId.toString()); @@ -307,11 +321,11 @@ } } - if(!("null".equals(id))){ + if (!("null".equals(id))) { AlarmJob alarmJob = this.baseMapper.selectById(id); sendJob(id, alarmJob, userClientViewList);//推送工单至app和pc端 } - if(StringUtils.isNotBlank(msg)){ + if (StringUtils.isNotBlank(msg)) { sendAlarm(msg, userClientViewList);//推送告警至app和pc端 } @@ -386,7 +400,7 @@ } Date shouldHandleTime = now.getTime(); - if(Boolean.getBoolean(useOverTime)) { + if (Boolean.getBoolean(useOverTime)) { System.out.println(shouldHandleTime); String jobName = "getJobDelay" + id; Map map = new HashMap<>(); @@ -437,4 +451,40 @@ public String selectClientIdByUser(Long userId) { return this.baseMapper.selectClientIdByUser(userId); } + + + public AlarmJob saveData(String devCode, String wellCode, String devTypeName, String jobType) { + AlarmJob alarmJob = new AlarmJob(); + alarmJob.setDevcode(devCode); + alarmJob.setWellCode(wellCode); + alarmJob.setJobStatus("0"); + alarmJob.setCreateTime(new Date()); + alarmJob.setJobcode(this.produceJobCode(devTypeName)); + alarmJob.setJobType(jobType); + this.baseMapper.insert(alarmJob); + return alarmJob; + } + + /** + * 前缀+日期+4位流水号 + * + * @param devTypeName + * @return + */ + private String produceJobCode(String devTypeName) { + String pre = devTypeName; + String dataStr = sdf6.format(new Date()); + String fix = this.getJobCodeMaxSerial(pre + dataStr); + return StringUtils.isNotBlank(fix) ? pre + dataStr + String.format("%04d", Long.valueOf(fix) + 1L) : pre + dataStr + "0001"; + } + + + private String getJobCodeMaxSerial(String jobcode) { + String MaxSerialJobCode = this.baseMapper.getJobCodeMaxSerial(jobcode); + String fix = ""; + if (null != MaxSerialJobCode && MaxSerialJobCode.length() > 4) { + fix = MaxSerialJobCode.substring(MaxSerialJobCode.length() - 4); + } + return fix; + } } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmRecordsServiceImpl.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmRecordsServiceImpl.java index e0f0959..60fa41a 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmRecordsServiceImpl.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmRecordsServiceImpl.java @@ -16,7 +16,7 @@ /** *

- * 服务实现类 + * 服务实现类 *

* * @author casic123 @@ -27,12 +27,12 @@ @Override - public List> alarmList(Page> page, String keywords, String beginTime, String endTime, String status, String alarmType, String alarmContent, String areaId, DataScope dataScope) { + public List> alarmList(Page> page, String keywords, String beginTime, String endTime, String status, String alarmType, String alarmContent, String areaId, DataScope dataScope) { String sContent = null; - if (ToolUtil.isNotEmpty(alarmContent)){ + if (ToolUtil.isNotEmpty(alarmContent)) { sContent = EhcacheConstant.retBean().getAlarmContentName(Integer.valueOf(alarmContent)); } - return this.baseMapper.alarmList(page,keywords,beginTime,endTime,status,alarmType,sContent, areaId, dataScope); + return this.baseMapper.alarmList(page, keywords, beginTime, endTime, status, alarmType, sContent, areaId, dataScope); } /** @@ -41,15 +41,15 @@ @Override public List alarmListNoPage(DataScope dataScope, String keywords, String alarmType, String alarmContent, String beginTime, String endTime, String areaId) { String sContent = null; - if (ToolUtil.isNotEmpty(alarmContent)){ + if (ToolUtil.isNotEmpty(alarmContent)) { sContent = EhcacheConstant.retBean().getAlarmContentName(Integer.valueOf(alarmContent)); } - return this.baseMapper.alarmListNoPage(dataScope,keywords,alarmType,sContent,beginTime,endTime, areaId); + return this.baseMapper.alarmListNoPage(dataScope, keywords, alarmType, sContent, beginTime, endTime, areaId); } @Override public boolean cancelAlarm(long id, String jobStatus, String handleMessage, long personId) { - return this.baseMapper.cancelAlarm(id,jobStatus,handleMessage,personId); + return this.baseMapper.cancelAlarm(id, jobStatus, handleMessage, personId); } @Override @@ -62,4 +62,15 @@ // this.baseMapper.cancelAlarmByNewRecord(alarmRec.getDevcode(), alarmRec.getAlarmType()); return this.baseMapper.insert(alarmRec); } + + public Boolean isOldAlarmRecord(String devCode, String MsgContent) { + if (this.baseMapper.isOldAlarmRecord(devCode, MsgContent) == null) { + return false; + } + return true; + } + + public Integer updateOldAlarmRecord(String devCode, String MsgContent) { + return this.baseMapper.updateOldAlarmRecord(devCode, MsgContent); + } } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/AlarmMapOverviewController.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/AlarmMapOverviewController.java index 9d60185..214c275 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/AlarmMapOverviewController.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/AlarmMapOverviewController.java @@ -8,14 +8,12 @@ import com.casic.missiles.core.exception.GunsExceptionEnum; import com.casic.missiles.core.base.response.SuccessResponseData; import com.casic.missiles.core.util.ToolUtil; -import com.casic.missiles.modular.system.constant.ModularDictConst; import com.casic.missiles.modular.system.dto.AlarmNowView; import com.casic.missiles.modular.system.dto.DeviceDto; import com.casic.missiles.modular.system.model.BusWellInfo; import com.casic.missiles.modular.system.service.IAlarmNowViewService; import com.casic.missiles.modular.system.service.IBusWellInfoService; import com.casic.missiles.modular.system.service.IDeviceService; -import com.casic.missiles.modular.system.service.impl.BusWellInfoServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataReceiver.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataReceiver.java index 0013989..b3f23d5 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataReceiver.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataReceiver.java @@ -2,6 +2,7 @@ import com.casic.missiles.core.base.controller.BaseController; import com.casic.missiles.core.base.response.ResponseData; +import com.casic.missiles.modular.alarm.service.IAlarmJobService; import com.casic.missiles.modular.alarm.service.IAlarmRecordsService; import com.casic.missiles.modular.alarm.service.IAlarmRuleService; import com.casic.missiles.modular.system.dto.DeviceWellDto; @@ -9,6 +10,7 @@ import com.casic.missiles.modular.system.service.IDeviceService; import com.casic.missiles.modular.system.service.IGasFlowDataService; import lombok.extern.java.Log; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -38,6 +40,9 @@ @Resource private IAlarmRecordsService alarmRecordsService; + @Autowired + IAlarmJobService alarmJobService; + private DecimalFormat df2 = new DecimalFormat("0.00"); @RequestMapping(value = "/data/recv") @@ -117,6 +122,13 @@ alarmRecord.setAlarmTime(Calendar.getInstance().getTime()); alarmRecord.setStatus("1"); alarmRecord.setAlarmMessage("日用气量超阈值报警"); + if (alarmRecordsService.isOldAlarmRecord(gasFlowAddr, "日用气量超阈值报警")) { + alarmRecordsService.updateOldAlarmRecord(gasFlowAddr, "日用气量超阈值报警"); + } else { + AlarmJob alarmJob = alarmJobService.saveData(gasFlowAddr, wellDto.getWellCode(), "SLCX", "1"); + alarmRecord.setJobId(alarmJob.getId()); + } + alarmRecordsService.insertAlarmRecord(alarmRecord); // 向前端推送报警 } else { @@ -134,6 +146,13 @@ alarmRecord.setAlarmTime(Calendar.getInstance().getTime()); alarmRecord.setStatus("1"); alarmRecord.setAlarmMessage("日用气量超阈值预警"); + alarmRecord.setAlarmMessage("日用水量超阈值预警"); + if (alarmRecordsService.isOldAlarmRecord(gasFlowAddr, "日用水量超阈值预警")) { + alarmRecordsService.updateOldAlarmRecord(gasFlowAddr, "日用水量超阈值预警"); + } else { + AlarmJob alarmJob = alarmJobService.saveData(gasFlowAddr, wellDto.getWellCode(), "SLCX", "1"); + alarmRecord.setJobId(alarmJob.getId()); + } alarmRecordsService.insertAlarmRecord(alarmRecord); // 向前端推送报警 } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataReceiver.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataReceiver.java index 6c25e18..200f5d2 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataReceiver.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataReceiver.java @@ -2,16 +2,15 @@ import com.casic.missiles.core.base.controller.BaseController; import com.casic.missiles.core.base.response.ResponseData; +import com.casic.missiles.modular.alarm.service.IAlarmJobService; import com.casic.missiles.modular.alarm.service.IAlarmRecordsService; import com.casic.missiles.modular.alarm.service.IAlarmRuleService; import com.casic.missiles.modular.system.dto.DeviceWellDto; -import com.casic.missiles.modular.system.model.AlarmRecords; -import com.casic.missiles.modular.system.model.AlarmRule; -import com.casic.missiles.modular.system.model.DataWaterMeter; -import com.casic.missiles.modular.system.model.Device; +import com.casic.missiles.modular.system.model.*; import com.casic.missiles.modular.system.service.IDeviceService; import com.casic.missiles.modular.system.service.IWaterMeterDataService; import lombok.extern.java.Log; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -40,6 +39,9 @@ @Resource private IAlarmRecordsService alarmRecordsService; + @Autowired + IAlarmJobService alarmJobService; + private DecimalFormat df2 = new DecimalFormat("0.00"); @RequestMapping(value = "/data/recv") @@ -106,7 +108,6 @@ if (flowAccToday - alarmRule.getHighvalue() > 0) { // 超出报警阈值 生成一条报警消息 AlarmRecords alarmRecord = new AlarmRecords(); - alarmRecord.setDeviceId(device.getId()); alarmRecord.setDevcode(meterAddr); alarmRecord.setWellCode(wellDto.getWellCode()); @@ -116,17 +117,19 @@ alarmRecord.setAlarmTime(Calendar.getInstance().getTime()); alarmRecord.setStatus("1"); alarmRecord.setAlarmMessage("日用水量超阈值报警"); - + if (alarmRecordsService.isOldAlarmRecord(meterAddr, "日用水量超阈值报警")) { + alarmRecordsService.updateOldAlarmRecord(meterAddr, "日用水量超阈值报警"); + } else { + AlarmJob alarmJob = alarmJobService.saveData(meterAddr, wellDto.getWellCode(), "QLCX", "1"); + alarmRecord.setJobId(alarmJob.getId()); + } alarmRecordsService.insertAlarmRecord(alarmRecord); - - // 向前端推送报警 } else { // 如果没有报警则判断是否预警 if (null != alarmRuleWarn && null != alarmRuleWarn.getHighvalue()) { if (flowAccToday - alarmRuleWarn.getHighvalue() > 0) { // 超出预警阈值 生成一条预警消息 AlarmRecords alarmRecord = new AlarmRecords(); - alarmRecord.setDeviceId(device.getId()); alarmRecord.setDevcode(meterAddr); alarmRecord.setWellCode(wellDto.getWellCode()); @@ -136,10 +139,13 @@ alarmRecord.setAlarmTime(Calendar.getInstance().getTime()); alarmRecord.setStatus("1"); alarmRecord.setAlarmMessage("日用水量超阈值预警"); - + if (alarmRecordsService.isOldAlarmRecord(meterAddr, "日用水量超阈值预警")) { + alarmRecordsService.updateOldAlarmRecord(meterAddr, "日用水量超阈值预警"); + } else { + AlarmJob alarmJob = alarmJobService.saveData(meterAddr, wellDto.getWellCode(), "QLCX", "1"); + alarmRecord.setJobId(alarmJob.getId()); + } alarmRecordsService.insertAlarmRecord(alarmRecord); - - // 向前端推送报警 } } } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java index 46bb487..d27afa9 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java @@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.plugins.Page; import com.casic.missiles.core.base.response.ResponseData; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.alarm.service.IAlarmJobService; import com.casic.missiles.core.common.service.ICommonPermissionService; import com.casic.missiles.core.datascope.DataScope; @@ -12,12 +13,14 @@ import com.casic.missiles.modular.system.warpper.AlarmJobWarpper; import com.casic.missiles.core.base.controller.BaseController; import com.casic.missiles.core.common.constant.factory.PageFactory; +import lombok.extern.slf4j.Slf4j; import org.hswebframework.expands.office.excel.ExcelIO; import org.json.JSONException; import org.json.JSONObject; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; @@ -29,6 +32,7 @@ import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.*; //import com.casic.missiles.core.base.response.ResponseData; @@ -40,6 +44,7 @@ * @Date 2019-05-17 10:48:36 */ @Controller +@Slf4j @RequestMapping("/job") public class AlarmJobController extends BaseController { @@ -65,6 +70,13 @@ private String templatePath; + /** + * 工单状态接口统计 + * + * @param httpServletRequest + * @return + * @throws ParseException + */ @RequestMapping(value = "/countByJobStatus") @ResponseBody public Object countByJobStatus(HttpServletRequest httpServletRequest) throws ParseException { @@ -117,7 +129,7 @@ } /** - * 获取分页列表 + * 获取工单分页列表 */ @RequestMapping(value = "/list") @ResponseBody @@ -164,30 +176,26 @@ */ @RequestMapping(value = "/searchList") @ResponseBody - public Object jobListSearch(String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime, String endTime, - String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, - String handleJobBeginTime, String handleJobEndTime, String shouldHandleBeginTime, String shouldHandleEndTime) { + public Object jobListSearch(@RequestBody JobListParam jobListParam) { Page> page = new PageFactory>().defaultPage("createTime", false); DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List> retList = new ArrayList<>(); if (alarmJobService.checkPcRole(currentUser.getRoleTips())) { // pc角色 - retList = alarmJobService.jobListSearch(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, - handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, dataScope, currentUser.getId()); + retList = alarmJobService.jobListSearch(page, jobListParam, dataScope, currentUser.getId()); } else { //app角色 long leaderId = 0L; if (currentUser.getRoleTips().contains(sLeader)) { // 组长,查组内全部 leaderId = currentUser.getId(); - if (ToolUtil.isNotEmpty(jobStatus)) { + if (ToolUtil.isNotEmpty(jobListParam.getJobStatus())) { //learder&&jobStatus=1,2,3时,关闭传入的sort,按sql排序(自己的排在前) - page.setOpenSort(!alarmJobService.checkJobStatus(jobStatus)); + page.setOpenSort(!alarmJobService.checkJobStatus(jobListParam.getJobStatus())); } } - retList = alarmJobService.jobListSearchApp(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, - handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, currentUser.getDeptId(), currentUser.getId(), leaderId); + retList = alarmJobService.jobListSearchApp(page, jobListParam, currentUser.getDeptId(), currentUser.getId(), leaderId); } new AlarmJobWarpper(retList).warp(); @@ -277,26 +285,24 @@ @RequestMapping(value = "/export") public void exportJob(HttpServletRequest httpServletRequest , HttpServletResponse httpServletResponse) throws IOException { - Page> page = new PageFactory>().defaultPage("createTime", false); page.setLimit(maxRowsExcel); page.setSize(maxRowsExcel); page.setSearchCount(false); page.setOffset(0); - String keywords = httpServletRequest.getParameter("keywords"); String beginTime = httpServletRequest.getParameter("beginTime"); String endTime = httpServletRequest.getParameter("endTime"); String jobStatusStr = httpServletRequest.getParameter("jobStatus"); String alarmTypeStr = httpServletRequest.getParameter("alarmType"); String alarmContentStr = httpServletRequest.getParameter("alarmContentType"); - - List> jobExpList = new ArrayList<>(); + log.debug("主题参数---------------" + keywords + "," + beginTime + "," + endTime + "," + jobStatusStr + "," + alarmTypeStr + "," + alarmContentStr); DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - jobExpList = alarmJobService.jobList(page, keywords, beginTime, endTime, jobStatusStr, alarmTypeStr, alarmContentStr, dataScope, currentUser.getId()); + List> jobExpList = alarmJobService.jobList(page, keywords, beginTime, endTime, jobStatusStr, alarmTypeStr, alarmContentStr, dataScope, currentUser.getId()); new AlarmJobWarpper(jobExpList).warp(); FileInputStream fileInputStream = null; + log.debug("----------------" + ToolUtil.isEmpty(jobExpList)); if (ToolUtil.isEmpty(jobExpList)) { fileInputStream = new FileInputStream(templatePath + "/jobRecEmpty.xlsx"); } else { @@ -305,12 +311,10 @@ try { httpServletResponse.setContentType("application/octet-stream"); httpServletResponse.addHeader("Content-Disposition", " attachment;filename=" + "jobOverview.xlsx"); - Map var = new HashMap<>(); var.put("标题", "工单一览表"); var.put("list", jobExpList); ExcelIO.writeTemplate(fileInputStream, httpServletResponse.getOutputStream(), var); - } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { @@ -328,11 +332,11 @@ */ @RequestMapping(value = "/getJob") @ResponseBody - public Object getJob(int id) { + public Object getJob(Long id) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - if (alarmJobService.getJob(id, currentUser.getId())){ + if (alarmJobService.getJob(id, currentUser.getId())) { return ResponseData.success(); } else { return ResponseData.error("接单失败"); @@ -344,10 +348,10 @@ */ @RequestMapping(value = "/confirmJob") @ResponseBody - public Object confirmJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "firstState", required = true) String firstState, - @RequestParam(value = "firstStatePhotos", required = true) String firstStatePhotos, - @RequestParam(value = "needHandle", required = true) String needHandle) { + public Object confirmJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "firstState", required = true) String firstState, + @RequestParam(value = "firstStatePhotos", required = true) String firstStatePhotos, + @RequestParam(value = "needHandle", required = true) String needHandle) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.confirmJob(id, currentUser.getId(), firstState, firstStatePhotos, needHandle)) { return ResponseData.success(); @@ -361,17 +365,19 @@ */ @RequestMapping(value = "/transferJob") @ResponseBody - public Object transferJob(@RequestParam(value = "id", required = true) int id, + public Object transferJob(@RequestParam(value = "id", required = true) Long id, @RequestParam(value = "transferPerson", required = true) String transferPerson) throws JSONException { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - String dbTime = iSysDictService.getDBtime(); +// String dbTime = iSysDictService.getDBtime(); + SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); +// String dbTime = iSysDictService.getDBtime(); + Date dbTime = new Date(); JSONObject jsonObject = new JSONObject(); jsonObject.put("from", currentUser.getName()); jsonObject.put("to", EhcacheConstant.retBean().getUsernameById(Long.valueOf(transferPerson))); - jsonObject.put("time", dbTime); - + jsonObject.put("time", dateFormat.format(dbTime)); if (alarmJobService.transferJob(id, Long.valueOf(transferPerson), jsonObject.toString())) { return ResponseData.success(); } else { @@ -384,9 +390,9 @@ */ @RequestMapping(value = "/saveJob") @ResponseBody - public Object saveJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "handleMessage", required = true) String handleMessage, - @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { + public Object saveJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "handleMessage", required = true) String handleMessage, + @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { if (alarmJobService.saveJob(id, handleMessage, handlePhotos)) { return ResponseData.success(); @@ -400,10 +406,9 @@ */ @RequestMapping(value = "/overJob") @ResponseBody - public Object overJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "handleMessage", required = true) String handleMessage, - @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { - + public Object overJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "handleMessage", required = true) String handleMessage, + @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.overJob(id, currentUser.getId(), handleMessage, handlePhotos)) { @@ -419,7 +424,7 @@ */ @RequestMapping(value = "/handleJob") @ResponseBody - public Object handleJob(@RequestParam(value = "id", required = true) int id) { + public Object handleJob(@RequestParam(value = "id", required = true) Long id) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.handleJob(id, currentUser.getId())) { return ResponseData.success(); @@ -433,12 +438,10 @@ */ @RequestMapping(value = "/info") @ResponseBody - public Object jobInfo(@RequestParam(value = "id", required = true) int id) { - + public Object jobInfo(@RequestParam(value = "id", required = true) long id) { DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List> retList = alarmJobService.jobInfo(id, dataScope, currentUser.getId()); - new AlarmJobWarpper(retList).warp(); return ResponseData.success(retList); } @@ -456,7 +459,7 @@ @RequestParam(value = "wellCode", required = true) String wellCode) { Map retMap = new HashMap<>(); try { - alarmJobService.updateSinkJob(id, URLDecoder.decode(msg, "UTF-8"),wellCode); + alarmJobService.updateSinkJob(id, URLDecoder.decode(msg, "UTF-8"), wellCode); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java index 26a2ba7..df59231 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java @@ -52,6 +52,7 @@ @Autowired private IDeviceService deviceService; + @Value("${smartcity.office.maxRowsExcel}") private int maxRowsExcel; @Value("${smartcity.config.config-path}") @@ -182,7 +183,8 @@ @RequestMapping(value = "/cancelAlarmById") @ResponseBody public Object cancelAlarmById(@RequestParam(value = "alarmId",required = true) long alarmId){ - boolean isCancel = alarmRecordsService.cancelAlarmById(alarmId); + ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); + boolean isCancel = alarmRecordsService.cancelAlarm(alarmId,"4","手动消警",currentUser.getId()); if(isCancel){ return ResponseData.success(); }else { @@ -235,10 +237,10 @@ //根据查询条件查询alarm_record记录 DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); + ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List alarmRecords = alarmRecordsService.alarmListNoPage(dataScope, keywords, alarmType, alarmContent, beginTime, endTime, areaId); - for (AlarmRecords alarmRecord : alarmRecords) { - alarmRecordsService.cancelAlarmById(alarmRecord.getId()); + alarmRecordsService.cancelAlarm(alarmRecord.getJobId(),"4","手动消警",currentUser.getId()); } return ResponseData.success(); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/model/JobListParam.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/model/JobListParam.java new file mode 100644 index 0000000..c83bff8 --- /dev/null +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/model/JobListParam.java @@ -0,0 +1,32 @@ +package com.casic.missiles.modular.alarm.model; + + +import lombok.Data; + +/** + * @author cz + * @date 2022-6-13 17:03 + */ +@Data +public class JobListParam { + /** + * 关键字 + */ + private String keywords; + /** + * 风险等级 + */ + private String alarmLevel; + private String alarmContent; + private String jobStatus; + private String beginTime; + private String endTime; + private String getJobBeginTime; + private String getJobEndTime; + private String shouldGetBeginTime; + private String shouldGetEndTime; + private String handleJobBeginTime; + private String handleJobEndTime; + private String shouldHandleBeginTime; + private String shouldHandleEndTime; +} diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java index d4db8ce..018d095 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java @@ -3,6 +3,7 @@ import com.baomidou.mybatisplus.plugins.Page; import com.baomidou.mybatisplus.service.IService; import com.casic.missiles.core.datascope.DataScope; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.system.dto.UserClientView; import com.casic.missiles.modular.system.model.AlarmJob; @@ -18,42 +19,60 @@ * @since 2019-05-17 */ public interface IAlarmJobService extends IService { - List> jobList( Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType,String alarmContent, DataScope dataScope,Long userId); - List> jobListApp( Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType,String alarmContent,Long deptId,Long userId,Long leaderId); + + List> jobList(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, DataScope dataScope, Long userId); + + List> jobListApp(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, Long deptId, Long userId, Long leaderId); // List jobListExport( Page page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType,String alarmContent, DataScope dataScope); - List> jobListDelayRe( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, DataScope dataScope,Long userId); - List> jobListDelayReApp( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, Long deptId,Long userId,Long leaderId); + List> jobListDelayRe(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId); - List> jobListDelayPro( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, DataScope dataScope,Long userId ); - List> jobListDelayProApp( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, Long deptId,Long userId,Long leaderId); + List> jobListDelayReApp(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, Long deptId, Long userId, Long leaderId); - List> jobListSearch(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime,String endTime, - String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, - String shouldHandleBeginTime, String shouldHandleEndTime, DataScope dataScope,Long userId); - List> jobListSearchApp(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime,String endTime, - String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, - String shouldHandleBeginTime, String shouldHandleEndTime, Long deptId, Long userId, Long leaderId); - List> jobInfo(int id, DataScope dataScope,Long personId); - boolean getJob(int id, long personId); - boolean confirmJob(int id,long personId,String firstState, String firstStatePhotos, String needHandle); - boolean transferJob(int id, long transferPerson,String flowRec); - boolean saveJob( int id,String handleMessage, String handlePhotos); - boolean overJob( int id,long personId, String handleMessage, String handlePhotos); - boolean overAlarm( int id); - boolean handleJob(int id,long personId); + List> jobListDelayPro(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId); - Map countByJobStatus(long deptId,int spanDays); - Map countMyJob(long userId,long deptId,int spanDays); + List> jobListDelayProApp(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, Long deptId, Long userId, Long leaderId); + + List> jobListSearch(Page> page, JobListParam jobListParam, DataScope dataScope, Long userId); + + List> jobListSearchApp(Page> page, JobListParam jobListParam, Long deptId, Long userId, Long leaderId); + + List> jobInfo(Long id, DataScope dataScope, Long personId); + + boolean getJob(Long id, long personId); + + boolean confirmJob(Long id, long personId, String firstState, String firstStatePhotos, String needHandle); + + boolean transferJob(Long id, long transferPerson, String flowRec); + + boolean saveJob(Long id, String handleMessage, String handlePhotos); + + boolean overJob(Long id, long personId, String handleMessage, String handlePhotos); + + boolean overAlarm(int id); + + boolean handleJob(Long id, long personId); + + Map countByJobStatus(long deptId, int spanDays); + + Map countMyJob(long userId, long deptId, int spanDays); boolean checkJobStatus(String jobStatus); + boolean checkPcRole(List roleTips); - Integer countByDataScope(DataScope dataScope,String alarmType, String jobStatus,String beginTime,String endTime); - Integer countByResponse(String alarmType,String jobStatus,Long deptId,String beginTime,String endTime); - Integer countByUser(String alarmType,String jobStatus,Long userId,String beginTime,String endTime); + Integer countByDataScope(DataScope dataScope, String alarmType, String jobStatus, String beginTime, String endTime); - void updateSinkJob(String id,String msg,String wellCode); + Integer countByResponse(String alarmType, String jobStatus, Long deptId, String beginTime, String endTime); + + Integer countByUser(String alarmType, String jobStatus, Long userId, String beginTime, String endTime); + + void updateSinkJob(String id, String msg, String wellCode); + List selectUserByWellCode(String wellCode); + String selectClientIdByUser(Long userId); + + AlarmJob saveData( String devCode, String wellCode, String devTypeName, String jobType); + } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java index 46e7dfe..6eecb2b 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.service.IService; import com.casic.missiles.modular.system.model.AlarmRecords; import com.casic.missiles.core.datascope.DataScope; +import org.apache.ibatis.annotations.Param; import java.util.List; import java.util.Map; @@ -26,4 +27,8 @@ boolean cancelAlarmById(long id); Integer insertAlarmRecord(AlarmRecords alarmRec); + + Boolean isOldAlarmRecord(String devCode,String MsgContent); + + Integer updateOldAlarmRecord(String devCode,String MsgContent); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java index fa6681d..943ebd7 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java @@ -7,12 +7,14 @@ import com.casic.missiles.core.common.service.ICommonUserService; import com.casic.missiles.modular.alarm.job.HandleAlarmJob; import com.casic.missiles.modular.alarm.job.getDelayJob; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.alarm.service.IAlarmJobService; import com.casic.missiles.core.datascope.DataScope; import com.casic.missiles.core.util.EhcacheConstant; import com.casic.missiles.core.util.ToolUtil; import com.casic.missiles.modular.system.dao.AlarmJobMapper; import com.casic.missiles.modular.system.dao.AlarmRecordsMapper; +import com.casic.missiles.modular.system.dto.DeviceTypeEnum; import com.casic.missiles.modular.system.dto.SelectDto; import com.casic.missiles.modular.system.dto.UserClientView; import com.casic.missiles.modular.system.model.AlarmJob; @@ -24,6 +26,8 @@ import com.casic.missiles.quartz.service.IQuartzManager; import com.gexin.rp.sdk.base.IPushResult; import com.google.gson.GsonBuilder; +import net.sf.ehcache.search.Query; +import net.sf.ehcache.search.expression.Criteria; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -48,6 +52,8 @@ public class AlarmJobServiceImpl extends ServiceImpl implements IAlarmJobService { private static final Logger logger = LoggerFactory.getLogger(AlarmJobServiceImpl.class); + public static final SimpleDateFormat sdf6 = new SimpleDateFormat("yyyyMMdd"); + private static Map deviceAlarmMap = new HashMap(); @Value("${smartcity.leaderRoleName}") private String sLeader; @@ -70,12 +76,14 @@ @Resource private IQuartzManager quartzManager; - @Autowired IBusWellInfoService busWellInfoService; + @Autowired + IBusWellInfoService busWellInfoService; @Override - public List> jobList(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, DataScope dataScope,Long userId) { + public List> jobList(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, DataScope dataScope, Long userId) { alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobList(page, keywords, beginTime, endTime, jobStatus, alarmType, alarmContent, dataScope,userId);return alarmJobList; + List> alarmJobList = this.baseMapper.jobList(page, keywords, beginTime, endTime, jobStatus, alarmType, alarmContent, dataScope, userId); + return alarmJobList; } @Override @@ -86,9 +94,9 @@ } @Override - public List> jobListDelayRe(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope,Long userId) { + public List> jobListDelayRe(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId) { alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListDelayRe(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope,userId); + List> alarmJobList = this.baseMapper.jobListDelayRe(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope, userId); return alarmJobList; } @@ -100,9 +108,9 @@ } @Override - public List> jobListDelayPro(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope,Long userId) { + public List> jobListDelayPro(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId) { alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListDelayPro(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope,userId); + List> alarmJobList = this.baseMapper.jobListDelayPro(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope, userId); return alarmJobList; } @@ -114,109 +122,115 @@ } @Override - public List> jobListSearch(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime, String endTime, String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, String shouldHandleBeginTime, String shouldHandleEndTime, DataScope dataScope,Long userId) { - alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListSearch(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, dataScope,userId); + public List> jobListSearch(Page> page, JobListParam jobListParam, DataScope dataScope, Long userId) { + jobListParam.setAlarmContent(converAlarmContent(jobListParam.getAlarmContent())); + List> alarmJobList = this.baseMapper.jobListSearch(page, jobListParam, dataScope, userId); return alarmJobList; } @Override - public List> jobListSearchApp(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime, String endTime, String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, String shouldHandleBeginTime, String shouldHandleEndTime, Long deptId, Long userId, Long leaderId) { - alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListSearchApp(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, deptId, userId, leaderId); + public List> jobListSearchApp(Page> page, JobListParam jobListParam, Long deptId, Long userId, Long leaderId) { + jobListParam.setAlarmContent(converAlarmContent(jobListParam.getAlarmContent())); + List> alarmJobList = this.baseMapper.jobListSearchApp(page, jobListParam.getKeywords(), + jobListParam.getAlarmLevel(), jobListParam.getAlarmContent(), jobListParam.getJobStatus(), jobListParam.getBeginTime(), + jobListParam.getEndTime(), jobListParam.getGetJobBeginTime(), jobListParam.getGetJobEndTime(), jobListParam.getShouldGetBeginTime(), + jobListParam.getShouldGetEndTime(), jobListParam.getHandleJobBeginTime(), jobListParam.getHandleJobEndTime(), jobListParam.getShouldHandleBeginTime(), + jobListParam.getShouldHandleEndTime(), deptId, userId, leaderId); return alarmJobList; } - private String converAlarmContent(String alarmContent){ - if(ToolUtil.isEmpty(alarmContent)){ + private String converAlarmContent(String alarmContent) { + if (ToolUtil.isEmpty(alarmContent)) { return alarmContent; - }else { + } else { return EhcacheConstant.retBean().getAlarmContentName(Integer.valueOf(alarmContent)); } } @Override - public List> jobInfo(int id, DataScope dataScope, Long personId) - { - List> job = this.baseMapper.jobInfo(id,dataScope,personId); + public List> jobInfo(Long id, DataScope dataScope, Long personId) { + List> job = this.baseMapper.jobInfo(id, dataScope, personId); return job; } @Override - public Map countByJobStatus(long deptId,int spanDays) { - return this.baseMapper.countByJobStatus(deptId,spanDays); + public Map countByJobStatus(long deptId, int spanDays) { + return this.baseMapper.countByJobStatus(deptId, spanDays); } @Override - public Map countMyJob(long userId,long deptId,int spanDays) { - return this.baseMapper.countMyJob(userId,deptId,spanDays); + public Map countMyJob(long userId, long deptId, int spanDays) { + return this.baseMapper.countMyJob(userId, deptId, spanDays); } @Override - public boolean getJob(int id, long personId) { + public boolean getJob(Long id, long personId) { Calendar now = Calendar.getInstance(); Date getTime = now.getTime(); - if(isWeekend(now)){ + if (isWeekend(now)) { now.add(Calendar.WEEK_OF_YEAR, 1); - now.set(Calendar.DAY_OF_WEEK ,Calendar.TUESDAY); - now.set(Calendar.HOUR_OF_DAY,8); - now.set(Calendar.MINUTE,0); - now.set(Calendar.SECOND,0); - }else { + now.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY); + now.set(Calendar.HOUR_OF_DAY, 8); + now.set(Calendar.MINUTE, 0); + now.set(Calendar.SECOND, 0); + } else { now.add(Calendar.HOUR, 24); - while(isWeekend(now)){ + while (isWeekend(now)) { now.add(Calendar.HOUR, 24); } } Date shouldHandleTime = now.getTime(); - if(Boolean.getBoolean(useOverTime)){ + if (Boolean.getBoolean(useOverTime)) { System.out.println(shouldHandleTime); String jobName = "getJobDelay" + id; - Map map = new HashMap<>(); - map.put("jobId",id); - map.put("iAlarmJobService",this); - map.put("iCommonUserService",iCommonUserService); - map.put("iQuartzManager",quartzManager); - map.put("webSocket",webSocket); - quartzManager.addJob(jobName,getDelayJob.class,shouldHandleTime,map); + Map map = new HashMap<>(); + map.put("jobId", id); + map.put("iAlarmJobService", this); + map.put("iCommonUserService", iCommonUserService); + map.put("iQuartzManager", quartzManager); + map.put("webSocket", webSocket); + quartzManager.addJob(jobName, getDelayJob.class, shouldHandleTime, map); } - return this.baseMapper.getJob(id,personId,getTime,shouldHandleTime); + return this.baseMapper.getJob(id, personId, getTime, shouldHandleTime); } - private boolean isWeekend(Calendar cal){ - if(cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY){ + private boolean isWeekend(Calendar cal) { + if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) { return true; - } else{ + } else { return false; } } @Override - public boolean confirmJob(int id,long personId, String firstState, String firstStatePhotos, String needHandle) { - if ("1".equals(needHandle)){ - return this.baseMapper.confirmJob(id,personId, firstState, firstStatePhotos, needHandle); + public boolean confirmJob(Long id, long personId, String firstState, String firstStatePhotos, String needHandle) { + if ("1".equals(needHandle)) { + return this.baseMapper.confirmJob(id, personId, firstState, firstStatePhotos, needHandle); } else { - return this.baseMapper.confirmOverJobAndAlarm(id, personId,firstState, firstStatePhotos); + return this.baseMapper.confirmOverJobAndAlarm(id, personId, firstState, firstStatePhotos); } } @Override - public boolean transferJob(int id, long transferPerson,String flowRec) { - return this.baseMapper.transferJob(id, transferPerson,flowRec); + public boolean transferJob(Long id, long transferPerson, String flowRec) { + return this.baseMapper.transferJob(id, transferPerson, flowRec); } @Override - public boolean saveJob(int id, String handleMessage, String handlePhotos) { + public boolean saveJob(Long id, String handleMessage, String handlePhotos) { return this.baseMapper.saveJob(id, handleMessage, handlePhotos); } @Override - public boolean overJob(int id,long personId, String handleMessage, String handlePhotos) { - return this.baseMapper.overJobAndAlarm(id, personId,handleMessage, handlePhotos); + public boolean overJob(Long id, long personId, String handleMessage, String handlePhotos) { + + return this.baseMapper.overJobAndAlarm(id, personId, handleMessage, handlePhotos); + // return this.baseMapper.overJob(id, personId,handleMessage, handlePhotos); } + @Override public boolean overAlarm(int jobId) { return this.baseMapper.overAlarm(jobId); @@ -224,15 +238,15 @@ } @Override - public boolean handleJob(int id,long personId) { - return this.baseMapper.handleJob(id,personId); + public boolean handleJob(Long id, long personId) { + return this.baseMapper.handleJob(id, personId); } @Override public boolean checkJobStatus(String jobStatus) { - if(ToolUtil.isEmpty(jobStatus)){ + if (ToolUtil.isEmpty(jobStatus)) { return false; - }else{ + } else { return "1".equals(jobStatus) || "2".equals(jobStatus) || "3".equals(jobStatus); } } @@ -243,10 +257,10 @@ } - public List selectRoles() { return this.baseMapper.selectRoles(); } + public List selectUseIds(List roleIds) { return this.baseMapper.selectUseIds(roleIds); } @@ -255,50 +269,50 @@ public boolean checkPcRole(List roleTips) { List roleList = new ArrayList<>(roleTips); Iterator it = roleList.iterator(); - while (it.hasNext()){ + while (it.hasNext()) { String role = it.next(); - if(role.equals(sApp)||role.equals(sLeader)||role.equals(sMember)){ + if (role.equals(sApp) || role.equals(sLeader) || role.equals(sMember)) { it.remove(); } } - return roleList.size()>0; + return roleList.size() > 0; } @Override - public Integer countByDataScope(DataScope dataScope, String alarmType, String jobStatus, String beginTime,String endTime) { - List> res = this.baseMapper.countByDataScope(dataScope,alarmType,jobStatus,beginTime,endTime); + public Integer countByDataScope(DataScope dataScope, String alarmType, String jobStatus, String beginTime, String endTime) { + List> res = this.baseMapper.countByDataScope(dataScope, alarmType, jobStatus, beginTime, endTime); return res.size(); } @Override - public Integer countByResponse(String alarmType, String jobStatus, Long deptId, String beginTime,String endTime) { - return this.baseMapper.countByResponse(alarmType,jobStatus,deptId,beginTime,endTime); + public Integer countByResponse(String alarmType, String jobStatus, Long deptId, String beginTime, String endTime) { + return this.baseMapper.countByResponse(alarmType, jobStatus, deptId, beginTime, endTime); } @Override - public Integer countByUser(String alarmType, String jobStatus, Long userId, String beginTime,String endTime) { - return this.baseMapper.countByUser(alarmType,jobStatus,userId,beginTime,endTime); + public Integer countByUser(String alarmType, String jobStatus, Long userId, String beginTime, String endTime) { + return this.baseMapper.countByUser(alarmType, jobStatus, userId, beginTime, endTime); } @Override - public void updateSinkJob(String id, String msg,String wellCode) { + public void updateSinkJob(String id, String msg, String wellCode) { List userClientViewList = new ArrayList<>(); List selectDtoList = selectRoles(); EntityWrapper busWellInfoEntityWrapper = new EntityWrapper<>(); - busWellInfoEntityWrapper.eq("WELL_CODE",wellCode); + busWellInfoEntityWrapper.eq("WELL_CODE", wellCode); BusWellInfo busWellInfo = busWellInfoService.selectOne(busWellInfoEntityWrapper); - if(busWellInfo!=null&&ToolUtil.isNotEmpty(busWellInfo.getDeptid())){ - List roleids= new ArrayList<>(); - for(SelectDto selectDto:selectDtoList){ - if(ToolUtil.isNotEmpty(selectDto.getName()) - && Arrays.asList(selectDto.getName().split(",")).contains(busWellInfo.getDeptid())){ + if (busWellInfo != null && ToolUtil.isNotEmpty(busWellInfo.getDeptid())) { + List roleids = new ArrayList<>(); + for (SelectDto selectDto : selectDtoList) { + if (ToolUtil.isNotEmpty(selectDto.getName()) + && Arrays.asList(selectDto.getName().split(",")).contains(busWellInfo.getDeptid())) { roleids.add(selectDto.getId()); } } - if(roleids.size()>0){ + if (roleids.size() > 0) { List useIds = selectUseIds(roleids); - for(Long useId:useIds){ + for (Long useId : useIds) { UserClientView userClientView = new UserClientView(); userClientView.setClientid(useId.toString()); userClientView.setId(useId.toString()); @@ -307,11 +321,11 @@ } } - if(!("null".equals(id))){ + if (!("null".equals(id))) { AlarmJob alarmJob = this.baseMapper.selectById(id); sendJob(id, alarmJob, userClientViewList);//推送工单至app和pc端 } - if(StringUtils.isNotBlank(msg)){ + if (StringUtils.isNotBlank(msg)) { sendAlarm(msg, userClientViewList);//推送告警至app和pc端 } @@ -386,7 +400,7 @@ } Date shouldHandleTime = now.getTime(); - if(Boolean.getBoolean(useOverTime)) { + if (Boolean.getBoolean(useOverTime)) { System.out.println(shouldHandleTime); String jobName = "getJobDelay" + id; Map map = new HashMap<>(); @@ -437,4 +451,40 @@ public String selectClientIdByUser(Long userId) { return this.baseMapper.selectClientIdByUser(userId); } + + + public AlarmJob saveData(String devCode, String wellCode, String devTypeName, String jobType) { + AlarmJob alarmJob = new AlarmJob(); + alarmJob.setDevcode(devCode); + alarmJob.setWellCode(wellCode); + alarmJob.setJobStatus("0"); + alarmJob.setCreateTime(new Date()); + alarmJob.setJobcode(this.produceJobCode(devTypeName)); + alarmJob.setJobType(jobType); + this.baseMapper.insert(alarmJob); + return alarmJob; + } + + /** + * 前缀+日期+4位流水号 + * + * @param devTypeName + * @return + */ + private String produceJobCode(String devTypeName) { + String pre = devTypeName; + String dataStr = sdf6.format(new Date()); + String fix = this.getJobCodeMaxSerial(pre + dataStr); + return StringUtils.isNotBlank(fix) ? pre + dataStr + String.format("%04d", Long.valueOf(fix) + 1L) : pre + dataStr + "0001"; + } + + + private String getJobCodeMaxSerial(String jobcode) { + String MaxSerialJobCode = this.baseMapper.getJobCodeMaxSerial(jobcode); + String fix = ""; + if (null != MaxSerialJobCode && MaxSerialJobCode.length() > 4) { + fix = MaxSerialJobCode.substring(MaxSerialJobCode.length() - 4); + } + return fix; + } } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmRecordsServiceImpl.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmRecordsServiceImpl.java index e0f0959..60fa41a 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmRecordsServiceImpl.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmRecordsServiceImpl.java @@ -16,7 +16,7 @@ /** *

- * 服务实现类 + * 服务实现类 *

* * @author casic123 @@ -27,12 +27,12 @@ @Override - public List> alarmList(Page> page, String keywords, String beginTime, String endTime, String status, String alarmType, String alarmContent, String areaId, DataScope dataScope) { + public List> alarmList(Page> page, String keywords, String beginTime, String endTime, String status, String alarmType, String alarmContent, String areaId, DataScope dataScope) { String sContent = null; - if (ToolUtil.isNotEmpty(alarmContent)){ + if (ToolUtil.isNotEmpty(alarmContent)) { sContent = EhcacheConstant.retBean().getAlarmContentName(Integer.valueOf(alarmContent)); } - return this.baseMapper.alarmList(page,keywords,beginTime,endTime,status,alarmType,sContent, areaId, dataScope); + return this.baseMapper.alarmList(page, keywords, beginTime, endTime, status, alarmType, sContent, areaId, dataScope); } /** @@ -41,15 +41,15 @@ @Override public List alarmListNoPage(DataScope dataScope, String keywords, String alarmType, String alarmContent, String beginTime, String endTime, String areaId) { String sContent = null; - if (ToolUtil.isNotEmpty(alarmContent)){ + if (ToolUtil.isNotEmpty(alarmContent)) { sContent = EhcacheConstant.retBean().getAlarmContentName(Integer.valueOf(alarmContent)); } - return this.baseMapper.alarmListNoPage(dataScope,keywords,alarmType,sContent,beginTime,endTime, areaId); + return this.baseMapper.alarmListNoPage(dataScope, keywords, alarmType, sContent, beginTime, endTime, areaId); } @Override public boolean cancelAlarm(long id, String jobStatus, String handleMessage, long personId) { - return this.baseMapper.cancelAlarm(id,jobStatus,handleMessage,personId); + return this.baseMapper.cancelAlarm(id, jobStatus, handleMessage, personId); } @Override @@ -62,4 +62,15 @@ // this.baseMapper.cancelAlarmByNewRecord(alarmRec.getDevcode(), alarmRec.getAlarmType()); return this.baseMapper.insert(alarmRec); } + + public Boolean isOldAlarmRecord(String devCode, String MsgContent) { + if (this.baseMapper.isOldAlarmRecord(devCode, MsgContent) == null) { + return false; + } + return true; + } + + public Integer updateOldAlarmRecord(String devCode, String MsgContent) { + return this.baseMapper.updateOldAlarmRecord(devCode, MsgContent); + } } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/AlarmMapOverviewController.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/AlarmMapOverviewController.java index 9d60185..214c275 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/AlarmMapOverviewController.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/AlarmMapOverviewController.java @@ -8,14 +8,12 @@ import com.casic.missiles.core.exception.GunsExceptionEnum; import com.casic.missiles.core.base.response.SuccessResponseData; import com.casic.missiles.core.util.ToolUtil; -import com.casic.missiles.modular.system.constant.ModularDictConst; import com.casic.missiles.modular.system.dto.AlarmNowView; import com.casic.missiles.modular.system.dto.DeviceDto; import com.casic.missiles.modular.system.model.BusWellInfo; import com.casic.missiles.modular.system.service.IAlarmNowViewService; import com.casic.missiles.modular.system.service.IBusWellInfoService; import com.casic.missiles.modular.system.service.IDeviceService; -import com.casic.missiles.modular.system.service.impl.BusWellInfoServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataReceiver.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataReceiver.java index 0013989..b3f23d5 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataReceiver.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataReceiver.java @@ -2,6 +2,7 @@ import com.casic.missiles.core.base.controller.BaseController; import com.casic.missiles.core.base.response.ResponseData; +import com.casic.missiles.modular.alarm.service.IAlarmJobService; import com.casic.missiles.modular.alarm.service.IAlarmRecordsService; import com.casic.missiles.modular.alarm.service.IAlarmRuleService; import com.casic.missiles.modular.system.dto.DeviceWellDto; @@ -9,6 +10,7 @@ import com.casic.missiles.modular.system.service.IDeviceService; import com.casic.missiles.modular.system.service.IGasFlowDataService; import lombok.extern.java.Log; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -38,6 +40,9 @@ @Resource private IAlarmRecordsService alarmRecordsService; + @Autowired + IAlarmJobService alarmJobService; + private DecimalFormat df2 = new DecimalFormat("0.00"); @RequestMapping(value = "/data/recv") @@ -117,6 +122,13 @@ alarmRecord.setAlarmTime(Calendar.getInstance().getTime()); alarmRecord.setStatus("1"); alarmRecord.setAlarmMessage("日用气量超阈值报警"); + if (alarmRecordsService.isOldAlarmRecord(gasFlowAddr, "日用气量超阈值报警")) { + alarmRecordsService.updateOldAlarmRecord(gasFlowAddr, "日用气量超阈值报警"); + } else { + AlarmJob alarmJob = alarmJobService.saveData(gasFlowAddr, wellDto.getWellCode(), "SLCX", "1"); + alarmRecord.setJobId(alarmJob.getId()); + } + alarmRecordsService.insertAlarmRecord(alarmRecord); // 向前端推送报警 } else { @@ -134,6 +146,13 @@ alarmRecord.setAlarmTime(Calendar.getInstance().getTime()); alarmRecord.setStatus("1"); alarmRecord.setAlarmMessage("日用气量超阈值预警"); + alarmRecord.setAlarmMessage("日用水量超阈值预警"); + if (alarmRecordsService.isOldAlarmRecord(gasFlowAddr, "日用水量超阈值预警")) { + alarmRecordsService.updateOldAlarmRecord(gasFlowAddr, "日用水量超阈值预警"); + } else { + AlarmJob alarmJob = alarmJobService.saveData(gasFlowAddr, wellDto.getWellCode(), "SLCX", "1"); + alarmRecord.setJobId(alarmJob.getId()); + } alarmRecordsService.insertAlarmRecord(alarmRecord); // 向前端推送报警 } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataReceiver.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataReceiver.java index 6c25e18..200f5d2 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataReceiver.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataReceiver.java @@ -2,16 +2,15 @@ import com.casic.missiles.core.base.controller.BaseController; import com.casic.missiles.core.base.response.ResponseData; +import com.casic.missiles.modular.alarm.service.IAlarmJobService; import com.casic.missiles.modular.alarm.service.IAlarmRecordsService; import com.casic.missiles.modular.alarm.service.IAlarmRuleService; import com.casic.missiles.modular.system.dto.DeviceWellDto; -import com.casic.missiles.modular.system.model.AlarmRecords; -import com.casic.missiles.modular.system.model.AlarmRule; -import com.casic.missiles.modular.system.model.DataWaterMeter; -import com.casic.missiles.modular.system.model.Device; +import com.casic.missiles.modular.system.model.*; import com.casic.missiles.modular.system.service.IDeviceService; import com.casic.missiles.modular.system.service.IWaterMeterDataService; import lombok.extern.java.Log; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -40,6 +39,9 @@ @Resource private IAlarmRecordsService alarmRecordsService; + @Autowired + IAlarmJobService alarmJobService; + private DecimalFormat df2 = new DecimalFormat("0.00"); @RequestMapping(value = "/data/recv") @@ -106,7 +108,6 @@ if (flowAccToday - alarmRule.getHighvalue() > 0) { // 超出报警阈值 生成一条报警消息 AlarmRecords alarmRecord = new AlarmRecords(); - alarmRecord.setDeviceId(device.getId()); alarmRecord.setDevcode(meterAddr); alarmRecord.setWellCode(wellDto.getWellCode()); @@ -116,17 +117,19 @@ alarmRecord.setAlarmTime(Calendar.getInstance().getTime()); alarmRecord.setStatus("1"); alarmRecord.setAlarmMessage("日用水量超阈值报警"); - + if (alarmRecordsService.isOldAlarmRecord(meterAddr, "日用水量超阈值报警")) { + alarmRecordsService.updateOldAlarmRecord(meterAddr, "日用水量超阈值报警"); + } else { + AlarmJob alarmJob = alarmJobService.saveData(meterAddr, wellDto.getWellCode(), "QLCX", "1"); + alarmRecord.setJobId(alarmJob.getId()); + } alarmRecordsService.insertAlarmRecord(alarmRecord); - - // 向前端推送报警 } else { // 如果没有报警则判断是否预警 if (null != alarmRuleWarn && null != alarmRuleWarn.getHighvalue()) { if (flowAccToday - alarmRuleWarn.getHighvalue() > 0) { // 超出预警阈值 生成一条预警消息 AlarmRecords alarmRecord = new AlarmRecords(); - alarmRecord.setDeviceId(device.getId()); alarmRecord.setDevcode(meterAddr); alarmRecord.setWellCode(wellDto.getWellCode()); @@ -136,10 +139,13 @@ alarmRecord.setAlarmTime(Calendar.getInstance().getTime()); alarmRecord.setStatus("1"); alarmRecord.setAlarmMessage("日用水量超阈值预警"); - + if (alarmRecordsService.isOldAlarmRecord(meterAddr, "日用水量超阈值预警")) { + alarmRecordsService.updateOldAlarmRecord(meterAddr, "日用水量超阈值预警"); + } else { + AlarmJob alarmJob = alarmJobService.saveData(meterAddr, wellDto.getWellCode(), "QLCX", "1"); + alarmRecord.setJobId(alarmJob.getId()); + } alarmRecordsService.insertAlarmRecord(alarmRecord); - - // 向前端推送报警 } } } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmJobMapper.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmJobMapper.java index 6592517..ccdff9a 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmJobMapper.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmJobMapper.java @@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.mapper.BaseMapper; import com.baomidou.mybatisplus.plugins.Page; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.system.dto.SelectDto; import com.casic.missiles.modular.system.dto.UserClientView; import com.casic.missiles.modular.system.model.AlarmJob; @@ -21,44 +22,65 @@ * @since 2019-05-17 */ public interface AlarmJobMapper extends BaseMapper { - List> jobList(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("jobStatus") String jobStatus, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("dataScope") DataScope dataScope,@Param("userId")Long userId); - List> jobListApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("jobStatus") String jobStatus, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("deptId")Long deptId,@Param("userId")Long userId,@Param("leaderId")Long leaderId); + List> jobList(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("jobStatus") String jobStatus, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("dataScope") DataScope dataScope, @Param("userId") Long userId); + + List> jobListApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("jobStatus") String jobStatus, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("deptId") Long deptId, @Param("userId") Long userId, @Param("leaderId") Long leaderId); + // List jobListExport(@Param("page") Page page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("jobStatus") String jobStatus, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("dataScope") DataScope dataScope); - List> jobListDelayRe(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("dataScope") DataScope dataScope,@Param("userId")Long userId); - List> jobListDelayReApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("deptId")Long deptId,@Param("userId")Long userId,@Param("leaderId")Long leaderId); + List> jobListDelayRe(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("dataScope") DataScope dataScope, @Param("userId") Long userId); - List> jobListDelayPro(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("dataScope") DataScope dataScope,@Param("userId")Long userId); - List> jobListDelayProApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("deptId")Long deptId,@Param("userId")Long userId,@Param("leaderId")Long leaderId); + List> jobListDelayReApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("deptId") Long deptId, @Param("userId") Long userId, @Param("leaderId") Long leaderId); - List> jobListSearchApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("alarmLevel")String alarmLevel, @Param("alarmContent") String alarmContent, @Param("jobStatus") String jobStatus, @Param("beginTime") String beginTime, @Param("endTime") String endTime, - @Param("getJobBeginTime") String getJobBeginTime, @Param("getJobEndTime") String getJobEndTime, @Param("shouldGetBeginTime") String shouldGetBeginTime, @Param("shouldGetEndTime") String shouldGetEndTime, - @Param("handleJobBeginTime") String handleJobBeginTime, @Param("handleJobEndTime") String handleJobEndTime, @Param("shouldHandleBeginTime") String shouldHandleBeginTime, @Param("shouldHandleEndTime") String shouldHandleEndTime, - @Param("deptId")Long deptId, @Param("userId")Long userId, @Param("leaderId")Long leaderId); - List> jobListSearch(@Param("page") Page> page, @Param("keywords") String keywords, @Param("alarmLevel")String alarmLevel, @Param("alarmContent") String alarmContent, @Param("jobStatus") String jobStatus, @Param("beginTime") String beginTime, @Param("endTime") String endTime, - @Param("getJobBeginTime") String getJobBeginTime, @Param("getJobEndTime") String getJobEndTime, @Param("shouldGetBeginTime") String shouldGetBeginTime, @Param("shouldGetEndTime") String shouldGetEndTime, - @Param("handleJobBeginTime") String handleJobBeginTime, @Param("handleJobEndTime") String handleJobEndTime, @Param("shouldHandleBeginTime") String shouldHandleBeginTime, @Param("shouldHandleEndTime") String shouldHandleEndTime, - @Param("dataScope") DataScope dataScope,@Param("userId")Long userId); + List> jobListDelayPro(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("dataScope") DataScope dataScope, @Param("userId") Long userId); - Map countByJobStatus(@Param("deptId")long deptId,@Param("spanDays") int spanDays); - Map countMyJob(@Param("userId")long userId,@Param("deptId")long deptId,@Param("spanDays") int spanDays); - List> jobInfo(@Param("id") int id,@Param("dataScope") DataScope dataScope,@Param("personId") Long personId); -// boolean getJob(@Param("id") int id,@Param("personId") long personId); - boolean getJob(@Param("id") int id,@Param("personId") long personId,@Param("getTime")Date getTime ,@Param("shouldHandleTime")Date shouldHandleTime); - boolean confirmJob(@Param("id") int id,@Param("personId") long personId,@Param("firstState") String firstState,@Param("firstStatePhotos") String firstStatePhotos,@Param("needHandle") String needHandle); - boolean confirmOverJobAndAlarm(@Param("id") int id,@Param("personId") long personId,@Param("firstState") String firstState,@Param("firstStatePhotos") String firstStatePhotos); - boolean transferJob(@Param("id") int id,@Param("transferPerson") long transferPerson,@Param("flowRec") String flowRec); - boolean saveJob(@Param("id") int id,@Param("handleMessage") String handleMessage,@Param("handlePhotos") String handlePhotos); - boolean overJob(@Param("id") int id,@Param("personId") long personId,@Param("handleMessage") String handleMessage,@Param("handlePhotos") String handlePhotos); + List> jobListDelayProApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("deptId") Long deptId, @Param("userId") Long userId, @Param("leaderId") Long leaderId); + + List> jobListSearchApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("alarmLevel") String alarmLevel, @Param("alarmContent") String alarmContent, @Param("jobStatus") String jobStatus, @Param("beginTime") String beginTime, @Param("endTime") String endTime, + @Param("getJobBeginTime") String getJobBeginTime, @Param("getJobEndTime") String getJobEndTime, @Param("shouldGetBeginTime") String shouldGetBeginTime, @Param("shouldGetEndTime") String shouldGetEndTime, + @Param("handleJobBeginTime") String handleJobBeginTime, @Param("handleJobEndTime") String handleJobEndTime, @Param("shouldHandleBeginTime") String shouldHandleBeginTime, @Param("shouldHandleEndTime") String shouldHandleEndTime, + @Param("deptId") Long deptId, @Param("userId") Long userId, @Param("leaderId") Long leaderId); + + List> jobListSearch(@Param("page") Page> page, @Param("jobListParam") JobListParam jobListParam, + @Param("dataScope") DataScope dataScope, @Param("userId") Long userId); + + Map countByJobStatus(@Param("deptId") long deptId, @Param("spanDays") int spanDays); + + Map countMyJob(@Param("userId") long userId, @Param("deptId") long deptId, @Param("spanDays") int spanDays); + + List> jobInfo(@Param("id") Long id, @Param("dataScope") DataScope dataScope, @Param("personId") Long personId); + + // boolean getJob(@Param("id") int id,@Param("personId") long personId); + boolean getJob(@Param("id") Long id, @Param("personId") long personId, @Param("getTime") Date getTime, @Param("shouldHandleTime") Date shouldHandleTime); + + boolean confirmJob(@Param("id") Long id, @Param("personId") long personId, @Param("firstState") String firstState, @Param("firstStatePhotos") String firstStatePhotos, @Param("needHandle") String needHandle); + + boolean confirmOverJobAndAlarm(@Param("id") Long id, @Param("personId") long personId, @Param("firstState") String firstState, @Param("firstStatePhotos") String firstStatePhotos); + + boolean transferJob(@Param("id") Long id, @Param("transferPerson") long transferPerson, @Param("flowRec") String flowRec); + + boolean saveJob(@Param("id") Long id, @Param("handleMessage") String handleMessage, @Param("handlePhotos") String handlePhotos); + + boolean overJob(@Param("id") int id, @Param("personId") long personId, @Param("handleMessage") String handleMessage, @Param("handlePhotos") String handlePhotos); + boolean overAlarm(@Param("jobId") int id); - boolean overJobAndAlarm(@Param("id") int id,@Param("personId") long personId,@Param("handleMessage") String handleMessage,@Param("handlePhotos") String handlePhotos); - boolean handleJob(@Param("id") int id,@Param("personId") long personId); - List> countByDataScope(@Param("dataScope") DataScope dataScope,@Param("alarmType")String alarmType,@Param("jobStatus")String jobStatus,@Param("beginTime")String beginTime,@Param("endTime")String endTime); - Integer countByResponse(@Param("alarmType")String alarmType,@Param("jobStatus")String jobStatus,@Param("deptId") Long deptId,@Param("beginTime")String beginTime,@Param("endTime")String endTime); - Integer countByUser(@Param("alarmType")String alarmType,@Param("jobStatus")String jobStatus,@Param("userId") Long userId,@Param("beginTime")String beginTime,@Param("endTime")String endTime); + boolean overJobAndAlarm(@Param("id") Long id, @Param("personId") long personId, @Param("handleMessage") String handleMessage, @Param("handlePhotos") String handlePhotos); + + boolean handleJob(@Param("id") Long id, @Param("personId") long personId); + + List> countByDataScope(@Param("dataScope") DataScope dataScope, @Param("alarmType") String alarmType, @Param("jobStatus") String jobStatus, @Param("beginTime") String beginTime, @Param("endTime") String endTime); + + Integer countByResponse(@Param("alarmType") String alarmType, @Param("jobStatus") String jobStatus, @Param("deptId") Long deptId, @Param("beginTime") String beginTime, @Param("endTime") String endTime); + + Integer countByUser(@Param("alarmType") String alarmType, @Param("jobStatus") String jobStatus, @Param("userId") Long userId, @Param("beginTime") String beginTime, @Param("endTime") String endTime); String selectClientIdByUser(@Param("userId") Long userId); + List selectUserByWellCode(@Param("wellCode") String wellCode); + List selectUseIds(@Param("roleIds") List roleIds); + List selectRoles(); + + String getJobCodeMaxSerial(@Param("jobcode") String jobcode); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java index 46bb487..d27afa9 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java @@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.plugins.Page; import com.casic.missiles.core.base.response.ResponseData; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.alarm.service.IAlarmJobService; import com.casic.missiles.core.common.service.ICommonPermissionService; import com.casic.missiles.core.datascope.DataScope; @@ -12,12 +13,14 @@ import com.casic.missiles.modular.system.warpper.AlarmJobWarpper; import com.casic.missiles.core.base.controller.BaseController; import com.casic.missiles.core.common.constant.factory.PageFactory; +import lombok.extern.slf4j.Slf4j; import org.hswebframework.expands.office.excel.ExcelIO; import org.json.JSONException; import org.json.JSONObject; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; @@ -29,6 +32,7 @@ import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.*; //import com.casic.missiles.core.base.response.ResponseData; @@ -40,6 +44,7 @@ * @Date 2019-05-17 10:48:36 */ @Controller +@Slf4j @RequestMapping("/job") public class AlarmJobController extends BaseController { @@ -65,6 +70,13 @@ private String templatePath; + /** + * 工单状态接口统计 + * + * @param httpServletRequest + * @return + * @throws ParseException + */ @RequestMapping(value = "/countByJobStatus") @ResponseBody public Object countByJobStatus(HttpServletRequest httpServletRequest) throws ParseException { @@ -117,7 +129,7 @@ } /** - * 获取分页列表 + * 获取工单分页列表 */ @RequestMapping(value = "/list") @ResponseBody @@ -164,30 +176,26 @@ */ @RequestMapping(value = "/searchList") @ResponseBody - public Object jobListSearch(String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime, String endTime, - String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, - String handleJobBeginTime, String handleJobEndTime, String shouldHandleBeginTime, String shouldHandleEndTime) { + public Object jobListSearch(@RequestBody JobListParam jobListParam) { Page> page = new PageFactory>().defaultPage("createTime", false); DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List> retList = new ArrayList<>(); if (alarmJobService.checkPcRole(currentUser.getRoleTips())) { // pc角色 - retList = alarmJobService.jobListSearch(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, - handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, dataScope, currentUser.getId()); + retList = alarmJobService.jobListSearch(page, jobListParam, dataScope, currentUser.getId()); } else { //app角色 long leaderId = 0L; if (currentUser.getRoleTips().contains(sLeader)) { // 组长,查组内全部 leaderId = currentUser.getId(); - if (ToolUtil.isNotEmpty(jobStatus)) { + if (ToolUtil.isNotEmpty(jobListParam.getJobStatus())) { //learder&&jobStatus=1,2,3时,关闭传入的sort,按sql排序(自己的排在前) - page.setOpenSort(!alarmJobService.checkJobStatus(jobStatus)); + page.setOpenSort(!alarmJobService.checkJobStatus(jobListParam.getJobStatus())); } } - retList = alarmJobService.jobListSearchApp(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, - handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, currentUser.getDeptId(), currentUser.getId(), leaderId); + retList = alarmJobService.jobListSearchApp(page, jobListParam, currentUser.getDeptId(), currentUser.getId(), leaderId); } new AlarmJobWarpper(retList).warp(); @@ -277,26 +285,24 @@ @RequestMapping(value = "/export") public void exportJob(HttpServletRequest httpServletRequest , HttpServletResponse httpServletResponse) throws IOException { - Page> page = new PageFactory>().defaultPage("createTime", false); page.setLimit(maxRowsExcel); page.setSize(maxRowsExcel); page.setSearchCount(false); page.setOffset(0); - String keywords = httpServletRequest.getParameter("keywords"); String beginTime = httpServletRequest.getParameter("beginTime"); String endTime = httpServletRequest.getParameter("endTime"); String jobStatusStr = httpServletRequest.getParameter("jobStatus"); String alarmTypeStr = httpServletRequest.getParameter("alarmType"); String alarmContentStr = httpServletRequest.getParameter("alarmContentType"); - - List> jobExpList = new ArrayList<>(); + log.debug("主题参数---------------" + keywords + "," + beginTime + "," + endTime + "," + jobStatusStr + "," + alarmTypeStr + "," + alarmContentStr); DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - jobExpList = alarmJobService.jobList(page, keywords, beginTime, endTime, jobStatusStr, alarmTypeStr, alarmContentStr, dataScope, currentUser.getId()); + List> jobExpList = alarmJobService.jobList(page, keywords, beginTime, endTime, jobStatusStr, alarmTypeStr, alarmContentStr, dataScope, currentUser.getId()); new AlarmJobWarpper(jobExpList).warp(); FileInputStream fileInputStream = null; + log.debug("----------------" + ToolUtil.isEmpty(jobExpList)); if (ToolUtil.isEmpty(jobExpList)) { fileInputStream = new FileInputStream(templatePath + "/jobRecEmpty.xlsx"); } else { @@ -305,12 +311,10 @@ try { httpServletResponse.setContentType("application/octet-stream"); httpServletResponse.addHeader("Content-Disposition", " attachment;filename=" + "jobOverview.xlsx"); - Map var = new HashMap<>(); var.put("标题", "工单一览表"); var.put("list", jobExpList); ExcelIO.writeTemplate(fileInputStream, httpServletResponse.getOutputStream(), var); - } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { @@ -328,11 +332,11 @@ */ @RequestMapping(value = "/getJob") @ResponseBody - public Object getJob(int id) { + public Object getJob(Long id) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - if (alarmJobService.getJob(id, currentUser.getId())){ + if (alarmJobService.getJob(id, currentUser.getId())) { return ResponseData.success(); } else { return ResponseData.error("接单失败"); @@ -344,10 +348,10 @@ */ @RequestMapping(value = "/confirmJob") @ResponseBody - public Object confirmJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "firstState", required = true) String firstState, - @RequestParam(value = "firstStatePhotos", required = true) String firstStatePhotos, - @RequestParam(value = "needHandle", required = true) String needHandle) { + public Object confirmJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "firstState", required = true) String firstState, + @RequestParam(value = "firstStatePhotos", required = true) String firstStatePhotos, + @RequestParam(value = "needHandle", required = true) String needHandle) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.confirmJob(id, currentUser.getId(), firstState, firstStatePhotos, needHandle)) { return ResponseData.success(); @@ -361,17 +365,19 @@ */ @RequestMapping(value = "/transferJob") @ResponseBody - public Object transferJob(@RequestParam(value = "id", required = true) int id, + public Object transferJob(@RequestParam(value = "id", required = true) Long id, @RequestParam(value = "transferPerson", required = true) String transferPerson) throws JSONException { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - String dbTime = iSysDictService.getDBtime(); +// String dbTime = iSysDictService.getDBtime(); + SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); +// String dbTime = iSysDictService.getDBtime(); + Date dbTime = new Date(); JSONObject jsonObject = new JSONObject(); jsonObject.put("from", currentUser.getName()); jsonObject.put("to", EhcacheConstant.retBean().getUsernameById(Long.valueOf(transferPerson))); - jsonObject.put("time", dbTime); - + jsonObject.put("time", dateFormat.format(dbTime)); if (alarmJobService.transferJob(id, Long.valueOf(transferPerson), jsonObject.toString())) { return ResponseData.success(); } else { @@ -384,9 +390,9 @@ */ @RequestMapping(value = "/saveJob") @ResponseBody - public Object saveJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "handleMessage", required = true) String handleMessage, - @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { + public Object saveJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "handleMessage", required = true) String handleMessage, + @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { if (alarmJobService.saveJob(id, handleMessage, handlePhotos)) { return ResponseData.success(); @@ -400,10 +406,9 @@ */ @RequestMapping(value = "/overJob") @ResponseBody - public Object overJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "handleMessage", required = true) String handleMessage, - @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { - + public Object overJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "handleMessage", required = true) String handleMessage, + @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.overJob(id, currentUser.getId(), handleMessage, handlePhotos)) { @@ -419,7 +424,7 @@ */ @RequestMapping(value = "/handleJob") @ResponseBody - public Object handleJob(@RequestParam(value = "id", required = true) int id) { + public Object handleJob(@RequestParam(value = "id", required = true) Long id) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.handleJob(id, currentUser.getId())) { return ResponseData.success(); @@ -433,12 +438,10 @@ */ @RequestMapping(value = "/info") @ResponseBody - public Object jobInfo(@RequestParam(value = "id", required = true) int id) { - + public Object jobInfo(@RequestParam(value = "id", required = true) long id) { DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List> retList = alarmJobService.jobInfo(id, dataScope, currentUser.getId()); - new AlarmJobWarpper(retList).warp(); return ResponseData.success(retList); } @@ -456,7 +459,7 @@ @RequestParam(value = "wellCode", required = true) String wellCode) { Map retMap = new HashMap<>(); try { - alarmJobService.updateSinkJob(id, URLDecoder.decode(msg, "UTF-8"),wellCode); + alarmJobService.updateSinkJob(id, URLDecoder.decode(msg, "UTF-8"), wellCode); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java index 26a2ba7..df59231 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java @@ -52,6 +52,7 @@ @Autowired private IDeviceService deviceService; + @Value("${smartcity.office.maxRowsExcel}") private int maxRowsExcel; @Value("${smartcity.config.config-path}") @@ -182,7 +183,8 @@ @RequestMapping(value = "/cancelAlarmById") @ResponseBody public Object cancelAlarmById(@RequestParam(value = "alarmId",required = true) long alarmId){ - boolean isCancel = alarmRecordsService.cancelAlarmById(alarmId); + ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); + boolean isCancel = alarmRecordsService.cancelAlarm(alarmId,"4","手动消警",currentUser.getId()); if(isCancel){ return ResponseData.success(); }else { @@ -235,10 +237,10 @@ //根据查询条件查询alarm_record记录 DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); + ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List alarmRecords = alarmRecordsService.alarmListNoPage(dataScope, keywords, alarmType, alarmContent, beginTime, endTime, areaId); - for (AlarmRecords alarmRecord : alarmRecords) { - alarmRecordsService.cancelAlarmById(alarmRecord.getId()); + alarmRecordsService.cancelAlarm(alarmRecord.getJobId(),"4","手动消警",currentUser.getId()); } return ResponseData.success(); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/model/JobListParam.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/model/JobListParam.java new file mode 100644 index 0000000..c83bff8 --- /dev/null +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/model/JobListParam.java @@ -0,0 +1,32 @@ +package com.casic.missiles.modular.alarm.model; + + +import lombok.Data; + +/** + * @author cz + * @date 2022-6-13 17:03 + */ +@Data +public class JobListParam { + /** + * 关键字 + */ + private String keywords; + /** + * 风险等级 + */ + private String alarmLevel; + private String alarmContent; + private String jobStatus; + private String beginTime; + private String endTime; + private String getJobBeginTime; + private String getJobEndTime; + private String shouldGetBeginTime; + private String shouldGetEndTime; + private String handleJobBeginTime; + private String handleJobEndTime; + private String shouldHandleBeginTime; + private String shouldHandleEndTime; +} diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java index d4db8ce..018d095 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java @@ -3,6 +3,7 @@ import com.baomidou.mybatisplus.plugins.Page; import com.baomidou.mybatisplus.service.IService; import com.casic.missiles.core.datascope.DataScope; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.system.dto.UserClientView; import com.casic.missiles.modular.system.model.AlarmJob; @@ -18,42 +19,60 @@ * @since 2019-05-17 */ public interface IAlarmJobService extends IService { - List> jobList( Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType,String alarmContent, DataScope dataScope,Long userId); - List> jobListApp( Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType,String alarmContent,Long deptId,Long userId,Long leaderId); + + List> jobList(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, DataScope dataScope, Long userId); + + List> jobListApp(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, Long deptId, Long userId, Long leaderId); // List jobListExport( Page page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType,String alarmContent, DataScope dataScope); - List> jobListDelayRe( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, DataScope dataScope,Long userId); - List> jobListDelayReApp( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, Long deptId,Long userId,Long leaderId); + List> jobListDelayRe(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId); - List> jobListDelayPro( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, DataScope dataScope,Long userId ); - List> jobListDelayProApp( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, Long deptId,Long userId,Long leaderId); + List> jobListDelayReApp(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, Long deptId, Long userId, Long leaderId); - List> jobListSearch(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime,String endTime, - String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, - String shouldHandleBeginTime, String shouldHandleEndTime, DataScope dataScope,Long userId); - List> jobListSearchApp(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime,String endTime, - String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, - String shouldHandleBeginTime, String shouldHandleEndTime, Long deptId, Long userId, Long leaderId); - List> jobInfo(int id, DataScope dataScope,Long personId); - boolean getJob(int id, long personId); - boolean confirmJob(int id,long personId,String firstState, String firstStatePhotos, String needHandle); - boolean transferJob(int id, long transferPerson,String flowRec); - boolean saveJob( int id,String handleMessage, String handlePhotos); - boolean overJob( int id,long personId, String handleMessage, String handlePhotos); - boolean overAlarm( int id); - boolean handleJob(int id,long personId); + List> jobListDelayPro(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId); - Map countByJobStatus(long deptId,int spanDays); - Map countMyJob(long userId,long deptId,int spanDays); + List> jobListDelayProApp(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, Long deptId, Long userId, Long leaderId); + + List> jobListSearch(Page> page, JobListParam jobListParam, DataScope dataScope, Long userId); + + List> jobListSearchApp(Page> page, JobListParam jobListParam, Long deptId, Long userId, Long leaderId); + + List> jobInfo(Long id, DataScope dataScope, Long personId); + + boolean getJob(Long id, long personId); + + boolean confirmJob(Long id, long personId, String firstState, String firstStatePhotos, String needHandle); + + boolean transferJob(Long id, long transferPerson, String flowRec); + + boolean saveJob(Long id, String handleMessage, String handlePhotos); + + boolean overJob(Long id, long personId, String handleMessage, String handlePhotos); + + boolean overAlarm(int id); + + boolean handleJob(Long id, long personId); + + Map countByJobStatus(long deptId, int spanDays); + + Map countMyJob(long userId, long deptId, int spanDays); boolean checkJobStatus(String jobStatus); + boolean checkPcRole(List roleTips); - Integer countByDataScope(DataScope dataScope,String alarmType, String jobStatus,String beginTime,String endTime); - Integer countByResponse(String alarmType,String jobStatus,Long deptId,String beginTime,String endTime); - Integer countByUser(String alarmType,String jobStatus,Long userId,String beginTime,String endTime); + Integer countByDataScope(DataScope dataScope, String alarmType, String jobStatus, String beginTime, String endTime); - void updateSinkJob(String id,String msg,String wellCode); + Integer countByResponse(String alarmType, String jobStatus, Long deptId, String beginTime, String endTime); + + Integer countByUser(String alarmType, String jobStatus, Long userId, String beginTime, String endTime); + + void updateSinkJob(String id, String msg, String wellCode); + List selectUserByWellCode(String wellCode); + String selectClientIdByUser(Long userId); + + AlarmJob saveData( String devCode, String wellCode, String devTypeName, String jobType); + } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java index 46e7dfe..6eecb2b 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.service.IService; import com.casic.missiles.modular.system.model.AlarmRecords; import com.casic.missiles.core.datascope.DataScope; +import org.apache.ibatis.annotations.Param; import java.util.List; import java.util.Map; @@ -26,4 +27,8 @@ boolean cancelAlarmById(long id); Integer insertAlarmRecord(AlarmRecords alarmRec); + + Boolean isOldAlarmRecord(String devCode,String MsgContent); + + Integer updateOldAlarmRecord(String devCode,String MsgContent); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java index fa6681d..943ebd7 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java @@ -7,12 +7,14 @@ import com.casic.missiles.core.common.service.ICommonUserService; import com.casic.missiles.modular.alarm.job.HandleAlarmJob; import com.casic.missiles.modular.alarm.job.getDelayJob; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.alarm.service.IAlarmJobService; import com.casic.missiles.core.datascope.DataScope; import com.casic.missiles.core.util.EhcacheConstant; import com.casic.missiles.core.util.ToolUtil; import com.casic.missiles.modular.system.dao.AlarmJobMapper; import com.casic.missiles.modular.system.dao.AlarmRecordsMapper; +import com.casic.missiles.modular.system.dto.DeviceTypeEnum; import com.casic.missiles.modular.system.dto.SelectDto; import com.casic.missiles.modular.system.dto.UserClientView; import com.casic.missiles.modular.system.model.AlarmJob; @@ -24,6 +26,8 @@ import com.casic.missiles.quartz.service.IQuartzManager; import com.gexin.rp.sdk.base.IPushResult; import com.google.gson.GsonBuilder; +import net.sf.ehcache.search.Query; +import net.sf.ehcache.search.expression.Criteria; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -48,6 +52,8 @@ public class AlarmJobServiceImpl extends ServiceImpl implements IAlarmJobService { private static final Logger logger = LoggerFactory.getLogger(AlarmJobServiceImpl.class); + public static final SimpleDateFormat sdf6 = new SimpleDateFormat("yyyyMMdd"); + private static Map deviceAlarmMap = new HashMap(); @Value("${smartcity.leaderRoleName}") private String sLeader; @@ -70,12 +76,14 @@ @Resource private IQuartzManager quartzManager; - @Autowired IBusWellInfoService busWellInfoService; + @Autowired + IBusWellInfoService busWellInfoService; @Override - public List> jobList(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, DataScope dataScope,Long userId) { + public List> jobList(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, DataScope dataScope, Long userId) { alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobList(page, keywords, beginTime, endTime, jobStatus, alarmType, alarmContent, dataScope,userId);return alarmJobList; + List> alarmJobList = this.baseMapper.jobList(page, keywords, beginTime, endTime, jobStatus, alarmType, alarmContent, dataScope, userId); + return alarmJobList; } @Override @@ -86,9 +94,9 @@ } @Override - public List> jobListDelayRe(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope,Long userId) { + public List> jobListDelayRe(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId) { alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListDelayRe(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope,userId); + List> alarmJobList = this.baseMapper.jobListDelayRe(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope, userId); return alarmJobList; } @@ -100,9 +108,9 @@ } @Override - public List> jobListDelayPro(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope,Long userId) { + public List> jobListDelayPro(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId) { alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListDelayPro(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope,userId); + List> alarmJobList = this.baseMapper.jobListDelayPro(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope, userId); return alarmJobList; } @@ -114,109 +122,115 @@ } @Override - public List> jobListSearch(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime, String endTime, String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, String shouldHandleBeginTime, String shouldHandleEndTime, DataScope dataScope,Long userId) { - alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListSearch(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, dataScope,userId); + public List> jobListSearch(Page> page, JobListParam jobListParam, DataScope dataScope, Long userId) { + jobListParam.setAlarmContent(converAlarmContent(jobListParam.getAlarmContent())); + List> alarmJobList = this.baseMapper.jobListSearch(page, jobListParam, dataScope, userId); return alarmJobList; } @Override - public List> jobListSearchApp(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime, String endTime, String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, String shouldHandleBeginTime, String shouldHandleEndTime, Long deptId, Long userId, Long leaderId) { - alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListSearchApp(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, deptId, userId, leaderId); + public List> jobListSearchApp(Page> page, JobListParam jobListParam, Long deptId, Long userId, Long leaderId) { + jobListParam.setAlarmContent(converAlarmContent(jobListParam.getAlarmContent())); + List> alarmJobList = this.baseMapper.jobListSearchApp(page, jobListParam.getKeywords(), + jobListParam.getAlarmLevel(), jobListParam.getAlarmContent(), jobListParam.getJobStatus(), jobListParam.getBeginTime(), + jobListParam.getEndTime(), jobListParam.getGetJobBeginTime(), jobListParam.getGetJobEndTime(), jobListParam.getShouldGetBeginTime(), + jobListParam.getShouldGetEndTime(), jobListParam.getHandleJobBeginTime(), jobListParam.getHandleJobEndTime(), jobListParam.getShouldHandleBeginTime(), + jobListParam.getShouldHandleEndTime(), deptId, userId, leaderId); return alarmJobList; } - private String converAlarmContent(String alarmContent){ - if(ToolUtil.isEmpty(alarmContent)){ + private String converAlarmContent(String alarmContent) { + if (ToolUtil.isEmpty(alarmContent)) { return alarmContent; - }else { + } else { return EhcacheConstant.retBean().getAlarmContentName(Integer.valueOf(alarmContent)); } } @Override - public List> jobInfo(int id, DataScope dataScope, Long personId) - { - List> job = this.baseMapper.jobInfo(id,dataScope,personId); + public List> jobInfo(Long id, DataScope dataScope, Long personId) { + List> job = this.baseMapper.jobInfo(id, dataScope, personId); return job; } @Override - public Map countByJobStatus(long deptId,int spanDays) { - return this.baseMapper.countByJobStatus(deptId,spanDays); + public Map countByJobStatus(long deptId, int spanDays) { + return this.baseMapper.countByJobStatus(deptId, spanDays); } @Override - public Map countMyJob(long userId,long deptId,int spanDays) { - return this.baseMapper.countMyJob(userId,deptId,spanDays); + public Map countMyJob(long userId, long deptId, int spanDays) { + return this.baseMapper.countMyJob(userId, deptId, spanDays); } @Override - public boolean getJob(int id, long personId) { + public boolean getJob(Long id, long personId) { Calendar now = Calendar.getInstance(); Date getTime = now.getTime(); - if(isWeekend(now)){ + if (isWeekend(now)) { now.add(Calendar.WEEK_OF_YEAR, 1); - now.set(Calendar.DAY_OF_WEEK ,Calendar.TUESDAY); - now.set(Calendar.HOUR_OF_DAY,8); - now.set(Calendar.MINUTE,0); - now.set(Calendar.SECOND,0); - }else { + now.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY); + now.set(Calendar.HOUR_OF_DAY, 8); + now.set(Calendar.MINUTE, 0); + now.set(Calendar.SECOND, 0); + } else { now.add(Calendar.HOUR, 24); - while(isWeekend(now)){ + while (isWeekend(now)) { now.add(Calendar.HOUR, 24); } } Date shouldHandleTime = now.getTime(); - if(Boolean.getBoolean(useOverTime)){ + if (Boolean.getBoolean(useOverTime)) { System.out.println(shouldHandleTime); String jobName = "getJobDelay" + id; - Map map = new HashMap<>(); - map.put("jobId",id); - map.put("iAlarmJobService",this); - map.put("iCommonUserService",iCommonUserService); - map.put("iQuartzManager",quartzManager); - map.put("webSocket",webSocket); - quartzManager.addJob(jobName,getDelayJob.class,shouldHandleTime,map); + Map map = new HashMap<>(); + map.put("jobId", id); + map.put("iAlarmJobService", this); + map.put("iCommonUserService", iCommonUserService); + map.put("iQuartzManager", quartzManager); + map.put("webSocket", webSocket); + quartzManager.addJob(jobName, getDelayJob.class, shouldHandleTime, map); } - return this.baseMapper.getJob(id,personId,getTime,shouldHandleTime); + return this.baseMapper.getJob(id, personId, getTime, shouldHandleTime); } - private boolean isWeekend(Calendar cal){ - if(cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY){ + private boolean isWeekend(Calendar cal) { + if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) { return true; - } else{ + } else { return false; } } @Override - public boolean confirmJob(int id,long personId, String firstState, String firstStatePhotos, String needHandle) { - if ("1".equals(needHandle)){ - return this.baseMapper.confirmJob(id,personId, firstState, firstStatePhotos, needHandle); + public boolean confirmJob(Long id, long personId, String firstState, String firstStatePhotos, String needHandle) { + if ("1".equals(needHandle)) { + return this.baseMapper.confirmJob(id, personId, firstState, firstStatePhotos, needHandle); } else { - return this.baseMapper.confirmOverJobAndAlarm(id, personId,firstState, firstStatePhotos); + return this.baseMapper.confirmOverJobAndAlarm(id, personId, firstState, firstStatePhotos); } } @Override - public boolean transferJob(int id, long transferPerson,String flowRec) { - return this.baseMapper.transferJob(id, transferPerson,flowRec); + public boolean transferJob(Long id, long transferPerson, String flowRec) { + return this.baseMapper.transferJob(id, transferPerson, flowRec); } @Override - public boolean saveJob(int id, String handleMessage, String handlePhotos) { + public boolean saveJob(Long id, String handleMessage, String handlePhotos) { return this.baseMapper.saveJob(id, handleMessage, handlePhotos); } @Override - public boolean overJob(int id,long personId, String handleMessage, String handlePhotos) { - return this.baseMapper.overJobAndAlarm(id, personId,handleMessage, handlePhotos); + public boolean overJob(Long id, long personId, String handleMessage, String handlePhotos) { + + return this.baseMapper.overJobAndAlarm(id, personId, handleMessage, handlePhotos); + // return this.baseMapper.overJob(id, personId,handleMessage, handlePhotos); } + @Override public boolean overAlarm(int jobId) { return this.baseMapper.overAlarm(jobId); @@ -224,15 +238,15 @@ } @Override - public boolean handleJob(int id,long personId) { - return this.baseMapper.handleJob(id,personId); + public boolean handleJob(Long id, long personId) { + return this.baseMapper.handleJob(id, personId); } @Override public boolean checkJobStatus(String jobStatus) { - if(ToolUtil.isEmpty(jobStatus)){ + if (ToolUtil.isEmpty(jobStatus)) { return false; - }else{ + } else { return "1".equals(jobStatus) || "2".equals(jobStatus) || "3".equals(jobStatus); } } @@ -243,10 +257,10 @@ } - public List selectRoles() { return this.baseMapper.selectRoles(); } + public List selectUseIds(List roleIds) { return this.baseMapper.selectUseIds(roleIds); } @@ -255,50 +269,50 @@ public boolean checkPcRole(List roleTips) { List roleList = new ArrayList<>(roleTips); Iterator it = roleList.iterator(); - while (it.hasNext()){ + while (it.hasNext()) { String role = it.next(); - if(role.equals(sApp)||role.equals(sLeader)||role.equals(sMember)){ + if (role.equals(sApp) || role.equals(sLeader) || role.equals(sMember)) { it.remove(); } } - return roleList.size()>0; + return roleList.size() > 0; } @Override - public Integer countByDataScope(DataScope dataScope, String alarmType, String jobStatus, String beginTime,String endTime) { - List> res = this.baseMapper.countByDataScope(dataScope,alarmType,jobStatus,beginTime,endTime); + public Integer countByDataScope(DataScope dataScope, String alarmType, String jobStatus, String beginTime, String endTime) { + List> res = this.baseMapper.countByDataScope(dataScope, alarmType, jobStatus, beginTime, endTime); return res.size(); } @Override - public Integer countByResponse(String alarmType, String jobStatus, Long deptId, String beginTime,String endTime) { - return this.baseMapper.countByResponse(alarmType,jobStatus,deptId,beginTime,endTime); + public Integer countByResponse(String alarmType, String jobStatus, Long deptId, String beginTime, String endTime) { + return this.baseMapper.countByResponse(alarmType, jobStatus, deptId, beginTime, endTime); } @Override - public Integer countByUser(String alarmType, String jobStatus, Long userId, String beginTime,String endTime) { - return this.baseMapper.countByUser(alarmType,jobStatus,userId,beginTime,endTime); + public Integer countByUser(String alarmType, String jobStatus, Long userId, String beginTime, String endTime) { + return this.baseMapper.countByUser(alarmType, jobStatus, userId, beginTime, endTime); } @Override - public void updateSinkJob(String id, String msg,String wellCode) { + public void updateSinkJob(String id, String msg, String wellCode) { List userClientViewList = new ArrayList<>(); List selectDtoList = selectRoles(); EntityWrapper busWellInfoEntityWrapper = new EntityWrapper<>(); - busWellInfoEntityWrapper.eq("WELL_CODE",wellCode); + busWellInfoEntityWrapper.eq("WELL_CODE", wellCode); BusWellInfo busWellInfo = busWellInfoService.selectOne(busWellInfoEntityWrapper); - if(busWellInfo!=null&&ToolUtil.isNotEmpty(busWellInfo.getDeptid())){ - List roleids= new ArrayList<>(); - for(SelectDto selectDto:selectDtoList){ - if(ToolUtil.isNotEmpty(selectDto.getName()) - && Arrays.asList(selectDto.getName().split(",")).contains(busWellInfo.getDeptid())){ + if (busWellInfo != null && ToolUtil.isNotEmpty(busWellInfo.getDeptid())) { + List roleids = new ArrayList<>(); + for (SelectDto selectDto : selectDtoList) { + if (ToolUtil.isNotEmpty(selectDto.getName()) + && Arrays.asList(selectDto.getName().split(",")).contains(busWellInfo.getDeptid())) { roleids.add(selectDto.getId()); } } - if(roleids.size()>0){ + if (roleids.size() > 0) { List useIds = selectUseIds(roleids); - for(Long useId:useIds){ + for (Long useId : useIds) { UserClientView userClientView = new UserClientView(); userClientView.setClientid(useId.toString()); userClientView.setId(useId.toString()); @@ -307,11 +321,11 @@ } } - if(!("null".equals(id))){ + if (!("null".equals(id))) { AlarmJob alarmJob = this.baseMapper.selectById(id); sendJob(id, alarmJob, userClientViewList);//推送工单至app和pc端 } - if(StringUtils.isNotBlank(msg)){ + if (StringUtils.isNotBlank(msg)) { sendAlarm(msg, userClientViewList);//推送告警至app和pc端 } @@ -386,7 +400,7 @@ } Date shouldHandleTime = now.getTime(); - if(Boolean.getBoolean(useOverTime)) { + if (Boolean.getBoolean(useOverTime)) { System.out.println(shouldHandleTime); String jobName = "getJobDelay" + id; Map map = new HashMap<>(); @@ -437,4 +451,40 @@ public String selectClientIdByUser(Long userId) { return this.baseMapper.selectClientIdByUser(userId); } + + + public AlarmJob saveData(String devCode, String wellCode, String devTypeName, String jobType) { + AlarmJob alarmJob = new AlarmJob(); + alarmJob.setDevcode(devCode); + alarmJob.setWellCode(wellCode); + alarmJob.setJobStatus("0"); + alarmJob.setCreateTime(new Date()); + alarmJob.setJobcode(this.produceJobCode(devTypeName)); + alarmJob.setJobType(jobType); + this.baseMapper.insert(alarmJob); + return alarmJob; + } + + /** + * 前缀+日期+4位流水号 + * + * @param devTypeName + * @return + */ + private String produceJobCode(String devTypeName) { + String pre = devTypeName; + String dataStr = sdf6.format(new Date()); + String fix = this.getJobCodeMaxSerial(pre + dataStr); + return StringUtils.isNotBlank(fix) ? pre + dataStr + String.format("%04d", Long.valueOf(fix) + 1L) : pre + dataStr + "0001"; + } + + + private String getJobCodeMaxSerial(String jobcode) { + String MaxSerialJobCode = this.baseMapper.getJobCodeMaxSerial(jobcode); + String fix = ""; + if (null != MaxSerialJobCode && MaxSerialJobCode.length() > 4) { + fix = MaxSerialJobCode.substring(MaxSerialJobCode.length() - 4); + } + return fix; + } } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmRecordsServiceImpl.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmRecordsServiceImpl.java index e0f0959..60fa41a 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmRecordsServiceImpl.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmRecordsServiceImpl.java @@ -16,7 +16,7 @@ /** *

- * 服务实现类 + * 服务实现类 *

* * @author casic123 @@ -27,12 +27,12 @@ @Override - public List> alarmList(Page> page, String keywords, String beginTime, String endTime, String status, String alarmType, String alarmContent, String areaId, DataScope dataScope) { + public List> alarmList(Page> page, String keywords, String beginTime, String endTime, String status, String alarmType, String alarmContent, String areaId, DataScope dataScope) { String sContent = null; - if (ToolUtil.isNotEmpty(alarmContent)){ + if (ToolUtil.isNotEmpty(alarmContent)) { sContent = EhcacheConstant.retBean().getAlarmContentName(Integer.valueOf(alarmContent)); } - return this.baseMapper.alarmList(page,keywords,beginTime,endTime,status,alarmType,sContent, areaId, dataScope); + return this.baseMapper.alarmList(page, keywords, beginTime, endTime, status, alarmType, sContent, areaId, dataScope); } /** @@ -41,15 +41,15 @@ @Override public List alarmListNoPage(DataScope dataScope, String keywords, String alarmType, String alarmContent, String beginTime, String endTime, String areaId) { String sContent = null; - if (ToolUtil.isNotEmpty(alarmContent)){ + if (ToolUtil.isNotEmpty(alarmContent)) { sContent = EhcacheConstant.retBean().getAlarmContentName(Integer.valueOf(alarmContent)); } - return this.baseMapper.alarmListNoPage(dataScope,keywords,alarmType,sContent,beginTime,endTime, areaId); + return this.baseMapper.alarmListNoPage(dataScope, keywords, alarmType, sContent, beginTime, endTime, areaId); } @Override public boolean cancelAlarm(long id, String jobStatus, String handleMessage, long personId) { - return this.baseMapper.cancelAlarm(id,jobStatus,handleMessage,personId); + return this.baseMapper.cancelAlarm(id, jobStatus, handleMessage, personId); } @Override @@ -62,4 +62,15 @@ // this.baseMapper.cancelAlarmByNewRecord(alarmRec.getDevcode(), alarmRec.getAlarmType()); return this.baseMapper.insert(alarmRec); } + + public Boolean isOldAlarmRecord(String devCode, String MsgContent) { + if (this.baseMapper.isOldAlarmRecord(devCode, MsgContent) == null) { + return false; + } + return true; + } + + public Integer updateOldAlarmRecord(String devCode, String MsgContent) { + return this.baseMapper.updateOldAlarmRecord(devCode, MsgContent); + } } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/AlarmMapOverviewController.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/AlarmMapOverviewController.java index 9d60185..214c275 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/AlarmMapOverviewController.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/AlarmMapOverviewController.java @@ -8,14 +8,12 @@ import com.casic.missiles.core.exception.GunsExceptionEnum; import com.casic.missiles.core.base.response.SuccessResponseData; import com.casic.missiles.core.util.ToolUtil; -import com.casic.missiles.modular.system.constant.ModularDictConst; import com.casic.missiles.modular.system.dto.AlarmNowView; import com.casic.missiles.modular.system.dto.DeviceDto; import com.casic.missiles.modular.system.model.BusWellInfo; import com.casic.missiles.modular.system.service.IAlarmNowViewService; import com.casic.missiles.modular.system.service.IBusWellInfoService; import com.casic.missiles.modular.system.service.IDeviceService; -import com.casic.missiles.modular.system.service.impl.BusWellInfoServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataReceiver.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataReceiver.java index 0013989..b3f23d5 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataReceiver.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataReceiver.java @@ -2,6 +2,7 @@ import com.casic.missiles.core.base.controller.BaseController; import com.casic.missiles.core.base.response.ResponseData; +import com.casic.missiles.modular.alarm.service.IAlarmJobService; import com.casic.missiles.modular.alarm.service.IAlarmRecordsService; import com.casic.missiles.modular.alarm.service.IAlarmRuleService; import com.casic.missiles.modular.system.dto.DeviceWellDto; @@ -9,6 +10,7 @@ import com.casic.missiles.modular.system.service.IDeviceService; import com.casic.missiles.modular.system.service.IGasFlowDataService; import lombok.extern.java.Log; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -38,6 +40,9 @@ @Resource private IAlarmRecordsService alarmRecordsService; + @Autowired + IAlarmJobService alarmJobService; + private DecimalFormat df2 = new DecimalFormat("0.00"); @RequestMapping(value = "/data/recv") @@ -117,6 +122,13 @@ alarmRecord.setAlarmTime(Calendar.getInstance().getTime()); alarmRecord.setStatus("1"); alarmRecord.setAlarmMessage("日用气量超阈值报警"); + if (alarmRecordsService.isOldAlarmRecord(gasFlowAddr, "日用气量超阈值报警")) { + alarmRecordsService.updateOldAlarmRecord(gasFlowAddr, "日用气量超阈值报警"); + } else { + AlarmJob alarmJob = alarmJobService.saveData(gasFlowAddr, wellDto.getWellCode(), "SLCX", "1"); + alarmRecord.setJobId(alarmJob.getId()); + } + alarmRecordsService.insertAlarmRecord(alarmRecord); // 向前端推送报警 } else { @@ -134,6 +146,13 @@ alarmRecord.setAlarmTime(Calendar.getInstance().getTime()); alarmRecord.setStatus("1"); alarmRecord.setAlarmMessage("日用气量超阈值预警"); + alarmRecord.setAlarmMessage("日用水量超阈值预警"); + if (alarmRecordsService.isOldAlarmRecord(gasFlowAddr, "日用水量超阈值预警")) { + alarmRecordsService.updateOldAlarmRecord(gasFlowAddr, "日用水量超阈值预警"); + } else { + AlarmJob alarmJob = alarmJobService.saveData(gasFlowAddr, wellDto.getWellCode(), "SLCX", "1"); + alarmRecord.setJobId(alarmJob.getId()); + } alarmRecordsService.insertAlarmRecord(alarmRecord); // 向前端推送报警 } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataReceiver.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataReceiver.java index 6c25e18..200f5d2 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataReceiver.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataReceiver.java @@ -2,16 +2,15 @@ import com.casic.missiles.core.base.controller.BaseController; import com.casic.missiles.core.base.response.ResponseData; +import com.casic.missiles.modular.alarm.service.IAlarmJobService; import com.casic.missiles.modular.alarm.service.IAlarmRecordsService; import com.casic.missiles.modular.alarm.service.IAlarmRuleService; import com.casic.missiles.modular.system.dto.DeviceWellDto; -import com.casic.missiles.modular.system.model.AlarmRecords; -import com.casic.missiles.modular.system.model.AlarmRule; -import com.casic.missiles.modular.system.model.DataWaterMeter; -import com.casic.missiles.modular.system.model.Device; +import com.casic.missiles.modular.system.model.*; import com.casic.missiles.modular.system.service.IDeviceService; import com.casic.missiles.modular.system.service.IWaterMeterDataService; import lombok.extern.java.Log; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -40,6 +39,9 @@ @Resource private IAlarmRecordsService alarmRecordsService; + @Autowired + IAlarmJobService alarmJobService; + private DecimalFormat df2 = new DecimalFormat("0.00"); @RequestMapping(value = "/data/recv") @@ -106,7 +108,6 @@ if (flowAccToday - alarmRule.getHighvalue() > 0) { // 超出报警阈值 生成一条报警消息 AlarmRecords alarmRecord = new AlarmRecords(); - alarmRecord.setDeviceId(device.getId()); alarmRecord.setDevcode(meterAddr); alarmRecord.setWellCode(wellDto.getWellCode()); @@ -116,17 +117,19 @@ alarmRecord.setAlarmTime(Calendar.getInstance().getTime()); alarmRecord.setStatus("1"); alarmRecord.setAlarmMessage("日用水量超阈值报警"); - + if (alarmRecordsService.isOldAlarmRecord(meterAddr, "日用水量超阈值报警")) { + alarmRecordsService.updateOldAlarmRecord(meterAddr, "日用水量超阈值报警"); + } else { + AlarmJob alarmJob = alarmJobService.saveData(meterAddr, wellDto.getWellCode(), "QLCX", "1"); + alarmRecord.setJobId(alarmJob.getId()); + } alarmRecordsService.insertAlarmRecord(alarmRecord); - - // 向前端推送报警 } else { // 如果没有报警则判断是否预警 if (null != alarmRuleWarn && null != alarmRuleWarn.getHighvalue()) { if (flowAccToday - alarmRuleWarn.getHighvalue() > 0) { // 超出预警阈值 生成一条预警消息 AlarmRecords alarmRecord = new AlarmRecords(); - alarmRecord.setDeviceId(device.getId()); alarmRecord.setDevcode(meterAddr); alarmRecord.setWellCode(wellDto.getWellCode()); @@ -136,10 +139,13 @@ alarmRecord.setAlarmTime(Calendar.getInstance().getTime()); alarmRecord.setStatus("1"); alarmRecord.setAlarmMessage("日用水量超阈值预警"); - + if (alarmRecordsService.isOldAlarmRecord(meterAddr, "日用水量超阈值预警")) { + alarmRecordsService.updateOldAlarmRecord(meterAddr, "日用水量超阈值预警"); + } else { + AlarmJob alarmJob = alarmJobService.saveData(meterAddr, wellDto.getWellCode(), "QLCX", "1"); + alarmRecord.setJobId(alarmJob.getId()); + } alarmRecordsService.insertAlarmRecord(alarmRecord); - - // 向前端推送报警 } } } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmJobMapper.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmJobMapper.java index 6592517..ccdff9a 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmJobMapper.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmJobMapper.java @@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.mapper.BaseMapper; import com.baomidou.mybatisplus.plugins.Page; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.system.dto.SelectDto; import com.casic.missiles.modular.system.dto.UserClientView; import com.casic.missiles.modular.system.model.AlarmJob; @@ -21,44 +22,65 @@ * @since 2019-05-17 */ public interface AlarmJobMapper extends BaseMapper { - List> jobList(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("jobStatus") String jobStatus, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("dataScope") DataScope dataScope,@Param("userId")Long userId); - List> jobListApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("jobStatus") String jobStatus, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("deptId")Long deptId,@Param("userId")Long userId,@Param("leaderId")Long leaderId); + List> jobList(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("jobStatus") String jobStatus, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("dataScope") DataScope dataScope, @Param("userId") Long userId); + + List> jobListApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("jobStatus") String jobStatus, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("deptId") Long deptId, @Param("userId") Long userId, @Param("leaderId") Long leaderId); + // List jobListExport(@Param("page") Page page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("jobStatus") String jobStatus, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("dataScope") DataScope dataScope); - List> jobListDelayRe(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("dataScope") DataScope dataScope,@Param("userId")Long userId); - List> jobListDelayReApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("deptId")Long deptId,@Param("userId")Long userId,@Param("leaderId")Long leaderId); + List> jobListDelayRe(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("dataScope") DataScope dataScope, @Param("userId") Long userId); - List> jobListDelayPro(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("dataScope") DataScope dataScope,@Param("userId")Long userId); - List> jobListDelayProApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("deptId")Long deptId,@Param("userId")Long userId,@Param("leaderId")Long leaderId); + List> jobListDelayReApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("deptId") Long deptId, @Param("userId") Long userId, @Param("leaderId") Long leaderId); - List> jobListSearchApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("alarmLevel")String alarmLevel, @Param("alarmContent") String alarmContent, @Param("jobStatus") String jobStatus, @Param("beginTime") String beginTime, @Param("endTime") String endTime, - @Param("getJobBeginTime") String getJobBeginTime, @Param("getJobEndTime") String getJobEndTime, @Param("shouldGetBeginTime") String shouldGetBeginTime, @Param("shouldGetEndTime") String shouldGetEndTime, - @Param("handleJobBeginTime") String handleJobBeginTime, @Param("handleJobEndTime") String handleJobEndTime, @Param("shouldHandleBeginTime") String shouldHandleBeginTime, @Param("shouldHandleEndTime") String shouldHandleEndTime, - @Param("deptId")Long deptId, @Param("userId")Long userId, @Param("leaderId")Long leaderId); - List> jobListSearch(@Param("page") Page> page, @Param("keywords") String keywords, @Param("alarmLevel")String alarmLevel, @Param("alarmContent") String alarmContent, @Param("jobStatus") String jobStatus, @Param("beginTime") String beginTime, @Param("endTime") String endTime, - @Param("getJobBeginTime") String getJobBeginTime, @Param("getJobEndTime") String getJobEndTime, @Param("shouldGetBeginTime") String shouldGetBeginTime, @Param("shouldGetEndTime") String shouldGetEndTime, - @Param("handleJobBeginTime") String handleJobBeginTime, @Param("handleJobEndTime") String handleJobEndTime, @Param("shouldHandleBeginTime") String shouldHandleBeginTime, @Param("shouldHandleEndTime") String shouldHandleEndTime, - @Param("dataScope") DataScope dataScope,@Param("userId")Long userId); + List> jobListDelayPro(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("dataScope") DataScope dataScope, @Param("userId") Long userId); - Map countByJobStatus(@Param("deptId")long deptId,@Param("spanDays") int spanDays); - Map countMyJob(@Param("userId")long userId,@Param("deptId")long deptId,@Param("spanDays") int spanDays); - List> jobInfo(@Param("id") int id,@Param("dataScope") DataScope dataScope,@Param("personId") Long personId); -// boolean getJob(@Param("id") int id,@Param("personId") long personId); - boolean getJob(@Param("id") int id,@Param("personId") long personId,@Param("getTime")Date getTime ,@Param("shouldHandleTime")Date shouldHandleTime); - boolean confirmJob(@Param("id") int id,@Param("personId") long personId,@Param("firstState") String firstState,@Param("firstStatePhotos") String firstStatePhotos,@Param("needHandle") String needHandle); - boolean confirmOverJobAndAlarm(@Param("id") int id,@Param("personId") long personId,@Param("firstState") String firstState,@Param("firstStatePhotos") String firstStatePhotos); - boolean transferJob(@Param("id") int id,@Param("transferPerson") long transferPerson,@Param("flowRec") String flowRec); - boolean saveJob(@Param("id") int id,@Param("handleMessage") String handleMessage,@Param("handlePhotos") String handlePhotos); - boolean overJob(@Param("id") int id,@Param("personId") long personId,@Param("handleMessage") String handleMessage,@Param("handlePhotos") String handlePhotos); + List> jobListDelayProApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("deptId") Long deptId, @Param("userId") Long userId, @Param("leaderId") Long leaderId); + + List> jobListSearchApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("alarmLevel") String alarmLevel, @Param("alarmContent") String alarmContent, @Param("jobStatus") String jobStatus, @Param("beginTime") String beginTime, @Param("endTime") String endTime, + @Param("getJobBeginTime") String getJobBeginTime, @Param("getJobEndTime") String getJobEndTime, @Param("shouldGetBeginTime") String shouldGetBeginTime, @Param("shouldGetEndTime") String shouldGetEndTime, + @Param("handleJobBeginTime") String handleJobBeginTime, @Param("handleJobEndTime") String handleJobEndTime, @Param("shouldHandleBeginTime") String shouldHandleBeginTime, @Param("shouldHandleEndTime") String shouldHandleEndTime, + @Param("deptId") Long deptId, @Param("userId") Long userId, @Param("leaderId") Long leaderId); + + List> jobListSearch(@Param("page") Page> page, @Param("jobListParam") JobListParam jobListParam, + @Param("dataScope") DataScope dataScope, @Param("userId") Long userId); + + Map countByJobStatus(@Param("deptId") long deptId, @Param("spanDays") int spanDays); + + Map countMyJob(@Param("userId") long userId, @Param("deptId") long deptId, @Param("spanDays") int spanDays); + + List> jobInfo(@Param("id") Long id, @Param("dataScope") DataScope dataScope, @Param("personId") Long personId); + + // boolean getJob(@Param("id") int id,@Param("personId") long personId); + boolean getJob(@Param("id") Long id, @Param("personId") long personId, @Param("getTime") Date getTime, @Param("shouldHandleTime") Date shouldHandleTime); + + boolean confirmJob(@Param("id") Long id, @Param("personId") long personId, @Param("firstState") String firstState, @Param("firstStatePhotos") String firstStatePhotos, @Param("needHandle") String needHandle); + + boolean confirmOverJobAndAlarm(@Param("id") Long id, @Param("personId") long personId, @Param("firstState") String firstState, @Param("firstStatePhotos") String firstStatePhotos); + + boolean transferJob(@Param("id") Long id, @Param("transferPerson") long transferPerson, @Param("flowRec") String flowRec); + + boolean saveJob(@Param("id") Long id, @Param("handleMessage") String handleMessage, @Param("handlePhotos") String handlePhotos); + + boolean overJob(@Param("id") int id, @Param("personId") long personId, @Param("handleMessage") String handleMessage, @Param("handlePhotos") String handlePhotos); + boolean overAlarm(@Param("jobId") int id); - boolean overJobAndAlarm(@Param("id") int id,@Param("personId") long personId,@Param("handleMessage") String handleMessage,@Param("handlePhotos") String handlePhotos); - boolean handleJob(@Param("id") int id,@Param("personId") long personId); - List> countByDataScope(@Param("dataScope") DataScope dataScope,@Param("alarmType")String alarmType,@Param("jobStatus")String jobStatus,@Param("beginTime")String beginTime,@Param("endTime")String endTime); - Integer countByResponse(@Param("alarmType")String alarmType,@Param("jobStatus")String jobStatus,@Param("deptId") Long deptId,@Param("beginTime")String beginTime,@Param("endTime")String endTime); - Integer countByUser(@Param("alarmType")String alarmType,@Param("jobStatus")String jobStatus,@Param("userId") Long userId,@Param("beginTime")String beginTime,@Param("endTime")String endTime); + boolean overJobAndAlarm(@Param("id") Long id, @Param("personId") long personId, @Param("handleMessage") String handleMessage, @Param("handlePhotos") String handlePhotos); + + boolean handleJob(@Param("id") Long id, @Param("personId") long personId); + + List> countByDataScope(@Param("dataScope") DataScope dataScope, @Param("alarmType") String alarmType, @Param("jobStatus") String jobStatus, @Param("beginTime") String beginTime, @Param("endTime") String endTime); + + Integer countByResponse(@Param("alarmType") String alarmType, @Param("jobStatus") String jobStatus, @Param("deptId") Long deptId, @Param("beginTime") String beginTime, @Param("endTime") String endTime); + + Integer countByUser(@Param("alarmType") String alarmType, @Param("jobStatus") String jobStatus, @Param("userId") Long userId, @Param("beginTime") String beginTime, @Param("endTime") String endTime); String selectClientIdByUser(@Param("userId") Long userId); + List selectUserByWellCode(@Param("wellCode") String wellCode); + List selectUseIds(@Param("roleIds") List roleIds); + List selectRoles(); + + String getJobCodeMaxSerial(@Param("jobcode") String jobcode); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmRecordsMapper.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmRecordsMapper.java index 87a71ff..d4c6a8b 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmRecordsMapper.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmRecordsMapper.java @@ -11,7 +11,7 @@ /** *

- * Mapper 接口 + * Mapper 接口 *

* * @author casic123 @@ -19,13 +19,18 @@ */ public interface AlarmRecordsMapper extends BaseMapper { - List> alarmList(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("status") String status, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("areaId") String areaId, @Param("dataScope") DataScope dataScope); + List> alarmList(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("status") String status, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("areaId") String areaId, @Param("dataScope") DataScope dataScope); List alarmListNoPage(@Param("scope") DataScope dataScope, @Param("keywords") String keywords, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("areaId") String areaId); - boolean cancelAlarm(@Param("id") long id, @Param("jobStatus")String jobStatus,@Param("handleMessage") String handleMessage,@Param("personId") long personId); + boolean cancelAlarm(@Param("id") long id, @Param("jobStatus") String jobStatus, @Param("handleMessage") String handleMessage, @Param("personId") long personId); boolean cancelAlarmById(@Param("id") long id); boolean cancelAlarmByNewRecord(@Param("devcode") String devcode, @Param("alarmType") String alarmType); + + String isOldAlarmRecord(@Param("devcode") String devcode, @Param("MsgContent") String MsgContent); + + Integer updateOldAlarmRecord(@Param("devcode") String devcode, @Param("MsgContent") String MsgContent); + } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java index 46bb487..d27afa9 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java @@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.plugins.Page; import com.casic.missiles.core.base.response.ResponseData; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.alarm.service.IAlarmJobService; import com.casic.missiles.core.common.service.ICommonPermissionService; import com.casic.missiles.core.datascope.DataScope; @@ -12,12 +13,14 @@ import com.casic.missiles.modular.system.warpper.AlarmJobWarpper; import com.casic.missiles.core.base.controller.BaseController; import com.casic.missiles.core.common.constant.factory.PageFactory; +import lombok.extern.slf4j.Slf4j; import org.hswebframework.expands.office.excel.ExcelIO; import org.json.JSONException; import org.json.JSONObject; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; @@ -29,6 +32,7 @@ import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.*; //import com.casic.missiles.core.base.response.ResponseData; @@ -40,6 +44,7 @@ * @Date 2019-05-17 10:48:36 */ @Controller +@Slf4j @RequestMapping("/job") public class AlarmJobController extends BaseController { @@ -65,6 +70,13 @@ private String templatePath; + /** + * 工单状态接口统计 + * + * @param httpServletRequest + * @return + * @throws ParseException + */ @RequestMapping(value = "/countByJobStatus") @ResponseBody public Object countByJobStatus(HttpServletRequest httpServletRequest) throws ParseException { @@ -117,7 +129,7 @@ } /** - * 获取分页列表 + * 获取工单分页列表 */ @RequestMapping(value = "/list") @ResponseBody @@ -164,30 +176,26 @@ */ @RequestMapping(value = "/searchList") @ResponseBody - public Object jobListSearch(String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime, String endTime, - String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, - String handleJobBeginTime, String handleJobEndTime, String shouldHandleBeginTime, String shouldHandleEndTime) { + public Object jobListSearch(@RequestBody JobListParam jobListParam) { Page> page = new PageFactory>().defaultPage("createTime", false); DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List> retList = new ArrayList<>(); if (alarmJobService.checkPcRole(currentUser.getRoleTips())) { // pc角色 - retList = alarmJobService.jobListSearch(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, - handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, dataScope, currentUser.getId()); + retList = alarmJobService.jobListSearch(page, jobListParam, dataScope, currentUser.getId()); } else { //app角色 long leaderId = 0L; if (currentUser.getRoleTips().contains(sLeader)) { // 组长,查组内全部 leaderId = currentUser.getId(); - if (ToolUtil.isNotEmpty(jobStatus)) { + if (ToolUtil.isNotEmpty(jobListParam.getJobStatus())) { //learder&&jobStatus=1,2,3时,关闭传入的sort,按sql排序(自己的排在前) - page.setOpenSort(!alarmJobService.checkJobStatus(jobStatus)); + page.setOpenSort(!alarmJobService.checkJobStatus(jobListParam.getJobStatus())); } } - retList = alarmJobService.jobListSearchApp(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, - handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, currentUser.getDeptId(), currentUser.getId(), leaderId); + retList = alarmJobService.jobListSearchApp(page, jobListParam, currentUser.getDeptId(), currentUser.getId(), leaderId); } new AlarmJobWarpper(retList).warp(); @@ -277,26 +285,24 @@ @RequestMapping(value = "/export") public void exportJob(HttpServletRequest httpServletRequest , HttpServletResponse httpServletResponse) throws IOException { - Page> page = new PageFactory>().defaultPage("createTime", false); page.setLimit(maxRowsExcel); page.setSize(maxRowsExcel); page.setSearchCount(false); page.setOffset(0); - String keywords = httpServletRequest.getParameter("keywords"); String beginTime = httpServletRequest.getParameter("beginTime"); String endTime = httpServletRequest.getParameter("endTime"); String jobStatusStr = httpServletRequest.getParameter("jobStatus"); String alarmTypeStr = httpServletRequest.getParameter("alarmType"); String alarmContentStr = httpServletRequest.getParameter("alarmContentType"); - - List> jobExpList = new ArrayList<>(); + log.debug("主题参数---------------" + keywords + "," + beginTime + "," + endTime + "," + jobStatusStr + "," + alarmTypeStr + "," + alarmContentStr); DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - jobExpList = alarmJobService.jobList(page, keywords, beginTime, endTime, jobStatusStr, alarmTypeStr, alarmContentStr, dataScope, currentUser.getId()); + List> jobExpList = alarmJobService.jobList(page, keywords, beginTime, endTime, jobStatusStr, alarmTypeStr, alarmContentStr, dataScope, currentUser.getId()); new AlarmJobWarpper(jobExpList).warp(); FileInputStream fileInputStream = null; + log.debug("----------------" + ToolUtil.isEmpty(jobExpList)); if (ToolUtil.isEmpty(jobExpList)) { fileInputStream = new FileInputStream(templatePath + "/jobRecEmpty.xlsx"); } else { @@ -305,12 +311,10 @@ try { httpServletResponse.setContentType("application/octet-stream"); httpServletResponse.addHeader("Content-Disposition", " attachment;filename=" + "jobOverview.xlsx"); - Map var = new HashMap<>(); var.put("标题", "工单一览表"); var.put("list", jobExpList); ExcelIO.writeTemplate(fileInputStream, httpServletResponse.getOutputStream(), var); - } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { @@ -328,11 +332,11 @@ */ @RequestMapping(value = "/getJob") @ResponseBody - public Object getJob(int id) { + public Object getJob(Long id) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - if (alarmJobService.getJob(id, currentUser.getId())){ + if (alarmJobService.getJob(id, currentUser.getId())) { return ResponseData.success(); } else { return ResponseData.error("接单失败"); @@ -344,10 +348,10 @@ */ @RequestMapping(value = "/confirmJob") @ResponseBody - public Object confirmJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "firstState", required = true) String firstState, - @RequestParam(value = "firstStatePhotos", required = true) String firstStatePhotos, - @RequestParam(value = "needHandle", required = true) String needHandle) { + public Object confirmJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "firstState", required = true) String firstState, + @RequestParam(value = "firstStatePhotos", required = true) String firstStatePhotos, + @RequestParam(value = "needHandle", required = true) String needHandle) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.confirmJob(id, currentUser.getId(), firstState, firstStatePhotos, needHandle)) { return ResponseData.success(); @@ -361,17 +365,19 @@ */ @RequestMapping(value = "/transferJob") @ResponseBody - public Object transferJob(@RequestParam(value = "id", required = true) int id, + public Object transferJob(@RequestParam(value = "id", required = true) Long id, @RequestParam(value = "transferPerson", required = true) String transferPerson) throws JSONException { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - String dbTime = iSysDictService.getDBtime(); +// String dbTime = iSysDictService.getDBtime(); + SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); +// String dbTime = iSysDictService.getDBtime(); + Date dbTime = new Date(); JSONObject jsonObject = new JSONObject(); jsonObject.put("from", currentUser.getName()); jsonObject.put("to", EhcacheConstant.retBean().getUsernameById(Long.valueOf(transferPerson))); - jsonObject.put("time", dbTime); - + jsonObject.put("time", dateFormat.format(dbTime)); if (alarmJobService.transferJob(id, Long.valueOf(transferPerson), jsonObject.toString())) { return ResponseData.success(); } else { @@ -384,9 +390,9 @@ */ @RequestMapping(value = "/saveJob") @ResponseBody - public Object saveJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "handleMessage", required = true) String handleMessage, - @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { + public Object saveJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "handleMessage", required = true) String handleMessage, + @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { if (alarmJobService.saveJob(id, handleMessage, handlePhotos)) { return ResponseData.success(); @@ -400,10 +406,9 @@ */ @RequestMapping(value = "/overJob") @ResponseBody - public Object overJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "handleMessage", required = true) String handleMessage, - @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { - + public Object overJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "handleMessage", required = true) String handleMessage, + @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.overJob(id, currentUser.getId(), handleMessage, handlePhotos)) { @@ -419,7 +424,7 @@ */ @RequestMapping(value = "/handleJob") @ResponseBody - public Object handleJob(@RequestParam(value = "id", required = true) int id) { + public Object handleJob(@RequestParam(value = "id", required = true) Long id) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.handleJob(id, currentUser.getId())) { return ResponseData.success(); @@ -433,12 +438,10 @@ */ @RequestMapping(value = "/info") @ResponseBody - public Object jobInfo(@RequestParam(value = "id", required = true) int id) { - + public Object jobInfo(@RequestParam(value = "id", required = true) long id) { DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List> retList = alarmJobService.jobInfo(id, dataScope, currentUser.getId()); - new AlarmJobWarpper(retList).warp(); return ResponseData.success(retList); } @@ -456,7 +459,7 @@ @RequestParam(value = "wellCode", required = true) String wellCode) { Map retMap = new HashMap<>(); try { - alarmJobService.updateSinkJob(id, URLDecoder.decode(msg, "UTF-8"),wellCode); + alarmJobService.updateSinkJob(id, URLDecoder.decode(msg, "UTF-8"), wellCode); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java index 26a2ba7..df59231 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java @@ -52,6 +52,7 @@ @Autowired private IDeviceService deviceService; + @Value("${smartcity.office.maxRowsExcel}") private int maxRowsExcel; @Value("${smartcity.config.config-path}") @@ -182,7 +183,8 @@ @RequestMapping(value = "/cancelAlarmById") @ResponseBody public Object cancelAlarmById(@RequestParam(value = "alarmId",required = true) long alarmId){ - boolean isCancel = alarmRecordsService.cancelAlarmById(alarmId); + ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); + boolean isCancel = alarmRecordsService.cancelAlarm(alarmId,"4","手动消警",currentUser.getId()); if(isCancel){ return ResponseData.success(); }else { @@ -235,10 +237,10 @@ //根据查询条件查询alarm_record记录 DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); + ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List alarmRecords = alarmRecordsService.alarmListNoPage(dataScope, keywords, alarmType, alarmContent, beginTime, endTime, areaId); - for (AlarmRecords alarmRecord : alarmRecords) { - alarmRecordsService.cancelAlarmById(alarmRecord.getId()); + alarmRecordsService.cancelAlarm(alarmRecord.getJobId(),"4","手动消警",currentUser.getId()); } return ResponseData.success(); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/model/JobListParam.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/model/JobListParam.java new file mode 100644 index 0000000..c83bff8 --- /dev/null +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/model/JobListParam.java @@ -0,0 +1,32 @@ +package com.casic.missiles.modular.alarm.model; + + +import lombok.Data; + +/** + * @author cz + * @date 2022-6-13 17:03 + */ +@Data +public class JobListParam { + /** + * 关键字 + */ + private String keywords; + /** + * 风险等级 + */ + private String alarmLevel; + private String alarmContent; + private String jobStatus; + private String beginTime; + private String endTime; + private String getJobBeginTime; + private String getJobEndTime; + private String shouldGetBeginTime; + private String shouldGetEndTime; + private String handleJobBeginTime; + private String handleJobEndTime; + private String shouldHandleBeginTime; + private String shouldHandleEndTime; +} diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java index d4db8ce..018d095 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java @@ -3,6 +3,7 @@ import com.baomidou.mybatisplus.plugins.Page; import com.baomidou.mybatisplus.service.IService; import com.casic.missiles.core.datascope.DataScope; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.system.dto.UserClientView; import com.casic.missiles.modular.system.model.AlarmJob; @@ -18,42 +19,60 @@ * @since 2019-05-17 */ public interface IAlarmJobService extends IService { - List> jobList( Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType,String alarmContent, DataScope dataScope,Long userId); - List> jobListApp( Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType,String alarmContent,Long deptId,Long userId,Long leaderId); + + List> jobList(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, DataScope dataScope, Long userId); + + List> jobListApp(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, Long deptId, Long userId, Long leaderId); // List jobListExport( Page page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType,String alarmContent, DataScope dataScope); - List> jobListDelayRe( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, DataScope dataScope,Long userId); - List> jobListDelayReApp( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, Long deptId,Long userId,Long leaderId); + List> jobListDelayRe(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId); - List> jobListDelayPro( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, DataScope dataScope,Long userId ); - List> jobListDelayProApp( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, Long deptId,Long userId,Long leaderId); + List> jobListDelayReApp(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, Long deptId, Long userId, Long leaderId); - List> jobListSearch(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime,String endTime, - String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, - String shouldHandleBeginTime, String shouldHandleEndTime, DataScope dataScope,Long userId); - List> jobListSearchApp(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime,String endTime, - String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, - String shouldHandleBeginTime, String shouldHandleEndTime, Long deptId, Long userId, Long leaderId); - List> jobInfo(int id, DataScope dataScope,Long personId); - boolean getJob(int id, long personId); - boolean confirmJob(int id,long personId,String firstState, String firstStatePhotos, String needHandle); - boolean transferJob(int id, long transferPerson,String flowRec); - boolean saveJob( int id,String handleMessage, String handlePhotos); - boolean overJob( int id,long personId, String handleMessage, String handlePhotos); - boolean overAlarm( int id); - boolean handleJob(int id,long personId); + List> jobListDelayPro(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId); - Map countByJobStatus(long deptId,int spanDays); - Map countMyJob(long userId,long deptId,int spanDays); + List> jobListDelayProApp(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, Long deptId, Long userId, Long leaderId); + + List> jobListSearch(Page> page, JobListParam jobListParam, DataScope dataScope, Long userId); + + List> jobListSearchApp(Page> page, JobListParam jobListParam, Long deptId, Long userId, Long leaderId); + + List> jobInfo(Long id, DataScope dataScope, Long personId); + + boolean getJob(Long id, long personId); + + boolean confirmJob(Long id, long personId, String firstState, String firstStatePhotos, String needHandle); + + boolean transferJob(Long id, long transferPerson, String flowRec); + + boolean saveJob(Long id, String handleMessage, String handlePhotos); + + boolean overJob(Long id, long personId, String handleMessage, String handlePhotos); + + boolean overAlarm(int id); + + boolean handleJob(Long id, long personId); + + Map countByJobStatus(long deptId, int spanDays); + + Map countMyJob(long userId, long deptId, int spanDays); boolean checkJobStatus(String jobStatus); + boolean checkPcRole(List roleTips); - Integer countByDataScope(DataScope dataScope,String alarmType, String jobStatus,String beginTime,String endTime); - Integer countByResponse(String alarmType,String jobStatus,Long deptId,String beginTime,String endTime); - Integer countByUser(String alarmType,String jobStatus,Long userId,String beginTime,String endTime); + Integer countByDataScope(DataScope dataScope, String alarmType, String jobStatus, String beginTime, String endTime); - void updateSinkJob(String id,String msg,String wellCode); + Integer countByResponse(String alarmType, String jobStatus, Long deptId, String beginTime, String endTime); + + Integer countByUser(String alarmType, String jobStatus, Long userId, String beginTime, String endTime); + + void updateSinkJob(String id, String msg, String wellCode); + List selectUserByWellCode(String wellCode); + String selectClientIdByUser(Long userId); + + AlarmJob saveData( String devCode, String wellCode, String devTypeName, String jobType); + } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java index 46e7dfe..6eecb2b 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.service.IService; import com.casic.missiles.modular.system.model.AlarmRecords; import com.casic.missiles.core.datascope.DataScope; +import org.apache.ibatis.annotations.Param; import java.util.List; import java.util.Map; @@ -26,4 +27,8 @@ boolean cancelAlarmById(long id); Integer insertAlarmRecord(AlarmRecords alarmRec); + + Boolean isOldAlarmRecord(String devCode,String MsgContent); + + Integer updateOldAlarmRecord(String devCode,String MsgContent); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java index fa6681d..943ebd7 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java @@ -7,12 +7,14 @@ import com.casic.missiles.core.common.service.ICommonUserService; import com.casic.missiles.modular.alarm.job.HandleAlarmJob; import com.casic.missiles.modular.alarm.job.getDelayJob; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.alarm.service.IAlarmJobService; import com.casic.missiles.core.datascope.DataScope; import com.casic.missiles.core.util.EhcacheConstant; import com.casic.missiles.core.util.ToolUtil; import com.casic.missiles.modular.system.dao.AlarmJobMapper; import com.casic.missiles.modular.system.dao.AlarmRecordsMapper; +import com.casic.missiles.modular.system.dto.DeviceTypeEnum; import com.casic.missiles.modular.system.dto.SelectDto; import com.casic.missiles.modular.system.dto.UserClientView; import com.casic.missiles.modular.system.model.AlarmJob; @@ -24,6 +26,8 @@ import com.casic.missiles.quartz.service.IQuartzManager; import com.gexin.rp.sdk.base.IPushResult; import com.google.gson.GsonBuilder; +import net.sf.ehcache.search.Query; +import net.sf.ehcache.search.expression.Criteria; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -48,6 +52,8 @@ public class AlarmJobServiceImpl extends ServiceImpl implements IAlarmJobService { private static final Logger logger = LoggerFactory.getLogger(AlarmJobServiceImpl.class); + public static final SimpleDateFormat sdf6 = new SimpleDateFormat("yyyyMMdd"); + private static Map deviceAlarmMap = new HashMap(); @Value("${smartcity.leaderRoleName}") private String sLeader; @@ -70,12 +76,14 @@ @Resource private IQuartzManager quartzManager; - @Autowired IBusWellInfoService busWellInfoService; + @Autowired + IBusWellInfoService busWellInfoService; @Override - public List> jobList(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, DataScope dataScope,Long userId) { + public List> jobList(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, DataScope dataScope, Long userId) { alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobList(page, keywords, beginTime, endTime, jobStatus, alarmType, alarmContent, dataScope,userId);return alarmJobList; + List> alarmJobList = this.baseMapper.jobList(page, keywords, beginTime, endTime, jobStatus, alarmType, alarmContent, dataScope, userId); + return alarmJobList; } @Override @@ -86,9 +94,9 @@ } @Override - public List> jobListDelayRe(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope,Long userId) { + public List> jobListDelayRe(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId) { alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListDelayRe(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope,userId); + List> alarmJobList = this.baseMapper.jobListDelayRe(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope, userId); return alarmJobList; } @@ -100,9 +108,9 @@ } @Override - public List> jobListDelayPro(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope,Long userId) { + public List> jobListDelayPro(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId) { alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListDelayPro(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope,userId); + List> alarmJobList = this.baseMapper.jobListDelayPro(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope, userId); return alarmJobList; } @@ -114,109 +122,115 @@ } @Override - public List> jobListSearch(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime, String endTime, String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, String shouldHandleBeginTime, String shouldHandleEndTime, DataScope dataScope,Long userId) { - alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListSearch(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, dataScope,userId); + public List> jobListSearch(Page> page, JobListParam jobListParam, DataScope dataScope, Long userId) { + jobListParam.setAlarmContent(converAlarmContent(jobListParam.getAlarmContent())); + List> alarmJobList = this.baseMapper.jobListSearch(page, jobListParam, dataScope, userId); return alarmJobList; } @Override - public List> jobListSearchApp(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime, String endTime, String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, String shouldHandleBeginTime, String shouldHandleEndTime, Long deptId, Long userId, Long leaderId) { - alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListSearchApp(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, deptId, userId, leaderId); + public List> jobListSearchApp(Page> page, JobListParam jobListParam, Long deptId, Long userId, Long leaderId) { + jobListParam.setAlarmContent(converAlarmContent(jobListParam.getAlarmContent())); + List> alarmJobList = this.baseMapper.jobListSearchApp(page, jobListParam.getKeywords(), + jobListParam.getAlarmLevel(), jobListParam.getAlarmContent(), jobListParam.getJobStatus(), jobListParam.getBeginTime(), + jobListParam.getEndTime(), jobListParam.getGetJobBeginTime(), jobListParam.getGetJobEndTime(), jobListParam.getShouldGetBeginTime(), + jobListParam.getShouldGetEndTime(), jobListParam.getHandleJobBeginTime(), jobListParam.getHandleJobEndTime(), jobListParam.getShouldHandleBeginTime(), + jobListParam.getShouldHandleEndTime(), deptId, userId, leaderId); return alarmJobList; } - private String converAlarmContent(String alarmContent){ - if(ToolUtil.isEmpty(alarmContent)){ + private String converAlarmContent(String alarmContent) { + if (ToolUtil.isEmpty(alarmContent)) { return alarmContent; - }else { + } else { return EhcacheConstant.retBean().getAlarmContentName(Integer.valueOf(alarmContent)); } } @Override - public List> jobInfo(int id, DataScope dataScope, Long personId) - { - List> job = this.baseMapper.jobInfo(id,dataScope,personId); + public List> jobInfo(Long id, DataScope dataScope, Long personId) { + List> job = this.baseMapper.jobInfo(id, dataScope, personId); return job; } @Override - public Map countByJobStatus(long deptId,int spanDays) { - return this.baseMapper.countByJobStatus(deptId,spanDays); + public Map countByJobStatus(long deptId, int spanDays) { + return this.baseMapper.countByJobStatus(deptId, spanDays); } @Override - public Map countMyJob(long userId,long deptId,int spanDays) { - return this.baseMapper.countMyJob(userId,deptId,spanDays); + public Map countMyJob(long userId, long deptId, int spanDays) { + return this.baseMapper.countMyJob(userId, deptId, spanDays); } @Override - public boolean getJob(int id, long personId) { + public boolean getJob(Long id, long personId) { Calendar now = Calendar.getInstance(); Date getTime = now.getTime(); - if(isWeekend(now)){ + if (isWeekend(now)) { now.add(Calendar.WEEK_OF_YEAR, 1); - now.set(Calendar.DAY_OF_WEEK ,Calendar.TUESDAY); - now.set(Calendar.HOUR_OF_DAY,8); - now.set(Calendar.MINUTE,0); - now.set(Calendar.SECOND,0); - }else { + now.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY); + now.set(Calendar.HOUR_OF_DAY, 8); + now.set(Calendar.MINUTE, 0); + now.set(Calendar.SECOND, 0); + } else { now.add(Calendar.HOUR, 24); - while(isWeekend(now)){ + while (isWeekend(now)) { now.add(Calendar.HOUR, 24); } } Date shouldHandleTime = now.getTime(); - if(Boolean.getBoolean(useOverTime)){ + if (Boolean.getBoolean(useOverTime)) { System.out.println(shouldHandleTime); String jobName = "getJobDelay" + id; - Map map = new HashMap<>(); - map.put("jobId",id); - map.put("iAlarmJobService",this); - map.put("iCommonUserService",iCommonUserService); - map.put("iQuartzManager",quartzManager); - map.put("webSocket",webSocket); - quartzManager.addJob(jobName,getDelayJob.class,shouldHandleTime,map); + Map map = new HashMap<>(); + map.put("jobId", id); + map.put("iAlarmJobService", this); + map.put("iCommonUserService", iCommonUserService); + map.put("iQuartzManager", quartzManager); + map.put("webSocket", webSocket); + quartzManager.addJob(jobName, getDelayJob.class, shouldHandleTime, map); } - return this.baseMapper.getJob(id,personId,getTime,shouldHandleTime); + return this.baseMapper.getJob(id, personId, getTime, shouldHandleTime); } - private boolean isWeekend(Calendar cal){ - if(cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY){ + private boolean isWeekend(Calendar cal) { + if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) { return true; - } else{ + } else { return false; } } @Override - public boolean confirmJob(int id,long personId, String firstState, String firstStatePhotos, String needHandle) { - if ("1".equals(needHandle)){ - return this.baseMapper.confirmJob(id,personId, firstState, firstStatePhotos, needHandle); + public boolean confirmJob(Long id, long personId, String firstState, String firstStatePhotos, String needHandle) { + if ("1".equals(needHandle)) { + return this.baseMapper.confirmJob(id, personId, firstState, firstStatePhotos, needHandle); } else { - return this.baseMapper.confirmOverJobAndAlarm(id, personId,firstState, firstStatePhotos); + return this.baseMapper.confirmOverJobAndAlarm(id, personId, firstState, firstStatePhotos); } } @Override - public boolean transferJob(int id, long transferPerson,String flowRec) { - return this.baseMapper.transferJob(id, transferPerson,flowRec); + public boolean transferJob(Long id, long transferPerson, String flowRec) { + return this.baseMapper.transferJob(id, transferPerson, flowRec); } @Override - public boolean saveJob(int id, String handleMessage, String handlePhotos) { + public boolean saveJob(Long id, String handleMessage, String handlePhotos) { return this.baseMapper.saveJob(id, handleMessage, handlePhotos); } @Override - public boolean overJob(int id,long personId, String handleMessage, String handlePhotos) { - return this.baseMapper.overJobAndAlarm(id, personId,handleMessage, handlePhotos); + public boolean overJob(Long id, long personId, String handleMessage, String handlePhotos) { + + return this.baseMapper.overJobAndAlarm(id, personId, handleMessage, handlePhotos); + // return this.baseMapper.overJob(id, personId,handleMessage, handlePhotos); } + @Override public boolean overAlarm(int jobId) { return this.baseMapper.overAlarm(jobId); @@ -224,15 +238,15 @@ } @Override - public boolean handleJob(int id,long personId) { - return this.baseMapper.handleJob(id,personId); + public boolean handleJob(Long id, long personId) { + return this.baseMapper.handleJob(id, personId); } @Override public boolean checkJobStatus(String jobStatus) { - if(ToolUtil.isEmpty(jobStatus)){ + if (ToolUtil.isEmpty(jobStatus)) { return false; - }else{ + } else { return "1".equals(jobStatus) || "2".equals(jobStatus) || "3".equals(jobStatus); } } @@ -243,10 +257,10 @@ } - public List selectRoles() { return this.baseMapper.selectRoles(); } + public List selectUseIds(List roleIds) { return this.baseMapper.selectUseIds(roleIds); } @@ -255,50 +269,50 @@ public boolean checkPcRole(List roleTips) { List roleList = new ArrayList<>(roleTips); Iterator it = roleList.iterator(); - while (it.hasNext()){ + while (it.hasNext()) { String role = it.next(); - if(role.equals(sApp)||role.equals(sLeader)||role.equals(sMember)){ + if (role.equals(sApp) || role.equals(sLeader) || role.equals(sMember)) { it.remove(); } } - return roleList.size()>0; + return roleList.size() > 0; } @Override - public Integer countByDataScope(DataScope dataScope, String alarmType, String jobStatus, String beginTime,String endTime) { - List> res = this.baseMapper.countByDataScope(dataScope,alarmType,jobStatus,beginTime,endTime); + public Integer countByDataScope(DataScope dataScope, String alarmType, String jobStatus, String beginTime, String endTime) { + List> res = this.baseMapper.countByDataScope(dataScope, alarmType, jobStatus, beginTime, endTime); return res.size(); } @Override - public Integer countByResponse(String alarmType, String jobStatus, Long deptId, String beginTime,String endTime) { - return this.baseMapper.countByResponse(alarmType,jobStatus,deptId,beginTime,endTime); + public Integer countByResponse(String alarmType, String jobStatus, Long deptId, String beginTime, String endTime) { + return this.baseMapper.countByResponse(alarmType, jobStatus, deptId, beginTime, endTime); } @Override - public Integer countByUser(String alarmType, String jobStatus, Long userId, String beginTime,String endTime) { - return this.baseMapper.countByUser(alarmType,jobStatus,userId,beginTime,endTime); + public Integer countByUser(String alarmType, String jobStatus, Long userId, String beginTime, String endTime) { + return this.baseMapper.countByUser(alarmType, jobStatus, userId, beginTime, endTime); } @Override - public void updateSinkJob(String id, String msg,String wellCode) { + public void updateSinkJob(String id, String msg, String wellCode) { List userClientViewList = new ArrayList<>(); List selectDtoList = selectRoles(); EntityWrapper busWellInfoEntityWrapper = new EntityWrapper<>(); - busWellInfoEntityWrapper.eq("WELL_CODE",wellCode); + busWellInfoEntityWrapper.eq("WELL_CODE", wellCode); BusWellInfo busWellInfo = busWellInfoService.selectOne(busWellInfoEntityWrapper); - if(busWellInfo!=null&&ToolUtil.isNotEmpty(busWellInfo.getDeptid())){ - List roleids= new ArrayList<>(); - for(SelectDto selectDto:selectDtoList){ - if(ToolUtil.isNotEmpty(selectDto.getName()) - && Arrays.asList(selectDto.getName().split(",")).contains(busWellInfo.getDeptid())){ + if (busWellInfo != null && ToolUtil.isNotEmpty(busWellInfo.getDeptid())) { + List roleids = new ArrayList<>(); + for (SelectDto selectDto : selectDtoList) { + if (ToolUtil.isNotEmpty(selectDto.getName()) + && Arrays.asList(selectDto.getName().split(",")).contains(busWellInfo.getDeptid())) { roleids.add(selectDto.getId()); } } - if(roleids.size()>0){ + if (roleids.size() > 0) { List useIds = selectUseIds(roleids); - for(Long useId:useIds){ + for (Long useId : useIds) { UserClientView userClientView = new UserClientView(); userClientView.setClientid(useId.toString()); userClientView.setId(useId.toString()); @@ -307,11 +321,11 @@ } } - if(!("null".equals(id))){ + if (!("null".equals(id))) { AlarmJob alarmJob = this.baseMapper.selectById(id); sendJob(id, alarmJob, userClientViewList);//推送工单至app和pc端 } - if(StringUtils.isNotBlank(msg)){ + if (StringUtils.isNotBlank(msg)) { sendAlarm(msg, userClientViewList);//推送告警至app和pc端 } @@ -386,7 +400,7 @@ } Date shouldHandleTime = now.getTime(); - if(Boolean.getBoolean(useOverTime)) { + if (Boolean.getBoolean(useOverTime)) { System.out.println(shouldHandleTime); String jobName = "getJobDelay" + id; Map map = new HashMap<>(); @@ -437,4 +451,40 @@ public String selectClientIdByUser(Long userId) { return this.baseMapper.selectClientIdByUser(userId); } + + + public AlarmJob saveData(String devCode, String wellCode, String devTypeName, String jobType) { + AlarmJob alarmJob = new AlarmJob(); + alarmJob.setDevcode(devCode); + alarmJob.setWellCode(wellCode); + alarmJob.setJobStatus("0"); + alarmJob.setCreateTime(new Date()); + alarmJob.setJobcode(this.produceJobCode(devTypeName)); + alarmJob.setJobType(jobType); + this.baseMapper.insert(alarmJob); + return alarmJob; + } + + /** + * 前缀+日期+4位流水号 + * + * @param devTypeName + * @return + */ + private String produceJobCode(String devTypeName) { + String pre = devTypeName; + String dataStr = sdf6.format(new Date()); + String fix = this.getJobCodeMaxSerial(pre + dataStr); + return StringUtils.isNotBlank(fix) ? pre + dataStr + String.format("%04d", Long.valueOf(fix) + 1L) : pre + dataStr + "0001"; + } + + + private String getJobCodeMaxSerial(String jobcode) { + String MaxSerialJobCode = this.baseMapper.getJobCodeMaxSerial(jobcode); + String fix = ""; + if (null != MaxSerialJobCode && MaxSerialJobCode.length() > 4) { + fix = MaxSerialJobCode.substring(MaxSerialJobCode.length() - 4); + } + return fix; + } } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmRecordsServiceImpl.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmRecordsServiceImpl.java index e0f0959..60fa41a 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmRecordsServiceImpl.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmRecordsServiceImpl.java @@ -16,7 +16,7 @@ /** *

- * 服务实现类 + * 服务实现类 *

* * @author casic123 @@ -27,12 +27,12 @@ @Override - public List> alarmList(Page> page, String keywords, String beginTime, String endTime, String status, String alarmType, String alarmContent, String areaId, DataScope dataScope) { + public List> alarmList(Page> page, String keywords, String beginTime, String endTime, String status, String alarmType, String alarmContent, String areaId, DataScope dataScope) { String sContent = null; - if (ToolUtil.isNotEmpty(alarmContent)){ + if (ToolUtil.isNotEmpty(alarmContent)) { sContent = EhcacheConstant.retBean().getAlarmContentName(Integer.valueOf(alarmContent)); } - return this.baseMapper.alarmList(page,keywords,beginTime,endTime,status,alarmType,sContent, areaId, dataScope); + return this.baseMapper.alarmList(page, keywords, beginTime, endTime, status, alarmType, sContent, areaId, dataScope); } /** @@ -41,15 +41,15 @@ @Override public List alarmListNoPage(DataScope dataScope, String keywords, String alarmType, String alarmContent, String beginTime, String endTime, String areaId) { String sContent = null; - if (ToolUtil.isNotEmpty(alarmContent)){ + if (ToolUtil.isNotEmpty(alarmContent)) { sContent = EhcacheConstant.retBean().getAlarmContentName(Integer.valueOf(alarmContent)); } - return this.baseMapper.alarmListNoPage(dataScope,keywords,alarmType,sContent,beginTime,endTime, areaId); + return this.baseMapper.alarmListNoPage(dataScope, keywords, alarmType, sContent, beginTime, endTime, areaId); } @Override public boolean cancelAlarm(long id, String jobStatus, String handleMessage, long personId) { - return this.baseMapper.cancelAlarm(id,jobStatus,handleMessage,personId); + return this.baseMapper.cancelAlarm(id, jobStatus, handleMessage, personId); } @Override @@ -62,4 +62,15 @@ // this.baseMapper.cancelAlarmByNewRecord(alarmRec.getDevcode(), alarmRec.getAlarmType()); return this.baseMapper.insert(alarmRec); } + + public Boolean isOldAlarmRecord(String devCode, String MsgContent) { + if (this.baseMapper.isOldAlarmRecord(devCode, MsgContent) == null) { + return false; + } + return true; + } + + public Integer updateOldAlarmRecord(String devCode, String MsgContent) { + return this.baseMapper.updateOldAlarmRecord(devCode, MsgContent); + } } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/AlarmMapOverviewController.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/AlarmMapOverviewController.java index 9d60185..214c275 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/AlarmMapOverviewController.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/AlarmMapOverviewController.java @@ -8,14 +8,12 @@ import com.casic.missiles.core.exception.GunsExceptionEnum; import com.casic.missiles.core.base.response.SuccessResponseData; import com.casic.missiles.core.util.ToolUtil; -import com.casic.missiles.modular.system.constant.ModularDictConst; import com.casic.missiles.modular.system.dto.AlarmNowView; import com.casic.missiles.modular.system.dto.DeviceDto; import com.casic.missiles.modular.system.model.BusWellInfo; import com.casic.missiles.modular.system.service.IAlarmNowViewService; import com.casic.missiles.modular.system.service.IBusWellInfoService; import com.casic.missiles.modular.system.service.IDeviceService; -import com.casic.missiles.modular.system.service.impl.BusWellInfoServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataReceiver.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataReceiver.java index 0013989..b3f23d5 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataReceiver.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataReceiver.java @@ -2,6 +2,7 @@ import com.casic.missiles.core.base.controller.BaseController; import com.casic.missiles.core.base.response.ResponseData; +import com.casic.missiles.modular.alarm.service.IAlarmJobService; import com.casic.missiles.modular.alarm.service.IAlarmRecordsService; import com.casic.missiles.modular.alarm.service.IAlarmRuleService; import com.casic.missiles.modular.system.dto.DeviceWellDto; @@ -9,6 +10,7 @@ import com.casic.missiles.modular.system.service.IDeviceService; import com.casic.missiles.modular.system.service.IGasFlowDataService; import lombok.extern.java.Log; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -38,6 +40,9 @@ @Resource private IAlarmRecordsService alarmRecordsService; + @Autowired + IAlarmJobService alarmJobService; + private DecimalFormat df2 = new DecimalFormat("0.00"); @RequestMapping(value = "/data/recv") @@ -117,6 +122,13 @@ alarmRecord.setAlarmTime(Calendar.getInstance().getTime()); alarmRecord.setStatus("1"); alarmRecord.setAlarmMessage("日用气量超阈值报警"); + if (alarmRecordsService.isOldAlarmRecord(gasFlowAddr, "日用气量超阈值报警")) { + alarmRecordsService.updateOldAlarmRecord(gasFlowAddr, "日用气量超阈值报警"); + } else { + AlarmJob alarmJob = alarmJobService.saveData(gasFlowAddr, wellDto.getWellCode(), "SLCX", "1"); + alarmRecord.setJobId(alarmJob.getId()); + } + alarmRecordsService.insertAlarmRecord(alarmRecord); // 向前端推送报警 } else { @@ -134,6 +146,13 @@ alarmRecord.setAlarmTime(Calendar.getInstance().getTime()); alarmRecord.setStatus("1"); alarmRecord.setAlarmMessage("日用气量超阈值预警"); + alarmRecord.setAlarmMessage("日用水量超阈值预警"); + if (alarmRecordsService.isOldAlarmRecord(gasFlowAddr, "日用水量超阈值预警")) { + alarmRecordsService.updateOldAlarmRecord(gasFlowAddr, "日用水量超阈值预警"); + } else { + AlarmJob alarmJob = alarmJobService.saveData(gasFlowAddr, wellDto.getWellCode(), "SLCX", "1"); + alarmRecord.setJobId(alarmJob.getId()); + } alarmRecordsService.insertAlarmRecord(alarmRecord); // 向前端推送报警 } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataReceiver.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataReceiver.java index 6c25e18..200f5d2 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataReceiver.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataReceiver.java @@ -2,16 +2,15 @@ import com.casic.missiles.core.base.controller.BaseController; import com.casic.missiles.core.base.response.ResponseData; +import com.casic.missiles.modular.alarm.service.IAlarmJobService; import com.casic.missiles.modular.alarm.service.IAlarmRecordsService; import com.casic.missiles.modular.alarm.service.IAlarmRuleService; import com.casic.missiles.modular.system.dto.DeviceWellDto; -import com.casic.missiles.modular.system.model.AlarmRecords; -import com.casic.missiles.modular.system.model.AlarmRule; -import com.casic.missiles.modular.system.model.DataWaterMeter; -import com.casic.missiles.modular.system.model.Device; +import com.casic.missiles.modular.system.model.*; import com.casic.missiles.modular.system.service.IDeviceService; import com.casic.missiles.modular.system.service.IWaterMeterDataService; import lombok.extern.java.Log; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -40,6 +39,9 @@ @Resource private IAlarmRecordsService alarmRecordsService; + @Autowired + IAlarmJobService alarmJobService; + private DecimalFormat df2 = new DecimalFormat("0.00"); @RequestMapping(value = "/data/recv") @@ -106,7 +108,6 @@ if (flowAccToday - alarmRule.getHighvalue() > 0) { // 超出报警阈值 生成一条报警消息 AlarmRecords alarmRecord = new AlarmRecords(); - alarmRecord.setDeviceId(device.getId()); alarmRecord.setDevcode(meterAddr); alarmRecord.setWellCode(wellDto.getWellCode()); @@ -116,17 +117,19 @@ alarmRecord.setAlarmTime(Calendar.getInstance().getTime()); alarmRecord.setStatus("1"); alarmRecord.setAlarmMessage("日用水量超阈值报警"); - + if (alarmRecordsService.isOldAlarmRecord(meterAddr, "日用水量超阈值报警")) { + alarmRecordsService.updateOldAlarmRecord(meterAddr, "日用水量超阈值报警"); + } else { + AlarmJob alarmJob = alarmJobService.saveData(meterAddr, wellDto.getWellCode(), "QLCX", "1"); + alarmRecord.setJobId(alarmJob.getId()); + } alarmRecordsService.insertAlarmRecord(alarmRecord); - - // 向前端推送报警 } else { // 如果没有报警则判断是否预警 if (null != alarmRuleWarn && null != alarmRuleWarn.getHighvalue()) { if (flowAccToday - alarmRuleWarn.getHighvalue() > 0) { // 超出预警阈值 生成一条预警消息 AlarmRecords alarmRecord = new AlarmRecords(); - alarmRecord.setDeviceId(device.getId()); alarmRecord.setDevcode(meterAddr); alarmRecord.setWellCode(wellDto.getWellCode()); @@ -136,10 +139,13 @@ alarmRecord.setAlarmTime(Calendar.getInstance().getTime()); alarmRecord.setStatus("1"); alarmRecord.setAlarmMessage("日用水量超阈值预警"); - + if (alarmRecordsService.isOldAlarmRecord(meterAddr, "日用水量超阈值预警")) { + alarmRecordsService.updateOldAlarmRecord(meterAddr, "日用水量超阈值预警"); + } else { + AlarmJob alarmJob = alarmJobService.saveData(meterAddr, wellDto.getWellCode(), "QLCX", "1"); + alarmRecord.setJobId(alarmJob.getId()); + } alarmRecordsService.insertAlarmRecord(alarmRecord); - - // 向前端推送报警 } } } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmJobMapper.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmJobMapper.java index 6592517..ccdff9a 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmJobMapper.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmJobMapper.java @@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.mapper.BaseMapper; import com.baomidou.mybatisplus.plugins.Page; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.system.dto.SelectDto; import com.casic.missiles.modular.system.dto.UserClientView; import com.casic.missiles.modular.system.model.AlarmJob; @@ -21,44 +22,65 @@ * @since 2019-05-17 */ public interface AlarmJobMapper extends BaseMapper { - List> jobList(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("jobStatus") String jobStatus, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("dataScope") DataScope dataScope,@Param("userId")Long userId); - List> jobListApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("jobStatus") String jobStatus, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("deptId")Long deptId,@Param("userId")Long userId,@Param("leaderId")Long leaderId); + List> jobList(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("jobStatus") String jobStatus, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("dataScope") DataScope dataScope, @Param("userId") Long userId); + + List> jobListApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("jobStatus") String jobStatus, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("deptId") Long deptId, @Param("userId") Long userId, @Param("leaderId") Long leaderId); + // List jobListExport(@Param("page") Page page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("jobStatus") String jobStatus, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("dataScope") DataScope dataScope); - List> jobListDelayRe(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("dataScope") DataScope dataScope,@Param("userId")Long userId); - List> jobListDelayReApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("deptId")Long deptId,@Param("userId")Long userId,@Param("leaderId")Long leaderId); + List> jobListDelayRe(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("dataScope") DataScope dataScope, @Param("userId") Long userId); - List> jobListDelayPro(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("dataScope") DataScope dataScope,@Param("userId")Long userId); - List> jobListDelayProApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("deptId")Long deptId,@Param("userId")Long userId,@Param("leaderId")Long leaderId); + List> jobListDelayReApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("deptId") Long deptId, @Param("userId") Long userId, @Param("leaderId") Long leaderId); - List> jobListSearchApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("alarmLevel")String alarmLevel, @Param("alarmContent") String alarmContent, @Param("jobStatus") String jobStatus, @Param("beginTime") String beginTime, @Param("endTime") String endTime, - @Param("getJobBeginTime") String getJobBeginTime, @Param("getJobEndTime") String getJobEndTime, @Param("shouldGetBeginTime") String shouldGetBeginTime, @Param("shouldGetEndTime") String shouldGetEndTime, - @Param("handleJobBeginTime") String handleJobBeginTime, @Param("handleJobEndTime") String handleJobEndTime, @Param("shouldHandleBeginTime") String shouldHandleBeginTime, @Param("shouldHandleEndTime") String shouldHandleEndTime, - @Param("deptId")Long deptId, @Param("userId")Long userId, @Param("leaderId")Long leaderId); - List> jobListSearch(@Param("page") Page> page, @Param("keywords") String keywords, @Param("alarmLevel")String alarmLevel, @Param("alarmContent") String alarmContent, @Param("jobStatus") String jobStatus, @Param("beginTime") String beginTime, @Param("endTime") String endTime, - @Param("getJobBeginTime") String getJobBeginTime, @Param("getJobEndTime") String getJobEndTime, @Param("shouldGetBeginTime") String shouldGetBeginTime, @Param("shouldGetEndTime") String shouldGetEndTime, - @Param("handleJobBeginTime") String handleJobBeginTime, @Param("handleJobEndTime") String handleJobEndTime, @Param("shouldHandleBeginTime") String shouldHandleBeginTime, @Param("shouldHandleEndTime") String shouldHandleEndTime, - @Param("dataScope") DataScope dataScope,@Param("userId")Long userId); + List> jobListDelayPro(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("dataScope") DataScope dataScope, @Param("userId") Long userId); - Map countByJobStatus(@Param("deptId")long deptId,@Param("spanDays") int spanDays); - Map countMyJob(@Param("userId")long userId,@Param("deptId")long deptId,@Param("spanDays") int spanDays); - List> jobInfo(@Param("id") int id,@Param("dataScope") DataScope dataScope,@Param("personId") Long personId); -// boolean getJob(@Param("id") int id,@Param("personId") long personId); - boolean getJob(@Param("id") int id,@Param("personId") long personId,@Param("getTime")Date getTime ,@Param("shouldHandleTime")Date shouldHandleTime); - boolean confirmJob(@Param("id") int id,@Param("personId") long personId,@Param("firstState") String firstState,@Param("firstStatePhotos") String firstStatePhotos,@Param("needHandle") String needHandle); - boolean confirmOverJobAndAlarm(@Param("id") int id,@Param("personId") long personId,@Param("firstState") String firstState,@Param("firstStatePhotos") String firstStatePhotos); - boolean transferJob(@Param("id") int id,@Param("transferPerson") long transferPerson,@Param("flowRec") String flowRec); - boolean saveJob(@Param("id") int id,@Param("handleMessage") String handleMessage,@Param("handlePhotos") String handlePhotos); - boolean overJob(@Param("id") int id,@Param("personId") long personId,@Param("handleMessage") String handleMessage,@Param("handlePhotos") String handlePhotos); + List> jobListDelayProApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("deptId") Long deptId, @Param("userId") Long userId, @Param("leaderId") Long leaderId); + + List> jobListSearchApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("alarmLevel") String alarmLevel, @Param("alarmContent") String alarmContent, @Param("jobStatus") String jobStatus, @Param("beginTime") String beginTime, @Param("endTime") String endTime, + @Param("getJobBeginTime") String getJobBeginTime, @Param("getJobEndTime") String getJobEndTime, @Param("shouldGetBeginTime") String shouldGetBeginTime, @Param("shouldGetEndTime") String shouldGetEndTime, + @Param("handleJobBeginTime") String handleJobBeginTime, @Param("handleJobEndTime") String handleJobEndTime, @Param("shouldHandleBeginTime") String shouldHandleBeginTime, @Param("shouldHandleEndTime") String shouldHandleEndTime, + @Param("deptId") Long deptId, @Param("userId") Long userId, @Param("leaderId") Long leaderId); + + List> jobListSearch(@Param("page") Page> page, @Param("jobListParam") JobListParam jobListParam, + @Param("dataScope") DataScope dataScope, @Param("userId") Long userId); + + Map countByJobStatus(@Param("deptId") long deptId, @Param("spanDays") int spanDays); + + Map countMyJob(@Param("userId") long userId, @Param("deptId") long deptId, @Param("spanDays") int spanDays); + + List> jobInfo(@Param("id") Long id, @Param("dataScope") DataScope dataScope, @Param("personId") Long personId); + + // boolean getJob(@Param("id") int id,@Param("personId") long personId); + boolean getJob(@Param("id") Long id, @Param("personId") long personId, @Param("getTime") Date getTime, @Param("shouldHandleTime") Date shouldHandleTime); + + boolean confirmJob(@Param("id") Long id, @Param("personId") long personId, @Param("firstState") String firstState, @Param("firstStatePhotos") String firstStatePhotos, @Param("needHandle") String needHandle); + + boolean confirmOverJobAndAlarm(@Param("id") Long id, @Param("personId") long personId, @Param("firstState") String firstState, @Param("firstStatePhotos") String firstStatePhotos); + + boolean transferJob(@Param("id") Long id, @Param("transferPerson") long transferPerson, @Param("flowRec") String flowRec); + + boolean saveJob(@Param("id") Long id, @Param("handleMessage") String handleMessage, @Param("handlePhotos") String handlePhotos); + + boolean overJob(@Param("id") int id, @Param("personId") long personId, @Param("handleMessage") String handleMessage, @Param("handlePhotos") String handlePhotos); + boolean overAlarm(@Param("jobId") int id); - boolean overJobAndAlarm(@Param("id") int id,@Param("personId") long personId,@Param("handleMessage") String handleMessage,@Param("handlePhotos") String handlePhotos); - boolean handleJob(@Param("id") int id,@Param("personId") long personId); - List> countByDataScope(@Param("dataScope") DataScope dataScope,@Param("alarmType")String alarmType,@Param("jobStatus")String jobStatus,@Param("beginTime")String beginTime,@Param("endTime")String endTime); - Integer countByResponse(@Param("alarmType")String alarmType,@Param("jobStatus")String jobStatus,@Param("deptId") Long deptId,@Param("beginTime")String beginTime,@Param("endTime")String endTime); - Integer countByUser(@Param("alarmType")String alarmType,@Param("jobStatus")String jobStatus,@Param("userId") Long userId,@Param("beginTime")String beginTime,@Param("endTime")String endTime); + boolean overJobAndAlarm(@Param("id") Long id, @Param("personId") long personId, @Param("handleMessage") String handleMessage, @Param("handlePhotos") String handlePhotos); + + boolean handleJob(@Param("id") Long id, @Param("personId") long personId); + + List> countByDataScope(@Param("dataScope") DataScope dataScope, @Param("alarmType") String alarmType, @Param("jobStatus") String jobStatus, @Param("beginTime") String beginTime, @Param("endTime") String endTime); + + Integer countByResponse(@Param("alarmType") String alarmType, @Param("jobStatus") String jobStatus, @Param("deptId") Long deptId, @Param("beginTime") String beginTime, @Param("endTime") String endTime); + + Integer countByUser(@Param("alarmType") String alarmType, @Param("jobStatus") String jobStatus, @Param("userId") Long userId, @Param("beginTime") String beginTime, @Param("endTime") String endTime); String selectClientIdByUser(@Param("userId") Long userId); + List selectUserByWellCode(@Param("wellCode") String wellCode); + List selectUseIds(@Param("roleIds") List roleIds); + List selectRoles(); + + String getJobCodeMaxSerial(@Param("jobcode") String jobcode); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmRecordsMapper.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmRecordsMapper.java index 87a71ff..d4c6a8b 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmRecordsMapper.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmRecordsMapper.java @@ -11,7 +11,7 @@ /** *

- * Mapper 接口 + * Mapper 接口 *

* * @author casic123 @@ -19,13 +19,18 @@ */ public interface AlarmRecordsMapper extends BaseMapper { - List> alarmList(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("status") String status, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("areaId") String areaId, @Param("dataScope") DataScope dataScope); + List> alarmList(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("status") String status, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("areaId") String areaId, @Param("dataScope") DataScope dataScope); List alarmListNoPage(@Param("scope") DataScope dataScope, @Param("keywords") String keywords, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("areaId") String areaId); - boolean cancelAlarm(@Param("id") long id, @Param("jobStatus")String jobStatus,@Param("handleMessage") String handleMessage,@Param("personId") long personId); + boolean cancelAlarm(@Param("id") long id, @Param("jobStatus") String jobStatus, @Param("handleMessage") String handleMessage, @Param("personId") long personId); boolean cancelAlarmById(@Param("id") long id); boolean cancelAlarmByNewRecord(@Param("devcode") String devcode, @Param("alarmType") String alarmType); + + String isOldAlarmRecord(@Param("devcode") String devcode, @Param("MsgContent") String MsgContent); + + Integer updateOldAlarmRecord(@Param("devcode") String devcode, @Param("MsgContent") String MsgContent); + } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmJobMapper.xml b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmJobMapper.xml index cd850b4..5aeef97 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmJobMapper.xml +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmJobMapper.xml @@ -65,6 +65,7 @@ GROUP BY aj.id ) c + + + + + + + + + + diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java index 46bb487..d27afa9 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java @@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.plugins.Page; import com.casic.missiles.core.base.response.ResponseData; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.alarm.service.IAlarmJobService; import com.casic.missiles.core.common.service.ICommonPermissionService; import com.casic.missiles.core.datascope.DataScope; @@ -12,12 +13,14 @@ import com.casic.missiles.modular.system.warpper.AlarmJobWarpper; import com.casic.missiles.core.base.controller.BaseController; import com.casic.missiles.core.common.constant.factory.PageFactory; +import lombok.extern.slf4j.Slf4j; import org.hswebframework.expands.office.excel.ExcelIO; import org.json.JSONException; import org.json.JSONObject; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; @@ -29,6 +32,7 @@ import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.*; //import com.casic.missiles.core.base.response.ResponseData; @@ -40,6 +44,7 @@ * @Date 2019-05-17 10:48:36 */ @Controller +@Slf4j @RequestMapping("/job") public class AlarmJobController extends BaseController { @@ -65,6 +70,13 @@ private String templatePath; + /** + * 工单状态接口统计 + * + * @param httpServletRequest + * @return + * @throws ParseException + */ @RequestMapping(value = "/countByJobStatus") @ResponseBody public Object countByJobStatus(HttpServletRequest httpServletRequest) throws ParseException { @@ -117,7 +129,7 @@ } /** - * 获取分页列表 + * 获取工单分页列表 */ @RequestMapping(value = "/list") @ResponseBody @@ -164,30 +176,26 @@ */ @RequestMapping(value = "/searchList") @ResponseBody - public Object jobListSearch(String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime, String endTime, - String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, - String handleJobBeginTime, String handleJobEndTime, String shouldHandleBeginTime, String shouldHandleEndTime) { + public Object jobListSearch(@RequestBody JobListParam jobListParam) { Page> page = new PageFactory>().defaultPage("createTime", false); DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List> retList = new ArrayList<>(); if (alarmJobService.checkPcRole(currentUser.getRoleTips())) { // pc角色 - retList = alarmJobService.jobListSearch(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, - handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, dataScope, currentUser.getId()); + retList = alarmJobService.jobListSearch(page, jobListParam, dataScope, currentUser.getId()); } else { //app角色 long leaderId = 0L; if (currentUser.getRoleTips().contains(sLeader)) { // 组长,查组内全部 leaderId = currentUser.getId(); - if (ToolUtil.isNotEmpty(jobStatus)) { + if (ToolUtil.isNotEmpty(jobListParam.getJobStatus())) { //learder&&jobStatus=1,2,3时,关闭传入的sort,按sql排序(自己的排在前) - page.setOpenSort(!alarmJobService.checkJobStatus(jobStatus)); + page.setOpenSort(!alarmJobService.checkJobStatus(jobListParam.getJobStatus())); } } - retList = alarmJobService.jobListSearchApp(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, - handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, currentUser.getDeptId(), currentUser.getId(), leaderId); + retList = alarmJobService.jobListSearchApp(page, jobListParam, currentUser.getDeptId(), currentUser.getId(), leaderId); } new AlarmJobWarpper(retList).warp(); @@ -277,26 +285,24 @@ @RequestMapping(value = "/export") public void exportJob(HttpServletRequest httpServletRequest , HttpServletResponse httpServletResponse) throws IOException { - Page> page = new PageFactory>().defaultPage("createTime", false); page.setLimit(maxRowsExcel); page.setSize(maxRowsExcel); page.setSearchCount(false); page.setOffset(0); - String keywords = httpServletRequest.getParameter("keywords"); String beginTime = httpServletRequest.getParameter("beginTime"); String endTime = httpServletRequest.getParameter("endTime"); String jobStatusStr = httpServletRequest.getParameter("jobStatus"); String alarmTypeStr = httpServletRequest.getParameter("alarmType"); String alarmContentStr = httpServletRequest.getParameter("alarmContentType"); - - List> jobExpList = new ArrayList<>(); + log.debug("主题参数---------------" + keywords + "," + beginTime + "," + endTime + "," + jobStatusStr + "," + alarmTypeStr + "," + alarmContentStr); DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - jobExpList = alarmJobService.jobList(page, keywords, beginTime, endTime, jobStatusStr, alarmTypeStr, alarmContentStr, dataScope, currentUser.getId()); + List> jobExpList = alarmJobService.jobList(page, keywords, beginTime, endTime, jobStatusStr, alarmTypeStr, alarmContentStr, dataScope, currentUser.getId()); new AlarmJobWarpper(jobExpList).warp(); FileInputStream fileInputStream = null; + log.debug("----------------" + ToolUtil.isEmpty(jobExpList)); if (ToolUtil.isEmpty(jobExpList)) { fileInputStream = new FileInputStream(templatePath + "/jobRecEmpty.xlsx"); } else { @@ -305,12 +311,10 @@ try { httpServletResponse.setContentType("application/octet-stream"); httpServletResponse.addHeader("Content-Disposition", " attachment;filename=" + "jobOverview.xlsx"); - Map var = new HashMap<>(); var.put("标题", "工单一览表"); var.put("list", jobExpList); ExcelIO.writeTemplate(fileInputStream, httpServletResponse.getOutputStream(), var); - } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { @@ -328,11 +332,11 @@ */ @RequestMapping(value = "/getJob") @ResponseBody - public Object getJob(int id) { + public Object getJob(Long id) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - if (alarmJobService.getJob(id, currentUser.getId())){ + if (alarmJobService.getJob(id, currentUser.getId())) { return ResponseData.success(); } else { return ResponseData.error("接单失败"); @@ -344,10 +348,10 @@ */ @RequestMapping(value = "/confirmJob") @ResponseBody - public Object confirmJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "firstState", required = true) String firstState, - @RequestParam(value = "firstStatePhotos", required = true) String firstStatePhotos, - @RequestParam(value = "needHandle", required = true) String needHandle) { + public Object confirmJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "firstState", required = true) String firstState, + @RequestParam(value = "firstStatePhotos", required = true) String firstStatePhotos, + @RequestParam(value = "needHandle", required = true) String needHandle) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.confirmJob(id, currentUser.getId(), firstState, firstStatePhotos, needHandle)) { return ResponseData.success(); @@ -361,17 +365,19 @@ */ @RequestMapping(value = "/transferJob") @ResponseBody - public Object transferJob(@RequestParam(value = "id", required = true) int id, + public Object transferJob(@RequestParam(value = "id", required = true) Long id, @RequestParam(value = "transferPerson", required = true) String transferPerson) throws JSONException { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - String dbTime = iSysDictService.getDBtime(); +// String dbTime = iSysDictService.getDBtime(); + SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); +// String dbTime = iSysDictService.getDBtime(); + Date dbTime = new Date(); JSONObject jsonObject = new JSONObject(); jsonObject.put("from", currentUser.getName()); jsonObject.put("to", EhcacheConstant.retBean().getUsernameById(Long.valueOf(transferPerson))); - jsonObject.put("time", dbTime); - + jsonObject.put("time", dateFormat.format(dbTime)); if (alarmJobService.transferJob(id, Long.valueOf(transferPerson), jsonObject.toString())) { return ResponseData.success(); } else { @@ -384,9 +390,9 @@ */ @RequestMapping(value = "/saveJob") @ResponseBody - public Object saveJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "handleMessage", required = true) String handleMessage, - @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { + public Object saveJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "handleMessage", required = true) String handleMessage, + @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { if (alarmJobService.saveJob(id, handleMessage, handlePhotos)) { return ResponseData.success(); @@ -400,10 +406,9 @@ */ @RequestMapping(value = "/overJob") @ResponseBody - public Object overJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "handleMessage", required = true) String handleMessage, - @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { - + public Object overJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "handleMessage", required = true) String handleMessage, + @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.overJob(id, currentUser.getId(), handleMessage, handlePhotos)) { @@ -419,7 +424,7 @@ */ @RequestMapping(value = "/handleJob") @ResponseBody - public Object handleJob(@RequestParam(value = "id", required = true) int id) { + public Object handleJob(@RequestParam(value = "id", required = true) Long id) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.handleJob(id, currentUser.getId())) { return ResponseData.success(); @@ -433,12 +438,10 @@ */ @RequestMapping(value = "/info") @ResponseBody - public Object jobInfo(@RequestParam(value = "id", required = true) int id) { - + public Object jobInfo(@RequestParam(value = "id", required = true) long id) { DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List> retList = alarmJobService.jobInfo(id, dataScope, currentUser.getId()); - new AlarmJobWarpper(retList).warp(); return ResponseData.success(retList); } @@ -456,7 +459,7 @@ @RequestParam(value = "wellCode", required = true) String wellCode) { Map retMap = new HashMap<>(); try { - alarmJobService.updateSinkJob(id, URLDecoder.decode(msg, "UTF-8"),wellCode); + alarmJobService.updateSinkJob(id, URLDecoder.decode(msg, "UTF-8"), wellCode); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java index 26a2ba7..df59231 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java @@ -52,6 +52,7 @@ @Autowired private IDeviceService deviceService; + @Value("${smartcity.office.maxRowsExcel}") private int maxRowsExcel; @Value("${smartcity.config.config-path}") @@ -182,7 +183,8 @@ @RequestMapping(value = "/cancelAlarmById") @ResponseBody public Object cancelAlarmById(@RequestParam(value = "alarmId",required = true) long alarmId){ - boolean isCancel = alarmRecordsService.cancelAlarmById(alarmId); + ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); + boolean isCancel = alarmRecordsService.cancelAlarm(alarmId,"4","手动消警",currentUser.getId()); if(isCancel){ return ResponseData.success(); }else { @@ -235,10 +237,10 @@ //根据查询条件查询alarm_record记录 DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); + ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List alarmRecords = alarmRecordsService.alarmListNoPage(dataScope, keywords, alarmType, alarmContent, beginTime, endTime, areaId); - for (AlarmRecords alarmRecord : alarmRecords) { - alarmRecordsService.cancelAlarmById(alarmRecord.getId()); + alarmRecordsService.cancelAlarm(alarmRecord.getJobId(),"4","手动消警",currentUser.getId()); } return ResponseData.success(); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/model/JobListParam.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/model/JobListParam.java new file mode 100644 index 0000000..c83bff8 --- /dev/null +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/model/JobListParam.java @@ -0,0 +1,32 @@ +package com.casic.missiles.modular.alarm.model; + + +import lombok.Data; + +/** + * @author cz + * @date 2022-6-13 17:03 + */ +@Data +public class JobListParam { + /** + * 关键字 + */ + private String keywords; + /** + * 风险等级 + */ + private String alarmLevel; + private String alarmContent; + private String jobStatus; + private String beginTime; + private String endTime; + private String getJobBeginTime; + private String getJobEndTime; + private String shouldGetBeginTime; + private String shouldGetEndTime; + private String handleJobBeginTime; + private String handleJobEndTime; + private String shouldHandleBeginTime; + private String shouldHandleEndTime; +} diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java index d4db8ce..018d095 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java @@ -3,6 +3,7 @@ import com.baomidou.mybatisplus.plugins.Page; import com.baomidou.mybatisplus.service.IService; import com.casic.missiles.core.datascope.DataScope; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.system.dto.UserClientView; import com.casic.missiles.modular.system.model.AlarmJob; @@ -18,42 +19,60 @@ * @since 2019-05-17 */ public interface IAlarmJobService extends IService { - List> jobList( Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType,String alarmContent, DataScope dataScope,Long userId); - List> jobListApp( Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType,String alarmContent,Long deptId,Long userId,Long leaderId); + + List> jobList(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, DataScope dataScope, Long userId); + + List> jobListApp(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, Long deptId, Long userId, Long leaderId); // List jobListExport( Page page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType,String alarmContent, DataScope dataScope); - List> jobListDelayRe( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, DataScope dataScope,Long userId); - List> jobListDelayReApp( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, Long deptId,Long userId,Long leaderId); + List> jobListDelayRe(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId); - List> jobListDelayPro( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, DataScope dataScope,Long userId ); - List> jobListDelayProApp( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, Long deptId,Long userId,Long leaderId); + List> jobListDelayReApp(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, Long deptId, Long userId, Long leaderId); - List> jobListSearch(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime,String endTime, - String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, - String shouldHandleBeginTime, String shouldHandleEndTime, DataScope dataScope,Long userId); - List> jobListSearchApp(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime,String endTime, - String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, - String shouldHandleBeginTime, String shouldHandleEndTime, Long deptId, Long userId, Long leaderId); - List> jobInfo(int id, DataScope dataScope,Long personId); - boolean getJob(int id, long personId); - boolean confirmJob(int id,long personId,String firstState, String firstStatePhotos, String needHandle); - boolean transferJob(int id, long transferPerson,String flowRec); - boolean saveJob( int id,String handleMessage, String handlePhotos); - boolean overJob( int id,long personId, String handleMessage, String handlePhotos); - boolean overAlarm( int id); - boolean handleJob(int id,long personId); + List> jobListDelayPro(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId); - Map countByJobStatus(long deptId,int spanDays); - Map countMyJob(long userId,long deptId,int spanDays); + List> jobListDelayProApp(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, Long deptId, Long userId, Long leaderId); + + List> jobListSearch(Page> page, JobListParam jobListParam, DataScope dataScope, Long userId); + + List> jobListSearchApp(Page> page, JobListParam jobListParam, Long deptId, Long userId, Long leaderId); + + List> jobInfo(Long id, DataScope dataScope, Long personId); + + boolean getJob(Long id, long personId); + + boolean confirmJob(Long id, long personId, String firstState, String firstStatePhotos, String needHandle); + + boolean transferJob(Long id, long transferPerson, String flowRec); + + boolean saveJob(Long id, String handleMessage, String handlePhotos); + + boolean overJob(Long id, long personId, String handleMessage, String handlePhotos); + + boolean overAlarm(int id); + + boolean handleJob(Long id, long personId); + + Map countByJobStatus(long deptId, int spanDays); + + Map countMyJob(long userId, long deptId, int spanDays); boolean checkJobStatus(String jobStatus); + boolean checkPcRole(List roleTips); - Integer countByDataScope(DataScope dataScope,String alarmType, String jobStatus,String beginTime,String endTime); - Integer countByResponse(String alarmType,String jobStatus,Long deptId,String beginTime,String endTime); - Integer countByUser(String alarmType,String jobStatus,Long userId,String beginTime,String endTime); + Integer countByDataScope(DataScope dataScope, String alarmType, String jobStatus, String beginTime, String endTime); - void updateSinkJob(String id,String msg,String wellCode); + Integer countByResponse(String alarmType, String jobStatus, Long deptId, String beginTime, String endTime); + + Integer countByUser(String alarmType, String jobStatus, Long userId, String beginTime, String endTime); + + void updateSinkJob(String id, String msg, String wellCode); + List selectUserByWellCode(String wellCode); + String selectClientIdByUser(Long userId); + + AlarmJob saveData( String devCode, String wellCode, String devTypeName, String jobType); + } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java index 46e7dfe..6eecb2b 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.service.IService; import com.casic.missiles.modular.system.model.AlarmRecords; import com.casic.missiles.core.datascope.DataScope; +import org.apache.ibatis.annotations.Param; import java.util.List; import java.util.Map; @@ -26,4 +27,8 @@ boolean cancelAlarmById(long id); Integer insertAlarmRecord(AlarmRecords alarmRec); + + Boolean isOldAlarmRecord(String devCode,String MsgContent); + + Integer updateOldAlarmRecord(String devCode,String MsgContent); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java index fa6681d..943ebd7 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java @@ -7,12 +7,14 @@ import com.casic.missiles.core.common.service.ICommonUserService; import com.casic.missiles.modular.alarm.job.HandleAlarmJob; import com.casic.missiles.modular.alarm.job.getDelayJob; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.alarm.service.IAlarmJobService; import com.casic.missiles.core.datascope.DataScope; import com.casic.missiles.core.util.EhcacheConstant; import com.casic.missiles.core.util.ToolUtil; import com.casic.missiles.modular.system.dao.AlarmJobMapper; import com.casic.missiles.modular.system.dao.AlarmRecordsMapper; +import com.casic.missiles.modular.system.dto.DeviceTypeEnum; import com.casic.missiles.modular.system.dto.SelectDto; import com.casic.missiles.modular.system.dto.UserClientView; import com.casic.missiles.modular.system.model.AlarmJob; @@ -24,6 +26,8 @@ import com.casic.missiles.quartz.service.IQuartzManager; import com.gexin.rp.sdk.base.IPushResult; import com.google.gson.GsonBuilder; +import net.sf.ehcache.search.Query; +import net.sf.ehcache.search.expression.Criteria; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -48,6 +52,8 @@ public class AlarmJobServiceImpl extends ServiceImpl implements IAlarmJobService { private static final Logger logger = LoggerFactory.getLogger(AlarmJobServiceImpl.class); + public static final SimpleDateFormat sdf6 = new SimpleDateFormat("yyyyMMdd"); + private static Map deviceAlarmMap = new HashMap(); @Value("${smartcity.leaderRoleName}") private String sLeader; @@ -70,12 +76,14 @@ @Resource private IQuartzManager quartzManager; - @Autowired IBusWellInfoService busWellInfoService; + @Autowired + IBusWellInfoService busWellInfoService; @Override - public List> jobList(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, DataScope dataScope,Long userId) { + public List> jobList(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, DataScope dataScope, Long userId) { alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobList(page, keywords, beginTime, endTime, jobStatus, alarmType, alarmContent, dataScope,userId);return alarmJobList; + List> alarmJobList = this.baseMapper.jobList(page, keywords, beginTime, endTime, jobStatus, alarmType, alarmContent, dataScope, userId); + return alarmJobList; } @Override @@ -86,9 +94,9 @@ } @Override - public List> jobListDelayRe(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope,Long userId) { + public List> jobListDelayRe(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId) { alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListDelayRe(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope,userId); + List> alarmJobList = this.baseMapper.jobListDelayRe(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope, userId); return alarmJobList; } @@ -100,9 +108,9 @@ } @Override - public List> jobListDelayPro(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope,Long userId) { + public List> jobListDelayPro(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId) { alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListDelayPro(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope,userId); + List> alarmJobList = this.baseMapper.jobListDelayPro(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope, userId); return alarmJobList; } @@ -114,109 +122,115 @@ } @Override - public List> jobListSearch(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime, String endTime, String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, String shouldHandleBeginTime, String shouldHandleEndTime, DataScope dataScope,Long userId) { - alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListSearch(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, dataScope,userId); + public List> jobListSearch(Page> page, JobListParam jobListParam, DataScope dataScope, Long userId) { + jobListParam.setAlarmContent(converAlarmContent(jobListParam.getAlarmContent())); + List> alarmJobList = this.baseMapper.jobListSearch(page, jobListParam, dataScope, userId); return alarmJobList; } @Override - public List> jobListSearchApp(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime, String endTime, String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, String shouldHandleBeginTime, String shouldHandleEndTime, Long deptId, Long userId, Long leaderId) { - alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListSearchApp(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, deptId, userId, leaderId); + public List> jobListSearchApp(Page> page, JobListParam jobListParam, Long deptId, Long userId, Long leaderId) { + jobListParam.setAlarmContent(converAlarmContent(jobListParam.getAlarmContent())); + List> alarmJobList = this.baseMapper.jobListSearchApp(page, jobListParam.getKeywords(), + jobListParam.getAlarmLevel(), jobListParam.getAlarmContent(), jobListParam.getJobStatus(), jobListParam.getBeginTime(), + jobListParam.getEndTime(), jobListParam.getGetJobBeginTime(), jobListParam.getGetJobEndTime(), jobListParam.getShouldGetBeginTime(), + jobListParam.getShouldGetEndTime(), jobListParam.getHandleJobBeginTime(), jobListParam.getHandleJobEndTime(), jobListParam.getShouldHandleBeginTime(), + jobListParam.getShouldHandleEndTime(), deptId, userId, leaderId); return alarmJobList; } - private String converAlarmContent(String alarmContent){ - if(ToolUtil.isEmpty(alarmContent)){ + private String converAlarmContent(String alarmContent) { + if (ToolUtil.isEmpty(alarmContent)) { return alarmContent; - }else { + } else { return EhcacheConstant.retBean().getAlarmContentName(Integer.valueOf(alarmContent)); } } @Override - public List> jobInfo(int id, DataScope dataScope, Long personId) - { - List> job = this.baseMapper.jobInfo(id,dataScope,personId); + public List> jobInfo(Long id, DataScope dataScope, Long personId) { + List> job = this.baseMapper.jobInfo(id, dataScope, personId); return job; } @Override - public Map countByJobStatus(long deptId,int spanDays) { - return this.baseMapper.countByJobStatus(deptId,spanDays); + public Map countByJobStatus(long deptId, int spanDays) { + return this.baseMapper.countByJobStatus(deptId, spanDays); } @Override - public Map countMyJob(long userId,long deptId,int spanDays) { - return this.baseMapper.countMyJob(userId,deptId,spanDays); + public Map countMyJob(long userId, long deptId, int spanDays) { + return this.baseMapper.countMyJob(userId, deptId, spanDays); } @Override - public boolean getJob(int id, long personId) { + public boolean getJob(Long id, long personId) { Calendar now = Calendar.getInstance(); Date getTime = now.getTime(); - if(isWeekend(now)){ + if (isWeekend(now)) { now.add(Calendar.WEEK_OF_YEAR, 1); - now.set(Calendar.DAY_OF_WEEK ,Calendar.TUESDAY); - now.set(Calendar.HOUR_OF_DAY,8); - now.set(Calendar.MINUTE,0); - now.set(Calendar.SECOND,0); - }else { + now.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY); + now.set(Calendar.HOUR_OF_DAY, 8); + now.set(Calendar.MINUTE, 0); + now.set(Calendar.SECOND, 0); + } else { now.add(Calendar.HOUR, 24); - while(isWeekend(now)){ + while (isWeekend(now)) { now.add(Calendar.HOUR, 24); } } Date shouldHandleTime = now.getTime(); - if(Boolean.getBoolean(useOverTime)){ + if (Boolean.getBoolean(useOverTime)) { System.out.println(shouldHandleTime); String jobName = "getJobDelay" + id; - Map map = new HashMap<>(); - map.put("jobId",id); - map.put("iAlarmJobService",this); - map.put("iCommonUserService",iCommonUserService); - map.put("iQuartzManager",quartzManager); - map.put("webSocket",webSocket); - quartzManager.addJob(jobName,getDelayJob.class,shouldHandleTime,map); + Map map = new HashMap<>(); + map.put("jobId", id); + map.put("iAlarmJobService", this); + map.put("iCommonUserService", iCommonUserService); + map.put("iQuartzManager", quartzManager); + map.put("webSocket", webSocket); + quartzManager.addJob(jobName, getDelayJob.class, shouldHandleTime, map); } - return this.baseMapper.getJob(id,personId,getTime,shouldHandleTime); + return this.baseMapper.getJob(id, personId, getTime, shouldHandleTime); } - private boolean isWeekend(Calendar cal){ - if(cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY){ + private boolean isWeekend(Calendar cal) { + if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) { return true; - } else{ + } else { return false; } } @Override - public boolean confirmJob(int id,long personId, String firstState, String firstStatePhotos, String needHandle) { - if ("1".equals(needHandle)){ - return this.baseMapper.confirmJob(id,personId, firstState, firstStatePhotos, needHandle); + public boolean confirmJob(Long id, long personId, String firstState, String firstStatePhotos, String needHandle) { + if ("1".equals(needHandle)) { + return this.baseMapper.confirmJob(id, personId, firstState, firstStatePhotos, needHandle); } else { - return this.baseMapper.confirmOverJobAndAlarm(id, personId,firstState, firstStatePhotos); + return this.baseMapper.confirmOverJobAndAlarm(id, personId, firstState, firstStatePhotos); } } @Override - public boolean transferJob(int id, long transferPerson,String flowRec) { - return this.baseMapper.transferJob(id, transferPerson,flowRec); + public boolean transferJob(Long id, long transferPerson, String flowRec) { + return this.baseMapper.transferJob(id, transferPerson, flowRec); } @Override - public boolean saveJob(int id, String handleMessage, String handlePhotos) { + public boolean saveJob(Long id, String handleMessage, String handlePhotos) { return this.baseMapper.saveJob(id, handleMessage, handlePhotos); } @Override - public boolean overJob(int id,long personId, String handleMessage, String handlePhotos) { - return this.baseMapper.overJobAndAlarm(id, personId,handleMessage, handlePhotos); + public boolean overJob(Long id, long personId, String handleMessage, String handlePhotos) { + + return this.baseMapper.overJobAndAlarm(id, personId, handleMessage, handlePhotos); + // return this.baseMapper.overJob(id, personId,handleMessage, handlePhotos); } + @Override public boolean overAlarm(int jobId) { return this.baseMapper.overAlarm(jobId); @@ -224,15 +238,15 @@ } @Override - public boolean handleJob(int id,long personId) { - return this.baseMapper.handleJob(id,personId); + public boolean handleJob(Long id, long personId) { + return this.baseMapper.handleJob(id, personId); } @Override public boolean checkJobStatus(String jobStatus) { - if(ToolUtil.isEmpty(jobStatus)){ + if (ToolUtil.isEmpty(jobStatus)) { return false; - }else{ + } else { return "1".equals(jobStatus) || "2".equals(jobStatus) || "3".equals(jobStatus); } } @@ -243,10 +257,10 @@ } - public List selectRoles() { return this.baseMapper.selectRoles(); } + public List selectUseIds(List roleIds) { return this.baseMapper.selectUseIds(roleIds); } @@ -255,50 +269,50 @@ public boolean checkPcRole(List roleTips) { List roleList = new ArrayList<>(roleTips); Iterator it = roleList.iterator(); - while (it.hasNext()){ + while (it.hasNext()) { String role = it.next(); - if(role.equals(sApp)||role.equals(sLeader)||role.equals(sMember)){ + if (role.equals(sApp) || role.equals(sLeader) || role.equals(sMember)) { it.remove(); } } - return roleList.size()>0; + return roleList.size() > 0; } @Override - public Integer countByDataScope(DataScope dataScope, String alarmType, String jobStatus, String beginTime,String endTime) { - List> res = this.baseMapper.countByDataScope(dataScope,alarmType,jobStatus,beginTime,endTime); + public Integer countByDataScope(DataScope dataScope, String alarmType, String jobStatus, String beginTime, String endTime) { + List> res = this.baseMapper.countByDataScope(dataScope, alarmType, jobStatus, beginTime, endTime); return res.size(); } @Override - public Integer countByResponse(String alarmType, String jobStatus, Long deptId, String beginTime,String endTime) { - return this.baseMapper.countByResponse(alarmType,jobStatus,deptId,beginTime,endTime); + public Integer countByResponse(String alarmType, String jobStatus, Long deptId, String beginTime, String endTime) { + return this.baseMapper.countByResponse(alarmType, jobStatus, deptId, beginTime, endTime); } @Override - public Integer countByUser(String alarmType, String jobStatus, Long userId, String beginTime,String endTime) { - return this.baseMapper.countByUser(alarmType,jobStatus,userId,beginTime,endTime); + public Integer countByUser(String alarmType, String jobStatus, Long userId, String beginTime, String endTime) { + return this.baseMapper.countByUser(alarmType, jobStatus, userId, beginTime, endTime); } @Override - public void updateSinkJob(String id, String msg,String wellCode) { + public void updateSinkJob(String id, String msg, String wellCode) { List userClientViewList = new ArrayList<>(); List selectDtoList = selectRoles(); EntityWrapper busWellInfoEntityWrapper = new EntityWrapper<>(); - busWellInfoEntityWrapper.eq("WELL_CODE",wellCode); + busWellInfoEntityWrapper.eq("WELL_CODE", wellCode); BusWellInfo busWellInfo = busWellInfoService.selectOne(busWellInfoEntityWrapper); - if(busWellInfo!=null&&ToolUtil.isNotEmpty(busWellInfo.getDeptid())){ - List roleids= new ArrayList<>(); - for(SelectDto selectDto:selectDtoList){ - if(ToolUtil.isNotEmpty(selectDto.getName()) - && Arrays.asList(selectDto.getName().split(",")).contains(busWellInfo.getDeptid())){ + if (busWellInfo != null && ToolUtil.isNotEmpty(busWellInfo.getDeptid())) { + List roleids = new ArrayList<>(); + for (SelectDto selectDto : selectDtoList) { + if (ToolUtil.isNotEmpty(selectDto.getName()) + && Arrays.asList(selectDto.getName().split(",")).contains(busWellInfo.getDeptid())) { roleids.add(selectDto.getId()); } } - if(roleids.size()>0){ + if (roleids.size() > 0) { List useIds = selectUseIds(roleids); - for(Long useId:useIds){ + for (Long useId : useIds) { UserClientView userClientView = new UserClientView(); userClientView.setClientid(useId.toString()); userClientView.setId(useId.toString()); @@ -307,11 +321,11 @@ } } - if(!("null".equals(id))){ + if (!("null".equals(id))) { AlarmJob alarmJob = this.baseMapper.selectById(id); sendJob(id, alarmJob, userClientViewList);//推送工单至app和pc端 } - if(StringUtils.isNotBlank(msg)){ + if (StringUtils.isNotBlank(msg)) { sendAlarm(msg, userClientViewList);//推送告警至app和pc端 } @@ -386,7 +400,7 @@ } Date shouldHandleTime = now.getTime(); - if(Boolean.getBoolean(useOverTime)) { + if (Boolean.getBoolean(useOverTime)) { System.out.println(shouldHandleTime); String jobName = "getJobDelay" + id; Map map = new HashMap<>(); @@ -437,4 +451,40 @@ public String selectClientIdByUser(Long userId) { return this.baseMapper.selectClientIdByUser(userId); } + + + public AlarmJob saveData(String devCode, String wellCode, String devTypeName, String jobType) { + AlarmJob alarmJob = new AlarmJob(); + alarmJob.setDevcode(devCode); + alarmJob.setWellCode(wellCode); + alarmJob.setJobStatus("0"); + alarmJob.setCreateTime(new Date()); + alarmJob.setJobcode(this.produceJobCode(devTypeName)); + alarmJob.setJobType(jobType); + this.baseMapper.insert(alarmJob); + return alarmJob; + } + + /** + * 前缀+日期+4位流水号 + * + * @param devTypeName + * @return + */ + private String produceJobCode(String devTypeName) { + String pre = devTypeName; + String dataStr = sdf6.format(new Date()); + String fix = this.getJobCodeMaxSerial(pre + dataStr); + return StringUtils.isNotBlank(fix) ? pre + dataStr + String.format("%04d", Long.valueOf(fix) + 1L) : pre + dataStr + "0001"; + } + + + private String getJobCodeMaxSerial(String jobcode) { + String MaxSerialJobCode = this.baseMapper.getJobCodeMaxSerial(jobcode); + String fix = ""; + if (null != MaxSerialJobCode && MaxSerialJobCode.length() > 4) { + fix = MaxSerialJobCode.substring(MaxSerialJobCode.length() - 4); + } + return fix; + } } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmRecordsServiceImpl.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmRecordsServiceImpl.java index e0f0959..60fa41a 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmRecordsServiceImpl.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmRecordsServiceImpl.java @@ -16,7 +16,7 @@ /** *

- * 服务实现类 + * 服务实现类 *

* * @author casic123 @@ -27,12 +27,12 @@ @Override - public List> alarmList(Page> page, String keywords, String beginTime, String endTime, String status, String alarmType, String alarmContent, String areaId, DataScope dataScope) { + public List> alarmList(Page> page, String keywords, String beginTime, String endTime, String status, String alarmType, String alarmContent, String areaId, DataScope dataScope) { String sContent = null; - if (ToolUtil.isNotEmpty(alarmContent)){ + if (ToolUtil.isNotEmpty(alarmContent)) { sContent = EhcacheConstant.retBean().getAlarmContentName(Integer.valueOf(alarmContent)); } - return this.baseMapper.alarmList(page,keywords,beginTime,endTime,status,alarmType,sContent, areaId, dataScope); + return this.baseMapper.alarmList(page, keywords, beginTime, endTime, status, alarmType, sContent, areaId, dataScope); } /** @@ -41,15 +41,15 @@ @Override public List alarmListNoPage(DataScope dataScope, String keywords, String alarmType, String alarmContent, String beginTime, String endTime, String areaId) { String sContent = null; - if (ToolUtil.isNotEmpty(alarmContent)){ + if (ToolUtil.isNotEmpty(alarmContent)) { sContent = EhcacheConstant.retBean().getAlarmContentName(Integer.valueOf(alarmContent)); } - return this.baseMapper.alarmListNoPage(dataScope,keywords,alarmType,sContent,beginTime,endTime, areaId); + return this.baseMapper.alarmListNoPage(dataScope, keywords, alarmType, sContent, beginTime, endTime, areaId); } @Override public boolean cancelAlarm(long id, String jobStatus, String handleMessage, long personId) { - return this.baseMapper.cancelAlarm(id,jobStatus,handleMessage,personId); + return this.baseMapper.cancelAlarm(id, jobStatus, handleMessage, personId); } @Override @@ -62,4 +62,15 @@ // this.baseMapper.cancelAlarmByNewRecord(alarmRec.getDevcode(), alarmRec.getAlarmType()); return this.baseMapper.insert(alarmRec); } + + public Boolean isOldAlarmRecord(String devCode, String MsgContent) { + if (this.baseMapper.isOldAlarmRecord(devCode, MsgContent) == null) { + return false; + } + return true; + } + + public Integer updateOldAlarmRecord(String devCode, String MsgContent) { + return this.baseMapper.updateOldAlarmRecord(devCode, MsgContent); + } } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/AlarmMapOverviewController.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/AlarmMapOverviewController.java index 9d60185..214c275 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/AlarmMapOverviewController.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/AlarmMapOverviewController.java @@ -8,14 +8,12 @@ import com.casic.missiles.core.exception.GunsExceptionEnum; import com.casic.missiles.core.base.response.SuccessResponseData; import com.casic.missiles.core.util.ToolUtil; -import com.casic.missiles.modular.system.constant.ModularDictConst; import com.casic.missiles.modular.system.dto.AlarmNowView; import com.casic.missiles.modular.system.dto.DeviceDto; import com.casic.missiles.modular.system.model.BusWellInfo; import com.casic.missiles.modular.system.service.IAlarmNowViewService; import com.casic.missiles.modular.system.service.IBusWellInfoService; import com.casic.missiles.modular.system.service.IDeviceService; -import com.casic.missiles.modular.system.service.impl.BusWellInfoServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataReceiver.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataReceiver.java index 0013989..b3f23d5 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataReceiver.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataReceiver.java @@ -2,6 +2,7 @@ import com.casic.missiles.core.base.controller.BaseController; import com.casic.missiles.core.base.response.ResponseData; +import com.casic.missiles.modular.alarm.service.IAlarmJobService; import com.casic.missiles.modular.alarm.service.IAlarmRecordsService; import com.casic.missiles.modular.alarm.service.IAlarmRuleService; import com.casic.missiles.modular.system.dto.DeviceWellDto; @@ -9,6 +10,7 @@ import com.casic.missiles.modular.system.service.IDeviceService; import com.casic.missiles.modular.system.service.IGasFlowDataService; import lombok.extern.java.Log; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -38,6 +40,9 @@ @Resource private IAlarmRecordsService alarmRecordsService; + @Autowired + IAlarmJobService alarmJobService; + private DecimalFormat df2 = new DecimalFormat("0.00"); @RequestMapping(value = "/data/recv") @@ -117,6 +122,13 @@ alarmRecord.setAlarmTime(Calendar.getInstance().getTime()); alarmRecord.setStatus("1"); alarmRecord.setAlarmMessage("日用气量超阈值报警"); + if (alarmRecordsService.isOldAlarmRecord(gasFlowAddr, "日用气量超阈值报警")) { + alarmRecordsService.updateOldAlarmRecord(gasFlowAddr, "日用气量超阈值报警"); + } else { + AlarmJob alarmJob = alarmJobService.saveData(gasFlowAddr, wellDto.getWellCode(), "SLCX", "1"); + alarmRecord.setJobId(alarmJob.getId()); + } + alarmRecordsService.insertAlarmRecord(alarmRecord); // 向前端推送报警 } else { @@ -134,6 +146,13 @@ alarmRecord.setAlarmTime(Calendar.getInstance().getTime()); alarmRecord.setStatus("1"); alarmRecord.setAlarmMessage("日用气量超阈值预警"); + alarmRecord.setAlarmMessage("日用水量超阈值预警"); + if (alarmRecordsService.isOldAlarmRecord(gasFlowAddr, "日用水量超阈值预警")) { + alarmRecordsService.updateOldAlarmRecord(gasFlowAddr, "日用水量超阈值预警"); + } else { + AlarmJob alarmJob = alarmJobService.saveData(gasFlowAddr, wellDto.getWellCode(), "SLCX", "1"); + alarmRecord.setJobId(alarmJob.getId()); + } alarmRecordsService.insertAlarmRecord(alarmRecord); // 向前端推送报警 } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataReceiver.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataReceiver.java index 6c25e18..200f5d2 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataReceiver.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataReceiver.java @@ -2,16 +2,15 @@ import com.casic.missiles.core.base.controller.BaseController; import com.casic.missiles.core.base.response.ResponseData; +import com.casic.missiles.modular.alarm.service.IAlarmJobService; import com.casic.missiles.modular.alarm.service.IAlarmRecordsService; import com.casic.missiles.modular.alarm.service.IAlarmRuleService; import com.casic.missiles.modular.system.dto.DeviceWellDto; -import com.casic.missiles.modular.system.model.AlarmRecords; -import com.casic.missiles.modular.system.model.AlarmRule; -import com.casic.missiles.modular.system.model.DataWaterMeter; -import com.casic.missiles.modular.system.model.Device; +import com.casic.missiles.modular.system.model.*; import com.casic.missiles.modular.system.service.IDeviceService; import com.casic.missiles.modular.system.service.IWaterMeterDataService; import lombok.extern.java.Log; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -40,6 +39,9 @@ @Resource private IAlarmRecordsService alarmRecordsService; + @Autowired + IAlarmJobService alarmJobService; + private DecimalFormat df2 = new DecimalFormat("0.00"); @RequestMapping(value = "/data/recv") @@ -106,7 +108,6 @@ if (flowAccToday - alarmRule.getHighvalue() > 0) { // 超出报警阈值 生成一条报警消息 AlarmRecords alarmRecord = new AlarmRecords(); - alarmRecord.setDeviceId(device.getId()); alarmRecord.setDevcode(meterAddr); alarmRecord.setWellCode(wellDto.getWellCode()); @@ -116,17 +117,19 @@ alarmRecord.setAlarmTime(Calendar.getInstance().getTime()); alarmRecord.setStatus("1"); alarmRecord.setAlarmMessage("日用水量超阈值报警"); - + if (alarmRecordsService.isOldAlarmRecord(meterAddr, "日用水量超阈值报警")) { + alarmRecordsService.updateOldAlarmRecord(meterAddr, "日用水量超阈值报警"); + } else { + AlarmJob alarmJob = alarmJobService.saveData(meterAddr, wellDto.getWellCode(), "QLCX", "1"); + alarmRecord.setJobId(alarmJob.getId()); + } alarmRecordsService.insertAlarmRecord(alarmRecord); - - // 向前端推送报警 } else { // 如果没有报警则判断是否预警 if (null != alarmRuleWarn && null != alarmRuleWarn.getHighvalue()) { if (flowAccToday - alarmRuleWarn.getHighvalue() > 0) { // 超出预警阈值 生成一条预警消息 AlarmRecords alarmRecord = new AlarmRecords(); - alarmRecord.setDeviceId(device.getId()); alarmRecord.setDevcode(meterAddr); alarmRecord.setWellCode(wellDto.getWellCode()); @@ -136,10 +139,13 @@ alarmRecord.setAlarmTime(Calendar.getInstance().getTime()); alarmRecord.setStatus("1"); alarmRecord.setAlarmMessage("日用水量超阈值预警"); - + if (alarmRecordsService.isOldAlarmRecord(meterAddr, "日用水量超阈值预警")) { + alarmRecordsService.updateOldAlarmRecord(meterAddr, "日用水量超阈值预警"); + } else { + AlarmJob alarmJob = alarmJobService.saveData(meterAddr, wellDto.getWellCode(), "QLCX", "1"); + alarmRecord.setJobId(alarmJob.getId()); + } alarmRecordsService.insertAlarmRecord(alarmRecord); - - // 向前端推送报警 } } } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmJobMapper.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmJobMapper.java index 6592517..ccdff9a 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmJobMapper.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmJobMapper.java @@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.mapper.BaseMapper; import com.baomidou.mybatisplus.plugins.Page; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.system.dto.SelectDto; import com.casic.missiles.modular.system.dto.UserClientView; import com.casic.missiles.modular.system.model.AlarmJob; @@ -21,44 +22,65 @@ * @since 2019-05-17 */ public interface AlarmJobMapper extends BaseMapper { - List> jobList(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("jobStatus") String jobStatus, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("dataScope") DataScope dataScope,@Param("userId")Long userId); - List> jobListApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("jobStatus") String jobStatus, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("deptId")Long deptId,@Param("userId")Long userId,@Param("leaderId")Long leaderId); + List> jobList(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("jobStatus") String jobStatus, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("dataScope") DataScope dataScope, @Param("userId") Long userId); + + List> jobListApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("jobStatus") String jobStatus, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("deptId") Long deptId, @Param("userId") Long userId, @Param("leaderId") Long leaderId); + // List jobListExport(@Param("page") Page page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("jobStatus") String jobStatus, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("dataScope") DataScope dataScope); - List> jobListDelayRe(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("dataScope") DataScope dataScope,@Param("userId")Long userId); - List> jobListDelayReApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("deptId")Long deptId,@Param("userId")Long userId,@Param("leaderId")Long leaderId); + List> jobListDelayRe(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("dataScope") DataScope dataScope, @Param("userId") Long userId); - List> jobListDelayPro(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("dataScope") DataScope dataScope,@Param("userId")Long userId); - List> jobListDelayProApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("deptId")Long deptId,@Param("userId")Long userId,@Param("leaderId")Long leaderId); + List> jobListDelayReApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("deptId") Long deptId, @Param("userId") Long userId, @Param("leaderId") Long leaderId); - List> jobListSearchApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("alarmLevel")String alarmLevel, @Param("alarmContent") String alarmContent, @Param("jobStatus") String jobStatus, @Param("beginTime") String beginTime, @Param("endTime") String endTime, - @Param("getJobBeginTime") String getJobBeginTime, @Param("getJobEndTime") String getJobEndTime, @Param("shouldGetBeginTime") String shouldGetBeginTime, @Param("shouldGetEndTime") String shouldGetEndTime, - @Param("handleJobBeginTime") String handleJobBeginTime, @Param("handleJobEndTime") String handleJobEndTime, @Param("shouldHandleBeginTime") String shouldHandleBeginTime, @Param("shouldHandleEndTime") String shouldHandleEndTime, - @Param("deptId")Long deptId, @Param("userId")Long userId, @Param("leaderId")Long leaderId); - List> jobListSearch(@Param("page") Page> page, @Param("keywords") String keywords, @Param("alarmLevel")String alarmLevel, @Param("alarmContent") String alarmContent, @Param("jobStatus") String jobStatus, @Param("beginTime") String beginTime, @Param("endTime") String endTime, - @Param("getJobBeginTime") String getJobBeginTime, @Param("getJobEndTime") String getJobEndTime, @Param("shouldGetBeginTime") String shouldGetBeginTime, @Param("shouldGetEndTime") String shouldGetEndTime, - @Param("handleJobBeginTime") String handleJobBeginTime, @Param("handleJobEndTime") String handleJobEndTime, @Param("shouldHandleBeginTime") String shouldHandleBeginTime, @Param("shouldHandleEndTime") String shouldHandleEndTime, - @Param("dataScope") DataScope dataScope,@Param("userId")Long userId); + List> jobListDelayPro(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("dataScope") DataScope dataScope, @Param("userId") Long userId); - Map countByJobStatus(@Param("deptId")long deptId,@Param("spanDays") int spanDays); - Map countMyJob(@Param("userId")long userId,@Param("deptId")long deptId,@Param("spanDays") int spanDays); - List> jobInfo(@Param("id") int id,@Param("dataScope") DataScope dataScope,@Param("personId") Long personId); -// boolean getJob(@Param("id") int id,@Param("personId") long personId); - boolean getJob(@Param("id") int id,@Param("personId") long personId,@Param("getTime")Date getTime ,@Param("shouldHandleTime")Date shouldHandleTime); - boolean confirmJob(@Param("id") int id,@Param("personId") long personId,@Param("firstState") String firstState,@Param("firstStatePhotos") String firstStatePhotos,@Param("needHandle") String needHandle); - boolean confirmOverJobAndAlarm(@Param("id") int id,@Param("personId") long personId,@Param("firstState") String firstState,@Param("firstStatePhotos") String firstStatePhotos); - boolean transferJob(@Param("id") int id,@Param("transferPerson") long transferPerson,@Param("flowRec") String flowRec); - boolean saveJob(@Param("id") int id,@Param("handleMessage") String handleMessage,@Param("handlePhotos") String handlePhotos); - boolean overJob(@Param("id") int id,@Param("personId") long personId,@Param("handleMessage") String handleMessage,@Param("handlePhotos") String handlePhotos); + List> jobListDelayProApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("deptId") Long deptId, @Param("userId") Long userId, @Param("leaderId") Long leaderId); + + List> jobListSearchApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("alarmLevel") String alarmLevel, @Param("alarmContent") String alarmContent, @Param("jobStatus") String jobStatus, @Param("beginTime") String beginTime, @Param("endTime") String endTime, + @Param("getJobBeginTime") String getJobBeginTime, @Param("getJobEndTime") String getJobEndTime, @Param("shouldGetBeginTime") String shouldGetBeginTime, @Param("shouldGetEndTime") String shouldGetEndTime, + @Param("handleJobBeginTime") String handleJobBeginTime, @Param("handleJobEndTime") String handleJobEndTime, @Param("shouldHandleBeginTime") String shouldHandleBeginTime, @Param("shouldHandleEndTime") String shouldHandleEndTime, + @Param("deptId") Long deptId, @Param("userId") Long userId, @Param("leaderId") Long leaderId); + + List> jobListSearch(@Param("page") Page> page, @Param("jobListParam") JobListParam jobListParam, + @Param("dataScope") DataScope dataScope, @Param("userId") Long userId); + + Map countByJobStatus(@Param("deptId") long deptId, @Param("spanDays") int spanDays); + + Map countMyJob(@Param("userId") long userId, @Param("deptId") long deptId, @Param("spanDays") int spanDays); + + List> jobInfo(@Param("id") Long id, @Param("dataScope") DataScope dataScope, @Param("personId") Long personId); + + // boolean getJob(@Param("id") int id,@Param("personId") long personId); + boolean getJob(@Param("id") Long id, @Param("personId") long personId, @Param("getTime") Date getTime, @Param("shouldHandleTime") Date shouldHandleTime); + + boolean confirmJob(@Param("id") Long id, @Param("personId") long personId, @Param("firstState") String firstState, @Param("firstStatePhotos") String firstStatePhotos, @Param("needHandle") String needHandle); + + boolean confirmOverJobAndAlarm(@Param("id") Long id, @Param("personId") long personId, @Param("firstState") String firstState, @Param("firstStatePhotos") String firstStatePhotos); + + boolean transferJob(@Param("id") Long id, @Param("transferPerson") long transferPerson, @Param("flowRec") String flowRec); + + boolean saveJob(@Param("id") Long id, @Param("handleMessage") String handleMessage, @Param("handlePhotos") String handlePhotos); + + boolean overJob(@Param("id") int id, @Param("personId") long personId, @Param("handleMessage") String handleMessage, @Param("handlePhotos") String handlePhotos); + boolean overAlarm(@Param("jobId") int id); - boolean overJobAndAlarm(@Param("id") int id,@Param("personId") long personId,@Param("handleMessage") String handleMessage,@Param("handlePhotos") String handlePhotos); - boolean handleJob(@Param("id") int id,@Param("personId") long personId); - List> countByDataScope(@Param("dataScope") DataScope dataScope,@Param("alarmType")String alarmType,@Param("jobStatus")String jobStatus,@Param("beginTime")String beginTime,@Param("endTime")String endTime); - Integer countByResponse(@Param("alarmType")String alarmType,@Param("jobStatus")String jobStatus,@Param("deptId") Long deptId,@Param("beginTime")String beginTime,@Param("endTime")String endTime); - Integer countByUser(@Param("alarmType")String alarmType,@Param("jobStatus")String jobStatus,@Param("userId") Long userId,@Param("beginTime")String beginTime,@Param("endTime")String endTime); + boolean overJobAndAlarm(@Param("id") Long id, @Param("personId") long personId, @Param("handleMessage") String handleMessage, @Param("handlePhotos") String handlePhotos); + + boolean handleJob(@Param("id") Long id, @Param("personId") long personId); + + List> countByDataScope(@Param("dataScope") DataScope dataScope, @Param("alarmType") String alarmType, @Param("jobStatus") String jobStatus, @Param("beginTime") String beginTime, @Param("endTime") String endTime); + + Integer countByResponse(@Param("alarmType") String alarmType, @Param("jobStatus") String jobStatus, @Param("deptId") Long deptId, @Param("beginTime") String beginTime, @Param("endTime") String endTime); + + Integer countByUser(@Param("alarmType") String alarmType, @Param("jobStatus") String jobStatus, @Param("userId") Long userId, @Param("beginTime") String beginTime, @Param("endTime") String endTime); String selectClientIdByUser(@Param("userId") Long userId); + List selectUserByWellCode(@Param("wellCode") String wellCode); + List selectUseIds(@Param("roleIds") List roleIds); + List selectRoles(); + + String getJobCodeMaxSerial(@Param("jobcode") String jobcode); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmRecordsMapper.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmRecordsMapper.java index 87a71ff..d4c6a8b 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmRecordsMapper.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmRecordsMapper.java @@ -11,7 +11,7 @@ /** *

- * Mapper 接口 + * Mapper 接口 *

* * @author casic123 @@ -19,13 +19,18 @@ */ public interface AlarmRecordsMapper extends BaseMapper { - List> alarmList(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("status") String status, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("areaId") String areaId, @Param("dataScope") DataScope dataScope); + List> alarmList(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("status") String status, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("areaId") String areaId, @Param("dataScope") DataScope dataScope); List alarmListNoPage(@Param("scope") DataScope dataScope, @Param("keywords") String keywords, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("areaId") String areaId); - boolean cancelAlarm(@Param("id") long id, @Param("jobStatus")String jobStatus,@Param("handleMessage") String handleMessage,@Param("personId") long personId); + boolean cancelAlarm(@Param("id") long id, @Param("jobStatus") String jobStatus, @Param("handleMessage") String handleMessage, @Param("personId") long personId); boolean cancelAlarmById(@Param("id") long id); boolean cancelAlarmByNewRecord(@Param("devcode") String devcode, @Param("alarmType") String alarmType); + + String isOldAlarmRecord(@Param("devcode") String devcode, @Param("MsgContent") String MsgContent); + + Integer updateOldAlarmRecord(@Param("devcode") String devcode, @Param("MsgContent") String MsgContent); + } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmJobMapper.xml b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmJobMapper.xml index cd850b4..5aeef97 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmJobMapper.xml +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmJobMapper.xml @@ -65,6 +65,7 @@ GROUP BY aj.id ) c + + + + + + + + + + diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmRecordsMapper.xml b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmRecordsMapper.xml index f2b5457..6929f44 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmRecordsMapper.xml +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmRecordsMapper.xml @@ -4,18 +4,18 @@ - - - - - - - - + + + + + + + + - - - + + + @@ -52,14 +52,14 @@ AND ar.STATUS = #{status} - - = #{beginTime} ]]> + + = #{beginTime} ]]> - - + + - - and ar.WELL_CODE like concat('%',CONCAT(#{keywords},'%')) + + and ar.WELL_CODE like concat('%',CONCAT(#{keywords},'%')) AND ar.ALARM_TYPE = #{alarmType} @@ -74,19 +74,19 @@ - UPDATE alarm_job aj, alarm_records ar + UPDATE alarm_job aj, alarm_records ar aj.job_status = #{jobStatus} , aj.handle_job_person = #{personId}, @@ -140,4 +140,20 @@ WHERE ar.devcode = #{devcode} and ar.alarm_type = #{alarmType} + + SELECT ID + FROM alarm_records + WHERE DEVCODE = #{devcode} + AND ALARM_CONTENT = #{MsgContent} + AND STATUS='1' + + + + UPDATE alarm_records + SET STATUS='0' + WHERE DEVCODE = #{devcode} + AND ALARM_CONTENT = #{MsgContent} + AND STATUS='1' + + diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java index 46bb487..d27afa9 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java @@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.plugins.Page; import com.casic.missiles.core.base.response.ResponseData; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.alarm.service.IAlarmJobService; import com.casic.missiles.core.common.service.ICommonPermissionService; import com.casic.missiles.core.datascope.DataScope; @@ -12,12 +13,14 @@ import com.casic.missiles.modular.system.warpper.AlarmJobWarpper; import com.casic.missiles.core.base.controller.BaseController; import com.casic.missiles.core.common.constant.factory.PageFactory; +import lombok.extern.slf4j.Slf4j; import org.hswebframework.expands.office.excel.ExcelIO; import org.json.JSONException; import org.json.JSONObject; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; @@ -29,6 +32,7 @@ import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.*; //import com.casic.missiles.core.base.response.ResponseData; @@ -40,6 +44,7 @@ * @Date 2019-05-17 10:48:36 */ @Controller +@Slf4j @RequestMapping("/job") public class AlarmJobController extends BaseController { @@ -65,6 +70,13 @@ private String templatePath; + /** + * 工单状态接口统计 + * + * @param httpServletRequest + * @return + * @throws ParseException + */ @RequestMapping(value = "/countByJobStatus") @ResponseBody public Object countByJobStatus(HttpServletRequest httpServletRequest) throws ParseException { @@ -117,7 +129,7 @@ } /** - * 获取分页列表 + * 获取工单分页列表 */ @RequestMapping(value = "/list") @ResponseBody @@ -164,30 +176,26 @@ */ @RequestMapping(value = "/searchList") @ResponseBody - public Object jobListSearch(String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime, String endTime, - String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, - String handleJobBeginTime, String handleJobEndTime, String shouldHandleBeginTime, String shouldHandleEndTime) { + public Object jobListSearch(@RequestBody JobListParam jobListParam) { Page> page = new PageFactory>().defaultPage("createTime", false); DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List> retList = new ArrayList<>(); if (alarmJobService.checkPcRole(currentUser.getRoleTips())) { // pc角色 - retList = alarmJobService.jobListSearch(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, - handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, dataScope, currentUser.getId()); + retList = alarmJobService.jobListSearch(page, jobListParam, dataScope, currentUser.getId()); } else { //app角色 long leaderId = 0L; if (currentUser.getRoleTips().contains(sLeader)) { // 组长,查组内全部 leaderId = currentUser.getId(); - if (ToolUtil.isNotEmpty(jobStatus)) { + if (ToolUtil.isNotEmpty(jobListParam.getJobStatus())) { //learder&&jobStatus=1,2,3时,关闭传入的sort,按sql排序(自己的排在前) - page.setOpenSort(!alarmJobService.checkJobStatus(jobStatus)); + page.setOpenSort(!alarmJobService.checkJobStatus(jobListParam.getJobStatus())); } } - retList = alarmJobService.jobListSearchApp(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, - handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, currentUser.getDeptId(), currentUser.getId(), leaderId); + retList = alarmJobService.jobListSearchApp(page, jobListParam, currentUser.getDeptId(), currentUser.getId(), leaderId); } new AlarmJobWarpper(retList).warp(); @@ -277,26 +285,24 @@ @RequestMapping(value = "/export") public void exportJob(HttpServletRequest httpServletRequest , HttpServletResponse httpServletResponse) throws IOException { - Page> page = new PageFactory>().defaultPage("createTime", false); page.setLimit(maxRowsExcel); page.setSize(maxRowsExcel); page.setSearchCount(false); page.setOffset(0); - String keywords = httpServletRequest.getParameter("keywords"); String beginTime = httpServletRequest.getParameter("beginTime"); String endTime = httpServletRequest.getParameter("endTime"); String jobStatusStr = httpServletRequest.getParameter("jobStatus"); String alarmTypeStr = httpServletRequest.getParameter("alarmType"); String alarmContentStr = httpServletRequest.getParameter("alarmContentType"); - - List> jobExpList = new ArrayList<>(); + log.debug("主题参数---------------" + keywords + "," + beginTime + "," + endTime + "," + jobStatusStr + "," + alarmTypeStr + "," + alarmContentStr); DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - jobExpList = alarmJobService.jobList(page, keywords, beginTime, endTime, jobStatusStr, alarmTypeStr, alarmContentStr, dataScope, currentUser.getId()); + List> jobExpList = alarmJobService.jobList(page, keywords, beginTime, endTime, jobStatusStr, alarmTypeStr, alarmContentStr, dataScope, currentUser.getId()); new AlarmJobWarpper(jobExpList).warp(); FileInputStream fileInputStream = null; + log.debug("----------------" + ToolUtil.isEmpty(jobExpList)); if (ToolUtil.isEmpty(jobExpList)) { fileInputStream = new FileInputStream(templatePath + "/jobRecEmpty.xlsx"); } else { @@ -305,12 +311,10 @@ try { httpServletResponse.setContentType("application/octet-stream"); httpServletResponse.addHeader("Content-Disposition", " attachment;filename=" + "jobOverview.xlsx"); - Map var = new HashMap<>(); var.put("标题", "工单一览表"); var.put("list", jobExpList); ExcelIO.writeTemplate(fileInputStream, httpServletResponse.getOutputStream(), var); - } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { @@ -328,11 +332,11 @@ */ @RequestMapping(value = "/getJob") @ResponseBody - public Object getJob(int id) { + public Object getJob(Long id) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - if (alarmJobService.getJob(id, currentUser.getId())){ + if (alarmJobService.getJob(id, currentUser.getId())) { return ResponseData.success(); } else { return ResponseData.error("接单失败"); @@ -344,10 +348,10 @@ */ @RequestMapping(value = "/confirmJob") @ResponseBody - public Object confirmJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "firstState", required = true) String firstState, - @RequestParam(value = "firstStatePhotos", required = true) String firstStatePhotos, - @RequestParam(value = "needHandle", required = true) String needHandle) { + public Object confirmJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "firstState", required = true) String firstState, + @RequestParam(value = "firstStatePhotos", required = true) String firstStatePhotos, + @RequestParam(value = "needHandle", required = true) String needHandle) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.confirmJob(id, currentUser.getId(), firstState, firstStatePhotos, needHandle)) { return ResponseData.success(); @@ -361,17 +365,19 @@ */ @RequestMapping(value = "/transferJob") @ResponseBody - public Object transferJob(@RequestParam(value = "id", required = true) int id, + public Object transferJob(@RequestParam(value = "id", required = true) Long id, @RequestParam(value = "transferPerson", required = true) String transferPerson) throws JSONException { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - String dbTime = iSysDictService.getDBtime(); +// String dbTime = iSysDictService.getDBtime(); + SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); +// String dbTime = iSysDictService.getDBtime(); + Date dbTime = new Date(); JSONObject jsonObject = new JSONObject(); jsonObject.put("from", currentUser.getName()); jsonObject.put("to", EhcacheConstant.retBean().getUsernameById(Long.valueOf(transferPerson))); - jsonObject.put("time", dbTime); - + jsonObject.put("time", dateFormat.format(dbTime)); if (alarmJobService.transferJob(id, Long.valueOf(transferPerson), jsonObject.toString())) { return ResponseData.success(); } else { @@ -384,9 +390,9 @@ */ @RequestMapping(value = "/saveJob") @ResponseBody - public Object saveJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "handleMessage", required = true) String handleMessage, - @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { + public Object saveJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "handleMessage", required = true) String handleMessage, + @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { if (alarmJobService.saveJob(id, handleMessage, handlePhotos)) { return ResponseData.success(); @@ -400,10 +406,9 @@ */ @RequestMapping(value = "/overJob") @ResponseBody - public Object overJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "handleMessage", required = true) String handleMessage, - @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { - + public Object overJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "handleMessage", required = true) String handleMessage, + @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.overJob(id, currentUser.getId(), handleMessage, handlePhotos)) { @@ -419,7 +424,7 @@ */ @RequestMapping(value = "/handleJob") @ResponseBody - public Object handleJob(@RequestParam(value = "id", required = true) int id) { + public Object handleJob(@RequestParam(value = "id", required = true) Long id) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.handleJob(id, currentUser.getId())) { return ResponseData.success(); @@ -433,12 +438,10 @@ */ @RequestMapping(value = "/info") @ResponseBody - public Object jobInfo(@RequestParam(value = "id", required = true) int id) { - + public Object jobInfo(@RequestParam(value = "id", required = true) long id) { DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List> retList = alarmJobService.jobInfo(id, dataScope, currentUser.getId()); - new AlarmJobWarpper(retList).warp(); return ResponseData.success(retList); } @@ -456,7 +459,7 @@ @RequestParam(value = "wellCode", required = true) String wellCode) { Map retMap = new HashMap<>(); try { - alarmJobService.updateSinkJob(id, URLDecoder.decode(msg, "UTF-8"),wellCode); + alarmJobService.updateSinkJob(id, URLDecoder.decode(msg, "UTF-8"), wellCode); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java index 26a2ba7..df59231 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java @@ -52,6 +52,7 @@ @Autowired private IDeviceService deviceService; + @Value("${smartcity.office.maxRowsExcel}") private int maxRowsExcel; @Value("${smartcity.config.config-path}") @@ -182,7 +183,8 @@ @RequestMapping(value = "/cancelAlarmById") @ResponseBody public Object cancelAlarmById(@RequestParam(value = "alarmId",required = true) long alarmId){ - boolean isCancel = alarmRecordsService.cancelAlarmById(alarmId); + ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); + boolean isCancel = alarmRecordsService.cancelAlarm(alarmId,"4","手动消警",currentUser.getId()); if(isCancel){ return ResponseData.success(); }else { @@ -235,10 +237,10 @@ //根据查询条件查询alarm_record记录 DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); + ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List alarmRecords = alarmRecordsService.alarmListNoPage(dataScope, keywords, alarmType, alarmContent, beginTime, endTime, areaId); - for (AlarmRecords alarmRecord : alarmRecords) { - alarmRecordsService.cancelAlarmById(alarmRecord.getId()); + alarmRecordsService.cancelAlarm(alarmRecord.getJobId(),"4","手动消警",currentUser.getId()); } return ResponseData.success(); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/model/JobListParam.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/model/JobListParam.java new file mode 100644 index 0000000..c83bff8 --- /dev/null +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/model/JobListParam.java @@ -0,0 +1,32 @@ +package com.casic.missiles.modular.alarm.model; + + +import lombok.Data; + +/** + * @author cz + * @date 2022-6-13 17:03 + */ +@Data +public class JobListParam { + /** + * 关键字 + */ + private String keywords; + /** + * 风险等级 + */ + private String alarmLevel; + private String alarmContent; + private String jobStatus; + private String beginTime; + private String endTime; + private String getJobBeginTime; + private String getJobEndTime; + private String shouldGetBeginTime; + private String shouldGetEndTime; + private String handleJobBeginTime; + private String handleJobEndTime; + private String shouldHandleBeginTime; + private String shouldHandleEndTime; +} diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java index d4db8ce..018d095 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java @@ -3,6 +3,7 @@ import com.baomidou.mybatisplus.plugins.Page; import com.baomidou.mybatisplus.service.IService; import com.casic.missiles.core.datascope.DataScope; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.system.dto.UserClientView; import com.casic.missiles.modular.system.model.AlarmJob; @@ -18,42 +19,60 @@ * @since 2019-05-17 */ public interface IAlarmJobService extends IService { - List> jobList( Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType,String alarmContent, DataScope dataScope,Long userId); - List> jobListApp( Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType,String alarmContent,Long deptId,Long userId,Long leaderId); + + List> jobList(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, DataScope dataScope, Long userId); + + List> jobListApp(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, Long deptId, Long userId, Long leaderId); // List jobListExport( Page page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType,String alarmContent, DataScope dataScope); - List> jobListDelayRe( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, DataScope dataScope,Long userId); - List> jobListDelayReApp( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, Long deptId,Long userId,Long leaderId); + List> jobListDelayRe(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId); - List> jobListDelayPro( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, DataScope dataScope,Long userId ); - List> jobListDelayProApp( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, Long deptId,Long userId,Long leaderId); + List> jobListDelayReApp(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, Long deptId, Long userId, Long leaderId); - List> jobListSearch(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime,String endTime, - String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, - String shouldHandleBeginTime, String shouldHandleEndTime, DataScope dataScope,Long userId); - List> jobListSearchApp(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime,String endTime, - String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, - String shouldHandleBeginTime, String shouldHandleEndTime, Long deptId, Long userId, Long leaderId); - List> jobInfo(int id, DataScope dataScope,Long personId); - boolean getJob(int id, long personId); - boolean confirmJob(int id,long personId,String firstState, String firstStatePhotos, String needHandle); - boolean transferJob(int id, long transferPerson,String flowRec); - boolean saveJob( int id,String handleMessage, String handlePhotos); - boolean overJob( int id,long personId, String handleMessage, String handlePhotos); - boolean overAlarm( int id); - boolean handleJob(int id,long personId); + List> jobListDelayPro(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId); - Map countByJobStatus(long deptId,int spanDays); - Map countMyJob(long userId,long deptId,int spanDays); + List> jobListDelayProApp(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, Long deptId, Long userId, Long leaderId); + + List> jobListSearch(Page> page, JobListParam jobListParam, DataScope dataScope, Long userId); + + List> jobListSearchApp(Page> page, JobListParam jobListParam, Long deptId, Long userId, Long leaderId); + + List> jobInfo(Long id, DataScope dataScope, Long personId); + + boolean getJob(Long id, long personId); + + boolean confirmJob(Long id, long personId, String firstState, String firstStatePhotos, String needHandle); + + boolean transferJob(Long id, long transferPerson, String flowRec); + + boolean saveJob(Long id, String handleMessage, String handlePhotos); + + boolean overJob(Long id, long personId, String handleMessage, String handlePhotos); + + boolean overAlarm(int id); + + boolean handleJob(Long id, long personId); + + Map countByJobStatus(long deptId, int spanDays); + + Map countMyJob(long userId, long deptId, int spanDays); boolean checkJobStatus(String jobStatus); + boolean checkPcRole(List roleTips); - Integer countByDataScope(DataScope dataScope,String alarmType, String jobStatus,String beginTime,String endTime); - Integer countByResponse(String alarmType,String jobStatus,Long deptId,String beginTime,String endTime); - Integer countByUser(String alarmType,String jobStatus,Long userId,String beginTime,String endTime); + Integer countByDataScope(DataScope dataScope, String alarmType, String jobStatus, String beginTime, String endTime); - void updateSinkJob(String id,String msg,String wellCode); + Integer countByResponse(String alarmType, String jobStatus, Long deptId, String beginTime, String endTime); + + Integer countByUser(String alarmType, String jobStatus, Long userId, String beginTime, String endTime); + + void updateSinkJob(String id, String msg, String wellCode); + List selectUserByWellCode(String wellCode); + String selectClientIdByUser(Long userId); + + AlarmJob saveData( String devCode, String wellCode, String devTypeName, String jobType); + } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java index 46e7dfe..6eecb2b 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.service.IService; import com.casic.missiles.modular.system.model.AlarmRecords; import com.casic.missiles.core.datascope.DataScope; +import org.apache.ibatis.annotations.Param; import java.util.List; import java.util.Map; @@ -26,4 +27,8 @@ boolean cancelAlarmById(long id); Integer insertAlarmRecord(AlarmRecords alarmRec); + + Boolean isOldAlarmRecord(String devCode,String MsgContent); + + Integer updateOldAlarmRecord(String devCode,String MsgContent); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java index fa6681d..943ebd7 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java @@ -7,12 +7,14 @@ import com.casic.missiles.core.common.service.ICommonUserService; import com.casic.missiles.modular.alarm.job.HandleAlarmJob; import com.casic.missiles.modular.alarm.job.getDelayJob; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.alarm.service.IAlarmJobService; import com.casic.missiles.core.datascope.DataScope; import com.casic.missiles.core.util.EhcacheConstant; import com.casic.missiles.core.util.ToolUtil; import com.casic.missiles.modular.system.dao.AlarmJobMapper; import com.casic.missiles.modular.system.dao.AlarmRecordsMapper; +import com.casic.missiles.modular.system.dto.DeviceTypeEnum; import com.casic.missiles.modular.system.dto.SelectDto; import com.casic.missiles.modular.system.dto.UserClientView; import com.casic.missiles.modular.system.model.AlarmJob; @@ -24,6 +26,8 @@ import com.casic.missiles.quartz.service.IQuartzManager; import com.gexin.rp.sdk.base.IPushResult; import com.google.gson.GsonBuilder; +import net.sf.ehcache.search.Query; +import net.sf.ehcache.search.expression.Criteria; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -48,6 +52,8 @@ public class AlarmJobServiceImpl extends ServiceImpl implements IAlarmJobService { private static final Logger logger = LoggerFactory.getLogger(AlarmJobServiceImpl.class); + public static final SimpleDateFormat sdf6 = new SimpleDateFormat("yyyyMMdd"); + private static Map deviceAlarmMap = new HashMap(); @Value("${smartcity.leaderRoleName}") private String sLeader; @@ -70,12 +76,14 @@ @Resource private IQuartzManager quartzManager; - @Autowired IBusWellInfoService busWellInfoService; + @Autowired + IBusWellInfoService busWellInfoService; @Override - public List> jobList(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, DataScope dataScope,Long userId) { + public List> jobList(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, DataScope dataScope, Long userId) { alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobList(page, keywords, beginTime, endTime, jobStatus, alarmType, alarmContent, dataScope,userId);return alarmJobList; + List> alarmJobList = this.baseMapper.jobList(page, keywords, beginTime, endTime, jobStatus, alarmType, alarmContent, dataScope, userId); + return alarmJobList; } @Override @@ -86,9 +94,9 @@ } @Override - public List> jobListDelayRe(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope,Long userId) { + public List> jobListDelayRe(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId) { alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListDelayRe(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope,userId); + List> alarmJobList = this.baseMapper.jobListDelayRe(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope, userId); return alarmJobList; } @@ -100,9 +108,9 @@ } @Override - public List> jobListDelayPro(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope,Long userId) { + public List> jobListDelayPro(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId) { alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListDelayPro(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope,userId); + List> alarmJobList = this.baseMapper.jobListDelayPro(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope, userId); return alarmJobList; } @@ -114,109 +122,115 @@ } @Override - public List> jobListSearch(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime, String endTime, String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, String shouldHandleBeginTime, String shouldHandleEndTime, DataScope dataScope,Long userId) { - alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListSearch(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, dataScope,userId); + public List> jobListSearch(Page> page, JobListParam jobListParam, DataScope dataScope, Long userId) { + jobListParam.setAlarmContent(converAlarmContent(jobListParam.getAlarmContent())); + List> alarmJobList = this.baseMapper.jobListSearch(page, jobListParam, dataScope, userId); return alarmJobList; } @Override - public List> jobListSearchApp(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime, String endTime, String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, String shouldHandleBeginTime, String shouldHandleEndTime, Long deptId, Long userId, Long leaderId) { - alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListSearchApp(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, deptId, userId, leaderId); + public List> jobListSearchApp(Page> page, JobListParam jobListParam, Long deptId, Long userId, Long leaderId) { + jobListParam.setAlarmContent(converAlarmContent(jobListParam.getAlarmContent())); + List> alarmJobList = this.baseMapper.jobListSearchApp(page, jobListParam.getKeywords(), + jobListParam.getAlarmLevel(), jobListParam.getAlarmContent(), jobListParam.getJobStatus(), jobListParam.getBeginTime(), + jobListParam.getEndTime(), jobListParam.getGetJobBeginTime(), jobListParam.getGetJobEndTime(), jobListParam.getShouldGetBeginTime(), + jobListParam.getShouldGetEndTime(), jobListParam.getHandleJobBeginTime(), jobListParam.getHandleJobEndTime(), jobListParam.getShouldHandleBeginTime(), + jobListParam.getShouldHandleEndTime(), deptId, userId, leaderId); return alarmJobList; } - private String converAlarmContent(String alarmContent){ - if(ToolUtil.isEmpty(alarmContent)){ + private String converAlarmContent(String alarmContent) { + if (ToolUtil.isEmpty(alarmContent)) { return alarmContent; - }else { + } else { return EhcacheConstant.retBean().getAlarmContentName(Integer.valueOf(alarmContent)); } } @Override - public List> jobInfo(int id, DataScope dataScope, Long personId) - { - List> job = this.baseMapper.jobInfo(id,dataScope,personId); + public List> jobInfo(Long id, DataScope dataScope, Long personId) { + List> job = this.baseMapper.jobInfo(id, dataScope, personId); return job; } @Override - public Map countByJobStatus(long deptId,int spanDays) { - return this.baseMapper.countByJobStatus(deptId,spanDays); + public Map countByJobStatus(long deptId, int spanDays) { + return this.baseMapper.countByJobStatus(deptId, spanDays); } @Override - public Map countMyJob(long userId,long deptId,int spanDays) { - return this.baseMapper.countMyJob(userId,deptId,spanDays); + public Map countMyJob(long userId, long deptId, int spanDays) { + return this.baseMapper.countMyJob(userId, deptId, spanDays); } @Override - public boolean getJob(int id, long personId) { + public boolean getJob(Long id, long personId) { Calendar now = Calendar.getInstance(); Date getTime = now.getTime(); - if(isWeekend(now)){ + if (isWeekend(now)) { now.add(Calendar.WEEK_OF_YEAR, 1); - now.set(Calendar.DAY_OF_WEEK ,Calendar.TUESDAY); - now.set(Calendar.HOUR_OF_DAY,8); - now.set(Calendar.MINUTE,0); - now.set(Calendar.SECOND,0); - }else { + now.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY); + now.set(Calendar.HOUR_OF_DAY, 8); + now.set(Calendar.MINUTE, 0); + now.set(Calendar.SECOND, 0); + } else { now.add(Calendar.HOUR, 24); - while(isWeekend(now)){ + while (isWeekend(now)) { now.add(Calendar.HOUR, 24); } } Date shouldHandleTime = now.getTime(); - if(Boolean.getBoolean(useOverTime)){ + if (Boolean.getBoolean(useOverTime)) { System.out.println(shouldHandleTime); String jobName = "getJobDelay" + id; - Map map = new HashMap<>(); - map.put("jobId",id); - map.put("iAlarmJobService",this); - map.put("iCommonUserService",iCommonUserService); - map.put("iQuartzManager",quartzManager); - map.put("webSocket",webSocket); - quartzManager.addJob(jobName,getDelayJob.class,shouldHandleTime,map); + Map map = new HashMap<>(); + map.put("jobId", id); + map.put("iAlarmJobService", this); + map.put("iCommonUserService", iCommonUserService); + map.put("iQuartzManager", quartzManager); + map.put("webSocket", webSocket); + quartzManager.addJob(jobName, getDelayJob.class, shouldHandleTime, map); } - return this.baseMapper.getJob(id,personId,getTime,shouldHandleTime); + return this.baseMapper.getJob(id, personId, getTime, shouldHandleTime); } - private boolean isWeekend(Calendar cal){ - if(cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY){ + private boolean isWeekend(Calendar cal) { + if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) { return true; - } else{ + } else { return false; } } @Override - public boolean confirmJob(int id,long personId, String firstState, String firstStatePhotos, String needHandle) { - if ("1".equals(needHandle)){ - return this.baseMapper.confirmJob(id,personId, firstState, firstStatePhotos, needHandle); + public boolean confirmJob(Long id, long personId, String firstState, String firstStatePhotos, String needHandle) { + if ("1".equals(needHandle)) { + return this.baseMapper.confirmJob(id, personId, firstState, firstStatePhotos, needHandle); } else { - return this.baseMapper.confirmOverJobAndAlarm(id, personId,firstState, firstStatePhotos); + return this.baseMapper.confirmOverJobAndAlarm(id, personId, firstState, firstStatePhotos); } } @Override - public boolean transferJob(int id, long transferPerson,String flowRec) { - return this.baseMapper.transferJob(id, transferPerson,flowRec); + public boolean transferJob(Long id, long transferPerson, String flowRec) { + return this.baseMapper.transferJob(id, transferPerson, flowRec); } @Override - public boolean saveJob(int id, String handleMessage, String handlePhotos) { + public boolean saveJob(Long id, String handleMessage, String handlePhotos) { return this.baseMapper.saveJob(id, handleMessage, handlePhotos); } @Override - public boolean overJob(int id,long personId, String handleMessage, String handlePhotos) { - return this.baseMapper.overJobAndAlarm(id, personId,handleMessage, handlePhotos); + public boolean overJob(Long id, long personId, String handleMessage, String handlePhotos) { + + return this.baseMapper.overJobAndAlarm(id, personId, handleMessage, handlePhotos); + // return this.baseMapper.overJob(id, personId,handleMessage, handlePhotos); } + @Override public boolean overAlarm(int jobId) { return this.baseMapper.overAlarm(jobId); @@ -224,15 +238,15 @@ } @Override - public boolean handleJob(int id,long personId) { - return this.baseMapper.handleJob(id,personId); + public boolean handleJob(Long id, long personId) { + return this.baseMapper.handleJob(id, personId); } @Override public boolean checkJobStatus(String jobStatus) { - if(ToolUtil.isEmpty(jobStatus)){ + if (ToolUtil.isEmpty(jobStatus)) { return false; - }else{ + } else { return "1".equals(jobStatus) || "2".equals(jobStatus) || "3".equals(jobStatus); } } @@ -243,10 +257,10 @@ } - public List selectRoles() { return this.baseMapper.selectRoles(); } + public List selectUseIds(List roleIds) { return this.baseMapper.selectUseIds(roleIds); } @@ -255,50 +269,50 @@ public boolean checkPcRole(List roleTips) { List roleList = new ArrayList<>(roleTips); Iterator it = roleList.iterator(); - while (it.hasNext()){ + while (it.hasNext()) { String role = it.next(); - if(role.equals(sApp)||role.equals(sLeader)||role.equals(sMember)){ + if (role.equals(sApp) || role.equals(sLeader) || role.equals(sMember)) { it.remove(); } } - return roleList.size()>0; + return roleList.size() > 0; } @Override - public Integer countByDataScope(DataScope dataScope, String alarmType, String jobStatus, String beginTime,String endTime) { - List> res = this.baseMapper.countByDataScope(dataScope,alarmType,jobStatus,beginTime,endTime); + public Integer countByDataScope(DataScope dataScope, String alarmType, String jobStatus, String beginTime, String endTime) { + List> res = this.baseMapper.countByDataScope(dataScope, alarmType, jobStatus, beginTime, endTime); return res.size(); } @Override - public Integer countByResponse(String alarmType, String jobStatus, Long deptId, String beginTime,String endTime) { - return this.baseMapper.countByResponse(alarmType,jobStatus,deptId,beginTime,endTime); + public Integer countByResponse(String alarmType, String jobStatus, Long deptId, String beginTime, String endTime) { + return this.baseMapper.countByResponse(alarmType, jobStatus, deptId, beginTime, endTime); } @Override - public Integer countByUser(String alarmType, String jobStatus, Long userId, String beginTime,String endTime) { - return this.baseMapper.countByUser(alarmType,jobStatus,userId,beginTime,endTime); + public Integer countByUser(String alarmType, String jobStatus, Long userId, String beginTime, String endTime) { + return this.baseMapper.countByUser(alarmType, jobStatus, userId, beginTime, endTime); } @Override - public void updateSinkJob(String id, String msg,String wellCode) { + public void updateSinkJob(String id, String msg, String wellCode) { List userClientViewList = new ArrayList<>(); List selectDtoList = selectRoles(); EntityWrapper busWellInfoEntityWrapper = new EntityWrapper<>(); - busWellInfoEntityWrapper.eq("WELL_CODE",wellCode); + busWellInfoEntityWrapper.eq("WELL_CODE", wellCode); BusWellInfo busWellInfo = busWellInfoService.selectOne(busWellInfoEntityWrapper); - if(busWellInfo!=null&&ToolUtil.isNotEmpty(busWellInfo.getDeptid())){ - List roleids= new ArrayList<>(); - for(SelectDto selectDto:selectDtoList){ - if(ToolUtil.isNotEmpty(selectDto.getName()) - && Arrays.asList(selectDto.getName().split(",")).contains(busWellInfo.getDeptid())){ + if (busWellInfo != null && ToolUtil.isNotEmpty(busWellInfo.getDeptid())) { + List roleids = new ArrayList<>(); + for (SelectDto selectDto : selectDtoList) { + if (ToolUtil.isNotEmpty(selectDto.getName()) + && Arrays.asList(selectDto.getName().split(",")).contains(busWellInfo.getDeptid())) { roleids.add(selectDto.getId()); } } - if(roleids.size()>0){ + if (roleids.size() > 0) { List useIds = selectUseIds(roleids); - for(Long useId:useIds){ + for (Long useId : useIds) { UserClientView userClientView = new UserClientView(); userClientView.setClientid(useId.toString()); userClientView.setId(useId.toString()); @@ -307,11 +321,11 @@ } } - if(!("null".equals(id))){ + if (!("null".equals(id))) { AlarmJob alarmJob = this.baseMapper.selectById(id); sendJob(id, alarmJob, userClientViewList);//推送工单至app和pc端 } - if(StringUtils.isNotBlank(msg)){ + if (StringUtils.isNotBlank(msg)) { sendAlarm(msg, userClientViewList);//推送告警至app和pc端 } @@ -386,7 +400,7 @@ } Date shouldHandleTime = now.getTime(); - if(Boolean.getBoolean(useOverTime)) { + if (Boolean.getBoolean(useOverTime)) { System.out.println(shouldHandleTime); String jobName = "getJobDelay" + id; Map map = new HashMap<>(); @@ -437,4 +451,40 @@ public String selectClientIdByUser(Long userId) { return this.baseMapper.selectClientIdByUser(userId); } + + + public AlarmJob saveData(String devCode, String wellCode, String devTypeName, String jobType) { + AlarmJob alarmJob = new AlarmJob(); + alarmJob.setDevcode(devCode); + alarmJob.setWellCode(wellCode); + alarmJob.setJobStatus("0"); + alarmJob.setCreateTime(new Date()); + alarmJob.setJobcode(this.produceJobCode(devTypeName)); + alarmJob.setJobType(jobType); + this.baseMapper.insert(alarmJob); + return alarmJob; + } + + /** + * 前缀+日期+4位流水号 + * + * @param devTypeName + * @return + */ + private String produceJobCode(String devTypeName) { + String pre = devTypeName; + String dataStr = sdf6.format(new Date()); + String fix = this.getJobCodeMaxSerial(pre + dataStr); + return StringUtils.isNotBlank(fix) ? pre + dataStr + String.format("%04d", Long.valueOf(fix) + 1L) : pre + dataStr + "0001"; + } + + + private String getJobCodeMaxSerial(String jobcode) { + String MaxSerialJobCode = this.baseMapper.getJobCodeMaxSerial(jobcode); + String fix = ""; + if (null != MaxSerialJobCode && MaxSerialJobCode.length() > 4) { + fix = MaxSerialJobCode.substring(MaxSerialJobCode.length() - 4); + } + return fix; + } } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmRecordsServiceImpl.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmRecordsServiceImpl.java index e0f0959..60fa41a 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmRecordsServiceImpl.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmRecordsServiceImpl.java @@ -16,7 +16,7 @@ /** *

- * 服务实现类 + * 服务实现类 *

* * @author casic123 @@ -27,12 +27,12 @@ @Override - public List> alarmList(Page> page, String keywords, String beginTime, String endTime, String status, String alarmType, String alarmContent, String areaId, DataScope dataScope) { + public List> alarmList(Page> page, String keywords, String beginTime, String endTime, String status, String alarmType, String alarmContent, String areaId, DataScope dataScope) { String sContent = null; - if (ToolUtil.isNotEmpty(alarmContent)){ + if (ToolUtil.isNotEmpty(alarmContent)) { sContent = EhcacheConstant.retBean().getAlarmContentName(Integer.valueOf(alarmContent)); } - return this.baseMapper.alarmList(page,keywords,beginTime,endTime,status,alarmType,sContent, areaId, dataScope); + return this.baseMapper.alarmList(page, keywords, beginTime, endTime, status, alarmType, sContent, areaId, dataScope); } /** @@ -41,15 +41,15 @@ @Override public List alarmListNoPage(DataScope dataScope, String keywords, String alarmType, String alarmContent, String beginTime, String endTime, String areaId) { String sContent = null; - if (ToolUtil.isNotEmpty(alarmContent)){ + if (ToolUtil.isNotEmpty(alarmContent)) { sContent = EhcacheConstant.retBean().getAlarmContentName(Integer.valueOf(alarmContent)); } - return this.baseMapper.alarmListNoPage(dataScope,keywords,alarmType,sContent,beginTime,endTime, areaId); + return this.baseMapper.alarmListNoPage(dataScope, keywords, alarmType, sContent, beginTime, endTime, areaId); } @Override public boolean cancelAlarm(long id, String jobStatus, String handleMessage, long personId) { - return this.baseMapper.cancelAlarm(id,jobStatus,handleMessage,personId); + return this.baseMapper.cancelAlarm(id, jobStatus, handleMessage, personId); } @Override @@ -62,4 +62,15 @@ // this.baseMapper.cancelAlarmByNewRecord(alarmRec.getDevcode(), alarmRec.getAlarmType()); return this.baseMapper.insert(alarmRec); } + + public Boolean isOldAlarmRecord(String devCode, String MsgContent) { + if (this.baseMapper.isOldAlarmRecord(devCode, MsgContent) == null) { + return false; + } + return true; + } + + public Integer updateOldAlarmRecord(String devCode, String MsgContent) { + return this.baseMapper.updateOldAlarmRecord(devCode, MsgContent); + } } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/AlarmMapOverviewController.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/AlarmMapOverviewController.java index 9d60185..214c275 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/AlarmMapOverviewController.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/AlarmMapOverviewController.java @@ -8,14 +8,12 @@ import com.casic.missiles.core.exception.GunsExceptionEnum; import com.casic.missiles.core.base.response.SuccessResponseData; import com.casic.missiles.core.util.ToolUtil; -import com.casic.missiles.modular.system.constant.ModularDictConst; import com.casic.missiles.modular.system.dto.AlarmNowView; import com.casic.missiles.modular.system.dto.DeviceDto; import com.casic.missiles.modular.system.model.BusWellInfo; import com.casic.missiles.modular.system.service.IAlarmNowViewService; import com.casic.missiles.modular.system.service.IBusWellInfoService; import com.casic.missiles.modular.system.service.IDeviceService; -import com.casic.missiles.modular.system.service.impl.BusWellInfoServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataReceiver.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataReceiver.java index 0013989..b3f23d5 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataReceiver.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataReceiver.java @@ -2,6 +2,7 @@ import com.casic.missiles.core.base.controller.BaseController; import com.casic.missiles.core.base.response.ResponseData; +import com.casic.missiles.modular.alarm.service.IAlarmJobService; import com.casic.missiles.modular.alarm.service.IAlarmRecordsService; import com.casic.missiles.modular.alarm.service.IAlarmRuleService; import com.casic.missiles.modular.system.dto.DeviceWellDto; @@ -9,6 +10,7 @@ import com.casic.missiles.modular.system.service.IDeviceService; import com.casic.missiles.modular.system.service.IGasFlowDataService; import lombok.extern.java.Log; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -38,6 +40,9 @@ @Resource private IAlarmRecordsService alarmRecordsService; + @Autowired + IAlarmJobService alarmJobService; + private DecimalFormat df2 = new DecimalFormat("0.00"); @RequestMapping(value = "/data/recv") @@ -117,6 +122,13 @@ alarmRecord.setAlarmTime(Calendar.getInstance().getTime()); alarmRecord.setStatus("1"); alarmRecord.setAlarmMessage("日用气量超阈值报警"); + if (alarmRecordsService.isOldAlarmRecord(gasFlowAddr, "日用气量超阈值报警")) { + alarmRecordsService.updateOldAlarmRecord(gasFlowAddr, "日用气量超阈值报警"); + } else { + AlarmJob alarmJob = alarmJobService.saveData(gasFlowAddr, wellDto.getWellCode(), "SLCX", "1"); + alarmRecord.setJobId(alarmJob.getId()); + } + alarmRecordsService.insertAlarmRecord(alarmRecord); // 向前端推送报警 } else { @@ -134,6 +146,13 @@ alarmRecord.setAlarmTime(Calendar.getInstance().getTime()); alarmRecord.setStatus("1"); alarmRecord.setAlarmMessage("日用气量超阈值预警"); + alarmRecord.setAlarmMessage("日用水量超阈值预警"); + if (alarmRecordsService.isOldAlarmRecord(gasFlowAddr, "日用水量超阈值预警")) { + alarmRecordsService.updateOldAlarmRecord(gasFlowAddr, "日用水量超阈值预警"); + } else { + AlarmJob alarmJob = alarmJobService.saveData(gasFlowAddr, wellDto.getWellCode(), "SLCX", "1"); + alarmRecord.setJobId(alarmJob.getId()); + } alarmRecordsService.insertAlarmRecord(alarmRecord); // 向前端推送报警 } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataReceiver.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataReceiver.java index 6c25e18..200f5d2 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataReceiver.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataReceiver.java @@ -2,16 +2,15 @@ import com.casic.missiles.core.base.controller.BaseController; import com.casic.missiles.core.base.response.ResponseData; +import com.casic.missiles.modular.alarm.service.IAlarmJobService; import com.casic.missiles.modular.alarm.service.IAlarmRecordsService; import com.casic.missiles.modular.alarm.service.IAlarmRuleService; import com.casic.missiles.modular.system.dto.DeviceWellDto; -import com.casic.missiles.modular.system.model.AlarmRecords; -import com.casic.missiles.modular.system.model.AlarmRule; -import com.casic.missiles.modular.system.model.DataWaterMeter; -import com.casic.missiles.modular.system.model.Device; +import com.casic.missiles.modular.system.model.*; import com.casic.missiles.modular.system.service.IDeviceService; import com.casic.missiles.modular.system.service.IWaterMeterDataService; import lombok.extern.java.Log; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -40,6 +39,9 @@ @Resource private IAlarmRecordsService alarmRecordsService; + @Autowired + IAlarmJobService alarmJobService; + private DecimalFormat df2 = new DecimalFormat("0.00"); @RequestMapping(value = "/data/recv") @@ -106,7 +108,6 @@ if (flowAccToday - alarmRule.getHighvalue() > 0) { // 超出报警阈值 生成一条报警消息 AlarmRecords alarmRecord = new AlarmRecords(); - alarmRecord.setDeviceId(device.getId()); alarmRecord.setDevcode(meterAddr); alarmRecord.setWellCode(wellDto.getWellCode()); @@ -116,17 +117,19 @@ alarmRecord.setAlarmTime(Calendar.getInstance().getTime()); alarmRecord.setStatus("1"); alarmRecord.setAlarmMessage("日用水量超阈值报警"); - + if (alarmRecordsService.isOldAlarmRecord(meterAddr, "日用水量超阈值报警")) { + alarmRecordsService.updateOldAlarmRecord(meterAddr, "日用水量超阈值报警"); + } else { + AlarmJob alarmJob = alarmJobService.saveData(meterAddr, wellDto.getWellCode(), "QLCX", "1"); + alarmRecord.setJobId(alarmJob.getId()); + } alarmRecordsService.insertAlarmRecord(alarmRecord); - - // 向前端推送报警 } else { // 如果没有报警则判断是否预警 if (null != alarmRuleWarn && null != alarmRuleWarn.getHighvalue()) { if (flowAccToday - alarmRuleWarn.getHighvalue() > 0) { // 超出预警阈值 生成一条预警消息 AlarmRecords alarmRecord = new AlarmRecords(); - alarmRecord.setDeviceId(device.getId()); alarmRecord.setDevcode(meterAddr); alarmRecord.setWellCode(wellDto.getWellCode()); @@ -136,10 +139,13 @@ alarmRecord.setAlarmTime(Calendar.getInstance().getTime()); alarmRecord.setStatus("1"); alarmRecord.setAlarmMessage("日用水量超阈值预警"); - + if (alarmRecordsService.isOldAlarmRecord(meterAddr, "日用水量超阈值预警")) { + alarmRecordsService.updateOldAlarmRecord(meterAddr, "日用水量超阈值预警"); + } else { + AlarmJob alarmJob = alarmJobService.saveData(meterAddr, wellDto.getWellCode(), "QLCX", "1"); + alarmRecord.setJobId(alarmJob.getId()); + } alarmRecordsService.insertAlarmRecord(alarmRecord); - - // 向前端推送报警 } } } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmJobMapper.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmJobMapper.java index 6592517..ccdff9a 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmJobMapper.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmJobMapper.java @@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.mapper.BaseMapper; import com.baomidou.mybatisplus.plugins.Page; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.system.dto.SelectDto; import com.casic.missiles.modular.system.dto.UserClientView; import com.casic.missiles.modular.system.model.AlarmJob; @@ -21,44 +22,65 @@ * @since 2019-05-17 */ public interface AlarmJobMapper extends BaseMapper { - List> jobList(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("jobStatus") String jobStatus, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("dataScope") DataScope dataScope,@Param("userId")Long userId); - List> jobListApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("jobStatus") String jobStatus, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("deptId")Long deptId,@Param("userId")Long userId,@Param("leaderId")Long leaderId); + List> jobList(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("jobStatus") String jobStatus, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("dataScope") DataScope dataScope, @Param("userId") Long userId); + + List> jobListApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("jobStatus") String jobStatus, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("deptId") Long deptId, @Param("userId") Long userId, @Param("leaderId") Long leaderId); + // List jobListExport(@Param("page") Page page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("jobStatus") String jobStatus, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("dataScope") DataScope dataScope); - List> jobListDelayRe(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("dataScope") DataScope dataScope,@Param("userId")Long userId); - List> jobListDelayReApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("deptId")Long deptId,@Param("userId")Long userId,@Param("leaderId")Long leaderId); + List> jobListDelayRe(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("dataScope") DataScope dataScope, @Param("userId") Long userId); - List> jobListDelayPro(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("dataScope") DataScope dataScope,@Param("userId")Long userId); - List> jobListDelayProApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("deptId")Long deptId,@Param("userId")Long userId,@Param("leaderId")Long leaderId); + List> jobListDelayReApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("deptId") Long deptId, @Param("userId") Long userId, @Param("leaderId") Long leaderId); - List> jobListSearchApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("alarmLevel")String alarmLevel, @Param("alarmContent") String alarmContent, @Param("jobStatus") String jobStatus, @Param("beginTime") String beginTime, @Param("endTime") String endTime, - @Param("getJobBeginTime") String getJobBeginTime, @Param("getJobEndTime") String getJobEndTime, @Param("shouldGetBeginTime") String shouldGetBeginTime, @Param("shouldGetEndTime") String shouldGetEndTime, - @Param("handleJobBeginTime") String handleJobBeginTime, @Param("handleJobEndTime") String handleJobEndTime, @Param("shouldHandleBeginTime") String shouldHandleBeginTime, @Param("shouldHandleEndTime") String shouldHandleEndTime, - @Param("deptId")Long deptId, @Param("userId")Long userId, @Param("leaderId")Long leaderId); - List> jobListSearch(@Param("page") Page> page, @Param("keywords") String keywords, @Param("alarmLevel")String alarmLevel, @Param("alarmContent") String alarmContent, @Param("jobStatus") String jobStatus, @Param("beginTime") String beginTime, @Param("endTime") String endTime, - @Param("getJobBeginTime") String getJobBeginTime, @Param("getJobEndTime") String getJobEndTime, @Param("shouldGetBeginTime") String shouldGetBeginTime, @Param("shouldGetEndTime") String shouldGetEndTime, - @Param("handleJobBeginTime") String handleJobBeginTime, @Param("handleJobEndTime") String handleJobEndTime, @Param("shouldHandleBeginTime") String shouldHandleBeginTime, @Param("shouldHandleEndTime") String shouldHandleEndTime, - @Param("dataScope") DataScope dataScope,@Param("userId")Long userId); + List> jobListDelayPro(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("dataScope") DataScope dataScope, @Param("userId") Long userId); - Map countByJobStatus(@Param("deptId")long deptId,@Param("spanDays") int spanDays); - Map countMyJob(@Param("userId")long userId,@Param("deptId")long deptId,@Param("spanDays") int spanDays); - List> jobInfo(@Param("id") int id,@Param("dataScope") DataScope dataScope,@Param("personId") Long personId); -// boolean getJob(@Param("id") int id,@Param("personId") long personId); - boolean getJob(@Param("id") int id,@Param("personId") long personId,@Param("getTime")Date getTime ,@Param("shouldHandleTime")Date shouldHandleTime); - boolean confirmJob(@Param("id") int id,@Param("personId") long personId,@Param("firstState") String firstState,@Param("firstStatePhotos") String firstStatePhotos,@Param("needHandle") String needHandle); - boolean confirmOverJobAndAlarm(@Param("id") int id,@Param("personId") long personId,@Param("firstState") String firstState,@Param("firstStatePhotos") String firstStatePhotos); - boolean transferJob(@Param("id") int id,@Param("transferPerson") long transferPerson,@Param("flowRec") String flowRec); - boolean saveJob(@Param("id") int id,@Param("handleMessage") String handleMessage,@Param("handlePhotos") String handlePhotos); - boolean overJob(@Param("id") int id,@Param("personId") long personId,@Param("handleMessage") String handleMessage,@Param("handlePhotos") String handlePhotos); + List> jobListDelayProApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("deptId") Long deptId, @Param("userId") Long userId, @Param("leaderId") Long leaderId); + + List> jobListSearchApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("alarmLevel") String alarmLevel, @Param("alarmContent") String alarmContent, @Param("jobStatus") String jobStatus, @Param("beginTime") String beginTime, @Param("endTime") String endTime, + @Param("getJobBeginTime") String getJobBeginTime, @Param("getJobEndTime") String getJobEndTime, @Param("shouldGetBeginTime") String shouldGetBeginTime, @Param("shouldGetEndTime") String shouldGetEndTime, + @Param("handleJobBeginTime") String handleJobBeginTime, @Param("handleJobEndTime") String handleJobEndTime, @Param("shouldHandleBeginTime") String shouldHandleBeginTime, @Param("shouldHandleEndTime") String shouldHandleEndTime, + @Param("deptId") Long deptId, @Param("userId") Long userId, @Param("leaderId") Long leaderId); + + List> jobListSearch(@Param("page") Page> page, @Param("jobListParam") JobListParam jobListParam, + @Param("dataScope") DataScope dataScope, @Param("userId") Long userId); + + Map countByJobStatus(@Param("deptId") long deptId, @Param("spanDays") int spanDays); + + Map countMyJob(@Param("userId") long userId, @Param("deptId") long deptId, @Param("spanDays") int spanDays); + + List> jobInfo(@Param("id") Long id, @Param("dataScope") DataScope dataScope, @Param("personId") Long personId); + + // boolean getJob(@Param("id") int id,@Param("personId") long personId); + boolean getJob(@Param("id") Long id, @Param("personId") long personId, @Param("getTime") Date getTime, @Param("shouldHandleTime") Date shouldHandleTime); + + boolean confirmJob(@Param("id") Long id, @Param("personId") long personId, @Param("firstState") String firstState, @Param("firstStatePhotos") String firstStatePhotos, @Param("needHandle") String needHandle); + + boolean confirmOverJobAndAlarm(@Param("id") Long id, @Param("personId") long personId, @Param("firstState") String firstState, @Param("firstStatePhotos") String firstStatePhotos); + + boolean transferJob(@Param("id") Long id, @Param("transferPerson") long transferPerson, @Param("flowRec") String flowRec); + + boolean saveJob(@Param("id") Long id, @Param("handleMessage") String handleMessage, @Param("handlePhotos") String handlePhotos); + + boolean overJob(@Param("id") int id, @Param("personId") long personId, @Param("handleMessage") String handleMessage, @Param("handlePhotos") String handlePhotos); + boolean overAlarm(@Param("jobId") int id); - boolean overJobAndAlarm(@Param("id") int id,@Param("personId") long personId,@Param("handleMessage") String handleMessage,@Param("handlePhotos") String handlePhotos); - boolean handleJob(@Param("id") int id,@Param("personId") long personId); - List> countByDataScope(@Param("dataScope") DataScope dataScope,@Param("alarmType")String alarmType,@Param("jobStatus")String jobStatus,@Param("beginTime")String beginTime,@Param("endTime")String endTime); - Integer countByResponse(@Param("alarmType")String alarmType,@Param("jobStatus")String jobStatus,@Param("deptId") Long deptId,@Param("beginTime")String beginTime,@Param("endTime")String endTime); - Integer countByUser(@Param("alarmType")String alarmType,@Param("jobStatus")String jobStatus,@Param("userId") Long userId,@Param("beginTime")String beginTime,@Param("endTime")String endTime); + boolean overJobAndAlarm(@Param("id") Long id, @Param("personId") long personId, @Param("handleMessage") String handleMessage, @Param("handlePhotos") String handlePhotos); + + boolean handleJob(@Param("id") Long id, @Param("personId") long personId); + + List> countByDataScope(@Param("dataScope") DataScope dataScope, @Param("alarmType") String alarmType, @Param("jobStatus") String jobStatus, @Param("beginTime") String beginTime, @Param("endTime") String endTime); + + Integer countByResponse(@Param("alarmType") String alarmType, @Param("jobStatus") String jobStatus, @Param("deptId") Long deptId, @Param("beginTime") String beginTime, @Param("endTime") String endTime); + + Integer countByUser(@Param("alarmType") String alarmType, @Param("jobStatus") String jobStatus, @Param("userId") Long userId, @Param("beginTime") String beginTime, @Param("endTime") String endTime); String selectClientIdByUser(@Param("userId") Long userId); + List selectUserByWellCode(@Param("wellCode") String wellCode); + List selectUseIds(@Param("roleIds") List roleIds); + List selectRoles(); + + String getJobCodeMaxSerial(@Param("jobcode") String jobcode); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmRecordsMapper.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmRecordsMapper.java index 87a71ff..d4c6a8b 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmRecordsMapper.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmRecordsMapper.java @@ -11,7 +11,7 @@ /** *

- * Mapper 接口 + * Mapper 接口 *

* * @author casic123 @@ -19,13 +19,18 @@ */ public interface AlarmRecordsMapper extends BaseMapper { - List> alarmList(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("status") String status, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("areaId") String areaId, @Param("dataScope") DataScope dataScope); + List> alarmList(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("status") String status, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("areaId") String areaId, @Param("dataScope") DataScope dataScope); List alarmListNoPage(@Param("scope") DataScope dataScope, @Param("keywords") String keywords, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("areaId") String areaId); - boolean cancelAlarm(@Param("id") long id, @Param("jobStatus")String jobStatus,@Param("handleMessage") String handleMessage,@Param("personId") long personId); + boolean cancelAlarm(@Param("id") long id, @Param("jobStatus") String jobStatus, @Param("handleMessage") String handleMessage, @Param("personId") long personId); boolean cancelAlarmById(@Param("id") long id); boolean cancelAlarmByNewRecord(@Param("devcode") String devcode, @Param("alarmType") String alarmType); + + String isOldAlarmRecord(@Param("devcode") String devcode, @Param("MsgContent") String MsgContent); + + Integer updateOldAlarmRecord(@Param("devcode") String devcode, @Param("MsgContent") String MsgContent); + } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmJobMapper.xml b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmJobMapper.xml index cd850b4..5aeef97 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmJobMapper.xml +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmJobMapper.xml @@ -65,6 +65,7 @@ GROUP BY aj.id ) c + + + + + + + + + + diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmRecordsMapper.xml b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmRecordsMapper.xml index f2b5457..6929f44 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmRecordsMapper.xml +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmRecordsMapper.xml @@ -4,18 +4,18 @@ - - - - - - - - + + + + + + + + - - - + + + @@ -52,14 +52,14 @@ AND ar.STATUS = #{status} - - = #{beginTime} ]]> + + = #{beginTime} ]]> - - + + - - and ar.WELL_CODE like concat('%',CONCAT(#{keywords},'%')) + + and ar.WELL_CODE like concat('%',CONCAT(#{keywords},'%')) AND ar.ALARM_TYPE = #{alarmType} @@ -74,19 +74,19 @@ - UPDATE alarm_job aj, alarm_records ar + UPDATE alarm_job aj, alarm_records ar aj.job_status = #{jobStatus} , aj.handle_job_person = #{personId}, @@ -140,4 +140,20 @@ WHERE ar.devcode = #{devcode} and ar.alarm_type = #{alarmType} + + SELECT ID + FROM alarm_records + WHERE DEVCODE = #{devcode} + AND ALARM_CONTENT = #{MsgContent} + AND STATUS='1' + + + + UPDATE alarm_records + SET STATUS='0' + WHERE DEVCODE = #{devcode} + AND ALARM_CONTENT = #{MsgContent} + AND STATUS='1' + + diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/model/AlarmJob.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/model/AlarmJob.java index 323fcab..69cf1cc 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/model/AlarmJob.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/model/AlarmJob.java @@ -146,25 +146,25 @@ @Override public String toString() { return "AlarmJob{" + - "id=" + id + - ", jobcode=" + jobcode + - ", jogType=" + jobType + - ", wellCode=" + wellCode + - ", devcode=" + devcode + - ", createTime=" + createTime + - ", jobStatus=" + jobStatus + - ", getJobPerson=" + getJobPerson + - ", getJobTime=" + getJobTime + - ", firstState=" + firstState + - ", firstStatePhotos=" + firstStatePhotos + - ", confirmJobPerson=" + confirmJobPerson + - ", confrimJobTime=" + confrimJobTime + - ", handleJobPerson=" + handleJobPerson + - ", handleJobTime=" + handleJobTime + - ", handleMessage=" + handleMessage + - ", handlePhotos=" + handlePhotos + - ", flow=" + flow + - ", recordId=" + recordId + - "}"; + "id=" + id + + ", jobcode=" + jobcode + + ", jogType=" + jobType + + ", wellCode=" + wellCode + + ", devcode=" + devcode + + ", createTime=" + createTime + + ", jobStatus=" + jobStatus + + ", getJobPerson=" + getJobPerson + + ", getJobTime=" + getJobTime + + ", firstState=" + firstState + + ", firstStatePhotos=" + firstStatePhotos + + ", confirmJobPerson=" + confirmJobPerson + + ", confrimJobTime=" + confrimJobTime + + ", handleJobPerson=" + handleJobPerson + + ", handleJobTime=" + handleJobTime + + ", handleMessage=" + handleMessage + + ", handlePhotos=" + handlePhotos + + ", flow=" + flow + + ", recordId=" + recordId + + "}"; } } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java index 46bb487..d27afa9 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java @@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.plugins.Page; import com.casic.missiles.core.base.response.ResponseData; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.alarm.service.IAlarmJobService; import com.casic.missiles.core.common.service.ICommonPermissionService; import com.casic.missiles.core.datascope.DataScope; @@ -12,12 +13,14 @@ import com.casic.missiles.modular.system.warpper.AlarmJobWarpper; import com.casic.missiles.core.base.controller.BaseController; import com.casic.missiles.core.common.constant.factory.PageFactory; +import lombok.extern.slf4j.Slf4j; import org.hswebframework.expands.office.excel.ExcelIO; import org.json.JSONException; import org.json.JSONObject; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; @@ -29,6 +32,7 @@ import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.*; //import com.casic.missiles.core.base.response.ResponseData; @@ -40,6 +44,7 @@ * @Date 2019-05-17 10:48:36 */ @Controller +@Slf4j @RequestMapping("/job") public class AlarmJobController extends BaseController { @@ -65,6 +70,13 @@ private String templatePath; + /** + * 工单状态接口统计 + * + * @param httpServletRequest + * @return + * @throws ParseException + */ @RequestMapping(value = "/countByJobStatus") @ResponseBody public Object countByJobStatus(HttpServletRequest httpServletRequest) throws ParseException { @@ -117,7 +129,7 @@ } /** - * 获取分页列表 + * 获取工单分页列表 */ @RequestMapping(value = "/list") @ResponseBody @@ -164,30 +176,26 @@ */ @RequestMapping(value = "/searchList") @ResponseBody - public Object jobListSearch(String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime, String endTime, - String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, - String handleJobBeginTime, String handleJobEndTime, String shouldHandleBeginTime, String shouldHandleEndTime) { + public Object jobListSearch(@RequestBody JobListParam jobListParam) { Page> page = new PageFactory>().defaultPage("createTime", false); DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List> retList = new ArrayList<>(); if (alarmJobService.checkPcRole(currentUser.getRoleTips())) { // pc角色 - retList = alarmJobService.jobListSearch(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, - handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, dataScope, currentUser.getId()); + retList = alarmJobService.jobListSearch(page, jobListParam, dataScope, currentUser.getId()); } else { //app角色 long leaderId = 0L; if (currentUser.getRoleTips().contains(sLeader)) { // 组长,查组内全部 leaderId = currentUser.getId(); - if (ToolUtil.isNotEmpty(jobStatus)) { + if (ToolUtil.isNotEmpty(jobListParam.getJobStatus())) { //learder&&jobStatus=1,2,3时,关闭传入的sort,按sql排序(自己的排在前) - page.setOpenSort(!alarmJobService.checkJobStatus(jobStatus)); + page.setOpenSort(!alarmJobService.checkJobStatus(jobListParam.getJobStatus())); } } - retList = alarmJobService.jobListSearchApp(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, - handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, currentUser.getDeptId(), currentUser.getId(), leaderId); + retList = alarmJobService.jobListSearchApp(page, jobListParam, currentUser.getDeptId(), currentUser.getId(), leaderId); } new AlarmJobWarpper(retList).warp(); @@ -277,26 +285,24 @@ @RequestMapping(value = "/export") public void exportJob(HttpServletRequest httpServletRequest , HttpServletResponse httpServletResponse) throws IOException { - Page> page = new PageFactory>().defaultPage("createTime", false); page.setLimit(maxRowsExcel); page.setSize(maxRowsExcel); page.setSearchCount(false); page.setOffset(0); - String keywords = httpServletRequest.getParameter("keywords"); String beginTime = httpServletRequest.getParameter("beginTime"); String endTime = httpServletRequest.getParameter("endTime"); String jobStatusStr = httpServletRequest.getParameter("jobStatus"); String alarmTypeStr = httpServletRequest.getParameter("alarmType"); String alarmContentStr = httpServletRequest.getParameter("alarmContentType"); - - List> jobExpList = new ArrayList<>(); + log.debug("主题参数---------------" + keywords + "," + beginTime + "," + endTime + "," + jobStatusStr + "," + alarmTypeStr + "," + alarmContentStr); DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - jobExpList = alarmJobService.jobList(page, keywords, beginTime, endTime, jobStatusStr, alarmTypeStr, alarmContentStr, dataScope, currentUser.getId()); + List> jobExpList = alarmJobService.jobList(page, keywords, beginTime, endTime, jobStatusStr, alarmTypeStr, alarmContentStr, dataScope, currentUser.getId()); new AlarmJobWarpper(jobExpList).warp(); FileInputStream fileInputStream = null; + log.debug("----------------" + ToolUtil.isEmpty(jobExpList)); if (ToolUtil.isEmpty(jobExpList)) { fileInputStream = new FileInputStream(templatePath + "/jobRecEmpty.xlsx"); } else { @@ -305,12 +311,10 @@ try { httpServletResponse.setContentType("application/octet-stream"); httpServletResponse.addHeader("Content-Disposition", " attachment;filename=" + "jobOverview.xlsx"); - Map var = new HashMap<>(); var.put("标题", "工单一览表"); var.put("list", jobExpList); ExcelIO.writeTemplate(fileInputStream, httpServletResponse.getOutputStream(), var); - } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { @@ -328,11 +332,11 @@ */ @RequestMapping(value = "/getJob") @ResponseBody - public Object getJob(int id) { + public Object getJob(Long id) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - if (alarmJobService.getJob(id, currentUser.getId())){ + if (alarmJobService.getJob(id, currentUser.getId())) { return ResponseData.success(); } else { return ResponseData.error("接单失败"); @@ -344,10 +348,10 @@ */ @RequestMapping(value = "/confirmJob") @ResponseBody - public Object confirmJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "firstState", required = true) String firstState, - @RequestParam(value = "firstStatePhotos", required = true) String firstStatePhotos, - @RequestParam(value = "needHandle", required = true) String needHandle) { + public Object confirmJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "firstState", required = true) String firstState, + @RequestParam(value = "firstStatePhotos", required = true) String firstStatePhotos, + @RequestParam(value = "needHandle", required = true) String needHandle) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.confirmJob(id, currentUser.getId(), firstState, firstStatePhotos, needHandle)) { return ResponseData.success(); @@ -361,17 +365,19 @@ */ @RequestMapping(value = "/transferJob") @ResponseBody - public Object transferJob(@RequestParam(value = "id", required = true) int id, + public Object transferJob(@RequestParam(value = "id", required = true) Long id, @RequestParam(value = "transferPerson", required = true) String transferPerson) throws JSONException { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - String dbTime = iSysDictService.getDBtime(); +// String dbTime = iSysDictService.getDBtime(); + SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); +// String dbTime = iSysDictService.getDBtime(); + Date dbTime = new Date(); JSONObject jsonObject = new JSONObject(); jsonObject.put("from", currentUser.getName()); jsonObject.put("to", EhcacheConstant.retBean().getUsernameById(Long.valueOf(transferPerson))); - jsonObject.put("time", dbTime); - + jsonObject.put("time", dateFormat.format(dbTime)); if (alarmJobService.transferJob(id, Long.valueOf(transferPerson), jsonObject.toString())) { return ResponseData.success(); } else { @@ -384,9 +390,9 @@ */ @RequestMapping(value = "/saveJob") @ResponseBody - public Object saveJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "handleMessage", required = true) String handleMessage, - @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { + public Object saveJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "handleMessage", required = true) String handleMessage, + @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { if (alarmJobService.saveJob(id, handleMessage, handlePhotos)) { return ResponseData.success(); @@ -400,10 +406,9 @@ */ @RequestMapping(value = "/overJob") @ResponseBody - public Object overJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "handleMessage", required = true) String handleMessage, - @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { - + public Object overJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "handleMessage", required = true) String handleMessage, + @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.overJob(id, currentUser.getId(), handleMessage, handlePhotos)) { @@ -419,7 +424,7 @@ */ @RequestMapping(value = "/handleJob") @ResponseBody - public Object handleJob(@RequestParam(value = "id", required = true) int id) { + public Object handleJob(@RequestParam(value = "id", required = true) Long id) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.handleJob(id, currentUser.getId())) { return ResponseData.success(); @@ -433,12 +438,10 @@ */ @RequestMapping(value = "/info") @ResponseBody - public Object jobInfo(@RequestParam(value = "id", required = true) int id) { - + public Object jobInfo(@RequestParam(value = "id", required = true) long id) { DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List> retList = alarmJobService.jobInfo(id, dataScope, currentUser.getId()); - new AlarmJobWarpper(retList).warp(); return ResponseData.success(retList); } @@ -456,7 +459,7 @@ @RequestParam(value = "wellCode", required = true) String wellCode) { Map retMap = new HashMap<>(); try { - alarmJobService.updateSinkJob(id, URLDecoder.decode(msg, "UTF-8"),wellCode); + alarmJobService.updateSinkJob(id, URLDecoder.decode(msg, "UTF-8"), wellCode); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java index 26a2ba7..df59231 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java @@ -52,6 +52,7 @@ @Autowired private IDeviceService deviceService; + @Value("${smartcity.office.maxRowsExcel}") private int maxRowsExcel; @Value("${smartcity.config.config-path}") @@ -182,7 +183,8 @@ @RequestMapping(value = "/cancelAlarmById") @ResponseBody public Object cancelAlarmById(@RequestParam(value = "alarmId",required = true) long alarmId){ - boolean isCancel = alarmRecordsService.cancelAlarmById(alarmId); + ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); + boolean isCancel = alarmRecordsService.cancelAlarm(alarmId,"4","手动消警",currentUser.getId()); if(isCancel){ return ResponseData.success(); }else { @@ -235,10 +237,10 @@ //根据查询条件查询alarm_record记录 DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); + ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List alarmRecords = alarmRecordsService.alarmListNoPage(dataScope, keywords, alarmType, alarmContent, beginTime, endTime, areaId); - for (AlarmRecords alarmRecord : alarmRecords) { - alarmRecordsService.cancelAlarmById(alarmRecord.getId()); + alarmRecordsService.cancelAlarm(alarmRecord.getJobId(),"4","手动消警",currentUser.getId()); } return ResponseData.success(); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/model/JobListParam.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/model/JobListParam.java new file mode 100644 index 0000000..c83bff8 --- /dev/null +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/model/JobListParam.java @@ -0,0 +1,32 @@ +package com.casic.missiles.modular.alarm.model; + + +import lombok.Data; + +/** + * @author cz + * @date 2022-6-13 17:03 + */ +@Data +public class JobListParam { + /** + * 关键字 + */ + private String keywords; + /** + * 风险等级 + */ + private String alarmLevel; + private String alarmContent; + private String jobStatus; + private String beginTime; + private String endTime; + private String getJobBeginTime; + private String getJobEndTime; + private String shouldGetBeginTime; + private String shouldGetEndTime; + private String handleJobBeginTime; + private String handleJobEndTime; + private String shouldHandleBeginTime; + private String shouldHandleEndTime; +} diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java index d4db8ce..018d095 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java @@ -3,6 +3,7 @@ import com.baomidou.mybatisplus.plugins.Page; import com.baomidou.mybatisplus.service.IService; import com.casic.missiles.core.datascope.DataScope; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.system.dto.UserClientView; import com.casic.missiles.modular.system.model.AlarmJob; @@ -18,42 +19,60 @@ * @since 2019-05-17 */ public interface IAlarmJobService extends IService { - List> jobList( Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType,String alarmContent, DataScope dataScope,Long userId); - List> jobListApp( Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType,String alarmContent,Long deptId,Long userId,Long leaderId); + + List> jobList(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, DataScope dataScope, Long userId); + + List> jobListApp(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, Long deptId, Long userId, Long leaderId); // List jobListExport( Page page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType,String alarmContent, DataScope dataScope); - List> jobListDelayRe( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, DataScope dataScope,Long userId); - List> jobListDelayReApp( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, Long deptId,Long userId,Long leaderId); + List> jobListDelayRe(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId); - List> jobListDelayPro( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, DataScope dataScope,Long userId ); - List> jobListDelayProApp( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, Long deptId,Long userId,Long leaderId); + List> jobListDelayReApp(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, Long deptId, Long userId, Long leaderId); - List> jobListSearch(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime,String endTime, - String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, - String shouldHandleBeginTime, String shouldHandleEndTime, DataScope dataScope,Long userId); - List> jobListSearchApp(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime,String endTime, - String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, - String shouldHandleBeginTime, String shouldHandleEndTime, Long deptId, Long userId, Long leaderId); - List> jobInfo(int id, DataScope dataScope,Long personId); - boolean getJob(int id, long personId); - boolean confirmJob(int id,long personId,String firstState, String firstStatePhotos, String needHandle); - boolean transferJob(int id, long transferPerson,String flowRec); - boolean saveJob( int id,String handleMessage, String handlePhotos); - boolean overJob( int id,long personId, String handleMessage, String handlePhotos); - boolean overAlarm( int id); - boolean handleJob(int id,long personId); + List> jobListDelayPro(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId); - Map countByJobStatus(long deptId,int spanDays); - Map countMyJob(long userId,long deptId,int spanDays); + List> jobListDelayProApp(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, Long deptId, Long userId, Long leaderId); + + List> jobListSearch(Page> page, JobListParam jobListParam, DataScope dataScope, Long userId); + + List> jobListSearchApp(Page> page, JobListParam jobListParam, Long deptId, Long userId, Long leaderId); + + List> jobInfo(Long id, DataScope dataScope, Long personId); + + boolean getJob(Long id, long personId); + + boolean confirmJob(Long id, long personId, String firstState, String firstStatePhotos, String needHandle); + + boolean transferJob(Long id, long transferPerson, String flowRec); + + boolean saveJob(Long id, String handleMessage, String handlePhotos); + + boolean overJob(Long id, long personId, String handleMessage, String handlePhotos); + + boolean overAlarm(int id); + + boolean handleJob(Long id, long personId); + + Map countByJobStatus(long deptId, int spanDays); + + Map countMyJob(long userId, long deptId, int spanDays); boolean checkJobStatus(String jobStatus); + boolean checkPcRole(List roleTips); - Integer countByDataScope(DataScope dataScope,String alarmType, String jobStatus,String beginTime,String endTime); - Integer countByResponse(String alarmType,String jobStatus,Long deptId,String beginTime,String endTime); - Integer countByUser(String alarmType,String jobStatus,Long userId,String beginTime,String endTime); + Integer countByDataScope(DataScope dataScope, String alarmType, String jobStatus, String beginTime, String endTime); - void updateSinkJob(String id,String msg,String wellCode); + Integer countByResponse(String alarmType, String jobStatus, Long deptId, String beginTime, String endTime); + + Integer countByUser(String alarmType, String jobStatus, Long userId, String beginTime, String endTime); + + void updateSinkJob(String id, String msg, String wellCode); + List selectUserByWellCode(String wellCode); + String selectClientIdByUser(Long userId); + + AlarmJob saveData( String devCode, String wellCode, String devTypeName, String jobType); + } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java index 46e7dfe..6eecb2b 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.service.IService; import com.casic.missiles.modular.system.model.AlarmRecords; import com.casic.missiles.core.datascope.DataScope; +import org.apache.ibatis.annotations.Param; import java.util.List; import java.util.Map; @@ -26,4 +27,8 @@ boolean cancelAlarmById(long id); Integer insertAlarmRecord(AlarmRecords alarmRec); + + Boolean isOldAlarmRecord(String devCode,String MsgContent); + + Integer updateOldAlarmRecord(String devCode,String MsgContent); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java index fa6681d..943ebd7 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java @@ -7,12 +7,14 @@ import com.casic.missiles.core.common.service.ICommonUserService; import com.casic.missiles.modular.alarm.job.HandleAlarmJob; import com.casic.missiles.modular.alarm.job.getDelayJob; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.alarm.service.IAlarmJobService; import com.casic.missiles.core.datascope.DataScope; import com.casic.missiles.core.util.EhcacheConstant; import com.casic.missiles.core.util.ToolUtil; import com.casic.missiles.modular.system.dao.AlarmJobMapper; import com.casic.missiles.modular.system.dao.AlarmRecordsMapper; +import com.casic.missiles.modular.system.dto.DeviceTypeEnum; import com.casic.missiles.modular.system.dto.SelectDto; import com.casic.missiles.modular.system.dto.UserClientView; import com.casic.missiles.modular.system.model.AlarmJob; @@ -24,6 +26,8 @@ import com.casic.missiles.quartz.service.IQuartzManager; import com.gexin.rp.sdk.base.IPushResult; import com.google.gson.GsonBuilder; +import net.sf.ehcache.search.Query; +import net.sf.ehcache.search.expression.Criteria; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -48,6 +52,8 @@ public class AlarmJobServiceImpl extends ServiceImpl implements IAlarmJobService { private static final Logger logger = LoggerFactory.getLogger(AlarmJobServiceImpl.class); + public static final SimpleDateFormat sdf6 = new SimpleDateFormat("yyyyMMdd"); + private static Map deviceAlarmMap = new HashMap(); @Value("${smartcity.leaderRoleName}") private String sLeader; @@ -70,12 +76,14 @@ @Resource private IQuartzManager quartzManager; - @Autowired IBusWellInfoService busWellInfoService; + @Autowired + IBusWellInfoService busWellInfoService; @Override - public List> jobList(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, DataScope dataScope,Long userId) { + public List> jobList(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, DataScope dataScope, Long userId) { alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobList(page, keywords, beginTime, endTime, jobStatus, alarmType, alarmContent, dataScope,userId);return alarmJobList; + List> alarmJobList = this.baseMapper.jobList(page, keywords, beginTime, endTime, jobStatus, alarmType, alarmContent, dataScope, userId); + return alarmJobList; } @Override @@ -86,9 +94,9 @@ } @Override - public List> jobListDelayRe(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope,Long userId) { + public List> jobListDelayRe(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId) { alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListDelayRe(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope,userId); + List> alarmJobList = this.baseMapper.jobListDelayRe(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope, userId); return alarmJobList; } @@ -100,9 +108,9 @@ } @Override - public List> jobListDelayPro(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope,Long userId) { + public List> jobListDelayPro(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId) { alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListDelayPro(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope,userId); + List> alarmJobList = this.baseMapper.jobListDelayPro(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope, userId); return alarmJobList; } @@ -114,109 +122,115 @@ } @Override - public List> jobListSearch(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime, String endTime, String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, String shouldHandleBeginTime, String shouldHandleEndTime, DataScope dataScope,Long userId) { - alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListSearch(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, dataScope,userId); + public List> jobListSearch(Page> page, JobListParam jobListParam, DataScope dataScope, Long userId) { + jobListParam.setAlarmContent(converAlarmContent(jobListParam.getAlarmContent())); + List> alarmJobList = this.baseMapper.jobListSearch(page, jobListParam, dataScope, userId); return alarmJobList; } @Override - public List> jobListSearchApp(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime, String endTime, String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, String shouldHandleBeginTime, String shouldHandleEndTime, Long deptId, Long userId, Long leaderId) { - alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListSearchApp(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, deptId, userId, leaderId); + public List> jobListSearchApp(Page> page, JobListParam jobListParam, Long deptId, Long userId, Long leaderId) { + jobListParam.setAlarmContent(converAlarmContent(jobListParam.getAlarmContent())); + List> alarmJobList = this.baseMapper.jobListSearchApp(page, jobListParam.getKeywords(), + jobListParam.getAlarmLevel(), jobListParam.getAlarmContent(), jobListParam.getJobStatus(), jobListParam.getBeginTime(), + jobListParam.getEndTime(), jobListParam.getGetJobBeginTime(), jobListParam.getGetJobEndTime(), jobListParam.getShouldGetBeginTime(), + jobListParam.getShouldGetEndTime(), jobListParam.getHandleJobBeginTime(), jobListParam.getHandleJobEndTime(), jobListParam.getShouldHandleBeginTime(), + jobListParam.getShouldHandleEndTime(), deptId, userId, leaderId); return alarmJobList; } - private String converAlarmContent(String alarmContent){ - if(ToolUtil.isEmpty(alarmContent)){ + private String converAlarmContent(String alarmContent) { + if (ToolUtil.isEmpty(alarmContent)) { return alarmContent; - }else { + } else { return EhcacheConstant.retBean().getAlarmContentName(Integer.valueOf(alarmContent)); } } @Override - public List> jobInfo(int id, DataScope dataScope, Long personId) - { - List> job = this.baseMapper.jobInfo(id,dataScope,personId); + public List> jobInfo(Long id, DataScope dataScope, Long personId) { + List> job = this.baseMapper.jobInfo(id, dataScope, personId); return job; } @Override - public Map countByJobStatus(long deptId,int spanDays) { - return this.baseMapper.countByJobStatus(deptId,spanDays); + public Map countByJobStatus(long deptId, int spanDays) { + return this.baseMapper.countByJobStatus(deptId, spanDays); } @Override - public Map countMyJob(long userId,long deptId,int spanDays) { - return this.baseMapper.countMyJob(userId,deptId,spanDays); + public Map countMyJob(long userId, long deptId, int spanDays) { + return this.baseMapper.countMyJob(userId, deptId, spanDays); } @Override - public boolean getJob(int id, long personId) { + public boolean getJob(Long id, long personId) { Calendar now = Calendar.getInstance(); Date getTime = now.getTime(); - if(isWeekend(now)){ + if (isWeekend(now)) { now.add(Calendar.WEEK_OF_YEAR, 1); - now.set(Calendar.DAY_OF_WEEK ,Calendar.TUESDAY); - now.set(Calendar.HOUR_OF_DAY,8); - now.set(Calendar.MINUTE,0); - now.set(Calendar.SECOND,0); - }else { + now.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY); + now.set(Calendar.HOUR_OF_DAY, 8); + now.set(Calendar.MINUTE, 0); + now.set(Calendar.SECOND, 0); + } else { now.add(Calendar.HOUR, 24); - while(isWeekend(now)){ + while (isWeekend(now)) { now.add(Calendar.HOUR, 24); } } Date shouldHandleTime = now.getTime(); - if(Boolean.getBoolean(useOverTime)){ + if (Boolean.getBoolean(useOverTime)) { System.out.println(shouldHandleTime); String jobName = "getJobDelay" + id; - Map map = new HashMap<>(); - map.put("jobId",id); - map.put("iAlarmJobService",this); - map.put("iCommonUserService",iCommonUserService); - map.put("iQuartzManager",quartzManager); - map.put("webSocket",webSocket); - quartzManager.addJob(jobName,getDelayJob.class,shouldHandleTime,map); + Map map = new HashMap<>(); + map.put("jobId", id); + map.put("iAlarmJobService", this); + map.put("iCommonUserService", iCommonUserService); + map.put("iQuartzManager", quartzManager); + map.put("webSocket", webSocket); + quartzManager.addJob(jobName, getDelayJob.class, shouldHandleTime, map); } - return this.baseMapper.getJob(id,personId,getTime,shouldHandleTime); + return this.baseMapper.getJob(id, personId, getTime, shouldHandleTime); } - private boolean isWeekend(Calendar cal){ - if(cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY){ + private boolean isWeekend(Calendar cal) { + if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) { return true; - } else{ + } else { return false; } } @Override - public boolean confirmJob(int id,long personId, String firstState, String firstStatePhotos, String needHandle) { - if ("1".equals(needHandle)){ - return this.baseMapper.confirmJob(id,personId, firstState, firstStatePhotos, needHandle); + public boolean confirmJob(Long id, long personId, String firstState, String firstStatePhotos, String needHandle) { + if ("1".equals(needHandle)) { + return this.baseMapper.confirmJob(id, personId, firstState, firstStatePhotos, needHandle); } else { - return this.baseMapper.confirmOverJobAndAlarm(id, personId,firstState, firstStatePhotos); + return this.baseMapper.confirmOverJobAndAlarm(id, personId, firstState, firstStatePhotos); } } @Override - public boolean transferJob(int id, long transferPerson,String flowRec) { - return this.baseMapper.transferJob(id, transferPerson,flowRec); + public boolean transferJob(Long id, long transferPerson, String flowRec) { + return this.baseMapper.transferJob(id, transferPerson, flowRec); } @Override - public boolean saveJob(int id, String handleMessage, String handlePhotos) { + public boolean saveJob(Long id, String handleMessage, String handlePhotos) { return this.baseMapper.saveJob(id, handleMessage, handlePhotos); } @Override - public boolean overJob(int id,long personId, String handleMessage, String handlePhotos) { - return this.baseMapper.overJobAndAlarm(id, personId,handleMessage, handlePhotos); + public boolean overJob(Long id, long personId, String handleMessage, String handlePhotos) { + + return this.baseMapper.overJobAndAlarm(id, personId, handleMessage, handlePhotos); + // return this.baseMapper.overJob(id, personId,handleMessage, handlePhotos); } + @Override public boolean overAlarm(int jobId) { return this.baseMapper.overAlarm(jobId); @@ -224,15 +238,15 @@ } @Override - public boolean handleJob(int id,long personId) { - return this.baseMapper.handleJob(id,personId); + public boolean handleJob(Long id, long personId) { + return this.baseMapper.handleJob(id, personId); } @Override public boolean checkJobStatus(String jobStatus) { - if(ToolUtil.isEmpty(jobStatus)){ + if (ToolUtil.isEmpty(jobStatus)) { return false; - }else{ + } else { return "1".equals(jobStatus) || "2".equals(jobStatus) || "3".equals(jobStatus); } } @@ -243,10 +257,10 @@ } - public List selectRoles() { return this.baseMapper.selectRoles(); } + public List selectUseIds(List roleIds) { return this.baseMapper.selectUseIds(roleIds); } @@ -255,50 +269,50 @@ public boolean checkPcRole(List roleTips) { List roleList = new ArrayList<>(roleTips); Iterator it = roleList.iterator(); - while (it.hasNext()){ + while (it.hasNext()) { String role = it.next(); - if(role.equals(sApp)||role.equals(sLeader)||role.equals(sMember)){ + if (role.equals(sApp) || role.equals(sLeader) || role.equals(sMember)) { it.remove(); } } - return roleList.size()>0; + return roleList.size() > 0; } @Override - public Integer countByDataScope(DataScope dataScope, String alarmType, String jobStatus, String beginTime,String endTime) { - List> res = this.baseMapper.countByDataScope(dataScope,alarmType,jobStatus,beginTime,endTime); + public Integer countByDataScope(DataScope dataScope, String alarmType, String jobStatus, String beginTime, String endTime) { + List> res = this.baseMapper.countByDataScope(dataScope, alarmType, jobStatus, beginTime, endTime); return res.size(); } @Override - public Integer countByResponse(String alarmType, String jobStatus, Long deptId, String beginTime,String endTime) { - return this.baseMapper.countByResponse(alarmType,jobStatus,deptId,beginTime,endTime); + public Integer countByResponse(String alarmType, String jobStatus, Long deptId, String beginTime, String endTime) { + return this.baseMapper.countByResponse(alarmType, jobStatus, deptId, beginTime, endTime); } @Override - public Integer countByUser(String alarmType, String jobStatus, Long userId, String beginTime,String endTime) { - return this.baseMapper.countByUser(alarmType,jobStatus,userId,beginTime,endTime); + public Integer countByUser(String alarmType, String jobStatus, Long userId, String beginTime, String endTime) { + return this.baseMapper.countByUser(alarmType, jobStatus, userId, beginTime, endTime); } @Override - public void updateSinkJob(String id, String msg,String wellCode) { + public void updateSinkJob(String id, String msg, String wellCode) { List userClientViewList = new ArrayList<>(); List selectDtoList = selectRoles(); EntityWrapper busWellInfoEntityWrapper = new EntityWrapper<>(); - busWellInfoEntityWrapper.eq("WELL_CODE",wellCode); + busWellInfoEntityWrapper.eq("WELL_CODE", wellCode); BusWellInfo busWellInfo = busWellInfoService.selectOne(busWellInfoEntityWrapper); - if(busWellInfo!=null&&ToolUtil.isNotEmpty(busWellInfo.getDeptid())){ - List roleids= new ArrayList<>(); - for(SelectDto selectDto:selectDtoList){ - if(ToolUtil.isNotEmpty(selectDto.getName()) - && Arrays.asList(selectDto.getName().split(",")).contains(busWellInfo.getDeptid())){ + if (busWellInfo != null && ToolUtil.isNotEmpty(busWellInfo.getDeptid())) { + List roleids = new ArrayList<>(); + for (SelectDto selectDto : selectDtoList) { + if (ToolUtil.isNotEmpty(selectDto.getName()) + && Arrays.asList(selectDto.getName().split(",")).contains(busWellInfo.getDeptid())) { roleids.add(selectDto.getId()); } } - if(roleids.size()>0){ + if (roleids.size() > 0) { List useIds = selectUseIds(roleids); - for(Long useId:useIds){ + for (Long useId : useIds) { UserClientView userClientView = new UserClientView(); userClientView.setClientid(useId.toString()); userClientView.setId(useId.toString()); @@ -307,11 +321,11 @@ } } - if(!("null".equals(id))){ + if (!("null".equals(id))) { AlarmJob alarmJob = this.baseMapper.selectById(id); sendJob(id, alarmJob, userClientViewList);//推送工单至app和pc端 } - if(StringUtils.isNotBlank(msg)){ + if (StringUtils.isNotBlank(msg)) { sendAlarm(msg, userClientViewList);//推送告警至app和pc端 } @@ -386,7 +400,7 @@ } Date shouldHandleTime = now.getTime(); - if(Boolean.getBoolean(useOverTime)) { + if (Boolean.getBoolean(useOverTime)) { System.out.println(shouldHandleTime); String jobName = "getJobDelay" + id; Map map = new HashMap<>(); @@ -437,4 +451,40 @@ public String selectClientIdByUser(Long userId) { return this.baseMapper.selectClientIdByUser(userId); } + + + public AlarmJob saveData(String devCode, String wellCode, String devTypeName, String jobType) { + AlarmJob alarmJob = new AlarmJob(); + alarmJob.setDevcode(devCode); + alarmJob.setWellCode(wellCode); + alarmJob.setJobStatus("0"); + alarmJob.setCreateTime(new Date()); + alarmJob.setJobcode(this.produceJobCode(devTypeName)); + alarmJob.setJobType(jobType); + this.baseMapper.insert(alarmJob); + return alarmJob; + } + + /** + * 前缀+日期+4位流水号 + * + * @param devTypeName + * @return + */ + private String produceJobCode(String devTypeName) { + String pre = devTypeName; + String dataStr = sdf6.format(new Date()); + String fix = this.getJobCodeMaxSerial(pre + dataStr); + return StringUtils.isNotBlank(fix) ? pre + dataStr + String.format("%04d", Long.valueOf(fix) + 1L) : pre + dataStr + "0001"; + } + + + private String getJobCodeMaxSerial(String jobcode) { + String MaxSerialJobCode = this.baseMapper.getJobCodeMaxSerial(jobcode); + String fix = ""; + if (null != MaxSerialJobCode && MaxSerialJobCode.length() > 4) { + fix = MaxSerialJobCode.substring(MaxSerialJobCode.length() - 4); + } + return fix; + } } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmRecordsServiceImpl.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmRecordsServiceImpl.java index e0f0959..60fa41a 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmRecordsServiceImpl.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmRecordsServiceImpl.java @@ -16,7 +16,7 @@ /** *

- * 服务实现类 + * 服务实现类 *

* * @author casic123 @@ -27,12 +27,12 @@ @Override - public List> alarmList(Page> page, String keywords, String beginTime, String endTime, String status, String alarmType, String alarmContent, String areaId, DataScope dataScope) { + public List> alarmList(Page> page, String keywords, String beginTime, String endTime, String status, String alarmType, String alarmContent, String areaId, DataScope dataScope) { String sContent = null; - if (ToolUtil.isNotEmpty(alarmContent)){ + if (ToolUtil.isNotEmpty(alarmContent)) { sContent = EhcacheConstant.retBean().getAlarmContentName(Integer.valueOf(alarmContent)); } - return this.baseMapper.alarmList(page,keywords,beginTime,endTime,status,alarmType,sContent, areaId, dataScope); + return this.baseMapper.alarmList(page, keywords, beginTime, endTime, status, alarmType, sContent, areaId, dataScope); } /** @@ -41,15 +41,15 @@ @Override public List alarmListNoPage(DataScope dataScope, String keywords, String alarmType, String alarmContent, String beginTime, String endTime, String areaId) { String sContent = null; - if (ToolUtil.isNotEmpty(alarmContent)){ + if (ToolUtil.isNotEmpty(alarmContent)) { sContent = EhcacheConstant.retBean().getAlarmContentName(Integer.valueOf(alarmContent)); } - return this.baseMapper.alarmListNoPage(dataScope,keywords,alarmType,sContent,beginTime,endTime, areaId); + return this.baseMapper.alarmListNoPage(dataScope, keywords, alarmType, sContent, beginTime, endTime, areaId); } @Override public boolean cancelAlarm(long id, String jobStatus, String handleMessage, long personId) { - return this.baseMapper.cancelAlarm(id,jobStatus,handleMessage,personId); + return this.baseMapper.cancelAlarm(id, jobStatus, handleMessage, personId); } @Override @@ -62,4 +62,15 @@ // this.baseMapper.cancelAlarmByNewRecord(alarmRec.getDevcode(), alarmRec.getAlarmType()); return this.baseMapper.insert(alarmRec); } + + public Boolean isOldAlarmRecord(String devCode, String MsgContent) { + if (this.baseMapper.isOldAlarmRecord(devCode, MsgContent) == null) { + return false; + } + return true; + } + + public Integer updateOldAlarmRecord(String devCode, String MsgContent) { + return this.baseMapper.updateOldAlarmRecord(devCode, MsgContent); + } } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/AlarmMapOverviewController.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/AlarmMapOverviewController.java index 9d60185..214c275 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/AlarmMapOverviewController.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/AlarmMapOverviewController.java @@ -8,14 +8,12 @@ import com.casic.missiles.core.exception.GunsExceptionEnum; import com.casic.missiles.core.base.response.SuccessResponseData; import com.casic.missiles.core.util.ToolUtil; -import com.casic.missiles.modular.system.constant.ModularDictConst; import com.casic.missiles.modular.system.dto.AlarmNowView; import com.casic.missiles.modular.system.dto.DeviceDto; import com.casic.missiles.modular.system.model.BusWellInfo; import com.casic.missiles.modular.system.service.IAlarmNowViewService; import com.casic.missiles.modular.system.service.IBusWellInfoService; import com.casic.missiles.modular.system.service.IDeviceService; -import com.casic.missiles.modular.system.service.impl.BusWellInfoServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataReceiver.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataReceiver.java index 0013989..b3f23d5 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataReceiver.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataReceiver.java @@ -2,6 +2,7 @@ import com.casic.missiles.core.base.controller.BaseController; import com.casic.missiles.core.base.response.ResponseData; +import com.casic.missiles.modular.alarm.service.IAlarmJobService; import com.casic.missiles.modular.alarm.service.IAlarmRecordsService; import com.casic.missiles.modular.alarm.service.IAlarmRuleService; import com.casic.missiles.modular.system.dto.DeviceWellDto; @@ -9,6 +10,7 @@ import com.casic.missiles.modular.system.service.IDeviceService; import com.casic.missiles.modular.system.service.IGasFlowDataService; import lombok.extern.java.Log; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -38,6 +40,9 @@ @Resource private IAlarmRecordsService alarmRecordsService; + @Autowired + IAlarmJobService alarmJobService; + private DecimalFormat df2 = new DecimalFormat("0.00"); @RequestMapping(value = "/data/recv") @@ -117,6 +122,13 @@ alarmRecord.setAlarmTime(Calendar.getInstance().getTime()); alarmRecord.setStatus("1"); alarmRecord.setAlarmMessage("日用气量超阈值报警"); + if (alarmRecordsService.isOldAlarmRecord(gasFlowAddr, "日用气量超阈值报警")) { + alarmRecordsService.updateOldAlarmRecord(gasFlowAddr, "日用气量超阈值报警"); + } else { + AlarmJob alarmJob = alarmJobService.saveData(gasFlowAddr, wellDto.getWellCode(), "SLCX", "1"); + alarmRecord.setJobId(alarmJob.getId()); + } + alarmRecordsService.insertAlarmRecord(alarmRecord); // 向前端推送报警 } else { @@ -134,6 +146,13 @@ alarmRecord.setAlarmTime(Calendar.getInstance().getTime()); alarmRecord.setStatus("1"); alarmRecord.setAlarmMessage("日用气量超阈值预警"); + alarmRecord.setAlarmMessage("日用水量超阈值预警"); + if (alarmRecordsService.isOldAlarmRecord(gasFlowAddr, "日用水量超阈值预警")) { + alarmRecordsService.updateOldAlarmRecord(gasFlowAddr, "日用水量超阈值预警"); + } else { + AlarmJob alarmJob = alarmJobService.saveData(gasFlowAddr, wellDto.getWellCode(), "SLCX", "1"); + alarmRecord.setJobId(alarmJob.getId()); + } alarmRecordsService.insertAlarmRecord(alarmRecord); // 向前端推送报警 } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataReceiver.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataReceiver.java index 6c25e18..200f5d2 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataReceiver.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataReceiver.java @@ -2,16 +2,15 @@ import com.casic.missiles.core.base.controller.BaseController; import com.casic.missiles.core.base.response.ResponseData; +import com.casic.missiles.modular.alarm.service.IAlarmJobService; import com.casic.missiles.modular.alarm.service.IAlarmRecordsService; import com.casic.missiles.modular.alarm.service.IAlarmRuleService; import com.casic.missiles.modular.system.dto.DeviceWellDto; -import com.casic.missiles.modular.system.model.AlarmRecords; -import com.casic.missiles.modular.system.model.AlarmRule; -import com.casic.missiles.modular.system.model.DataWaterMeter; -import com.casic.missiles.modular.system.model.Device; +import com.casic.missiles.modular.system.model.*; import com.casic.missiles.modular.system.service.IDeviceService; import com.casic.missiles.modular.system.service.IWaterMeterDataService; import lombok.extern.java.Log; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -40,6 +39,9 @@ @Resource private IAlarmRecordsService alarmRecordsService; + @Autowired + IAlarmJobService alarmJobService; + private DecimalFormat df2 = new DecimalFormat("0.00"); @RequestMapping(value = "/data/recv") @@ -106,7 +108,6 @@ if (flowAccToday - alarmRule.getHighvalue() > 0) { // 超出报警阈值 生成一条报警消息 AlarmRecords alarmRecord = new AlarmRecords(); - alarmRecord.setDeviceId(device.getId()); alarmRecord.setDevcode(meterAddr); alarmRecord.setWellCode(wellDto.getWellCode()); @@ -116,17 +117,19 @@ alarmRecord.setAlarmTime(Calendar.getInstance().getTime()); alarmRecord.setStatus("1"); alarmRecord.setAlarmMessage("日用水量超阈值报警"); - + if (alarmRecordsService.isOldAlarmRecord(meterAddr, "日用水量超阈值报警")) { + alarmRecordsService.updateOldAlarmRecord(meterAddr, "日用水量超阈值报警"); + } else { + AlarmJob alarmJob = alarmJobService.saveData(meterAddr, wellDto.getWellCode(), "QLCX", "1"); + alarmRecord.setJobId(alarmJob.getId()); + } alarmRecordsService.insertAlarmRecord(alarmRecord); - - // 向前端推送报警 } else { // 如果没有报警则判断是否预警 if (null != alarmRuleWarn && null != alarmRuleWarn.getHighvalue()) { if (flowAccToday - alarmRuleWarn.getHighvalue() > 0) { // 超出预警阈值 生成一条预警消息 AlarmRecords alarmRecord = new AlarmRecords(); - alarmRecord.setDeviceId(device.getId()); alarmRecord.setDevcode(meterAddr); alarmRecord.setWellCode(wellDto.getWellCode()); @@ -136,10 +139,13 @@ alarmRecord.setAlarmTime(Calendar.getInstance().getTime()); alarmRecord.setStatus("1"); alarmRecord.setAlarmMessage("日用水量超阈值预警"); - + if (alarmRecordsService.isOldAlarmRecord(meterAddr, "日用水量超阈值预警")) { + alarmRecordsService.updateOldAlarmRecord(meterAddr, "日用水量超阈值预警"); + } else { + AlarmJob alarmJob = alarmJobService.saveData(meterAddr, wellDto.getWellCode(), "QLCX", "1"); + alarmRecord.setJobId(alarmJob.getId()); + } alarmRecordsService.insertAlarmRecord(alarmRecord); - - // 向前端推送报警 } } } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmJobMapper.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmJobMapper.java index 6592517..ccdff9a 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmJobMapper.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmJobMapper.java @@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.mapper.BaseMapper; import com.baomidou.mybatisplus.plugins.Page; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.system.dto.SelectDto; import com.casic.missiles.modular.system.dto.UserClientView; import com.casic.missiles.modular.system.model.AlarmJob; @@ -21,44 +22,65 @@ * @since 2019-05-17 */ public interface AlarmJobMapper extends BaseMapper { - List> jobList(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("jobStatus") String jobStatus, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("dataScope") DataScope dataScope,@Param("userId")Long userId); - List> jobListApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("jobStatus") String jobStatus, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("deptId")Long deptId,@Param("userId")Long userId,@Param("leaderId")Long leaderId); + List> jobList(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("jobStatus") String jobStatus, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("dataScope") DataScope dataScope, @Param("userId") Long userId); + + List> jobListApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("jobStatus") String jobStatus, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("deptId") Long deptId, @Param("userId") Long userId, @Param("leaderId") Long leaderId); + // List jobListExport(@Param("page") Page page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("jobStatus") String jobStatus, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("dataScope") DataScope dataScope); - List> jobListDelayRe(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("dataScope") DataScope dataScope,@Param("userId")Long userId); - List> jobListDelayReApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("deptId")Long deptId,@Param("userId")Long userId,@Param("leaderId")Long leaderId); + List> jobListDelayRe(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("dataScope") DataScope dataScope, @Param("userId") Long userId); - List> jobListDelayPro(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("dataScope") DataScope dataScope,@Param("userId")Long userId); - List> jobListDelayProApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("deptId")Long deptId,@Param("userId")Long userId,@Param("leaderId")Long leaderId); + List> jobListDelayReApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("deptId") Long deptId, @Param("userId") Long userId, @Param("leaderId") Long leaderId); - List> jobListSearchApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("alarmLevel")String alarmLevel, @Param("alarmContent") String alarmContent, @Param("jobStatus") String jobStatus, @Param("beginTime") String beginTime, @Param("endTime") String endTime, - @Param("getJobBeginTime") String getJobBeginTime, @Param("getJobEndTime") String getJobEndTime, @Param("shouldGetBeginTime") String shouldGetBeginTime, @Param("shouldGetEndTime") String shouldGetEndTime, - @Param("handleJobBeginTime") String handleJobBeginTime, @Param("handleJobEndTime") String handleJobEndTime, @Param("shouldHandleBeginTime") String shouldHandleBeginTime, @Param("shouldHandleEndTime") String shouldHandleEndTime, - @Param("deptId")Long deptId, @Param("userId")Long userId, @Param("leaderId")Long leaderId); - List> jobListSearch(@Param("page") Page> page, @Param("keywords") String keywords, @Param("alarmLevel")String alarmLevel, @Param("alarmContent") String alarmContent, @Param("jobStatus") String jobStatus, @Param("beginTime") String beginTime, @Param("endTime") String endTime, - @Param("getJobBeginTime") String getJobBeginTime, @Param("getJobEndTime") String getJobEndTime, @Param("shouldGetBeginTime") String shouldGetBeginTime, @Param("shouldGetEndTime") String shouldGetEndTime, - @Param("handleJobBeginTime") String handleJobBeginTime, @Param("handleJobEndTime") String handleJobEndTime, @Param("shouldHandleBeginTime") String shouldHandleBeginTime, @Param("shouldHandleEndTime") String shouldHandleEndTime, - @Param("dataScope") DataScope dataScope,@Param("userId")Long userId); + List> jobListDelayPro(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("dataScope") DataScope dataScope, @Param("userId") Long userId); - Map countByJobStatus(@Param("deptId")long deptId,@Param("spanDays") int spanDays); - Map countMyJob(@Param("userId")long userId,@Param("deptId")long deptId,@Param("spanDays") int spanDays); - List> jobInfo(@Param("id") int id,@Param("dataScope") DataScope dataScope,@Param("personId") Long personId); -// boolean getJob(@Param("id") int id,@Param("personId") long personId); - boolean getJob(@Param("id") int id,@Param("personId") long personId,@Param("getTime")Date getTime ,@Param("shouldHandleTime")Date shouldHandleTime); - boolean confirmJob(@Param("id") int id,@Param("personId") long personId,@Param("firstState") String firstState,@Param("firstStatePhotos") String firstStatePhotos,@Param("needHandle") String needHandle); - boolean confirmOverJobAndAlarm(@Param("id") int id,@Param("personId") long personId,@Param("firstState") String firstState,@Param("firstStatePhotos") String firstStatePhotos); - boolean transferJob(@Param("id") int id,@Param("transferPerson") long transferPerson,@Param("flowRec") String flowRec); - boolean saveJob(@Param("id") int id,@Param("handleMessage") String handleMessage,@Param("handlePhotos") String handlePhotos); - boolean overJob(@Param("id") int id,@Param("personId") long personId,@Param("handleMessage") String handleMessage,@Param("handlePhotos") String handlePhotos); + List> jobListDelayProApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("deptId") Long deptId, @Param("userId") Long userId, @Param("leaderId") Long leaderId); + + List> jobListSearchApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("alarmLevel") String alarmLevel, @Param("alarmContent") String alarmContent, @Param("jobStatus") String jobStatus, @Param("beginTime") String beginTime, @Param("endTime") String endTime, + @Param("getJobBeginTime") String getJobBeginTime, @Param("getJobEndTime") String getJobEndTime, @Param("shouldGetBeginTime") String shouldGetBeginTime, @Param("shouldGetEndTime") String shouldGetEndTime, + @Param("handleJobBeginTime") String handleJobBeginTime, @Param("handleJobEndTime") String handleJobEndTime, @Param("shouldHandleBeginTime") String shouldHandleBeginTime, @Param("shouldHandleEndTime") String shouldHandleEndTime, + @Param("deptId") Long deptId, @Param("userId") Long userId, @Param("leaderId") Long leaderId); + + List> jobListSearch(@Param("page") Page> page, @Param("jobListParam") JobListParam jobListParam, + @Param("dataScope") DataScope dataScope, @Param("userId") Long userId); + + Map countByJobStatus(@Param("deptId") long deptId, @Param("spanDays") int spanDays); + + Map countMyJob(@Param("userId") long userId, @Param("deptId") long deptId, @Param("spanDays") int spanDays); + + List> jobInfo(@Param("id") Long id, @Param("dataScope") DataScope dataScope, @Param("personId") Long personId); + + // boolean getJob(@Param("id") int id,@Param("personId") long personId); + boolean getJob(@Param("id") Long id, @Param("personId") long personId, @Param("getTime") Date getTime, @Param("shouldHandleTime") Date shouldHandleTime); + + boolean confirmJob(@Param("id") Long id, @Param("personId") long personId, @Param("firstState") String firstState, @Param("firstStatePhotos") String firstStatePhotos, @Param("needHandle") String needHandle); + + boolean confirmOverJobAndAlarm(@Param("id") Long id, @Param("personId") long personId, @Param("firstState") String firstState, @Param("firstStatePhotos") String firstStatePhotos); + + boolean transferJob(@Param("id") Long id, @Param("transferPerson") long transferPerson, @Param("flowRec") String flowRec); + + boolean saveJob(@Param("id") Long id, @Param("handleMessage") String handleMessage, @Param("handlePhotos") String handlePhotos); + + boolean overJob(@Param("id") int id, @Param("personId") long personId, @Param("handleMessage") String handleMessage, @Param("handlePhotos") String handlePhotos); + boolean overAlarm(@Param("jobId") int id); - boolean overJobAndAlarm(@Param("id") int id,@Param("personId") long personId,@Param("handleMessage") String handleMessage,@Param("handlePhotos") String handlePhotos); - boolean handleJob(@Param("id") int id,@Param("personId") long personId); - List> countByDataScope(@Param("dataScope") DataScope dataScope,@Param("alarmType")String alarmType,@Param("jobStatus")String jobStatus,@Param("beginTime")String beginTime,@Param("endTime")String endTime); - Integer countByResponse(@Param("alarmType")String alarmType,@Param("jobStatus")String jobStatus,@Param("deptId") Long deptId,@Param("beginTime")String beginTime,@Param("endTime")String endTime); - Integer countByUser(@Param("alarmType")String alarmType,@Param("jobStatus")String jobStatus,@Param("userId") Long userId,@Param("beginTime")String beginTime,@Param("endTime")String endTime); + boolean overJobAndAlarm(@Param("id") Long id, @Param("personId") long personId, @Param("handleMessage") String handleMessage, @Param("handlePhotos") String handlePhotos); + + boolean handleJob(@Param("id") Long id, @Param("personId") long personId); + + List> countByDataScope(@Param("dataScope") DataScope dataScope, @Param("alarmType") String alarmType, @Param("jobStatus") String jobStatus, @Param("beginTime") String beginTime, @Param("endTime") String endTime); + + Integer countByResponse(@Param("alarmType") String alarmType, @Param("jobStatus") String jobStatus, @Param("deptId") Long deptId, @Param("beginTime") String beginTime, @Param("endTime") String endTime); + + Integer countByUser(@Param("alarmType") String alarmType, @Param("jobStatus") String jobStatus, @Param("userId") Long userId, @Param("beginTime") String beginTime, @Param("endTime") String endTime); String selectClientIdByUser(@Param("userId") Long userId); + List selectUserByWellCode(@Param("wellCode") String wellCode); + List selectUseIds(@Param("roleIds") List roleIds); + List selectRoles(); + + String getJobCodeMaxSerial(@Param("jobcode") String jobcode); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmRecordsMapper.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmRecordsMapper.java index 87a71ff..d4c6a8b 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmRecordsMapper.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmRecordsMapper.java @@ -11,7 +11,7 @@ /** *

- * Mapper 接口 + * Mapper 接口 *

* * @author casic123 @@ -19,13 +19,18 @@ */ public interface AlarmRecordsMapper extends BaseMapper { - List> alarmList(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("status") String status, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("areaId") String areaId, @Param("dataScope") DataScope dataScope); + List> alarmList(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("status") String status, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("areaId") String areaId, @Param("dataScope") DataScope dataScope); List alarmListNoPage(@Param("scope") DataScope dataScope, @Param("keywords") String keywords, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("areaId") String areaId); - boolean cancelAlarm(@Param("id") long id, @Param("jobStatus")String jobStatus,@Param("handleMessage") String handleMessage,@Param("personId") long personId); + boolean cancelAlarm(@Param("id") long id, @Param("jobStatus") String jobStatus, @Param("handleMessage") String handleMessage, @Param("personId") long personId); boolean cancelAlarmById(@Param("id") long id); boolean cancelAlarmByNewRecord(@Param("devcode") String devcode, @Param("alarmType") String alarmType); + + String isOldAlarmRecord(@Param("devcode") String devcode, @Param("MsgContent") String MsgContent); + + Integer updateOldAlarmRecord(@Param("devcode") String devcode, @Param("MsgContent") String MsgContent); + } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmJobMapper.xml b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmJobMapper.xml index cd850b4..5aeef97 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmJobMapper.xml +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmJobMapper.xml @@ -65,6 +65,7 @@ GROUP BY aj.id ) c + + + + + + + + + + diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmRecordsMapper.xml b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmRecordsMapper.xml index f2b5457..6929f44 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmRecordsMapper.xml +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmRecordsMapper.xml @@ -4,18 +4,18 @@ - - - - - - - - + + + + + + + + - - - + + + @@ -52,14 +52,14 @@ AND ar.STATUS = #{status} - - = #{beginTime} ]]> + + = #{beginTime} ]]> - - + + - - and ar.WELL_CODE like concat('%',CONCAT(#{keywords},'%')) + + and ar.WELL_CODE like concat('%',CONCAT(#{keywords},'%')) AND ar.ALARM_TYPE = #{alarmType} @@ -74,19 +74,19 @@ - UPDATE alarm_job aj, alarm_records ar + UPDATE alarm_job aj, alarm_records ar aj.job_status = #{jobStatus} , aj.handle_job_person = #{personId}, @@ -140,4 +140,20 @@ WHERE ar.devcode = #{devcode} and ar.alarm_type = #{alarmType} + + SELECT ID + FROM alarm_records + WHERE DEVCODE = #{devcode} + AND ALARM_CONTENT = #{MsgContent} + AND STATUS='1' + + + + UPDATE alarm_records + SET STATUS='0' + WHERE DEVCODE = #{devcode} + AND ALARM_CONTENT = #{MsgContent} + AND STATUS='1' + + diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/model/AlarmJob.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/model/AlarmJob.java index 323fcab..69cf1cc 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/model/AlarmJob.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/model/AlarmJob.java @@ -146,25 +146,25 @@ @Override public String toString() { return "AlarmJob{" + - "id=" + id + - ", jobcode=" + jobcode + - ", jogType=" + jobType + - ", wellCode=" + wellCode + - ", devcode=" + devcode + - ", createTime=" + createTime + - ", jobStatus=" + jobStatus + - ", getJobPerson=" + getJobPerson + - ", getJobTime=" + getJobTime + - ", firstState=" + firstState + - ", firstStatePhotos=" + firstStatePhotos + - ", confirmJobPerson=" + confirmJobPerson + - ", confrimJobTime=" + confrimJobTime + - ", handleJobPerson=" + handleJobPerson + - ", handleJobTime=" + handleJobTime + - ", handleMessage=" + handleMessage + - ", handlePhotos=" + handlePhotos + - ", flow=" + flow + - ", recordId=" + recordId + - "}"; + "id=" + id + + ", jobcode=" + jobcode + + ", jogType=" + jobType + + ", wellCode=" + wellCode + + ", devcode=" + devcode + + ", createTime=" + createTime + + ", jobStatus=" + jobStatus + + ", getJobPerson=" + getJobPerson + + ", getJobTime=" + getJobTime + + ", firstState=" + firstState + + ", firstStatePhotos=" + firstStatePhotos + + ", confirmJobPerson=" + confirmJobPerson + + ", confrimJobTime=" + confrimJobTime + + ", handleJobPerson=" + handleJobPerson + + ", handleJobTime=" + handleJobTime + + ", handleMessage=" + handleMessage + + ", handlePhotos=" + handlePhotos + + ", flow=" + flow + + ", recordId=" + recordId + + "}"; } } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/util/DateUtil.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/util/DateUtil.java index 88ee7f0..c55acac 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/util/DateUtil.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/util/DateUtil.java @@ -45,4 +45,7 @@ return betweenTime; } + + + } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java index 46bb487..d27afa9 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java @@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.plugins.Page; import com.casic.missiles.core.base.response.ResponseData; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.alarm.service.IAlarmJobService; import com.casic.missiles.core.common.service.ICommonPermissionService; import com.casic.missiles.core.datascope.DataScope; @@ -12,12 +13,14 @@ import com.casic.missiles.modular.system.warpper.AlarmJobWarpper; import com.casic.missiles.core.base.controller.BaseController; import com.casic.missiles.core.common.constant.factory.PageFactory; +import lombok.extern.slf4j.Slf4j; import org.hswebframework.expands.office.excel.ExcelIO; import org.json.JSONException; import org.json.JSONObject; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; @@ -29,6 +32,7 @@ import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.*; //import com.casic.missiles.core.base.response.ResponseData; @@ -40,6 +44,7 @@ * @Date 2019-05-17 10:48:36 */ @Controller +@Slf4j @RequestMapping("/job") public class AlarmJobController extends BaseController { @@ -65,6 +70,13 @@ private String templatePath; + /** + * 工单状态接口统计 + * + * @param httpServletRequest + * @return + * @throws ParseException + */ @RequestMapping(value = "/countByJobStatus") @ResponseBody public Object countByJobStatus(HttpServletRequest httpServletRequest) throws ParseException { @@ -117,7 +129,7 @@ } /** - * 获取分页列表 + * 获取工单分页列表 */ @RequestMapping(value = "/list") @ResponseBody @@ -164,30 +176,26 @@ */ @RequestMapping(value = "/searchList") @ResponseBody - public Object jobListSearch(String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime, String endTime, - String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, - String handleJobBeginTime, String handleJobEndTime, String shouldHandleBeginTime, String shouldHandleEndTime) { + public Object jobListSearch(@RequestBody JobListParam jobListParam) { Page> page = new PageFactory>().defaultPage("createTime", false); DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List> retList = new ArrayList<>(); if (alarmJobService.checkPcRole(currentUser.getRoleTips())) { // pc角色 - retList = alarmJobService.jobListSearch(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, - handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, dataScope, currentUser.getId()); + retList = alarmJobService.jobListSearch(page, jobListParam, dataScope, currentUser.getId()); } else { //app角色 long leaderId = 0L; if (currentUser.getRoleTips().contains(sLeader)) { // 组长,查组内全部 leaderId = currentUser.getId(); - if (ToolUtil.isNotEmpty(jobStatus)) { + if (ToolUtil.isNotEmpty(jobListParam.getJobStatus())) { //learder&&jobStatus=1,2,3时,关闭传入的sort,按sql排序(自己的排在前) - page.setOpenSort(!alarmJobService.checkJobStatus(jobStatus)); + page.setOpenSort(!alarmJobService.checkJobStatus(jobListParam.getJobStatus())); } } - retList = alarmJobService.jobListSearchApp(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, - handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, currentUser.getDeptId(), currentUser.getId(), leaderId); + retList = alarmJobService.jobListSearchApp(page, jobListParam, currentUser.getDeptId(), currentUser.getId(), leaderId); } new AlarmJobWarpper(retList).warp(); @@ -277,26 +285,24 @@ @RequestMapping(value = "/export") public void exportJob(HttpServletRequest httpServletRequest , HttpServletResponse httpServletResponse) throws IOException { - Page> page = new PageFactory>().defaultPage("createTime", false); page.setLimit(maxRowsExcel); page.setSize(maxRowsExcel); page.setSearchCount(false); page.setOffset(0); - String keywords = httpServletRequest.getParameter("keywords"); String beginTime = httpServletRequest.getParameter("beginTime"); String endTime = httpServletRequest.getParameter("endTime"); String jobStatusStr = httpServletRequest.getParameter("jobStatus"); String alarmTypeStr = httpServletRequest.getParameter("alarmType"); String alarmContentStr = httpServletRequest.getParameter("alarmContentType"); - - List> jobExpList = new ArrayList<>(); + log.debug("主题参数---------------" + keywords + "," + beginTime + "," + endTime + "," + jobStatusStr + "," + alarmTypeStr + "," + alarmContentStr); DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - jobExpList = alarmJobService.jobList(page, keywords, beginTime, endTime, jobStatusStr, alarmTypeStr, alarmContentStr, dataScope, currentUser.getId()); + List> jobExpList = alarmJobService.jobList(page, keywords, beginTime, endTime, jobStatusStr, alarmTypeStr, alarmContentStr, dataScope, currentUser.getId()); new AlarmJobWarpper(jobExpList).warp(); FileInputStream fileInputStream = null; + log.debug("----------------" + ToolUtil.isEmpty(jobExpList)); if (ToolUtil.isEmpty(jobExpList)) { fileInputStream = new FileInputStream(templatePath + "/jobRecEmpty.xlsx"); } else { @@ -305,12 +311,10 @@ try { httpServletResponse.setContentType("application/octet-stream"); httpServletResponse.addHeader("Content-Disposition", " attachment;filename=" + "jobOverview.xlsx"); - Map var = new HashMap<>(); var.put("标题", "工单一览表"); var.put("list", jobExpList); ExcelIO.writeTemplate(fileInputStream, httpServletResponse.getOutputStream(), var); - } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { @@ -328,11 +332,11 @@ */ @RequestMapping(value = "/getJob") @ResponseBody - public Object getJob(int id) { + public Object getJob(Long id) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - if (alarmJobService.getJob(id, currentUser.getId())){ + if (alarmJobService.getJob(id, currentUser.getId())) { return ResponseData.success(); } else { return ResponseData.error("接单失败"); @@ -344,10 +348,10 @@ */ @RequestMapping(value = "/confirmJob") @ResponseBody - public Object confirmJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "firstState", required = true) String firstState, - @RequestParam(value = "firstStatePhotos", required = true) String firstStatePhotos, - @RequestParam(value = "needHandle", required = true) String needHandle) { + public Object confirmJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "firstState", required = true) String firstState, + @RequestParam(value = "firstStatePhotos", required = true) String firstStatePhotos, + @RequestParam(value = "needHandle", required = true) String needHandle) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.confirmJob(id, currentUser.getId(), firstState, firstStatePhotos, needHandle)) { return ResponseData.success(); @@ -361,17 +365,19 @@ */ @RequestMapping(value = "/transferJob") @ResponseBody - public Object transferJob(@RequestParam(value = "id", required = true) int id, + public Object transferJob(@RequestParam(value = "id", required = true) Long id, @RequestParam(value = "transferPerson", required = true) String transferPerson) throws JSONException { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - String dbTime = iSysDictService.getDBtime(); +// String dbTime = iSysDictService.getDBtime(); + SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); +// String dbTime = iSysDictService.getDBtime(); + Date dbTime = new Date(); JSONObject jsonObject = new JSONObject(); jsonObject.put("from", currentUser.getName()); jsonObject.put("to", EhcacheConstant.retBean().getUsernameById(Long.valueOf(transferPerson))); - jsonObject.put("time", dbTime); - + jsonObject.put("time", dateFormat.format(dbTime)); if (alarmJobService.transferJob(id, Long.valueOf(transferPerson), jsonObject.toString())) { return ResponseData.success(); } else { @@ -384,9 +390,9 @@ */ @RequestMapping(value = "/saveJob") @ResponseBody - public Object saveJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "handleMessage", required = true) String handleMessage, - @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { + public Object saveJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "handleMessage", required = true) String handleMessage, + @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { if (alarmJobService.saveJob(id, handleMessage, handlePhotos)) { return ResponseData.success(); @@ -400,10 +406,9 @@ */ @RequestMapping(value = "/overJob") @ResponseBody - public Object overJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "handleMessage", required = true) String handleMessage, - @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { - + public Object overJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "handleMessage", required = true) String handleMessage, + @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.overJob(id, currentUser.getId(), handleMessage, handlePhotos)) { @@ -419,7 +424,7 @@ */ @RequestMapping(value = "/handleJob") @ResponseBody - public Object handleJob(@RequestParam(value = "id", required = true) int id) { + public Object handleJob(@RequestParam(value = "id", required = true) Long id) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.handleJob(id, currentUser.getId())) { return ResponseData.success(); @@ -433,12 +438,10 @@ */ @RequestMapping(value = "/info") @ResponseBody - public Object jobInfo(@RequestParam(value = "id", required = true) int id) { - + public Object jobInfo(@RequestParam(value = "id", required = true) long id) { DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List> retList = alarmJobService.jobInfo(id, dataScope, currentUser.getId()); - new AlarmJobWarpper(retList).warp(); return ResponseData.success(retList); } @@ -456,7 +459,7 @@ @RequestParam(value = "wellCode", required = true) String wellCode) { Map retMap = new HashMap<>(); try { - alarmJobService.updateSinkJob(id, URLDecoder.decode(msg, "UTF-8"),wellCode); + alarmJobService.updateSinkJob(id, URLDecoder.decode(msg, "UTF-8"), wellCode); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java index 26a2ba7..df59231 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java @@ -52,6 +52,7 @@ @Autowired private IDeviceService deviceService; + @Value("${smartcity.office.maxRowsExcel}") private int maxRowsExcel; @Value("${smartcity.config.config-path}") @@ -182,7 +183,8 @@ @RequestMapping(value = "/cancelAlarmById") @ResponseBody public Object cancelAlarmById(@RequestParam(value = "alarmId",required = true) long alarmId){ - boolean isCancel = alarmRecordsService.cancelAlarmById(alarmId); + ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); + boolean isCancel = alarmRecordsService.cancelAlarm(alarmId,"4","手动消警",currentUser.getId()); if(isCancel){ return ResponseData.success(); }else { @@ -235,10 +237,10 @@ //根据查询条件查询alarm_record记录 DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); + ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List alarmRecords = alarmRecordsService.alarmListNoPage(dataScope, keywords, alarmType, alarmContent, beginTime, endTime, areaId); - for (AlarmRecords alarmRecord : alarmRecords) { - alarmRecordsService.cancelAlarmById(alarmRecord.getId()); + alarmRecordsService.cancelAlarm(alarmRecord.getJobId(),"4","手动消警",currentUser.getId()); } return ResponseData.success(); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/model/JobListParam.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/model/JobListParam.java new file mode 100644 index 0000000..c83bff8 --- /dev/null +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/model/JobListParam.java @@ -0,0 +1,32 @@ +package com.casic.missiles.modular.alarm.model; + + +import lombok.Data; + +/** + * @author cz + * @date 2022-6-13 17:03 + */ +@Data +public class JobListParam { + /** + * 关键字 + */ + private String keywords; + /** + * 风险等级 + */ + private String alarmLevel; + private String alarmContent; + private String jobStatus; + private String beginTime; + private String endTime; + private String getJobBeginTime; + private String getJobEndTime; + private String shouldGetBeginTime; + private String shouldGetEndTime; + private String handleJobBeginTime; + private String handleJobEndTime; + private String shouldHandleBeginTime; + private String shouldHandleEndTime; +} diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java index d4db8ce..018d095 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java @@ -3,6 +3,7 @@ import com.baomidou.mybatisplus.plugins.Page; import com.baomidou.mybatisplus.service.IService; import com.casic.missiles.core.datascope.DataScope; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.system.dto.UserClientView; import com.casic.missiles.modular.system.model.AlarmJob; @@ -18,42 +19,60 @@ * @since 2019-05-17 */ public interface IAlarmJobService extends IService { - List> jobList( Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType,String alarmContent, DataScope dataScope,Long userId); - List> jobListApp( Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType,String alarmContent,Long deptId,Long userId,Long leaderId); + + List> jobList(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, DataScope dataScope, Long userId); + + List> jobListApp(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, Long deptId, Long userId, Long leaderId); // List jobListExport( Page page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType,String alarmContent, DataScope dataScope); - List> jobListDelayRe( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, DataScope dataScope,Long userId); - List> jobListDelayReApp( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, Long deptId,Long userId,Long leaderId); + List> jobListDelayRe(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId); - List> jobListDelayPro( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, DataScope dataScope,Long userId ); - List> jobListDelayProApp( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, Long deptId,Long userId,Long leaderId); + List> jobListDelayReApp(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, Long deptId, Long userId, Long leaderId); - List> jobListSearch(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime,String endTime, - String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, - String shouldHandleBeginTime, String shouldHandleEndTime, DataScope dataScope,Long userId); - List> jobListSearchApp(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime,String endTime, - String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, - String shouldHandleBeginTime, String shouldHandleEndTime, Long deptId, Long userId, Long leaderId); - List> jobInfo(int id, DataScope dataScope,Long personId); - boolean getJob(int id, long personId); - boolean confirmJob(int id,long personId,String firstState, String firstStatePhotos, String needHandle); - boolean transferJob(int id, long transferPerson,String flowRec); - boolean saveJob( int id,String handleMessage, String handlePhotos); - boolean overJob( int id,long personId, String handleMessage, String handlePhotos); - boolean overAlarm( int id); - boolean handleJob(int id,long personId); + List> jobListDelayPro(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId); - Map countByJobStatus(long deptId,int spanDays); - Map countMyJob(long userId,long deptId,int spanDays); + List> jobListDelayProApp(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, Long deptId, Long userId, Long leaderId); + + List> jobListSearch(Page> page, JobListParam jobListParam, DataScope dataScope, Long userId); + + List> jobListSearchApp(Page> page, JobListParam jobListParam, Long deptId, Long userId, Long leaderId); + + List> jobInfo(Long id, DataScope dataScope, Long personId); + + boolean getJob(Long id, long personId); + + boolean confirmJob(Long id, long personId, String firstState, String firstStatePhotos, String needHandle); + + boolean transferJob(Long id, long transferPerson, String flowRec); + + boolean saveJob(Long id, String handleMessage, String handlePhotos); + + boolean overJob(Long id, long personId, String handleMessage, String handlePhotos); + + boolean overAlarm(int id); + + boolean handleJob(Long id, long personId); + + Map countByJobStatus(long deptId, int spanDays); + + Map countMyJob(long userId, long deptId, int spanDays); boolean checkJobStatus(String jobStatus); + boolean checkPcRole(List roleTips); - Integer countByDataScope(DataScope dataScope,String alarmType, String jobStatus,String beginTime,String endTime); - Integer countByResponse(String alarmType,String jobStatus,Long deptId,String beginTime,String endTime); - Integer countByUser(String alarmType,String jobStatus,Long userId,String beginTime,String endTime); + Integer countByDataScope(DataScope dataScope, String alarmType, String jobStatus, String beginTime, String endTime); - void updateSinkJob(String id,String msg,String wellCode); + Integer countByResponse(String alarmType, String jobStatus, Long deptId, String beginTime, String endTime); + + Integer countByUser(String alarmType, String jobStatus, Long userId, String beginTime, String endTime); + + void updateSinkJob(String id, String msg, String wellCode); + List selectUserByWellCode(String wellCode); + String selectClientIdByUser(Long userId); + + AlarmJob saveData( String devCode, String wellCode, String devTypeName, String jobType); + } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java index 46e7dfe..6eecb2b 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.service.IService; import com.casic.missiles.modular.system.model.AlarmRecords; import com.casic.missiles.core.datascope.DataScope; +import org.apache.ibatis.annotations.Param; import java.util.List; import java.util.Map; @@ -26,4 +27,8 @@ boolean cancelAlarmById(long id); Integer insertAlarmRecord(AlarmRecords alarmRec); + + Boolean isOldAlarmRecord(String devCode,String MsgContent); + + Integer updateOldAlarmRecord(String devCode,String MsgContent); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java index fa6681d..943ebd7 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java @@ -7,12 +7,14 @@ import com.casic.missiles.core.common.service.ICommonUserService; import com.casic.missiles.modular.alarm.job.HandleAlarmJob; import com.casic.missiles.modular.alarm.job.getDelayJob; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.alarm.service.IAlarmJobService; import com.casic.missiles.core.datascope.DataScope; import com.casic.missiles.core.util.EhcacheConstant; import com.casic.missiles.core.util.ToolUtil; import com.casic.missiles.modular.system.dao.AlarmJobMapper; import com.casic.missiles.modular.system.dao.AlarmRecordsMapper; +import com.casic.missiles.modular.system.dto.DeviceTypeEnum; import com.casic.missiles.modular.system.dto.SelectDto; import com.casic.missiles.modular.system.dto.UserClientView; import com.casic.missiles.modular.system.model.AlarmJob; @@ -24,6 +26,8 @@ import com.casic.missiles.quartz.service.IQuartzManager; import com.gexin.rp.sdk.base.IPushResult; import com.google.gson.GsonBuilder; +import net.sf.ehcache.search.Query; +import net.sf.ehcache.search.expression.Criteria; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -48,6 +52,8 @@ public class AlarmJobServiceImpl extends ServiceImpl implements IAlarmJobService { private static final Logger logger = LoggerFactory.getLogger(AlarmJobServiceImpl.class); + public static final SimpleDateFormat sdf6 = new SimpleDateFormat("yyyyMMdd"); + private static Map deviceAlarmMap = new HashMap(); @Value("${smartcity.leaderRoleName}") private String sLeader; @@ -70,12 +76,14 @@ @Resource private IQuartzManager quartzManager; - @Autowired IBusWellInfoService busWellInfoService; + @Autowired + IBusWellInfoService busWellInfoService; @Override - public List> jobList(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, DataScope dataScope,Long userId) { + public List> jobList(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, DataScope dataScope, Long userId) { alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobList(page, keywords, beginTime, endTime, jobStatus, alarmType, alarmContent, dataScope,userId);return alarmJobList; + List> alarmJobList = this.baseMapper.jobList(page, keywords, beginTime, endTime, jobStatus, alarmType, alarmContent, dataScope, userId); + return alarmJobList; } @Override @@ -86,9 +94,9 @@ } @Override - public List> jobListDelayRe(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope,Long userId) { + public List> jobListDelayRe(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId) { alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListDelayRe(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope,userId); + List> alarmJobList = this.baseMapper.jobListDelayRe(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope, userId); return alarmJobList; } @@ -100,9 +108,9 @@ } @Override - public List> jobListDelayPro(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope,Long userId) { + public List> jobListDelayPro(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId) { alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListDelayPro(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope,userId); + List> alarmJobList = this.baseMapper.jobListDelayPro(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope, userId); return alarmJobList; } @@ -114,109 +122,115 @@ } @Override - public List> jobListSearch(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime, String endTime, String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, String shouldHandleBeginTime, String shouldHandleEndTime, DataScope dataScope,Long userId) { - alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListSearch(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, dataScope,userId); + public List> jobListSearch(Page> page, JobListParam jobListParam, DataScope dataScope, Long userId) { + jobListParam.setAlarmContent(converAlarmContent(jobListParam.getAlarmContent())); + List> alarmJobList = this.baseMapper.jobListSearch(page, jobListParam, dataScope, userId); return alarmJobList; } @Override - public List> jobListSearchApp(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime, String endTime, String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, String shouldHandleBeginTime, String shouldHandleEndTime, Long deptId, Long userId, Long leaderId) { - alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListSearchApp(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, deptId, userId, leaderId); + public List> jobListSearchApp(Page> page, JobListParam jobListParam, Long deptId, Long userId, Long leaderId) { + jobListParam.setAlarmContent(converAlarmContent(jobListParam.getAlarmContent())); + List> alarmJobList = this.baseMapper.jobListSearchApp(page, jobListParam.getKeywords(), + jobListParam.getAlarmLevel(), jobListParam.getAlarmContent(), jobListParam.getJobStatus(), jobListParam.getBeginTime(), + jobListParam.getEndTime(), jobListParam.getGetJobBeginTime(), jobListParam.getGetJobEndTime(), jobListParam.getShouldGetBeginTime(), + jobListParam.getShouldGetEndTime(), jobListParam.getHandleJobBeginTime(), jobListParam.getHandleJobEndTime(), jobListParam.getShouldHandleBeginTime(), + jobListParam.getShouldHandleEndTime(), deptId, userId, leaderId); return alarmJobList; } - private String converAlarmContent(String alarmContent){ - if(ToolUtil.isEmpty(alarmContent)){ + private String converAlarmContent(String alarmContent) { + if (ToolUtil.isEmpty(alarmContent)) { return alarmContent; - }else { + } else { return EhcacheConstant.retBean().getAlarmContentName(Integer.valueOf(alarmContent)); } } @Override - public List> jobInfo(int id, DataScope dataScope, Long personId) - { - List> job = this.baseMapper.jobInfo(id,dataScope,personId); + public List> jobInfo(Long id, DataScope dataScope, Long personId) { + List> job = this.baseMapper.jobInfo(id, dataScope, personId); return job; } @Override - public Map countByJobStatus(long deptId,int spanDays) { - return this.baseMapper.countByJobStatus(deptId,spanDays); + public Map countByJobStatus(long deptId, int spanDays) { + return this.baseMapper.countByJobStatus(deptId, spanDays); } @Override - public Map countMyJob(long userId,long deptId,int spanDays) { - return this.baseMapper.countMyJob(userId,deptId,spanDays); + public Map countMyJob(long userId, long deptId, int spanDays) { + return this.baseMapper.countMyJob(userId, deptId, spanDays); } @Override - public boolean getJob(int id, long personId) { + public boolean getJob(Long id, long personId) { Calendar now = Calendar.getInstance(); Date getTime = now.getTime(); - if(isWeekend(now)){ + if (isWeekend(now)) { now.add(Calendar.WEEK_OF_YEAR, 1); - now.set(Calendar.DAY_OF_WEEK ,Calendar.TUESDAY); - now.set(Calendar.HOUR_OF_DAY,8); - now.set(Calendar.MINUTE,0); - now.set(Calendar.SECOND,0); - }else { + now.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY); + now.set(Calendar.HOUR_OF_DAY, 8); + now.set(Calendar.MINUTE, 0); + now.set(Calendar.SECOND, 0); + } else { now.add(Calendar.HOUR, 24); - while(isWeekend(now)){ + while (isWeekend(now)) { now.add(Calendar.HOUR, 24); } } Date shouldHandleTime = now.getTime(); - if(Boolean.getBoolean(useOverTime)){ + if (Boolean.getBoolean(useOverTime)) { System.out.println(shouldHandleTime); String jobName = "getJobDelay" + id; - Map map = new HashMap<>(); - map.put("jobId",id); - map.put("iAlarmJobService",this); - map.put("iCommonUserService",iCommonUserService); - map.put("iQuartzManager",quartzManager); - map.put("webSocket",webSocket); - quartzManager.addJob(jobName,getDelayJob.class,shouldHandleTime,map); + Map map = new HashMap<>(); + map.put("jobId", id); + map.put("iAlarmJobService", this); + map.put("iCommonUserService", iCommonUserService); + map.put("iQuartzManager", quartzManager); + map.put("webSocket", webSocket); + quartzManager.addJob(jobName, getDelayJob.class, shouldHandleTime, map); } - return this.baseMapper.getJob(id,personId,getTime,shouldHandleTime); + return this.baseMapper.getJob(id, personId, getTime, shouldHandleTime); } - private boolean isWeekend(Calendar cal){ - if(cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY){ + private boolean isWeekend(Calendar cal) { + if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) { return true; - } else{ + } else { return false; } } @Override - public boolean confirmJob(int id,long personId, String firstState, String firstStatePhotos, String needHandle) { - if ("1".equals(needHandle)){ - return this.baseMapper.confirmJob(id,personId, firstState, firstStatePhotos, needHandle); + public boolean confirmJob(Long id, long personId, String firstState, String firstStatePhotos, String needHandle) { + if ("1".equals(needHandle)) { + return this.baseMapper.confirmJob(id, personId, firstState, firstStatePhotos, needHandle); } else { - return this.baseMapper.confirmOverJobAndAlarm(id, personId,firstState, firstStatePhotos); + return this.baseMapper.confirmOverJobAndAlarm(id, personId, firstState, firstStatePhotos); } } @Override - public boolean transferJob(int id, long transferPerson,String flowRec) { - return this.baseMapper.transferJob(id, transferPerson,flowRec); + public boolean transferJob(Long id, long transferPerson, String flowRec) { + return this.baseMapper.transferJob(id, transferPerson, flowRec); } @Override - public boolean saveJob(int id, String handleMessage, String handlePhotos) { + public boolean saveJob(Long id, String handleMessage, String handlePhotos) { return this.baseMapper.saveJob(id, handleMessage, handlePhotos); } @Override - public boolean overJob(int id,long personId, String handleMessage, String handlePhotos) { - return this.baseMapper.overJobAndAlarm(id, personId,handleMessage, handlePhotos); + public boolean overJob(Long id, long personId, String handleMessage, String handlePhotos) { + + return this.baseMapper.overJobAndAlarm(id, personId, handleMessage, handlePhotos); + // return this.baseMapper.overJob(id, personId,handleMessage, handlePhotos); } + @Override public boolean overAlarm(int jobId) { return this.baseMapper.overAlarm(jobId); @@ -224,15 +238,15 @@ } @Override - public boolean handleJob(int id,long personId) { - return this.baseMapper.handleJob(id,personId); + public boolean handleJob(Long id, long personId) { + return this.baseMapper.handleJob(id, personId); } @Override public boolean checkJobStatus(String jobStatus) { - if(ToolUtil.isEmpty(jobStatus)){ + if (ToolUtil.isEmpty(jobStatus)) { return false; - }else{ + } else { return "1".equals(jobStatus) || "2".equals(jobStatus) || "3".equals(jobStatus); } } @@ -243,10 +257,10 @@ } - public List selectRoles() { return this.baseMapper.selectRoles(); } + public List selectUseIds(List roleIds) { return this.baseMapper.selectUseIds(roleIds); } @@ -255,50 +269,50 @@ public boolean checkPcRole(List roleTips) { List roleList = new ArrayList<>(roleTips); Iterator it = roleList.iterator(); - while (it.hasNext()){ + while (it.hasNext()) { String role = it.next(); - if(role.equals(sApp)||role.equals(sLeader)||role.equals(sMember)){ + if (role.equals(sApp) || role.equals(sLeader) || role.equals(sMember)) { it.remove(); } } - return roleList.size()>0; + return roleList.size() > 0; } @Override - public Integer countByDataScope(DataScope dataScope, String alarmType, String jobStatus, String beginTime,String endTime) { - List> res = this.baseMapper.countByDataScope(dataScope,alarmType,jobStatus,beginTime,endTime); + public Integer countByDataScope(DataScope dataScope, String alarmType, String jobStatus, String beginTime, String endTime) { + List> res = this.baseMapper.countByDataScope(dataScope, alarmType, jobStatus, beginTime, endTime); return res.size(); } @Override - public Integer countByResponse(String alarmType, String jobStatus, Long deptId, String beginTime,String endTime) { - return this.baseMapper.countByResponse(alarmType,jobStatus,deptId,beginTime,endTime); + public Integer countByResponse(String alarmType, String jobStatus, Long deptId, String beginTime, String endTime) { + return this.baseMapper.countByResponse(alarmType, jobStatus, deptId, beginTime, endTime); } @Override - public Integer countByUser(String alarmType, String jobStatus, Long userId, String beginTime,String endTime) { - return this.baseMapper.countByUser(alarmType,jobStatus,userId,beginTime,endTime); + public Integer countByUser(String alarmType, String jobStatus, Long userId, String beginTime, String endTime) { + return this.baseMapper.countByUser(alarmType, jobStatus, userId, beginTime, endTime); } @Override - public void updateSinkJob(String id, String msg,String wellCode) { + public void updateSinkJob(String id, String msg, String wellCode) { List userClientViewList = new ArrayList<>(); List selectDtoList = selectRoles(); EntityWrapper busWellInfoEntityWrapper = new EntityWrapper<>(); - busWellInfoEntityWrapper.eq("WELL_CODE",wellCode); + busWellInfoEntityWrapper.eq("WELL_CODE", wellCode); BusWellInfo busWellInfo = busWellInfoService.selectOne(busWellInfoEntityWrapper); - if(busWellInfo!=null&&ToolUtil.isNotEmpty(busWellInfo.getDeptid())){ - List roleids= new ArrayList<>(); - for(SelectDto selectDto:selectDtoList){ - if(ToolUtil.isNotEmpty(selectDto.getName()) - && Arrays.asList(selectDto.getName().split(",")).contains(busWellInfo.getDeptid())){ + if (busWellInfo != null && ToolUtil.isNotEmpty(busWellInfo.getDeptid())) { + List roleids = new ArrayList<>(); + for (SelectDto selectDto : selectDtoList) { + if (ToolUtil.isNotEmpty(selectDto.getName()) + && Arrays.asList(selectDto.getName().split(",")).contains(busWellInfo.getDeptid())) { roleids.add(selectDto.getId()); } } - if(roleids.size()>0){ + if (roleids.size() > 0) { List useIds = selectUseIds(roleids); - for(Long useId:useIds){ + for (Long useId : useIds) { UserClientView userClientView = new UserClientView(); userClientView.setClientid(useId.toString()); userClientView.setId(useId.toString()); @@ -307,11 +321,11 @@ } } - if(!("null".equals(id))){ + if (!("null".equals(id))) { AlarmJob alarmJob = this.baseMapper.selectById(id); sendJob(id, alarmJob, userClientViewList);//推送工单至app和pc端 } - if(StringUtils.isNotBlank(msg)){ + if (StringUtils.isNotBlank(msg)) { sendAlarm(msg, userClientViewList);//推送告警至app和pc端 } @@ -386,7 +400,7 @@ } Date shouldHandleTime = now.getTime(); - if(Boolean.getBoolean(useOverTime)) { + if (Boolean.getBoolean(useOverTime)) { System.out.println(shouldHandleTime); String jobName = "getJobDelay" + id; Map map = new HashMap<>(); @@ -437,4 +451,40 @@ public String selectClientIdByUser(Long userId) { return this.baseMapper.selectClientIdByUser(userId); } + + + public AlarmJob saveData(String devCode, String wellCode, String devTypeName, String jobType) { + AlarmJob alarmJob = new AlarmJob(); + alarmJob.setDevcode(devCode); + alarmJob.setWellCode(wellCode); + alarmJob.setJobStatus("0"); + alarmJob.setCreateTime(new Date()); + alarmJob.setJobcode(this.produceJobCode(devTypeName)); + alarmJob.setJobType(jobType); + this.baseMapper.insert(alarmJob); + return alarmJob; + } + + /** + * 前缀+日期+4位流水号 + * + * @param devTypeName + * @return + */ + private String produceJobCode(String devTypeName) { + String pre = devTypeName; + String dataStr = sdf6.format(new Date()); + String fix = this.getJobCodeMaxSerial(pre + dataStr); + return StringUtils.isNotBlank(fix) ? pre + dataStr + String.format("%04d", Long.valueOf(fix) + 1L) : pre + dataStr + "0001"; + } + + + private String getJobCodeMaxSerial(String jobcode) { + String MaxSerialJobCode = this.baseMapper.getJobCodeMaxSerial(jobcode); + String fix = ""; + if (null != MaxSerialJobCode && MaxSerialJobCode.length() > 4) { + fix = MaxSerialJobCode.substring(MaxSerialJobCode.length() - 4); + } + return fix; + } } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmRecordsServiceImpl.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmRecordsServiceImpl.java index e0f0959..60fa41a 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmRecordsServiceImpl.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmRecordsServiceImpl.java @@ -16,7 +16,7 @@ /** *

- * 服务实现类 + * 服务实现类 *

* * @author casic123 @@ -27,12 +27,12 @@ @Override - public List> alarmList(Page> page, String keywords, String beginTime, String endTime, String status, String alarmType, String alarmContent, String areaId, DataScope dataScope) { + public List> alarmList(Page> page, String keywords, String beginTime, String endTime, String status, String alarmType, String alarmContent, String areaId, DataScope dataScope) { String sContent = null; - if (ToolUtil.isNotEmpty(alarmContent)){ + if (ToolUtil.isNotEmpty(alarmContent)) { sContent = EhcacheConstant.retBean().getAlarmContentName(Integer.valueOf(alarmContent)); } - return this.baseMapper.alarmList(page,keywords,beginTime,endTime,status,alarmType,sContent, areaId, dataScope); + return this.baseMapper.alarmList(page, keywords, beginTime, endTime, status, alarmType, sContent, areaId, dataScope); } /** @@ -41,15 +41,15 @@ @Override public List alarmListNoPage(DataScope dataScope, String keywords, String alarmType, String alarmContent, String beginTime, String endTime, String areaId) { String sContent = null; - if (ToolUtil.isNotEmpty(alarmContent)){ + if (ToolUtil.isNotEmpty(alarmContent)) { sContent = EhcacheConstant.retBean().getAlarmContentName(Integer.valueOf(alarmContent)); } - return this.baseMapper.alarmListNoPage(dataScope,keywords,alarmType,sContent,beginTime,endTime, areaId); + return this.baseMapper.alarmListNoPage(dataScope, keywords, alarmType, sContent, beginTime, endTime, areaId); } @Override public boolean cancelAlarm(long id, String jobStatus, String handleMessage, long personId) { - return this.baseMapper.cancelAlarm(id,jobStatus,handleMessage,personId); + return this.baseMapper.cancelAlarm(id, jobStatus, handleMessage, personId); } @Override @@ -62,4 +62,15 @@ // this.baseMapper.cancelAlarmByNewRecord(alarmRec.getDevcode(), alarmRec.getAlarmType()); return this.baseMapper.insert(alarmRec); } + + public Boolean isOldAlarmRecord(String devCode, String MsgContent) { + if (this.baseMapper.isOldAlarmRecord(devCode, MsgContent) == null) { + return false; + } + return true; + } + + public Integer updateOldAlarmRecord(String devCode, String MsgContent) { + return this.baseMapper.updateOldAlarmRecord(devCode, MsgContent); + } } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/AlarmMapOverviewController.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/AlarmMapOverviewController.java index 9d60185..214c275 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/AlarmMapOverviewController.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/AlarmMapOverviewController.java @@ -8,14 +8,12 @@ import com.casic.missiles.core.exception.GunsExceptionEnum; import com.casic.missiles.core.base.response.SuccessResponseData; import com.casic.missiles.core.util.ToolUtil; -import com.casic.missiles.modular.system.constant.ModularDictConst; import com.casic.missiles.modular.system.dto.AlarmNowView; import com.casic.missiles.modular.system.dto.DeviceDto; import com.casic.missiles.modular.system.model.BusWellInfo; import com.casic.missiles.modular.system.service.IAlarmNowViewService; import com.casic.missiles.modular.system.service.IBusWellInfoService; import com.casic.missiles.modular.system.service.IDeviceService; -import com.casic.missiles.modular.system.service.impl.BusWellInfoServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataReceiver.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataReceiver.java index 0013989..b3f23d5 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataReceiver.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataReceiver.java @@ -2,6 +2,7 @@ import com.casic.missiles.core.base.controller.BaseController; import com.casic.missiles.core.base.response.ResponseData; +import com.casic.missiles.modular.alarm.service.IAlarmJobService; import com.casic.missiles.modular.alarm.service.IAlarmRecordsService; import com.casic.missiles.modular.alarm.service.IAlarmRuleService; import com.casic.missiles.modular.system.dto.DeviceWellDto; @@ -9,6 +10,7 @@ import com.casic.missiles.modular.system.service.IDeviceService; import com.casic.missiles.modular.system.service.IGasFlowDataService; import lombok.extern.java.Log; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -38,6 +40,9 @@ @Resource private IAlarmRecordsService alarmRecordsService; + @Autowired + IAlarmJobService alarmJobService; + private DecimalFormat df2 = new DecimalFormat("0.00"); @RequestMapping(value = "/data/recv") @@ -117,6 +122,13 @@ alarmRecord.setAlarmTime(Calendar.getInstance().getTime()); alarmRecord.setStatus("1"); alarmRecord.setAlarmMessage("日用气量超阈值报警"); + if (alarmRecordsService.isOldAlarmRecord(gasFlowAddr, "日用气量超阈值报警")) { + alarmRecordsService.updateOldAlarmRecord(gasFlowAddr, "日用气量超阈值报警"); + } else { + AlarmJob alarmJob = alarmJobService.saveData(gasFlowAddr, wellDto.getWellCode(), "SLCX", "1"); + alarmRecord.setJobId(alarmJob.getId()); + } + alarmRecordsService.insertAlarmRecord(alarmRecord); // 向前端推送报警 } else { @@ -134,6 +146,13 @@ alarmRecord.setAlarmTime(Calendar.getInstance().getTime()); alarmRecord.setStatus("1"); alarmRecord.setAlarmMessage("日用气量超阈值预警"); + alarmRecord.setAlarmMessage("日用水量超阈值预警"); + if (alarmRecordsService.isOldAlarmRecord(gasFlowAddr, "日用水量超阈值预警")) { + alarmRecordsService.updateOldAlarmRecord(gasFlowAddr, "日用水量超阈值预警"); + } else { + AlarmJob alarmJob = alarmJobService.saveData(gasFlowAddr, wellDto.getWellCode(), "SLCX", "1"); + alarmRecord.setJobId(alarmJob.getId()); + } alarmRecordsService.insertAlarmRecord(alarmRecord); // 向前端推送报警 } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataReceiver.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataReceiver.java index 6c25e18..200f5d2 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataReceiver.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataReceiver.java @@ -2,16 +2,15 @@ import com.casic.missiles.core.base.controller.BaseController; import com.casic.missiles.core.base.response.ResponseData; +import com.casic.missiles.modular.alarm.service.IAlarmJobService; import com.casic.missiles.modular.alarm.service.IAlarmRecordsService; import com.casic.missiles.modular.alarm.service.IAlarmRuleService; import com.casic.missiles.modular.system.dto.DeviceWellDto; -import com.casic.missiles.modular.system.model.AlarmRecords; -import com.casic.missiles.modular.system.model.AlarmRule; -import com.casic.missiles.modular.system.model.DataWaterMeter; -import com.casic.missiles.modular.system.model.Device; +import com.casic.missiles.modular.system.model.*; import com.casic.missiles.modular.system.service.IDeviceService; import com.casic.missiles.modular.system.service.IWaterMeterDataService; import lombok.extern.java.Log; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -40,6 +39,9 @@ @Resource private IAlarmRecordsService alarmRecordsService; + @Autowired + IAlarmJobService alarmJobService; + private DecimalFormat df2 = new DecimalFormat("0.00"); @RequestMapping(value = "/data/recv") @@ -106,7 +108,6 @@ if (flowAccToday - alarmRule.getHighvalue() > 0) { // 超出报警阈值 生成一条报警消息 AlarmRecords alarmRecord = new AlarmRecords(); - alarmRecord.setDeviceId(device.getId()); alarmRecord.setDevcode(meterAddr); alarmRecord.setWellCode(wellDto.getWellCode()); @@ -116,17 +117,19 @@ alarmRecord.setAlarmTime(Calendar.getInstance().getTime()); alarmRecord.setStatus("1"); alarmRecord.setAlarmMessage("日用水量超阈值报警"); - + if (alarmRecordsService.isOldAlarmRecord(meterAddr, "日用水量超阈值报警")) { + alarmRecordsService.updateOldAlarmRecord(meterAddr, "日用水量超阈值报警"); + } else { + AlarmJob alarmJob = alarmJobService.saveData(meterAddr, wellDto.getWellCode(), "QLCX", "1"); + alarmRecord.setJobId(alarmJob.getId()); + } alarmRecordsService.insertAlarmRecord(alarmRecord); - - // 向前端推送报警 } else { // 如果没有报警则判断是否预警 if (null != alarmRuleWarn && null != alarmRuleWarn.getHighvalue()) { if (flowAccToday - alarmRuleWarn.getHighvalue() > 0) { // 超出预警阈值 生成一条预警消息 AlarmRecords alarmRecord = new AlarmRecords(); - alarmRecord.setDeviceId(device.getId()); alarmRecord.setDevcode(meterAddr); alarmRecord.setWellCode(wellDto.getWellCode()); @@ -136,10 +139,13 @@ alarmRecord.setAlarmTime(Calendar.getInstance().getTime()); alarmRecord.setStatus("1"); alarmRecord.setAlarmMessage("日用水量超阈值预警"); - + if (alarmRecordsService.isOldAlarmRecord(meterAddr, "日用水量超阈值预警")) { + alarmRecordsService.updateOldAlarmRecord(meterAddr, "日用水量超阈值预警"); + } else { + AlarmJob alarmJob = alarmJobService.saveData(meterAddr, wellDto.getWellCode(), "QLCX", "1"); + alarmRecord.setJobId(alarmJob.getId()); + } alarmRecordsService.insertAlarmRecord(alarmRecord); - - // 向前端推送报警 } } } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmJobMapper.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmJobMapper.java index 6592517..ccdff9a 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmJobMapper.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmJobMapper.java @@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.mapper.BaseMapper; import com.baomidou.mybatisplus.plugins.Page; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.system.dto.SelectDto; import com.casic.missiles.modular.system.dto.UserClientView; import com.casic.missiles.modular.system.model.AlarmJob; @@ -21,44 +22,65 @@ * @since 2019-05-17 */ public interface AlarmJobMapper extends BaseMapper { - List> jobList(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("jobStatus") String jobStatus, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("dataScope") DataScope dataScope,@Param("userId")Long userId); - List> jobListApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("jobStatus") String jobStatus, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("deptId")Long deptId,@Param("userId")Long userId,@Param("leaderId")Long leaderId); + List> jobList(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("jobStatus") String jobStatus, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("dataScope") DataScope dataScope, @Param("userId") Long userId); + + List> jobListApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("jobStatus") String jobStatus, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("deptId") Long deptId, @Param("userId") Long userId, @Param("leaderId") Long leaderId); + // List jobListExport(@Param("page") Page page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("jobStatus") String jobStatus, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("dataScope") DataScope dataScope); - List> jobListDelayRe(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("dataScope") DataScope dataScope,@Param("userId")Long userId); - List> jobListDelayReApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("deptId")Long deptId,@Param("userId")Long userId,@Param("leaderId")Long leaderId); + List> jobListDelayRe(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("dataScope") DataScope dataScope, @Param("userId") Long userId); - List> jobListDelayPro(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("dataScope") DataScope dataScope,@Param("userId")Long userId); - List> jobListDelayProApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("deptId")Long deptId,@Param("userId")Long userId,@Param("leaderId")Long leaderId); + List> jobListDelayReApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("deptId") Long deptId, @Param("userId") Long userId, @Param("leaderId") Long leaderId); - List> jobListSearchApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("alarmLevel")String alarmLevel, @Param("alarmContent") String alarmContent, @Param("jobStatus") String jobStatus, @Param("beginTime") String beginTime, @Param("endTime") String endTime, - @Param("getJobBeginTime") String getJobBeginTime, @Param("getJobEndTime") String getJobEndTime, @Param("shouldGetBeginTime") String shouldGetBeginTime, @Param("shouldGetEndTime") String shouldGetEndTime, - @Param("handleJobBeginTime") String handleJobBeginTime, @Param("handleJobEndTime") String handleJobEndTime, @Param("shouldHandleBeginTime") String shouldHandleBeginTime, @Param("shouldHandleEndTime") String shouldHandleEndTime, - @Param("deptId")Long deptId, @Param("userId")Long userId, @Param("leaderId")Long leaderId); - List> jobListSearch(@Param("page") Page> page, @Param("keywords") String keywords, @Param("alarmLevel")String alarmLevel, @Param("alarmContent") String alarmContent, @Param("jobStatus") String jobStatus, @Param("beginTime") String beginTime, @Param("endTime") String endTime, - @Param("getJobBeginTime") String getJobBeginTime, @Param("getJobEndTime") String getJobEndTime, @Param("shouldGetBeginTime") String shouldGetBeginTime, @Param("shouldGetEndTime") String shouldGetEndTime, - @Param("handleJobBeginTime") String handleJobBeginTime, @Param("handleJobEndTime") String handleJobEndTime, @Param("shouldHandleBeginTime") String shouldHandleBeginTime, @Param("shouldHandleEndTime") String shouldHandleEndTime, - @Param("dataScope") DataScope dataScope,@Param("userId")Long userId); + List> jobListDelayPro(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("dataScope") DataScope dataScope, @Param("userId") Long userId); - Map countByJobStatus(@Param("deptId")long deptId,@Param("spanDays") int spanDays); - Map countMyJob(@Param("userId")long userId,@Param("deptId")long deptId,@Param("spanDays") int spanDays); - List> jobInfo(@Param("id") int id,@Param("dataScope") DataScope dataScope,@Param("personId") Long personId); -// boolean getJob(@Param("id") int id,@Param("personId") long personId); - boolean getJob(@Param("id") int id,@Param("personId") long personId,@Param("getTime")Date getTime ,@Param("shouldHandleTime")Date shouldHandleTime); - boolean confirmJob(@Param("id") int id,@Param("personId") long personId,@Param("firstState") String firstState,@Param("firstStatePhotos") String firstStatePhotos,@Param("needHandle") String needHandle); - boolean confirmOverJobAndAlarm(@Param("id") int id,@Param("personId") long personId,@Param("firstState") String firstState,@Param("firstStatePhotos") String firstStatePhotos); - boolean transferJob(@Param("id") int id,@Param("transferPerson") long transferPerson,@Param("flowRec") String flowRec); - boolean saveJob(@Param("id") int id,@Param("handleMessage") String handleMessage,@Param("handlePhotos") String handlePhotos); - boolean overJob(@Param("id") int id,@Param("personId") long personId,@Param("handleMessage") String handleMessage,@Param("handlePhotos") String handlePhotos); + List> jobListDelayProApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("deptId") Long deptId, @Param("userId") Long userId, @Param("leaderId") Long leaderId); + + List> jobListSearchApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("alarmLevel") String alarmLevel, @Param("alarmContent") String alarmContent, @Param("jobStatus") String jobStatus, @Param("beginTime") String beginTime, @Param("endTime") String endTime, + @Param("getJobBeginTime") String getJobBeginTime, @Param("getJobEndTime") String getJobEndTime, @Param("shouldGetBeginTime") String shouldGetBeginTime, @Param("shouldGetEndTime") String shouldGetEndTime, + @Param("handleJobBeginTime") String handleJobBeginTime, @Param("handleJobEndTime") String handleJobEndTime, @Param("shouldHandleBeginTime") String shouldHandleBeginTime, @Param("shouldHandleEndTime") String shouldHandleEndTime, + @Param("deptId") Long deptId, @Param("userId") Long userId, @Param("leaderId") Long leaderId); + + List> jobListSearch(@Param("page") Page> page, @Param("jobListParam") JobListParam jobListParam, + @Param("dataScope") DataScope dataScope, @Param("userId") Long userId); + + Map countByJobStatus(@Param("deptId") long deptId, @Param("spanDays") int spanDays); + + Map countMyJob(@Param("userId") long userId, @Param("deptId") long deptId, @Param("spanDays") int spanDays); + + List> jobInfo(@Param("id") Long id, @Param("dataScope") DataScope dataScope, @Param("personId") Long personId); + + // boolean getJob(@Param("id") int id,@Param("personId") long personId); + boolean getJob(@Param("id") Long id, @Param("personId") long personId, @Param("getTime") Date getTime, @Param("shouldHandleTime") Date shouldHandleTime); + + boolean confirmJob(@Param("id") Long id, @Param("personId") long personId, @Param("firstState") String firstState, @Param("firstStatePhotos") String firstStatePhotos, @Param("needHandle") String needHandle); + + boolean confirmOverJobAndAlarm(@Param("id") Long id, @Param("personId") long personId, @Param("firstState") String firstState, @Param("firstStatePhotos") String firstStatePhotos); + + boolean transferJob(@Param("id") Long id, @Param("transferPerson") long transferPerson, @Param("flowRec") String flowRec); + + boolean saveJob(@Param("id") Long id, @Param("handleMessage") String handleMessage, @Param("handlePhotos") String handlePhotos); + + boolean overJob(@Param("id") int id, @Param("personId") long personId, @Param("handleMessage") String handleMessage, @Param("handlePhotos") String handlePhotos); + boolean overAlarm(@Param("jobId") int id); - boolean overJobAndAlarm(@Param("id") int id,@Param("personId") long personId,@Param("handleMessage") String handleMessage,@Param("handlePhotos") String handlePhotos); - boolean handleJob(@Param("id") int id,@Param("personId") long personId); - List> countByDataScope(@Param("dataScope") DataScope dataScope,@Param("alarmType")String alarmType,@Param("jobStatus")String jobStatus,@Param("beginTime")String beginTime,@Param("endTime")String endTime); - Integer countByResponse(@Param("alarmType")String alarmType,@Param("jobStatus")String jobStatus,@Param("deptId") Long deptId,@Param("beginTime")String beginTime,@Param("endTime")String endTime); - Integer countByUser(@Param("alarmType")String alarmType,@Param("jobStatus")String jobStatus,@Param("userId") Long userId,@Param("beginTime")String beginTime,@Param("endTime")String endTime); + boolean overJobAndAlarm(@Param("id") Long id, @Param("personId") long personId, @Param("handleMessage") String handleMessage, @Param("handlePhotos") String handlePhotos); + + boolean handleJob(@Param("id") Long id, @Param("personId") long personId); + + List> countByDataScope(@Param("dataScope") DataScope dataScope, @Param("alarmType") String alarmType, @Param("jobStatus") String jobStatus, @Param("beginTime") String beginTime, @Param("endTime") String endTime); + + Integer countByResponse(@Param("alarmType") String alarmType, @Param("jobStatus") String jobStatus, @Param("deptId") Long deptId, @Param("beginTime") String beginTime, @Param("endTime") String endTime); + + Integer countByUser(@Param("alarmType") String alarmType, @Param("jobStatus") String jobStatus, @Param("userId") Long userId, @Param("beginTime") String beginTime, @Param("endTime") String endTime); String selectClientIdByUser(@Param("userId") Long userId); + List selectUserByWellCode(@Param("wellCode") String wellCode); + List selectUseIds(@Param("roleIds") List roleIds); + List selectRoles(); + + String getJobCodeMaxSerial(@Param("jobcode") String jobcode); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmRecordsMapper.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmRecordsMapper.java index 87a71ff..d4c6a8b 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmRecordsMapper.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmRecordsMapper.java @@ -11,7 +11,7 @@ /** *

- * Mapper 接口 + * Mapper 接口 *

* * @author casic123 @@ -19,13 +19,18 @@ */ public interface AlarmRecordsMapper extends BaseMapper { - List> alarmList(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("status") String status, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("areaId") String areaId, @Param("dataScope") DataScope dataScope); + List> alarmList(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("status") String status, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("areaId") String areaId, @Param("dataScope") DataScope dataScope); List alarmListNoPage(@Param("scope") DataScope dataScope, @Param("keywords") String keywords, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("areaId") String areaId); - boolean cancelAlarm(@Param("id") long id, @Param("jobStatus")String jobStatus,@Param("handleMessage") String handleMessage,@Param("personId") long personId); + boolean cancelAlarm(@Param("id") long id, @Param("jobStatus") String jobStatus, @Param("handleMessage") String handleMessage, @Param("personId") long personId); boolean cancelAlarmById(@Param("id") long id); boolean cancelAlarmByNewRecord(@Param("devcode") String devcode, @Param("alarmType") String alarmType); + + String isOldAlarmRecord(@Param("devcode") String devcode, @Param("MsgContent") String MsgContent); + + Integer updateOldAlarmRecord(@Param("devcode") String devcode, @Param("MsgContent") String MsgContent); + } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmJobMapper.xml b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmJobMapper.xml index cd850b4..5aeef97 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmJobMapper.xml +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmJobMapper.xml @@ -65,6 +65,7 @@ GROUP BY aj.id ) c + + + + + + + + + + diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmRecordsMapper.xml b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmRecordsMapper.xml index f2b5457..6929f44 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmRecordsMapper.xml +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmRecordsMapper.xml @@ -4,18 +4,18 @@ - - - - - - - - + + + + + + + + - - - + + + @@ -52,14 +52,14 @@ AND ar.STATUS = #{status} - - = #{beginTime} ]]> + + = #{beginTime} ]]> - - + + - - and ar.WELL_CODE like concat('%',CONCAT(#{keywords},'%')) + + and ar.WELL_CODE like concat('%',CONCAT(#{keywords},'%')) AND ar.ALARM_TYPE = #{alarmType} @@ -74,19 +74,19 @@ - UPDATE alarm_job aj, alarm_records ar + UPDATE alarm_job aj, alarm_records ar aj.job_status = #{jobStatus} , aj.handle_job_person = #{personId}, @@ -140,4 +140,20 @@ WHERE ar.devcode = #{devcode} and ar.alarm_type = #{alarmType} + + SELECT ID + FROM alarm_records + WHERE DEVCODE = #{devcode} + AND ALARM_CONTENT = #{MsgContent} + AND STATUS='1' + + + + UPDATE alarm_records + SET STATUS='0' + WHERE DEVCODE = #{devcode} + AND ALARM_CONTENT = #{MsgContent} + AND STATUS='1' + + diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/model/AlarmJob.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/model/AlarmJob.java index 323fcab..69cf1cc 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/model/AlarmJob.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/model/AlarmJob.java @@ -146,25 +146,25 @@ @Override public String toString() { return "AlarmJob{" + - "id=" + id + - ", jobcode=" + jobcode + - ", jogType=" + jobType + - ", wellCode=" + wellCode + - ", devcode=" + devcode + - ", createTime=" + createTime + - ", jobStatus=" + jobStatus + - ", getJobPerson=" + getJobPerson + - ", getJobTime=" + getJobTime + - ", firstState=" + firstState + - ", firstStatePhotos=" + firstStatePhotos + - ", confirmJobPerson=" + confirmJobPerson + - ", confrimJobTime=" + confrimJobTime + - ", handleJobPerson=" + handleJobPerson + - ", handleJobTime=" + handleJobTime + - ", handleMessage=" + handleMessage + - ", handlePhotos=" + handlePhotos + - ", flow=" + flow + - ", recordId=" + recordId + - "}"; + "id=" + id + + ", jobcode=" + jobcode + + ", jogType=" + jobType + + ", wellCode=" + wellCode + + ", devcode=" + devcode + + ", createTime=" + createTime + + ", jobStatus=" + jobStatus + + ", getJobPerson=" + getJobPerson + + ", getJobTime=" + getJobTime + + ", firstState=" + firstState + + ", firstStatePhotos=" + firstStatePhotos + + ", confirmJobPerson=" + confirmJobPerson + + ", confrimJobTime=" + confrimJobTime + + ", handleJobPerson=" + handleJobPerson + + ", handleJobTime=" + handleJobTime + + ", handleMessage=" + handleMessage + + ", handlePhotos=" + handlePhotos + + ", flow=" + flow + + ", recordId=" + recordId + + "}"; } } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/util/DateUtil.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/util/DateUtil.java index 88ee7f0..c55acac 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/util/DateUtil.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/util/DateUtil.java @@ -45,4 +45,7 @@ return betweenTime; } + + + } diff --git a/casic-device/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataController.java b/casic-device/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataController.java index 561ec83..d73e6fa 100644 --- a/casic-device/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataController.java +++ b/casic-device/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataController.java @@ -161,8 +161,8 @@ deviceDto.put("gasFlowNum", "0"); deviceDto.put("uptime", sdf4.format(new Date())); } else { - deviceDto.put("gasFlowNum", flowRec.get("TOTAL_FLOW") == null ? "0" : flowRec.get("TOTAL_FLOW").toString()); - deviceDto.put("uptime", sdf4.format((Date) flowRec.get("UPTIME"))); + deviceDto.put("gasFlowNum", flowRec.get("totalFlow") == null ? "0" : flowRec.get("totalFlow").toString()); + deviceDto.put("uptime", sdf4.format((Date) flowRec.get("upTime"))); } deviceDto.put("fullAreaName", deviceService.getAreaFullNameById(deviceDto.get("AREA").toString()) + "/" + deviceDto.get("POSITION").toString()); diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java index 46bb487..d27afa9 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java @@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.plugins.Page; import com.casic.missiles.core.base.response.ResponseData; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.alarm.service.IAlarmJobService; import com.casic.missiles.core.common.service.ICommonPermissionService; import com.casic.missiles.core.datascope.DataScope; @@ -12,12 +13,14 @@ import com.casic.missiles.modular.system.warpper.AlarmJobWarpper; import com.casic.missiles.core.base.controller.BaseController; import com.casic.missiles.core.common.constant.factory.PageFactory; +import lombok.extern.slf4j.Slf4j; import org.hswebframework.expands.office.excel.ExcelIO; import org.json.JSONException; import org.json.JSONObject; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; @@ -29,6 +32,7 @@ import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.*; //import com.casic.missiles.core.base.response.ResponseData; @@ -40,6 +44,7 @@ * @Date 2019-05-17 10:48:36 */ @Controller +@Slf4j @RequestMapping("/job") public class AlarmJobController extends BaseController { @@ -65,6 +70,13 @@ private String templatePath; + /** + * 工单状态接口统计 + * + * @param httpServletRequest + * @return + * @throws ParseException + */ @RequestMapping(value = "/countByJobStatus") @ResponseBody public Object countByJobStatus(HttpServletRequest httpServletRequest) throws ParseException { @@ -117,7 +129,7 @@ } /** - * 获取分页列表 + * 获取工单分页列表 */ @RequestMapping(value = "/list") @ResponseBody @@ -164,30 +176,26 @@ */ @RequestMapping(value = "/searchList") @ResponseBody - public Object jobListSearch(String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime, String endTime, - String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, - String handleJobBeginTime, String handleJobEndTime, String shouldHandleBeginTime, String shouldHandleEndTime) { + public Object jobListSearch(@RequestBody JobListParam jobListParam) { Page> page = new PageFactory>().defaultPage("createTime", false); DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List> retList = new ArrayList<>(); if (alarmJobService.checkPcRole(currentUser.getRoleTips())) { // pc角色 - retList = alarmJobService.jobListSearch(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, - handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, dataScope, currentUser.getId()); + retList = alarmJobService.jobListSearch(page, jobListParam, dataScope, currentUser.getId()); } else { //app角色 long leaderId = 0L; if (currentUser.getRoleTips().contains(sLeader)) { // 组长,查组内全部 leaderId = currentUser.getId(); - if (ToolUtil.isNotEmpty(jobStatus)) { + if (ToolUtil.isNotEmpty(jobListParam.getJobStatus())) { //learder&&jobStatus=1,2,3时,关闭传入的sort,按sql排序(自己的排在前) - page.setOpenSort(!alarmJobService.checkJobStatus(jobStatus)); + page.setOpenSort(!alarmJobService.checkJobStatus(jobListParam.getJobStatus())); } } - retList = alarmJobService.jobListSearchApp(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, - handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, currentUser.getDeptId(), currentUser.getId(), leaderId); + retList = alarmJobService.jobListSearchApp(page, jobListParam, currentUser.getDeptId(), currentUser.getId(), leaderId); } new AlarmJobWarpper(retList).warp(); @@ -277,26 +285,24 @@ @RequestMapping(value = "/export") public void exportJob(HttpServletRequest httpServletRequest , HttpServletResponse httpServletResponse) throws IOException { - Page> page = new PageFactory>().defaultPage("createTime", false); page.setLimit(maxRowsExcel); page.setSize(maxRowsExcel); page.setSearchCount(false); page.setOffset(0); - String keywords = httpServletRequest.getParameter("keywords"); String beginTime = httpServletRequest.getParameter("beginTime"); String endTime = httpServletRequest.getParameter("endTime"); String jobStatusStr = httpServletRequest.getParameter("jobStatus"); String alarmTypeStr = httpServletRequest.getParameter("alarmType"); String alarmContentStr = httpServletRequest.getParameter("alarmContentType"); - - List> jobExpList = new ArrayList<>(); + log.debug("主题参数---------------" + keywords + "," + beginTime + "," + endTime + "," + jobStatusStr + "," + alarmTypeStr + "," + alarmContentStr); DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - jobExpList = alarmJobService.jobList(page, keywords, beginTime, endTime, jobStatusStr, alarmTypeStr, alarmContentStr, dataScope, currentUser.getId()); + List> jobExpList = alarmJobService.jobList(page, keywords, beginTime, endTime, jobStatusStr, alarmTypeStr, alarmContentStr, dataScope, currentUser.getId()); new AlarmJobWarpper(jobExpList).warp(); FileInputStream fileInputStream = null; + log.debug("----------------" + ToolUtil.isEmpty(jobExpList)); if (ToolUtil.isEmpty(jobExpList)) { fileInputStream = new FileInputStream(templatePath + "/jobRecEmpty.xlsx"); } else { @@ -305,12 +311,10 @@ try { httpServletResponse.setContentType("application/octet-stream"); httpServletResponse.addHeader("Content-Disposition", " attachment;filename=" + "jobOverview.xlsx"); - Map var = new HashMap<>(); var.put("标题", "工单一览表"); var.put("list", jobExpList); ExcelIO.writeTemplate(fileInputStream, httpServletResponse.getOutputStream(), var); - } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { @@ -328,11 +332,11 @@ */ @RequestMapping(value = "/getJob") @ResponseBody - public Object getJob(int id) { + public Object getJob(Long id) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - if (alarmJobService.getJob(id, currentUser.getId())){ + if (alarmJobService.getJob(id, currentUser.getId())) { return ResponseData.success(); } else { return ResponseData.error("接单失败"); @@ -344,10 +348,10 @@ */ @RequestMapping(value = "/confirmJob") @ResponseBody - public Object confirmJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "firstState", required = true) String firstState, - @RequestParam(value = "firstStatePhotos", required = true) String firstStatePhotos, - @RequestParam(value = "needHandle", required = true) String needHandle) { + public Object confirmJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "firstState", required = true) String firstState, + @RequestParam(value = "firstStatePhotos", required = true) String firstStatePhotos, + @RequestParam(value = "needHandle", required = true) String needHandle) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.confirmJob(id, currentUser.getId(), firstState, firstStatePhotos, needHandle)) { return ResponseData.success(); @@ -361,17 +365,19 @@ */ @RequestMapping(value = "/transferJob") @ResponseBody - public Object transferJob(@RequestParam(value = "id", required = true) int id, + public Object transferJob(@RequestParam(value = "id", required = true) Long id, @RequestParam(value = "transferPerson", required = true) String transferPerson) throws JSONException { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - String dbTime = iSysDictService.getDBtime(); +// String dbTime = iSysDictService.getDBtime(); + SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); +// String dbTime = iSysDictService.getDBtime(); + Date dbTime = new Date(); JSONObject jsonObject = new JSONObject(); jsonObject.put("from", currentUser.getName()); jsonObject.put("to", EhcacheConstant.retBean().getUsernameById(Long.valueOf(transferPerson))); - jsonObject.put("time", dbTime); - + jsonObject.put("time", dateFormat.format(dbTime)); if (alarmJobService.transferJob(id, Long.valueOf(transferPerson), jsonObject.toString())) { return ResponseData.success(); } else { @@ -384,9 +390,9 @@ */ @RequestMapping(value = "/saveJob") @ResponseBody - public Object saveJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "handleMessage", required = true) String handleMessage, - @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { + public Object saveJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "handleMessage", required = true) String handleMessage, + @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { if (alarmJobService.saveJob(id, handleMessage, handlePhotos)) { return ResponseData.success(); @@ -400,10 +406,9 @@ */ @RequestMapping(value = "/overJob") @ResponseBody - public Object overJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "handleMessage", required = true) String handleMessage, - @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { - + public Object overJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "handleMessage", required = true) String handleMessage, + @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.overJob(id, currentUser.getId(), handleMessage, handlePhotos)) { @@ -419,7 +424,7 @@ */ @RequestMapping(value = "/handleJob") @ResponseBody - public Object handleJob(@RequestParam(value = "id", required = true) int id) { + public Object handleJob(@RequestParam(value = "id", required = true) Long id) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.handleJob(id, currentUser.getId())) { return ResponseData.success(); @@ -433,12 +438,10 @@ */ @RequestMapping(value = "/info") @ResponseBody - public Object jobInfo(@RequestParam(value = "id", required = true) int id) { - + public Object jobInfo(@RequestParam(value = "id", required = true) long id) { DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List> retList = alarmJobService.jobInfo(id, dataScope, currentUser.getId()); - new AlarmJobWarpper(retList).warp(); return ResponseData.success(retList); } @@ -456,7 +459,7 @@ @RequestParam(value = "wellCode", required = true) String wellCode) { Map retMap = new HashMap<>(); try { - alarmJobService.updateSinkJob(id, URLDecoder.decode(msg, "UTF-8"),wellCode); + alarmJobService.updateSinkJob(id, URLDecoder.decode(msg, "UTF-8"), wellCode); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java index 26a2ba7..df59231 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java @@ -52,6 +52,7 @@ @Autowired private IDeviceService deviceService; + @Value("${smartcity.office.maxRowsExcel}") private int maxRowsExcel; @Value("${smartcity.config.config-path}") @@ -182,7 +183,8 @@ @RequestMapping(value = "/cancelAlarmById") @ResponseBody public Object cancelAlarmById(@RequestParam(value = "alarmId",required = true) long alarmId){ - boolean isCancel = alarmRecordsService.cancelAlarmById(alarmId); + ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); + boolean isCancel = alarmRecordsService.cancelAlarm(alarmId,"4","手动消警",currentUser.getId()); if(isCancel){ return ResponseData.success(); }else { @@ -235,10 +237,10 @@ //根据查询条件查询alarm_record记录 DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); + ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List alarmRecords = alarmRecordsService.alarmListNoPage(dataScope, keywords, alarmType, alarmContent, beginTime, endTime, areaId); - for (AlarmRecords alarmRecord : alarmRecords) { - alarmRecordsService.cancelAlarmById(alarmRecord.getId()); + alarmRecordsService.cancelAlarm(alarmRecord.getJobId(),"4","手动消警",currentUser.getId()); } return ResponseData.success(); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/model/JobListParam.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/model/JobListParam.java new file mode 100644 index 0000000..c83bff8 --- /dev/null +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/model/JobListParam.java @@ -0,0 +1,32 @@ +package com.casic.missiles.modular.alarm.model; + + +import lombok.Data; + +/** + * @author cz + * @date 2022-6-13 17:03 + */ +@Data +public class JobListParam { + /** + * 关键字 + */ + private String keywords; + /** + * 风险等级 + */ + private String alarmLevel; + private String alarmContent; + private String jobStatus; + private String beginTime; + private String endTime; + private String getJobBeginTime; + private String getJobEndTime; + private String shouldGetBeginTime; + private String shouldGetEndTime; + private String handleJobBeginTime; + private String handleJobEndTime; + private String shouldHandleBeginTime; + private String shouldHandleEndTime; +} diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java index d4db8ce..018d095 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java @@ -3,6 +3,7 @@ import com.baomidou.mybatisplus.plugins.Page; import com.baomidou.mybatisplus.service.IService; import com.casic.missiles.core.datascope.DataScope; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.system.dto.UserClientView; import com.casic.missiles.modular.system.model.AlarmJob; @@ -18,42 +19,60 @@ * @since 2019-05-17 */ public interface IAlarmJobService extends IService { - List> jobList( Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType,String alarmContent, DataScope dataScope,Long userId); - List> jobListApp( Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType,String alarmContent,Long deptId,Long userId,Long leaderId); + + List> jobList(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, DataScope dataScope, Long userId); + + List> jobListApp(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, Long deptId, Long userId, Long leaderId); // List jobListExport( Page page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType,String alarmContent, DataScope dataScope); - List> jobListDelayRe( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, DataScope dataScope,Long userId); - List> jobListDelayReApp( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, Long deptId,Long userId,Long leaderId); + List> jobListDelayRe(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId); - List> jobListDelayPro( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, DataScope dataScope,Long userId ); - List> jobListDelayProApp( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, Long deptId,Long userId,Long leaderId); + List> jobListDelayReApp(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, Long deptId, Long userId, Long leaderId); - List> jobListSearch(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime,String endTime, - String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, - String shouldHandleBeginTime, String shouldHandleEndTime, DataScope dataScope,Long userId); - List> jobListSearchApp(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime,String endTime, - String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, - String shouldHandleBeginTime, String shouldHandleEndTime, Long deptId, Long userId, Long leaderId); - List> jobInfo(int id, DataScope dataScope,Long personId); - boolean getJob(int id, long personId); - boolean confirmJob(int id,long personId,String firstState, String firstStatePhotos, String needHandle); - boolean transferJob(int id, long transferPerson,String flowRec); - boolean saveJob( int id,String handleMessage, String handlePhotos); - boolean overJob( int id,long personId, String handleMessage, String handlePhotos); - boolean overAlarm( int id); - boolean handleJob(int id,long personId); + List> jobListDelayPro(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId); - Map countByJobStatus(long deptId,int spanDays); - Map countMyJob(long userId,long deptId,int spanDays); + List> jobListDelayProApp(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, Long deptId, Long userId, Long leaderId); + + List> jobListSearch(Page> page, JobListParam jobListParam, DataScope dataScope, Long userId); + + List> jobListSearchApp(Page> page, JobListParam jobListParam, Long deptId, Long userId, Long leaderId); + + List> jobInfo(Long id, DataScope dataScope, Long personId); + + boolean getJob(Long id, long personId); + + boolean confirmJob(Long id, long personId, String firstState, String firstStatePhotos, String needHandle); + + boolean transferJob(Long id, long transferPerson, String flowRec); + + boolean saveJob(Long id, String handleMessage, String handlePhotos); + + boolean overJob(Long id, long personId, String handleMessage, String handlePhotos); + + boolean overAlarm(int id); + + boolean handleJob(Long id, long personId); + + Map countByJobStatus(long deptId, int spanDays); + + Map countMyJob(long userId, long deptId, int spanDays); boolean checkJobStatus(String jobStatus); + boolean checkPcRole(List roleTips); - Integer countByDataScope(DataScope dataScope,String alarmType, String jobStatus,String beginTime,String endTime); - Integer countByResponse(String alarmType,String jobStatus,Long deptId,String beginTime,String endTime); - Integer countByUser(String alarmType,String jobStatus,Long userId,String beginTime,String endTime); + Integer countByDataScope(DataScope dataScope, String alarmType, String jobStatus, String beginTime, String endTime); - void updateSinkJob(String id,String msg,String wellCode); + Integer countByResponse(String alarmType, String jobStatus, Long deptId, String beginTime, String endTime); + + Integer countByUser(String alarmType, String jobStatus, Long userId, String beginTime, String endTime); + + void updateSinkJob(String id, String msg, String wellCode); + List selectUserByWellCode(String wellCode); + String selectClientIdByUser(Long userId); + + AlarmJob saveData( String devCode, String wellCode, String devTypeName, String jobType); + } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java index 46e7dfe..6eecb2b 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.service.IService; import com.casic.missiles.modular.system.model.AlarmRecords; import com.casic.missiles.core.datascope.DataScope; +import org.apache.ibatis.annotations.Param; import java.util.List; import java.util.Map; @@ -26,4 +27,8 @@ boolean cancelAlarmById(long id); Integer insertAlarmRecord(AlarmRecords alarmRec); + + Boolean isOldAlarmRecord(String devCode,String MsgContent); + + Integer updateOldAlarmRecord(String devCode,String MsgContent); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java index fa6681d..943ebd7 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java @@ -7,12 +7,14 @@ import com.casic.missiles.core.common.service.ICommonUserService; import com.casic.missiles.modular.alarm.job.HandleAlarmJob; import com.casic.missiles.modular.alarm.job.getDelayJob; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.alarm.service.IAlarmJobService; import com.casic.missiles.core.datascope.DataScope; import com.casic.missiles.core.util.EhcacheConstant; import com.casic.missiles.core.util.ToolUtil; import com.casic.missiles.modular.system.dao.AlarmJobMapper; import com.casic.missiles.modular.system.dao.AlarmRecordsMapper; +import com.casic.missiles.modular.system.dto.DeviceTypeEnum; import com.casic.missiles.modular.system.dto.SelectDto; import com.casic.missiles.modular.system.dto.UserClientView; import com.casic.missiles.modular.system.model.AlarmJob; @@ -24,6 +26,8 @@ import com.casic.missiles.quartz.service.IQuartzManager; import com.gexin.rp.sdk.base.IPushResult; import com.google.gson.GsonBuilder; +import net.sf.ehcache.search.Query; +import net.sf.ehcache.search.expression.Criteria; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -48,6 +52,8 @@ public class AlarmJobServiceImpl extends ServiceImpl implements IAlarmJobService { private static final Logger logger = LoggerFactory.getLogger(AlarmJobServiceImpl.class); + public static final SimpleDateFormat sdf6 = new SimpleDateFormat("yyyyMMdd"); + private static Map deviceAlarmMap = new HashMap(); @Value("${smartcity.leaderRoleName}") private String sLeader; @@ -70,12 +76,14 @@ @Resource private IQuartzManager quartzManager; - @Autowired IBusWellInfoService busWellInfoService; + @Autowired + IBusWellInfoService busWellInfoService; @Override - public List> jobList(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, DataScope dataScope,Long userId) { + public List> jobList(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, DataScope dataScope, Long userId) { alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobList(page, keywords, beginTime, endTime, jobStatus, alarmType, alarmContent, dataScope,userId);return alarmJobList; + List> alarmJobList = this.baseMapper.jobList(page, keywords, beginTime, endTime, jobStatus, alarmType, alarmContent, dataScope, userId); + return alarmJobList; } @Override @@ -86,9 +94,9 @@ } @Override - public List> jobListDelayRe(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope,Long userId) { + public List> jobListDelayRe(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId) { alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListDelayRe(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope,userId); + List> alarmJobList = this.baseMapper.jobListDelayRe(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope, userId); return alarmJobList; } @@ -100,9 +108,9 @@ } @Override - public List> jobListDelayPro(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope,Long userId) { + public List> jobListDelayPro(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId) { alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListDelayPro(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope,userId); + List> alarmJobList = this.baseMapper.jobListDelayPro(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope, userId); return alarmJobList; } @@ -114,109 +122,115 @@ } @Override - public List> jobListSearch(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime, String endTime, String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, String shouldHandleBeginTime, String shouldHandleEndTime, DataScope dataScope,Long userId) { - alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListSearch(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, dataScope,userId); + public List> jobListSearch(Page> page, JobListParam jobListParam, DataScope dataScope, Long userId) { + jobListParam.setAlarmContent(converAlarmContent(jobListParam.getAlarmContent())); + List> alarmJobList = this.baseMapper.jobListSearch(page, jobListParam, dataScope, userId); return alarmJobList; } @Override - public List> jobListSearchApp(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime, String endTime, String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, String shouldHandleBeginTime, String shouldHandleEndTime, Long deptId, Long userId, Long leaderId) { - alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListSearchApp(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, deptId, userId, leaderId); + public List> jobListSearchApp(Page> page, JobListParam jobListParam, Long deptId, Long userId, Long leaderId) { + jobListParam.setAlarmContent(converAlarmContent(jobListParam.getAlarmContent())); + List> alarmJobList = this.baseMapper.jobListSearchApp(page, jobListParam.getKeywords(), + jobListParam.getAlarmLevel(), jobListParam.getAlarmContent(), jobListParam.getJobStatus(), jobListParam.getBeginTime(), + jobListParam.getEndTime(), jobListParam.getGetJobBeginTime(), jobListParam.getGetJobEndTime(), jobListParam.getShouldGetBeginTime(), + jobListParam.getShouldGetEndTime(), jobListParam.getHandleJobBeginTime(), jobListParam.getHandleJobEndTime(), jobListParam.getShouldHandleBeginTime(), + jobListParam.getShouldHandleEndTime(), deptId, userId, leaderId); return alarmJobList; } - private String converAlarmContent(String alarmContent){ - if(ToolUtil.isEmpty(alarmContent)){ + private String converAlarmContent(String alarmContent) { + if (ToolUtil.isEmpty(alarmContent)) { return alarmContent; - }else { + } else { return EhcacheConstant.retBean().getAlarmContentName(Integer.valueOf(alarmContent)); } } @Override - public List> jobInfo(int id, DataScope dataScope, Long personId) - { - List> job = this.baseMapper.jobInfo(id,dataScope,personId); + public List> jobInfo(Long id, DataScope dataScope, Long personId) { + List> job = this.baseMapper.jobInfo(id, dataScope, personId); return job; } @Override - public Map countByJobStatus(long deptId,int spanDays) { - return this.baseMapper.countByJobStatus(deptId,spanDays); + public Map countByJobStatus(long deptId, int spanDays) { + return this.baseMapper.countByJobStatus(deptId, spanDays); } @Override - public Map countMyJob(long userId,long deptId,int spanDays) { - return this.baseMapper.countMyJob(userId,deptId,spanDays); + public Map countMyJob(long userId, long deptId, int spanDays) { + return this.baseMapper.countMyJob(userId, deptId, spanDays); } @Override - public boolean getJob(int id, long personId) { + public boolean getJob(Long id, long personId) { Calendar now = Calendar.getInstance(); Date getTime = now.getTime(); - if(isWeekend(now)){ + if (isWeekend(now)) { now.add(Calendar.WEEK_OF_YEAR, 1); - now.set(Calendar.DAY_OF_WEEK ,Calendar.TUESDAY); - now.set(Calendar.HOUR_OF_DAY,8); - now.set(Calendar.MINUTE,0); - now.set(Calendar.SECOND,0); - }else { + now.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY); + now.set(Calendar.HOUR_OF_DAY, 8); + now.set(Calendar.MINUTE, 0); + now.set(Calendar.SECOND, 0); + } else { now.add(Calendar.HOUR, 24); - while(isWeekend(now)){ + while (isWeekend(now)) { now.add(Calendar.HOUR, 24); } } Date shouldHandleTime = now.getTime(); - if(Boolean.getBoolean(useOverTime)){ + if (Boolean.getBoolean(useOverTime)) { System.out.println(shouldHandleTime); String jobName = "getJobDelay" + id; - Map map = new HashMap<>(); - map.put("jobId",id); - map.put("iAlarmJobService",this); - map.put("iCommonUserService",iCommonUserService); - map.put("iQuartzManager",quartzManager); - map.put("webSocket",webSocket); - quartzManager.addJob(jobName,getDelayJob.class,shouldHandleTime,map); + Map map = new HashMap<>(); + map.put("jobId", id); + map.put("iAlarmJobService", this); + map.put("iCommonUserService", iCommonUserService); + map.put("iQuartzManager", quartzManager); + map.put("webSocket", webSocket); + quartzManager.addJob(jobName, getDelayJob.class, shouldHandleTime, map); } - return this.baseMapper.getJob(id,personId,getTime,shouldHandleTime); + return this.baseMapper.getJob(id, personId, getTime, shouldHandleTime); } - private boolean isWeekend(Calendar cal){ - if(cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY){ + private boolean isWeekend(Calendar cal) { + if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) { return true; - } else{ + } else { return false; } } @Override - public boolean confirmJob(int id,long personId, String firstState, String firstStatePhotos, String needHandle) { - if ("1".equals(needHandle)){ - return this.baseMapper.confirmJob(id,personId, firstState, firstStatePhotos, needHandle); + public boolean confirmJob(Long id, long personId, String firstState, String firstStatePhotos, String needHandle) { + if ("1".equals(needHandle)) { + return this.baseMapper.confirmJob(id, personId, firstState, firstStatePhotos, needHandle); } else { - return this.baseMapper.confirmOverJobAndAlarm(id, personId,firstState, firstStatePhotos); + return this.baseMapper.confirmOverJobAndAlarm(id, personId, firstState, firstStatePhotos); } } @Override - public boolean transferJob(int id, long transferPerson,String flowRec) { - return this.baseMapper.transferJob(id, transferPerson,flowRec); + public boolean transferJob(Long id, long transferPerson, String flowRec) { + return this.baseMapper.transferJob(id, transferPerson, flowRec); } @Override - public boolean saveJob(int id, String handleMessage, String handlePhotos) { + public boolean saveJob(Long id, String handleMessage, String handlePhotos) { return this.baseMapper.saveJob(id, handleMessage, handlePhotos); } @Override - public boolean overJob(int id,long personId, String handleMessage, String handlePhotos) { - return this.baseMapper.overJobAndAlarm(id, personId,handleMessage, handlePhotos); + public boolean overJob(Long id, long personId, String handleMessage, String handlePhotos) { + + return this.baseMapper.overJobAndAlarm(id, personId, handleMessage, handlePhotos); + // return this.baseMapper.overJob(id, personId,handleMessage, handlePhotos); } + @Override public boolean overAlarm(int jobId) { return this.baseMapper.overAlarm(jobId); @@ -224,15 +238,15 @@ } @Override - public boolean handleJob(int id,long personId) { - return this.baseMapper.handleJob(id,personId); + public boolean handleJob(Long id, long personId) { + return this.baseMapper.handleJob(id, personId); } @Override public boolean checkJobStatus(String jobStatus) { - if(ToolUtil.isEmpty(jobStatus)){ + if (ToolUtil.isEmpty(jobStatus)) { return false; - }else{ + } else { return "1".equals(jobStatus) || "2".equals(jobStatus) || "3".equals(jobStatus); } } @@ -243,10 +257,10 @@ } - public List selectRoles() { return this.baseMapper.selectRoles(); } + public List selectUseIds(List roleIds) { return this.baseMapper.selectUseIds(roleIds); } @@ -255,50 +269,50 @@ public boolean checkPcRole(List roleTips) { List roleList = new ArrayList<>(roleTips); Iterator it = roleList.iterator(); - while (it.hasNext()){ + while (it.hasNext()) { String role = it.next(); - if(role.equals(sApp)||role.equals(sLeader)||role.equals(sMember)){ + if (role.equals(sApp) || role.equals(sLeader) || role.equals(sMember)) { it.remove(); } } - return roleList.size()>0; + return roleList.size() > 0; } @Override - public Integer countByDataScope(DataScope dataScope, String alarmType, String jobStatus, String beginTime,String endTime) { - List> res = this.baseMapper.countByDataScope(dataScope,alarmType,jobStatus,beginTime,endTime); + public Integer countByDataScope(DataScope dataScope, String alarmType, String jobStatus, String beginTime, String endTime) { + List> res = this.baseMapper.countByDataScope(dataScope, alarmType, jobStatus, beginTime, endTime); return res.size(); } @Override - public Integer countByResponse(String alarmType, String jobStatus, Long deptId, String beginTime,String endTime) { - return this.baseMapper.countByResponse(alarmType,jobStatus,deptId,beginTime,endTime); + public Integer countByResponse(String alarmType, String jobStatus, Long deptId, String beginTime, String endTime) { + return this.baseMapper.countByResponse(alarmType, jobStatus, deptId, beginTime, endTime); } @Override - public Integer countByUser(String alarmType, String jobStatus, Long userId, String beginTime,String endTime) { - return this.baseMapper.countByUser(alarmType,jobStatus,userId,beginTime,endTime); + public Integer countByUser(String alarmType, String jobStatus, Long userId, String beginTime, String endTime) { + return this.baseMapper.countByUser(alarmType, jobStatus, userId, beginTime, endTime); } @Override - public void updateSinkJob(String id, String msg,String wellCode) { + public void updateSinkJob(String id, String msg, String wellCode) { List userClientViewList = new ArrayList<>(); List selectDtoList = selectRoles(); EntityWrapper busWellInfoEntityWrapper = new EntityWrapper<>(); - busWellInfoEntityWrapper.eq("WELL_CODE",wellCode); + busWellInfoEntityWrapper.eq("WELL_CODE", wellCode); BusWellInfo busWellInfo = busWellInfoService.selectOne(busWellInfoEntityWrapper); - if(busWellInfo!=null&&ToolUtil.isNotEmpty(busWellInfo.getDeptid())){ - List roleids= new ArrayList<>(); - for(SelectDto selectDto:selectDtoList){ - if(ToolUtil.isNotEmpty(selectDto.getName()) - && Arrays.asList(selectDto.getName().split(",")).contains(busWellInfo.getDeptid())){ + if (busWellInfo != null && ToolUtil.isNotEmpty(busWellInfo.getDeptid())) { + List roleids = new ArrayList<>(); + for (SelectDto selectDto : selectDtoList) { + if (ToolUtil.isNotEmpty(selectDto.getName()) + && Arrays.asList(selectDto.getName().split(",")).contains(busWellInfo.getDeptid())) { roleids.add(selectDto.getId()); } } - if(roleids.size()>0){ + if (roleids.size() > 0) { List useIds = selectUseIds(roleids); - for(Long useId:useIds){ + for (Long useId : useIds) { UserClientView userClientView = new UserClientView(); userClientView.setClientid(useId.toString()); userClientView.setId(useId.toString()); @@ -307,11 +321,11 @@ } } - if(!("null".equals(id))){ + if (!("null".equals(id))) { AlarmJob alarmJob = this.baseMapper.selectById(id); sendJob(id, alarmJob, userClientViewList);//推送工单至app和pc端 } - if(StringUtils.isNotBlank(msg)){ + if (StringUtils.isNotBlank(msg)) { sendAlarm(msg, userClientViewList);//推送告警至app和pc端 } @@ -386,7 +400,7 @@ } Date shouldHandleTime = now.getTime(); - if(Boolean.getBoolean(useOverTime)) { + if (Boolean.getBoolean(useOverTime)) { System.out.println(shouldHandleTime); String jobName = "getJobDelay" + id; Map map = new HashMap<>(); @@ -437,4 +451,40 @@ public String selectClientIdByUser(Long userId) { return this.baseMapper.selectClientIdByUser(userId); } + + + public AlarmJob saveData(String devCode, String wellCode, String devTypeName, String jobType) { + AlarmJob alarmJob = new AlarmJob(); + alarmJob.setDevcode(devCode); + alarmJob.setWellCode(wellCode); + alarmJob.setJobStatus("0"); + alarmJob.setCreateTime(new Date()); + alarmJob.setJobcode(this.produceJobCode(devTypeName)); + alarmJob.setJobType(jobType); + this.baseMapper.insert(alarmJob); + return alarmJob; + } + + /** + * 前缀+日期+4位流水号 + * + * @param devTypeName + * @return + */ + private String produceJobCode(String devTypeName) { + String pre = devTypeName; + String dataStr = sdf6.format(new Date()); + String fix = this.getJobCodeMaxSerial(pre + dataStr); + return StringUtils.isNotBlank(fix) ? pre + dataStr + String.format("%04d", Long.valueOf(fix) + 1L) : pre + dataStr + "0001"; + } + + + private String getJobCodeMaxSerial(String jobcode) { + String MaxSerialJobCode = this.baseMapper.getJobCodeMaxSerial(jobcode); + String fix = ""; + if (null != MaxSerialJobCode && MaxSerialJobCode.length() > 4) { + fix = MaxSerialJobCode.substring(MaxSerialJobCode.length() - 4); + } + return fix; + } } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmRecordsServiceImpl.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmRecordsServiceImpl.java index e0f0959..60fa41a 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmRecordsServiceImpl.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmRecordsServiceImpl.java @@ -16,7 +16,7 @@ /** *

- * 服务实现类 + * 服务实现类 *

* * @author casic123 @@ -27,12 +27,12 @@ @Override - public List> alarmList(Page> page, String keywords, String beginTime, String endTime, String status, String alarmType, String alarmContent, String areaId, DataScope dataScope) { + public List> alarmList(Page> page, String keywords, String beginTime, String endTime, String status, String alarmType, String alarmContent, String areaId, DataScope dataScope) { String sContent = null; - if (ToolUtil.isNotEmpty(alarmContent)){ + if (ToolUtil.isNotEmpty(alarmContent)) { sContent = EhcacheConstant.retBean().getAlarmContentName(Integer.valueOf(alarmContent)); } - return this.baseMapper.alarmList(page,keywords,beginTime,endTime,status,alarmType,sContent, areaId, dataScope); + return this.baseMapper.alarmList(page, keywords, beginTime, endTime, status, alarmType, sContent, areaId, dataScope); } /** @@ -41,15 +41,15 @@ @Override public List alarmListNoPage(DataScope dataScope, String keywords, String alarmType, String alarmContent, String beginTime, String endTime, String areaId) { String sContent = null; - if (ToolUtil.isNotEmpty(alarmContent)){ + if (ToolUtil.isNotEmpty(alarmContent)) { sContent = EhcacheConstant.retBean().getAlarmContentName(Integer.valueOf(alarmContent)); } - return this.baseMapper.alarmListNoPage(dataScope,keywords,alarmType,sContent,beginTime,endTime, areaId); + return this.baseMapper.alarmListNoPage(dataScope, keywords, alarmType, sContent, beginTime, endTime, areaId); } @Override public boolean cancelAlarm(long id, String jobStatus, String handleMessage, long personId) { - return this.baseMapper.cancelAlarm(id,jobStatus,handleMessage,personId); + return this.baseMapper.cancelAlarm(id, jobStatus, handleMessage, personId); } @Override @@ -62,4 +62,15 @@ // this.baseMapper.cancelAlarmByNewRecord(alarmRec.getDevcode(), alarmRec.getAlarmType()); return this.baseMapper.insert(alarmRec); } + + public Boolean isOldAlarmRecord(String devCode, String MsgContent) { + if (this.baseMapper.isOldAlarmRecord(devCode, MsgContent) == null) { + return false; + } + return true; + } + + public Integer updateOldAlarmRecord(String devCode, String MsgContent) { + return this.baseMapper.updateOldAlarmRecord(devCode, MsgContent); + } } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/AlarmMapOverviewController.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/AlarmMapOverviewController.java index 9d60185..214c275 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/AlarmMapOverviewController.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/AlarmMapOverviewController.java @@ -8,14 +8,12 @@ import com.casic.missiles.core.exception.GunsExceptionEnum; import com.casic.missiles.core.base.response.SuccessResponseData; import com.casic.missiles.core.util.ToolUtil; -import com.casic.missiles.modular.system.constant.ModularDictConst; import com.casic.missiles.modular.system.dto.AlarmNowView; import com.casic.missiles.modular.system.dto.DeviceDto; import com.casic.missiles.modular.system.model.BusWellInfo; import com.casic.missiles.modular.system.service.IAlarmNowViewService; import com.casic.missiles.modular.system.service.IBusWellInfoService; import com.casic.missiles.modular.system.service.IDeviceService; -import com.casic.missiles.modular.system.service.impl.BusWellInfoServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataReceiver.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataReceiver.java index 0013989..b3f23d5 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataReceiver.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataReceiver.java @@ -2,6 +2,7 @@ import com.casic.missiles.core.base.controller.BaseController; import com.casic.missiles.core.base.response.ResponseData; +import com.casic.missiles.modular.alarm.service.IAlarmJobService; import com.casic.missiles.modular.alarm.service.IAlarmRecordsService; import com.casic.missiles.modular.alarm.service.IAlarmRuleService; import com.casic.missiles.modular.system.dto.DeviceWellDto; @@ -9,6 +10,7 @@ import com.casic.missiles.modular.system.service.IDeviceService; import com.casic.missiles.modular.system.service.IGasFlowDataService; import lombok.extern.java.Log; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -38,6 +40,9 @@ @Resource private IAlarmRecordsService alarmRecordsService; + @Autowired + IAlarmJobService alarmJobService; + private DecimalFormat df2 = new DecimalFormat("0.00"); @RequestMapping(value = "/data/recv") @@ -117,6 +122,13 @@ alarmRecord.setAlarmTime(Calendar.getInstance().getTime()); alarmRecord.setStatus("1"); alarmRecord.setAlarmMessage("日用气量超阈值报警"); + if (alarmRecordsService.isOldAlarmRecord(gasFlowAddr, "日用气量超阈值报警")) { + alarmRecordsService.updateOldAlarmRecord(gasFlowAddr, "日用气量超阈值报警"); + } else { + AlarmJob alarmJob = alarmJobService.saveData(gasFlowAddr, wellDto.getWellCode(), "SLCX", "1"); + alarmRecord.setJobId(alarmJob.getId()); + } + alarmRecordsService.insertAlarmRecord(alarmRecord); // 向前端推送报警 } else { @@ -134,6 +146,13 @@ alarmRecord.setAlarmTime(Calendar.getInstance().getTime()); alarmRecord.setStatus("1"); alarmRecord.setAlarmMessage("日用气量超阈值预警"); + alarmRecord.setAlarmMessage("日用水量超阈值预警"); + if (alarmRecordsService.isOldAlarmRecord(gasFlowAddr, "日用水量超阈值预警")) { + alarmRecordsService.updateOldAlarmRecord(gasFlowAddr, "日用水量超阈值预警"); + } else { + AlarmJob alarmJob = alarmJobService.saveData(gasFlowAddr, wellDto.getWellCode(), "SLCX", "1"); + alarmRecord.setJobId(alarmJob.getId()); + } alarmRecordsService.insertAlarmRecord(alarmRecord); // 向前端推送报警 } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataReceiver.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataReceiver.java index 6c25e18..200f5d2 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataReceiver.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataReceiver.java @@ -2,16 +2,15 @@ import com.casic.missiles.core.base.controller.BaseController; import com.casic.missiles.core.base.response.ResponseData; +import com.casic.missiles.modular.alarm.service.IAlarmJobService; import com.casic.missiles.modular.alarm.service.IAlarmRecordsService; import com.casic.missiles.modular.alarm.service.IAlarmRuleService; import com.casic.missiles.modular.system.dto.DeviceWellDto; -import com.casic.missiles.modular.system.model.AlarmRecords; -import com.casic.missiles.modular.system.model.AlarmRule; -import com.casic.missiles.modular.system.model.DataWaterMeter; -import com.casic.missiles.modular.system.model.Device; +import com.casic.missiles.modular.system.model.*; import com.casic.missiles.modular.system.service.IDeviceService; import com.casic.missiles.modular.system.service.IWaterMeterDataService; import lombok.extern.java.Log; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -40,6 +39,9 @@ @Resource private IAlarmRecordsService alarmRecordsService; + @Autowired + IAlarmJobService alarmJobService; + private DecimalFormat df2 = new DecimalFormat("0.00"); @RequestMapping(value = "/data/recv") @@ -106,7 +108,6 @@ if (flowAccToday - alarmRule.getHighvalue() > 0) { // 超出报警阈值 生成一条报警消息 AlarmRecords alarmRecord = new AlarmRecords(); - alarmRecord.setDeviceId(device.getId()); alarmRecord.setDevcode(meterAddr); alarmRecord.setWellCode(wellDto.getWellCode()); @@ -116,17 +117,19 @@ alarmRecord.setAlarmTime(Calendar.getInstance().getTime()); alarmRecord.setStatus("1"); alarmRecord.setAlarmMessage("日用水量超阈值报警"); - + if (alarmRecordsService.isOldAlarmRecord(meterAddr, "日用水量超阈值报警")) { + alarmRecordsService.updateOldAlarmRecord(meterAddr, "日用水量超阈值报警"); + } else { + AlarmJob alarmJob = alarmJobService.saveData(meterAddr, wellDto.getWellCode(), "QLCX", "1"); + alarmRecord.setJobId(alarmJob.getId()); + } alarmRecordsService.insertAlarmRecord(alarmRecord); - - // 向前端推送报警 } else { // 如果没有报警则判断是否预警 if (null != alarmRuleWarn && null != alarmRuleWarn.getHighvalue()) { if (flowAccToday - alarmRuleWarn.getHighvalue() > 0) { // 超出预警阈值 生成一条预警消息 AlarmRecords alarmRecord = new AlarmRecords(); - alarmRecord.setDeviceId(device.getId()); alarmRecord.setDevcode(meterAddr); alarmRecord.setWellCode(wellDto.getWellCode()); @@ -136,10 +139,13 @@ alarmRecord.setAlarmTime(Calendar.getInstance().getTime()); alarmRecord.setStatus("1"); alarmRecord.setAlarmMessage("日用水量超阈值预警"); - + if (alarmRecordsService.isOldAlarmRecord(meterAddr, "日用水量超阈值预警")) { + alarmRecordsService.updateOldAlarmRecord(meterAddr, "日用水量超阈值预警"); + } else { + AlarmJob alarmJob = alarmJobService.saveData(meterAddr, wellDto.getWellCode(), "QLCX", "1"); + alarmRecord.setJobId(alarmJob.getId()); + } alarmRecordsService.insertAlarmRecord(alarmRecord); - - // 向前端推送报警 } } } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmJobMapper.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmJobMapper.java index 6592517..ccdff9a 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmJobMapper.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmJobMapper.java @@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.mapper.BaseMapper; import com.baomidou.mybatisplus.plugins.Page; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.system.dto.SelectDto; import com.casic.missiles.modular.system.dto.UserClientView; import com.casic.missiles.modular.system.model.AlarmJob; @@ -21,44 +22,65 @@ * @since 2019-05-17 */ public interface AlarmJobMapper extends BaseMapper { - List> jobList(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("jobStatus") String jobStatus, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("dataScope") DataScope dataScope,@Param("userId")Long userId); - List> jobListApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("jobStatus") String jobStatus, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("deptId")Long deptId,@Param("userId")Long userId,@Param("leaderId")Long leaderId); + List> jobList(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("jobStatus") String jobStatus, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("dataScope") DataScope dataScope, @Param("userId") Long userId); + + List> jobListApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("jobStatus") String jobStatus, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("deptId") Long deptId, @Param("userId") Long userId, @Param("leaderId") Long leaderId); + // List jobListExport(@Param("page") Page page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("jobStatus") String jobStatus, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("dataScope") DataScope dataScope); - List> jobListDelayRe(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("dataScope") DataScope dataScope,@Param("userId")Long userId); - List> jobListDelayReApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("deptId")Long deptId,@Param("userId")Long userId,@Param("leaderId")Long leaderId); + List> jobListDelayRe(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("dataScope") DataScope dataScope, @Param("userId") Long userId); - List> jobListDelayPro(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("dataScope") DataScope dataScope,@Param("userId")Long userId); - List> jobListDelayProApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("deptId")Long deptId,@Param("userId")Long userId,@Param("leaderId")Long leaderId); + List> jobListDelayReApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("deptId") Long deptId, @Param("userId") Long userId, @Param("leaderId") Long leaderId); - List> jobListSearchApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("alarmLevel")String alarmLevel, @Param("alarmContent") String alarmContent, @Param("jobStatus") String jobStatus, @Param("beginTime") String beginTime, @Param("endTime") String endTime, - @Param("getJobBeginTime") String getJobBeginTime, @Param("getJobEndTime") String getJobEndTime, @Param("shouldGetBeginTime") String shouldGetBeginTime, @Param("shouldGetEndTime") String shouldGetEndTime, - @Param("handleJobBeginTime") String handleJobBeginTime, @Param("handleJobEndTime") String handleJobEndTime, @Param("shouldHandleBeginTime") String shouldHandleBeginTime, @Param("shouldHandleEndTime") String shouldHandleEndTime, - @Param("deptId")Long deptId, @Param("userId")Long userId, @Param("leaderId")Long leaderId); - List> jobListSearch(@Param("page") Page> page, @Param("keywords") String keywords, @Param("alarmLevel")String alarmLevel, @Param("alarmContent") String alarmContent, @Param("jobStatus") String jobStatus, @Param("beginTime") String beginTime, @Param("endTime") String endTime, - @Param("getJobBeginTime") String getJobBeginTime, @Param("getJobEndTime") String getJobEndTime, @Param("shouldGetBeginTime") String shouldGetBeginTime, @Param("shouldGetEndTime") String shouldGetEndTime, - @Param("handleJobBeginTime") String handleJobBeginTime, @Param("handleJobEndTime") String handleJobEndTime, @Param("shouldHandleBeginTime") String shouldHandleBeginTime, @Param("shouldHandleEndTime") String shouldHandleEndTime, - @Param("dataScope") DataScope dataScope,@Param("userId")Long userId); + List> jobListDelayPro(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("dataScope") DataScope dataScope, @Param("userId") Long userId); - Map countByJobStatus(@Param("deptId")long deptId,@Param("spanDays") int spanDays); - Map countMyJob(@Param("userId")long userId,@Param("deptId")long deptId,@Param("spanDays") int spanDays); - List> jobInfo(@Param("id") int id,@Param("dataScope") DataScope dataScope,@Param("personId") Long personId); -// boolean getJob(@Param("id") int id,@Param("personId") long personId); - boolean getJob(@Param("id") int id,@Param("personId") long personId,@Param("getTime")Date getTime ,@Param("shouldHandleTime")Date shouldHandleTime); - boolean confirmJob(@Param("id") int id,@Param("personId") long personId,@Param("firstState") String firstState,@Param("firstStatePhotos") String firstStatePhotos,@Param("needHandle") String needHandle); - boolean confirmOverJobAndAlarm(@Param("id") int id,@Param("personId") long personId,@Param("firstState") String firstState,@Param("firstStatePhotos") String firstStatePhotos); - boolean transferJob(@Param("id") int id,@Param("transferPerson") long transferPerson,@Param("flowRec") String flowRec); - boolean saveJob(@Param("id") int id,@Param("handleMessage") String handleMessage,@Param("handlePhotos") String handlePhotos); - boolean overJob(@Param("id") int id,@Param("personId") long personId,@Param("handleMessage") String handleMessage,@Param("handlePhotos") String handlePhotos); + List> jobListDelayProApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("deptId") Long deptId, @Param("userId") Long userId, @Param("leaderId") Long leaderId); + + List> jobListSearchApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("alarmLevel") String alarmLevel, @Param("alarmContent") String alarmContent, @Param("jobStatus") String jobStatus, @Param("beginTime") String beginTime, @Param("endTime") String endTime, + @Param("getJobBeginTime") String getJobBeginTime, @Param("getJobEndTime") String getJobEndTime, @Param("shouldGetBeginTime") String shouldGetBeginTime, @Param("shouldGetEndTime") String shouldGetEndTime, + @Param("handleJobBeginTime") String handleJobBeginTime, @Param("handleJobEndTime") String handleJobEndTime, @Param("shouldHandleBeginTime") String shouldHandleBeginTime, @Param("shouldHandleEndTime") String shouldHandleEndTime, + @Param("deptId") Long deptId, @Param("userId") Long userId, @Param("leaderId") Long leaderId); + + List> jobListSearch(@Param("page") Page> page, @Param("jobListParam") JobListParam jobListParam, + @Param("dataScope") DataScope dataScope, @Param("userId") Long userId); + + Map countByJobStatus(@Param("deptId") long deptId, @Param("spanDays") int spanDays); + + Map countMyJob(@Param("userId") long userId, @Param("deptId") long deptId, @Param("spanDays") int spanDays); + + List> jobInfo(@Param("id") Long id, @Param("dataScope") DataScope dataScope, @Param("personId") Long personId); + + // boolean getJob(@Param("id") int id,@Param("personId") long personId); + boolean getJob(@Param("id") Long id, @Param("personId") long personId, @Param("getTime") Date getTime, @Param("shouldHandleTime") Date shouldHandleTime); + + boolean confirmJob(@Param("id") Long id, @Param("personId") long personId, @Param("firstState") String firstState, @Param("firstStatePhotos") String firstStatePhotos, @Param("needHandle") String needHandle); + + boolean confirmOverJobAndAlarm(@Param("id") Long id, @Param("personId") long personId, @Param("firstState") String firstState, @Param("firstStatePhotos") String firstStatePhotos); + + boolean transferJob(@Param("id") Long id, @Param("transferPerson") long transferPerson, @Param("flowRec") String flowRec); + + boolean saveJob(@Param("id") Long id, @Param("handleMessage") String handleMessage, @Param("handlePhotos") String handlePhotos); + + boolean overJob(@Param("id") int id, @Param("personId") long personId, @Param("handleMessage") String handleMessage, @Param("handlePhotos") String handlePhotos); + boolean overAlarm(@Param("jobId") int id); - boolean overJobAndAlarm(@Param("id") int id,@Param("personId") long personId,@Param("handleMessage") String handleMessage,@Param("handlePhotos") String handlePhotos); - boolean handleJob(@Param("id") int id,@Param("personId") long personId); - List> countByDataScope(@Param("dataScope") DataScope dataScope,@Param("alarmType")String alarmType,@Param("jobStatus")String jobStatus,@Param("beginTime")String beginTime,@Param("endTime")String endTime); - Integer countByResponse(@Param("alarmType")String alarmType,@Param("jobStatus")String jobStatus,@Param("deptId") Long deptId,@Param("beginTime")String beginTime,@Param("endTime")String endTime); - Integer countByUser(@Param("alarmType")String alarmType,@Param("jobStatus")String jobStatus,@Param("userId") Long userId,@Param("beginTime")String beginTime,@Param("endTime")String endTime); + boolean overJobAndAlarm(@Param("id") Long id, @Param("personId") long personId, @Param("handleMessage") String handleMessage, @Param("handlePhotos") String handlePhotos); + + boolean handleJob(@Param("id") Long id, @Param("personId") long personId); + + List> countByDataScope(@Param("dataScope") DataScope dataScope, @Param("alarmType") String alarmType, @Param("jobStatus") String jobStatus, @Param("beginTime") String beginTime, @Param("endTime") String endTime); + + Integer countByResponse(@Param("alarmType") String alarmType, @Param("jobStatus") String jobStatus, @Param("deptId") Long deptId, @Param("beginTime") String beginTime, @Param("endTime") String endTime); + + Integer countByUser(@Param("alarmType") String alarmType, @Param("jobStatus") String jobStatus, @Param("userId") Long userId, @Param("beginTime") String beginTime, @Param("endTime") String endTime); String selectClientIdByUser(@Param("userId") Long userId); + List selectUserByWellCode(@Param("wellCode") String wellCode); + List selectUseIds(@Param("roleIds") List roleIds); + List selectRoles(); + + String getJobCodeMaxSerial(@Param("jobcode") String jobcode); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmRecordsMapper.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmRecordsMapper.java index 87a71ff..d4c6a8b 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmRecordsMapper.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmRecordsMapper.java @@ -11,7 +11,7 @@ /** *

- * Mapper 接口 + * Mapper 接口 *

* * @author casic123 @@ -19,13 +19,18 @@ */ public interface AlarmRecordsMapper extends BaseMapper { - List> alarmList(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("status") String status, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("areaId") String areaId, @Param("dataScope") DataScope dataScope); + List> alarmList(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("status") String status, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("areaId") String areaId, @Param("dataScope") DataScope dataScope); List alarmListNoPage(@Param("scope") DataScope dataScope, @Param("keywords") String keywords, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("areaId") String areaId); - boolean cancelAlarm(@Param("id") long id, @Param("jobStatus")String jobStatus,@Param("handleMessage") String handleMessage,@Param("personId") long personId); + boolean cancelAlarm(@Param("id") long id, @Param("jobStatus") String jobStatus, @Param("handleMessage") String handleMessage, @Param("personId") long personId); boolean cancelAlarmById(@Param("id") long id); boolean cancelAlarmByNewRecord(@Param("devcode") String devcode, @Param("alarmType") String alarmType); + + String isOldAlarmRecord(@Param("devcode") String devcode, @Param("MsgContent") String MsgContent); + + Integer updateOldAlarmRecord(@Param("devcode") String devcode, @Param("MsgContent") String MsgContent); + } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmJobMapper.xml b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmJobMapper.xml index cd850b4..5aeef97 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmJobMapper.xml +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmJobMapper.xml @@ -65,6 +65,7 @@ GROUP BY aj.id ) c + + + + + + + + + + diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmRecordsMapper.xml b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmRecordsMapper.xml index f2b5457..6929f44 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmRecordsMapper.xml +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmRecordsMapper.xml @@ -4,18 +4,18 @@ - - - - - - - - + + + + + + + + - - - + + + @@ -52,14 +52,14 @@ AND ar.STATUS = #{status} - - = #{beginTime} ]]> + + = #{beginTime} ]]> - - + + - - and ar.WELL_CODE like concat('%',CONCAT(#{keywords},'%')) + + and ar.WELL_CODE like concat('%',CONCAT(#{keywords},'%')) AND ar.ALARM_TYPE = #{alarmType} @@ -74,19 +74,19 @@ - UPDATE alarm_job aj, alarm_records ar + UPDATE alarm_job aj, alarm_records ar aj.job_status = #{jobStatus} , aj.handle_job_person = #{personId}, @@ -140,4 +140,20 @@ WHERE ar.devcode = #{devcode} and ar.alarm_type = #{alarmType} + + SELECT ID + FROM alarm_records + WHERE DEVCODE = #{devcode} + AND ALARM_CONTENT = #{MsgContent} + AND STATUS='1' + + + + UPDATE alarm_records + SET STATUS='0' + WHERE DEVCODE = #{devcode} + AND ALARM_CONTENT = #{MsgContent} + AND STATUS='1' + + diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/model/AlarmJob.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/model/AlarmJob.java index 323fcab..69cf1cc 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/model/AlarmJob.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/model/AlarmJob.java @@ -146,25 +146,25 @@ @Override public String toString() { return "AlarmJob{" + - "id=" + id + - ", jobcode=" + jobcode + - ", jogType=" + jobType + - ", wellCode=" + wellCode + - ", devcode=" + devcode + - ", createTime=" + createTime + - ", jobStatus=" + jobStatus + - ", getJobPerson=" + getJobPerson + - ", getJobTime=" + getJobTime + - ", firstState=" + firstState + - ", firstStatePhotos=" + firstStatePhotos + - ", confirmJobPerson=" + confirmJobPerson + - ", confrimJobTime=" + confrimJobTime + - ", handleJobPerson=" + handleJobPerson + - ", handleJobTime=" + handleJobTime + - ", handleMessage=" + handleMessage + - ", handlePhotos=" + handlePhotos + - ", flow=" + flow + - ", recordId=" + recordId + - "}"; + "id=" + id + + ", jobcode=" + jobcode + + ", jogType=" + jobType + + ", wellCode=" + wellCode + + ", devcode=" + devcode + + ", createTime=" + createTime + + ", jobStatus=" + jobStatus + + ", getJobPerson=" + getJobPerson + + ", getJobTime=" + getJobTime + + ", firstState=" + firstState + + ", firstStatePhotos=" + firstStatePhotos + + ", confirmJobPerson=" + confirmJobPerson + + ", confrimJobTime=" + confrimJobTime + + ", handleJobPerson=" + handleJobPerson + + ", handleJobTime=" + handleJobTime + + ", handleMessage=" + handleMessage + + ", handlePhotos=" + handlePhotos + + ", flow=" + flow + + ", recordId=" + recordId + + "}"; } } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/util/DateUtil.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/util/DateUtil.java index 88ee7f0..c55acac 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/util/DateUtil.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/util/DateUtil.java @@ -45,4 +45,7 @@ return betweenTime; } + + + } diff --git a/casic-device/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataController.java b/casic-device/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataController.java index 561ec83..d73e6fa 100644 --- a/casic-device/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataController.java +++ b/casic-device/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataController.java @@ -161,8 +161,8 @@ deviceDto.put("gasFlowNum", "0"); deviceDto.put("uptime", sdf4.format(new Date())); } else { - deviceDto.put("gasFlowNum", flowRec.get("TOTAL_FLOW") == null ? "0" : flowRec.get("TOTAL_FLOW").toString()); - deviceDto.put("uptime", sdf4.format((Date) flowRec.get("UPTIME"))); + deviceDto.put("gasFlowNum", flowRec.get("totalFlow") == null ? "0" : flowRec.get("totalFlow").toString()); + deviceDto.put("uptime", sdf4.format((Date) flowRec.get("upTime"))); } deviceDto.put("fullAreaName", deviceService.getAreaFullNameById(deviceDto.get("AREA").toString()) + "/" + deviceDto.get("POSITION").toString()); diff --git a/casic-device/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataController.java b/casic-device/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataController.java index 5cf736c..a6f01a9 100644 --- a/casic-device/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataController.java +++ b/casic-device/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataController.java @@ -22,10 +22,7 @@ import java.io.IOException; import java.text.DateFormat; import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; /** * @author a203 @@ -38,7 +35,7 @@ private final IDeviceService deviceService; @Value("${smartcity.office.maxRowsExcel}") - private int maxRowsExcel; + private int maxRowsExcel; @Value("${smartcity.config.config-path}") private String templatePath; @@ -88,9 +85,11 @@ Map meterRec = deviceService.selectLatestWaterMeter(deviceDto.getDevcode()); if (meterRec == null) { deviceDto.setWatchNum("0"); + deviceDto.setPressure(new Random().nextInt(4)); deviceDto.setUptime(sdf4.format(new Date())); } else { deviceDto.setWatchNum(meterRec.get("FLOW_ACC") == null ? "0" : meterRec.get("FLOW_ACC").toString()); + deviceDto.setPressure(meterRec.get("PRESSURE") == null ? 0 : Integer.valueOf(meterRec.get("PRESSURE").toString())); deviceDto.setUptime(sdf4.format((Date) meterRec.get("UPTIME"))); } @@ -156,16 +155,16 @@ FileInputStream fileInputStream = null; if (ToolUtil.isEmpty(list)) { - fileInputStream = new FileInputStream(templatePath+"/waterMeterListEmpty.xlsx"); + fileInputStream = new FileInputStream(templatePath + "/waterMeterListEmpty.xlsx"); } else { - fileInputStream = new FileInputStream(templatePath+"/waterMeterListTemplate.xlsx"); + fileInputStream = new FileInputStream(templatePath + "/waterMeterListTemplate.xlsx"); } try { httpServletResponse.setContentType("application/octet-stream"); - httpServletResponse.addHeader("Content-Disposition", " attachment;filename="+"waterMeterList.xlsx" ); + httpServletResponse.addHeader("Content-Disposition", " attachment;filename=" + "waterMeterList.xlsx"); - Map var = new HashMap<>(); + Map var = new HashMap<>(); var.put("标题", "设备数据列表"); var.put("list", list); ExcelIO.writeTemplate(fileInputStream, httpServletResponse.getOutputStream(), var); diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java index 46bb487..d27afa9 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmJobController.java @@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.plugins.Page; import com.casic.missiles.core.base.response.ResponseData; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.alarm.service.IAlarmJobService; import com.casic.missiles.core.common.service.ICommonPermissionService; import com.casic.missiles.core.datascope.DataScope; @@ -12,12 +13,14 @@ import com.casic.missiles.modular.system.warpper.AlarmJobWarpper; import com.casic.missiles.core.base.controller.BaseController; import com.casic.missiles.core.common.constant.factory.PageFactory; +import lombok.extern.slf4j.Slf4j; import org.hswebframework.expands.office.excel.ExcelIO; import org.json.JSONException; import org.json.JSONObject; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; @@ -29,6 +32,7 @@ import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.*; //import com.casic.missiles.core.base.response.ResponseData; @@ -40,6 +44,7 @@ * @Date 2019-05-17 10:48:36 */ @Controller +@Slf4j @RequestMapping("/job") public class AlarmJobController extends BaseController { @@ -65,6 +70,13 @@ private String templatePath; + /** + * 工单状态接口统计 + * + * @param httpServletRequest + * @return + * @throws ParseException + */ @RequestMapping(value = "/countByJobStatus") @ResponseBody public Object countByJobStatus(HttpServletRequest httpServletRequest) throws ParseException { @@ -117,7 +129,7 @@ } /** - * 获取分页列表 + * 获取工单分页列表 */ @RequestMapping(value = "/list") @ResponseBody @@ -164,30 +176,26 @@ */ @RequestMapping(value = "/searchList") @ResponseBody - public Object jobListSearch(String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime, String endTime, - String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, - String handleJobBeginTime, String handleJobEndTime, String shouldHandleBeginTime, String shouldHandleEndTime) { + public Object jobListSearch(@RequestBody JobListParam jobListParam) { Page> page = new PageFactory>().defaultPage("createTime", false); DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List> retList = new ArrayList<>(); if (alarmJobService.checkPcRole(currentUser.getRoleTips())) { // pc角色 - retList = alarmJobService.jobListSearch(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, - handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, dataScope, currentUser.getId()); + retList = alarmJobService.jobListSearch(page, jobListParam, dataScope, currentUser.getId()); } else { //app角色 long leaderId = 0L; if (currentUser.getRoleTips().contains(sLeader)) { // 组长,查组内全部 leaderId = currentUser.getId(); - if (ToolUtil.isNotEmpty(jobStatus)) { + if (ToolUtil.isNotEmpty(jobListParam.getJobStatus())) { //learder&&jobStatus=1,2,3时,关闭传入的sort,按sql排序(自己的排在前) - page.setOpenSort(!alarmJobService.checkJobStatus(jobStatus)); + page.setOpenSort(!alarmJobService.checkJobStatus(jobListParam.getJobStatus())); } } - retList = alarmJobService.jobListSearchApp(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, - handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, currentUser.getDeptId(), currentUser.getId(), leaderId); + retList = alarmJobService.jobListSearchApp(page, jobListParam, currentUser.getDeptId(), currentUser.getId(), leaderId); } new AlarmJobWarpper(retList).warp(); @@ -277,26 +285,24 @@ @RequestMapping(value = "/export") public void exportJob(HttpServletRequest httpServletRequest , HttpServletResponse httpServletResponse) throws IOException { - Page> page = new PageFactory>().defaultPage("createTime", false); page.setLimit(maxRowsExcel); page.setSize(maxRowsExcel); page.setSearchCount(false); page.setOffset(0); - String keywords = httpServletRequest.getParameter("keywords"); String beginTime = httpServletRequest.getParameter("beginTime"); String endTime = httpServletRequest.getParameter("endTime"); String jobStatusStr = httpServletRequest.getParameter("jobStatus"); String alarmTypeStr = httpServletRequest.getParameter("alarmType"); String alarmContentStr = httpServletRequest.getParameter("alarmContentType"); - - List> jobExpList = new ArrayList<>(); + log.debug("主题参数---------------" + keywords + "," + beginTime + "," + endTime + "," + jobStatusStr + "," + alarmTypeStr + "," + alarmContentStr); DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - jobExpList = alarmJobService.jobList(page, keywords, beginTime, endTime, jobStatusStr, alarmTypeStr, alarmContentStr, dataScope, currentUser.getId()); + List> jobExpList = alarmJobService.jobList(page, keywords, beginTime, endTime, jobStatusStr, alarmTypeStr, alarmContentStr, dataScope, currentUser.getId()); new AlarmJobWarpper(jobExpList).warp(); FileInputStream fileInputStream = null; + log.debug("----------------" + ToolUtil.isEmpty(jobExpList)); if (ToolUtil.isEmpty(jobExpList)) { fileInputStream = new FileInputStream(templatePath + "/jobRecEmpty.xlsx"); } else { @@ -305,12 +311,10 @@ try { httpServletResponse.setContentType("application/octet-stream"); httpServletResponse.addHeader("Content-Disposition", " attachment;filename=" + "jobOverview.xlsx"); - Map var = new HashMap<>(); var.put("标题", "工单一览表"); var.put("list", jobExpList); ExcelIO.writeTemplate(fileInputStream, httpServletResponse.getOutputStream(), var); - } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { @@ -328,11 +332,11 @@ */ @RequestMapping(value = "/getJob") @ResponseBody - public Object getJob(int id) { + public Object getJob(Long id) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - if (alarmJobService.getJob(id, currentUser.getId())){ + if (alarmJobService.getJob(id, currentUser.getId())) { return ResponseData.success(); } else { return ResponseData.error("接单失败"); @@ -344,10 +348,10 @@ */ @RequestMapping(value = "/confirmJob") @ResponseBody - public Object confirmJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "firstState", required = true) String firstState, - @RequestParam(value = "firstStatePhotos", required = true) String firstStatePhotos, - @RequestParam(value = "needHandle", required = true) String needHandle) { + public Object confirmJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "firstState", required = true) String firstState, + @RequestParam(value = "firstStatePhotos", required = true) String firstStatePhotos, + @RequestParam(value = "needHandle", required = true) String needHandle) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.confirmJob(id, currentUser.getId(), firstState, firstStatePhotos, needHandle)) { return ResponseData.success(); @@ -361,17 +365,19 @@ */ @RequestMapping(value = "/transferJob") @ResponseBody - public Object transferJob(@RequestParam(value = "id", required = true) int id, + public Object transferJob(@RequestParam(value = "id", required = true) Long id, @RequestParam(value = "transferPerson", required = true) String transferPerson) throws JSONException { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); - String dbTime = iSysDictService.getDBtime(); +// String dbTime = iSysDictService.getDBtime(); + SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); +// String dbTime = iSysDictService.getDBtime(); + Date dbTime = new Date(); JSONObject jsonObject = new JSONObject(); jsonObject.put("from", currentUser.getName()); jsonObject.put("to", EhcacheConstant.retBean().getUsernameById(Long.valueOf(transferPerson))); - jsonObject.put("time", dbTime); - + jsonObject.put("time", dateFormat.format(dbTime)); if (alarmJobService.transferJob(id, Long.valueOf(transferPerson), jsonObject.toString())) { return ResponseData.success(); } else { @@ -384,9 +390,9 @@ */ @RequestMapping(value = "/saveJob") @ResponseBody - public Object saveJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "handleMessage", required = true) String handleMessage, - @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { + public Object saveJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "handleMessage", required = true) String handleMessage, + @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { if (alarmJobService.saveJob(id, handleMessage, handlePhotos)) { return ResponseData.success(); @@ -400,10 +406,9 @@ */ @RequestMapping(value = "/overJob") @ResponseBody - public Object overJob(@RequestParam(value = "id", required = true) int id, - @RequestParam(value = "handleMessage", required = true) String handleMessage, - @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { - + public Object overJob(@RequestParam(value = "id", required = true) Long id, + @RequestParam(value = "handleMessage", required = true) String handleMessage, + @RequestParam(value = "handlePhotos", required = true) String handlePhotos) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.overJob(id, currentUser.getId(), handleMessage, handlePhotos)) { @@ -419,7 +424,7 @@ */ @RequestMapping(value = "/handleJob") @ResponseBody - public Object handleJob(@RequestParam(value = "id", required = true) int id) { + public Object handleJob(@RequestParam(value = "id", required = true) Long id) { ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); if (alarmJobService.handleJob(id, currentUser.getId())) { return ResponseData.success(); @@ -433,12 +438,10 @@ */ @RequestMapping(value = "/info") @ResponseBody - public Object jobInfo(@RequestParam(value = "id", required = true) int id) { - + public Object jobInfo(@RequestParam(value = "id", required = true) long id) { DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List> retList = alarmJobService.jobInfo(id, dataScope, currentUser.getId()); - new AlarmJobWarpper(retList).warp(); return ResponseData.success(retList); } @@ -456,7 +459,7 @@ @RequestParam(value = "wellCode", required = true) String wellCode) { Map retMap = new HashMap<>(); try { - alarmJobService.updateSinkJob(id, URLDecoder.decode(msg, "UTF-8"),wellCode); + alarmJobService.updateSinkJob(id, URLDecoder.decode(msg, "UTF-8"), wellCode); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java index 26a2ba7..df59231 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/controller/AlarmRecordsController.java @@ -52,6 +52,7 @@ @Autowired private IDeviceService deviceService; + @Value("${smartcity.office.maxRowsExcel}") private int maxRowsExcel; @Value("${smartcity.config.config-path}") @@ -182,7 +183,8 @@ @RequestMapping(value = "/cancelAlarmById") @ResponseBody public Object cancelAlarmById(@RequestParam(value = "alarmId",required = true) long alarmId){ - boolean isCancel = alarmRecordsService.cancelAlarmById(alarmId); + ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); + boolean isCancel = alarmRecordsService.cancelAlarm(alarmId,"4","手动消警",currentUser.getId()); if(isCancel){ return ResponseData.success(); }else { @@ -235,10 +237,10 @@ //根据查询条件查询alarm_record记录 DataScope dataScope = iCommonPermissionService.getCurrUserDataScope(); + ShiroUser currentUser = iCommonPermissionService.getCurrLoginUser(); List alarmRecords = alarmRecordsService.alarmListNoPage(dataScope, keywords, alarmType, alarmContent, beginTime, endTime, areaId); - for (AlarmRecords alarmRecord : alarmRecords) { - alarmRecordsService.cancelAlarmById(alarmRecord.getId()); + alarmRecordsService.cancelAlarm(alarmRecord.getJobId(),"4","手动消警",currentUser.getId()); } return ResponseData.success(); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/model/JobListParam.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/model/JobListParam.java new file mode 100644 index 0000000..c83bff8 --- /dev/null +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/model/JobListParam.java @@ -0,0 +1,32 @@ +package com.casic.missiles.modular.alarm.model; + + +import lombok.Data; + +/** + * @author cz + * @date 2022-6-13 17:03 + */ +@Data +public class JobListParam { + /** + * 关键字 + */ + private String keywords; + /** + * 风险等级 + */ + private String alarmLevel; + private String alarmContent; + private String jobStatus; + private String beginTime; + private String endTime; + private String getJobBeginTime; + private String getJobEndTime; + private String shouldGetBeginTime; + private String shouldGetEndTime; + private String handleJobBeginTime; + private String handleJobEndTime; + private String shouldHandleBeginTime; + private String shouldHandleEndTime; +} diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java index d4db8ce..018d095 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmJobService.java @@ -3,6 +3,7 @@ import com.baomidou.mybatisplus.plugins.Page; import com.baomidou.mybatisplus.service.IService; import com.casic.missiles.core.datascope.DataScope; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.system.dto.UserClientView; import com.casic.missiles.modular.system.model.AlarmJob; @@ -18,42 +19,60 @@ * @since 2019-05-17 */ public interface IAlarmJobService extends IService { - List> jobList( Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType,String alarmContent, DataScope dataScope,Long userId); - List> jobListApp( Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType,String alarmContent,Long deptId,Long userId,Long leaderId); + + List> jobList(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, DataScope dataScope, Long userId); + + List> jobListApp(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, Long deptId, Long userId, Long leaderId); // List jobListExport( Page page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType,String alarmContent, DataScope dataScope); - List> jobListDelayRe( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, DataScope dataScope,Long userId); - List> jobListDelayReApp( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, Long deptId,Long userId,Long leaderId); + List> jobListDelayRe(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId); - List> jobListDelayPro( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, DataScope dataScope,Long userId ); - List> jobListDelayProApp( Page> page, String keywords, String beginTime, String endTime, String alarmType,String alarmContent, Long deptId,Long userId,Long leaderId); + List> jobListDelayReApp(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, Long deptId, Long userId, Long leaderId); - List> jobListSearch(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime,String endTime, - String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, - String shouldHandleBeginTime, String shouldHandleEndTime, DataScope dataScope,Long userId); - List> jobListSearchApp(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime,String endTime, - String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, - String shouldHandleBeginTime, String shouldHandleEndTime, Long deptId, Long userId, Long leaderId); - List> jobInfo(int id, DataScope dataScope,Long personId); - boolean getJob(int id, long personId); - boolean confirmJob(int id,long personId,String firstState, String firstStatePhotos, String needHandle); - boolean transferJob(int id, long transferPerson,String flowRec); - boolean saveJob( int id,String handleMessage, String handlePhotos); - boolean overJob( int id,long personId, String handleMessage, String handlePhotos); - boolean overAlarm( int id); - boolean handleJob(int id,long personId); + List> jobListDelayPro(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId); - Map countByJobStatus(long deptId,int spanDays); - Map countMyJob(long userId,long deptId,int spanDays); + List> jobListDelayProApp(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, Long deptId, Long userId, Long leaderId); + + List> jobListSearch(Page> page, JobListParam jobListParam, DataScope dataScope, Long userId); + + List> jobListSearchApp(Page> page, JobListParam jobListParam, Long deptId, Long userId, Long leaderId); + + List> jobInfo(Long id, DataScope dataScope, Long personId); + + boolean getJob(Long id, long personId); + + boolean confirmJob(Long id, long personId, String firstState, String firstStatePhotos, String needHandle); + + boolean transferJob(Long id, long transferPerson, String flowRec); + + boolean saveJob(Long id, String handleMessage, String handlePhotos); + + boolean overJob(Long id, long personId, String handleMessage, String handlePhotos); + + boolean overAlarm(int id); + + boolean handleJob(Long id, long personId); + + Map countByJobStatus(long deptId, int spanDays); + + Map countMyJob(long userId, long deptId, int spanDays); boolean checkJobStatus(String jobStatus); + boolean checkPcRole(List roleTips); - Integer countByDataScope(DataScope dataScope,String alarmType, String jobStatus,String beginTime,String endTime); - Integer countByResponse(String alarmType,String jobStatus,Long deptId,String beginTime,String endTime); - Integer countByUser(String alarmType,String jobStatus,Long userId,String beginTime,String endTime); + Integer countByDataScope(DataScope dataScope, String alarmType, String jobStatus, String beginTime, String endTime); - void updateSinkJob(String id,String msg,String wellCode); + Integer countByResponse(String alarmType, String jobStatus, Long deptId, String beginTime, String endTime); + + Integer countByUser(String alarmType, String jobStatus, Long userId, String beginTime, String endTime); + + void updateSinkJob(String id, String msg, String wellCode); + List selectUserByWellCode(String wellCode); + String selectClientIdByUser(Long userId); + + AlarmJob saveData( String devCode, String wellCode, String devTypeName, String jobType); + } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java index 46e7dfe..6eecb2b 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/IAlarmRecordsService.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.service.IService; import com.casic.missiles.modular.system.model.AlarmRecords; import com.casic.missiles.core.datascope.DataScope; +import org.apache.ibatis.annotations.Param; import java.util.List; import java.util.Map; @@ -26,4 +27,8 @@ boolean cancelAlarmById(long id); Integer insertAlarmRecord(AlarmRecords alarmRec); + + Boolean isOldAlarmRecord(String devCode,String MsgContent); + + Integer updateOldAlarmRecord(String devCode,String MsgContent); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java index fa6681d..943ebd7 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmJobServiceImpl.java @@ -7,12 +7,14 @@ import com.casic.missiles.core.common.service.ICommonUserService; import com.casic.missiles.modular.alarm.job.HandleAlarmJob; import com.casic.missiles.modular.alarm.job.getDelayJob; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.alarm.service.IAlarmJobService; import com.casic.missiles.core.datascope.DataScope; import com.casic.missiles.core.util.EhcacheConstant; import com.casic.missiles.core.util.ToolUtil; import com.casic.missiles.modular.system.dao.AlarmJobMapper; import com.casic.missiles.modular.system.dao.AlarmRecordsMapper; +import com.casic.missiles.modular.system.dto.DeviceTypeEnum; import com.casic.missiles.modular.system.dto.SelectDto; import com.casic.missiles.modular.system.dto.UserClientView; import com.casic.missiles.modular.system.model.AlarmJob; @@ -24,6 +26,8 @@ import com.casic.missiles.quartz.service.IQuartzManager; import com.gexin.rp.sdk.base.IPushResult; import com.google.gson.GsonBuilder; +import net.sf.ehcache.search.Query; +import net.sf.ehcache.search.expression.Criteria; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -48,6 +52,8 @@ public class AlarmJobServiceImpl extends ServiceImpl implements IAlarmJobService { private static final Logger logger = LoggerFactory.getLogger(AlarmJobServiceImpl.class); + public static final SimpleDateFormat sdf6 = new SimpleDateFormat("yyyyMMdd"); + private static Map deviceAlarmMap = new HashMap(); @Value("${smartcity.leaderRoleName}") private String sLeader; @@ -70,12 +76,14 @@ @Resource private IQuartzManager quartzManager; - @Autowired IBusWellInfoService busWellInfoService; + @Autowired + IBusWellInfoService busWellInfoService; @Override - public List> jobList(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, DataScope dataScope,Long userId) { + public List> jobList(Page> page, String keywords, String beginTime, String endTime, String jobStatus, String alarmType, String alarmContent, DataScope dataScope, Long userId) { alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobList(page, keywords, beginTime, endTime, jobStatus, alarmType, alarmContent, dataScope,userId);return alarmJobList; + List> alarmJobList = this.baseMapper.jobList(page, keywords, beginTime, endTime, jobStatus, alarmType, alarmContent, dataScope, userId); + return alarmJobList; } @Override @@ -86,9 +94,9 @@ } @Override - public List> jobListDelayRe(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope,Long userId) { + public List> jobListDelayRe(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId) { alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListDelayRe(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope,userId); + List> alarmJobList = this.baseMapper.jobListDelayRe(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope, userId); return alarmJobList; } @@ -100,9 +108,9 @@ } @Override - public List> jobListDelayPro(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope,Long userId) { + public List> jobListDelayPro(Page> page, String keywords, String beginTime, String endTime, String alarmType, String alarmContent, DataScope dataScope, Long userId) { alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListDelayPro(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope,userId); + List> alarmJobList = this.baseMapper.jobListDelayPro(page, keywords, beginTime, endTime, alarmType, alarmContent, dataScope, userId); return alarmJobList; } @@ -114,109 +122,115 @@ } @Override - public List> jobListSearch(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime, String endTime, String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, String shouldHandleBeginTime, String shouldHandleEndTime, DataScope dataScope,Long userId) { - alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListSearch(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, dataScope,userId); + public List> jobListSearch(Page> page, JobListParam jobListParam, DataScope dataScope, Long userId) { + jobListParam.setAlarmContent(converAlarmContent(jobListParam.getAlarmContent())); + List> alarmJobList = this.baseMapper.jobListSearch(page, jobListParam, dataScope, userId); return alarmJobList; } @Override - public List> jobListSearchApp(Page> page, String keywords, String alarmLevel, String alarmContent, String jobStatus, String beginTime, String endTime, String getJobBeginTime, String getJobEndTime, String shouldGetBeginTime, String shouldGetEndTime, String handleJobBeginTime, String handleJobEndTime, String shouldHandleBeginTime, String shouldHandleEndTime, Long deptId, Long userId, Long leaderId) { - alarmContent = converAlarmContent(alarmContent); - List> alarmJobList = this.baseMapper.jobListSearchApp(page, keywords, alarmLevel, alarmContent, jobStatus, beginTime, endTime, getJobBeginTime, getJobEndTime, shouldGetBeginTime, shouldGetEndTime, handleJobBeginTime, handleJobEndTime, shouldHandleBeginTime, shouldHandleEndTime, deptId, userId, leaderId); + public List> jobListSearchApp(Page> page, JobListParam jobListParam, Long deptId, Long userId, Long leaderId) { + jobListParam.setAlarmContent(converAlarmContent(jobListParam.getAlarmContent())); + List> alarmJobList = this.baseMapper.jobListSearchApp(page, jobListParam.getKeywords(), + jobListParam.getAlarmLevel(), jobListParam.getAlarmContent(), jobListParam.getJobStatus(), jobListParam.getBeginTime(), + jobListParam.getEndTime(), jobListParam.getGetJobBeginTime(), jobListParam.getGetJobEndTime(), jobListParam.getShouldGetBeginTime(), + jobListParam.getShouldGetEndTime(), jobListParam.getHandleJobBeginTime(), jobListParam.getHandleJobEndTime(), jobListParam.getShouldHandleBeginTime(), + jobListParam.getShouldHandleEndTime(), deptId, userId, leaderId); return alarmJobList; } - private String converAlarmContent(String alarmContent){ - if(ToolUtil.isEmpty(alarmContent)){ + private String converAlarmContent(String alarmContent) { + if (ToolUtil.isEmpty(alarmContent)) { return alarmContent; - }else { + } else { return EhcacheConstant.retBean().getAlarmContentName(Integer.valueOf(alarmContent)); } } @Override - public List> jobInfo(int id, DataScope dataScope, Long personId) - { - List> job = this.baseMapper.jobInfo(id,dataScope,personId); + public List> jobInfo(Long id, DataScope dataScope, Long personId) { + List> job = this.baseMapper.jobInfo(id, dataScope, personId); return job; } @Override - public Map countByJobStatus(long deptId,int spanDays) { - return this.baseMapper.countByJobStatus(deptId,spanDays); + public Map countByJobStatus(long deptId, int spanDays) { + return this.baseMapper.countByJobStatus(deptId, spanDays); } @Override - public Map countMyJob(long userId,long deptId,int spanDays) { - return this.baseMapper.countMyJob(userId,deptId,spanDays); + public Map countMyJob(long userId, long deptId, int spanDays) { + return this.baseMapper.countMyJob(userId, deptId, spanDays); } @Override - public boolean getJob(int id, long personId) { + public boolean getJob(Long id, long personId) { Calendar now = Calendar.getInstance(); Date getTime = now.getTime(); - if(isWeekend(now)){ + if (isWeekend(now)) { now.add(Calendar.WEEK_OF_YEAR, 1); - now.set(Calendar.DAY_OF_WEEK ,Calendar.TUESDAY); - now.set(Calendar.HOUR_OF_DAY,8); - now.set(Calendar.MINUTE,0); - now.set(Calendar.SECOND,0); - }else { + now.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY); + now.set(Calendar.HOUR_OF_DAY, 8); + now.set(Calendar.MINUTE, 0); + now.set(Calendar.SECOND, 0); + } else { now.add(Calendar.HOUR, 24); - while(isWeekend(now)){ + while (isWeekend(now)) { now.add(Calendar.HOUR, 24); } } Date shouldHandleTime = now.getTime(); - if(Boolean.getBoolean(useOverTime)){ + if (Boolean.getBoolean(useOverTime)) { System.out.println(shouldHandleTime); String jobName = "getJobDelay" + id; - Map map = new HashMap<>(); - map.put("jobId",id); - map.put("iAlarmJobService",this); - map.put("iCommonUserService",iCommonUserService); - map.put("iQuartzManager",quartzManager); - map.put("webSocket",webSocket); - quartzManager.addJob(jobName,getDelayJob.class,shouldHandleTime,map); + Map map = new HashMap<>(); + map.put("jobId", id); + map.put("iAlarmJobService", this); + map.put("iCommonUserService", iCommonUserService); + map.put("iQuartzManager", quartzManager); + map.put("webSocket", webSocket); + quartzManager.addJob(jobName, getDelayJob.class, shouldHandleTime, map); } - return this.baseMapper.getJob(id,personId,getTime,shouldHandleTime); + return this.baseMapper.getJob(id, personId, getTime, shouldHandleTime); } - private boolean isWeekend(Calendar cal){ - if(cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY){ + private boolean isWeekend(Calendar cal) { + if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) { return true; - } else{ + } else { return false; } } @Override - public boolean confirmJob(int id,long personId, String firstState, String firstStatePhotos, String needHandle) { - if ("1".equals(needHandle)){ - return this.baseMapper.confirmJob(id,personId, firstState, firstStatePhotos, needHandle); + public boolean confirmJob(Long id, long personId, String firstState, String firstStatePhotos, String needHandle) { + if ("1".equals(needHandle)) { + return this.baseMapper.confirmJob(id, personId, firstState, firstStatePhotos, needHandle); } else { - return this.baseMapper.confirmOverJobAndAlarm(id, personId,firstState, firstStatePhotos); + return this.baseMapper.confirmOverJobAndAlarm(id, personId, firstState, firstStatePhotos); } } @Override - public boolean transferJob(int id, long transferPerson,String flowRec) { - return this.baseMapper.transferJob(id, transferPerson,flowRec); + public boolean transferJob(Long id, long transferPerson, String flowRec) { + return this.baseMapper.transferJob(id, transferPerson, flowRec); } @Override - public boolean saveJob(int id, String handleMessage, String handlePhotos) { + public boolean saveJob(Long id, String handleMessage, String handlePhotos) { return this.baseMapper.saveJob(id, handleMessage, handlePhotos); } @Override - public boolean overJob(int id,long personId, String handleMessage, String handlePhotos) { - return this.baseMapper.overJobAndAlarm(id, personId,handleMessage, handlePhotos); + public boolean overJob(Long id, long personId, String handleMessage, String handlePhotos) { + + return this.baseMapper.overJobAndAlarm(id, personId, handleMessage, handlePhotos); + // return this.baseMapper.overJob(id, personId,handleMessage, handlePhotos); } + @Override public boolean overAlarm(int jobId) { return this.baseMapper.overAlarm(jobId); @@ -224,15 +238,15 @@ } @Override - public boolean handleJob(int id,long personId) { - return this.baseMapper.handleJob(id,personId); + public boolean handleJob(Long id, long personId) { + return this.baseMapper.handleJob(id, personId); } @Override public boolean checkJobStatus(String jobStatus) { - if(ToolUtil.isEmpty(jobStatus)){ + if (ToolUtil.isEmpty(jobStatus)) { return false; - }else{ + } else { return "1".equals(jobStatus) || "2".equals(jobStatus) || "3".equals(jobStatus); } } @@ -243,10 +257,10 @@ } - public List selectRoles() { return this.baseMapper.selectRoles(); } + public List selectUseIds(List roleIds) { return this.baseMapper.selectUseIds(roleIds); } @@ -255,50 +269,50 @@ public boolean checkPcRole(List roleTips) { List roleList = new ArrayList<>(roleTips); Iterator it = roleList.iterator(); - while (it.hasNext()){ + while (it.hasNext()) { String role = it.next(); - if(role.equals(sApp)||role.equals(sLeader)||role.equals(sMember)){ + if (role.equals(sApp) || role.equals(sLeader) || role.equals(sMember)) { it.remove(); } } - return roleList.size()>0; + return roleList.size() > 0; } @Override - public Integer countByDataScope(DataScope dataScope, String alarmType, String jobStatus, String beginTime,String endTime) { - List> res = this.baseMapper.countByDataScope(dataScope,alarmType,jobStatus,beginTime,endTime); + public Integer countByDataScope(DataScope dataScope, String alarmType, String jobStatus, String beginTime, String endTime) { + List> res = this.baseMapper.countByDataScope(dataScope, alarmType, jobStatus, beginTime, endTime); return res.size(); } @Override - public Integer countByResponse(String alarmType, String jobStatus, Long deptId, String beginTime,String endTime) { - return this.baseMapper.countByResponse(alarmType,jobStatus,deptId,beginTime,endTime); + public Integer countByResponse(String alarmType, String jobStatus, Long deptId, String beginTime, String endTime) { + return this.baseMapper.countByResponse(alarmType, jobStatus, deptId, beginTime, endTime); } @Override - public Integer countByUser(String alarmType, String jobStatus, Long userId, String beginTime,String endTime) { - return this.baseMapper.countByUser(alarmType,jobStatus,userId,beginTime,endTime); + public Integer countByUser(String alarmType, String jobStatus, Long userId, String beginTime, String endTime) { + return this.baseMapper.countByUser(alarmType, jobStatus, userId, beginTime, endTime); } @Override - public void updateSinkJob(String id, String msg,String wellCode) { + public void updateSinkJob(String id, String msg, String wellCode) { List userClientViewList = new ArrayList<>(); List selectDtoList = selectRoles(); EntityWrapper busWellInfoEntityWrapper = new EntityWrapper<>(); - busWellInfoEntityWrapper.eq("WELL_CODE",wellCode); + busWellInfoEntityWrapper.eq("WELL_CODE", wellCode); BusWellInfo busWellInfo = busWellInfoService.selectOne(busWellInfoEntityWrapper); - if(busWellInfo!=null&&ToolUtil.isNotEmpty(busWellInfo.getDeptid())){ - List roleids= new ArrayList<>(); - for(SelectDto selectDto:selectDtoList){ - if(ToolUtil.isNotEmpty(selectDto.getName()) - && Arrays.asList(selectDto.getName().split(",")).contains(busWellInfo.getDeptid())){ + if (busWellInfo != null && ToolUtil.isNotEmpty(busWellInfo.getDeptid())) { + List roleids = new ArrayList<>(); + for (SelectDto selectDto : selectDtoList) { + if (ToolUtil.isNotEmpty(selectDto.getName()) + && Arrays.asList(selectDto.getName().split(",")).contains(busWellInfo.getDeptid())) { roleids.add(selectDto.getId()); } } - if(roleids.size()>0){ + if (roleids.size() > 0) { List useIds = selectUseIds(roleids); - for(Long useId:useIds){ + for (Long useId : useIds) { UserClientView userClientView = new UserClientView(); userClientView.setClientid(useId.toString()); userClientView.setId(useId.toString()); @@ -307,11 +321,11 @@ } } - if(!("null".equals(id))){ + if (!("null".equals(id))) { AlarmJob alarmJob = this.baseMapper.selectById(id); sendJob(id, alarmJob, userClientViewList);//推送工单至app和pc端 } - if(StringUtils.isNotBlank(msg)){ + if (StringUtils.isNotBlank(msg)) { sendAlarm(msg, userClientViewList);//推送告警至app和pc端 } @@ -386,7 +400,7 @@ } Date shouldHandleTime = now.getTime(); - if(Boolean.getBoolean(useOverTime)) { + if (Boolean.getBoolean(useOverTime)) { System.out.println(shouldHandleTime); String jobName = "getJobDelay" + id; Map map = new HashMap<>(); @@ -437,4 +451,40 @@ public String selectClientIdByUser(Long userId) { return this.baseMapper.selectClientIdByUser(userId); } + + + public AlarmJob saveData(String devCode, String wellCode, String devTypeName, String jobType) { + AlarmJob alarmJob = new AlarmJob(); + alarmJob.setDevcode(devCode); + alarmJob.setWellCode(wellCode); + alarmJob.setJobStatus("0"); + alarmJob.setCreateTime(new Date()); + alarmJob.setJobcode(this.produceJobCode(devTypeName)); + alarmJob.setJobType(jobType); + this.baseMapper.insert(alarmJob); + return alarmJob; + } + + /** + * 前缀+日期+4位流水号 + * + * @param devTypeName + * @return + */ + private String produceJobCode(String devTypeName) { + String pre = devTypeName; + String dataStr = sdf6.format(new Date()); + String fix = this.getJobCodeMaxSerial(pre + dataStr); + return StringUtils.isNotBlank(fix) ? pre + dataStr + String.format("%04d", Long.valueOf(fix) + 1L) : pre + dataStr + "0001"; + } + + + private String getJobCodeMaxSerial(String jobcode) { + String MaxSerialJobCode = this.baseMapper.getJobCodeMaxSerial(jobcode); + String fix = ""; + if (null != MaxSerialJobCode && MaxSerialJobCode.length() > 4) { + fix = MaxSerialJobCode.substring(MaxSerialJobCode.length() - 4); + } + return fix; + } } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmRecordsServiceImpl.java b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmRecordsServiceImpl.java index e0f0959..60fa41a 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmRecordsServiceImpl.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/alarm/service/impl/AlarmRecordsServiceImpl.java @@ -16,7 +16,7 @@ /** *

- * 服务实现类 + * 服务实现类 *

* * @author casic123 @@ -27,12 +27,12 @@ @Override - public List> alarmList(Page> page, String keywords, String beginTime, String endTime, String status, String alarmType, String alarmContent, String areaId, DataScope dataScope) { + public List> alarmList(Page> page, String keywords, String beginTime, String endTime, String status, String alarmType, String alarmContent, String areaId, DataScope dataScope) { String sContent = null; - if (ToolUtil.isNotEmpty(alarmContent)){ + if (ToolUtil.isNotEmpty(alarmContent)) { sContent = EhcacheConstant.retBean().getAlarmContentName(Integer.valueOf(alarmContent)); } - return this.baseMapper.alarmList(page,keywords,beginTime,endTime,status,alarmType,sContent, areaId, dataScope); + return this.baseMapper.alarmList(page, keywords, beginTime, endTime, status, alarmType, sContent, areaId, dataScope); } /** @@ -41,15 +41,15 @@ @Override public List alarmListNoPage(DataScope dataScope, String keywords, String alarmType, String alarmContent, String beginTime, String endTime, String areaId) { String sContent = null; - if (ToolUtil.isNotEmpty(alarmContent)){ + if (ToolUtil.isNotEmpty(alarmContent)) { sContent = EhcacheConstant.retBean().getAlarmContentName(Integer.valueOf(alarmContent)); } - return this.baseMapper.alarmListNoPage(dataScope,keywords,alarmType,sContent,beginTime,endTime, areaId); + return this.baseMapper.alarmListNoPage(dataScope, keywords, alarmType, sContent, beginTime, endTime, areaId); } @Override public boolean cancelAlarm(long id, String jobStatus, String handleMessage, long personId) { - return this.baseMapper.cancelAlarm(id,jobStatus,handleMessage,personId); + return this.baseMapper.cancelAlarm(id, jobStatus, handleMessage, personId); } @Override @@ -62,4 +62,15 @@ // this.baseMapper.cancelAlarmByNewRecord(alarmRec.getDevcode(), alarmRec.getAlarmType()); return this.baseMapper.insert(alarmRec); } + + public Boolean isOldAlarmRecord(String devCode, String MsgContent) { + if (this.baseMapper.isOldAlarmRecord(devCode, MsgContent) == null) { + return false; + } + return true; + } + + public Integer updateOldAlarmRecord(String devCode, String MsgContent) { + return this.baseMapper.updateOldAlarmRecord(devCode, MsgContent); + } } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/AlarmMapOverviewController.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/AlarmMapOverviewController.java index 9d60185..214c275 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/AlarmMapOverviewController.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/AlarmMapOverviewController.java @@ -8,14 +8,12 @@ import com.casic.missiles.core.exception.GunsExceptionEnum; import com.casic.missiles.core.base.response.SuccessResponseData; import com.casic.missiles.core.util.ToolUtil; -import com.casic.missiles.modular.system.constant.ModularDictConst; import com.casic.missiles.modular.system.dto.AlarmNowView; import com.casic.missiles.modular.system.dto.DeviceDto; import com.casic.missiles.modular.system.model.BusWellInfo; import com.casic.missiles.modular.system.service.IAlarmNowViewService; import com.casic.missiles.modular.system.service.IBusWellInfoService; import com.casic.missiles.modular.system.service.IDeviceService; -import com.casic.missiles.modular.system.service.impl.BusWellInfoServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataReceiver.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataReceiver.java index 0013989..b3f23d5 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataReceiver.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataReceiver.java @@ -2,6 +2,7 @@ import com.casic.missiles.core.base.controller.BaseController; import com.casic.missiles.core.base.response.ResponseData; +import com.casic.missiles.modular.alarm.service.IAlarmJobService; import com.casic.missiles.modular.alarm.service.IAlarmRecordsService; import com.casic.missiles.modular.alarm.service.IAlarmRuleService; import com.casic.missiles.modular.system.dto.DeviceWellDto; @@ -9,6 +10,7 @@ import com.casic.missiles.modular.system.service.IDeviceService; import com.casic.missiles.modular.system.service.IGasFlowDataService; import lombok.extern.java.Log; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -38,6 +40,9 @@ @Resource private IAlarmRecordsService alarmRecordsService; + @Autowired + IAlarmJobService alarmJobService; + private DecimalFormat df2 = new DecimalFormat("0.00"); @RequestMapping(value = "/data/recv") @@ -117,6 +122,13 @@ alarmRecord.setAlarmTime(Calendar.getInstance().getTime()); alarmRecord.setStatus("1"); alarmRecord.setAlarmMessage("日用气量超阈值报警"); + if (alarmRecordsService.isOldAlarmRecord(gasFlowAddr, "日用气量超阈值报警")) { + alarmRecordsService.updateOldAlarmRecord(gasFlowAddr, "日用气量超阈值报警"); + } else { + AlarmJob alarmJob = alarmJobService.saveData(gasFlowAddr, wellDto.getWellCode(), "SLCX", "1"); + alarmRecord.setJobId(alarmJob.getId()); + } + alarmRecordsService.insertAlarmRecord(alarmRecord); // 向前端推送报警 } else { @@ -134,6 +146,13 @@ alarmRecord.setAlarmTime(Calendar.getInstance().getTime()); alarmRecord.setStatus("1"); alarmRecord.setAlarmMessage("日用气量超阈值预警"); + alarmRecord.setAlarmMessage("日用水量超阈值预警"); + if (alarmRecordsService.isOldAlarmRecord(gasFlowAddr, "日用水量超阈值预警")) { + alarmRecordsService.updateOldAlarmRecord(gasFlowAddr, "日用水量超阈值预警"); + } else { + AlarmJob alarmJob = alarmJobService.saveData(gasFlowAddr, wellDto.getWellCode(), "SLCX", "1"); + alarmRecord.setJobId(alarmJob.getId()); + } alarmRecordsService.insertAlarmRecord(alarmRecord); // 向前端推送报警 } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataReceiver.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataReceiver.java index 6c25e18..200f5d2 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataReceiver.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataReceiver.java @@ -2,16 +2,15 @@ import com.casic.missiles.core.base.controller.BaseController; import com.casic.missiles.core.base.response.ResponseData; +import com.casic.missiles.modular.alarm.service.IAlarmJobService; import com.casic.missiles.modular.alarm.service.IAlarmRecordsService; import com.casic.missiles.modular.alarm.service.IAlarmRuleService; import com.casic.missiles.modular.system.dto.DeviceWellDto; -import com.casic.missiles.modular.system.model.AlarmRecords; -import com.casic.missiles.modular.system.model.AlarmRule; -import com.casic.missiles.modular.system.model.DataWaterMeter; -import com.casic.missiles.modular.system.model.Device; +import com.casic.missiles.modular.system.model.*; import com.casic.missiles.modular.system.service.IDeviceService; import com.casic.missiles.modular.system.service.IWaterMeterDataService; import lombok.extern.java.Log; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -40,6 +39,9 @@ @Resource private IAlarmRecordsService alarmRecordsService; + @Autowired + IAlarmJobService alarmJobService; + private DecimalFormat df2 = new DecimalFormat("0.00"); @RequestMapping(value = "/data/recv") @@ -106,7 +108,6 @@ if (flowAccToday - alarmRule.getHighvalue() > 0) { // 超出报警阈值 生成一条报警消息 AlarmRecords alarmRecord = new AlarmRecords(); - alarmRecord.setDeviceId(device.getId()); alarmRecord.setDevcode(meterAddr); alarmRecord.setWellCode(wellDto.getWellCode()); @@ -116,17 +117,19 @@ alarmRecord.setAlarmTime(Calendar.getInstance().getTime()); alarmRecord.setStatus("1"); alarmRecord.setAlarmMessage("日用水量超阈值报警"); - + if (alarmRecordsService.isOldAlarmRecord(meterAddr, "日用水量超阈值报警")) { + alarmRecordsService.updateOldAlarmRecord(meterAddr, "日用水量超阈值报警"); + } else { + AlarmJob alarmJob = alarmJobService.saveData(meterAddr, wellDto.getWellCode(), "QLCX", "1"); + alarmRecord.setJobId(alarmJob.getId()); + } alarmRecordsService.insertAlarmRecord(alarmRecord); - - // 向前端推送报警 } else { // 如果没有报警则判断是否预警 if (null != alarmRuleWarn && null != alarmRuleWarn.getHighvalue()) { if (flowAccToday - alarmRuleWarn.getHighvalue() > 0) { // 超出预警阈值 生成一条预警消息 AlarmRecords alarmRecord = new AlarmRecords(); - alarmRecord.setDeviceId(device.getId()); alarmRecord.setDevcode(meterAddr); alarmRecord.setWellCode(wellDto.getWellCode()); @@ -136,10 +139,13 @@ alarmRecord.setAlarmTime(Calendar.getInstance().getTime()); alarmRecord.setStatus("1"); alarmRecord.setAlarmMessage("日用水量超阈值预警"); - + if (alarmRecordsService.isOldAlarmRecord(meterAddr, "日用水量超阈值预警")) { + alarmRecordsService.updateOldAlarmRecord(meterAddr, "日用水量超阈值预警"); + } else { + AlarmJob alarmJob = alarmJobService.saveData(meterAddr, wellDto.getWellCode(), "QLCX", "1"); + alarmRecord.setJobId(alarmJob.getId()); + } alarmRecordsService.insertAlarmRecord(alarmRecord); - - // 向前端推送报警 } } } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmJobMapper.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmJobMapper.java index 6592517..ccdff9a 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmJobMapper.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmJobMapper.java @@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.mapper.BaseMapper; import com.baomidou.mybatisplus.plugins.Page; +import com.casic.missiles.modular.alarm.model.JobListParam; import com.casic.missiles.modular.system.dto.SelectDto; import com.casic.missiles.modular.system.dto.UserClientView; import com.casic.missiles.modular.system.model.AlarmJob; @@ -21,44 +22,65 @@ * @since 2019-05-17 */ public interface AlarmJobMapper extends BaseMapper { - List> jobList(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("jobStatus") String jobStatus, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("dataScope") DataScope dataScope,@Param("userId")Long userId); - List> jobListApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("jobStatus") String jobStatus, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("deptId")Long deptId,@Param("userId")Long userId,@Param("leaderId")Long leaderId); + List> jobList(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("jobStatus") String jobStatus, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("dataScope") DataScope dataScope, @Param("userId") Long userId); + + List> jobListApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("jobStatus") String jobStatus, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("deptId") Long deptId, @Param("userId") Long userId, @Param("leaderId") Long leaderId); + // List jobListExport(@Param("page") Page page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("jobStatus") String jobStatus, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("dataScope") DataScope dataScope); - List> jobListDelayRe(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("dataScope") DataScope dataScope,@Param("userId")Long userId); - List> jobListDelayReApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("deptId")Long deptId,@Param("userId")Long userId,@Param("leaderId")Long leaderId); + List> jobListDelayRe(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("dataScope") DataScope dataScope, @Param("userId") Long userId); - List> jobListDelayPro(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("dataScope") DataScope dataScope,@Param("userId")Long userId); - List> jobListDelayProApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("deptId")Long deptId,@Param("userId")Long userId,@Param("leaderId")Long leaderId); + List> jobListDelayReApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("deptId") Long deptId, @Param("userId") Long userId, @Param("leaderId") Long leaderId); - List> jobListSearchApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("alarmLevel")String alarmLevel, @Param("alarmContent") String alarmContent, @Param("jobStatus") String jobStatus, @Param("beginTime") String beginTime, @Param("endTime") String endTime, - @Param("getJobBeginTime") String getJobBeginTime, @Param("getJobEndTime") String getJobEndTime, @Param("shouldGetBeginTime") String shouldGetBeginTime, @Param("shouldGetEndTime") String shouldGetEndTime, - @Param("handleJobBeginTime") String handleJobBeginTime, @Param("handleJobEndTime") String handleJobEndTime, @Param("shouldHandleBeginTime") String shouldHandleBeginTime, @Param("shouldHandleEndTime") String shouldHandleEndTime, - @Param("deptId")Long deptId, @Param("userId")Long userId, @Param("leaderId")Long leaderId); - List> jobListSearch(@Param("page") Page> page, @Param("keywords") String keywords, @Param("alarmLevel")String alarmLevel, @Param("alarmContent") String alarmContent, @Param("jobStatus") String jobStatus, @Param("beginTime") String beginTime, @Param("endTime") String endTime, - @Param("getJobBeginTime") String getJobBeginTime, @Param("getJobEndTime") String getJobEndTime, @Param("shouldGetBeginTime") String shouldGetBeginTime, @Param("shouldGetEndTime") String shouldGetEndTime, - @Param("handleJobBeginTime") String handleJobBeginTime, @Param("handleJobEndTime") String handleJobEndTime, @Param("shouldHandleBeginTime") String shouldHandleBeginTime, @Param("shouldHandleEndTime") String shouldHandleEndTime, - @Param("dataScope") DataScope dataScope,@Param("userId")Long userId); + List> jobListDelayPro(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("dataScope") DataScope dataScope, @Param("userId") Long userId); - Map countByJobStatus(@Param("deptId")long deptId,@Param("spanDays") int spanDays); - Map countMyJob(@Param("userId")long userId,@Param("deptId")long deptId,@Param("spanDays") int spanDays); - List> jobInfo(@Param("id") int id,@Param("dataScope") DataScope dataScope,@Param("personId") Long personId); -// boolean getJob(@Param("id") int id,@Param("personId") long personId); - boolean getJob(@Param("id") int id,@Param("personId") long personId,@Param("getTime")Date getTime ,@Param("shouldHandleTime")Date shouldHandleTime); - boolean confirmJob(@Param("id") int id,@Param("personId") long personId,@Param("firstState") String firstState,@Param("firstStatePhotos") String firstStatePhotos,@Param("needHandle") String needHandle); - boolean confirmOverJobAndAlarm(@Param("id") int id,@Param("personId") long personId,@Param("firstState") String firstState,@Param("firstStatePhotos") String firstStatePhotos); - boolean transferJob(@Param("id") int id,@Param("transferPerson") long transferPerson,@Param("flowRec") String flowRec); - boolean saveJob(@Param("id") int id,@Param("handleMessage") String handleMessage,@Param("handlePhotos") String handlePhotos); - boolean overJob(@Param("id") int id,@Param("personId") long personId,@Param("handleMessage") String handleMessage,@Param("handlePhotos") String handlePhotos); + List> jobListDelayProApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("deptId") Long deptId, @Param("userId") Long userId, @Param("leaderId") Long leaderId); + + List> jobListSearchApp(@Param("page") Page> page, @Param("keywords") String keywords, @Param("alarmLevel") String alarmLevel, @Param("alarmContent") String alarmContent, @Param("jobStatus") String jobStatus, @Param("beginTime") String beginTime, @Param("endTime") String endTime, + @Param("getJobBeginTime") String getJobBeginTime, @Param("getJobEndTime") String getJobEndTime, @Param("shouldGetBeginTime") String shouldGetBeginTime, @Param("shouldGetEndTime") String shouldGetEndTime, + @Param("handleJobBeginTime") String handleJobBeginTime, @Param("handleJobEndTime") String handleJobEndTime, @Param("shouldHandleBeginTime") String shouldHandleBeginTime, @Param("shouldHandleEndTime") String shouldHandleEndTime, + @Param("deptId") Long deptId, @Param("userId") Long userId, @Param("leaderId") Long leaderId); + + List> jobListSearch(@Param("page") Page> page, @Param("jobListParam") JobListParam jobListParam, + @Param("dataScope") DataScope dataScope, @Param("userId") Long userId); + + Map countByJobStatus(@Param("deptId") long deptId, @Param("spanDays") int spanDays); + + Map countMyJob(@Param("userId") long userId, @Param("deptId") long deptId, @Param("spanDays") int spanDays); + + List> jobInfo(@Param("id") Long id, @Param("dataScope") DataScope dataScope, @Param("personId") Long personId); + + // boolean getJob(@Param("id") int id,@Param("personId") long personId); + boolean getJob(@Param("id") Long id, @Param("personId") long personId, @Param("getTime") Date getTime, @Param("shouldHandleTime") Date shouldHandleTime); + + boolean confirmJob(@Param("id") Long id, @Param("personId") long personId, @Param("firstState") String firstState, @Param("firstStatePhotos") String firstStatePhotos, @Param("needHandle") String needHandle); + + boolean confirmOverJobAndAlarm(@Param("id") Long id, @Param("personId") long personId, @Param("firstState") String firstState, @Param("firstStatePhotos") String firstStatePhotos); + + boolean transferJob(@Param("id") Long id, @Param("transferPerson") long transferPerson, @Param("flowRec") String flowRec); + + boolean saveJob(@Param("id") Long id, @Param("handleMessage") String handleMessage, @Param("handlePhotos") String handlePhotos); + + boolean overJob(@Param("id") int id, @Param("personId") long personId, @Param("handleMessage") String handleMessage, @Param("handlePhotos") String handlePhotos); + boolean overAlarm(@Param("jobId") int id); - boolean overJobAndAlarm(@Param("id") int id,@Param("personId") long personId,@Param("handleMessage") String handleMessage,@Param("handlePhotos") String handlePhotos); - boolean handleJob(@Param("id") int id,@Param("personId") long personId); - List> countByDataScope(@Param("dataScope") DataScope dataScope,@Param("alarmType")String alarmType,@Param("jobStatus")String jobStatus,@Param("beginTime")String beginTime,@Param("endTime")String endTime); - Integer countByResponse(@Param("alarmType")String alarmType,@Param("jobStatus")String jobStatus,@Param("deptId") Long deptId,@Param("beginTime")String beginTime,@Param("endTime")String endTime); - Integer countByUser(@Param("alarmType")String alarmType,@Param("jobStatus")String jobStatus,@Param("userId") Long userId,@Param("beginTime")String beginTime,@Param("endTime")String endTime); + boolean overJobAndAlarm(@Param("id") Long id, @Param("personId") long personId, @Param("handleMessage") String handleMessage, @Param("handlePhotos") String handlePhotos); + + boolean handleJob(@Param("id") Long id, @Param("personId") long personId); + + List> countByDataScope(@Param("dataScope") DataScope dataScope, @Param("alarmType") String alarmType, @Param("jobStatus") String jobStatus, @Param("beginTime") String beginTime, @Param("endTime") String endTime); + + Integer countByResponse(@Param("alarmType") String alarmType, @Param("jobStatus") String jobStatus, @Param("deptId") Long deptId, @Param("beginTime") String beginTime, @Param("endTime") String endTime); + + Integer countByUser(@Param("alarmType") String alarmType, @Param("jobStatus") String jobStatus, @Param("userId") Long userId, @Param("beginTime") String beginTime, @Param("endTime") String endTime); String selectClientIdByUser(@Param("userId") Long userId); + List selectUserByWellCode(@Param("wellCode") String wellCode); + List selectUseIds(@Param("roleIds") List roleIds); + List selectRoles(); + + String getJobCodeMaxSerial(@Param("jobcode") String jobcode); } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmRecordsMapper.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmRecordsMapper.java index 87a71ff..d4c6a8b 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmRecordsMapper.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/AlarmRecordsMapper.java @@ -11,7 +11,7 @@ /** *

- * Mapper 接口 + * Mapper 接口 *

* * @author casic123 @@ -19,13 +19,18 @@ */ public interface AlarmRecordsMapper extends BaseMapper { - List> alarmList(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("status") String status, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("areaId") String areaId, @Param("dataScope") DataScope dataScope); + List> alarmList(@Param("page") Page> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("status") String status, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("areaId") String areaId, @Param("dataScope") DataScope dataScope); List alarmListNoPage(@Param("scope") DataScope dataScope, @Param("keywords") String keywords, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("areaId") String areaId); - boolean cancelAlarm(@Param("id") long id, @Param("jobStatus")String jobStatus,@Param("handleMessage") String handleMessage,@Param("personId") long personId); + boolean cancelAlarm(@Param("id") long id, @Param("jobStatus") String jobStatus, @Param("handleMessage") String handleMessage, @Param("personId") long personId); boolean cancelAlarmById(@Param("id") long id); boolean cancelAlarmByNewRecord(@Param("devcode") String devcode, @Param("alarmType") String alarmType); + + String isOldAlarmRecord(@Param("devcode") String devcode, @Param("MsgContent") String MsgContent); + + Integer updateOldAlarmRecord(@Param("devcode") String devcode, @Param("MsgContent") String MsgContent); + } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmJobMapper.xml b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmJobMapper.xml index cd850b4..5aeef97 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmJobMapper.xml +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmJobMapper.xml @@ -65,6 +65,7 @@ GROUP BY aj.id ) c + + + + + + + + + + diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmRecordsMapper.xml b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmRecordsMapper.xml index f2b5457..6929f44 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmRecordsMapper.xml +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmRecordsMapper.xml @@ -4,18 +4,18 @@ - - - - - - - - + + + + + + + + - - - + + + @@ -52,14 +52,14 @@ AND ar.STATUS = #{status} - - = #{beginTime} ]]> + + = #{beginTime} ]]> - - + + - - and ar.WELL_CODE like concat('%',CONCAT(#{keywords},'%')) + + and ar.WELL_CODE like concat('%',CONCAT(#{keywords},'%')) AND ar.ALARM_TYPE = #{alarmType} @@ -74,19 +74,19 @@ - UPDATE alarm_job aj, alarm_records ar + UPDATE alarm_job aj, alarm_records ar aj.job_status = #{jobStatus} , aj.handle_job_person = #{personId}, @@ -140,4 +140,20 @@ WHERE ar.devcode = #{devcode} and ar.alarm_type = #{alarmType} + + SELECT ID + FROM alarm_records + WHERE DEVCODE = #{devcode} + AND ALARM_CONTENT = #{MsgContent} + AND STATUS='1' + + + + UPDATE alarm_records + SET STATUS='0' + WHERE DEVCODE = #{devcode} + AND ALARM_CONTENT = #{MsgContent} + AND STATUS='1' + + diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/model/AlarmJob.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/model/AlarmJob.java index 323fcab..69cf1cc 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/model/AlarmJob.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/model/AlarmJob.java @@ -146,25 +146,25 @@ @Override public String toString() { return "AlarmJob{" + - "id=" + id + - ", jobcode=" + jobcode + - ", jogType=" + jobType + - ", wellCode=" + wellCode + - ", devcode=" + devcode + - ", createTime=" + createTime + - ", jobStatus=" + jobStatus + - ", getJobPerson=" + getJobPerson + - ", getJobTime=" + getJobTime + - ", firstState=" + firstState + - ", firstStatePhotos=" + firstStatePhotos + - ", confirmJobPerson=" + confirmJobPerson + - ", confrimJobTime=" + confrimJobTime + - ", handleJobPerson=" + handleJobPerson + - ", handleJobTime=" + handleJobTime + - ", handleMessage=" + handleMessage + - ", handlePhotos=" + handlePhotos + - ", flow=" + flow + - ", recordId=" + recordId + - "}"; + "id=" + id + + ", jobcode=" + jobcode + + ", jogType=" + jobType + + ", wellCode=" + wellCode + + ", devcode=" + devcode + + ", createTime=" + createTime + + ", jobStatus=" + jobStatus + + ", getJobPerson=" + getJobPerson + + ", getJobTime=" + getJobTime + + ", firstState=" + firstState + + ", firstStatePhotos=" + firstStatePhotos + + ", confirmJobPerson=" + confirmJobPerson + + ", confrimJobTime=" + confrimJobTime + + ", handleJobPerson=" + handleJobPerson + + ", handleJobTime=" + handleJobTime + + ", handleMessage=" + handleMessage + + ", handlePhotos=" + handlePhotos + + ", flow=" + flow + + ", recordId=" + recordId + + "}"; } } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/util/DateUtil.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/util/DateUtil.java index 88ee7f0..c55acac 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/util/DateUtil.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/util/DateUtil.java @@ -45,4 +45,7 @@ return betweenTime; } + + + } diff --git a/casic-device/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataController.java b/casic-device/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataController.java index 561ec83..d73e6fa 100644 --- a/casic-device/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataController.java +++ b/casic-device/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataController.java @@ -161,8 +161,8 @@ deviceDto.put("gasFlowNum", "0"); deviceDto.put("uptime", sdf4.format(new Date())); } else { - deviceDto.put("gasFlowNum", flowRec.get("TOTAL_FLOW") == null ? "0" : flowRec.get("TOTAL_FLOW").toString()); - deviceDto.put("uptime", sdf4.format((Date) flowRec.get("UPTIME"))); + deviceDto.put("gasFlowNum", flowRec.get("totalFlow") == null ? "0" : flowRec.get("totalFlow").toString()); + deviceDto.put("uptime", sdf4.format((Date) flowRec.get("upTime"))); } deviceDto.put("fullAreaName", deviceService.getAreaFullNameById(deviceDto.get("AREA").toString()) + "/" + deviceDto.get("POSITION").toString()); diff --git a/casic-device/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataController.java b/casic-device/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataController.java index 5cf736c..a6f01a9 100644 --- a/casic-device/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataController.java +++ b/casic-device/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataController.java @@ -22,10 +22,7 @@ import java.io.IOException; import java.text.DateFormat; import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; /** * @author a203 @@ -38,7 +35,7 @@ private final IDeviceService deviceService; @Value("${smartcity.office.maxRowsExcel}") - private int maxRowsExcel; + private int maxRowsExcel; @Value("${smartcity.config.config-path}") private String templatePath; @@ -88,9 +85,11 @@ Map meterRec = deviceService.selectLatestWaterMeter(deviceDto.getDevcode()); if (meterRec == null) { deviceDto.setWatchNum("0"); + deviceDto.setPressure(new Random().nextInt(4)); deviceDto.setUptime(sdf4.format(new Date())); } else { deviceDto.setWatchNum(meterRec.get("FLOW_ACC") == null ? "0" : meterRec.get("FLOW_ACC").toString()); + deviceDto.setPressure(meterRec.get("PRESSURE") == null ? 0 : Integer.valueOf(meterRec.get("PRESSURE").toString())); deviceDto.setUptime(sdf4.format((Date) meterRec.get("UPTIME"))); } @@ -156,16 +155,16 @@ FileInputStream fileInputStream = null; if (ToolUtil.isEmpty(list)) { - fileInputStream = new FileInputStream(templatePath+"/waterMeterListEmpty.xlsx"); + fileInputStream = new FileInputStream(templatePath + "/waterMeterListEmpty.xlsx"); } else { - fileInputStream = new FileInputStream(templatePath+"/waterMeterListTemplate.xlsx"); + fileInputStream = new FileInputStream(templatePath + "/waterMeterListTemplate.xlsx"); } try { httpServletResponse.setContentType("application/octet-stream"); - httpServletResponse.addHeader("Content-Disposition", " attachment;filename="+"waterMeterList.xlsx" ); + httpServletResponse.addHeader("Content-Disposition", " attachment;filename=" + "waterMeterList.xlsx"); - Map var = new HashMap<>(); + Map var = new HashMap<>(); var.put("标题", "设备数据列表"); var.put("list", list); ExcelIO.writeTemplate(fileInputStream, httpServletResponse.getOutputStream(), var); diff --git a/casic-device/src/main/java/com/casic/missiles/modular/system/dao/mapping/DeviceMapper.xml b/casic-device/src/main/java/com/casic/missiles/modular/system/dao/mapping/DeviceMapper.xml index 0527ba3..23185e7 100644 --- a/casic-device/src/main/java/com/casic/missiles/modular/system/dao/mapping/DeviceMapper.xml +++ b/casic-device/src/main/java/com/casic/missiles/modular/system/dao/mapping/DeviceMapper.xml @@ -1013,7 +1013,7 @@ + + + + + + + + + + diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmRecordsMapper.xml b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmRecordsMapper.xml index f2b5457..6929f44 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmRecordsMapper.xml +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmRecordsMapper.xml @@ -4,18 +4,18 @@ - - - - - - - - + + + + + + + + - - - + + + @@ -52,14 +52,14 @@ AND ar.STATUS = #{status} - - = #{beginTime} ]]> + + = #{beginTime} ]]> - - + + - - and ar.WELL_CODE like concat('%',CONCAT(#{keywords},'%')) + + and ar.WELL_CODE like concat('%',CONCAT(#{keywords},'%')) AND ar.ALARM_TYPE = #{alarmType} @@ -74,19 +74,19 @@ - UPDATE alarm_job aj, alarm_records ar + UPDATE alarm_job aj, alarm_records ar aj.job_status = #{jobStatus} , aj.handle_job_person = #{personId}, @@ -140,4 +140,20 @@ WHERE ar.devcode = #{devcode} and ar.alarm_type = #{alarmType} + + SELECT ID + FROM alarm_records + WHERE DEVCODE = #{devcode} + AND ALARM_CONTENT = #{MsgContent} + AND STATUS='1' + + + + UPDATE alarm_records + SET STATUS='0' + WHERE DEVCODE = #{devcode} + AND ALARM_CONTENT = #{MsgContent} + AND STATUS='1' + + diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/model/AlarmJob.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/model/AlarmJob.java index 323fcab..69cf1cc 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/model/AlarmJob.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/model/AlarmJob.java @@ -146,25 +146,25 @@ @Override public String toString() { return "AlarmJob{" + - "id=" + id + - ", jobcode=" + jobcode + - ", jogType=" + jobType + - ", wellCode=" + wellCode + - ", devcode=" + devcode + - ", createTime=" + createTime + - ", jobStatus=" + jobStatus + - ", getJobPerson=" + getJobPerson + - ", getJobTime=" + getJobTime + - ", firstState=" + firstState + - ", firstStatePhotos=" + firstStatePhotos + - ", confirmJobPerson=" + confirmJobPerson + - ", confrimJobTime=" + confrimJobTime + - ", handleJobPerson=" + handleJobPerson + - ", handleJobTime=" + handleJobTime + - ", handleMessage=" + handleMessage + - ", handlePhotos=" + handlePhotos + - ", flow=" + flow + - ", recordId=" + recordId + - "}"; + "id=" + id + + ", jobcode=" + jobcode + + ", jogType=" + jobType + + ", wellCode=" + wellCode + + ", devcode=" + devcode + + ", createTime=" + createTime + + ", jobStatus=" + jobStatus + + ", getJobPerson=" + getJobPerson + + ", getJobTime=" + getJobTime + + ", firstState=" + firstState + + ", firstStatePhotos=" + firstStatePhotos + + ", confirmJobPerson=" + confirmJobPerson + + ", confrimJobTime=" + confrimJobTime + + ", handleJobPerson=" + handleJobPerson + + ", handleJobTime=" + handleJobTime + + ", handleMessage=" + handleMessage + + ", handlePhotos=" + handlePhotos + + ", flow=" + flow + + ", recordId=" + recordId + + "}"; } } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/util/DateUtil.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/util/DateUtil.java index 88ee7f0..c55acac 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/util/DateUtil.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/util/DateUtil.java @@ -45,4 +45,7 @@ return betweenTime; } + + + } diff --git a/casic-device/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataController.java b/casic-device/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataController.java index 561ec83..d73e6fa 100644 --- a/casic-device/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataController.java +++ b/casic-device/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataController.java @@ -161,8 +161,8 @@ deviceDto.put("gasFlowNum", "0"); deviceDto.put("uptime", sdf4.format(new Date())); } else { - deviceDto.put("gasFlowNum", flowRec.get("TOTAL_FLOW") == null ? "0" : flowRec.get("TOTAL_FLOW").toString()); - deviceDto.put("uptime", sdf4.format((Date) flowRec.get("UPTIME"))); + deviceDto.put("gasFlowNum", flowRec.get("totalFlow") == null ? "0" : flowRec.get("totalFlow").toString()); + deviceDto.put("uptime", sdf4.format((Date) flowRec.get("upTime"))); } deviceDto.put("fullAreaName", deviceService.getAreaFullNameById(deviceDto.get("AREA").toString()) + "/" + deviceDto.get("POSITION").toString()); diff --git a/casic-device/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataController.java b/casic-device/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataController.java index 5cf736c..a6f01a9 100644 --- a/casic-device/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataController.java +++ b/casic-device/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataController.java @@ -22,10 +22,7 @@ import java.io.IOException; import java.text.DateFormat; import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; /** * @author a203 @@ -38,7 +35,7 @@ private final IDeviceService deviceService; @Value("${smartcity.office.maxRowsExcel}") - private int maxRowsExcel; + private int maxRowsExcel; @Value("${smartcity.config.config-path}") private String templatePath; @@ -88,9 +85,11 @@ Map meterRec = deviceService.selectLatestWaterMeter(deviceDto.getDevcode()); if (meterRec == null) { deviceDto.setWatchNum("0"); + deviceDto.setPressure(new Random().nextInt(4)); deviceDto.setUptime(sdf4.format(new Date())); } else { deviceDto.setWatchNum(meterRec.get("FLOW_ACC") == null ? "0" : meterRec.get("FLOW_ACC").toString()); + deviceDto.setPressure(meterRec.get("PRESSURE") == null ? 0 : Integer.valueOf(meterRec.get("PRESSURE").toString())); deviceDto.setUptime(sdf4.format((Date) meterRec.get("UPTIME"))); } @@ -156,16 +155,16 @@ FileInputStream fileInputStream = null; if (ToolUtil.isEmpty(list)) { - fileInputStream = new FileInputStream(templatePath+"/waterMeterListEmpty.xlsx"); + fileInputStream = new FileInputStream(templatePath + "/waterMeterListEmpty.xlsx"); } else { - fileInputStream = new FileInputStream(templatePath+"/waterMeterListTemplate.xlsx"); + fileInputStream = new FileInputStream(templatePath + "/waterMeterListTemplate.xlsx"); } try { httpServletResponse.setContentType("application/octet-stream"); - httpServletResponse.addHeader("Content-Disposition", " attachment;filename="+"waterMeterList.xlsx" ); + httpServletResponse.addHeader("Content-Disposition", " attachment;filename=" + "waterMeterList.xlsx"); - Map var = new HashMap<>(); + Map var = new HashMap<>(); var.put("标题", "设备数据列表"); var.put("list", list); ExcelIO.writeTemplate(fileInputStream, httpServletResponse.getOutputStream(), var); diff --git a/casic-device/src/main/java/com/casic/missiles/modular/system/dao/mapping/DeviceMapper.xml b/casic-device/src/main/java/com/casic/missiles/modular/system/dao/mapping/DeviceMapper.xml index 0527ba3..23185e7 100644 --- a/casic-device/src/main/java/com/casic/missiles/modular/system/dao/mapping/DeviceMapper.xml +++ b/casic-device/src/main/java/com/casic/missiles/modular/system/dao/mapping/DeviceMapper.xml @@ -1013,7 +1013,7 @@ + + + + + + + + + + diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmRecordsMapper.xml b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmRecordsMapper.xml index f2b5457..6929f44 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmRecordsMapper.xml +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmRecordsMapper.xml @@ -4,18 +4,18 @@ - - - - - - - - + + + + + + + + - - - + + + @@ -52,14 +52,14 @@ AND ar.STATUS = #{status} - - = #{beginTime} ]]> + + = #{beginTime} ]]> - - + + - - and ar.WELL_CODE like concat('%',CONCAT(#{keywords},'%')) + + and ar.WELL_CODE like concat('%',CONCAT(#{keywords},'%')) AND ar.ALARM_TYPE = #{alarmType} @@ -74,19 +74,19 @@ - UPDATE alarm_job aj, alarm_records ar + UPDATE alarm_job aj, alarm_records ar aj.job_status = #{jobStatus} , aj.handle_job_person = #{personId}, @@ -140,4 +140,20 @@ WHERE ar.devcode = #{devcode} and ar.alarm_type = #{alarmType} + + SELECT ID + FROM alarm_records + WHERE DEVCODE = #{devcode} + AND ALARM_CONTENT = #{MsgContent} + AND STATUS='1' + + + + UPDATE alarm_records + SET STATUS='0' + WHERE DEVCODE = #{devcode} + AND ALARM_CONTENT = #{MsgContent} + AND STATUS='1' + + diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/model/AlarmJob.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/model/AlarmJob.java index 323fcab..69cf1cc 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/model/AlarmJob.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/model/AlarmJob.java @@ -146,25 +146,25 @@ @Override public String toString() { return "AlarmJob{" + - "id=" + id + - ", jobcode=" + jobcode + - ", jogType=" + jobType + - ", wellCode=" + wellCode + - ", devcode=" + devcode + - ", createTime=" + createTime + - ", jobStatus=" + jobStatus + - ", getJobPerson=" + getJobPerson + - ", getJobTime=" + getJobTime + - ", firstState=" + firstState + - ", firstStatePhotos=" + firstStatePhotos + - ", confirmJobPerson=" + confirmJobPerson + - ", confrimJobTime=" + confrimJobTime + - ", handleJobPerson=" + handleJobPerson + - ", handleJobTime=" + handleJobTime + - ", handleMessage=" + handleMessage + - ", handlePhotos=" + handlePhotos + - ", flow=" + flow + - ", recordId=" + recordId + - "}"; + "id=" + id + + ", jobcode=" + jobcode + + ", jogType=" + jobType + + ", wellCode=" + wellCode + + ", devcode=" + devcode + + ", createTime=" + createTime + + ", jobStatus=" + jobStatus + + ", getJobPerson=" + getJobPerson + + ", getJobTime=" + getJobTime + + ", firstState=" + firstState + + ", firstStatePhotos=" + firstStatePhotos + + ", confirmJobPerson=" + confirmJobPerson + + ", confrimJobTime=" + confrimJobTime + + ", handleJobPerson=" + handleJobPerson + + ", handleJobTime=" + handleJobTime + + ", handleMessage=" + handleMessage + + ", handlePhotos=" + handlePhotos + + ", flow=" + flow + + ", recordId=" + recordId + + "}"; } } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/util/DateUtil.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/util/DateUtil.java index 88ee7f0..c55acac 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/util/DateUtil.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/util/DateUtil.java @@ -45,4 +45,7 @@ return betweenTime; } + + + } diff --git a/casic-device/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataController.java b/casic-device/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataController.java index 561ec83..d73e6fa 100644 --- a/casic-device/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataController.java +++ b/casic-device/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataController.java @@ -161,8 +161,8 @@ deviceDto.put("gasFlowNum", "0"); deviceDto.put("uptime", sdf4.format(new Date())); } else { - deviceDto.put("gasFlowNum", flowRec.get("TOTAL_FLOW") == null ? "0" : flowRec.get("TOTAL_FLOW").toString()); - deviceDto.put("uptime", sdf4.format((Date) flowRec.get("UPTIME"))); + deviceDto.put("gasFlowNum", flowRec.get("totalFlow") == null ? "0" : flowRec.get("totalFlow").toString()); + deviceDto.put("uptime", sdf4.format((Date) flowRec.get("upTime"))); } deviceDto.put("fullAreaName", deviceService.getAreaFullNameById(deviceDto.get("AREA").toString()) + "/" + deviceDto.get("POSITION").toString()); diff --git a/casic-device/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataController.java b/casic-device/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataController.java index 5cf736c..a6f01a9 100644 --- a/casic-device/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataController.java +++ b/casic-device/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataController.java @@ -22,10 +22,7 @@ import java.io.IOException; import java.text.DateFormat; import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; /** * @author a203 @@ -38,7 +35,7 @@ private final IDeviceService deviceService; @Value("${smartcity.office.maxRowsExcel}") - private int maxRowsExcel; + private int maxRowsExcel; @Value("${smartcity.config.config-path}") private String templatePath; @@ -88,9 +85,11 @@ Map meterRec = deviceService.selectLatestWaterMeter(deviceDto.getDevcode()); if (meterRec == null) { deviceDto.setWatchNum("0"); + deviceDto.setPressure(new Random().nextInt(4)); deviceDto.setUptime(sdf4.format(new Date())); } else { deviceDto.setWatchNum(meterRec.get("FLOW_ACC") == null ? "0" : meterRec.get("FLOW_ACC").toString()); + deviceDto.setPressure(meterRec.get("PRESSURE") == null ? 0 : Integer.valueOf(meterRec.get("PRESSURE").toString())); deviceDto.setUptime(sdf4.format((Date) meterRec.get("UPTIME"))); } @@ -156,16 +155,16 @@ FileInputStream fileInputStream = null; if (ToolUtil.isEmpty(list)) { - fileInputStream = new FileInputStream(templatePath+"/waterMeterListEmpty.xlsx"); + fileInputStream = new FileInputStream(templatePath + "/waterMeterListEmpty.xlsx"); } else { - fileInputStream = new FileInputStream(templatePath+"/waterMeterListTemplate.xlsx"); + fileInputStream = new FileInputStream(templatePath + "/waterMeterListTemplate.xlsx"); } try { httpServletResponse.setContentType("application/octet-stream"); - httpServletResponse.addHeader("Content-Disposition", " attachment;filename="+"waterMeterList.xlsx" ); + httpServletResponse.addHeader("Content-Disposition", " attachment;filename=" + "waterMeterList.xlsx"); - Map var = new HashMap<>(); + Map var = new HashMap<>(); var.put("标题", "设备数据列表"); var.put("list", list); ExcelIO.writeTemplate(fileInputStream, httpServletResponse.getOutputStream(), var); diff --git a/casic-device/src/main/java/com/casic/missiles/modular/system/dao/mapping/DeviceMapper.xml b/casic-device/src/main/java/com/casic/missiles/modular/system/dao/mapping/DeviceMapper.xml index 0527ba3..23185e7 100644 --- a/casic-device/src/main/java/com/casic/missiles/modular/system/dao/mapping/DeviceMapper.xml +++ b/casic-device/src/main/java/com/casic/missiles/modular/system/dao/mapping/DeviceMapper.xml @@ -1013,7 +1013,7 @@ + + + + + + + + + + diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmRecordsMapper.xml b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmRecordsMapper.xml index f2b5457..6929f44 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmRecordsMapper.xml +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmRecordsMapper.xml @@ -4,18 +4,18 @@ - - - - - - - - + + + + + + + + - - - + + + @@ -52,14 +52,14 @@ AND ar.STATUS = #{status} - - = #{beginTime} ]]> + + = #{beginTime} ]]> - - + + - - and ar.WELL_CODE like concat('%',CONCAT(#{keywords},'%')) + + and ar.WELL_CODE like concat('%',CONCAT(#{keywords},'%')) AND ar.ALARM_TYPE = #{alarmType} @@ -74,19 +74,19 @@ - UPDATE alarm_job aj, alarm_records ar + UPDATE alarm_job aj, alarm_records ar aj.job_status = #{jobStatus} , aj.handle_job_person = #{personId}, @@ -140,4 +140,20 @@ WHERE ar.devcode = #{devcode} and ar.alarm_type = #{alarmType} + + SELECT ID + FROM alarm_records + WHERE DEVCODE = #{devcode} + AND ALARM_CONTENT = #{MsgContent} + AND STATUS='1' + + + + UPDATE alarm_records + SET STATUS='0' + WHERE DEVCODE = #{devcode} + AND ALARM_CONTENT = #{MsgContent} + AND STATUS='1' + + diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/model/AlarmJob.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/model/AlarmJob.java index 323fcab..69cf1cc 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/model/AlarmJob.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/model/AlarmJob.java @@ -146,25 +146,25 @@ @Override public String toString() { return "AlarmJob{" + - "id=" + id + - ", jobcode=" + jobcode + - ", jogType=" + jobType + - ", wellCode=" + wellCode + - ", devcode=" + devcode + - ", createTime=" + createTime + - ", jobStatus=" + jobStatus + - ", getJobPerson=" + getJobPerson + - ", getJobTime=" + getJobTime + - ", firstState=" + firstState + - ", firstStatePhotos=" + firstStatePhotos + - ", confirmJobPerson=" + confirmJobPerson + - ", confrimJobTime=" + confrimJobTime + - ", handleJobPerson=" + handleJobPerson + - ", handleJobTime=" + handleJobTime + - ", handleMessage=" + handleMessage + - ", handlePhotos=" + handlePhotos + - ", flow=" + flow + - ", recordId=" + recordId + - "}"; + "id=" + id + + ", jobcode=" + jobcode + + ", jogType=" + jobType + + ", wellCode=" + wellCode + + ", devcode=" + devcode + + ", createTime=" + createTime + + ", jobStatus=" + jobStatus + + ", getJobPerson=" + getJobPerson + + ", getJobTime=" + getJobTime + + ", firstState=" + firstState + + ", firstStatePhotos=" + firstStatePhotos + + ", confirmJobPerson=" + confirmJobPerson + + ", confrimJobTime=" + confrimJobTime + + ", handleJobPerson=" + handleJobPerson + + ", handleJobTime=" + handleJobTime + + ", handleMessage=" + handleMessage + + ", handlePhotos=" + handlePhotos + + ", flow=" + flow + + ", recordId=" + recordId + + "}"; } } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/util/DateUtil.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/util/DateUtil.java index 88ee7f0..c55acac 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/util/DateUtil.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/util/DateUtil.java @@ -45,4 +45,7 @@ return betweenTime; } + + + } diff --git a/casic-device/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataController.java b/casic-device/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataController.java index 561ec83..d73e6fa 100644 --- a/casic-device/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataController.java +++ b/casic-device/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataController.java @@ -161,8 +161,8 @@ deviceDto.put("gasFlowNum", "0"); deviceDto.put("uptime", sdf4.format(new Date())); } else { - deviceDto.put("gasFlowNum", flowRec.get("TOTAL_FLOW") == null ? "0" : flowRec.get("TOTAL_FLOW").toString()); - deviceDto.put("uptime", sdf4.format((Date) flowRec.get("UPTIME"))); + deviceDto.put("gasFlowNum", flowRec.get("totalFlow") == null ? "0" : flowRec.get("totalFlow").toString()); + deviceDto.put("uptime", sdf4.format((Date) flowRec.get("upTime"))); } deviceDto.put("fullAreaName", deviceService.getAreaFullNameById(deviceDto.get("AREA").toString()) + "/" + deviceDto.get("POSITION").toString()); diff --git a/casic-device/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataController.java b/casic-device/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataController.java index 5cf736c..a6f01a9 100644 --- a/casic-device/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataController.java +++ b/casic-device/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataController.java @@ -22,10 +22,7 @@ import java.io.IOException; import java.text.DateFormat; import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; /** * @author a203 @@ -38,7 +35,7 @@ private final IDeviceService deviceService; @Value("${smartcity.office.maxRowsExcel}") - private int maxRowsExcel; + private int maxRowsExcel; @Value("${smartcity.config.config-path}") private String templatePath; @@ -88,9 +85,11 @@ Map meterRec = deviceService.selectLatestWaterMeter(deviceDto.getDevcode()); if (meterRec == null) { deviceDto.setWatchNum("0"); + deviceDto.setPressure(new Random().nextInt(4)); deviceDto.setUptime(sdf4.format(new Date())); } else { deviceDto.setWatchNum(meterRec.get("FLOW_ACC") == null ? "0" : meterRec.get("FLOW_ACC").toString()); + deviceDto.setPressure(meterRec.get("PRESSURE") == null ? 0 : Integer.valueOf(meterRec.get("PRESSURE").toString())); deviceDto.setUptime(sdf4.format((Date) meterRec.get("UPTIME"))); } @@ -156,16 +155,16 @@ FileInputStream fileInputStream = null; if (ToolUtil.isEmpty(list)) { - fileInputStream = new FileInputStream(templatePath+"/waterMeterListEmpty.xlsx"); + fileInputStream = new FileInputStream(templatePath + "/waterMeterListEmpty.xlsx"); } else { - fileInputStream = new FileInputStream(templatePath+"/waterMeterListTemplate.xlsx"); + fileInputStream = new FileInputStream(templatePath + "/waterMeterListTemplate.xlsx"); } try { httpServletResponse.setContentType("application/octet-stream"); - httpServletResponse.addHeader("Content-Disposition", " attachment;filename="+"waterMeterList.xlsx" ); + httpServletResponse.addHeader("Content-Disposition", " attachment;filename=" + "waterMeterList.xlsx"); - Map var = new HashMap<>(); + Map var = new HashMap<>(); var.put("标题", "设备数据列表"); var.put("list", list); ExcelIO.writeTemplate(fileInputStream, httpServletResponse.getOutputStream(), var); diff --git a/casic-device/src/main/java/com/casic/missiles/modular/system/dao/mapping/DeviceMapper.xml b/casic-device/src/main/java/com/casic/missiles/modular/system/dao/mapping/DeviceMapper.xml index 0527ba3..23185e7 100644 --- a/casic-device/src/main/java/com/casic/missiles/modular/system/dao/mapping/DeviceMapper.xml +++ b/casic-device/src/main/java/com/casic/missiles/modular/system/dao/mapping/DeviceMapper.xml @@ -1013,7 +1013,7 @@ + + + + + + + + + + diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmRecordsMapper.xml b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmRecordsMapper.xml index f2b5457..6929f44 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmRecordsMapper.xml +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmRecordsMapper.xml @@ -4,18 +4,18 @@ - - - - - - - - + + + + + + + + - - - + + + @@ -52,14 +52,14 @@ AND ar.STATUS = #{status} - - = #{beginTime} ]]> + + = #{beginTime} ]]> - - + + - - and ar.WELL_CODE like concat('%',CONCAT(#{keywords},'%')) + + and ar.WELL_CODE like concat('%',CONCAT(#{keywords},'%')) AND ar.ALARM_TYPE = #{alarmType} @@ -74,19 +74,19 @@ - UPDATE alarm_job aj, alarm_records ar + UPDATE alarm_job aj, alarm_records ar aj.job_status = #{jobStatus} , aj.handle_job_person = #{personId}, @@ -140,4 +140,20 @@ WHERE ar.devcode = #{devcode} and ar.alarm_type = #{alarmType} + + SELECT ID + FROM alarm_records + WHERE DEVCODE = #{devcode} + AND ALARM_CONTENT = #{MsgContent} + AND STATUS='1' + + + + UPDATE alarm_records + SET STATUS='0' + WHERE DEVCODE = #{devcode} + AND ALARM_CONTENT = #{MsgContent} + AND STATUS='1' + + diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/model/AlarmJob.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/model/AlarmJob.java index 323fcab..69cf1cc 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/model/AlarmJob.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/model/AlarmJob.java @@ -146,25 +146,25 @@ @Override public String toString() { return "AlarmJob{" + - "id=" + id + - ", jobcode=" + jobcode + - ", jogType=" + jobType + - ", wellCode=" + wellCode + - ", devcode=" + devcode + - ", createTime=" + createTime + - ", jobStatus=" + jobStatus + - ", getJobPerson=" + getJobPerson + - ", getJobTime=" + getJobTime + - ", firstState=" + firstState + - ", firstStatePhotos=" + firstStatePhotos + - ", confirmJobPerson=" + confirmJobPerson + - ", confrimJobTime=" + confrimJobTime + - ", handleJobPerson=" + handleJobPerson + - ", handleJobTime=" + handleJobTime + - ", handleMessage=" + handleMessage + - ", handlePhotos=" + handlePhotos + - ", flow=" + flow + - ", recordId=" + recordId + - "}"; + "id=" + id + + ", jobcode=" + jobcode + + ", jogType=" + jobType + + ", wellCode=" + wellCode + + ", devcode=" + devcode + + ", createTime=" + createTime + + ", jobStatus=" + jobStatus + + ", getJobPerson=" + getJobPerson + + ", getJobTime=" + getJobTime + + ", firstState=" + firstState + + ", firstStatePhotos=" + firstStatePhotos + + ", confirmJobPerson=" + confirmJobPerson + + ", confrimJobTime=" + confrimJobTime + + ", handleJobPerson=" + handleJobPerson + + ", handleJobTime=" + handleJobTime + + ", handleMessage=" + handleMessage + + ", handlePhotos=" + handlePhotos + + ", flow=" + flow + + ", recordId=" + recordId + + "}"; } } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/util/DateUtil.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/util/DateUtil.java index 88ee7f0..c55acac 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/util/DateUtil.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/util/DateUtil.java @@ -45,4 +45,7 @@ return betweenTime; } + + + } diff --git a/casic-device/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataController.java b/casic-device/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataController.java index 561ec83..d73e6fa 100644 --- a/casic-device/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataController.java +++ b/casic-device/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataController.java @@ -161,8 +161,8 @@ deviceDto.put("gasFlowNum", "0"); deviceDto.put("uptime", sdf4.format(new Date())); } else { - deviceDto.put("gasFlowNum", flowRec.get("TOTAL_FLOW") == null ? "0" : flowRec.get("TOTAL_FLOW").toString()); - deviceDto.put("uptime", sdf4.format((Date) flowRec.get("UPTIME"))); + deviceDto.put("gasFlowNum", flowRec.get("totalFlow") == null ? "0" : flowRec.get("totalFlow").toString()); + deviceDto.put("uptime", sdf4.format((Date) flowRec.get("upTime"))); } deviceDto.put("fullAreaName", deviceService.getAreaFullNameById(deviceDto.get("AREA").toString()) + "/" + deviceDto.get("POSITION").toString()); diff --git a/casic-device/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataController.java b/casic-device/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataController.java index 5cf736c..a6f01a9 100644 --- a/casic-device/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataController.java +++ b/casic-device/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataController.java @@ -22,10 +22,7 @@ import java.io.IOException; import java.text.DateFormat; import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; /** * @author a203 @@ -38,7 +35,7 @@ private final IDeviceService deviceService; @Value("${smartcity.office.maxRowsExcel}") - private int maxRowsExcel; + private int maxRowsExcel; @Value("${smartcity.config.config-path}") private String templatePath; @@ -88,9 +85,11 @@ Map meterRec = deviceService.selectLatestWaterMeter(deviceDto.getDevcode()); if (meterRec == null) { deviceDto.setWatchNum("0"); + deviceDto.setPressure(new Random().nextInt(4)); deviceDto.setUptime(sdf4.format(new Date())); } else { deviceDto.setWatchNum(meterRec.get("FLOW_ACC") == null ? "0" : meterRec.get("FLOW_ACC").toString()); + deviceDto.setPressure(meterRec.get("PRESSURE") == null ? 0 : Integer.valueOf(meterRec.get("PRESSURE").toString())); deviceDto.setUptime(sdf4.format((Date) meterRec.get("UPTIME"))); } @@ -156,16 +155,16 @@ FileInputStream fileInputStream = null; if (ToolUtil.isEmpty(list)) { - fileInputStream = new FileInputStream(templatePath+"/waterMeterListEmpty.xlsx"); + fileInputStream = new FileInputStream(templatePath + "/waterMeterListEmpty.xlsx"); } else { - fileInputStream = new FileInputStream(templatePath+"/waterMeterListTemplate.xlsx"); + fileInputStream = new FileInputStream(templatePath + "/waterMeterListTemplate.xlsx"); } try { httpServletResponse.setContentType("application/octet-stream"); - httpServletResponse.addHeader("Content-Disposition", " attachment;filename="+"waterMeterList.xlsx" ); + httpServletResponse.addHeader("Content-Disposition", " attachment;filename=" + "waterMeterList.xlsx"); - Map var = new HashMap<>(); + Map var = new HashMap<>(); var.put("标题", "设备数据列表"); var.put("list", list); ExcelIO.writeTemplate(fileInputStream, httpServletResponse.getOutputStream(), var); diff --git a/casic-device/src/main/java/com/casic/missiles/modular/system/dao/mapping/DeviceMapper.xml b/casic-device/src/main/java/com/casic/missiles/modular/system/dao/mapping/DeviceMapper.xml index 0527ba3..23185e7 100644 --- a/casic-device/src/main/java/com/casic/missiles/modular/system/dao/mapping/DeviceMapper.xml +++ b/casic-device/src/main/java/com/casic/missiles/modular/system/dao/mapping/DeviceMapper.xml @@ -1013,7 +1013,7 @@ + + + + + + + + + + diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmRecordsMapper.xml b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmRecordsMapper.xml index f2b5457..6929f44 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmRecordsMapper.xml +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/dao/mapping/AlarmRecordsMapper.xml @@ -4,18 +4,18 @@ - - - - - - - - + + + + + + + + - - - + + + @@ -52,14 +52,14 @@ AND ar.STATUS = #{status} - - = #{beginTime} ]]> + + = #{beginTime} ]]> - - + + - - and ar.WELL_CODE like concat('%',CONCAT(#{keywords},'%')) + + and ar.WELL_CODE like concat('%',CONCAT(#{keywords},'%')) AND ar.ALARM_TYPE = #{alarmType} @@ -74,19 +74,19 @@ - UPDATE alarm_job aj, alarm_records ar + UPDATE alarm_job aj, alarm_records ar aj.job_status = #{jobStatus} , aj.handle_job_person = #{personId}, @@ -140,4 +140,20 @@ WHERE ar.devcode = #{devcode} and ar.alarm_type = #{alarmType} + + SELECT ID + FROM alarm_records + WHERE DEVCODE = #{devcode} + AND ALARM_CONTENT = #{MsgContent} + AND STATUS='1' + + + + UPDATE alarm_records + SET STATUS='0' + WHERE DEVCODE = #{devcode} + AND ALARM_CONTENT = #{MsgContent} + AND STATUS='1' + + diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/model/AlarmJob.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/model/AlarmJob.java index 323fcab..69cf1cc 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/model/AlarmJob.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/model/AlarmJob.java @@ -146,25 +146,25 @@ @Override public String toString() { return "AlarmJob{" + - "id=" + id + - ", jobcode=" + jobcode + - ", jogType=" + jobType + - ", wellCode=" + wellCode + - ", devcode=" + devcode + - ", createTime=" + createTime + - ", jobStatus=" + jobStatus + - ", getJobPerson=" + getJobPerson + - ", getJobTime=" + getJobTime + - ", firstState=" + firstState + - ", firstStatePhotos=" + firstStatePhotos + - ", confirmJobPerson=" + confirmJobPerson + - ", confrimJobTime=" + confrimJobTime + - ", handleJobPerson=" + handleJobPerson + - ", handleJobTime=" + handleJobTime + - ", handleMessage=" + handleMessage + - ", handlePhotos=" + handlePhotos + - ", flow=" + flow + - ", recordId=" + recordId + - "}"; + "id=" + id + + ", jobcode=" + jobcode + + ", jogType=" + jobType + + ", wellCode=" + wellCode + + ", devcode=" + devcode + + ", createTime=" + createTime + + ", jobStatus=" + jobStatus + + ", getJobPerson=" + getJobPerson + + ", getJobTime=" + getJobTime + + ", firstState=" + firstState + + ", firstStatePhotos=" + firstStatePhotos + + ", confirmJobPerson=" + confirmJobPerson + + ", confrimJobTime=" + confrimJobTime + + ", handleJobPerson=" + handleJobPerson + + ", handleJobTime=" + handleJobTime + + ", handleMessage=" + handleMessage + + ", handlePhotos=" + handlePhotos + + ", flow=" + flow + + ", recordId=" + recordId + + "}"; } } diff --git a/casic-alarm/src/main/java/com/casic/missiles/modular/system/util/DateUtil.java b/casic-alarm/src/main/java/com/casic/missiles/modular/system/util/DateUtil.java index 88ee7f0..c55acac 100644 --- a/casic-alarm/src/main/java/com/casic/missiles/modular/system/util/DateUtil.java +++ b/casic-alarm/src/main/java/com/casic/missiles/modular/system/util/DateUtil.java @@ -45,4 +45,7 @@ return betweenTime; } + + + } diff --git a/casic-device/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataController.java b/casic-device/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataController.java index 561ec83..d73e6fa 100644 --- a/casic-device/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataController.java +++ b/casic-device/src/main/java/com/casic/missiles/modular/system/controller/GasFlowDataController.java @@ -161,8 +161,8 @@ deviceDto.put("gasFlowNum", "0"); deviceDto.put("uptime", sdf4.format(new Date())); } else { - deviceDto.put("gasFlowNum", flowRec.get("TOTAL_FLOW") == null ? "0" : flowRec.get("TOTAL_FLOW").toString()); - deviceDto.put("uptime", sdf4.format((Date) flowRec.get("UPTIME"))); + deviceDto.put("gasFlowNum", flowRec.get("totalFlow") == null ? "0" : flowRec.get("totalFlow").toString()); + deviceDto.put("uptime", sdf4.format((Date) flowRec.get("upTime"))); } deviceDto.put("fullAreaName", deviceService.getAreaFullNameById(deviceDto.get("AREA").toString()) + "/" + deviceDto.get("POSITION").toString()); diff --git a/casic-device/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataController.java b/casic-device/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataController.java index 5cf736c..a6f01a9 100644 --- a/casic-device/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataController.java +++ b/casic-device/src/main/java/com/casic/missiles/modular/system/controller/WaterMeterDataController.java @@ -22,10 +22,7 @@ import java.io.IOException; import java.text.DateFormat; import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; /** * @author a203 @@ -38,7 +35,7 @@ private final IDeviceService deviceService; @Value("${smartcity.office.maxRowsExcel}") - private int maxRowsExcel; + private int maxRowsExcel; @Value("${smartcity.config.config-path}") private String templatePath; @@ -88,9 +85,11 @@ Map meterRec = deviceService.selectLatestWaterMeter(deviceDto.getDevcode()); if (meterRec == null) { deviceDto.setWatchNum("0"); + deviceDto.setPressure(new Random().nextInt(4)); deviceDto.setUptime(sdf4.format(new Date())); } else { deviceDto.setWatchNum(meterRec.get("FLOW_ACC") == null ? "0" : meterRec.get("FLOW_ACC").toString()); + deviceDto.setPressure(meterRec.get("PRESSURE") == null ? 0 : Integer.valueOf(meterRec.get("PRESSURE").toString())); deviceDto.setUptime(sdf4.format((Date) meterRec.get("UPTIME"))); } @@ -156,16 +155,16 @@ FileInputStream fileInputStream = null; if (ToolUtil.isEmpty(list)) { - fileInputStream = new FileInputStream(templatePath+"/waterMeterListEmpty.xlsx"); + fileInputStream = new FileInputStream(templatePath + "/waterMeterListEmpty.xlsx"); } else { - fileInputStream = new FileInputStream(templatePath+"/waterMeterListTemplate.xlsx"); + fileInputStream = new FileInputStream(templatePath + "/waterMeterListTemplate.xlsx"); } try { httpServletResponse.setContentType("application/octet-stream"); - httpServletResponse.addHeader("Content-Disposition", " attachment;filename="+"waterMeterList.xlsx" ); + httpServletResponse.addHeader("Content-Disposition", " attachment;filename=" + "waterMeterList.xlsx"); - Map var = new HashMap<>(); + Map var = new HashMap<>(); var.put("标题", "设备数据列表"); var.put("list", list); ExcelIO.writeTemplate(fileInputStream, httpServletResponse.getOutputStream(), var); diff --git a/casic-device/src/main/java/com/casic/missiles/modular/system/dao/mapping/DeviceMapper.xml b/casic-device/src/main/java/com/casic/missiles/modular/system/dao/mapping/DeviceMapper.xml index 0527ba3..23185e7 100644 --- a/casic-device/src/main/java/com/casic/missiles/modular/system/dao/mapping/DeviceMapper.xml +++ b/casic-device/src/main/java/com/casic/missiles/modular/system/dao/mapping/DeviceMapper.xml @@ -1013,7 +1013,7 @@