| | |
| | | package com.doumee.service.business.impl; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.doumee.biz.system.SystemDictDataBiz; |
| | | import com.doumee.core.constants.Constants; |
| | | import com.doumee.core.constants.ResponseStatus; |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.core.model.PageData; |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.core.utils.Utils; |
| | | import com.doumee.dao.business.WorkorderMapper; |
| | | import com.doumee.dao.business.model.Workorder; |
| | | import com.doumee.dao.business.*; |
| | | import com.doumee.dao.business.model.*; |
| | | import com.doumee.service.business.WorkorderService; |
| | | 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.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import org.apache.catalina.Manager; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 工单信息表Service实现 |
| | |
| | | @Autowired |
| | | private WorkorderMapper workorderMapper; |
| | | |
| | | @Autowired |
| | | private MultifileMapper multifileMapper; |
| | | |
| | | @Autowired |
| | | private WorkorderLogMapper workorderLogMapper; |
| | | |
| | | @Autowired |
| | | private SystemDictDataBiz systemDictDataBiz; |
| | | |
| | | @Autowired |
| | | private MemberMapper memberMapper; |
| | | |
| | | @Autowired |
| | | private ManagersMapper managersMapper; |
| | | |
| | | @Override |
| | | public Integer create(Workorder workorder) { |
| | | this.isValidBaseParam(workorder); |
| | | workorder.setCreateDate(new Date()); |
| | | workorder.setEditDate(new Date()); |
| | | workorder.setMemberId(workorder.getMemberId()); |
| | | workorder.setIsdeleted(Constants.ZERO); |
| | | workorder.setStatus(Constants.ZERO); |
| | | //跌绊滑事件上报 查询SHE负责人 |
| | | if(Constants.equalsInteger(workorder.getType(),Constants.THREE)){ |
| | | List<Managers> managersList = managersMapper.selectList(new QueryWrapper<Managers>().lambda().eq(Managers::getIsdeleted,Constants.ZERO) |
| | | .eq(Managers::getType,Constants.ZERO).orderByAsc(Managers::getSortnum) |
| | | ); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(managersList)){ |
| | | workorder.setQwnoticeMemberIds(managersList.stream().map(i->i.getMemberId().toString()).collect(Collectors.joining(","))); |
| | | } |
| | | } |
| | | workorderMapper.insert(workorder); |
| | | //存储附件信息 |
| | | List<Multifile> multifileList = workorder.getMultifileList(); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(multifileList)){ |
| | | for (Multifile multifile:multifileList) { |
| | | multifile.setObjId(workorder.getId()); |
| | | multifile.setCreateDate(new Date()); |
| | | //TODO 后续整理处理 |
| | | if(Constants.equalsInteger(workorder.getType(),Constants.ZERO)){//SHE事件上报图片 |
| | | multifile.setObjType(Constants.ZERO); |
| | | }else if(Constants.equalsInteger(workorder.getType(),Constants.THREE)){//跌绊滑事件上报图片 |
| | | multifile.setObjType(Constants.ONE); |
| | | } |
| | | } |
| | | multifileMapper.insert(multifileList); |
| | | } |
| | | //处理上报日志 |
| | | this.saveLog(null,workorder,Constants.ZERO,workorder.getMemberId()); |
| | | return workorder.getId(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * |
| | | * @param beforeJson |
| | | * @param afterWorkorder |
| | | * @param objType 操作类型 0任务上报 1任务确认 2任务分配物业主管 3任务关闭 4任务分配处理人 5任务催促 |
| | | * @param memberId |
| | | */ |
| | | public void saveLog(String beforeJson,Workorder afterWorkorder,Integer objType,Integer memberId){ |
| | | WorkorderLog workorderLog = new WorkorderLog(); |
| | | workorderLog.setCreateDate(new Date()); |
| | | workorderLog.setEditDate(new Date()); |
| | | workorderLog.setIsdeleted(Constants.ZERO); |
| | | workorderLog.setBeforeContent(beforeJson); |
| | | workorderLog.setAfterContent(JSONObject.toJSONString(afterWorkorder)); |
| | | workorderLog.setParam1(memberId.toString()); |
| | | workorderLog.setObjId(afterWorkorder.getId().toString()); |
| | | workorderLog.setObjType(objType); |
| | | workorderLogMapper.insert(workorderLog); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 数据校验 |
| | | * @param workorder |
| | | */ |
| | | public void isValidBaseParam(Workorder workorder){ |
| | | if(Objects.isNull(workorder) |
| | | || Objects.isNull(workorder.getSubmitDate()) |
| | | || Objects.isNull(workorder.getHappenTime()) |
| | | || Objects.isNull(workorder.getType()) |
| | | || !( Constants.equalsInteger(workorder.getType(),Constants.ZERO) || Constants.equalsInteger(workorder.getType(),Constants.ONE) |
| | | || Constants.equalsInteger(workorder.getType(),Constants.TWO) || Constants.equalsInteger(workorder.getType(),Constants.THREE) |
| | | )){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | //SHE 事件上报 |
| | | if(Constants.equalsInteger(workorder.getType(),Constants.ZERO)){ |
| | | if(Objects.isNull(workorder.getMemberType()) |
| | | || Objects.isNull(workorder.getLocaltionId()) |
| | | || Objects.isNull(workorder.getOutJiuyi()) |
| | | || (Constants.equalsInteger(workorder.getOutJiuyi(),Constants.ZERO) && Objects.isNull(workorder.getIsYiwushi())) |
| | | || (Constants.equalsInteger(workorder.getIsYiwushi(),Constants.ZERO) && Objects.isNull(workorder.getIsHurted())) |
| | | || Objects.isNull(workorder.getCategoryId()) |
| | | || Objects.isNull(workorder.getWorkRelated()) |
| | | || (Constants.equalsInteger(workorder.getMemberType(),Constants.TWO) && StringUtils.isEmpty(workorder.getMemberNames())) |
| | | || (Constants.equalsInteger(workorder.getMemberType(),Constants.ZERO) && StringUtils.isEmpty(workorder.getMemberQwids())) |
| | | || org.apache.commons.lang3.StringUtils.isBlank(workorder.getEventInfo()) |
| | | ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | } |
| | | //跌绊滑 事件上报 |
| | | if(Constants.equalsInteger(workorder.getType(),Constants.THREE)){ |
| | | if(Objects.isNull(workorder.getTypeId()) |
| | | || Objects.isNull(workorder.getLocaltionId()) |
| | | || org.apache.commons.lang3.StringUtils.isBlank(workorder.getEventInfo()) |
| | | ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public Workorder getDetail(Integer id){ |
| | | Workorder workorder = workorderMapper.selectJoinOne(Workorder.class, |
| | | new MPJLambdaWrapper<Workorder>() |
| | | .selectAll(Workorder.class) |
| | | .selectAs(Member::getName,Workorder::getMemberName) |
| | | .selectAs(Company::getNamePath,Workorder::getCompanyName) |
| | | .select(" c1.name ",Workorder::getHurtTypeName) |
| | | .select(" c2.name ",Workorder::getLocationTypeName) |
| | | .select(" c3.name ",Workorder::getTypeName) |
| | | .select(" c4.name ",Workorder::getProblemName) |
| | | .leftJoin(Member.class,Member::getId,Workorder::getMemberId) |
| | | .leftJoin(Company.class,Company::getId,Member::getCompanyId) |
| | | .leftJoin(" category c1 on t.CATEGORY_ID = c1.id ") //受伤类别 |
| | | .leftJoin(" category c2 on t.LOCALTION_ID = c2.id ") //发生地点 |
| | | .leftJoin(" category c3 on t.TYPE_ID = c3.id ") //风险类型 |
| | | .leftJoin(" category c4 on t.PROBLEM_ID = c4.id ") //DCA问题编码 |
| | | .eq(Workorder::getId,id) |
| | | .last(" limit 1 ") |
| | | ); |
| | | if(Objects.nonNull(workorder)){ |
| | | //如果是SHE事件上报 SHE涉及人员类型为同事信息 需要查询同事名称 |
| | | if(Constants.equalsInteger(workorder.getType(),Constants.ZERO)&&Constants.equalsInteger(workorder.getMemberType(),Constants.ONE)){ |
| | | List<Member> memberList = memberMapper.selectList(new QueryWrapper<Member>().lambda().eq(Member::getIsdeleted,Constants.ZERO).in(Member::getQwId, Arrays.asList(workorder.getMemberQwids().split(",")))); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(memberList)){ |
| | | workorder.setColleague(memberList.stream().map(i->i.getName()).collect(Collectors.joining(","))); |
| | | } |
| | | } |
| | | //查询附件信息 |
| | | List<Multifile> multifileList = multifileMapper.selectList(new QueryWrapper<Multifile>().lambda().eq(Multifile::getIsdeleted,Constants.ZERO) |
| | | .eq(Multifile::getObjId,workorder).orderByAsc(Multifile::getId)); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(multifileList)){ |
| | | String path = systemDictDataBiz.queryByCode(Constants.FTP,Constants.FTP_RESOURCE_PATH).getCode() |
| | | +systemDictDataBiz.queryByCode(Constants.FTP,Constants.WORKORDER_FILE_PATH).getCode(); |
| | | for (Multifile multifile:multifileList) { |
| | | multifile.setFileurlFull(path+multifile.getFileurl()); |
| | | } |
| | | workorder.setMultifileList(multifileList); |
| | | } |
| | | } |
| | | |
| | | |
| | | return workorder; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public void deleteById(Integer id) { |
| | |
| | | QueryWrapper<Workorder> wrapper = new QueryWrapper<>(workorder); |
| | | return workorderMapper.selectCount(wrapper); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |