| | |
| | | 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.dao.business.YwProjectMapper; |
| | | import com.doumee.dao.business.YwRoomMapper; |
| | | import com.doumee.dao.business.YwWorkorderMapper; |
| | | import com.doumee.dao.business.model.YwBuilding; |
| | | import com.doumee.dao.business.model.YwProject; |
| | | import com.doumee.dao.business.model.YwRoom; |
| | | import com.doumee.dao.business.model.YwWorkorder; |
| | | 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.YwWorkorderService; |
| | | 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.checkerframework.checker.units.qual.C; |
| | | 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.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | |
| | | @Autowired |
| | | private YwWorkorderMapper ywWorkorderMapper; |
| | | @Autowired |
| | | private SystemDictDataBiz systemDictDataBiz; |
| | | @Autowired |
| | | private MultifileMapper multifileMapper; |
| | | @Autowired |
| | | private YwProjectMapper ywProjectMapper; |
| | | @Autowired |
| | | private YwRoomMapper ywRoomMapper; |
| | |
| | | private YwBuildingMapper ywBuildingMapper; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) |
| | | public Integer create(YwWorkorder model) { |
| | | |
| | | dealParamValid(model); |
| | |
| | | model.setEditDate(model.getCreateDate()); |
| | | model.setEditor(model.getCreator()); |
| | | ywWorkorderMapper.insert(model); |
| | | |
| | | List<Multifile> fileList = new ArrayList<>(); |
| | | if(model.getFileList()!=null && model.getFileList().size()>0){ |
| | | boolean isTrue = false; |
| | | for (int i = 0; i < model.getFileList().size(); i++) { |
| | | Multifile multifile = model.getFileList().get(i); |
| | | if(StringUtils.isBlank(multifile.getFileurl())){ |
| | | continue; |
| | | } |
| | | multifile.setCreateDate(new Date()); |
| | | multifile.setCreator(model.getEditor()); |
| | | multifile.setIsdeleted(Constants.ZERO); |
| | | multifile.setObjId(model.getId()); |
| | | multifile.setCreator(model.getCreator()); |
| | | multifile.setObjType(Constants.MultiFile.YW_WORKORDER_PROBLEM.getKey()); |
| | | multifile.setSortnum(i+1); |
| | | fileList.add(multifile); |
| | | } |
| | | } |
| | | if(fileList.size()>0){ |
| | | multifileMapper.insert(fileList); |
| | | } |
| | | return model.getId(); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) |
| | | public void updateById(YwWorkorder model) { |
| | | dealParamValid(model); |
| | | model.setEditDate(new Date()); |
| | | model.setEditor(model.getLoginUserInfo().getId()); |
| | | ywWorkorderMapper.updateById(model); |
| | | |
| | | List<Multifile> fileList = new ArrayList<>(); |
| | | if(model.getFileList()!=null && model.getFileList().size()>0){ |
| | | for (int i = 0; i < model.getFileList().size(); i++) { |
| | | Multifile multifile = model.getFileList().get(i); |
| | | if(StringUtils.isBlank(multifile.getFileurl())){ |
| | | continue; |
| | | } |
| | | multifile.setCreateDate(new Date()); |
| | | multifile.setCreator(model.getEditor()); |
| | | multifile.setIsdeleted(Constants.ZERO); |
| | | multifile.setObjId(model.getId()); |
| | | multifile.setCreator(model.getCreator()); |
| | | multifile.setObjType(Constants.MultiFile.YW_WORKORDER_PROBLEM.getKey()); |
| | | multifile.setSortnum(i+1); |
| | | fileList.add(multifile); |
| | | } |
| | | } |
| | | multifileMapper.update(null,new UpdateWrapper<Multifile>().lambda() |
| | | .set(Multifile::getIsdeleted,Constants.ONE) |
| | | .set(Multifile::getEditDate,model.getEditDate()) |
| | | .set(Multifile::getEditor,model.getEditor()) |
| | | .eq(Multifile::getIsdeleted, Constants.ZERO) |
| | | .eq(Multifile::getObjType,Constants.MultiFile.YW_WORKORDER_PROBLEM.getKey()) |
| | | ); |
| | | if(fileList.size()>0){ |
| | | multifileMapper.insert(fileList); |
| | | } |
| | | } |
| | | private void initFiles(YwWorkorder model) { |
| | | List<Multifile> multifiles = multifileMapper.selectList(new QueryWrapper<Multifile>().lambda() |
| | | .eq(Multifile::getObjId, model.getId() ) |
| | | .in(Multifile::getObjType, Arrays.asList(new Integer[]{Constants.MultiFile.YW_WORKORDER_PROBLEM.getKey() |
| | | ,Constants.MultiFile.YW_WORKORDER_DEAL.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_WORKORDER_FILE).getCode(); |
| | | for(Multifile f : multifiles){ |
| | | if(StringUtils.isBlank(f.getFileurl())){ |
| | | continue; |
| | | } |
| | | f.setFileurlFull(path+f.getFileurl()); |
| | | if(Constants.equalsInteger(f.getObjType(),Constants.MultiFile.YW_WORKORDER_PROBLEM.getKey())){ |
| | | //现场情况 |
| | | if(model.getFileList() == null){ |
| | | model.setFileList(new ArrayList<>()); |
| | | } |
| | | model.getFileList().add(f); |
| | | } |
| | | if(Constants.equalsInteger(f.getObjType(),Constants.MultiFile.YW_WORKORDER_DEAL.getKey())){ |
| | | //处理附件 |
| | | if(model.getDealFileList() == null){ |
| | | model.setDealFileList(new ArrayList<>()); |
| | | } |
| | | model.getDealFileList().add(f); |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | @Override |
| | | public void updateByIdInBatch(List<YwWorkorder> ywWorkorders) { |
| | | if (CollectionUtils.isEmpty(ywWorkorders)) { |
| | |
| | | |
| | | @Override |
| | | public YwWorkorder findById(Integer id) { |
| | | return ywWorkorderMapper.selectById(id); |
| | | MPJLambdaWrapper<YwWorkorder> wrapper = new MPJLambdaWrapper<>(); |
| | | wrapper.selectAll(YwWorkorder.class ) |
| | | .selectAs(SystemUser::getRealname,YwWorkorder::getCreatorName) |
| | | .selectAs(SystemUser::getMobile,YwWorkorder::getCreatorPhone) |
| | | .selectAs(Company::getCompanyNamePath,YwWorkorder::getCreatorCompany) |
| | | .leftJoin(SystemUser.class,SystemUser::getId,YwWorkorder::getCreator) |
| | | .leftJoin(Company.class,Company::getId,SystemUser::getCompanyId) |
| | | .eq(YwWorkorder::getId,id); |
| | | YwWorkorder model = ywWorkorderMapper.selectJoinOne(YwWorkorder.class,wrapper); |
| | | initFiles(model);//读取附件信息 |
| | | return model; |
| | | } |
| | | |
| | | @Override |