BaseExpertController.java 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. package com.ozs.web.controller.base;
  2. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  3. import com.baomidou.mybatisplus.core.metadata.IPage;
  4. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  5. import com.ozs.base.domain.BaseExpert;
  6. import com.ozs.base.domain.BaseProfessional;
  7. import com.ozs.base.domain.vo.BaseExpertVo;
  8. import com.ozs.base.domain.vo.BaseProfessionalVo;
  9. import com.ozs.base.service.BaseExpertService;
  10. import com.ozs.base.service.BaseProfessionalService;
  11. import com.ozs.common.annotation.Log;
  12. import com.ozs.common.constant.ModularConstans;
  13. import com.ozs.common.core.controller.BaseController;
  14. import com.ozs.common.core.domain.AjaxResult;
  15. import com.ozs.common.enums.BusinessType;
  16. import com.ozs.common.utils.PageUtils;
  17. import com.ozs.common.utils.StringUtils;
  18. import com.ozs.common.utils.bean.BeanUtils;
  19. import com.ozs.system.domain.vo.SysRegionVO;
  20. import com.ozs.system.service.ISysDictDataService;
  21. import com.ozs.system.service.SysRegionService;
  22. import io.swagger.annotations.Api;
  23. import io.swagger.annotations.ApiOperation;
  24. import org.joda.time.DateTime;
  25. import org.springframework.beans.factory.annotation.Autowired;
  26. import org.springframework.security.access.prepost.PreAuthorize;
  27. import org.springframework.util.ObjectUtils;
  28. import org.springframework.web.bind.annotation.PostMapping;
  29. import org.springframework.web.bind.annotation.RequestBody;
  30. import org.springframework.web.bind.annotation.RequestMapping;
  31. import org.springframework.web.bind.annotation.RestController;
  32. import javax.annotation.Resource;
  33. import javax.validation.constraints.NotEmpty;
  34. import java.util.Arrays;
  35. import java.util.Date;
  36. import java.util.List;
  37. import java.util.stream.Collectors;
  38. /**
  39. * 专家库管理
  40. *
  41. * @author sunhh
  42. */
  43. @Api(tags = "专家库管理")
  44. @RestController
  45. @RequestMapping("/base/expert")
  46. public class BaseExpertController extends BaseController {
  47. @Autowired
  48. private BaseExpertService baseExpertService;
  49. @Autowired
  50. private SysRegionService sysRegionService;
  51. @Autowired
  52. private BaseProfessionalService baseProfessionalService;
  53. @Autowired
  54. private ISysDictDataService dictDataService;
  55. @ApiOperation(value = "新增专家库" , notes = "必传 专家库名称")
  56. @PostMapping("/insertExpert")
  57. @PreAuthorize("@ss.hasPermi('base:expert:insertExpert')")
  58. @Log(title = ModularConstans.expert, businessType = BusinessType.INSERT)
  59. public AjaxResult insertExpert(@RequestBody BaseExpertVo baseExpertVo) {
  60. if (StringUtils.isNull(baseExpertVo) || StringUtils.isNull(baseExpertVo.getExpertName())) {
  61. return error("专家库名称不能为空");
  62. }
  63. baseExpertVo.setCreated(getUserId().toString());
  64. baseExpertVo.setCreateTime(new Date());
  65. baseExpertVo.setUpdated(baseExpertVo.getCreated());
  66. baseExpertVo.setUpdateTime(baseExpertVo.getCreateTime());
  67. if (ObjectUtils.isEmpty(baseExpertVo.getMajorType())) {
  68. return error("专业类型为空");
  69. }
  70. LambdaQueryWrapper<BaseProfessional> lw = new LambdaQueryWrapper();
  71. lw.eq(BaseProfessional::getProfessionalCode, baseExpertVo.getMajorType());
  72. List<BaseProfessional> list = baseProfessionalService.list(lw);
  73. if (ObjectUtils.isEmpty(list) || list.size() < 1) {
  74. return error("专业类型传值错误");
  75. }
  76. LambdaQueryWrapper<BaseExpert> l = new LambdaQueryWrapper();
  77. l.eq(BaseExpert::getIdNumber, baseExpertVo.getIdNumber());
  78. List<BaseExpert> list1 = baseExpertService.list(l);
  79. if (!ObjectUtils.isEmpty(list1) && list1.size() > 0) {
  80. return error("身份证号已经存在");
  81. }
  82. SysRegionVO sysRegionVO = sysRegionService.selectInfoByCode(baseExpertVo.getLocalArea());
  83. if (ObjectUtils.isEmpty(sysRegionVO)) {
  84. return error("该区域在数据库中不存在");
  85. }
  86. return toAjax(baseExpertService.insertExpert(baseExpertVo));
  87. }
  88. @ApiOperation(value = "删除专家库", notes = "必传 id")
  89. @PostMapping("/deleteExpert")
  90. @PreAuthorize("@ss.hasPermi('base:expert:deleteExpert')")
  91. @Log(title = ModularConstans.expert, businessType = BusinessType.DELETE)
  92. public AjaxResult deleteExpert(@RequestBody BaseExpert baseExpert) {
  93. if (StringUtils.isNull(baseExpert) || StringUtils.isNull(baseExpert.getId())) {
  94. return error("专家库id不能为空");
  95. }
  96. return toAjax(baseExpertService.removeById(baseExpert.getId()));
  97. }
  98. @ApiOperation(value = "修改专家库", notes = "必传 id 及修改数据")
  99. @PostMapping("/updateExpert")
  100. @PreAuthorize("@ss.hasPermi('base:expert:updateExpert')")
  101. @Log(title = ModularConstans.expert, businessType = BusinessType.UPDATE)
  102. public AjaxResult updateProfessional(@RequestBody BaseExpert baseExpert) {
  103. if (StringUtils.isNull(baseExpert) || StringUtils.isNull(baseExpert.getId())) {
  104. return error("专家库id和修改数据不能为空");
  105. }
  106. baseExpert.setUpdated(getUserId().toString());
  107. baseExpert.setUpdateTime(new Date());
  108. if (ObjectUtils.isEmpty(baseExpert.getMajorType())) {
  109. return error("专业类型为空");
  110. }
  111. LambdaQueryWrapper<BaseProfessional> lw = new LambdaQueryWrapper();
  112. lw.eq(BaseProfessional::getProfessionalCode, baseExpert.getMajorType());
  113. List<BaseProfessional> list = baseProfessionalService.list(lw);
  114. if (ObjectUtils.isEmpty(list) || list.size() < 1) {
  115. return error("专业类型传值错误");
  116. }
  117. LambdaQueryWrapper<BaseExpert> l = new LambdaQueryWrapper();
  118. l.eq(BaseExpert::getIdNumber, baseExpert.getIdNumber());
  119. List<BaseExpert> list1 = baseExpertService.list(l);
  120. if (!ObjectUtils.isEmpty(list1) && list.size() > 0) {
  121. if (!list1.get(0).getId().equals(baseExpert.getId())) {
  122. return error("身份证号已经存在");
  123. }
  124. }
  125. SysRegionVO sysRegionVO = sysRegionService.selectInfoByCode(baseExpert.getLocalArea());
  126. if (ObjectUtils.isEmpty(sysRegionVO)) {
  127. return error("该区域在数据库中不存在");
  128. }
  129. return toAjax(baseExpertService.updateById(baseExpert));
  130. }
  131. @ApiOperation(value = "查询专家库", notes = "非必传 查询条件:品目名称")
  132. @PostMapping("/selectExpert")
  133. @PreAuthorize("@ss.hasPermi('base:expert:selectExpert')")
  134. @Log(title = ModularConstans.expert, businessType = BusinessType.QUERY)
  135. public AjaxResult selectExpert(@RequestBody BaseExpertVo baseExpertVo) {
  136. LambdaQueryWrapper<BaseExpert> lw = new LambdaQueryWrapper<BaseExpert>();
  137. if (!StringUtils.isBlank(baseExpertVo.getExpertName())) {
  138. lw.like(BaseExpert::getExpertName, baseExpertVo.getExpertName());
  139. }
  140. if (!StringUtils.isBlank(baseExpertVo.getMajorType())) {
  141. lw.eq(BaseExpert::getMajorType, baseExpertVo.getMajorType());
  142. }
  143. if (!ObjectUtils.isEmpty(baseExpertVo.getMajorGrade())) {
  144. lw.eq(BaseExpert::getMajorGrade, baseExpertVo.getMajorGrade());
  145. }
  146. lw.orderBy(true, false, BaseExpert::getCreateTime);
  147. List<BaseExpert> list = baseExpertService.list(lw);
  148. List<BaseExpertVo> listVo = BeanUtils.entityListToVOList(list, BaseExpertVo.class);
  149. for (BaseExpertVo vo : listVo) {
  150. // 区域
  151. if (StringUtils.isNotNull(vo.getLocalArea())) {
  152. String parentAdministrativeDivisionNames = sysRegionService.getParentAdministrativeDivisionNames(vo.getLocalArea());
  153. vo.setLocalAreaName(parentAdministrativeDivisionNames);
  154. }
  155. // 专业类型
  156. if (!org.apache.commons.lang3.StringUtils.isBlank(vo.getMajorType())) {
  157. LambdaQueryWrapper<BaseProfessional> lwe = new LambdaQueryWrapper<>();
  158. lwe.eq(BaseProfessional::getProfessionalCode, vo.getMajorType());
  159. List<BaseProfessional> list1 = baseProfessionalService.list(lwe);
  160. if (!ObjectUtils.isEmpty(list1)) {
  161. vo.setMajorTypeName(list1.get(0).getProfessionalName());
  162. }
  163. }
  164. // 专家类型
  165. if (StringUtils.isNotEmpty(vo.getExpertType())) {
  166. String expertType = vo.getExpertType();
  167. List<String> expertTypeList = Arrays.stream(expertType.split(",")).map(s -> s.trim()).collect(Collectors.toList());
  168. for (String eT : expertTypeList) {
  169. String expertTypeName = dictDataService.selectDictLabel("expert_type", eT);
  170. if (StringUtils.isNotEmpty(expertTypeName)) {
  171. vo.setExpertTypeName(expertTypeName);
  172. }
  173. }
  174. }
  175. }
  176. Page pages = PageUtils.getPages(baseExpertVo.getPageNum().intValue(), baseExpertVo.getPageSize().intValue(), listVo);
  177. return success(pages);
  178. }
  179. @ApiOperation(value = "黑白名单开关", notes = "必传id,status 其他字段不传; 黑名单传0,白名单传1")
  180. @PostMapping("/updateSupplierType")
  181. @PreAuthorize("@ss.hasPermi('base:expert:updateSupplierType')")
  182. @Log(title = ModularConstans.expert, businessType = BusinessType.UPDATE)
  183. public AjaxResult updateSupplierType(@RequestBody BaseExpert baseExpert) {
  184. if (StringUtils.isNull(baseExpert) || StringUtils.isNull(baseExpert.getId())
  185. || StringUtils.isNull(baseExpert.getStatus())) {
  186. return error("状态及ID不能为空");
  187. }
  188. // LambdaQueryWrapper<BaseExpert> lw = new LambdaQueryWrapper<BaseExpert>();
  189. // if (!StringUtils.isNull(baseExpert.getId())) {
  190. // lw.eq(BaseExpert::getId, baseExpert.getId());
  191. // }
  192. // if (!StringUtils.isBlank(baseExpert.getStatus())) {
  193. // lw.eq(BaseExpert::getStatus, baseExpert.getStatus());
  194. // }
  195. return toAjax(baseExpertService.updateSupplierType(baseExpert));
  196. }
  197. @ApiOperation(value = "评审项目", notes = "必传:分页,专家ID")
  198. @PostMapping("/selectReviewProject")
  199. @PreAuthorize("@ss.hasPermi('base:expert:selectReviewProject')")
  200. @Log(title = ModularConstans.expert, businessType = BusinessType.OTHER)
  201. public AjaxResult selectReviewProject(@RequestBody BaseExpertVo baseExpertVo) {
  202. if (StringUtils.isNull(baseExpertVo)
  203. || StringUtils.isNull(baseExpertVo.getPageNum())
  204. || StringUtils.isNull(baseExpertVo.getPageSize())
  205. || StringUtils.isNull(baseExpertVo.getId())) {
  206. return error("专家ID、分页 不能为空");
  207. }
  208. return baseExpertService.selectReviewProject(baseExpertVo);
  209. }
  210. @ApiOperation(value = "抽取专家", notes = "必传:分页;非必传:专家名称,开始结束时间")
  211. @PostMapping("/selectExtractionExpert")
  212. @PreAuthorize("@ss.hasPermi('base:expert:selectExtractionExpert')")
  213. @Log(title = ModularConstans.expert, businessType = BusinessType.OTHER)
  214. public AjaxResult selectExtractionExpert(@RequestBody BaseExpertVo baseExpertVo) {
  215. if (StringUtils.isNull(baseExpertVo)
  216. || StringUtils.isNull(baseExpertVo.getPageNum())
  217. || StringUtils.isNull(baseExpertVo.getPageSize())) {
  218. return error("分页 不能为空");
  219. }
  220. return baseExpertService.selectExtractionExpert(baseExpertVo);
  221. }
  222. }