|
@@ -4,22 +4,53 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.springblade.manager.dto.SaveUserInfoByProjectDTO;
|
|
|
+import org.springblade.manager.entity.ContractInfo;
|
|
|
+import org.springblade.manager.entity.ContractRelationJlyz;
|
|
|
import org.springblade.manager.service.SaveUserInfoByProjectService;
|
|
|
+import org.springblade.manager.service.impl.ContractInfoServiceImpl;
|
|
|
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
+import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
+import java.util.function.Function;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@RestController
|
|
|
@AllArgsConstructor
|
|
|
public class ProjectAssignmentUserClientImpl implements ProjectAssignmentUserClient {
|
|
|
|
|
|
+ private final JdbcTemplate jdbcTemplate;
|
|
|
+ private final ContractInfoServiceImpl contractInfoServiceImpl;
|
|
|
private final SaveUserInfoByProjectService saveUserInfoByProjectService;
|
|
|
|
|
|
@Override
|
|
|
- public List<SaveUserInfoByProjectDTO> queryContractDownAllUser(String contractId) {
|
|
|
- return this.saveUserInfoByProjectService.list(Wrappers.<SaveUserInfoByProjectDTO>lambdaQuery().eq(SaveUserInfoByProjectDTO::getContractId, contractId).eq(SaveUserInfoByProjectDTO::getIsDeleted, 0));
|
|
|
+ public List<SaveUserInfoByProjectDTO> queryContractDownAllUser(String contractId, Integer type) {
|
|
|
+ if (type == 1) { //type=1 表示查询施工合同段所关联的监理合同段+当前合同段
|
|
|
+ ContractInfo contractInfo = contractInfoServiceImpl.selectById(contractId);
|
|
|
+ if (contractInfo.getContractType() == 1) {
|
|
|
+ List<ContractRelationJlyz> query = jdbcTemplate.query("select * from m_contract_relation_jlyz where contract_id_sg =" + contractId, new BeanPropertyRowMapper<>(ContractRelationJlyz.class));
|
|
|
+ if (query.size() > 0) {
|
|
|
+ Set<Long> contractIds = query.stream().map(ContractRelationJlyz::getContractIdJlyz).collect(Collectors.toSet());
|
|
|
+ contractIds.add(Long.parseLong(contractId)); //添加当前合同段
|
|
|
+ List<SaveUserInfoByProjectDTO> list = this.saveUserInfoByProjectService.list(Wrappers.<SaveUserInfoByProjectDTO>lambdaQuery().in(SaveUserInfoByProjectDTO::getContractId, contractIds).eq(SaveUserInfoByProjectDTO::getIsDeleted, 0));
|
|
|
+ //根据roleId、userId去重
|
|
|
+ return new ArrayList<>(list.stream()
|
|
|
+ .collect(Collectors.toMap(
|
|
|
+ dto -> dto.getRoleId() + "-" + dto.getUserId(),
|
|
|
+ Function.identity(),
|
|
|
+ (dto1, dto2) -> dto1))
|
|
|
+ .values());
|
|
|
+ }
|
|
|
+ } else if (contractInfo.getContractType() == 2 || contractInfo.getContractType() == 3) {
|
|
|
+ //如果本身就是监理合同段,那么不处理,返回本身合同段信息
|
|
|
+ return this.saveUserInfoByProjectService.list(Wrappers.<SaveUserInfoByProjectDTO>lambdaQuery().eq(SaveUserInfoByProjectDTO::getContractId, contractId).eq(SaveUserInfoByProjectDTO::getIsDeleted, 0));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (type == 2) { //type=2 不处理,单合同段
|
|
|
+ return this.saveUserInfoByProjectService.list(Wrappers.<SaveUserInfoByProjectDTO>lambdaQuery().eq(SaveUserInfoByProjectDTO::getContractId, contractId).eq(SaveUserInfoByProjectDTO::getIsDeleted, 0));
|
|
|
+ }
|
|
|
+ return new ArrayList<>();
|
|
|
}
|
|
|
|
|
|
@Override
|