|
|
@@ -0,0 +1,266 @@
|
|
|
+package com.xunmei.core.evaluate.service.impl;
|
|
|
+
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.xunmei.common.core.constant.ErrorMsgConstants;
|
|
|
+import com.xunmei.common.core.constant.SecurityConstants;
|
|
|
+import com.xunmei.common.core.utils.DateUtils;
|
|
|
+import com.xunmei.common.core.web.page.TableDataInfo;
|
|
|
+import com.xunmei.common.security.utils.SecurityUtils;
|
|
|
+import com.xunmei.core.evaluate.domain.CoreEvaluateContent;
|
|
|
+import com.xunmei.core.evaluate.domain.CoreEvaluatePlan;
|
|
|
+import com.xunmei.core.evaluate.domain.CoreEvaluatePlanContent;
|
|
|
+import com.xunmei.core.evaluate.domain.CoreEvaluateRole;
|
|
|
+import com.xunmei.core.evaluate.dto.CoreEvaluatePlanDTO;
|
|
|
+import com.xunmei.core.evaluate.dto.EvaluateQueryDTO;
|
|
|
+import com.xunmei.core.evaluate.mapper.CoreEvaluateContentMapper;
|
|
|
+import com.xunmei.core.evaluate.mapper.CoreEvaluatePlanContentMapper;
|
|
|
+import com.xunmei.core.evaluate.mapper.CoreEvaluatePlanMapper;
|
|
|
+import com.xunmei.core.evaluate.mapper.CoreEvaluateRoleMapper;
|
|
|
+import com.xunmei.core.evaluate.service.ICoreEvaluatePlanService;
|
|
|
+import com.xunmei.core.evaluate.vo.CoreEvaluatePlanListVO;
|
|
|
+import com.xunmei.core.evaluate.vo.CoreEvaluatePlanVO;
|
|
|
+import com.xunmei.system.api.RemoteOrgService;
|
|
|
+import com.xunmei.system.api.RemoteUserService;
|
|
|
+import com.xunmei.system.api.domain.SysOrg;
|
|
|
+import com.xunmei.system.api.domain.SysUser;
|
|
|
+import com.xunmei.system.api.function.RemoteCallHandlerExecutor;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 外包评价计划Service业务层处理
|
|
|
+ *
|
|
|
+ * @author xunmei
|
|
|
+ * @date 2023-10-10
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class CoreEvaluatePlanServiceImpl extends ServiceImpl<CoreEvaluatePlanMapper, CoreEvaluatePlan> implements ICoreEvaluatePlanService {
|
|
|
+ @Autowired
|
|
|
+ private CoreEvaluatePlanMapper coreEvaluatePlanMapper;
|
|
|
+ @Autowired
|
|
|
+ private RemoteOrgService remoteOrgService;
|
|
|
+ @Autowired
|
|
|
+ private RemoteUserService remoteUserService;
|
|
|
+ @Autowired
|
|
|
+ private CoreEvaluateRoleMapper coreEvaluateRoleMapper;
|
|
|
+ @Autowired
|
|
|
+ private CoreEvaluateContentMapper coreEvaluateContentMapper;
|
|
|
+ @Autowired
|
|
|
+ private CoreEvaluatePlanContentMapper coreEvaluatePlanContentMapper;
|
|
|
+ @Resource
|
|
|
+ private RemoteOrgService orgService;
|
|
|
+/* @Override
|
|
|
+ public TableDataInfo<CoreEvaluatePlan> selectPage(CoreEvaluatePlan coreEvaluatePlan) {
|
|
|
+ //未删除
|
|
|
+ coreEvaluatePlan.setDeleted(0L);
|
|
|
+ Page<CoreEvaluatePlan> page;
|
|
|
+ //分页
|
|
|
+ if (coreEvaluatePlan.getPageNum()!=null&&coreEvaluatePlan.getPageSize()!=null)
|
|
|
+ {
|
|
|
+ page = new Page<>(coreEvaluatePlan.getPageNum(), coreEvaluatePlan.getPageSize());
|
|
|
+ }else{
|
|
|
+ page = new Page<>();
|
|
|
+ }
|
|
|
+ //查询条件
|
|
|
+ QueryWrapper<CoreEvaluatePlan> query = new QueryWrapper<>(coreEvaluatePlan);
|
|
|
+ //下穿
|
|
|
+ if (coreEvaluatePlan.getCheckSub()){
|
|
|
+ List<Long> ids = orgService.selectCheckSubOrgIdList(coreEvaluatePlan.getOrgId());
|
|
|
+ //清空前端传递的org_id
|
|
|
+ coreEvaluatePlan.setOrgId(null);
|
|
|
+ //添加in条件
|
|
|
+ query.in("org_id",ids);
|
|
|
+ }
|
|
|
+ //时间范围查询
|
|
|
+ if (coreEvaluatePlan.getParams().get("beginTime")!=null&&coreEvaluatePlan.getParams().get("endTime")!=null){
|
|
|
+ query.between("create_time", coreEvaluatePlan.getParams().get("beginTime"), coreEvaluatePlan.getParams().get("endTime"));
|
|
|
+ }
|
|
|
+ //获取数据
|
|
|
+ page = coreEvaluatePlanMapper.selectPage(page, query);
|
|
|
+ //抓换为TableDataInfo适配前端
|
|
|
+ return TableDataInfo.build(page);
|
|
|
+ }*/
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询外包评价计划
|
|
|
+ *
|
|
|
+ * @param id 外包评价计划主键
|
|
|
+ * @return 外包评价计划
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public CoreEvaluatePlanVO selectCoreEvaluatePlanById(Long id) {
|
|
|
+ CoreEvaluatePlanVO coreEvaluatePlanVO = new CoreEvaluatePlanVO();
|
|
|
+ CoreEvaluatePlan coreEvaluatePlan = coreEvaluatePlanMapper.selectById(id);
|
|
|
+ BeanUtils.copyProperties(coreEvaluatePlan, coreEvaluatePlanVO);
|
|
|
+ List<Long> roleList = coreEvaluateRoleMapper.getRoleByEvaluateId(id);
|
|
|
+ coreEvaluatePlanVO.setRoleIds(roleList);
|
|
|
+ List<CoreEvaluateContent> byEvaluateId = coreEvaluateContentMapper.getByEvaluateId(id);
|
|
|
+ coreEvaluatePlanVO.setCoreEvaluateContentList(byEvaluateId);
|
|
|
+ return coreEvaluatePlanVO;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int updateStatus(CoreEvaluatePlan coreEvaluatePlan) {
|
|
|
+ CoreEvaluatePlan coreEvaluatePlan1 = coreEvaluatePlanMapper.selectById(coreEvaluatePlan.getId());
|
|
|
+ coreEvaluatePlan1.setStatus(coreEvaluatePlan.getStatus());
|
|
|
+ return coreEvaluatePlanMapper.updateById(coreEvaluatePlan1);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询外包评价计划列表
|
|
|
+ *
|
|
|
+ * @param coreEvaluatePlan 外包评价计划
|
|
|
+ * @return 外包评价计划
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<CoreEvaluatePlan> selectCoreEvaluatePlanList(CoreEvaluatePlan coreEvaluatePlan) {
|
|
|
+ return coreEvaluatePlanMapper.selectList(new QueryWrapper<>(coreEvaluatePlan));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增外包评价计划
|
|
|
+ *
|
|
|
+ * @param coreEvaluatePlanDTO 外包评价计划
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public int insertCoreEvaluatePlan(CoreEvaluatePlanDTO coreEvaluatePlanDTO) {
|
|
|
+ CoreEvaluatePlan coreEvaluatePlan = new CoreEvaluatePlan();
|
|
|
+ BeanUtils.copyProperties(coreEvaluatePlanDTO, coreEvaluatePlan);
|
|
|
+ coreEvaluatePlan.setStatus("0");
|
|
|
+ coreEvaluatePlan.setCreateTime(DateUtils.getNowDate());
|
|
|
+ SysUser sysUser = remoteUserService.getUserById(SecurityUtils.getUserId(), SecurityConstants.INNER);
|
|
|
+ SysOrg sysOrg = remoteOrgService.selectSysOrgById(sysUser.getOrgId(), SecurityConstants.INNER);
|
|
|
+ coreEvaluatePlan.setCreateBy(SecurityUtils.getUsername());
|
|
|
+ coreEvaluatePlan.setOrgId(sysUser.getOrgId());
|
|
|
+ coreEvaluatePlan.setOrgName(sysOrg.getShortName());
|
|
|
+ coreEvaluatePlan.setIsDeleted("0");
|
|
|
+ long planId = IdWorker.getId();
|
|
|
+ coreEvaluatePlan.setId(planId);
|
|
|
+ int insert = 0;
|
|
|
+ //主体
|
|
|
+ insert = coreEvaluatePlanMapper.insert(coreEvaluatePlan);
|
|
|
+ //角色
|
|
|
+ coreEvaluatePlanDTO.getRoleIds().forEach(r -> {
|
|
|
+ CoreEvaluateRole coreEvaluateRole = new CoreEvaluateRole();
|
|
|
+ coreEvaluateRole.setRoleId(r);
|
|
|
+ coreEvaluateRole.setEvaluateId(planId);
|
|
|
+ coreEvaluateRoleMapper.insert(coreEvaluateRole);
|
|
|
+ });
|
|
|
+ //内容和计划绑定
|
|
|
+ coreEvaluatePlanDTO.getCoreEvaluateContentList().forEach(c -> {
|
|
|
+ long contentId = IdWorker.getId();
|
|
|
+ c.setId(contentId);
|
|
|
+ coreEvaluateContentMapper.insert(c);
|
|
|
+ CoreEvaluatePlanContent coreEvaluatePlanContent = new CoreEvaluatePlanContent();
|
|
|
+ coreEvaluatePlanContent.setContentId(contentId);
|
|
|
+ coreEvaluatePlanContent.setEvaluateId(planId);
|
|
|
+ coreEvaluatePlanContentMapper.insert(coreEvaluatePlanContent);
|
|
|
+ });
|
|
|
+ return insert;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改外包评价计划
|
|
|
+ *
|
|
|
+ * @param coreEvaluatePlanDTO 外包评价计划
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public int updateCoreEvaluatePlan(CoreEvaluatePlanDTO coreEvaluatePlanDTO) {
|
|
|
+ //todo
|
|
|
+ //删除未完成任务
|
|
|
+ CoreEvaluatePlan coreEvaluatePlan = new CoreEvaluatePlan();
|
|
|
+ BeanUtils.copyProperties(coreEvaluatePlanDTO, coreEvaluatePlan);
|
|
|
+ coreEvaluatePlan.setUpdateTime(DateUtils.getNowDate());
|
|
|
+ coreEvaluatePlan.setUpdateBy(SecurityUtils.getUsername());
|
|
|
+ //主体
|
|
|
+ int i = coreEvaluatePlanMapper.updateById(coreEvaluatePlan);
|
|
|
+ //角色
|
|
|
+ //先删除再新增
|
|
|
+ coreEvaluateRoleMapper.deleteByEvaluateId(coreEvaluatePlanDTO.getId());
|
|
|
+ coreEvaluatePlanDTO.getRoleIds().forEach(r -> {
|
|
|
+ CoreEvaluateRole coreEvaluateRole = new CoreEvaluateRole();
|
|
|
+ coreEvaluateRole.setRoleId(r);
|
|
|
+ coreEvaluateRole.setEvaluateId(coreEvaluatePlanDTO.getId());
|
|
|
+ coreEvaluateRoleMapper.insert(coreEvaluateRole);
|
|
|
+ });
|
|
|
+ //内容
|
|
|
+ coreEvaluatePlanContentMapper.deleteByEvaluateIdInt(coreEvaluatePlanDTO.getId());
|
|
|
+ coreEvaluatePlanDTO.getCoreEvaluateContentList().forEach(c -> {
|
|
|
+ CoreEvaluatePlanContent coreEvaluatePlanContent = new CoreEvaluatePlanContent();
|
|
|
+ if (null == c.getId()) {
|
|
|
+ long contentId = IdWorker.getId();
|
|
|
+ c.setId(contentId);
|
|
|
+ coreEvaluateContentMapper.insert(c);
|
|
|
+ coreEvaluatePlanContent.setContentId(contentId);
|
|
|
+ } else {
|
|
|
+ coreEvaluatePlanContent.setContentId(c.getId());
|
|
|
+ }
|
|
|
+ coreEvaluatePlanContent.setEvaluateId(coreEvaluatePlanDTO.getId());
|
|
|
+ coreEvaluatePlanContentMapper.insert(coreEvaluatePlanContent);
|
|
|
+ });
|
|
|
+ return i;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量删除外包评价计划
|
|
|
+ *
|
|
|
+ * @param ids 需要删除的外包评价计划主键
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public int deleteCoreEvaluatePlanByIds(Long[] ids) {
|
|
|
+ int delete = 1;
|
|
|
+ for (int i = 0; i < ids.length; i++) {
|
|
|
+ CoreEvaluatePlan coreEvaluatePlan1 = coreEvaluatePlanMapper.selectById(ids[i]);
|
|
|
+ coreEvaluatePlan1.setIsDeleted("1");
|
|
|
+ delete = coreEvaluatePlanMapper.updateById(coreEvaluatePlan1);
|
|
|
+ if (delete < 1) {
|
|
|
+ return delete;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return delete;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除外包评价计划信息
|
|
|
+ *
|
|
|
+ * @param id 外包评价计划主键
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public int deleteCoreEvaluatePlanById(Long id) {
|
|
|
+ return coreEvaluatePlanMapper.deleteById(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public TableDataInfo<CoreEvaluatePlanListVO> selectPage(EvaluateQueryDTO evaluateQueryDTO) {
|
|
|
+ Page<CoreEvaluatePlanListVO> page;
|
|
|
+ //分页
|
|
|
+ if (evaluateQueryDTO.getPageNum() != null && evaluateQueryDTO.getPageSize() != null) {
|
|
|
+ page = new Page<>(evaluateQueryDTO.getPageNum(), evaluateQueryDTO.getPageSize());
|
|
|
+ } else {
|
|
|
+ page = new Page<>();
|
|
|
+ }
|
|
|
+ //下穿
|
|
|
+ if (evaluateQueryDTO.getCheckSub()) {
|
|
|
+ SysOrg sysOrg = RemoteCallHandlerExecutor.executeRemoteCall(() -> orgService.selectSysOrgById(evaluateQueryDTO.getOrgId(), SecurityConstants.INNER), ErrorMsgConstants.QUERY_ORG_DATA_ERROR);
|
|
|
+ evaluateQueryDTO.setOrgPath(sysOrg.getPath());
|
|
|
+ evaluateQueryDTO.setOrgId(null);
|
|
|
+ }
|
|
|
+ page = coreEvaluatePlanMapper.selectPageList(page, evaluateQueryDTO);
|
|
|
+ //抓换为TableDataInfo适配前端
|
|
|
+ return TableDataInfo.build(page);
|
|
|
+ }
|
|
|
+}
|