|
@@ -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);
|