|  |  |  | 
|---|
|  |  |  | package com.doumee.service.business.impl; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.doumee.biz.system.SystemDictDataBiz; | 
|---|
|  |  |  | import com.doumee.core.constants.ResponseStatus; | 
|---|
|  |  |  | import com.doumee.core.exception.BusinessException; | 
|---|
|  |  |  | import com.doumee.core.model.LoginUserInfo; | 
|---|
|  |  |  | 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.YwProblemMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.model.YwProblem; | 
|---|
|  |  |  | import com.doumee.dao.business.YwRoomMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.model.*; | 
|---|
|  |  |  | import com.doumee.dao.system.MultifileMapper; | 
|---|
|  |  |  | import com.doumee.dao.system.model.Multifile; | 
|---|
|  |  |  | import com.doumee.dao.system.model.SystemUser; | 
|---|
|  |  |  | import com.doumee.service.business.YwProblemService; | 
|---|
|  |  |  | 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.commons.lang3.StringUtils; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.stereotype.Service; | 
|---|
|  |  |  | import org.springframework.transaction.annotation.Transactional; | 
|---|
|  |  |  | import org.springframework.util.CollectionUtils; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.*; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 运维问题上报信息表Service实现 | 
|---|
|  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private YwProblemMapper ywProblemMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private YwRoomMapper ywRoomMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private MultifileMapper multifileMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private SystemDictDataBiz systemDictDataBiz; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional(rollbackFor = {Exception.class,BusinessException.class}) | 
|---|
|  |  |  | public Integer create(YwProblem ywProblem) { | 
|---|
|  |  |  | if(Objects.isNull(ywProblem) | 
|---|
|  |  |  | || Objects.isNull(ywProblem.getSubmitDate()) | 
|---|
|  |  |  | || StringUtils.isBlank(ywProblem.getContent()) | 
|---|
|  |  |  | || StringUtils.isBlank(ywProblem.getPhone()) | 
|---|
|  |  |  | || StringUtils.isBlank(ywProblem.getName()) | 
|---|
|  |  |  | ){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | ywProblem.setCreateDate(new Date()); | 
|---|
|  |  |  | ywProblem.setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | ywProblem.setStatus(Constants.ZERO); | 
|---|
|  |  |  | ywProblem.setDealStatus(Constants.ZERO); | 
|---|
|  |  |  | ywProblemMapper.insert(ywProblem); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<Multifile> fileList = new ArrayList<>(); | 
|---|
|  |  |  | if(ywProblem.getFileList()!=null && ywProblem.getFileList().size()>0){ | 
|---|
|  |  |  | for (int i = 0; i <  ywProblem.getFileList().size(); i++) { | 
|---|
|  |  |  | Multifile multifile =  ywProblem.getFileList().get(i); | 
|---|
|  |  |  | if(StringUtils.isBlank(multifile.getFileurl())){ | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | multifile.setCreateDate(ywProblem.getCreateDate()); | 
|---|
|  |  |  | multifile.setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | multifile.setObjId(ywProblem.getId()); | 
|---|
|  |  |  | multifile.setObjType(Constants.MultiFile.PROBLEM_FILE.getKey()); | 
|---|
|  |  |  | multifile.setSortnum(i+1); | 
|---|
|  |  |  | fileList.add(multifile); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(fileList.size()>0){ | 
|---|
|  |  |  | multifileMapper.insert(fileList); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return ywProblem.getId(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | return ywProblemMapper.selectById(id); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public YwProblem getDetail(Integer id) { | 
|---|
|  |  |  | MPJLambdaWrapper<YwProblem> queryWrapper = new MPJLambdaWrapper<YwProblem>(); | 
|---|
|  |  |  | queryWrapper.selectAll(YwProblem.class) | 
|---|
|  |  |  | .selectAs(SystemUser::getRealname,YwProblem::getDealUserName) | 
|---|
|  |  |  | .selectAs(Company::getName,YwProblem::getDealUserCompanyName) | 
|---|
|  |  |  | .leftJoin(SystemUser.class,SystemUser::getId,YwProblem::getDealUserId) | 
|---|
|  |  |  | .leftJoin(Company.class,Company::getId,SystemUser::getCompanyId) | 
|---|
|  |  |  | .eq(YwProblem::getId,id) | 
|---|
|  |  |  | ; | 
|---|
|  |  |  | YwProblem ywProblem = ywProblemMapper.selectJoinOne(YwProblem.class,queryWrapper); | 
|---|
|  |  |  | if(Objects.isNull(ywProblem)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<Multifile> multifiles = multifileMapper.selectList(new QueryWrapper<Multifile>().lambda() | 
|---|
|  |  |  | .eq(Multifile::getObjId, ywProblem.getId() ) | 
|---|
|  |  |  | .in(Multifile::getObjType, Arrays.asList(new Integer[]{Constants.MultiFile.PROBLEM_FILE.getKey() })) | 
|---|
|  |  |  | .eq(Multifile::getIsdeleted,Constants.ZERO)); | 
|---|
|  |  |  | if(multifiles!=null){ | 
|---|
|  |  |  | String path = systemDictDataBiz.queryByCode(Constants.FTP,Constants.FTP_RESOURCE_PATH).getCode() | 
|---|
|  |  |  | +systemDictDataBiz.queryByCode(Constants.FTP,Constants.YW_PROBLEM).getCode(); | 
|---|
|  |  |  | for(Multifile f : multifiles){ | 
|---|
|  |  |  | if(StringUtils.isBlank(f.getFileurl())){ | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | f.setFileurlFull(path+f.getFileurl()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | ywProblem.setFileList(multifiles); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return ywProblem; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional(rollbackFor = {Exception.class,BusinessException.class}) | 
|---|
|  |  |  | public void editProblem(YwProblem ywProblem,YwWorkorderServiceImpl ywWorkorderService){ | 
|---|
|  |  |  | if(Objects.isNull(ywProblem) | 
|---|
|  |  |  | || Objects.isNull(ywProblem.getId()) | 
|---|
|  |  |  | || Objects.isNull(ywProblem.getDealStatus()) | 
|---|
|  |  |  | || !(Constants.equalsInteger(ywProblem.getDealStatus(),Constants.ONE)||Constants.equalsInteger(ywProblem.getDealStatus(),Constants.TWO)) | 
|---|
|  |  |  | || (Constants.equalsInteger(ywProblem.getDealStatus(),Constants.TWO)&&StringUtils.isBlank(ywProblem.getDealInfo())) | 
|---|
|  |  |  | ){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | LoginUserInfo loginUserInfo = ywProblem.getLoginUserInfo(); | 
|---|
|  |  |  | //关闭问题 | 
|---|
|  |  |  | if(Constants.equalsInteger(ywProblem.getDealStatus(),Constants.TWO)){ | 
|---|
|  |  |  | ywProblemMapper.update(new UpdateWrapper<YwProblem>().lambda() | 
|---|
|  |  |  | .set(YwProblem::getDealDate, DateUtil.getCurrDateTime()) | 
|---|
|  |  |  | .set(YwProblem::getDealInfo,ywProblem.getDealInfo()) | 
|---|
|  |  |  | .set(YwProblem::getDealType,Constants.ONE) | 
|---|
|  |  |  | .set(YwProblem::getDealStatus,ywProblem.getDealStatus()) | 
|---|
|  |  |  | .set(YwProblem::getDealUserId,loginUserInfo.getId()) | 
|---|
|  |  |  | .set(YwProblem::getEditor,loginUserInfo.getId()) | 
|---|
|  |  |  | .set(YwProblem::getEditDate, DateUtil.getCurrDateTime()) | 
|---|
|  |  |  | .eq(YwProblem::getId,ywProblem.getId()) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | if(Objects.isNull(ywProblem.getWorkOrderAreaType()) | 
|---|
|  |  |  | ||Objects.isNull(ywProblem.getWorkOrderCateId()) | 
|---|
|  |  |  | ||StringUtils.isBlank(ywProblem.getWorkOrderContent()) | 
|---|
|  |  |  | ){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | YwWorkorder ywWorkorder = new YwWorkorder(); | 
|---|
|  |  |  | ywWorkorder.setAreaType(ywProblem.getWorkOrderAreaType()); | 
|---|
|  |  |  | ywWorkorder.setCateId(ywProblem.getWorkOrderCateId()); | 
|---|
|  |  |  | ywWorkorder.setContent(ywProblem.getWorkOrderContent()); | 
|---|
|  |  |  | ywWorkorder.setRoomId(ywProblem.getWorkOrderRoomId()); | 
|---|
|  |  |  | ywWorkorder.setFloorId(ywProblem.getWorkOrderFloorId()); | 
|---|
|  |  |  | ywWorkorder.setGetDate(ywProblem.getWorkOrderGetDate()); | 
|---|
|  |  |  | ywWorkorder.setOrigin(Constants.ONE); | 
|---|
|  |  |  | ywWorkorder.setLoginUserInfo(loginUserInfo); | 
|---|
|  |  |  | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(ywProblem.getWorkOrderFileList())){ | 
|---|
|  |  |  | ywWorkorder.setFileList(ywProblem.getWorkOrderFileList()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Integer workOrderId = ywWorkorderService.create(ywWorkorder); | 
|---|
|  |  |  | ywProblemMapper.update(new UpdateWrapper<YwProblem>().lambda() | 
|---|
|  |  |  | .set(YwProblem::getDealDate, DateUtil.getCurrDateTime()) | 
|---|
|  |  |  | .set(YwProblem::getDealInfo,ywProblem.getDealInfo()) | 
|---|
|  |  |  | .set(YwProblem::getDealType,Constants.ZERO) | 
|---|
|  |  |  | .set(YwProblem::getDealStatus,ywProblem.getDealStatus()) | 
|---|
|  |  |  | .set(YwProblem::getDealUserId,loginUserInfo.getId()) | 
|---|
|  |  |  | .set(YwProblem::getEditor,loginUserInfo.getId()) | 
|---|
|  |  |  | .set(YwProblem::getEditDate, DateUtil.getCurrDateTime()) | 
|---|
|  |  |  | .set(YwProblem::getWorkorderId,workOrderId) | 
|---|
|  |  |  | .eq(YwProblem::getId,ywProblem.getId()) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public YwProblem findOne(YwProblem ywProblem) { | 
|---|
|  |  |  | QueryWrapper<YwProblem> wrapper = new QueryWrapper<>(ywProblem); | 
|---|
|  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public PageData<YwProblem> findPage(PageWrap<YwProblem> pageWrap) { | 
|---|
|  |  |  | IPage<YwProblem> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); | 
|---|
|  |  |  | QueryWrapper<YwProblem> queryWrapper = new QueryWrapper<>(); | 
|---|
|  |  |  | MPJLambdaWrapper<YwProblem> queryWrapper = new MPJLambdaWrapper<YwProblem>(); | 
|---|
|  |  |  | Utils.MP.blankToNull(pageWrap.getModel()); | 
|---|
|  |  |  | if (pageWrap.getModel().getId() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(YwProblem::getId, pageWrap.getModel().getId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getCreator() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(YwProblem::getCreator, pageWrap.getModel().getCreator()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getCreateDate() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().ge(YwProblem::getCreateDate, Utils.Date.getStart(pageWrap.getModel().getCreateDate())); | 
|---|
|  |  |  | queryWrapper.lambda().le(YwProblem::getCreateDate, Utils.Date.getEnd(pageWrap.getModel().getCreateDate())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getEditor() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(YwProblem::getEditor, pageWrap.getModel().getEditor()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getEditDate() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().ge(YwProblem::getEditDate, Utils.Date.getStart(pageWrap.getModel().getEditDate())); | 
|---|
|  |  |  | queryWrapper.lambda().le(YwProblem::getEditDate, Utils.Date.getEnd(pageWrap.getModel().getEditDate())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getIsdeleted() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(YwProblem::getIsdeleted, pageWrap.getModel().getIsdeleted()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getPosition() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(YwProblem::getPosition, pageWrap.getModel().getPosition()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getRemark() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(YwProblem::getRemark, pageWrap.getModel().getRemark()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getStatus() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(YwProblem::getStatus, pageWrap.getModel().getStatus()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getContent() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(YwProblem::getContent, pageWrap.getModel().getContent()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getName() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().ge(YwProblem::getName, Utils.Date.getStart(pageWrap.getModel().getName())); | 
|---|
|  |  |  | queryWrapper.lambda().le(YwProblem::getName, Utils.Date.getEnd(pageWrap.getModel().getName())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getPhone() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(YwProblem::getPhone, pageWrap.getModel().getPhone()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getSubmitDate() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().ge(YwProblem::getSubmitDate, Utils.Date.getStart(pageWrap.getModel().getSubmitDate())); | 
|---|
|  |  |  | queryWrapper.lambda().le(YwProblem::getSubmitDate, Utils.Date.getEnd(pageWrap.getModel().getSubmitDate())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getCode() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(YwProblem::getCode, pageWrap.getModel().getCode()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getDealStatus() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(YwProblem::getDealStatus, pageWrap.getModel().getDealStatus()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getDealUserId() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(YwProblem::getDealUserId, pageWrap.getModel().getDealUserId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getDealDate() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().ge(YwProblem::getDealDate, Utils.Date.getStart(pageWrap.getModel().getDealDate())); | 
|---|
|  |  |  | queryWrapper.lambda().le(YwProblem::getDealDate, Utils.Date.getEnd(pageWrap.getModel().getDealDate())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getDealInfo() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(YwProblem::getDealInfo, pageWrap.getModel().getDealInfo()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getDealType() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(YwProblem::getDealType, pageWrap.getModel().getDealType()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getWorkorderId() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(YwProblem::getWorkorderId, pageWrap.getModel().getWorkorderId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | for(PageWrap.SortData sortData: pageWrap.getSorts()) { | 
|---|
|  |  |  | if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) { | 
|---|
|  |  |  | queryWrapper.orderByDesc(sortData.getProperty()); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | queryWrapper.orderByAsc(sortData.getProperty()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return PageData.from(ywProblemMapper.selectPage(page, queryWrapper)); | 
|---|
|  |  |  | YwProblem model = pageWrap.getModel(); | 
|---|
|  |  |  | queryWrapper.selectAll(YwProblem.class) | 
|---|
|  |  |  | .selectAs(SystemUser::getRealname,YwProblem::getDealUserName) | 
|---|
|  |  |  | .leftJoin(SystemUser.class,SystemUser::getId,YwProblem::getDealUserId) | 
|---|
|  |  |  | .like(StringUtils.isNotBlank(model.getContent()),YwProblem::getContent,model.getContent()) | 
|---|
|  |  |  | .ge(Objects.nonNull(model.getDealDateStart()),YwProblem::getDealDate, Utils.Date.getStart(model.getDealDateStart())) | 
|---|
|  |  |  | .le(Objects.nonNull(model.getDealDateEnd()),YwProblem::getDealDate, Utils.Date.getEnd(model.getDealDateEnd())) | 
|---|
|  |  |  | .eq(Objects.nonNull(model.getDealStatus()),YwProblem::getDealStatus,model.getDealStatus()) | 
|---|
|  |  |  | ; | 
|---|
|  |  |  | IPage iPage = ywProblemMapper.selectJoinPage(page,YwProblem.class,queryWrapper); | 
|---|
|  |  |  | return PageData.from(iPage); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|