Browse Source

添加任务接口

tall3
ma 4 years ago
parent
commit
48c8c25408
  1. 50
      common/src/main/java/com/ccsens/common/CommonApplication.java
  2. 200
      common/src/main/java/com/ccsens/common/api/TaskController.java
  3. 10
      common/src/main/java/com/ccsens/common/bean/dto/CTaskDto.java
  4. 44
      common/src/main/java/com/ccsens/common/config/BeanConfig.java
  5. 196
      common/src/main/java/com/ccsens/common/config/SpringConfig.java
  6. 112
      common/src/main/java/com/ccsens/common/config/SwaggerConfigure.java
  7. 1
      common/src/main/java/com/ccsens/common/persist/dao/LabelDao.java
  8. 7
      common/src/main/java/com/ccsens/common/persist/dao/ProTaskDetailDao.java
  9. 2
      common/src/main/java/com/ccsens/common/service/ITaskService.java
  10. 83
      common/src/main/java/com/ccsens/common/service/TaskService.java
  11. 16
      common/src/main/resources/mapper_dao/LabelDao.xml
  12. 34
      common/src/main/resources/mapper_dao/ProTaskDetailDao.xml

50
common/src/main/java/com/ccsens/common/CommonApplication.java

@ -1,25 +1,25 @@
//package com.ccsens.common;
//
//import org.mybatis.spring.annotation.MapperScan;
//import org.springframework.boot.SpringApplication;
//import org.springframework.boot.autoconfigure.SpringBootApplication;
//import org.springframework.boot.web.servlet.ServletComponentScan;
//import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
//import org.springframework.cloud.openfeign.EnableFeignClients;
//import org.springframework.scheduling.annotation.EnableAsync;
//
///**
// * @author ma
// */
//@MapperScan(basePackages = {"com.ccsens.common.persist.*"})
//@ServletComponentScan
//@EnableAsync
////开启断路器功能
//@EnableCircuitBreaker
//@EnableFeignClients(basePackages = "com.ccsens.cloudutil.feign")
//@SpringBootApplication(scanBasePackages = "com.ccsens")
//public class CommonApplication {
// public static void main(String[] args) {
// SpringApplication.run(CommonApplication.class,args);
// }
//}
package com.ccsens.common;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.scheduling.annotation.EnableAsync;
/**
* @author ma
*/
@MapperScan(basePackages = {"com.ccsens.common.persist.*"})
@ServletComponentScan
@EnableAsync
//开启断路器功能
@EnableCircuitBreaker
@EnableFeignClients(basePackages = "com.ccsens.cloudutil.feign")
@SpringBootApplication(scanBasePackages = "com.ccsens")
public class CommonApplication {
public static void main(String[] args) {
SpringApplication.run(CommonApplication.class,args);
}
}

200
common/src/main/java/com/ccsens/common/api/TaskController.java

