Bladeren bron

服务计划需求

cr 2 maanden geleden
bovenliggende
commit
3106c86a63

+ 4 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/dto/ServicePlanDTO.java

@@ -32,4 +32,8 @@ public class ServicePlanDTO extends ServicePlan {
 	private static final long serialVersionUID = 1L;
 
     private String userId;
+
+    private String planStartTime1;
+
+    private String planEndTime1;
 }

+ 50 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/entity/ServicePlanTask.java

@@ -0,0 +1,50 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.manager.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import org.springblade.core.mp.base.BaseEntity;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 实体类
+ *
+ * @author BladeX
+ * @since 2025-06-27
+ */
+@Data
+@TableName("m_service_plan_task")
+@EqualsAndHashCode(callSuper = true)
+public class ServicePlanTask extends BaseEntity {
+
+	private static final long serialVersionUID = 1L;
+
+	/**
+	* 服务计划主键ID
+	*/
+		private Long servicePlanId;
+	/**
+	* 发送人ID
+	*/
+		private Long userId;
+
+		private Integer isCancel;
+
+
+}

+ 2 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/ServicePlanVO.java

@@ -45,4 +45,6 @@ public class ServicePlanVO extends ServicePlan {
 
    private String planTime;
 
+
+
 }

+ 56 - 13
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/ServicePlanController.java

@@ -18,6 +18,7 @@ package org.springblade.manager.controller;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import io.swagger.annotations.*;
@@ -43,6 +44,7 @@ import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.mp.support.Condition;
 import org.springblade.core.mp.support.Query;
 import org.springblade.core.oss.model.BladeFile;
+import org.springblade.core.secure.BladeUser;
 import org.springblade.core.secure.utils.SecureUtil;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.*;
@@ -50,6 +52,7 @@ import org.springblade.manager.bean.TableInfo;
 import org.springblade.manager.dto.ServicePlanDTO;
 import org.springblade.manager.dto.ServiceUserDto;
 import org.springblade.manager.entity.*;
+import org.springblade.manager.service.IServicePlanTaskService;
 import org.springblade.manager.utils.FileUtils;
 import org.springblade.system.cache.ParamCache;
 import org.springframework.jdbc.core.BeanPropertyRowMapper;
