|  | @@ -8,6 +8,7 @@ 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.utils.StringUtils;
 | 
	
		
			
				|  |  |  import com.xunmei.common.core.web.page.TableDataInfo;
 | 
	
		
			
				|  |  |  import com.xunmei.common.security.utils.SecurityUtils;
 | 
	
		
			
				|  |  |  import com.xunmei.core.evaluate.domain.*;
 | 
	
	
		
			
				|  | @@ -22,6 +23,7 @@ import com.xunmei.core.evaluate.service.ICoreEvaluateTaskService;
 | 
	
		
			
				|  |  |  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.RemoteRoleService;
 | 
	
		
			
				|  |  |  import com.xunmei.system.api.RemoteUserService;
 | 
	
		
			
				|  |  |  import com.xunmei.system.api.domain.SysOrg;
 | 
	
		
			
				|  |  |  import com.xunmei.system.api.domain.SysUser;
 | 
	
	
		
			
				|  | @@ -63,6 +65,8 @@ public class CoreEvaluatePlanServiceImpl extends ServiceImpl<CoreEvaluatePlanMap
 | 
	
		
			
				|  |  |      private RemoteOrgService orgService;
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private ICoreEvaluateTaskService coreEvaluateTaskService;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private RemoteRoleService remoteRoleService;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 查询外包评价计划
 | 
	
	
		
			
				|  | @@ -108,6 +112,9 @@ public class CoreEvaluatePlanServiceImpl extends ServiceImpl<CoreEvaluatePlanMap
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public int insertCoreEvaluatePlan(CoreEvaluatePlanDTO coreEvaluatePlanDTO) {
 | 
	
		
			
				|  |  | +        if (!check(SecurityUtils.getUserId())) {
 | 
	
		
			
				|  |  | +            throw new RuntimeException("该角色没有新增权限");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |          CoreEvaluatePlan coreEvaluatePlan = new CoreEvaluatePlan();
 | 
	
		
			
				|  |  |          BeanUtils.copyProperties(coreEvaluatePlanDTO, coreEvaluatePlan);
 | 
	
		
			
				|  |  |          coreEvaluatePlan.setCreateTime(DateUtils.getNowDate());
 | 
	
	
		
			
				|  | @@ -119,7 +126,7 @@ public class CoreEvaluatePlanServiceImpl extends ServiceImpl<CoreEvaluatePlanMap
 | 
	
		
			
				|  |  |          coreEvaluatePlan.setOrgPath(sysOrg.getPath());
 | 
	
		
			
				|  |  |          long planId = IdWorker.getId();
 | 
	
		
			
				|  |  |          coreEvaluatePlan.setId(planId);
 | 
	
		
			
				|  |  | -        int insert = 0;
 | 
	
		
			
				|  |  | +        int insert;
 | 
	
		
			
				|  |  |          //主体
 | 
	
		
			
				|  |  |          insert = coreEvaluatePlanMapper.insert(coreEvaluatePlan);
 | 
	
		
			
				|  |  |          //角色
 | 
	
	
		
			
				|  | @@ -139,12 +146,36 @@ public class CoreEvaluatePlanServiceImpl extends ServiceImpl<CoreEvaluatePlanMap
 | 
	
		
			
				|  |  |              coreEvaluatePlanContent.setEvaluateId(planId);
 | 
	
		
			
				|  |  |              coreEvaluatePlanContentMapper.insert(coreEvaluatePlanContent);
 | 
	
		
			
				|  |  |          });
 | 
	
		
			
				|  |  | -        if (coreEvaluatePlanDTO.getBuildTaskNow()){
 | 
	
		
			
				|  |  | +  /*      if (coreEvaluatePlanDTO.getBuildTaskNow()) {
 | 
	
		
			
				|  |  |              this.distribute(planId);
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | +        }*/
 | 
	
		
			
				|  |  |          return insert;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    private boolean check(Long userId) {
 | 
	
		
			
				|  |  | +        String s = remoteRoleService.selectRoleNameByUserId(userId, SecurityConstants.INNER);
 | 
	
		
			
				|  |  | +        boolean admin = false;
 | 
	
		
			
				|  |  | +        if (StringUtils.isNotEmpty(s)) {
 | 
	
		
			
				|  |  | +            int i = s.indexOf(",");
 | 
	
		
			
				|  |  | +            if (i >= 0) {
 | 
	
		
			
				|  |  | +                String[] split = s.split(",");
 | 
	
		
			
				|  |  | +                for (int l = 0; l < split.length; l++) {
 | 
	
		
			
				|  |  | +                    if (split[l].equals("省联社安全保卫管理人员") || split[l].equals("超级管理员")
 | 
	
		
			
				|  |  | +                            || split[l].equals("行社安全保卫管理人员")) {
 | 
	
		
			
				|  |  | +                        admin = true;
 | 
	
		
			
				|  |  | +                        break;
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            } else if (s.equals("省联社安全保卫管理人员") || s.equals("超级管理员") || s.equals("行社安全保卫管理人员")
 | 
	
		
			
				|  |  | +            ) {
 | 
	
		
			
				|  |  | +                admin = true;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        } else if (SecurityUtils.getUserId() == 1) {
 | 
	
		
			
				|  |  | +            admin = true;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return admin;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 修改外包评价计划
 | 
	
		
			
				|  |  |       *
 | 
	
	
		
			
				|  | @@ -153,6 +184,9 @@ public class CoreEvaluatePlanServiceImpl extends ServiceImpl<CoreEvaluatePlanMap
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public int updateCoreEvaluatePlan(CoreEvaluatePlanDTO coreEvaluatePlanDTO) {
 | 
	
		
			
				|  |  | +        if (!check(SecurityUtils.getUserId())) {
 | 
	
		
			
				|  |  | +            throw new RuntimeException("该角色没有修改权限");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |          //删除未完成任务
 | 
	
		
			
				|  |  |          List status = new ArrayList();
 | 
	
		
			
				|  |  |          status.add("0");
 | 
	
	
		
			
				|  | @@ -189,12 +223,16 @@ public class CoreEvaluatePlanServiceImpl extends ServiceImpl<CoreEvaluatePlanMap
 | 
	
		
			
				|  |  |              coreEvaluatePlanContent.setEvaluateId(coreEvaluatePlanDTO.getId());
 | 
	
		
			
				|  |  |              coreEvaluatePlanContentMapper.insert(coreEvaluatePlanContent);
 | 
	
		
			
				|  |  |          });
 | 
	
		
			
				|  |  | +      /*  if (coreEvaluatePlanDTO.getBuildTaskNow()) {
 | 
	
		
			
				|  |  | +            this.distribute(coreEvaluatePlanDTO.getId());
 | 
	
		
			
				|  |  | +        }*/
 | 
	
		
			
				|  |  |          return i;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public int distribute(Long id) {
 | 
	
		
			
				|  |  |          CoreEvaluatePlanVO coreEvaluatePlanVO = this.selectCoreEvaluatePlanById(id);
 | 
	
		
			
				|  |  | +        CoreEvaluatePlan coreEvaluatePlan = baseMapper.selectById(id);
 | 
	
		
			
				|  |  |          SysOrg org = new SysOrg();
 | 
	
		
			
				|  |  |          org.setType(Integer.valueOf(coreEvaluatePlanVO.getOrgType()));
 | 
	
		
			
				|  |  |          org.setPath(coreEvaluatePlanVO.getOrgPath());
 | 
	
	
		
			
				|  | @@ -211,7 +249,7 @@ public class CoreEvaluatePlanServiceImpl extends ServiceImpl<CoreEvaluatePlanMap
 | 
	
		
			
				|  |  |                  time = 13;
 | 
	
		
			
				|  |  |                  break;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        int i = 1;
 | 
	
		
			
				|  |  | +        int i;
 | 
	
		
			
				|  |  |          LocalDate localDate = getTime(time);
 | 
	
		
			
				|  |  |          String firstDay = DateUtils.parseDateToStr("yyyy-MM-dd 23:59:59", Date.from(localDate.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant()));
 | 
	
		
			
				|  |  |          SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 | 
	
	
		
			
				|  | @@ -221,27 +259,39 @@ public class CoreEvaluatePlanServiceImpl extends ServiceImpl<CoreEvaluatePlanMap
 | 
	
		
			
				|  |  |          } catch (Exception e) {
 | 
	
		
			
				|  |  |              e.getMessage();
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        for (SysOrg l : list) {
 | 
	
		
			
				|  |  | -            CoreEvaluateTask coreEvaluateTask = new CoreEvaluateTask();
 | 
	
		
			
				|  |  | -            coreEvaluateTask.setPlanId(id);
 | 
	
		
			
				|  |  | -            coreEvaluateTask.setOrgId(l.getId());
 | 
	
		
			
				|  |  | -            coreEvaluateTask.setStatus("0");
 | 
	
		
			
				|  |  | -            coreEvaluateTask.setOrgName(l.getShortName());
 | 
	
		
			
				|  |  | -            coreEvaluateTask.setEvaluateName(coreEvaluatePlanVO.getEvaluateName());
 | 
	
		
			
				|  |  | -            coreEvaluateTask.setCreateTime(DateUtils.getNowDate());
 | 
	
		
			
				|  |  | -            coreEvaluateTask.setCreateBy(coreEvaluatePlanVO.getCreateBy());
 | 
	
		
			
				|  |  | -            coreEvaluateTask.setStartTime(DateUtils.getNowDate());
 | 
	
		
			
				|  |  | -            coreEvaluateTask.setEndTime(endTime);
 | 
	
		
			
				|  |  | -            i = coreEvaluateTaskService.insertCoreEvaluateTask(coreEvaluateTask);
 | 
	
		
			
				|  |  | -            if (i < 1) {
 | 
	
		
			
				|  |  | -                return i;
 | 
	
		
			
				|  |  | +        //如果立即执行
 | 
	
		
			
				|  |  | +        if (coreEvaluatePlan.getBuildTaskNow()) {
 | 
	
		
			
				|  |  | +            for (SysOrg l : list) {
 | 
	
		
			
				|  |  | +                CoreEvaluateTask coreEvaluateTask = new CoreEvaluateTask();
 | 
	
		
			
				|  |  | +                coreEvaluateTask.setPlanId(id);
 | 
	
		
			
				|  |  | +                coreEvaluateTask.setOrgId(l.getId());
 | 
	
		
			
				|  |  | +                coreEvaluateTask.setStatus("0");
 | 
	
		
			
				|  |  | +                coreEvaluateTask.setOrgName(l.getShortName());
 | 
	
		
			
				|  |  | +                coreEvaluateTask.setOrgPath(l.getPath());
 | 
	
		
			
				|  |  | +                coreEvaluateTask.setEvaluateName(coreEvaluatePlanVO.getEvaluateName());
 | 
	
		
			
				|  |  | +                coreEvaluateTask.setCreateTime(DateUtils.getNowDate());
 | 
	
		
			
				|  |  | +                coreEvaluateTask.setCreateBy(coreEvaluatePlanVO.getCreateBy());
 | 
	
		
			
				|  |  | +                coreEvaluateTask.setStartTime(DateUtils.getNowDate());
 | 
	
		
			
				|  |  | +                coreEvaluateTask.setEndTime(endTime);
 | 
	
		
			
				|  |  | +                i = coreEvaluateTaskService.insertCoreEvaluateTask(coreEvaluateTask);
 | 
	
		
			
				|  |  | +                if (i < 1) {
 | 
	
		
			
				|  |  | +                    return i;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        CoreEvaluatePlan coreEvaluatePlan = baseMapper.selectById(id);
 | 
	
		
			
				|  |  |          coreEvaluatePlan.setIsDistribute("1");
 | 
	
		
			
				|  |  | -        baseMapper.updateById(coreEvaluatePlan);
 | 
	
		
			
				|  |  | +        i = baseMapper.updateById(coreEvaluatePlan);
 | 
	
		
			
				|  |  |          return i;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    public void generate(String cycle) {
 | 
	
		
			
				|  |  | +        List<CoreEvaluatePlan> coreEvaluatePlans = baseMapper.selectPlanByCycle(cycle);
 | 
	
		
			
				|  |  | +        coreEvaluatePlans.forEach(c -> {
 | 
	
		
			
				|  |  | +            distribute(c.getId());
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      public LocalDate getTime(int time) {
 | 
	
		
			
				|  |  |          LocalDate localDate = LocalDate.now();
 | 
	
		
			
				|  |  |          LocalDate nextMonthFirstDay = localDate.plusMonths(time).withDayOfMonth(1);
 |