| | |
| | | package com.doumee.service.business.impl; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | |
| | | import com.doumee.core.model.PageData; |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.core.utils.DateUtil; |
| | | import com.doumee.core.utils.Utils; |
| | | import com.doumee.dao.business.HiddenDangerLogMapper; |
| | | import com.doumee.dao.business.HiddenDangerMapper; |
| | |
| | | import com.doumee.dao.business.MemberMapper; |
| | | import com.doumee.dao.business.model.*; |
| | | import com.doumee.dao.system.MultifileMapper; |
| | | import com.doumee.dao.system.join.NoticesJoinMapper; |
| | | import com.doumee.dao.system.model.Multifile; |
| | | import com.doumee.dao.system.model.Notices; |
| | | import com.doumee.service.business.HiddenDangerLogService; |
| | | import com.doumee.service.business.HiddenDangerService; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.checkerframework.checker.units.qual.C; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | |
| | | private HiddenDangerLogMapper hiddenDangerLogMapper; |
| | | |
| | | |
| | | @Autowired |
| | | private NoticesJoinMapper noticesJoinMapper; |
| | | |
| | | @Override |
| | | public Integer create(HiddenDanger hiddenDanger) { |
| | | if(Objects.isNull(hiddenDanger) |
| | |
| | | ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | hiddenDanger.setMemberId(hiddenDanger.getLoginUserInfo().getMemberId()); |
| | | hiddenDanger.setIsdeleted(Constants.ZERO); |
| | | hiddenDanger.setCreateDate(new Date()); |
| | | hiddenDanger.setEditDate(new Date()); |
| | | HiddenDangerParam hiddenDangerParam = hiddenDangerParamMapper.selectById(hiddenDanger.getAreaId()); |
| | | if(Objects.isNull(hiddenDangerParam)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到隐患区域"); |
| | | } |
| | | HiddenDangerParam hiddenDangerCate = hiddenDangerParamMapper.selectById(hiddenDanger.getCateId()); |
| | | if(Objects.isNull(hiddenDangerCate)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到隐患类型"); |
| | | } |
| | | hiddenDanger.setCreator(hiddenDanger.getLoginUserInfo().getId()); |
| | | hiddenDanger.setAreaName(hiddenDangerParam.getName()); |
| | |
| | | hiddenDangerLog.setObjType(Constants.ZERO); |
| | | hiddenDangerLogMapper.insert(hiddenDangerLog); |
| | | |
| | | List<Multifile> multifiles = hiddenDanger.getMultifileList(); |
| | | List<Multifile> multifiles = hiddenDanger.getSubmitFileList(); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(multifiles)){ |
| | | for (int i = 0; i < multifiles.size(); i++) { |
| | | Multifile multifile = multifiles.get(i); |
| | |
| | | multifile.setCreator(hiddenDanger.getCreator()); |
| | | multifile.setIsdeleted(Constants.ZERO); |
| | | multifile.setObjId(hiddenDanger.getId()); |
| | | multifile.setObjType(Constants.multifileObjType.zero); |
| | | multifile.setObjType(Constants.MultiFile.HIDDEN_DANGER_SUBMIT.getKey()); |
| | | multifile.setSortnum(i+1); |
| | | multifileMapper.insert(multifile); |
| | | } |
| | | } |
| | | String title = "[隐患随手拍]提报人-"+hiddenDanger.getLoginUserInfo().getRealname(); |
| | | //json数据 |
| | | Map<String,Object> jsonMap = new HashMap<>(); |
| | | jsonMap.put("area", "发现区域:" + hiddenDangerParam.getName()); |
| | | jsonMap.put("cate", "隐患类型:" + hiddenDangerCate.getName()); |
| | | jsonMap.put("sTime", "发现时间:" + DateUtil.DateToStr(hiddenDanger.getSubmitTime() , "yyyy-MM-dd HH:mm")); |
| | | //默认生成一条 申请人的数据 标记删除状态用于处理到 任务中心(我发起)使用 |
| | | Notices createNotices = new Notices(); |
| | | createNotices.setCreateDate(new Date()); |
| | | createNotices.setIsdeleted(Constants.ONE); |
| | | createNotices.setObjId(hiddenDanger.getId()); |
| | | createNotices.setObjType(Constants.THREE); |
| | | createNotices.setType(Constants.THREE); |
| | | createNotices.setTitle(title); |
| | | createNotices.setParam1(JSONObject.toJSONString(jsonMap)); |
| | | createNotices.setStatus(Constants.ZERO); |
| | | createNotices.setReaded(Constants.ZERO); |
| | | createNotices.setSendacopy(Constants.ZERO); |
| | | createNotices.setParam2("0"); |
| | | createNotices.setParam3(hiddenDanger.getLoginUserInfo().getMemberId().toString()); |
| | | createNotices.setInfo("处理中"); |
| | | noticesJoinMapper.insert(createNotices); |
| | | |
| | | //存储处理人的通知消息 |
| | | Notices notices = new Notices(); |
| | | notices.setId(null); |
| | | notices.setCreateDate(new Date()); |
| | | notices.setIsdeleted(Constants.ZERO); |
| | | notices.setTitle(title); |
| | | notices.setParam1(JSONObject.toJSONString(jsonMap)); |
| | | notices.setParam2("0"); |
| | | notices.setObjId(hiddenDanger.getId()); |
| | | notices.setObjType(Constants.THREE); |
| | | notices.setType(Constants.THREE); |
| | | notices.setEditDate(new Date()); |
| | | notices.setUserId(hiddenDanger.getCheckUserId()); |
| | | notices.setStatus(Constants.ZERO); |
| | | notices.setSendacopy(Constants.ZERO); |
| | | notices.setReaded(Constants.ZERO); |
| | | noticesJoinMapper.insert(notices); |
| | | |
| | | |
| | | return hiddenDanger.getId(); |
| | |
| | | .eq(pageWrap.getModel().getMemberId() != null, HiddenDanger::getMemberId, pageWrap.getModel().getMemberId()) |
| | | .ge(pageWrap.getModel().getCheckDate() != null, HiddenDanger::getCheckDate, Utils.Date.getStart(pageWrap.getModel().getCheckDate())) |
| | | .le(pageWrap.getModel().getCheckDate() != null, HiddenDanger::getCheckDate, Utils.Date.getEnd(pageWrap.getModel().getCheckDate())) |
| | | .eq(pageWrap.getModel().getChecklInfo() != null, HiddenDanger::getChecklInfo, pageWrap.getModel().getChecklInfo()) |
| | | .eq(pageWrap.getModel().getCheckInfo() != null, HiddenDanger::getCheckInfo, pageWrap.getModel().getCheckInfo()) |
| | | .eq(pageWrap.getModel().getCheckUserId() != null, HiddenDanger::getCheckUserId, pageWrap.getModel().getCheckUserId()) |
| | | .eq(pageWrap.getModel().getAreaName() != null, HiddenDanger::getAreaName, pageWrap.getModel().getAreaName()) |
| | | |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class,BusinessException.class}) |
| | | public void dealHiddenDanger(HiddenDanger hiddenDanger){ |
| | | isParamValid(hiddenDanger); |
| | | dealFileBiz(hiddenDanger); |
| | | hiddenDanger.setEditor(hiddenDanger.getLoginUserInfo().getId()); |
| | | hiddenDanger.setEditDate(new Date()); |
| | | hiddenDanger.setCheckDate(hiddenDanger.getEditDate()); |
| | | hiddenDangerMapper.updateById(hiddenDanger); |
| | | //存储 操作日志 |
| | | HiddenDangerLog hiddenDangerLog = new HiddenDangerLog(); |
| | | hiddenDangerLog.setIsdeleted(Constants.ZERO); |
| | | hiddenDangerLog.setCreateDate(new Date()); |
| | | hiddenDangerLog.setCreator(hiddenDanger.getEditor()); |
| | | hiddenDangerLog.setHiddenDangerId(hiddenDanger.getId()); |
| | | hiddenDangerLog.setContent(hiddenDanger.getCheckInfo()); |
| | | hiddenDangerLog.setTitle(hiddenDanger.getStatus().equals(Constants.ONE)?"隐患处理":"隐患退回"); |
| | | hiddenDangerLog.setObjType(hiddenDanger.getStatus().equals(Constants.ONE)?Constants.FOUR:Constants.TWO); |
| | | hiddenDangerLogMapper.insert(hiddenDangerLog); |
| | | //处理待办信息 |
| | | noticesJoinMapper.update(null,new UpdateWrapper<Notices>() |
| | | .lambda() |
| | | .set(Notices::getReaded,Constants.ONE) |
| | | .set(Notices::getStatus,Constants.ONE) |
| | | .set(Notices::getParam2,hiddenDanger.getStatus()) |
| | | .eq(Notices::getObjId,hiddenDanger.getId()) |
| | | .eq(Notices::getObjType,Constants.THREE) |
| | | .eq(Notices::getUserId,hiddenDanger.getLoginUserInfo().getMemberId()) |
| | | ); |
| | | |
| | | } |
| | | |
| | | private void isParamValid(HiddenDanger hiddenDanger) { |
| | | if(Objects.isNull(hiddenDanger) |
| | | || Objects.isNull(hiddenDanger.getId()) |
| | | || Objects.isNull(hiddenDanger.getDealTime()) |
| | | || Objects.isNull(hiddenDanger.getLoginUserInfo()) |
| | | || Objects.isNull(hiddenDanger.getStatus()) |
| | | ){ |
| | | || Objects.isNull(hiddenDanger.getId()) |
| | | || Objects.isNull(hiddenDanger.getDealTime()) |
| | | || Objects.isNull(hiddenDanger.getLoginUserInfo()) |
| | | || Objects.isNull(hiddenDanger.getStatus()) |
| | | ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | HiddenDanger model = hiddenDangerMapper.selectById(hiddenDanger.getId()); |
| | |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到隐患数据"); |
| | | } |
| | | if (!model.getStatus().equals(Constants.ZERO)) { |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"数据状态已流转!"); |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"数据状态已流转,请刷新查看!"); |
| | | } |
| | | if (!model.getCheckUserId().equals(hiddenDanger.getEditor())) { |
| | | if (!model.getCheckUserId().equals(hiddenDanger.getLoginUserInfo().getMemberId())) { |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"处理人非当前人员!"); |
| | | } |
| | | if(!(hiddenDanger.getStatus().equals(Constants.ONE)||hiddenDanger.getStatus().equals(Constants.TWO))){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"数据状态错误!"); |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"数据状态错误,请刷新查看!"); |
| | | } |
| | | //整改前文件 |
| | | } |
| | | |
| | | private void dealFileBiz(HiddenDanger hiddenDanger) {//整改前文件 |
| | | List<Multifile> beforList = hiddenDanger.getDealBeforeFileList(); |
| | | List<Multifile> fileList = new ArrayList<>(); |
| | | |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(beforList)){ |
| | | boolean isTrue = false; |
| | | for (int i = 0; i < beforList.size(); i++) { |
| | | Multifile multifile = beforList.get(i); |
| | | if(StringUtils.isBlank(multifile.getFileurl())){ |
| | | continue; |
| | | } |
| | | multifile.setCreateDate(new Date()); |
| | | multifile.setCreator(hiddenDanger.getEditor()); |
| | | multifile.setIsdeleted(Constants.ZERO); |
| | | multifile.setObjId(hiddenDanger.getId()); |
| | | multifile.setObjType(Constants.multifileObjType.one); |
| | | multifile.setCreator(hiddenDanger.getLoginUserInfo().getId()); |
| | | multifile.setObjType(Constants.MultiFile.HIDDEN_DANGER_DEAL_BEFORE.getKey()); |
| | | multifile.setSortnum(i+1); |
| | | multifileMapper.insert(multifile); |
| | | fileList.add(multifile); |
| | | isTrue=true; |
| | | } |
| | | if(hiddenDanger.getStatus().equals(Constants.ONE) && !isTrue){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,请按要求填写处理数据"); |
| | | } |
| | | } |
| | | if(hiddenDanger.getStatus().equals(Constants.ONE)){ |
| | | boolean isTrue = false; |
| | | List<Multifile> afterList = hiddenDanger.getDealAfterFileList(); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(afterList)){ |
| | | for (int i = 0; i < afterList.size(); i++) { |
| | | Multifile multifile = afterList.get(i); |
| | | if(StringUtils.isBlank(multifile.getFileurl())){ |
| | | continue; |
| | | } |
| | | multifile.setCreateDate(new Date()); |
| | | multifile.setCreator(hiddenDanger.getEditor()); |
| | | multifile.setIsdeleted(Constants.ZERO); |
| | | multifile.setCreator(hiddenDanger.getLoginUserInfo().getId()); |
| | | multifile.setObjId(hiddenDanger.getId()); |
| | | multifile.setObjType(Constants.multifileObjType.two); |
| | | multifile.setObjType(Constants.MultiFile.HIDDEN_DANGER_DEAL_AFTER.getKey()); |
| | | multifile.setSortnum(i+1); |
| | | multifileMapper.insert(multifile); |
| | | fileList.add(multifile); |
| | | isTrue = true; |
| | | } |
| | | } |
| | | if(!isTrue){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,请按要求填写处理数据"); |
| | | } |
| | | } |
| | | hiddenDanger.setEditor(hiddenDanger.getLoginUserInfo().getId()); |
| | | hiddenDanger.setEditDate(new Date()); |
| | | hiddenDangerMapper.updateById(hiddenDanger); |
| | | //存储 操作日志 |
| | | HiddenDangerLog hiddenDangerLog = new HiddenDangerLog(); |
| | | hiddenDangerLog.setIsdeleted(Constants.ZERO); |
| | | hiddenDangerLog.setCreateDate(new Date()); |
| | | hiddenDangerLog.setCreator(hiddenDanger.getCreator()); |
| | | hiddenDangerLog.setHiddenDangerId(hiddenDanger.getId()); |
| | | hiddenDangerLog.setTitle(hiddenDanger.getStatus().equals(Constants.ONE)?"隐患处理":"隐患退回"); |
| | | hiddenDangerLog.setObjType(hiddenDanger.getStatus().equals(Constants.ONE)?Constants.FOUR:Constants.TWO); |
| | | hiddenDangerLogMapper.insert(hiddenDangerLog); |
| | | if(fileList.size()>0){ |
| | | multifileMapper.insertBatchSomeColumn(fileList); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到隐患数据"); |
| | | } |
| | | if (!Constants.equalsInteger(model.getStatus(),Constants.ZERO)) { |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"数据状态已流转!"); |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"数据状态已流转,请刷新查看!"); |
| | | } |
| | | if (!Constants.equalsInteger(model.getCheckUserId(),hiddenDanger.getLoginUserInfo().getMemberId())) { |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"处理人非当前人员!"); |
| | |
| | | hiddenDangerLog.setHiddenDangerId(hiddenDanger.getId()); |
| | | hiddenDangerLog.setObjType(Constants.ONE); |
| | | hiddenDangerLogMapper.insert(hiddenDangerLog); |
| | | Notices notices = noticesJoinMapper.selectOne(new QueryWrapper<Notices>() |
| | | .lambda() |
| | | .eq(Notices::getObjId,hiddenDanger.getId()) |
| | | .eq(Notices::getObjType,Constants.THREE) |
| | | .eq(Notices::getUserId,hiddenDanger.getLoginUserInfo().getMemberId()) |
| | | .last(" limit 1 ") |
| | | ); |
| | | if(Objects.nonNull(notices)){ |
| | | Notices newNotices = new Notices(); |
| | | BeanUtils.copyProperties(notices,newNotices); |
| | | newNotices.setId(null); |
| | | newNotices.setCreateDate(new Date()); |
| | | newNotices.setParam2("3"); |
| | | newNotices.setUserId(hiddenDanger.getCheckUserId()); |
| | | noticesJoinMapper.insert(newNotices); |
| | | notices.setStatus(Constants.ONE); |
| | | notices.setEditDate(new Date()); |
| | | notices.setReaded(Constants.ONE); |
| | | noticesJoinMapper.updateById(notices); |
| | | } |
| | | } |
| | | |
| | | |