package com.newfiber.api.pc.service.impl; import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.baomidou.mybatisplus.service.impl.ServiceImpl; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.newfiber.api.core.bean.RespBodyObj; import com.newfiber.api.core.utils.UUIDPK; import com.newfiber.api.pc.dao.EventsManage.ComplainPicDao; import com.newfiber.api.pc.dao.EventsManage.ComplaintProcessMapper; import com.newfiber.api.pc.model.EventsManage.ComplainPic; import com.newfiber.api.pc.model.EventsManage.ComplaintProcess; import com.newfiber.api.pc.model.EventsManage.ComplaintTask; import com.newfiber.api.pc.model.EventsManage.ComplaintTaskProcessDto; import com.newfiber.api.pc.service.ComplaintProcessService; import com.newfiber.api.pc.service.ComplaintTaskService; import com.newfiber.api.pc.service.ComplaintUserStateService; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.StringUtils; import java.util.List; @Service("complaintProcessService") public class ComplaintProcessServiceImpl extends ServiceImpl<ComplaintProcessMapper, ComplaintProcess> implements ComplaintProcessService { @Autowired private ComplaintProcessMapper complaintProcessMapper; @Autowired private ComplaintTaskService complaintTaskService; @Autowired private ComplainPicDao complainPicDao; @Autowired private ComplaintUserStateService complaintUserStateService; @Override public PageInfo<ComplaintProcess> listForPage(String searchStr, Integer pageNo, Integer pageSize) { PageHelper.startPage(pageNo, pageSize); EntityWrapper<ComplaintProcess> wapper = new EntityWrapper<>(); //name 模糊匹配的字段 wapper.like("name", searchStr); List<ComplaintProcess> list = complaintProcessMapper.selectList(wapper); PageInfo<ComplaintProcess> result = new PageInfo<>(); if (!list.isEmpty()) { result = new PageInfo<ComplaintProcess>(list); } return result; } /** * 流程操作 * @param param * @param state * @param stateDesc * @param operationNo * @param nextNo */ public void setProcess(ComplaintTaskProcessDto param, Integer state, String stateDesc,String processDesc, String operationNo, String nextNo) { //1.修改任务状态 ComplaintTask task = new ComplaintTask(); BeanUtils.copyProperties(param, task); task.setId(param.getId()); task.setState(state); task.setStateDesc(stateDesc); complaintTaskService.updateById(task); //2.保存流程信息 if (param.getComplainProcessPics() != null) { saveProcessImg(param); } ComplaintProcess process = new ComplaintProcess(); process.setComplaintType(param.getComplaintType()); process.setComplaintTaskId(param.getId()); process.setOperationUserNo(operationNo); process.setNextUserNo(nextNo); process.setDescription(param.getProcessDesc()); if (!StringUtils.isEmpty(param.getComplainProcessPics()) && param.getComplainProcessPics().size()>0 && param.getComplainProcessPics().get(0).getEventsNo()!=null) { process.setPicNo(param.getComplainProcessPics().get(0).getEventsNo()); } process.setState(state.toString()); process.setStateDesc(processDesc); this.insert(process); //3.创建或保存人员状态 complaintUserStateService.addOrUpdateUserState(param.getId(), param.getComplaintType(), operationNo, 2); if (!StringUtils.isEmpty(nextNo)) { complaintUserStateService.addOrUpdateUserState(param.getId(), param.getComplaintType(), nextNo, 1); } } //1.指派验证 //2.第一次验证操作 //3.不验证直接指派处理人操作 //4.处理人提交任务 //5.指派验证人 //6.验证人提交 //7.审核人通过或者驳回 @Override @Transactional(rollbackFor = Exception.class) public RespBodyObj appointCheck(ComplaintTaskProcessDto param) { //是否需要验证 if (param != null && param.getIsCheck() == 1) {//验证流程 setProcess(param, 2, "待验证","待验证", param.getLeaderNo(), param.getCheckComplaintNo()); } else { setProcess(param, 4, "待处理","待处理", param.getLeaderNo(), param.getHandlerNo()); } return RespBodyObj.ok(); } @Override @Transactional(rollbackFor = Exception.class) public RespBodyObj checkComplaint(ComplaintTaskProcessDto param) { setProcess(param, 3, "已验证",StringUtils.isEmpty(param.getCheckComplaintName())?"":param.getCheckComplaintName()+"已验证", param.getCheckComplaintNo(), param.getLeaderNo()); return RespBodyObj.ok(); } @Override @Transactional(rollbackFor = Exception.class) public RespBodyObj appointHandle(ComplaintTaskProcessDto param) { setProcess(param, 4, "待处理","待处理", param.getLeaderNo(), param.getHandlerNo()); return RespBodyObj.ok(); } @Override @Transactional(rollbackFor = Exception.class) public RespBodyObj handleComplaint(ComplaintTaskProcessDto param) { complaintUserStateService.addOrUpdateUserState(param.getId(), param.getComplaintType(), param.getCheckComplaintNo(), 2); complaintUserStateService.addOrUpdateUserState(param.getId(), param.getComplaintType(), param.getHandlerNo(), 2); setProcess(param, 5, "已处理",param.getHandlerName()+"已处理", param.getHandlerNo(), param.getLeaderNo()); return RespBodyObj.ok(); } @Override @Transactional(rollbackFor = Exception.class) public RespBodyObj appointComplaintHandle(ComplaintTaskProcessDto param) { setProcess(param, 6, "已指派",param.getLeaderName()+"指派给"+param.getCheckHandleName()+"验证", param.getLeaderNo(), param.getCheckHandleNo()); return RespBodyObj.ok(); } @Override @Transactional(rollbackFor = Exception.class) public RespBodyObj handleCheck(ComplaintTaskProcessDto param) { setProcess(param, 7, "已验证",param.getCheckHandleName()+"验证提交", param.getCheckHandleNo(), param.getLeaderNo()); return RespBodyObj.ok(); } @Override @Transactional(rollbackFor = Exception.class) public RespBodyObj pass(ComplaintTaskProcessDto param) { setProcess(param, 8, "完成",param.getLeaderName()+"完结投诉事件", param.getLeaderNo(), null); return RespBodyObj.ok(); } @Override @Transactional(rollbackFor = Exception.class) public RespBodyObj refuse(ComplaintTaskProcessDto param) { //1.修改任务状态 setProcess(param, 4, "驳回",param.getLeaderName()+"驳回给"+param.getHandlerName(), param.getLeaderNo(), param.getHandlerNo()); return RespBodyObj.ok(); } /** * 保存图片 * * @param process */ private String saveProcessImg(ComplaintTaskProcessDto process) { String picNo=null; if (process.getComplainProcessPics() != null && process.getComplainProcessPics().size() > 0) { List<ComplainPic> pics = process.getComplainProcessPics(); picNo = UUIDPK.UUIDGenerator.getUUID(); process.setPicNo(picNo); for (ComplainPic pic : pics) { pic.setEventsNo(picNo); pic.setPicType(process.getComplaintType()); pic.setPicTypeName(process.getComplaintName()); } complainPicDao.insertBatch(pics); } return picNo; } }