BaseExpertServiceImpl.java 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. package com.ozs.base.service.impl;
  2. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  3. import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
  4. import com.baomidou.mybatisplus.core.metadata.IPage;
  5. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  6. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  7. import com.github.pagehelper.PageHelper;
  8. import com.github.pagehelper.PageInfo;
  9. import com.ozs.base.domain.BaseExpert;
  10. import com.ozs.base.domain.BaseUnitInformation;
  11. import com.ozs.base.domain.vo.BaseExpertVo;
  12. import com.ozs.base.mapper.BaseExpertMapper;
  13. import com.ozs.base.service.BaseExpertService;
  14. import com.ozs.common.core.domain.AjaxResult;
  15. import com.ozs.common.enums.*;
  16. import com.ozs.common.utils.StringUtils;
  17. import com.ozs.common.utils.bean.BeanUtils;
  18. import com.ozs.plan.doman.PlanQuarter;
  19. import com.ozs.plan.doman.ProvisionalPlan;
  20. import com.ozs.pm.doman.PmDemand;
  21. import com.ozs.pm.doman.PmDemandExpertRef;
  22. import com.ozs.pm.doman.vo.responseVo.PmDemandResVo;
  23. import com.ozs.pm.service.IPmDemandService;
  24. import com.ozs.pm.service.PmDemandExpertRefService;
  25. import com.ozs.system.domain.vo.responseVo.SysDeptResponseVo;
  26. import com.ozs.system.service.ISysDeptService;
  27. import com.ozs.system.service.ISysDictDataService;
  28. import org.springframework.beans.factory.annotation.Autowired;
  29. import org.springframework.stereotype.Service;
  30. import org.springframework.util.ObjectUtils;
  31. import java.util.ArrayList;
  32. import java.util.Date;
  33. import java.util.List;
  34. import java.util.Map;
  35. import java.util.stream.Collectors;
  36. @Service
  37. public class BaseExpertServiceImpl extends ServiceImpl<BaseExpertMapper, BaseExpert> implements BaseExpertService {
  38. @Autowired
  39. private BaseExpertMapper baseExpertMapper;
  40. @Autowired
  41. private PmDemandExpertRefService pmDemandExpertRefService;
  42. @Autowired
  43. private IPmDemandService pmDemandService;
  44. @Autowired
  45. private ISysDeptService deptService;
  46. @Autowired
  47. private ISysDictDataService dictDataService;
  48. @Override
  49. public int insertExpert(BaseExpertVo baseExpertVo) {
  50. // base_unit_information 单位信息表
  51. if (StringUtils.isNotNull(baseExpertVo.getUnitInformation())) {
  52. List<BaseUnitInformation> baseUnitInformationList = baseExpertMapper.selectByUnitInformation(baseExpertVo.getUnitInformation());
  53. if (baseUnitInformationList.size() <= 0) {
  54. BaseUnitInformation baseUnitInformation = new BaseUnitInformation();
  55. baseUnitInformation.setUnitName(baseExpertVo.getUnitInformation());
  56. baseUnitInformation.setCreated(baseExpertVo.getExpertName());
  57. baseUnitInformation.setCreateTime(new Date());
  58. Integer i = baseExpertMapper.insertBaseUnitInformation(baseUnitInformation);
  59. }
  60. }
  61. // 区域list转字符串
  62. if (StringUtils.isNotNull(baseExpertVo.getLocalAreaList())) {
  63. // String stringFromList = String.join(",", baseExpertVo.getLocalAreaList());
  64. baseExpertVo.setLocalArea(baseExpertVo.getLocalAreaList().get(baseExpertVo.getLocalAreaList().size() - 1));
  65. }
  66. return baseExpertMapper.insertExpert(baseExpertVo);
  67. }
  68. @Override
  69. public int updateSupplierType(BaseExpert baseExpert) {
  70. LambdaUpdateWrapper<BaseExpert> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
  71. //eq是指你查询的条件,set是指你修改的值
  72. lambdaUpdateWrapper
  73. .eq(BaseExpert::getId, baseExpert.getId())
  74. .set(BaseExpert::getStatus, baseExpert.getStatus());
  75. return baseExpertMapper.update(null, lambdaUpdateWrapper);
  76. }
  77. @Override
  78. public AjaxResult selectReviewProject(BaseExpertVo baseExpertVo) {
  79. // 通过专家ID查询 与专家库关联的采购执行管理ID
  80. List<Integer> demandIdList = pmDemandExpertRefService.selectByExpertId(baseExpertVo.getId());
  81. if (ObjectUtils.isEmpty(demandIdList)) {
  82. return AjaxResult.success(new PageInfo<>(demandIdList));
  83. }
  84. List<PmDemand> pmDemandList = pmDemandService.selectByDemandIdList(demandIdList);
  85. List<PmDemandResVo> pmDemandResponseVoList = changTo(pmDemandList);
  86. PageHelper.startPage(baseExpertVo.getPageNum().intValue(), baseExpertVo.getPageSize().intValue());
  87. PageInfo<PmDemandResVo> pageInfo = new PageInfo<>(pmDemandResponseVoList);
  88. return AjaxResult.success(pageInfo);
  89. }
  90. @Override
  91. public AjaxResult selectExtractionExpert(BaseExpertVo baseExpertVo) {
  92. // 查询抽取过专家的项目列表
  93. List<PmDemand> pmDemandList = pmDemandService.selectExtractionExpert(baseExpertVo);
  94. List<PmDemandResVo> pmDemandResponseVoList = changTo(pmDemandList);
  95. // 遍历项目 查询专家姓名
  96. for (PmDemandResVo pmDemandResVo : pmDemandResponseVoList) {
  97. Long demandId = pmDemandResVo.getDemandId();
  98. List<String> expertNameList = baseExpertMapper.getExpertNameList(pmDemandResVo.getDemandId());
  99. String expertNameStr = expertNameList.stream().collect(Collectors.joining(",", "{", "}"));
  100. pmDemandResVo.setExpertNameStr(expertNameStr);
  101. }
  102. PageHelper.startPage(baseExpertVo.getPageNum().intValue(), baseExpertVo.getPageSize().intValue());
  103. PageInfo<PmDemandResVo> pageInfo = new PageInfo<>(pmDemandResponseVoList);
  104. return AjaxResult.success(pageInfo);
  105. }
  106. @Override
  107. public List<BaseUnitInformation> getBaseUnitInformationList(){
  108. List<BaseUnitInformation> baseUnitInformationList = baseExpertMapper.selectByUnitInformation(null);
  109. return baseUnitInformationList;
  110. }
  111. private List<PmDemandResVo> changTo(List<PmDemand> pmDemandList) {
  112. List<PmDemandResVo> pmDemandResponseVoList = new ArrayList<>();
  113. if (pmDemandList != null && pmDemandList.size() > 0) {
  114. for (PmDemand pmDemand1 : pmDemandList) {
  115. PmDemandResVo vo = new PmDemandResVo();
  116. BeanUtils.copyProperties(pmDemand1, vo);
  117. if (vo.getPurchaseDeptId() != null) {
  118. Map<String, Object> deptMap = deptService.selectDeptById(vo.getPurchaseDeptId());
  119. if (deptMap != null) {
  120. SysDeptResponseVo sysDeptResponseVo = (SysDeptResponseVo) deptMap.get("sysDept");
  121. if (sysDeptResponseVo != null) {
  122. vo.setPurchaseDeptName(sysDeptResponseVo.getDeptName());
  123. }
  124. }
  125. }
  126. String purchaseServicesName = dictDataService.selectDictLabel("purchase_services", vo.getPurchaseServices());
  127. if (StringUtils.isNotEmpty(purchaseServicesName)) {
  128. vo.setPurchaseServicesName(purchaseServicesName);
  129. }
  130. //项目类型
  131. for (ProjectTypes value : ProjectTypes.values()) {
  132. if (vo.getProjectType() != null && vo.getProjectType().equals(value.getCode())) {
  133. vo.setProjectTypeName(value.getInfo());
  134. break;
  135. }
  136. }
  137. //是否为超限额计划
  138. for (IsExcess value : IsExcess.values()) {
  139. if (vo.getIsExcess() != null && vo.getIsExcess().equals(value.getCode())) {
  140. vo.setIsExcessName(value.getInfo());
  141. break;
  142. }
  143. }
  144. //采购方式
  145. for (PlanPurchaseMode value : PlanPurchaseMode.values()) {
  146. if (vo.getPurchaseMode() != null && vo.getPurchaseMode().equals(value.getCode())) {
  147. vo.setPurchaseModeName(value.getInfo());
  148. break;
  149. }
  150. }
  151. //项目属性
  152. for (ProjectAttribute value : ProjectAttribute.values()) {
  153. if (vo.getProjectAttr() != null && vo.getProjectAttr().equals(value.getCode())) {
  154. vo.setProjectAttrName(value.getInfo());
  155. break;
  156. }
  157. }
  158. //预警状态
  159. for (WarnStatus value : WarnStatus.values()) {
  160. if (vo.getWarnStatus() != null && vo.getWarnStatus().equals(value.getCode())) {
  161. vo.setWarnStatusName(value.getInfo());
  162. break;
  163. }
  164. }
  165. //项目状态
  166. for (PmProjectStatus value : PmProjectStatus.values()) {
  167. if (vo.getProjectStatus() != null && vo.getProjectStatus().equals(value.getCode())) {
  168. vo.setProjectStatusName(value.getInfo());
  169. break;
  170. }
  171. }
  172. pmDemandResponseVoList.add(vo);
  173. }
  174. }
  175. return pmDemandResponseVoList;
  176. }
  177. }