@ -1,96 +1,104 @@
//package com.ccsens.common.api;
//
//import com.ccsens.cloudutil.annotation.MustLogin;
//import com.ccsens.common.bean.dto.CClockingInDto;
//import com.ccsens.common.bean.dto.CTaskDto;
//
//import com.ccsens.common.bean.vo.CClockingInVo;
//import com.ccsens.common.bean.vo.CTaskVo;
//
//import com.ccsens.common.service.IClockingInService;
//import com.ccsens.common.service.ITaskService;
//import com.ccsens.util.JsonResponse;
//import com.ccsens.util.bean.dto.QueryDto;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import io.swagger.annotations.ApiParam;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.validation.annotation.Validated;
//import org.springframework.web.bind.annotation.RequestBody;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestMethod;
//import org.springframework.web.bind.annotation.RestController;
//
//import javax.annotation.Resource;
//import java.util.List;
//
///**
// * @author 逗
// */
//@Api(tags = "DEBUG" , description = "DebugController | ")
//@RestController
//@RequestMapping("/task")
//@Slf4j
//public class TaskController {
//
// @Resource
// private ITaskService taskService;
// @Resource
// private IClockingInService clockingInService;
//
// @MustLogin
// @ApiOperation(value = "查找永久日常任务", notes = "")
// @RequestMapping(value = "/permanent", method = RequestMethod.POST, produces = {"application/json;charet=UTF-8"})
// public JsonResponse<List<CTaskVo.QueryTask>> queryPermanentGlobalTask(@ApiParam @Validated @RequestBody QueryDto<CTaskDto.QueryPermanentGlobalTask> params) {
// log.info("查找永久日常任务开始{}",params);
// List<CTaskVo.QueryTask> permanentGlobalTaskList = taskService.queryPermanentGlobalTask(params.getParam(),params.getUserId());
// log.info("查找永久日常任务结束{}",permanentGlobalTaskList);
// return JsonResponse.newInstance().ok(permanentGlobalTaskList);
// }
//
// @MustLogin
// @ApiOperation(value = "查找带时间的日常任务", notes = "")
// @RequestMapping(value = "/global", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
// public JsonResponse<List<CTaskVo.QueryTask>> queryGlobalTask(@ApiParam @Validated @RequestBody QueryDto<CTaskDto.QueryGlobalTask> params) {
// log.info("查找带时间的日常任务开始{}",params);
// List<CTaskVo.QueryTask> globalTask = taskService.queryGlobalTask(params.getParam(),params.getUserId());
// log.info("查找带时间的日常任务结束{}",globalTask);
// return JsonResponse.newInstance().ok(globalTask);
// }
//
// @MustLogin
// @ApiOperation(value = "查找带时间的定期任务", notes = "")
// @RequestMapping(value = "/regular", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
// public JsonResponse<List<CTaskVo.QueryTask>> queryRegularTask(@ApiParam @Validated @RequestBody QueryDto<CTaskDto.QueryRegularTask> params) {
// log.info("查找带时间的定期任务开始{}",params);
// List<CTaskVo.QueryTask> regularTask = taskService.queryRegularTask(params.getParam(), params.getUserId());
// log.info("查找带时间的定期任务结束{}",regularTask);
// return JsonResponse.newInstance().ok(regularTask);
// }
//
//
// @MustLogin
// @ApiOperation(value = "查询考勤信息", notes = "")
// @RequestMapping(value = "/query", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
// public JsonResponse<List<CClockingInVo.ClockingInInfo>> queryDeliverOfTask(@ApiParam @Validated @RequestBody QueryDto<CClockingInDto.QueryClockingIn> params) throws Exception{
// List<CClockingInVo.ClockingInInfo> clockingInInfos = clockingInService.queryClockingIn(params.getParam(), params.getUserId());
// return JsonResponse.newInstance().ok(clockingInInfos);
// }
//
// @MustLogin
// @ApiOperation(value = "打卡", notes = "")
// @RequestMapping(value = "/punch", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
// public JsonResponse punchTheClock(@ApiParam @Validated @RequestBody QueryDto<CClockingInDto.PunchTheClock> params) throws Exception{
// clockingInService.punchTheClock(params.getParam(), params.getUserId());
// return JsonResponse.newInstance().ok();
// }
//
// @MustLogin
// @ApiOperation(value = "导出考勤excel", notes = "")
// @RequestMapping(value = "/export", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
// public JsonResponse export(@ApiParam @Validated @RequestBody QueryDto<CClockingInDto.QueryClockingIn> params) throws Exception{
// clockingInService.exportRecord(params.getParam(), params.getUserId());
// return JsonResponse.newInstance().ok();
// }
//
//}
package com.ccsens.common.api;
import com.ccsens.cloudutil.annotation.MustLogin;
import com.ccsens.common.bean.dto.CClockingInDto;
import com.ccsens.common.bean.dto.CTaskDto;
import com.ccsens.common.bean.vo.CClockingInVo;
import com.ccsens.common.bean.vo.CTaskVo;
import com.ccsens.common.service.IClockingInService;
import com.ccsens.common.service.ITaskService;
import com.ccsens.util.JsonResponse;
import com.ccsens.util.bean.dto.QueryDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
/**
* @author
*/
@Api(tags = "DEBUG" , description = "DebugController | ")
@RestController
@RequestMapping("/task")
@Slf4j
public class TaskController {
@Resource
private ITaskService taskService;
@Resource
private IClockingInService clockingInService;
@MustLogin
@ApiOperation(value = "查找永久日常任务", notes = "")
@RequestMapping(value = "/permanent", method = RequestMethod.POST, produces = {"application/json;charet=UTF-8"})
public JsonResponse<List<CTaskVo.QueryTask>> queryPermanentGlobalTask(@ApiParam @Validated @RequestBody QueryDto<CTaskDto.QueryPermanentGlobalTask> params) {
log.info("查找永久日常任务开始{}",params);
List<CTaskVo.QueryTask> permanentGlobalTaskList = taskService.queryPermanentGlobalTask(params.getParam(),params.getUserId());
log.info("查找永久日常任务结束{}",permanentGlobalTaskList);
return JsonResponse.newInstance().ok(permanentGlobalTaskList);
}
@MustLogin
@ApiOperation(value = "查找带时间的日常任务", notes = "")
@RequestMapping(value = "/global", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse<List<CTaskVo.QueryTask>> queryGlobalTask(@ApiParam @Validated @RequestBody QueryDto<CTaskDto.QueryGlobalTask> params) {
log.info("查找带时间的日常任务开始{}",params);
List<CTaskVo.QueryTask> globalTask = taskService.queryGlobalTask(params.getParam(),params.getUserId());
log.info("查找带时间的日常任务结束{}",globalTask);
return JsonResponse.newInstance().ok(globalTask);
}
@MustLogin
@ApiOperation(value = "查找带时间的定期任务", notes = "")
@RequestMapping(value = "/regular", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse<List<CTaskVo.QueryTask>> queryRegularTask(@ApiParam @Validated @RequestBody QueryDto<CTaskDto.QueryRegularTask> params) {
log.info("查找带时间的定期任务开始{}",params);
List<CTaskVo.QueryTask> regularTask = taskService.queryRegularTask(params.getParam(), params.getUserId());
log.info("查找带时间的定期任务结束{}",regularTask);
return JsonResponse.newInstance().ok(regularTask);
}
@MustLogin
@ApiOperation(value = "查询考勤信息", notes = "")
@RequestMapping(value = "/query", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse<List<CClockingInVo.ClockingInInfo>> queryDeliverOfTask(@ApiParam @Validated @RequestBody QueryDto<CClockingInDto.QueryClockingIn> params) throws Exception{
List<CClockingInVo.ClockingInInfo> clockingInInfos = clockingInService.queryClockingIn(params.getParam(), params.getUserId());
return JsonResponse.newInstance().ok(clockingInInfos);
}
@MustLogin
@ApiOperation(value = "打卡", notes = "")
@RequestMapping(value = "/punch", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse punchTheClock(@ApiParam @Validated @RequestBody QueryDto<CClockingInDto.PunchTheClock> params) throws Exception{
clockingInService.punchTheClock(params.getParam(), params.getUserId());
return JsonResponse.newInstance().ok();
}
@MustLogin
@ApiOperation(value = "导出考勤excel", notes = "")
@RequestMapping(value = "/export", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse export(@ApiParam @Validated @RequestBody QueryDto<CClockingInDto.QueryClockingIn> params) throws Exception{
clockingInService.exportRecord(params.getParam(), params.getUserId());
return JsonResponse.newInstance().ok();
}
@ApiOperation(value = "添加任务", notes = "")
@RequestMapping(value = "/save", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse<List<CTaskVo.QueryTask>> saveTask(@ApiParam @Validated @RequestBody QueryDto<CTaskDto.SaveTask> params) throws Exception {
log.info("添加任务开始");
List<CTaskVo.QueryTask> taskList = taskService.saveTask(params.getParam(), params.getUserId());
log.info("添加任务结束{}",taskList);
return JsonResponse.newInstance().ok(taskList);
}
}

10
common/src/main/java/com/ccsens/common/bean/dto/CTaskDto.java

@ -87,21 +87,25 @@ public class CTaskDto {
@NotBlank(message = "任务名不能为空")
@ApiModelProperty("任务名")
private String name;
@NotBlank(message = "开始时间不能为空")
@NotNull(message = "开始时间不能为空")
@ApiModelProperty("开始时间")
private Long startTime;
@NotBlank(message = "结束时间不能为空")
@NotNull(message = "结束时间不能为空")
@ApiModelProperty("结束时间")
private Long endTime;
@ApiModelProperty("描述")
private String description;
@NotBlank(message = "项目id不能为空")
@NotNull(message = "项目id不能为空")
@ApiModelProperty("项目id")
private Long projectId;
@ApiModelProperty("父任务id")
private Long parentTaskId;
@ApiModelProperty("上道工序id(任务id)")
private Long processTaskId;
@ApiModelProperty("上道工序类型(0开始前,1开始时,2开始后,3结束前,4结束时,5结束后)")
private Byte processType = 4;
@ApiModelProperty("关联的绝对时间")
private Long timeDifference = 0L;
@ApiModelProperty("是否日常任务 0否 1是")
private byte global;

44
common/src/main/java/com/ccsens/common/config/BeanConfig.java

@ -1,22 +1,22 @@
//package com.ccsens.common.config;
//
//import com.ccsens.common.intercept.MybatisInterceptor;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//
///**
// * @description:
// * @author: wuHuiJuan
// * @create: 2019/12/11 10:59
// */
//@Configuration
//public class BeanConfig {
// /**
// * 注册拦截器
// */
// @Bean
// public MybatisInterceptor mybatisInterceptor() {
// MybatisInterceptor interceptor = new MybatisInterceptor();
// return interceptor;
// }
//}
package com.ccsens.common.config;
import com.ccsens.common.intercept.MybatisInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* @description:
* @author: wuHuiJuan
* @create: 2019/12/11 10:59
*/
@Configuration
public class BeanConfig {
/**
* 注册拦截器
*/
@Bean
public MybatisInterceptor mybatisInterceptor() {
MybatisInterceptor interceptor = new MybatisInterceptor();
return interceptor;
}
}

196
common/src/main/java/com/ccsens/common/config/SpringConfig.java

@ -1,98 +1,98 @@
//package com.ccsens.common.config;
//
//
//import cn.hutool.core.lang.Snowflake;
//import cn.hutool.core.util.IdUtil;
//import com.ccsens.util.config.DruidProps;
//import com.fasterxml.jackson.databind.DeserializationFeature;
//import com.fasterxml.jackson.databind.ObjectMapper;
//import com.fasterxml.jackson.databind.module.SimpleModule;
//import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.http.MediaType;
//import org.springframework.http.converter.HttpMessageConverter;
//import org.springframework.http.converter.StringHttpMessageConverter;
//import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
//import org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer;
//import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
//import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
//import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
//
//import javax.sql.DataSource;
//import java.nio.charset.Charset;
//import java.util.ArrayList;
//import java.util.List;
//
//@Configuration
////public class SpringConfig extends WebMvcConfigurationSupport {
//public class SpringConfig implements WebMvcConfigurer {
// @Autowired
// private DruidProps druidPropsUtil;
// @Value("${spring.snowflake.workerId}")
// private String workerId;
// @Value("${spring.snowflake.datacenterId}")
// private String datacenterId;
//
// /**
// * 配置Converter
// * @return
// */
// @Bean
// public HttpMessageConverter<String> responseStringConverter() {
// StringHttpMessageConverter converter = new StringHttpMessageConverter(
// Charset.forName("UTF-8"));
// return converter;
// }
//
// @Bean
// public HttpMessageConverter<Object> responseJsonConverter(){
// MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
// List<MediaType> mediaTypeList = new ArrayList<>();
// mediaTypeList.add(MediaType.TEXT_HTML);
// mediaTypeList.add(MediaType.APPLICATION_JSON_UTF8);
// converter.setSupportedMediaTypes(mediaTypeList);
//
// ObjectMapper objectMapper = new ObjectMapper();
// SimpleModule simpleModule = new SimpleModule();
// simpleModule.addSerializer(Long.class, ToStringSerializer.instance);
// simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance);
// objectMapper.registerModule(simpleModule);
// objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
// converter.setObjectMapper(objectMapper);
//
// return converter;
// }
//
// @Override
// public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
// converters.add(responseStringConverter());
// converters.add(responseJsonConverter());
// }
//
// @Override
// public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
// configurer.favorPathExtension(false);
// }
//
// /**
// * 配置数据源(单数据源)
// */
// @Bean
// public DataSource dataSource(){
// return druidPropsUtil.createDruidDataSource();
// }
//
// @Bean
// public Snowflake snowflake(){
// return IdUtil.createSnowflake(Long.valueOf(workerId),Long.valueOf(datacenterId));
// }
//
// @Override
// public void addResourceHandlers(ResourceHandlerRegistry registry) {
// registry.addResourceHandler("/uploads/**")
// .addResourceLocations("file:///home/cloud/ht/uploads/");
// }
//}
package com.ccsens.common.config;
import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
import com.ccsens.util.config.DruidProps;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import javax.sql.DataSource;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
@Configuration
//public class SpringConfig extends WebMvcConfigurationSupport {
public class SpringConfig implements WebMvcConfigurer {
@Autowired
private DruidProps druidPropsUtil;
@Value("${spring.snowflake.workerId}")
private String workerId;
@Value("${spring.snowflake.datacenterId}")
private String datacenterId;
/**
* 配置Converter
* @return
*/
@Bean
public HttpMessageConverter<String> responseStringConverter() {
StringHttpMessageConverter converter = new StringHttpMessageConverter(
Charset.forName("UTF-8"));
return converter;
}
@Bean
public HttpMessageConverter<Object> responseJsonConverter(){
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
List<MediaType> mediaTypeList = new ArrayList<>();
mediaTypeList.add(MediaType.TEXT_HTML);
mediaTypeList.add(MediaType.APPLICATION_JSON_UTF8);
converter.setSupportedMediaTypes(mediaTypeList);
ObjectMapper objectMapper = new ObjectMapper();
SimpleModule simpleModule = new SimpleModule();
simpleModule.addSerializer(Long.class, ToStringSerializer.instance);
simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance);
objectMapper.registerModule(simpleModule);
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
converter.setObjectMapper(objectMapper);
return converter;
}
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
converters.add(responseStringConverter());
converters.add(responseJsonConverter());
}
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
configurer.favorPathExtension(false);
}
/**
* 配置数据源单数据源
*/
@Bean
public DataSource dataSource(){
return druidPropsUtil.createDruidDataSource();
}
@Bean
public Snowflake snowflake(){
return IdUtil.createSnowflake(Long.valueOf(workerId),Long.valueOf(datacenterId));
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/uploads/**")
.addResourceLocations("file:///home/cloud/ht/uploads/");
}
}

112
common/src/main/java/com/ccsens/common/config/SwaggerConfigure.java

@ -1,56 +1,56 @@
//package com.ccsens.common.config;
//
//import com.ccsens.util.WebConstant;
//import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import springfox.documentation.builders.ParameterBuilder;
//import springfox.documentation.builders.RequestHandlerSelectors;
//import springfox.documentation.schema.ModelRef;
//import springfox.documentation.service.ApiInfo;
//import springfox.documentation.service.Parameter;
//import springfox.documentation.spi.DocumentationType;
//import springfox.documentation.spring.web.plugins.Docket;
//import springfox.documentation.swagger2.annotations.EnableSwagger2;
//
//import java.util.ArrayList;
//import java.util.List;
//
//@Configuration
//@EnableSwagger2
//@ConditionalOnExpression("${swagger.enable}")
////public class SwaggerConfigure extends WebMvcConfigurationSupport {
//public class SwaggerConfigure /*implements WebMvcConfigurer*/ {
// @Bean
// public Docket customDocket() {
// //
// return new Docket(DocumentationType.SWAGGER_2)
// .apiInfo(apiInfo())
// .select()
// .apis(RequestHandlerSelectors
// .basePackage("com.ccsens.common.api"))
// .build()
// .globalOperationParameters(setHeaderToken());
// }
//
// private ApiInfo apiInfo() {
// return new ApiInfo("Swagger Tall-ptpro",//大标题 title
// "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.",//小标题
// "1.0.0",//版本
// "http://swagger.io/terms/",//termsOfServiceUrl
// "zhangsan",//作者
// "Apache 2.0",//链接显示文字
// "http://www.apache.org/licenses/LICENSE-2.0.html"//网站链接
// );
// }
//
// private List<Parameter> setHeaderToken() {
// ParameterBuilder tokenPar = new ParameterBuilder();
// List<Parameter> pars = new ArrayList<>();
// tokenPar.name(WebConstant.HEADER_KEY_TOKEN).description("token")
// .defaultValue(WebConstant.HEADER_KEY_TOKEN_PREFIX)
// .modelRef(new ModelRef("string")).parameterType("header").required(false).build();
// pars.add(tokenPar.build());
// return pars;
// }
//}
package com.ccsens.common.config;
import com.ccsens.util.WebConstant;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ParameterBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.schema.ModelRef;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Parameter;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import java.util.ArrayList;
import java.util.List;
@Configuration
@EnableSwagger2
@ConditionalOnExpression("${swagger.enable}")
//public class SwaggerConfigure extends WebMvcConfigurationSupport {
public class SwaggerConfigure /*implements WebMvcConfigurer*/ {
@Bean
public Docket customDocket() {
//
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors
.basePackage("com.ccsens.common.api"))
.build()
.globalOperationParameters(setHeaderToken());
}
private ApiInfo apiInfo() {
return new ApiInfo("Swagger Tall-ptpro",//大标题 title
"This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.",//小标题
"1.0.0",//版本
"http://swagger.io/terms/",//termsOfServiceUrl
"zhangsan",//作者
"Apache 2.0",//链接显示文字
"http://www.apache.org/licenses/LICENSE-2.0.html"//网站链接
);
}
private List<Parameter> setHeaderToken() {
ParameterBuilder tokenPar = new ParameterBuilder();
List<Parameter> pars = new ArrayList<>();
tokenPar.name(WebConstant.HEADER_KEY_TOKEN).description("token")
.defaultValue(WebConstant.HEADER_KEY_TOKEN_PREFIX)
.modelRef(new ModelRef("string")).parameterType("header").required(false).build();
pars.add(tokenPar.build());
return pars;
}
}

1
common/src/main/java/com/ccsens/common/persist/dao/LabelDao.java

@ -11,4 +11,5 @@ public interface LabelDao extends LabelMapper {
String queryIsPm(Long labelId);
Long getLabelByTypeAndLevel(@Param("type")int type, @Param("level")int level);
}

7
common/src/main/java/com/ccsens/common/persist/dao/ProTaskDetailDao.java

@ -79,4 +79,11 @@ public interface ProTaskDetailDao extends ProTaskDetailMapper {
* @return 子任务列表
*/
List<CTaskVo.SonTaskDetail> findSonTask(CTaskDto.FindSonTask param);
/**
* 根据任务id查询任务信息
* @param id 任务详情id
* @return 任务及相关信息
*/
CTaskVo.QueryTask queryTaskById(@Param("taskDetailId") Long id);
}

2
common/src/main/java/com/ccsens/common/service/ITaskService.java

@ -63,5 +63,5 @@ public interface ITaskService {
* @param userId 用户id
* @return 子项目列表
*/
CTaskVo.QueryTask saveTask(CTaskDto.SaveTask param,Long userId);
List<CTaskVo.QueryTask> saveTask(CTaskDto.SaveTask param,Long userId);
}

83
common/src/main/java/com/ccsens/common/service/TaskService.java

@ -19,6 +19,7 @@ import com.ccsens.util.bean.message.common.InMessage;
import com.ccsens.util.bean.message.common.MessageConstant;
import com.ccsens.util.config.RabbitMQConfig;
import com.ccsens.util.exception.BaseException;
import com.sun.org.apache.bcel.internal.generic.NEW;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.stereotype.Service;
@ -60,6 +61,14 @@ public class TaskService implements ITaskService {
private AmqpTemplate rabbitTemplate;
@Resource
private ProTaskProcessDao taskProcessDao;
@Resource
private LabelDao labelDao;
@Resource
private LabelBusinessDao labelBusinessDao;
@Resource
private ProParentTaskDao parentTaskDao;
@Resource
private ProRoleTaskDao roleTaskDao;
/**
* 判断当前用户的角色是否被设置不可见(是否有权限查看任务)
@ -595,17 +604,87 @@ public class TaskService implements ITaskService {
}
@Override
public CTaskVo.QueryTask saveTask(CTaskDto.SaveTask param, Long userId) {
public List<CTaskVo.QueryTask> saveTask(CTaskDto.SaveTask param, Long userId) {
//任务详情
ProTaskDetail proTaskDetail = new ProTaskDetail();
proTaskDetail.setId(snowflake.nextId());
proTaskDetail.setName(param.getName());
proTaskDetail.setDescription(param.getDescription());
taskDetailDao.insertSelective(proTaskDetail);
//任务分解信息
ProTaskSub taskSub = new ProTaskSub();
taskSub.setId(snowflake.nextId());
taskSub.setPlanStartTime(param.getStartTime());
taskSub.setPlanEndTime(param.getEndTime());
taskSub.setTaskDetailId(proTaskDetail.getId());
taskSubDao.insertSelective(taskSub);
//任务添加标签(天,普通/日常任务)
//天
Long labelOfDay = labelDao.getLabelByTypeAndLevel(0, 4);
LabelBusiness labelDay = new LabelBusiness();
labelDay.setId(snowflake.nextId());
labelDay.setLabelId(labelOfDay);
labelDay.setBusinessId(proTaskDetail.getId());
labelBusinessDao.insertSelective(labelDay);
//定期/日常任务
LabelBusiness taskOfType = new LabelBusiness();
taskOfType.setId(snowflake.nextId());
taskOfType.setBusinessId(proTaskDetail.getId());
if (1 == param.getGlobal()) {
Long everyday = labelDao.getLabelByTypeAndLevel(1, 2);
taskOfType.setLabelId(everyday);
}else{
Long regular = labelDao.getLabelByTypeAndLevel(1, 3);
taskOfType.setLabelId(regular);
}
labelBusinessDao.insertSelective(taskOfType);
//任务关系表(父任务)(项目id)
if (ObjectUtil.isNotNull(param.getParentTaskId())) {
ProParentTask proParentTask = new ProParentTask();
proParentTask.setId(snowflake.nextId());
proParentTask.setParentTaskDetailId(param.getParentTaskId());
proParentTask.setTaskDetailId(proTaskDetail.getId());
parentTaskDao.insertSelective(proParentTask);
}
//角色任务关联表(负责人)
if (CollectionUtil.isNotEmpty(param.getRoleIdList())) {
for (Long roleId : param.getRoleIdList()) {
ProRoleTask roleTask = new ProRoleTask();
roleTask.setId(snowflake.nextId());
roleTask.setRoleId(roleId);
roleTask.setTaskId(proTaskDetail.getId());
roleTask.setOperator(userId);
roleTaskDao.insertSelective(roleTask);
}
}
//TODO 检查人(待定)
//上下道工序
if (ObjectUtil.isNotNull(param.getProcessTaskId())) {
ProTaskProcess taskProcess = new ProTaskProcess();
taskProcess.setId(snowflake.nextId());
taskProcess.setTaskDetailId(proTaskDetail.getId());
taskProcess.setNextTaskDetailId(param.getProcessTaskId());
taskProcess.setProcessType(param.getProcessType());
taskProcess.setTimeDifference(param.getTimeDifference());
taskProcessDao.insertSelective(taskProcess);
}
//插件(添加一个任务名插件)
ProTaskPlugin proTaskPlugin = new ProTaskPlugin();
proTaskPlugin.setId(snowflake.nextId());
proTaskPlugin.setTaskDetailId(proTaskDetail.getId());
proTaskPlugin.setPluginId(1L);
proTaskPlugin.setPlginRow(1);
proTaskPlugin.setPlginCol(1);
proTaskPlugin.setRowspan(1);
proTaskPlugin.setColspan(1);
taskPluginDao.insertSelective(proTaskPlugin);
//TODO 交付物(待定)
return null;
CTaskVo.QueryTask taskInfo = taskDetailDao.queryTaskById(proTaskDetail.getId());
List<CTaskVo.QueryTask> taskList = new ArrayList<>();
taskList.add(taskInfo);
queryPluginForTask(taskList);
return taskList;
}
}

16
common/src/main/resources/mapper_dao/LabelDao.xml

@ -10,10 +10,18 @@
and t_label.label_type_id=t_label_type.id
</select>
<select id="getLabelByTypeAndLevel" resultType="java.lang.Long">
SELECT
l.id
FROM
t_label l
LEFT JOIN t_label_type lt on l.label_type_id = lt.id
WHERE
lt.label_type = #{type}
and
l.level = #{level}
limit 1
</select>
</mapper>

34
common/src/main/resources/mapper_dao/ProTaskDetailDao.xml

@ -379,4 +379,38 @@
AND pt.parent_task_detail_id = #{detailId}
</select>
<select id="queryTaskById" resultType="com.ccsens.common.bean.vo.CTaskVo$QueryTask">
SELECT
ts.id,
td.id AS detailId,
td.`name`,
td.description,
ts.plan_start_time AS planStart,
ts.plan_duration,
ts.plan_end_time AS planEnd,
ts.real_start_time AS realStart,
ts.real_duration,
ts.real_end_time AS realEnd,
ts.task_status AS process,
tf.flow_type AS skip,
tf.jump_task_detail_id AS skipTaskId,
tpi.back_color AS backgroundColor,
tpi.round_corner AS borderRadius,
tpi.border AS border,
tpi.shadow AS shadow,
tpi.width AS width,
tpi.height AS height,
tpi.`row` AS `row`,
tpi.col AS col
FROM
t_pro_task_detail AS td
LEFT JOIN t_pro_task_sub AS ts ON ts.task_detail_id = td.id
LEFT JOIN t_pro_task_flow AS tf ON tf.task_detail_id = td.id AND tf.rec_status = 0
LEFT JOIN t_pro_role_task AS rt ON rt.task_id = td.id
LEFT JOIN t_pro_task_panel_info AS tpi ON tpi.task_detail_id = td.id AND tpi.rec_status = 0
WHERE
td.rec_status = 0 AND ts.rec_status = 0 AND rt.rec_status = 0
AND td.id = #{taskDetailId}
</select>
</mapper>
Loading…
Cancel
Save