|
@@ -22,20 +22,21 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
import org.apache.ibatis.annotations.Param;
|
|
import org.apache.ibatis.annotations.Param;
|
|
import org.springblade.common.utils.BaiduApiUtil;
|
|
import org.springblade.common.utils.BaiduApiUtil;
|
|
|
|
+import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
|
+import org.springblade.core.log.exception.ServiceException;
|
|
import org.springblade.core.tool.node.ForestNodeMerger;
|
|
import org.springblade.core.tool.node.ForestNodeMerger;
|
|
import org.springblade.manager.dto.FindAllUserByConditionDTO;
|
|
import org.springblade.manager.dto.FindAllUserByConditionDTO;
|
|
import org.springblade.manager.dto.SaveUserInfoByProjectDTO;
|
|
import org.springblade.manager.dto.SaveUserInfoByProjectDTO;
|
|
import org.springblade.manager.entity.ContractInfo;
|
|
import org.springblade.manager.entity.ContractInfo;
|
|
import org.springblade.manager.entity.ProjectContractArea;
|
|
import org.springblade.manager.entity.ProjectContractArea;
|
|
|
|
+import org.springblade.manager.entity.WbsTreeContract;
|
|
import org.springblade.manager.mapper.ProjectContractAreaMapper;
|
|
import org.springblade.manager.mapper.ProjectContractAreaMapper;
|
|
import org.springblade.manager.mapper.SaveUserInfoByProjectMapper;
|
|
import org.springblade.manager.mapper.SaveUserInfoByProjectMapper;
|
|
-import org.springblade.manager.vo.CRolePostVO;
|
|
|
|
-import org.springblade.manager.vo.ContractInfoVO;
|
|
|
|
|
|
+import org.springblade.manager.mapper.WbsTreeContractMapper;
|
|
|
|
+import org.springblade.manager.vo.*;
|
|
import org.springblade.manager.mapper.ContractInfoMapper;
|
|
import org.springblade.manager.mapper.ContractInfoMapper;
|
|
import org.springblade.manager.service.IContractInfoService;
|
|
import org.springblade.manager.service.IContractInfoService;
|
|
import org.springblade.core.mp.base.BaseServiceImpl;
|
|
import org.springblade.core.mp.base.BaseServiceImpl;
|
|
-import org.springblade.manager.vo.WbsTreeContractTreeVO;
|
|
|
|
-import org.springblade.manager.vo.WbsTreeVO;
|
|
|
|
import org.springblade.system.user.entity.User;
|
|
import org.springblade.system.user.entity.User;
|
|
import org.springblade.system.user.vo.UserVO2;
|
|
import org.springblade.system.user.vo.UserVO2;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -44,6 +45,8 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
@@ -62,6 +65,8 @@ public class ContractInfoServiceImpl
|
|
private final ContractInfoMapper contractInfoMapper;
|
|
private final ContractInfoMapper contractInfoMapper;
|
|
private final ProjectContractAreaMapper projectContractAreaMapper;
|
|
private final ProjectContractAreaMapper projectContractAreaMapper;
|
|
private final SaveUserInfoByProjectMapper saveUserInfoByProjectMapper;
|
|
private final SaveUserInfoByProjectMapper saveUserInfoByProjectMapper;
|
|
|
|
+ private final WbsTreeContractMapper wbsTreeContractMapper;
|
|
|
|
+ private final WbsTreeContractServiceImpl wbsTreeContractService;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public List<ContractInfo> selectContractByProjectIds(List<Long> ids) {
|
|
public List<ContractInfo> selectContractByProjectIds(List<Long> ids) {
|
|
@@ -136,6 +141,13 @@ public class ContractInfoServiceImpl
|
|
return ForestNodeMerger.merge(baseMapper.tree(wbsId, projectId, contractId, null, null));
|
|
return ForestNodeMerger.merge(baseMapper.tree(wbsId, projectId, contractId, null, null));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public List<WbsTreeContractVO2> treeTwo(String wbsId, String projectId) {
|
|
|
|
+ //查询当前项目下所有施工合同树根节点
|
|
|
|
+ List<WbsTreeContractVO2> list = wbsTreeContractMapper.selectListByCondition(wbsId, projectId);
|
|
|
|
+ return list;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 对客户端接口
|
|
* 对客户端接口
|
|
*
|
|
*
|
|
@@ -154,10 +166,139 @@ public class ContractInfoServiceImpl
|
|
return this.baseMapper.tree(null, null, contractId, wbsType, parentId);
|
|
return this.baseMapper.tree(null, null, contractId, wbsType, parentId);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 新增合同段保存(施工-监理引用施工合同wbs私有树)
|
|
|
|
+ *
|
|
|
|
+ * @param contractInfo
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
@Override
|
|
@Override
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
public boolean saveAndUpdateContract(ContractInfoVO contractInfo) {
|
|
public boolean saveAndUpdateContract(ContractInfoVO contractInfo) {
|
|
- boolean row = saveOrUpdate(contractInfo);
|
|
|
|
|
|
+ //新增
|
|
|
|
+ if (contractInfo.getId() == null) {
|
|
|
|
+ List<ContractInfo> contractInfos = baseMapper.selectList(Wrappers.<ContractInfo>query().lambda()
|
|
|
|
+ .eq(ContractInfo::getContractName, contractInfo.getContractName())
|
|
|
|
+ .eq(ContractInfo::getPId, contractInfo.getPId())
|
|
|
|
+ );
|
|
|
|
+ if (contractInfos.size() > 0) {
|
|
|
|
+ throw new ServiceException("合同段名称已存在当前项目下,请重新输入");
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isEmpty(String.valueOf(contractInfo.getContractType()))) {
|
|
|
|
+ throw new ServiceException("合同类型不能为空");
|
|
|
|
+ }
|
|
|
|
+ //新增
|
|
|
|
+ boolean row = saveOrUpdate(contractInfo);
|
|
|
|
+ //新增contract_type=2监理或=3指挥部(业主)类型Wbs树
|
|
|
|
+ if (contractInfo.getContractType().equals(2) || contractInfo.getContractType().equals(3)) {
|
|
|
|
+ List<WbsTreeContractVO3> infos = contractInfo.getIdList();
|
|
|
|
+ infos.forEach(info -> {
|
|
|
|
+ List<WbsTreeContract> wbsTreeContracts = wbsTreeContractMapper.selectList(Wrappers.<WbsTreeContract>query().lambda()
|
|
|
|
+ .eq(WbsTreeContract::getContractId, info.getContractId())
|
|
|
|
+ );
|
|
|
|
+ //初始化
|
|
|
|
+ wbsTreeContracts.forEach(i -> {
|
|
|
|
+ Long id = SnowFlakeUtil.getId();
|
|
|
|
+ i.setPKeyId(id);
|
|
|
|
+ i.setContractIdRelation(i.getContractId());
|
|
|
|
+ i.setContractId(String.valueOf(contractInfo.getId()));
|
|
|
|
+ i.setContractType(contractInfo.getContractType());
|
|
|
|
+ });
|
|
|
|
+ //新增
|
|
|
|
+ wbsTreeContractService.saveBatch(wbsTreeContracts);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ return submitContractRelevantInfo(row, contractInfo);
|
|
|
|
+
|
|
|
|
+ } else { //编辑修改
|
|
|
|
+ List<ContractInfo> contractInfos = baseMapper.selectList(Wrappers.<ContractInfo>query().lambda()
|
|
|
|
+ .eq(ContractInfo::getContractName, contractInfo.getContractName())
|
|
|
|
+ .eq(ContractInfo::getPId, contractInfo.getPId())
|
|
|
|
+ .ne(ContractInfo::getId, contractInfo.getId())
|
|
|
|
+ );
|
|
|
|
+ if (contractInfos.size() > 0) {
|
|
|
|
+ throw new ServiceException("合同段名称已存在当前项目下,请重新输入");
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isEmpty(String.valueOf(contractInfo.getContractType()))) {
|
|
|
|
+ throw new ServiceException("合同类型不能为空");
|
|
|
|
+ }
|
|
|
|
+ boolean row = saveOrUpdate(contractInfo);
|
|
|
|
+ if (contractInfo.getContractType().equals(2) || contractInfo.getContractType().equals(3)) {
|
|
|
|
+ List<String> idList1 = new ArrayList<>(); //当前所有入参施工合同根节点合同id
|
|
|
|
+ List<String> idList2 = new ArrayList<>(); //当前所有已引用监理或业主根节点合同引用id
|
|
|
|
+ List<WbsTreeContractVO3> list = contractInfo.getIdList();
|
|
|
|
+ if (list.size() > 0) {
|
|
|
|
+ list.forEach(cId -> {
|
|
|
|
+ //获取入参根节点id
|
|
|
|
+ String contractId = cId.getContractId();
|
|
|
|
+ idList1.add(contractId);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ //查询当前所有已引用监理或业主根节点合同引用id
|
|
|
|
+ List<WbsTreeContract> wbsTreeContracts = wbsTreeContractMapper.selectList(Wrappers.<WbsTreeContract>query().lambda()
|
|
|
|
+ .eq(WbsTreeContract::getContractId, contractInfo.getId())
|
|
|
|
+ .eq(WbsTreeContract::getContractType, contractInfo.getContractType())
|
|
|
|
+ .eq(WbsTreeContract::getStatus, 1)
|
|
|
|
+ .eq(WbsTreeContract::getParentId, 0)
|
|
|
|
+ );
|
|
|
|
+ wbsTreeContracts.forEach(id -> {
|
|
|
|
+ String contractIdRelation = id.getContractIdRelation();
|
|
|
|
+ idList2.add(String.valueOf(contractIdRelation));
|
|
|
|
+ });
|
|
|
|
+ List<String> result = getDiffrent(idList1, idList2);
|
|
|
|
+ System.out.println("list1:" + idList1);
|
|
|
|
+ System.out.println("list2:" + idList2);
|
|
|
|
+ System.out.println("result:" + result);
|
|
|
|
+
|
|
|
|
+ if (idList1.size() > idList2.size()) {
|
|
|
|
+ //新增
|
|
|
|
+ result.forEach(id -> {
|
|
|
|
+ //查询当前需要引用的施工合同wbs树根节点信息
|
|
|
|
+ WbsTreeContract wbsTreeContract = wbsTreeContractMapper.selectOne(Wrappers.<WbsTreeContract>query().lambda()
|
|
|
|
+ .eq(WbsTreeContract::getContractId, id)
|
|
|
|
+ .eq(WbsTreeContract::getParentId, 0)
|
|
|
|
+ .eq(WbsTreeContract::getContractType, 1)
|
|
|
|
+ );
|
|
|
|
+ WbsTreeContract wbsTreeContractsIsDeleted = wbsTreeContractMapper.selectCondition(contractInfo.getId(), wbsTreeContract.getId(), id, contractInfo.getContractType());
|
|
|
|
+ if (wbsTreeContractsIsDeleted != null) {
|
|
|
|
+ //修改 通过当前合同id = contractInfo.getId(),监理或业主关联的合同段id = contractIdRelation
|
|
|
|
+ wbsTreeContractMapper.updateByCondition2(contractInfo.getId(), wbsTreeContractsIsDeleted.getContractIdRelation());
|
|
|
|
+ } else {
|
|
|
|
+ //新增 根据施工合同根节点查询当前根节点下的施工合同wbs树
|
|
|
|
+ List<WbsTreeContract> wbsTreeContractsList = wbsTreeContractMapper.selectList(Wrappers.<WbsTreeContract>query().lambda()
|
|
|
|
+ .eq(WbsTreeContract::getContractId, id)
|
|
|
|
+ .eq(WbsTreeContract::getContractType, 1)
|
|
|
|
+ );
|
|
|
|
+ //初始化
|
|
|
|
+ wbsTreeContractsList.forEach(i -> {
|
|
|
|
+ Long id1 = SnowFlakeUtil.getId();
|
|
|
|
+ i.setPKeyId(id1);
|
|
|
|
+ i.setContractIdRelation(i.getContractId());
|
|
|
|
+ i.setContractId(String.valueOf(contractInfo.getId()));
|
|
|
|
+ i.setContractType(contractInfo.getContractType());
|
|
|
|
+ });
|
|
|
|
+ wbsTreeContractService.saveBatch(wbsTreeContractsList);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
|
|
+ //删除wbs树
|
|
|
|
+ result.forEach(id -> {
|
|
|
|
+ //根据关联项目id = getContractIdRelation , 删除监理或业主合同的wbs树
|
|
|
|
+ wbsTreeContractMapper.delete(Wrappers.<WbsTreeContract>update().lambda()
|
|
|
|
+ .set(WbsTreeContract::getIsDeleted, 1)
|
|
|
|
+ .eq(WbsTreeContract::getContractIdRelation, id)
|
|
|
|
+ .eq(WbsTreeContract::getProjectId, contractInfo.getPId())
|
|
|
|
+ .eq(WbsTreeContract::getContractId, contractInfo.getId())
|
|
|
|
+ );
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return submitContractRelevantInfo(row, contractInfo);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private boolean submitContractRelevantInfo(boolean row, ContractInfoVO contractInfo) {
|
|
if (row) {
|
|
if (row) {
|
|
//绑定用户角色信息
|
|
//绑定用户角色信息
|
|
List<SaveUserInfoByProjectDTO> list = saveUserInfoByProjectMapper.selectList(Wrappers.<SaveUserInfoByProjectDTO>query().lambda()
|
|
List<SaveUserInfoByProjectDTO> list = saveUserInfoByProjectMapper.selectList(Wrappers.<SaveUserInfoByProjectDTO>query().lambda()
|
|
@@ -185,7 +326,6 @@ public class ContractInfoServiceImpl
|
|
projectContractArea.setProjectId(contractInfo.getPId());
|
|
projectContractArea.setProjectId(contractInfo.getPId());
|
|
projectContractArea.setIsDeleted(0);
|
|
projectContractArea.setIsDeleted(0);
|
|
projectContractArea.setContractId(String.valueOf(contractInfo.getId()));
|
|
projectContractArea.setContractId(String.valueOf(contractInfo.getId()));
|
|
-
|
|
|
|
QueryWrapper<ProjectContractArea> queryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<ProjectContractArea> queryWrapper = new QueryWrapper<>();
|
|
queryWrapper.eq("project_id", contractInfo.getPId());
|
|
queryWrapper.eq("project_id", contractInfo.getPId());
|
|
queryWrapper.eq("contract_id", contractInfo.getId());
|
|
queryWrapper.eq("contract_id", contractInfo.getId());
|
|
@@ -196,19 +336,45 @@ public class ContractInfoServiceImpl
|
|
queryWrapper.eq("is_deleted", contractInfo.getIsDeleted());
|
|
queryWrapper.eq("is_deleted", contractInfo.getIsDeleted());
|
|
ProjectContractArea projectContractArea1 = projectContractAreaMapper.selectOne(queryWrapper);
|
|
ProjectContractArea projectContractArea1 = projectContractAreaMapper.selectOne(queryWrapper);
|
|
if (projectContractArea1 == null) {
|
|
if (projectContractArea1 == null) {
|
|
- int insert = projectContractAreaMapper.insert(projectContractArea);
|
|
|
|
- if (insert > 0) {
|
|
|
|
- return true;
|
|
|
|
- }
|
|
|
|
|
|
+ int res = projectContractAreaMapper.insert(projectContractArea);
|
|
|
|
+ return res > 0;
|
|
}
|
|
}
|
|
|
|
+ return true;
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
- return true;
|
|
|
|
}
|
|
}
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private static List<String> getDiffrent(List<String> list1, List<String> list2) {
|
|
|
|
+ List<String> diff = new ArrayList<String>();
|
|
|
|
+ List<String> maxList = list1;
|
|
|
|
+ List<String> minList = list2;
|
|
|
|
+ if (list2.size() > list1.size()) {
|
|
|
|
+ maxList = list2;
|
|
|
|
+ minList = list1;
|
|
|
|
+ }
|
|
|
|
+ Map<String, Integer> map = new HashMap<String, Integer>(maxList.size());
|
|
|
|
+ for (String string : maxList) {
|
|
|
|
+ map.put(string, 1);
|
|
|
|
+ }
|
|
|
|
+ for (String string : minList) {
|
|
|
|
+ if (map.get(string) != null) {
|
|
|
|
+ map.put(string, 2);
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ diff.add(string);
|
|
|
|
+ }
|
|
|
|
+ for (Map.Entry<String, Integer> entry : map.entrySet()) {
|
|
|
|
+ if (entry.getValue() == 1) {
|
|
|
|
+ diff.add(entry.getKey());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return diff;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public List<ContractInfo> findContractInProject(String ids) {
|
|
public List<ContractInfo> findContractInProject(String ids) {
|
|
return baseMapper.selectList(Wrappers.<ContractInfo>query().lambda().eq(ContractInfo::getPId, ids));
|
|
return baseMapper.selectList(Wrappers.<ContractInfo>query().lambda().eq(ContractInfo::getPId, ids));
|