From bd25d9a8a058e8c618ee4188ed5f15a898c0f7e8 Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期六, 27 一月 2024 11:43:37 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
server/service/src/main/java/com/doumee/service/business/impl/DispatchUnitServiceImpl.java | 582 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 577 insertions(+), 5 deletions(-)
diff --git a/server/service/src/main/java/com/doumee/service/business/impl/DispatchUnitServiceImpl.java b/server/service/src/main/java/com/doumee/service/business/impl/DispatchUnitServiceImpl.java
index 1aaa562..8483330 100644
--- a/server/service/src/main/java/com/doumee/service/business/impl/DispatchUnitServiceImpl.java
+++ b/server/service/src/main/java/com/doumee/service/business/impl/DispatchUnitServiceImpl.java
@@ -1,25 +1,41 @@
package com.doumee.service.business.impl;
+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.Utils;
import com.doumee.dao.business.DispatchUnitMapper;
-import com.doumee.dao.business.model.DispatchUnit;
+import com.doumee.dao.business.DuLogMapper;
+import com.doumee.dao.business.DuSolutionMapper;
+import com.doumee.dao.business.DuWorktypeMapper;
+import com.doumee.dao.business.dto.*;
+import com.doumee.dao.business.join.DuLogJoinMapper;
+import com.doumee.dao.business.join.DuSolutionJoinMapper;
+import com.doumee.dao.business.join.DuWorkTypeJoinMapper;
+import com.doumee.dao.business.model.*;
import com.doumee.service.business.DispatchUnitService;
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.xiaoymin.knife4j.core.util.CollectionUtils;
+import com.github.yulichang.wrapper.MPJLambdaWrapper;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.shiro.SecurityUtils;
+import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
-import org.springframework.util.CollectionUtils;
+import org.springframework.transaction.annotation.Transactional;
-import java.util.List;
+import java.util.*;
/**
* 娲鹃仯鍗曚綅淇℃伅琛⊿ervice瀹炵幇
* @author 姹熻箘韫�
- * @date 2024/01/15 15:07
+ * @date 2024/01/16 10:03
*/
@Service
public class DispatchUnitServiceImpl implements DispatchUnitService {
@@ -27,11 +43,498 @@
@Autowired
private DispatchUnitMapper dispatchUnitMapper;
+ @Autowired
+ private DuSolutionMapper duSolutionMapper;
+
+ @Autowired
+ private DuWorktypeMapper duWorktypeMapper;
+
+ @Autowired
+ private DuLogMapper duLogMapper;
+
+ @Autowired
+ private DuLogJoinMapper duLogJoinMapper;
+
+ @Autowired
+ private DuSolutionJoinMapper duSolutionJoinMapper;
+
+ @Autowired
+ private DuWorkTypeJoinMapper duWorkTypeJoinMapper;
+
@Override
- public Integer create(DispatchUnit dispatchUnit) {
+ @Transactional(rollbackFor = {Exception.class,BusinessException.class})
+ public Integer checkWorktype(DispatchUnit param) {
+ if(Objects.isNull(param)
+ ||Objects.isNull(param.getId())
+ ||param.getWorktypeStatus() == null
+ ||!(param.getWorktypeStatus() ==Constants.ONE || param.getWorktypeStatus() == Constants.TWO)){
+ throw new BusinessException(ResponseStatus.BAD_REQUEST);
+ }
+ LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
+ DispatchUnit model = dispatchUnitMapper.selectById(param.getId());
+ if(Objects.isNull(model) || Constants.equalsInteger(model.getIsdeleted(),Constants.ZERO) ||!Constants.equalsInteger(model.getDataType(),Constants.ZERO)){
+ throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"鏈煡璇㈠埌娲鹃仯鍗曚綅淇℃伅");
+ }
+ if(!Constants.equalsInteger(model.getStatus(),Constants.ONE)){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瀵逛笉璧凤紝璇ユ淳閬e崟浣嶅皻鏈鏍搁�氳繃锛屼笉鏀寔璇ユ搷浣滐紒");
+ }
+ if(Constants.equalsInteger(model.getWorktypeStatus(),Constants.ZERO)){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瀵逛笉璧凤紝璇ユ淳閬e崟浣嶅伐绉嶅凡瀹℃牳锛岃鍕块噸澶嶆彁浜");
+ }
+ DispatchUnit update = new DispatchUnit();
+ update.setEditor(user.getId());
+ update.setEditDate(new Date());
+ update.setId(model.getId());
+ update.setWorktypeStatus(param.getWorktypeStatus());
+ update.setCheckDate(update.getEditDate());
+ update.setCheckUserId(user.getId());
+ update.setCheckInfo(param.getCheckInfo());
+ dispatchUnitMapper.updateById(update);
+ if(Constants.equalsInteger(param.getWorktypeStatus(),Constants.ONE)){
+ //瀹℃牳閫氳繃锛屼慨鏀圭姸鎬侊紝浜х敓鍘嗗彶鐗堟湰
+ newVersionData(dispatchUnitMapper.selectById(param.getId()),update);
+ }else{
+ //鏇存柊鏄庣粏鏁版嵁涓哄鏍稿け璐�
+ duSolutionMapper.update(null,new UpdateWrapper<DuSolution>().lambda()
+ .set(DuSolution::getCheckDate,new Date() )
+ .set(DuSolution::getStatus,Constants.TWO)
+ .set(DuSolution::getCheckUserId,update.getCheckUserId())
+ .set(DuSolution::getCheckInfo,update.getCheckInfo())
+ .eq(DuSolution::getDispatchUnitId,update.getId()));
+ }
+ return 1;
+ }
+
+ private void newVersionData(DispatchUnit model, DispatchUnit update) {
+ dispatchUnitMapper.update(null,new UpdateWrapper<DispatchUnit>().lambda()
+ .set(DispatchUnit::getDataType,Constants.ZERO)
+ .eq(DispatchUnit::getIsdeleted,Constants.ZERO)
+ .eq(DispatchUnit::getBaseId,model.getId()));
+ DispatchUnit newVersion = new DispatchUnit();
+ BeanUtils.copyProperties(model, newVersion);
+ newVersion.setWorktypeStatus(Constants.ONE);
+ newVersion.setCheckDate(update.getEditDate());
+ newVersion.setCheckUserId(update.getCheckUserId());
+ newVersion.setCheckInfo(update.getCheckInfo());
+ newVersion.setCreateDate(update.getCreateDate());
+ newVersion.setCreator(update.getEditor());
+ newVersion.setBaseId(model.getBaseId());
+ newVersion.setDataType(Constants.TWO);
+ dispatchUnitMapper.insert(newVersion);
+
+ List<DuWorktype> newWorktypes = new ArrayList<>();
+ List<DuSolution> solutions = duSolutionMapper.selectList(new QueryWrapper<DuSolution>().lambda()
+ .eq(DuSolution::getIsdeleted,Constants.ZERO)
+ .eq(DuSolution::getDispatchUnitId,model.getSolutionId()));
+ if(solutions == null || solutions.size() ==0){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瀵逛笉璧凤紝璇ユ淳閬e崟浣嶆湭璁剧疆鏂规宸ョ淇℃伅锛屽鏍搁�氳繃澶辫触锛�");
+ }
+ for (DuSolution s : solutions){
+ DuSolution ns = new DuSolution();
+ BeanUtils.copyProperties(s, ns);
+ ns.setDispatchUnitId(newVersion.getId());
+ ns.setCheckDate(update.getEditDate());
+ ns.setStatus(Constants.ONE);
+ ns.setCheckInfo(update.getCheckInfo());
+ ns.setCheckUserId(update.getCheckUserId());
+ duSolutionMapper.insert(ns);
+ List<DuWorktype> worktypes = duWorktypeMapper.selectList(new QueryWrapper<DuWorktype>().lambda()
+ .eq(DuWorktype::getIsdeleted,Constants.ZERO)
+ .eq(DuWorktype::getDuSolutionId,s.getId()));
+ if(worktypes == null || worktypes.size() ==0){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瀵逛笉璧凤紝璇ユ淳閬e崟浣嶆柟妗堝瓨鍦ㄦ柟妗堟槸鏈缃伐绉嶄俊鎭俊鎭紝瀹℃牳閫氳繃澶辫触锛�");
+ }
+ for (DuWorktype w : worktypes) {
+ DuWorktype nw = new DuWorktype();
+ BeanUtils.copyProperties(w, nw);
+ nw.setCheckDate(update.getEditDate());
+ nw.setStatus(Constants.ONE);
+ nw.setDuSolutionId(ns.getId());
+ nw.setCheckInfo(update.getCheckInfo());
+ nw.setCheckUserId(update.getCheckUserId());
+ newWorktypes.add(nw);
+ }
+ }
+ if(newWorktypes!=null &&newWorktypes.size()>0){
+ //鎵归噺鏌ヨ宸ョ鍏宠仈璁板綍
+ duWorktypeMapper.insertBatchSomeColumn(newWorktypes);
+ }
+ }
+
+ @Override
+ @Transactional(rollbackFor = {Exception.class,BusinessException.class})
+ public Integer check(DispatchUnit param) {
+ if(Objects.isNull(param)
+ ||Objects.isNull(param.getId())
+ ||param.getStatus() == null
+ ||!(param.getStatus() ==Constants.ONE || param.getStatus() == Constants.TWO)){
+ throw new BusinessException(ResponseStatus.BAD_REQUEST);
+ }
+ LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
+ DispatchUnit model = dispatchUnitMapper.selectById(param.getId());
+ if(Objects.isNull(model) || Constants.equalsInteger(model.getIsdeleted(),Constants.ZERO) ||!Constants.equalsInteger(model.getDataType(),Constants.ZERO)){
+ throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"鏈煡璇㈠埌娲鹃仯鍗曚綅淇℃伅");
+ }
+ if(Constants.equalsInteger(model.getStatus(),Constants.ZERO)){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瀵逛笉璧凤紝璇ユ淳閬e崟浣嶅伐绉嶅凡瀹℃牳锛岃鍕块噸澶嶆彁浜");
+ }
+ DispatchUnit update = new DispatchUnit();
+ update.setEditor(user.getId());
+ update.setEditDate(new Date());
+ update.setId(model.getId());
+ update.setStatus(param.getStatus());
+ update.setWorktypeStatus(param.getWorktypeStatus());
+ update.setCheckDate(update.getEditDate());
+ update.setCheckUserId(user.getId());
+ update.setCheckInfo(param.getCheckInfo());
+ dispatchUnitMapper.updateById(update);
+ if(Constants.equalsInteger(model.getStatus(),Constants.ONE)){
+ //瀹℃牳閫氳繃锛屼慨鏀圭姸鎬侊紝浜х敓鍘嗗彶鐗堟湰
+ newVersionData(dispatchUnitMapper.selectById(param.getId()),update);
+ }else{
+ //鏇存柊鏄庣粏鏁版嵁涓哄鏍稿け璐�
+ duSolutionMapper.update(null,new UpdateWrapper<DuSolution>().lambda()
+ .set(DuSolution::getCheckDate,new Date() )
+ .set(DuSolution::getStatus,Constants.TWO)
+ .set(DuSolution::getCheckUserId,update.getCheckUserId())
+ .set(DuSolution::getCheckInfo,update.getCheckInfo())
+ .eq(DuSolution::getDispatchUnitId,update.getId()));
+ }
+ return 1;
+ }
+ @Override
+ @Transactional(rollbackFor = {Exception.class,BusinessException.class})
+ public Integer create(SaveDispatchUnitDTO saveDispatchUnitDTO) {
+ if(Objects.isNull(saveDispatchUnitDTO)
+ || StringUtils.isEmpty(saveDispatchUnitDTO.getName())
+ || StringUtils.isEmpty(saveDispatchUnitDTO.getCode())
+ || StringUtils.isEmpty(saveDispatchUnitDTO.getContent())
+ || CollectionUtils.isEmpty(saveDispatchUnitDTO.getSaveDuSolutionDTOList())
+ ){
+ throw new BusinessException(ResponseStatus.BAD_REQUEST);
+ }
+ LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
+ if(dispatchUnitMapper.selectCount(new QueryWrapper<DispatchUnit>().lambda()
+ .eq(DispatchUnit::getCompanyId,loginUserInfo.getCompanyId())
+ .eq(DispatchUnit::getName,saveDispatchUnitDTO.getName())
+ .eq(DispatchUnit::getIsdeleted,Constants.ZERO)
+ )> Constants.ZERO){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"銆愭淳閬e崟浣嶅悕绉般�戝凡瀛樺湪");
+ };
+ if(dispatchUnitMapper.selectCount(new QueryWrapper<DispatchUnit>().lambda()
+ .eq(DispatchUnit::getCompanyId,loginUserInfo.getCompanyId())
+ .eq(DispatchUnit::getCode,saveDispatchUnitDTO.getCode())
+ .eq(DispatchUnit::getIsdeleted,Constants.ZERO)
+ )> Constants.ZERO){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"銆愭淳閬e崟浣嶄俊鐢ㄤ唬鐮併�戝凡瀛樺湪");
+ };
+ DispatchUnit dispatchUnit = new DispatchUnit();
+ dispatchUnit.setCreateDate(new Date());
+ dispatchUnit.setCreator(loginUserInfo.getId());
+ dispatchUnit.setCompanyId(loginUserInfo.getCompanyId());
+ dispatchUnit.setIsdeleted(Constants.ZERO);
+ dispatchUnit.setName(saveDispatchUnitDTO.getName());
+ dispatchUnit.setCode(saveDispatchUnitDTO.getCode());
+ dispatchUnit.setContent(saveDispatchUnitDTO.getContent());
+ dispatchUnit.setStatus(Constants.ZERO);
+ dispatchUnit.setVersion(UUID.randomUUID().toString());
+ dispatchUnit.setUnitStatus(Constants.ZERO);
+ dispatchUnit.setWorktypeStatus(Constants.ZERO);
+ dispatchUnit.setDataType(Constants.ZERO);
dispatchUnitMapper.insert(dispatchUnit);
+
+ //瀛樺偍鎿嶄綔鍘嗗彶
+ this.saveDuLog(dispatchUnit,Constants.DispatchUnitLogType.UPLOAD,null);
+
+ List<SaveDuSolutionDTO> saveDuSolutionDTOList = saveDispatchUnitDTO.getSaveDuSolutionDTOList();
+ for (int i = 0; i < saveDuSolutionDTOList.size(); i++) {
+ SaveDuSolutionDTO saveDuSolutionDTO = saveDuSolutionDTOList.get(i);
+ DuSolution duSolution = new DuSolution();
+ duSolution.setCreateDate(new Date());
+ duSolution.setCreator(loginUserInfo.getId());
+ duSolution.setIsdeleted(Constants.ZERO);
+ duSolution.setDispatchUnitId(dispatchUnit.getId());
+ duSolution.setSortnum(i);
+ duSolution.setSolutionId(saveDuSolutionDTO.getSolutionId());
+ duSolutionMapper.insert(duSolution);
+
+ List<SaveDuWorkTypeDTO> saveDuWorkTypeDTOList = saveDuSolutionDTO.getSaveDuWorkTypeDTOList();
+ if(!CollectionUtils.isNotEmpty(saveDuSolutionDTOList)){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"銆�"+saveDuSolutionDTO.getSolutionName()+"銆戣鏂规涓嬫湭閫夋嫨宸ョ锛�");
+ }
+ for (int j = 0; j < saveDuWorkTypeDTOList.size(); j++) {
+ SaveDuWorkTypeDTO saveDuWorkTypeDTO = saveDuWorkTypeDTOList.get(j);
+ DuWorktype duWorktype = new DuWorktype();
+ duWorktype.setCreateDate(new Date());
+ duWorktype.setCreator(loginUserInfo.getId());
+ duWorktype.setIsdeleted(Constants.ZERO);
+ duWorktype.setDuSolutionId(duSolution.getId());
+ duWorktype.setSortnum(j);
+ duWorktype.setWorkTypeId(saveDuWorkTypeDTO.getWorkTypeId());
+ duWorktype.setVideoUrl(saveDuWorkTypeDTO.getVideoUrl());
+ duWorktype.setStatus2(Constants.ZERO);
+ duWorktypeMapper.insert(duWorktype);
+ }
+ }
return dispatchUnit.getId();
}
+
+
+ @Override
+ @Transactional(rollbackFor = {Exception.class,BusinessException.class})
+ public Integer editDispatchUnit(SaveDispatchUnitDTO saveDispatchUnitDTO) {
+ if(Objects.isNull(saveDispatchUnitDTO)
+ ||Objects.isNull(saveDispatchUnitDTO.getId())
+ || CollectionUtils.isEmpty(saveDispatchUnitDTO.getSaveDuSolutionDTOList())
+ ){
+ throw new BusinessException(ResponseStatus.BAD_REQUEST);
+ }
+ LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
+ DispatchUnit dispatchUnit = this.dispatchUnitMapper.selectById(saveDispatchUnitDTO.getId());
+ if(Objects.isNull(dispatchUnit)){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鏈煡璇㈠埌娲鹃仯鍗曚綅淇℃伅");
+ }
+ if(dispatchUnitMapper.selectCount(new QueryWrapper<DispatchUnit>().lambda()
+ .ne(DispatchUnit::getId,saveDispatchUnitDTO.getId())
+ .eq(DispatchUnit::getCompanyId,loginUserInfo.getCompanyId())
+ .eq(DispatchUnit::getName,saveDispatchUnitDTO.getName())
+ .eq(DispatchUnit::getIsdeleted,Constants.ZERO)
+ )> Constants.ZERO){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"銆愭淳閬e崟浣嶅悕绉般�戝凡瀛樺湪");
+ };
+ if(dispatchUnitMapper.selectCount(new QueryWrapper<DispatchUnit>().lambda()
+ .ne(DispatchUnit::getId,saveDispatchUnitDTO.getId())
+ .eq(DispatchUnit::getCompanyId,loginUserInfo.getCompanyId())
+ .eq(DispatchUnit::getCode,saveDispatchUnitDTO.getCode())
+ .eq(DispatchUnit::getIsdeleted,Constants.ZERO)
+ )> Constants.ZERO){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"銆愭淳閬e崟浣嶄俊鐢ㄤ唬鐮併�戝凡瀛樺湪");
+ }
+ dispatchUnit.setCode(saveDispatchUnitDTO.getCode());
+ dispatchUnit.setContent(saveDispatchUnitDTO.getContent());
+ dispatchUnit.setName(saveDispatchUnitDTO.getName());
+ dispatchUnit.setUnitStatus(Constants.ZERO);
+ dispatchUnit.setWorktypeStatus(Constants.ZERO);
+ dispatchUnit.setEditDate(new Date());
+ dispatchUnit.setEditor(loginUserInfo.getId());
+ dispatchUnitMapper.updateById(dispatchUnit);
+
+ //瀛樺偍鎿嶄綔璁板綍
+ this.saveDuLog(dispatchUnit,Constants.DispatchUnitLogType.EDIT_UNIT,null);
+
+ this.dealDuData(saveDispatchUnitDTO,loginUserInfo);
+
+ return dispatchUnit.getId();
+ }
+
+
+ /**
+ * 娣诲姞鏂规淇℃伅
+ * @param saveDispatchUnitDTO
+ * @return
+ */
+ @Override
+ @Transactional(rollbackFor = {Exception.class,BusinessException.class})
+ public Integer createSolution(SaveDispatchUnitDTO saveDispatchUnitDTO) {
+ if(Objects.isNull(saveDispatchUnitDTO)
+ ||Objects.isNull(saveDispatchUnitDTO.getId())
+ || CollectionUtils.isEmpty(saveDispatchUnitDTO.getSaveDuSolutionDTOList())
+ ){
+ throw new BusinessException(ResponseStatus.BAD_REQUEST);
+ }
+ LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
+ DispatchUnit dispatchUnit = this.dispatchUnitMapper.selectById(saveDispatchUnitDTO.getId());
+ dispatchUnit.setWorktypeStatus(Constants.ZERO);
+ dispatchUnit.setEditDate(new Date());
+ dispatchUnit.setEditor(loginUserInfo.getId());
+ dispatchUnitMapper.updateById(dispatchUnit);
+
+ if(Objects.isNull(dispatchUnit)){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鏈煡璇㈠埌娲鹃仯鍗曚綅淇℃伅");
+ }
+ //瀛樺偍鎿嶄綔鍘嗗彶
+ this.saveDuLog(dispatchUnit,Constants.DispatchUnitLogType.ADD_WORK_TYPE,null);
+ this.dealDuData(saveDispatchUnitDTO,loginUserInfo);
+ return dispatchUnit.getId();
+ }
+
+
+ public void dealDuData(SaveDispatchUnitDTO saveDispatchUnitDTO,LoginUserInfo loginUserInfo){
+ List<SaveDuSolutionDTO> saveDuSolutionDTOList = saveDispatchUnitDTO.getSaveDuSolutionDTOList();
+ for (int i = 0; i < saveDuSolutionDTOList.size(); i++) {
+ SaveDuSolutionDTO saveDuSolutionDTO = saveDuSolutionDTOList.get(i);
+ DuSolution duSolution = duSolutionMapper.selectOne(new QueryWrapper<DuSolution>().lambda().eq(DuSolution::getDispatchUnitId,saveDuSolutionDTO.getId())
+ .eq(DuSolution::getIsdeleted,Constants.ZERO)
+ .eq(DuSolution::getSolutionId,saveDuSolutionDTO.getSolutionId()).last("limit 1"));
+ Integer duSolutionNum = duSolutionMapper.selectCount(new QueryWrapper<DuSolution>().lambda().eq(DuSolution::getDispatchUnitId,saveDuSolutionDTO.getId()));
+ if(Objects.isNull(duSolution)){
+ duSolution = new DuSolution();
+ duSolution.setCreateDate(new Date());
+ duSolution.setCreator(loginUserInfo.getId());
+ duSolution.setIsdeleted(Constants.ZERO);
+ duSolution.setDispatchUnitId(saveDispatchUnitDTO.getId());
+ duSolution.setSortnum(duSolutionNum + i);
+ duSolution.setSolutionId(saveDuSolutionDTO.getSolutionId());
+ duSolutionMapper.insert(duSolution);
+ }
+ List<SaveDuWorkTypeDTO> saveDuWorkTypeDTOList = saveDuSolutionDTO.getSaveDuWorkTypeDTOList();
+ if(!CollectionUtils.isNotEmpty(saveDuSolutionDTOList)){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"銆�"+saveDuSolutionDTO.getSolutionName()+"銆戣鏂规涓嬫湭閫夋嫨宸ョ锛�");
+ }
+ for (int j = 0; j < saveDuWorkTypeDTOList.size(); j++) {
+ SaveDuWorkTypeDTO saveDuWorkTypeDTO = saveDuWorkTypeDTOList.get(j);
+ if(duWorktypeMapper.selectCount(new QueryWrapper<DuWorktype>().lambda().eq(DuWorktype::getDuSolutionId,duSolution.getId())
+ .eq(DuWorktype::getIsdeleted,Constants.ZERO)
+ .eq(DuWorktype::getWorkTypeId,saveDuWorkTypeDTO.getWorkTypeId()))>0){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"銆�"+saveDuSolutionDTO.getSolutionName()+"銆戣鏂规涓�"+saveDuWorkTypeDTO.getWorkTypeName()+"璇ュ伐绉嶅凡瀛樺湪宸ョ宸插瓨鍦�");
+ }
+ Integer duWorkTypeNum = duWorktypeMapper.selectCount(new QueryWrapper<DuWorktype>().lambda().eq(DuWorktype::getDuSolutionId,duSolution.getId()));
+ DuWorktype duWorktype = new DuWorktype();
+ duWorktype.setCreateDate(new Date());
+ duWorktype.setCreator(loginUserInfo.getId());
+ duWorktype.setIsdeleted(Constants.ZERO);
+ duWorktype.setDuSolutionId(duSolution.getId());
+ duWorktype.setSortnum(duWorkTypeNum + j);
+ duWorktype.setWorkTypeId(saveDuWorkTypeDTO.getWorkTypeId());
+ duWorktype.setVideoUrl(saveDuWorkTypeDTO.getVideoUrl());
+ duWorktype.setStatus2(Constants.ZERO);
+ duWorktypeMapper.insert(duWorktype);
+ }
+ }
+ }
+
+
+
+ @Override
+ @Transactional(rollbackFor = {BusinessException.class,Exception.class})
+ public void auditData(DispatchUnitAuditDTO dispatchUnitAuditDTO){
+ if(Objects.isNull(dispatchUnitAuditDTO)
+ || Objects.isNull(dispatchUnitAuditDTO.getId())
+ || Objects.isNull(dispatchUnitAuditDTO.getAuditType())
+ || Objects.isNull(dispatchUnitAuditDTO.getStatus())
+ || !(dispatchUnitAuditDTO.getAuditType().equals(Constants.ZERO) || dispatchUnitAuditDTO.getAuditType().equals(Constants.ONE))
+ || !(dispatchUnitAuditDTO.getStatus().equals(Constants.ONE) || dispatchUnitAuditDTO.getAuditType().equals(Constants.TWO))
+ ){
+ throw new BusinessException(ResponseStatus.BAD_REQUEST);
+ }
+ LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
+ if(loginUserInfo.getType().equals(Constants.ONE)){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鐢ㄦ埛绫诲瀷閿欒锛氫紒涓氱敤鎴锋棤娉曡繘琛岃鎿嶄綔");
+ }
+ DispatchUnit dispatchUnit = this.dispatchUnitMapper.selectById(dispatchUnitAuditDTO.getId());
+ if(Objects.isNull(dispatchUnit)){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鏈煡璇㈠埌娲鹃仯鍗曚綅淇℃伅");
+ }
+ //娲鹃仯鍗曚綅瀹℃壒
+ if(dispatchUnitAuditDTO.getAuditType().equals(Constants.ZERO)){
+ if(dispatchUnit.getStatus().equals(Constants.ONE)){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"娲鹃仯鍗曚綅淇℃伅宸插鏍�");
+ }
+ dispatchUnit.setStatus(dispatchUnitAuditDTO.getStatus());
+ dispatchUnit.setCheckDate(new Date());
+ dispatchUnit.setCheckUserId(loginUserInfo.getId());
+ dispatchUnit.setCheckInfo(dispatchUnitAuditDTO.getAuditRemark());
+ dispatchUnitMapper.updateById(dispatchUnit);
+ if(dispatchUnitAuditDTO.getStatus().equals(Constants.ONE)){
+ this.saveDuLog(dispatchUnit,Constants.DispatchUnitLogType.AUDIT_PASS,dispatchUnitAuditDTO.getAuditRemark());
+ }else{
+ this.saveDuLog(dispatchUnit,Constants.DispatchUnitLogType.AUDIT_UN_PASS,dispatchUnitAuditDTO.getAuditRemark());
+ }
+
+ }else if(dispatchUnitAuditDTO.getAuditType().equals(Constants.ONE)){
+ if(!dispatchUnit.getStatus().equals(Constants.ONE)){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"娲鹃仯鍗曚綅淇℃伅鏈鏍�,鏃犳硶杩涜璇ユ搷浣�");
+ }
+ if(dispatchUnitAuditDTO.getStatus().equals(Constants.ONE)){
+ this.saveDuLog(dispatchUnit,Constants.DispatchUnitLogType.WORK_TYPE_AUDIT_PASS,dispatchUnitAuditDTO.getAuditRemark());
+ }else{
+ this.saveDuLog(dispatchUnit,Constants.DispatchUnitLogType.WORK_TYPE_AUDIT_UN_PASS,dispatchUnitAuditDTO.getAuditRemark());
+ }
+ }else{
+ throw new BusinessException(ResponseStatus.BAD_REQUEST);
+ }
+ //鏇存柊鏂规鏁版嵁
+ List<DuSolution> duSolutionList = duSolutionMapper.selectList(new QueryWrapper<DuSolution>().lambda()
+ .eq(DuSolution::getStatus,Constants.ZERO)
+ .eq(DuSolution::getIsdeleted,Constants.ZERO)
+ .eq(DuSolution::getDispatchUnitId,dispatchUnit.getId()));
+ for (DuSolution duSolution:duSolutionList) {
+ duSolution.setStatus(dispatchUnitAuditDTO.getStatus());
+ duSolution.setCheckDate(new Date());
+ duSolution.setCheckUserId(loginUserInfo.getId());
+ duSolution.setCheckInfo(dispatchUnitAuditDTO.getAuditRemark());
+ dispatchUnitMapper.updateById(dispatchUnit);
+ //鏌ヨ宸ョ鏁版嵁
+ List<DuWorktype> duWorktypeList = duWorktypeMapper.selectList(new QueryWrapper<DuWorktype>().lambda()
+ .eq(DuWorktype::getStatus,Constants.ZERO)
+ .eq(DuWorktype::getIsdeleted,Constants.ZERO)
+ .eq(DuWorktype::getDuSolutionId,duSolution.getId()));
+ for (DuWorktype duWorktype:duWorktypeList) {
+ duWorktype.setStatus(dispatchUnitAuditDTO.getStatus());
+ duWorktype.setCheckDate(new Date());
+ duWorktype.setCheckUserId(loginUserInfo.getId());
+ duWorktype.setCheckInfo(dispatchUnitAuditDTO.getAuditRemark());
+ dispatchUnitMapper.updateById(dispatchUnit);
+ }
+ }
+ this.saveHistory(dispatchUnit);
+ }
+
+
+ public void saveHistory(DispatchUnit dispatchUnit){
+ if(dispatchUnit.getStatus().equals(Constants.ONE)){
+ DispatchUnit his = new DispatchUnit();
+ BeanUtils.copyProperties(dispatchUnit,his);
+ his.setBaseId(dispatchUnit.getId());
+ his.setId(null);
+ his.setDataType(Constants.TWO);
+ dispatchUnitMapper.insert(his);
+ //淇敼鍏朵粬鍘嗗彶鐗堟湰鏁版嵁涓� 鍘嗗彶鐗堟湰
+ dispatchUnitMapper.update(null,new UpdateWrapper<DispatchUnit>().lambda().set(DispatchUnit::getDataType,Constants.ONE).eq(DispatchUnit::getBaseId,dispatchUnit.getId())
+ .eq(DispatchUnit::getDataType,Constants.TWO).ne(DispatchUnit::getId,his.getId())
+ );
+ //瀛樺偍鏂规鏁版嵁
+ List<DuSolution> duSolutionList = duSolutionMapper.selectList(new QueryWrapper<DuSolution>().lambda()
+ .eq(DuSolution::getStatus,Constants.ONE)
+ .eq(DuSolution::getDispatchUnitId,dispatchUnit.getId()));
+ for (DuSolution duSolution:duSolutionList) {
+ DuSolution hisDuSolution = new DuSolution();
+ BeanUtils.copyProperties(duSolution,hisDuSolution);
+ hisDuSolution.setId(null);
+ hisDuSolution.setDispatchUnitId(his.getId());
+ duSolutionMapper.insert(hisDuSolution);
+ //鏌ヨ宸ョ鏁版嵁
+ List<DuWorktype> duWorktypeList = duWorktypeMapper.selectList(new QueryWrapper<DuWorktype>().lambda()
+ .eq(DuWorktype::getStatus,Constants.ONE)
+ .eq(DuWorktype::getDuSolutionId,duSolution.getId()));
+ for (DuWorktype duWorktype:duWorktypeList) {
+ DuWorktype hisDuWorktype = new DuWorktype();
+ BeanUtils.copyProperties(duWorktype,hisDuWorktype);
+ hisDuWorktype.setId(null);
+ hisDuWorktype.setDuSolutionId(hisDuSolution.getId());
+ duWorktypeMapper.insert(hisDuWorktype);
+ }
+ }
+ }
+ }
+
+
+
+ public void saveDuLog(DispatchUnit dispatchUnit,Constants.DispatchUnitLogType dispatchUnitLogType,String content){
+ LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
+ DuLog duLog = new DuLog();
+ duLog.setCreateDate(new Date());
+ duLog.setCreator(loginUserInfo.getId());
+ duLog.setIsdeleted(Constants.ZERO);
+ duLog.setDuId(dispatchUnit.getId());
+ duLog.setTitle(dispatchUnitLogType.getName());
+ duLog.setContent(content);
+ duLog.setObjType(dispatchUnitLogType.getKey());
+ duLog.setObjId(Integer.toString(dispatchUnit.getId()));
+ duLog.setStatus(Constants.ZERO);
+ duLogMapper.insert(duLog);
+ }
+
@Override
public void deleteById(Integer id) {
@@ -80,6 +583,7 @@
@Override
public List<DispatchUnit> findList(DispatchUnit dispatchUnit) {
+ dispatchUnit.setIsdeleted(Constants.ZERO);
QueryWrapper<DispatchUnit> wrapper = new QueryWrapper<>(dispatchUnit);
return dispatchUnitMapper.selectList(wrapper);
}
@@ -170,4 +674,72 @@
QueryWrapper<DispatchUnit> wrapper = new QueryWrapper<>(dispatchUnit);
return dispatchUnitMapper.selectCount(wrapper);
}
+
+
+ @Override
+ public DispatchUnit detailById(Integer id) {
+ DispatchUnit dispatchUnit = dispatchUnitMapper.selectById(id);
+ //鏂规閰嶇疆琛�
+ List<DuSolution> duSolutionList = duSolutionJoinMapper.selectJoinList(DuSolution.class,
+ new MPJLambdaWrapper<DuSolution>()
+ .selectAll(DuSolution.class)
+ .selectAs(Solutions::getName,DuSolution::getSolutionName)
+ .leftJoin(Solutions.class,Solutions::getId,DuSolution::getSolutionId)
+ .eq(DuSolution::getSolutionId,dispatchUnit.getId())
+ .orderByAsc(DuSolution::getSortnum)
+ );
+ if(CollectionUtils.isNotEmpty(duSolutionList)){
+ for (DuSolution duSolution:duSolutionList) {
+ //鏌ヨ鏂规涓嬬殑宸ョ淇℃伅
+ List<DuWorktype> duWorkTypeList = duWorkTypeJoinMapper.selectJoinList(DuWorktype.class,
+ new MPJLambdaWrapper<DuWorktype>()
+ .selectAll(DuWorktype.class)
+ .selectAs(Worktype::getName,DuWorktype::getWorkTypeName)
+ .leftJoin(Worktype.class,Worktype::getId,DuWorktype::getWorkTypeId)
+ .eq(DuWorktype::getDuSolutionId,duSolution.getId())
+ );
+ duSolution.setDuWorktypeList(duWorkTypeList);
+ }
+ dispatchUnit.setDuSolutionList(duSolutionList);
+ }
+ //鏌ヨ鎿嶄綔璁板綍
+ List<DuLog> duLogList = duLogJoinMapper.selectJoinList(DuLog.class,
+ new MPJLambdaWrapper<DuLog>()
+ .selectAll(DuLog.class)
+ .selectAs(Member::getName,DuLog::getCreatorName)
+ .selectAs(Company::getName,DuLog::getCompanyName)
+ .leftJoin(Member.class,Member::getId,DuLog::getCreator)
+ .leftJoin(Company.class,Company::getId,Member::getCompanyId)
+ .eq(DuLog::getDuId,dispatchUnit.getId())
+ .orderByAsc(DuLog::getCreateDate)
+ );
+ dispatchUnit.setDuLogList(duLogList);
+ return dispatchUnit;
+ }
+
+
+ /**
+ * 鏌ヨ浼佷笟涓嬬殑娲鹃仯鍗曚綅
+ * @return
+ */
+ @Override
+ public List<DispatchUnit> findByDTO(DispatchUnitQueryDTO dispatchUnitQueryDTO) {
+ LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
+ List<DispatchUnit> dispatchUnitList = dispatchUnitMapper.selectList(new QueryWrapper<DispatchUnit>().lambda()
+ .eq(DispatchUnit::getIsdeleted,Constants.ZERO)
+ .eq(loginUserInfo.getType().equals(Constants.ONE),DispatchUnit::getCompanyId,loginUserInfo.getCompanyId())
+ .eq(DispatchUnit::getStatus,Constants.ZERO)
+ .eq(DispatchUnit::getDataType,dispatchUnitQueryDTO.getDataType())
+ .apply(!Objects.isNull(dispatchUnitQueryDTO.getSolutionId()), " id in ( select d.dispatch_unit_id from du_solution d where d.solutionId = "+dispatchUnitQueryDTO.getSolutionId()+" ) " )
+ .exists(!Objects.isNull(dispatchUnitQueryDTO.getApplyId()),
+ " select 1 from apply_detail ad where ad.isdeleted = 0 and ad.apply_id = "+dispatchUnitQueryDTO.getApplyId()+" " +
+ " ad.du_id = t.id ")
+ .orderByAsc(DispatchUnit::getSortnum)
+ );
+ return dispatchUnitList;
+ }
+
+
+
+
}
--
Gitblit v1.9.3