@@ -85,6 +88,8 @@ public class ServicePlanController extends BladeController {
 
 	private final IServicePlanService servicePlanService;
 
+    private final IServicePlanTaskService servicePlanTaskService;
+
     private final JdbcTemplate jdbcTemplate;
 
 	/**
@@ -172,25 +177,59 @@ public class ServicePlanController extends BladeController {
 //	}
     @GetMapping("/sendServicePlan")
     @ApiOperationSupport(order = 34)
-    @ApiOperation(value = "修改服务计划流程", notes = "修改服务计划流程")
+    @ApiOperation(value = "发送计划", notes = "修改服务计划流程")
     @ApiImplicitParams(value = {
         @ApiImplicitParam(name = "id", value = "计划id", required = true),
-        @ApiImplicitParam(name = "sendUser", value = "发送人ID 逗号拼接", required = false),
-        @ApiImplicitParam(name = "status", value = "2发送,3回退,4完成", required = true),
+        @ApiImplicitParam(name = "sendUser", value = "发送人ID 逗号拼接", required = true),
     })
-    public R changeServicePlanStatus(Long id,String sendUser,Integer status){
+    public R sendServicePlan(Long id,String sendUser){
+        ServicePlan plan = servicePlanService.getById(id);
+        plan.setStatus(2);
+        String[] split = sendUser.split(",");
+        for (String sid : split) {
+            ServicePlanTask task = servicePlanTaskService.getOne(new LambdaQueryWrapper<>(ServicePlanTask.class).eq(ServicePlanTask::getServicePlanId, id).eq(ServicePlanTask::getUserId, sid));
+            if(task==null){
+                task=new ServicePlanTask();
+            }
+            task.setServicePlanId(id);
+            task.setUserId(Long.valueOf(sid));
+            task.setStatus(2);
+            servicePlanTaskService.saveOrUpdate(task);
+        }
+        plan.setSendUser(sendUser);
+        servicePlanService.updateById(plan);
+        return R.status(true);
+    }
+
+    @GetMapping("/cancelServicePlan")
+    @ApiOperationSupport(order = 34)
+    @ApiOperation( value = "计划回退")
+    public R cancelServicePlan(Long id){
+        ServicePlan plan = servicePlanService.getById(id);
+        plan.setStatus(3);
+        String sql="update m_service_plan_task set status=3 where service_plan_id="+id+" and is_deleted=0";
+        jdbcTemplate.update(sql);
+        String sql2="update m_service_plan_task set is_cancel=1 where service_plan_id="+id+" and is_deleted=0 and user_id="+SecureUtil.getUserId();
+        jdbcTemplate.update(sql2);
+         return R.status(servicePlanService.updateById(plan));
+    }
+
+    @GetMapping("/confirmServicePlan")
+    @ApiOperationSupport(order = 34)
+    @ApiOperation( value = "确认计划")
+    public R confirmServicePlan(Long id){
         ServicePlan plan = servicePlanService.getById(id);
-        if(plan!=null){
-            if(StringUtils.isNotEmpty(sendUser)&&status==2){
-                plan.setSendUser(sendUser);
-                plan.setStatus(2);
-            } else if (status==3) {
-                plan.setStatus(3);
-            }else {
+        String sql="update m_service_plan_task set status=4 where service_plan_id="+id+" and user_id="+SecureUtil.getUserId();
+        jdbcTemplate.update(sql);
+        List<ServicePlanTask> tasks = servicePlanTaskService.getTaskByServicePlanId(id);
+        if(!tasks.isEmpty()){
+            List<ServicePlanTask> collect = tasks.stream().filter(o -> o.getStatus() != 4).collect(Collectors.toList());
+            if(collect.isEmpty()){
                 plan.setStatus(4);
+             return R.status(servicePlanService.updateById(plan));
             }
         }
-       return R.status(servicePlanService.updateById(plan));
+        return R.status(true);
     }
 
 	/**
@@ -302,9 +341,13 @@ public class ServicePlanController extends BladeController {
         Long pkeyId = Long.valueOf(dataInfo.getString("pkeyId"));
         Long projectId=Long.valueOf(dataInfo.getString("projectId"));
         Long contractId=Long.valueOf(dataInfo.getString("contractId"));
+        Long groupId1 = null;
+        if(dataInfo.containsKey("group_id")){
+            groupId1=Long.valueOf(dataInfo.getString("group_id"));
+        }
         dataArray.add(dataInfo);
         List<TableInfo> tableInfoList=getServiceData(dataArray);
-        Long groupId = servicePlanService.saveServicePlan(pkeyId,projectId,contractId,dataInfo);
+        Long groupId = servicePlanService.saveServicePlan(pkeyId,projectId,contractId,dataInfo,groupId1);
         servicePlanService.saveServiceData(tableInfoList,groupId,pkeyId);
         servicePlanService.saveServicePlanPdf(projectId,pkeyId,Func.toLong(groupId));
         return R.data(groupId);

+ 6 - 6
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ServicePlanMapper.xml

@@ -19,7 +19,7 @@
 
     <select id="selectServicePlanPage" resultMap="servicePlanResultMap">
         select * from m_service_plan where is_deleted = 0 and project_id = #{servicePlan.projectId} and contract_id = #{servicePlan.contractId}
-                                       and (FIND_IN_SET(write_user,#{servicePlan.userId}) or FIND_IN_SET(send_user,#{servicePlan.userId}))
+                                       and (FIND_IN_SET(#{servicePlan.userId},write_user) or FIND_IN_SET(#{servicePlan.userId},send_user))
         <if test="servicePlan.fileInType != null">
             and file_in_type = #{servicePlan.fileInType}
         </if>
@@ -32,12 +32,12 @@
         <if test="servicePlan.sendUser!=null">
             and FIND_IN_SET(send_user,#{servicePlan.sendUser})
         </if>
-        <if test="servicePlan.planStartTime != null and servicePlan.planEndTime != null">
+        <if test="servicePlan.planStartTime1 != null and servicePlan.planEndTime1 != null">
             and (
-            (#{servicePlan.planStartTime} between plan_start_time and plan_end_time)
-            or (#{servicePlan.planEndTime} between plan_start_time and plan_end_time)
-            or (plan_start_time between #{servicePlan.planStartTime} and #{servicePlan.planEndTime})
-            or (plan_end_time between #{servicePlan.planStartTime} and #{servicePlan.planEndTime})
+            (#{servicePlan.planStartTime1} between plan_start_time and plan_end_time)
+            or (#{servicePlan.planEndTime1} between plan_start_time and plan_end_time)
+            or (plan_start_time between #{servicePlan.planStartTime1} and #{servicePlan.planEndTime1})
+            or (plan_end_time between #{servicePlan.planStartTime1} and #{servicePlan.planEndTime1})
             )
         </if>
     </select>

+ 44 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ServicePlanTaskMapper.java

@@ -0,0 +1,44 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.manager.mapper;
+
+import io.lettuce.core.dynamic.annotation.Param;
+import org.springblade.manager.entity.ServicePlanTask;
+import org.springblade.manager.vo.ServicePlanTaskVO;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import java.util.List;
+
+/**
+ *  Mapper 接口
+ *
+ * @author BladeX
+ * @since 2025-06-27
+ */
+public interface ServicePlanTaskMapper extends BaseMapper<ServicePlanTask> {
+
+	/**
+	 * 自定义分页
+	 *
+	 * @param page
+	 * @param servicePlanTask
+	 * @return
+	 */
+	List<ServicePlanTaskVO> selectServicePlanTaskPage(IPage page, ServicePlanTaskVO servicePlanTask);
+
+    List<ServicePlanTask> getTaskByServicePlanId(@Param("id") Long id);
+}

+ 22 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ServicePlanTaskMapper.xml

@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.springblade.manager.mapper.ServicePlanTaskMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="servicePlanTaskResultMap" type="org.springblade.manager.entity.ServicePlanTask">
+        <result column="id" property="id"/>
+        <result column="status" property="status"/>
+        <result column="is_deleted" property="isDeleted"/>
+        <result column="service_plan_id" property="servicePlanId"/>
+        <result column="user_id" property="userId"/>
+    </resultMap>
+
+
+    <select id="selectServicePlanTaskPage" resultMap="servicePlanTaskResultMap">
+        select * from m_service_plan_task where is_deleted = 0
+    </select>
+    <select id="getTaskByServicePlanId" resultType="org.springblade.manager.entity.ServicePlanTask">
+         select * from m_service_plan_task where service_plan_id=#{id} and is_deleted=0;
+    </select>
+
+</mapper>

+ 1 - 1
blade-service/blade-manager/src/main/java/org/springblade/manager/service/IServicePlanService.java

@@ -57,7 +57,7 @@ public interface IServicePlanService extends BaseService<ServicePlan> {
 
     Map<String,List<ServiceUserDto>> getSendUserAndWriteUser(Long projectId, Long contractId);
 
-    Long saveServicePlan(Long pkeyId,Long projectId,Long contractId,@Valid JSONObject dataInfo);
+    Long saveServicePlan(Long pkeyId,Long projectId,Long contractId,@Valid JSONObject dataInfo,Long groupId1);
 
     ServicePlanVO getdetail(Long id);
 }

+ 44 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/service/IServicePlanTaskService.java

@@ -0,0 +1,44 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.manager.service;
+
+import org.springblade.manager.entity.ServicePlanTask;
+import org.springblade.manager.vo.ServicePlanTaskVO;
+import org.springblade.core.mp.base.BaseService;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+
+import java.util.List;
+
+/**
+ *  服务类
+ *
+ * @author BladeX
+ * @since 2025-06-27
+ */
+public interface IServicePlanTaskService extends BaseService<ServicePlanTask> {
+
+	/**
+	 * 自定义分页
+	 *
+	 * @param page
+	 * @param servicePlanTask
+	 * @return
+	 */
+	IPage<ServicePlanTaskVO> selectServicePlanTaskPage(IPage<ServicePlanTaskVO> page, ServicePlanTaskVO servicePlanTask);
+
+    List<ServicePlanTask> getTaskByServicePlanId(Long id);
+}

+ 8 - 8
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ServicePlanServiceImpl.java

@@ -99,7 +99,7 @@ public class ServicePlanServiceImpl extends BaseServiceImpl<ServicePlanMapper, S
         for (ServicePlan sp : vos) {
             ServicePlanVO vo = new ServicePlanVO();
             BeanUtil.copyProperties(sp, vo);
-           vo.setStatusValue(vo.getStatus()==1?"计划中":vo.getStatus()==2?"协同中-甲方":vo.getStatus()==3?"协同中-系统":"已计划");
+           vo.setStatusValue(vo.getStatus()==1?"计划中":vo.getStatus()==2?"确认中-甲方":vo.getStatus()==3?"反馈中-系统":"已计划");
            vo.setIsEdit(checkIsEdit(vo));
            if(vo.getPlanStartTime()!=null){
                vo.setStartTime(vo.getPlanStartTime().format(DateTimeFormatter.ofPattern("yyyy年M月d日")));
@@ -110,8 +110,8 @@ public class ServicePlanServiceImpl extends BaseServiceImpl<ServicePlanMapper, S
            if(StringUtils.isNotEmpty(vo.getStartTime())&&StringUtils.isNotEmpty(vo.getEndTime())){
                vo.setPlanTime(vo.getStartTime()+"至"+vo.getEndTime());
            }
-           vo.setWriteUserName(slectUserName(vo.getWriteUser()));
-           vo.setSendUserName(slectUserName(vo.getSendUser()));
+            vo.setWriteUserName(slectUserName(vo.getWriteUser()));
+            vo.setSendUserName(slectUserName(vo.getSendUser()));
             voList.add(vo);
         }
         return page.setRecords(voList);
@@ -556,7 +556,7 @@ public class ServicePlanServiceImpl extends BaseServiceImpl<ServicePlanMapper, S
                         } else if (tabVal.indexOf("_^_") >= 0) {
                             String[] tabData = tabVal.split("_\\^_");
                             if (StringUtils.isNotEmpty(tabData[0])) {
-                                if (tabVal.contains("[") && tabVal.contains("年")) {
+                                if (tabVal.contains("[")) {
                                     String[] strings = StringUtils.strip(tabData[0], "[]").split(",");
                                     reData.put(key + "__" + tabData[1], strings);
                                 } else {
@@ -605,7 +605,7 @@ public class ServicePlanServiceImpl extends BaseServiceImpl<ServicePlanMapper, S
     }
 
     @Override
-    public Long saveServicePlan(Long pkeyId,Long projectId,Long contractId,JSONObject dataInfo) {
+    public Long saveServicePlan(Long pkeyId,Long projectId,Long contractId,JSONObject dataInfo,Long groupId1) {
         ServicePlan plan = new ServicePlan();
         if(dataInfo.containsKey("key_15__3_4")){
             Object o = dataInfo.get("key_15__3_4");
@@ -631,8 +631,8 @@ public class ServicePlanServiceImpl extends BaseServiceImpl<ServicePlanMapper, S
                 plan.setPlanEndTime(LocalDate.parse(endDate));
             }
         }
-        if(dataInfo.containsKey("group_id")&&dataInfo.get("group_id")!=null&&StringUtils.isNotEmpty(dataInfo.get("group_id").toString())){
-            plan.setId(dataInfo.getLongValue("group_id"));
+        if(groupId1 != null){
+            plan.setId(groupId1);
             ServicePlan plan1 = this.getById(plan.getId());
             if(plan1.getWriteUser()!=null){
                 if(!plan1.getWriteUser().contains(SecureUtil.getUserId()+"")){
@@ -673,7 +673,7 @@ public class ServicePlanServiceImpl extends BaseServiceImpl<ServicePlanMapper, S
         if(StringUtils.isNotEmpty(vo.getStartTime())&&StringUtils.isNotEmpty(vo.getEndTime())){
             vo.setPlanTime(vo.getStartTime()+"至"+vo.getEndTime());
         }
-        vo.setWriteUser(slectUserName(vo.getWriteUser()));
+        vo.setWriteUserName(slectUserName(vo.getWriteUser()));
         vo.setSendUserName(slectUserName(vo.getSendUser()));
         return vo;
     }

+ 50 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ServicePlanTaskServiceImpl.java

@@ -0,0 +1,50 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.manager.service.impl;
+
+import org.springblade.manager.entity.ServicePlanTask;
+import org.springblade.manager.vo.ServicePlanTaskVO;
+import org.springblade.manager.mapper.ServicePlanTaskMapper;
+import org.springblade.manager.service.IServicePlanTaskService;
+import org.springblade.core.mp.base.BaseServiceImpl;
+import org.springframework.stereotype.Service;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+ *  服务实现类
+ *
+ * @author BladeX
+ * @since 2025-06-27
+ */
+@Service
+public class ServicePlanTaskServiceImpl extends BaseServiceImpl<ServicePlanTaskMapper, ServicePlanTask> implements IServicePlanTaskService {
+
+	@Override
+	public IPage<ServicePlanTaskVO> selectServicePlanTaskPage(IPage<ServicePlanTaskVO> page, ServicePlanTaskVO servicePlanTask) {
+		return page.setRecords(baseMapper.selectServicePlanTaskPage(page, servicePlanTask));
+	}
+
+	@Override
+	public List<ServicePlanTask> getTaskByServicePlanId(Long id) {
+
+		return baseMapper.getTaskByServicePlanId(id);
+	}
+
+}