From 8ac30411bb33e406e0ed5a2b6e2edaf7ab59f11f Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期六, 23 十一月 2024 17:10:21 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwWorkorderServiceImpl.java | 276 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 263 insertions(+), 13 deletions(-)
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwWorkorderServiceImpl.java b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwWorkorderServiceImpl.java
index 0223ac9..66f431f 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwWorkorderServiceImpl.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwWorkorderServiceImpl.java
@@ -1,19 +1,36 @@
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.LoginUserInfo;
import com.doumee.core.model.PageData;
import com.doumee.core.model.PageWrap;
+import com.doumee.core.utils.Constants;
import com.doumee.core.utils.Utils;
-import com.doumee.dao.business.YwWorkorderMapper;
-import com.doumee.dao.business.model.YwWorkorder;
+import com.doumee.dao.business.*;
+import com.doumee.dao.business.model.*;
+import com.doumee.dao.system.MultifileMapper;
+import com.doumee.dao.system.SystemUserMapper;
+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;
/**
@@ -26,16 +43,112 @@
@Autowired
private YwWorkorderMapper ywWorkorderMapper;
+ @Autowired
+ private SystemUserMapper systemUserMapper;
+ @Autowired
+ private YwWorkorderLogMapper ywWorkorderLogMapper;
+ @Autowired
+ private SystemDictDataBiz systemDictDataBiz;
+ @Autowired
+ private MultifileMapper multifileMapper;
+ @Autowired
+ private YwProjectMapper ywProjectMapper;
+ @Autowired
+ private YwRoomMapper ywRoomMapper;
+ @Autowired
+ private YwBuildingMapper ywBuildingMapper;
@Override
- public Integer create(YwWorkorder ywWorkorder) {
- ywWorkorderMapper.insert(ywWorkorder);
- return ywWorkorder.getId();
+ @Transactional(rollbackFor = {BusinessException.class,Exception.class})
+ public Integer create(YwWorkorder model) {
+
+ dealParamValid(model);
+ model.setCreator(model.getLoginUserInfo().getId());
+ model.setIsdeleted(Constants.ZERO);
+ model.setCreateDate(new Date());
+ model.setStatus(Constants.ZERO);
+ 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);
+ }
+ dealLogBiz(model,Constants.ZERO,model.getLoginUserInfo().getRealname(),null);//璁板綍鏂板缓鏃ュ織
+ return model.getId();
+ }
+
+ private void dealLogBiz(YwWorkorder model, int type,String param1,String param2) {
+ YwWorkorderLog log = new YwWorkorderLog();
+ log.setCreateDate(model.getEditDate());
+ log.setCreator(model.getCreator());
+ log.setJobId(model.getId());
+ log.setIsdeleted(Constants.ZERO);
+ log.setObjId(model.getId()+"");
+ log.setObjType(type);
+ log.setParam1(param1);
+ log.setParam2(param2);
+ if(type ==0){
+ log.setTitle("鍒涘缓宸ュ崟");
+ }else if(type ==1){
+ log.setTitle("鍒嗘淳宸ュ崟");
+ }else if(type ==2){
+ log.setTitle("澶勭悊宸ュ崟");
+ }
+ ywWorkorderLogMapper.insert(log);
+ }
+
+ private void dealParamValid(YwWorkorder model) {
+ if(Constants.equalsInteger(model.getAreaType(),Constants.ZERO)) {
+ //濡傛灉鏄競鍐呰淇紝蹇呴』閫夋嫨鎴挎簮淇℃伅
+ if(model.getRoomId()==null){
+ throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"瀵逛笉璧凤紝璇烽�夋嫨姝g‘鐨勬埧婧愪俊鎭紒");
+ }
+ YwRoom room = ywRoomMapper.selectById(model.getRoomId());
+ if(room ==null || Constants.equalsInteger(room.getIsdeleted(),Constants.ONE)){
+ throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"瀵逛笉璧凤紝璇烽�夋嫨姝g‘鐨勬埧婧愪俊鎭紒");
+ }
+ model.setBuildingId(room.getBuildingId());
+ model.setProjectId(room.getProjectId());
+ }else{
+ //濡傛灉鏄叕鍏卞尯鍩熻淇紝蹇呴』閫夋嫨妤煎畤淇℃伅
+ if(model.getBuildingId()==null){
+ throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"瀵逛笉璧凤紝璇烽�夋嫨姝g‘鐨勬ゼ瀹囦俊鎭紒");
+ }
+ YwBuilding room = ywBuildingMapper.selectById(model.getRoomId());
+ if(room ==null || Constants.equalsInteger(room.getIsdeleted(),Constants.ONE)){
+ throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"瀵逛笉璧凤紝璇烽�夋嫨姝g‘鐨勬ゼ瀹囦俊鎭紒");
+ }
+ model.setProjectId(room.getProjectId());
+ }
}
@Override
- public void deleteById(Integer id) {
- ywWorkorderMapper.deleteById(id);
+ public void deleteById(Integer id, LoginUserInfo user) {
+ YwWorkorder model = new YwWorkorder();
+ model.setId(id);
+ model.setEditDate(new Date());
+ model.setEditor(user.getId());
+ model.setIsdeleted(Constants.ONE);
+ ywWorkorderMapper.updateById(model);
}
@Override
@@ -45,18 +158,135 @@
}
@Override
- public void deleteByIdInBatch(List<Integer> ids) {
+ public void deleteByIdInBatch(List<Integer> ids, LoginUserInfo user) {
if (CollectionUtils.isEmpty(ids)) {
return;
}
- ywWorkorderMapper.deleteBatchIds(ids);
+ for(Integer id : ids){
+ this.deleteById(id,user);
+ }
}
@Override
- public void updateById(YwWorkorder ywWorkorder) {
- ywWorkorderMapper.updateById(ywWorkorder);
- }
+ @Transactional(rollbackFor = {BusinessException.class,Exception.class})
+ public void dispatchOrder(YwWorkorder ywWorkorder){
+ YwWorkorder model = this.findById(ywWorkorder.getId());
+ if(model ==null || Constants.equalsInteger(model.getIsdeleted(),Constants.ONE)){
+ throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"瀵逛笉璧凤紝宸ュ崟淇℃伅涓嶅瓨鍦紒");
+ }
+ if(!Constants.equalsInteger(model.getDealStatus(),Constants.ZERO) && !Constants.equalsInteger(model.getDealStatus(),Constants.ONE)){
+ throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"瀵逛笉璧凤紝宸ュ崟鐘舵�佸凡娴佽浆锛屼笉鏀寔褰撳墠鎿嶄綔锛�");
+ }
+ SystemUser user = systemUserMapper.selectById(ywWorkorder.getDealUserId());
+ if(user ==null || (user.getDeleted()!=null&& user.getDeleted() )){
+ throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"瀵逛笉璧凤紝鍛樺伐淇℃伅涓嶅瓨鍦紒");
+ }
+ YwWorkorder update = new YwWorkorder();
+ update.setId(model.getId());
+ update.setEditDate(new Date());
+ update.setEditor(ywWorkorder.getLoginUserInfo().getId());
+ update.setDealStatus(Constants.ONE);
+ update.setDispatchUserId(update.getEditor());
+ update.setDispatchDate(update.getEditDate());
+ update.setDispatchInfo(ywWorkorder.getDispatchInfo());
+ ywWorkorderMapper.updateById(update);
+ dealLogBiz(model,Constants.ONE,model.getLoginUserInfo().getRealname(),user.getRealname());//璁板綍鏂板缓鏃ュ織
+ }
+ @Override
+ @Transactional(rollbackFor = {BusinessException.class,Exception.class})
+ public void dealOrder(YwWorkorder ywWorkorder){
+ YwWorkorder model = this.findById(ywWorkorder.getId());
+ if(model ==null || Constants.equalsInteger(model.getIsdeleted(),Constants.ONE)){
+ throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"瀵逛笉璧凤紝宸ュ崟淇℃伅涓嶅瓨鍦紒");
+ }
+ if(!Constants.equalsInteger(model.getDealStatus(),Constants.ZERO) && !Constants.equalsInteger(model.getDealStatus(),Constants.ONE)){
+ throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"瀵逛笉璧凤紝宸ュ崟鐘舵�佸凡娴佽浆锛屼笉鏀寔褰撳墠鎿嶄綔锛�");
+ }
+
+ SystemUser user = systemUserMapper.selectById(ywWorkorder.getDealUserId());
+ if(user ==null || (user.getDeleted()!=null&& user.getDeleted() )){
+ throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"瀵逛笉璧凤紝鍛樺伐淇℃伅涓嶅瓨鍦紒");
+ }
+ YwWorkorder update = new YwWorkorder();
+ update.setId(model.getId());
+ update.setEditDate(new Date());
+ update.setEditor(ywWorkorder.getLoginUserInfo().getId());
+ update.setDealStatus(Constants.TWO);
+ update.setDealUserId(update.getEditor());
+ update.setDealDate(update.getEditDate());
+ update.setDealInfo(ywWorkorder.getDispatchInfo());
+ ywWorkorderMapper.updateById(update);
+ dealLogBiz(model,Constants.TWO,model.getLoginUserInfo().getRealname(),null);//璁板綍鏂板缓鏃ュ織
+ }
+ @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)) {
@@ -69,7 +299,25 @@
@Override
public YwWorkorder findById(Integer id) {
- return ywWorkorderMapper.selectById(id);
+ MPJLambdaWrapper<YwWorkorder> wrapper = new MPJLambdaWrapper<>();
+ wrapper.selectAll(YwWorkorder.class )
+ .select("t4.realname",YwWorkorder::getDealUserName)
+ .select("t3.realname",YwWorkorder::getDispatchUserName)
+ .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)
+ .leftJoin(SystemUser.class,SystemUser::getId,YwWorkorder::getDispatchUserId)
+ .leftJoin(SystemUser.class,SystemUser::getId,YwWorkorder::getDealUserId)
+ .eq(YwWorkorder::getId,id);
+ YwWorkorder model = ywWorkorderMapper.selectJoinOne(YwWorkorder.class,wrapper);
+ initFiles(model);//璇诲彇闄勪欢淇℃伅
+ YwWorkorderLog log = new YwWorkorderLog();
+ log.setJobId(model.getId());
+ log.setIsdeleted(Constants.ZERO);
+ model.setLogList(ywWorkorderLogMapper.selectList(new QueryWrapper<YwWorkorderLog>(log).lambda().orderByAsc(YwWorkorderLog::getCreateDate)));
+ return model;
}
@Override
@@ -80,6 +328,7 @@
@Override
public List<YwWorkorder> findList(YwWorkorder ywWorkorder) {
+ ywWorkorder.setIsdeleted(Constants.ZERO);
QueryWrapper<YwWorkorder> wrapper = new QueryWrapper<>(ywWorkorder);
return ywWorkorderMapper.selectList(wrapper);
}
@@ -88,6 +337,7 @@
public PageData<YwWorkorder> findPage(PageWrap<YwWorkorder> pageWrap) {
IPage<YwWorkorder> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity());
QueryWrapper<YwWorkorder> queryWrapper = new QueryWrapper<>();
+ pageWrap.getModel().setIsdeleted(Constants.ZERO);
Utils.MP.blankToNull(pageWrap.getModel());
if (pageWrap.getModel().getId() != null) {
queryWrapper.lambda().eq(YwWorkorder::getId, pageWrap.getModel().getId());
--
Gitblit v1.9.3