| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.panzhihua.common.constants.ReturnMsgConstants; |
| | | import com.panzhihua.common.enums.SanShuoEventStatusEnum; |
| | | import com.panzhihua.common.model.vos.LoginUserInfoVO; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.sanshuo.*; |
| | | import com.panzhihua.common.utlis.CopyUtil; |
| | | import com.panzhihua.common.utlis.DateUtils; |
| | | import com.panzhihua.common.utlis.Snowflake; |
| | | import com.panzhihua.common.utlis.StringUtils; |
| | | import com.panzhihua.service_community.dao.ComActDAO; |
| | | import com.panzhihua.service_community.dao.ComEventMapper; |
| | | import com.panzhihua.service_community.entity.ComEvent; |
| | | import com.panzhihua.service_community.service.IComEventService; |
| | | import com.panzhihua.service_community.dao.ComStreetDAO; |
| | | import com.panzhihua.service_community.entity.*; |
| | | import com.panzhihua.service_community.model.dos.ComActDO; |
| | | import com.panzhihua.service_community.model.dos.ComStreetDO; |
| | | import com.panzhihua.service_community.service.*; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.RandomUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.Collections; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * Description 三说会堂事件表业务层实现类 |
| | |
| | | @Service("comEventService") |
| | | public class ComEventServiceImpl extends ServiceImpl<ComEventMapper, ComEvent> implements IComEventService { |
| | | |
| | | @Resource |
| | | private IComEventTransferRecordService comEventTransferRecordService; |
| | | |
| | | @Resource |
| | | private ComSanShuoExpertService comSanShuoExpertService; |
| | | |
| | | @Resource |
| | | private IComEventResourceService comEventResourceService; |
| | | |
| | | @Resource |
| | | private ComActDAO comActDAO; |
| | | |
| | | @Resource |
| | | private ComStreetDAO comStreetDAO; |
| | | |
| | | @Resource |
| | | private ComSanShuoIndustryCenterService comSanShuoIndustryCenterService; |
| | | |
| | | @Override |
| | | public R pageByComEvent(ComEvent comEvent, Page pagination) { |
| | | IPage<ComEvent> list = baseMapper.pageByComEvent(comEvent, pagination); |
| | | if (list.getRecords().size() < 1) { |
| | | return R.ok(Collections.emptyList()); |
| | | } |
| | | list.getRecords().forEach(comEvent1 -> { |
| | | List<ComEventResource> resourceList = comEventResourceService.list(new QueryWrapper<ComEventResource>().lambda().eq(ComEventResource::getRefId, comEvent1.getId())); |
| | | List<ComEventRequestImageVO> comEventRequestImageVO = CopyUtil.deepCopyListObject(resourceList, ComEventRequestImageVO.class); |
| | | comEvent1.setImages(comEventRequestImageVO); |
| | | }); |
| | | return R.ok(list); |
| | | } |
| | | |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R insertComEvent(ComEvent comEvent) { |
| | | if (checkExist( comEvent.getOrderSn(), null)) { |
| | | return R.fail(ReturnMsgConstants.DATA_EXIST); |
| | | ComSanshuoExpert expert = comSanShuoExpertService.getById(comEvent.getSpecialistId()); |
| | | if (comEvent.getRequestUserCommunity() != null) { |
| | | ComActDO community = comActDAO.selectById(comEvent.getRequestUserCommunity()); |
| | | comEvent.setCurrentOrgName(community.getName()); |
| | | } |
| | | if (comEvent.getCenterId() != null) { |
| | | ComSanshuoIndustryCenter center = comSanShuoIndustryCenterService.getById(comEvent.getCenterId()); |
| | | comEvent.setCurrentOrgName(center.getName()); |
| | | } |
| | | comEvent.setUserEventStatus(2); |
| | | comEvent.setEventProcessStatus(SanShuoEventStatusEnum.UNDO.getCode()); |
| | | comEvent.setSpecialistName(expert.getName()); |
| | | comEvent.setOrderSn(DateUtils.getDateFormatString(new Date(), "yyyyMMddHHmmss") + RandomUtils.nextLong(1, 10000)); |
| | | comEvent.setInvalid(true); |
| | | comEvent.setId(Snowflake.getId()); |
| | | comEvent.setSubmitDate(new Date()); |
| | | comEvent.setCreateAt(new Date()); |
| | | comEvent.setCreateBy(comEvent.getRequestUserId()); |
| | | comEvent.setUpdateBy(comEvent.getRequestUserId()); |
| | | comEvent.setUpdateAt(new Date()); |
| | | boolean flag = save(comEvent); |
| | | if (!flag) { |
| | | return R.fail(ReturnMsgConstants.DATA_EXIST); |
| | | } |
| | | saveEventImageList(comEvent.getImages(), comEvent.getId()); |
| | | return R.ok(ReturnMsgConstants.SAVE_SUCCESS); |
| | | } |
| | | |
| | | private Boolean saveEventImageList(List<ComEventRequestImageVO> images, Long id) { |
| | | List<ComEventResource> comEventResourceList = new ArrayList<>(); |
| | | if (!StringUtils.isEmpty(images)) { |
| | | List<ComEventRequestImageVO> imagesList = images; |
| | | imagesList.forEach(comEventRequestImageVO -> { |
| | | ComEventResource comEventResource = new ComEventResource(); |
| | | comEventResource.setId(Snowflake.getId()); |
| | | comEventResource.setRefId(id); |
| | | comEventResource.setStatus(1); |
| | | comEventResource.setType(1); |
| | | comEventResource.setResourceName(comEventRequestImageVO.getName()); |
| | | comEventResource.setResourceSize(comEventRequestImageVO.getSize()); |
| | | comEventResource.setUrl(comEventRequestImageVO.getUrl()); |
| | | comEventResource.setDeleteFlag(false); |
| | | comEventResourceList.add(comEventResource); |
| | | }); |
| | | } |
| | | return comEventResourceService.saveBatch(comEventResourceList); |
| | | } |
| | | |
| | | @Override |
| | |
| | | return flag ? R.ok(comEvent, ReturnMsgConstants.UPDATE_SUCCESS) : R.fail(ReturnMsgConstants.UPDATE_FALSE); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R conciliationEvent(ComEventConciliationVO comEventConciliationVO) { |
| | | saveEventImageList(comEventConciliationVO.getImages(), comEventConciliationVO.getId()); |
| | | ComEvent comEvent = baseMapper.selectById(comEventConciliationVO.getId()); |
| | | comEvent.setEventSucceed(comEventConciliationVO.getEventSucceed()); |
| | | comEvent.setEventResult(comEventConciliationVO.getEventResult()); |
| | | comEvent.setReportSuperior(comEventConciliationVO.getReportSuperior()); |
| | | comEvent.setCurrentEventProcessResult(comEventConciliationVO.getCurrentEventProcessResult()); |
| | | //如果当前请求,需要上报上级进行处理 |
| | | if (comEventConciliationVO.getReportSuperior()) { |
| | | if (comEvent.getCurrentProcessType() == 2) { |
| | | //查询街道的账号 |
| | | comEvent.setCurrentProcessType(3); |
| | | ComActDO comActDO = comActDAO.selectById(comEvent.getCurrentOrgId()); |
| | | comEvent.setCurrentOrgId(comActDO.getStreetId().toString()); |
| | | } else { |
| | | //查询街道的上级区域账号 |
| | | comEvent.setCurrentProcessType(4); |
| | | try { |
| | | ComStreetDO street = comStreetDAO.selectById(comEvent.getCurrentOrgId()); |
| | | comEvent.setCurrentOrgId(street.getAreaCode().toString()); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | baseMapper.updateById(comEvent); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R cancelRequest(Long id) { |
| | | ComEvent comEvent = baseMapper.selectById(id); |
| | | if (comEvent.getEventProcessStatus() == SanShuoEventStatusEnum.UNDO.getCode().intValue() |
| | | || comEvent.getEventProcessStatus() == SanShuoEventStatusEnum.VALID.getCode().intValue()) { |
| | | comEvent.setId(id); |
| | | comEvent.setUserEventStatus(4); |
| | | comEvent.setEventProcessStatus(SanShuoEventStatusEnum.CANCEL.getCode()); |
| | | comEvent.setRevokeDes("用户手动取消"); |
| | | baseMapper.updateById(comEvent); |
| | | return R.ok(); |
| | | } else { |
| | | return R.fail("当前申请已经受理,不能取消!"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public HashMap detail(String id) { |
| | | HashMap map = new HashMap(3); |
| | | ComEventDetailVO comEventDetailVO = new ComEventDetailVO(); |
| | | ComEvent comEvent = baseMapper.selectById(id); |
| | | ComSanshuoExpert specter = comSanShuoExpertService.getById(comEvent.getSpecialistId()); |
| | | CopyUtil.copyProperties(comEvent, comEventDetailVO); |
| | | List<ComEventResource> resourceList = comEventResourceService.list(new QueryWrapper<ComEventResource>().lambda().eq(ComEventResource::getRefId, id)); |
| | | List<ComEventRequestImageVO> comEventRequestImageVO = CopyUtil.deepCopyListObject(resourceList, ComEventRequestImageVO.class); |
| | | comEventDetailVO.setImages(comEventRequestImageVO); |
| | | map.put("specter", specter); |
| | | map.put("eventDetail", comEventDetailVO); |
| | | List<ComEventTransferRecord> transferRecord = comEventTransferRecordService.list(new QueryWrapper<ComEventTransferRecord>().lambda().eq(ComEventTransferRecord::getEventId, id)); |
| | | map.put("transferLog", transferRecord); |
| | | List<ComEventResource> resource = comEventResourceService.list(new QueryWrapper<ComEventResource>().lambda().eq(ComEventResource::getRefId, id) |
| | | .eq(ComEventResource::getStatus, 5)); |
| | | map.put("archiveImage", resource); |
| | | return map; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R acceptRequest(Long id, Long specterId) { |
| | | ComEvent comEvent = new ComEvent(); |
| | | comEvent.setId(id); |
| | | comEvent.setSpecialistId(specterId); |
| | | ComSanshuoExpert specter = comSanShuoExpertService.getById(specterId); |
| | | comEvent.setSpecialistAcceptTime(new Date()); |
| | | comEvent.setSpecialistName(specter.getName()); |
| | | comEvent.setEventProcessStatus(SanShuoEventStatusEnum.ACCEPT.getCode()); |
| | | baseMapper.updateById(comEvent); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R reappoint(Long id, Long specialistId) { |
| | | ComEvent comEvent = new ComEvent(); |
| | | comEvent.setId(id); |
| | | comEvent.setSpecialistId(specialistId); |
| | | ComSanshuoExpert specter = comSanShuoExpertService.getById(specialistId); |
| | | comEvent.setSpecialistAcceptTime(new Date()); |
| | | comEvent.setSpecialistName(specter.getName()); |
| | | comEvent.setEventProcessStatus(SanShuoEventStatusEnum.ACCEPT.getCode()); |
| | | baseMapper.updateById(comEvent); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @Override |
| | | public R calculate() { |
| | | List<ComEventCalculateVO> calculateList = baseMapper.calculate(); |
| | | return R.ok(calculateList); |
| | | } |
| | | |
| | | @Override |
| | | public R archiveRequest(ComEventArchiveVO comEventArchiveVO, LoginUserInfoVO sysUser) { |
| | | ComEvent comEvent = baseMapper.selectById(comEventArchiveVO.getId()); |
| | | comEvent.setEventProcessStatus(6); |
| | | comEvent.setResult(comEventArchiveVO.getResult()); |
| | | baseMapper.updateById(comEvent); |
| | | ComEventTransferRecord comEventTransferRecord = new ComEventTransferRecord(); |
| | | comEventTransferRecord.setEventId(comEvent.getId()); |
| | | comEventTransferRecord.setSave(true); |
| | | comEventTransferRecord.setProcessResult(comEventArchiveVO.getResult()); |
| | | comEventTransferRecord.setProcessResultData(new Date().toString()); |
| | | comEventTransferRecord.setProcessDate(new Date()); |
| | | comEventTransferRecord.setProcessBy(sysUser.getUserId()); |
| | | comEventTransferRecord.setProcessByName(sysUser.getName()); |
| | | comEventTransferRecord.setProcessType(1); |
| | | comEventTransferRecord.setCreateAt(new Date()); |
| | | comEventTransferRecord.setSpecialistId(comEvent.getSpecialistId()); |
| | | comEventTransferRecord.setSpecialistOrg(comEvent.getCurrentOrgId()); |
| | | comEventTransferRecord.setSpecialistLevel(comEvent.getSpecialistLevel()); |
| | | comEventTransferRecord.setSpecialistName(comEvent.getSpecialistName()); |
| | | comEventTransferRecord.setEventResult(comEvent.getEventSucceed()); |
| | | comEventTransferRecord.setEventStatus(comEvent.getEventProcessStatus()); |
| | | comEventTransferRecordService.insertComEventTransferRecord(comEventTransferRecord); |
| | | return R.ok(); |
| | | } |
| | | |
| | | private Boolean checkExist(String sn, Long id) { |
| | | ComEvent comEvent = new ComEvent(); |
| | | comEvent.setOrderSn(sn); |