Commit c6c4db66 authored by 竹天卫's avatar 竹天卫
parents d1290be8 13a63fe4
......@@ -10,9 +10,8 @@ import java.util.TimeZone;
/**
* 启动类
*
* @author zhutianwei
*
* @author zhutianwei
*/
@SpringBootApplication
@MapperScan("cn.wise.sc.cement.business.mapper")
......@@ -25,10 +24,8 @@ public class TJCementApplication {
}
@Bean
public RestTemplate restTemplate(){
public RestTemplate restTemplate() {
return new RestTemplate();
}
}
......@@ -32,116 +32,120 @@ import java.util.Date;
@Configuration
public class DateConfig {
/** 默认日期时间格式 */
public static final String DEFAULT_DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
/** 默认日期格式 */
public static final String DEFAULT_DATE_FORMAT = "yyyy-MM-dd";
/** 默认时间格式 */
public static final String DEFAULT_TIME_FORMAT = "HH:mm:ss";
/**
* LocalDate转换器,用于转换RequestParam和PathVariable参数
*/
@Bean
public Converter<String, LocalDate> localDateConverter() {
return new Converter<String, LocalDate>() {
@Override
public LocalDate convert(String source) {
return LocalDate.parse(source, DateTimeFormatter.ofPattern(DEFAULT_DATE_FORMAT));
}
};
}
/**
* LocalDateTime转换器,用于转换RequestParam和PathVariable参数
*/
@Bean
public Converter<String, LocalDateTime> localDateTimeConverter() {
return new Converter<String, LocalDateTime>() {
@Override
public LocalDateTime convert(String source) {
return LocalDateTime.parse(source, DateTimeFormatter.ofPattern(DEFAULT_DATE_TIME_FORMAT));
}
};
}
/**
* LocalTime转换器,用于转换RequestParam和PathVariable参数
*/
@Bean
public Converter<String, LocalTime> localTimeConverter() {
return new Converter<String, LocalTime>() {
@Override
public LocalTime convert(String source) {
return LocalTime.parse(source, DateTimeFormatter.ofPattern(DEFAULT_TIME_FORMAT));
}
};
}
/**
* Date转换器,用于转换RequestParam和PathVariable参数
*/
@Bean
public Converter<String, Date> dateConverter() {
return new Converter<String, Date>() {
@Override
public Date convert(String source) {
SimpleDateFormat format = new SimpleDateFormat(DEFAULT_DATE_TIME_FORMAT);
try {
return format.parse(source);
} catch (ParseException e) {
throw new RuntimeException(e);
}
}
};
}
/**
* Json序列化和反序列化转换器,用于转换Post请求体中的json以及将我们的对象序列化为返回响应的json
*/
@Bean
public ObjectMapper objectMapper(){
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
objectMapper.disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE);
//ObjectMapper忽略多余字段
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
//LocalDateTime系列序列化和反序列化模块,继承自jsr310,我们在这里修改了日期格式
JavaTimeModule javaTimeModule = new JavaTimeModule();
javaTimeModule.addSerializer(LocalDateTime.class,new LocalDateTimeSerializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_TIME_FORMAT)));
javaTimeModule.addSerializer(LocalDate.class,new LocalDateSerializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_FORMAT)));
javaTimeModule.addSerializer(LocalTime.class,new LocalTimeSerializer(DateTimeFormatter.ofPattern(DEFAULT_TIME_FORMAT)));
javaTimeModule.addDeserializer(LocalDateTime.class,new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_TIME_FORMAT)));
javaTimeModule.addDeserializer(LocalDate.class,new LocalDateDeserializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_FORMAT)));
javaTimeModule.addDeserializer(LocalTime.class,new LocalTimeDeserializer(DateTimeFormatter.ofPattern(DEFAULT_TIME_FORMAT)));
//Date序列化和反序列化
javaTimeModule.addSerializer(Date.class, new JsonSerializer<Date>() {
@Override
public void serialize(Date date, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
SimpleDateFormat formatter = new SimpleDateFormat(DEFAULT_DATE_TIME_FORMAT);
String formattedDate = formatter.format(date);
jsonGenerator.writeString(formattedDate);
}
});
javaTimeModule.addDeserializer(Date.class, new JsonDeserializer<Date>() {
@Override
public Date deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
SimpleDateFormat format = new SimpleDateFormat(DEFAULT_DATE_TIME_FORMAT);
String date = jsonParser.getText();
try {
return format.parse(date);
} catch (ParseException e) {
throw new RuntimeException(e);
}
}
});
// 注册新的模块到objectMapper
objectMapper.registerModule(javaTimeModule);
return objectMapper;
}
/**
* 默认日期时间格式
*/
public static final String DEFAULT_DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
/**
* 默认日期格式
*/
public static final String DEFAULT_DATE_FORMAT = "yyyy-MM-dd";
/**
* 默认时间格式
*/
public static final String DEFAULT_TIME_FORMAT = "HH:mm:ss";
/**
* LocalDate转换器,用于转换RequestParam和PathVariable参数
*/
@Bean
public Converter<String, LocalDate> localDateConverter() {
return new Converter<String, LocalDate>() {
@Override
public LocalDate convert(String source) {
return LocalDate.parse(source, DateTimeFormatter.ofPattern(DEFAULT_DATE_FORMAT));
}
};
}
/**
* LocalDateTime转换器,用于转换RequestParam和PathVariable参数
*/
@Bean
public Converter<String, LocalDateTime> localDateTimeConverter() {
return new Converter<String, LocalDateTime>() {
@Override
public LocalDateTime convert(String source) {
return LocalDateTime.parse(source, DateTimeFormatter.ofPattern(DEFAULT_DATE_TIME_FORMAT));
}
};
}
/**
* LocalTime转换器,用于转换RequestParam和PathVariable参数
*/
@Bean
public Converter<String, LocalTime> localTimeConverter() {
return new Converter<String, LocalTime>() {
@Override
public LocalTime convert(String source) {
return LocalTime.parse(source, DateTimeFormatter.ofPattern(DEFAULT_TIME_FORMAT));
}
};
}
/**
* Date转换器,用于转换RequestParam和PathVariable参数
*/
@Bean
public Converter<String, Date> dateConverter() {
return new Converter<String, Date>() {
@Override
public Date convert(String source) {
SimpleDateFormat format = new SimpleDateFormat(DEFAULT_DATE_TIME_FORMAT);
try {
return format.parse(source);
} catch (ParseException e) {
throw new RuntimeException(e);
}
}
};
}
/**
* Json序列化和反序列化转换器,用于转换Post请求体中的json以及将我们的对象序列化为返回响应的json
*/
@Bean
public ObjectMapper objectMapper() {
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
objectMapper.disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE);
//ObjectMapper忽略多余字段
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
//LocalDateTime系列序列化和反序列化模块,继承自jsr310,我们在这里修改了日期格式
JavaTimeModule javaTimeModule = new JavaTimeModule();
javaTimeModule.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_TIME_FORMAT)));
javaTimeModule.addSerializer(LocalDate.class, new LocalDateSerializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_FORMAT)));
javaTimeModule.addSerializer(LocalTime.class, new LocalTimeSerializer(DateTimeFormatter.ofPattern(DEFAULT_TIME_FORMAT)));
javaTimeModule.addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_TIME_FORMAT)));
javaTimeModule.addDeserializer(LocalDate.class, new LocalDateDeserializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_FORMAT)));
javaTimeModule.addDeserializer(LocalTime.class, new LocalTimeDeserializer(DateTimeFormatter.ofPattern(DEFAULT_TIME_FORMAT)));
//Date序列化和反序列化
javaTimeModule.addSerializer(Date.class, new JsonSerializer<Date>() {
@Override
public void serialize(Date date, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
SimpleDateFormat formatter = new SimpleDateFormat(DEFAULT_DATE_TIME_FORMAT);
String formattedDate = formatter.format(date);
jsonGenerator.writeString(formattedDate);
}
});
javaTimeModule.addDeserializer(Date.class, new JsonDeserializer<Date>() {
@Override
public Date deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
SimpleDateFormat format = new SimpleDateFormat(DEFAULT_DATE_TIME_FORMAT);
String date = jsonParser.getText();
try {
return format.parse(date);
} catch (ParseException e) {
throw new RuntimeException(e);
}
}
});
// 注册新的模块到objectMapper
objectMapper.registerModule(javaTimeModule);
return objectMapper;
}
}
\ No newline at end of file
......@@ -14,48 +14,48 @@ import java.nio.charset.Charset;
/**
* @date :Created in 2019-03-21 10:21
* @description:用途:
*/
public class FastJsonRedisSerializer<T> implements RedisSerializer<T> {
private ObjectMapper objectMapper = new ObjectMapper();
private ObjectMapper objectMapper = new ObjectMapper();
public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8");
public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8");
private Class<T> clazz;
private Class<T> clazz;
static {
//解决fastJson autoType is not support错误
ParserConfig.getGlobalInstance().setAutoTypeSupport(true);
}
public FastJsonRedisSerializer(Class<T> clazz) {
super();
this.clazz = clazz;
}
@Override
public byte[] serialize(T t) throws SerializationException {
if (t == null) {
return new byte[0];
}
return JSON.toJSONString(t, SerializerFeature.WriteClassName).getBytes(DEFAULT_CHARSET);
}
@Override
public T deserialize(byte[] bytes) throws SerializationException {
if (bytes == null || bytes.length <= 0) {
return null;
}
String str = new String(bytes, DEFAULT_CHARSET);
return JSON.parseObject(str, clazz);
}
public void setObjectMapper(ObjectMapper objectMapper) {
this.objectMapper = objectMapper;
}
protected JavaType getJavaType(Class<?> clazz) {
return TypeFactory.defaultInstance().constructType(clazz);
}
public FastJsonRedisSerializer(Class<T> clazz) {
super();
this.clazz = clazz;
}
@Override
public byte[] serialize(T t) throws SerializationException {
if (t == null) {
return new byte[0];
}
return JSON.toJSONString(t, SerializerFeature.WriteClassName).getBytes(DEFAULT_CHARSET);
}
@Override
public T deserialize(byte[] bytes) throws SerializationException {
if (bytes == null || bytes.length <= 0) {
return null;
}
String str = new String(bytes, DEFAULT_CHARSET);
return JSON.parseObject(str, clazz);
}
public void setObjectMapper(ObjectMapper objectMapper) {
this.objectMapper = objectMapper;
}
protected JavaType getJavaType(Class<?> clazz) {
return TypeFactory.defaultInstance().constructType(clazz);
}
}
......@@ -22,47 +22,47 @@ import java.util.Map;
@RestController
public class GlobalDefaultExceptionHandler extends AbstractErrorController {
@ExceptionHandler(value = RuntimeException.class)
@ResponseBody
public Wrapper defaultErrorHandler(HttpServletResponse response, BusinessOldException e) {
response.setStatus(e.getStatusCode().value());
return WrapMapper.error(e.getMessage());
}
@ExceptionHandler(value = RuntimeException.class)
@ResponseBody
public Wrapper defaultErrorHandler(HttpServletResponse response, BusinessOldException e) {
response.setStatus(e.getStatusCode().value());
return WrapMapper.error(e.getMessage());
}
public GlobalDefaultExceptionHandler(ErrorAttributes errorAttributes) {
super(errorAttributes);
}
public GlobalDefaultExceptionHandler(ErrorAttributes errorAttributes) {
super(errorAttributes);
}
private static final String ERROR_PATH = "/error";
private static final String ERROR_PATH = "/error";
@Override
public String getErrorPath() {
return ERROR_PATH;
}
@Override
public String getErrorPath() {
return ERROR_PATH;
}
@RequestMapping(value = ERROR_PATH)
public Wrapper error(HttpServletRequest request) {
WebRequest webRequest = new ServletWebRequest(request);
Throwable e = getError(webRequest);
if (e == null) {
Map<String, Object> attributes = getErrorAttributes(request, false);
Object timestamp = attributes.get("timestamp");
Object status = attributes.get("status");
String error = attributes.get("error").toString();
String message = attributes.get("message").toString();
Object path = attributes.get("path");
//todo 上线后更改为error
return WrapMapper.wrap(Integer.parseInt(status.toString()), message);
}else {
return WrapMapper.error(e.getMessage());
}
}
@RequestMapping(value = ERROR_PATH)
public Wrapper error(HttpServletRequest request) {
WebRequest webRequest = new ServletWebRequest(request);
Throwable e = getError(webRequest);
if (e == null) {
Map<String, Object> attributes = getErrorAttributes(request, false);
Object timestamp = attributes.get("timestamp");
Object status = attributes.get("status");
String error = attributes.get("error").toString();
String message = attributes.get("message").toString();
Object path = attributes.get("path");
//todo 上线后更改为error
return WrapMapper.wrap(Integer.parseInt(status.toString()), message);
} else {
return WrapMapper.error(e.getMessage());
}
}
private Throwable getError(WebRequest webRequest) {
return (Throwable) this.getAttribute(webRequest, "javax.servlet.error.exception");
}
private Throwable getError(WebRequest webRequest) {
return (Throwable) this.getAttribute(webRequest, "javax.servlet.error.exception");
}
private Object getAttribute(RequestAttributes requestAttributes, String name) {
return requestAttributes.getAttribute(name, 0);
}
private Object getAttribute(RequestAttributes requestAttributes, String name) {
return requestAttributes.getAttribute(name, 0);
}
}
\ No newline at end of file
......@@ -13,43 +13,43 @@ import java.util.HashMap;
import java.util.Map;
public class MapStringTypeHandler<T> extends BaseTypeHandler<Map<String, T>> {
private Class<T> clazz;
//private static final TypeReference<HashMap<String, String>> mapStrStrTypeRef = new TypeReference<HashMap<String, String>>(){};
private final TypeReference<HashMap<String, T>> typeRef = new TypeReference<HashMap<String, T>>() {
};
public MapStringTypeHandler(Class<T> clazz) {
this.clazz = clazz;
}
@Override
public void setNonNullParameter(PreparedStatement ps, int i, Map<String, T> parameter, JdbcType jdbcType) throws SQLException {
String json = JSON.toJSONString(parameter);
ps.setString(i, json);
}
@Override
public Map<String, T> getNullableResult(ResultSet rs, String columnName) throws SQLException {
return parseJson(rs.getString(columnName));
}
@Override
public Map<String, T> getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
return parseJson(rs.getString(columnIndex));
}
@Override
public Map<String, T> getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
return parseJson(cs.getString(columnIndex));
}
private Map<String, T> parseJson(String json) {
if (String.class == clazz || Integer.class == clazz || Boolean.class == clazz) {
return JSON.parseObject(json, typeRef);
}
Map<String, T> result = new HashMap<>();
JSON.parseObject(json).forEach((k, v) -> result.put(k, JSON.parseObject(JSON.toJSONString(v), clazz)));
return result;
}
private Class<T> clazz;
//private static final TypeReference<HashMap<String, String>> mapStrStrTypeRef = new TypeReference<HashMap<String, String>>(){};
private final TypeReference<HashMap<String, T>> typeRef = new TypeReference<HashMap<String, T>>() {
};
public MapStringTypeHandler(Class<T> clazz) {
this.clazz = clazz;
}
@Override
public void setNonNullParameter(PreparedStatement ps, int i, Map<String, T> parameter, JdbcType jdbcType) throws SQLException {
String json = JSON.toJSONString(parameter);
ps.setString(i, json);
}
@Override
public Map<String, T> getNullableResult(ResultSet rs, String columnName) throws SQLException {
return parseJson(rs.getString(columnName));
}
@Override
public Map<String, T> getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
return parseJson(rs.getString(columnIndex));
}
@Override
public Map<String, T> getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
return parseJson(cs.getString(columnIndex));
}
private Map<String, T> parseJson(String json) {
if (String.class == clazz || Integer.class == clazz || Boolean.class == clazz) {
return JSON.parseObject(json, typeRef);
}
Map<String, T> result = new HashMap<>();
JSON.parseObject(json).forEach((k, v) -> result.put(k, JSON.parseObject(JSON.toJSONString(v), clazz)));
return result;
}
}
\ No newline at end of file
......@@ -13,12 +13,12 @@ import org.springframework.context.annotation.Configuration;
@Configuration
public class MybatisPlusConfig {
/**
* 分页插件
*/
@Bean
public PaginationInterceptor paginationInterceptor() {
// 开启 count 的 join 优化,只针对 left join !!!
return new PaginationInterceptor().setCountSqlParser(new JsqlParserCountOptimize(true));
}
/**
* 分页插件
*/
@Bean
public PaginationInterceptor paginationInterceptor() {
// 开启 count 的 join 优化,只针对 left join !!!
return new PaginationInterceptor().setCountSqlParser(new JsqlParserCountOptimize(true));
}
}
......@@ -22,11 +22,11 @@ import java.time.Duration;
@EnableCaching
public class RedisCacheConfig {
private RedisConnectionFactory redisConnectionFactory;
private RedisConnectionFactory redisConnectionFactory;
public RedisCacheConfig(RedisConnectionFactory redisConnectionFactory) {
this.redisConnectionFactory = redisConnectionFactory;
}
public RedisCacheConfig(RedisConnectionFactory redisConnectionFactory) {
this.redisConnectionFactory = redisConnectionFactory;
}
// @Bean
// public Jedis jedis() {
......@@ -38,49 +38,49 @@ public class RedisCacheConfig {
// return jedisPool.getResource();
// }
/**
* 覆盖默认的配置
*
* @return RedisTemplate
*/
@Bean
public RedisTemplate<String, Object> redisTemplate() {
RedisTemplate<String, Object> template = new RedisTemplate();
template.setConnectionFactory(redisConnectionFactory);
StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
FastJsonRedisSerializer fastJsonRedisSerializer = new FastJsonRedisSerializer(Object.class);
/**
* 覆盖默认的配置
*
* @return RedisTemplate
*/
@Bean
public RedisTemplate<String, Object> redisTemplate() {
RedisTemplate<String, Object> template = new RedisTemplate();
template.setConnectionFactory(redisConnectionFactory);
StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
FastJsonRedisSerializer fastJsonRedisSerializer = new FastJsonRedisSerializer(Object.class);
// 设置value的序列化规则和key的序列化规则
template.setKeySerializer(stringRedisSerializer);
template.setValueSerializer(fastJsonRedisSerializer);
template.setHashKeySerializer(stringRedisSerializer);
template.setHashValueSerializer(fastJsonRedisSerializer);
template.setDefaultSerializer(fastJsonRedisSerializer);
template.afterPropertiesSet();
return template;
}
// 设置value的序列化规则和key的序列化规则
template.setKeySerializer(stringRedisSerializer);
template.setValueSerializer(fastJsonRedisSerializer);
template.setHashKeySerializer(stringRedisSerializer);
template.setHashValueSerializer(fastJsonRedisSerializer);
template.setDefaultSerializer(fastJsonRedisSerializer);
template.afterPropertiesSet();
return template;
}
/**
* 解决注解方式存放到redis中的值是乱码的情况
*
* @param factory
* @return CacheManager
*/
@Bean
public CacheManager cacheManager(RedisConnectionFactory factory) {
RedisSerializer<String> redisSerializer = new StringRedisSerializer();
FastJsonRedisSerializer fastJsonRedisSerializer = new FastJsonRedisSerializer(Object.class);
/**
* 解决注解方式存放到redis中的值是乱码的情况
*
* @param factory
* @return CacheManager
*/
@Bean
public CacheManager cacheManager(RedisConnectionFactory factory) {
RedisSerializer<String> redisSerializer = new StringRedisSerializer();
FastJsonRedisSerializer fastJsonRedisSerializer = new FastJsonRedisSerializer(Object.class);
// 配置注解方式的序列化
RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig();
RedisCacheConfiguration redisCacheConfiguration =
config.serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(redisSerializer))
.serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(fastJsonRedisSerializer))
//配置注解默认的过期时间
.entryTtl(Duration.ofDays(1));
// 加入白名单 https://github.com/alibaba/fastjson/wiki/enable_autotype
ParserConfig.getGlobalInstance().addAccept("cn.wise");
return RedisCacheManager.builder(factory).cacheDefaults(redisCacheConfiguration).build();
}
// 配置注解方式的序列化
RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig();
RedisCacheConfiguration redisCacheConfiguration =
config.serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(redisSerializer))
.serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(fastJsonRedisSerializer))
//配置注解默认的过期时间
.entryTtl(Duration.ofDays(1));
// 加入白名单 https://github.com/alibaba/fastjson/wiki/enable_autotype
ParserConfig.getGlobalInstance().addAccept("cn.wise");
return RedisCacheManager.builder(factory).cacheDefaults(redisCacheConfiguration).build();
}
}
......@@ -7,25 +7,24 @@ import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* 上下文初始化
* 以及跨域的支持
*/
public class RequestInterceptor extends HandlerInterceptorAdapter {
/**
* 拦截request和response并放到上下文中
* @param request 要拦截的request
*
* @param request 要拦截的request
* @param response 要拦截的response
* @param handler spring 机制传递过来的
* @param handler spring 机制传递过来的
* @return 不中断,继续执行,返回为true
* @throws Exception
*/
@Override
public boolean preHandle(HttpServletRequest request,
HttpServletResponse response, Object handler) throws Exception {
public boolean preHandle(HttpServletRequest request,
HttpServletResponse response, Object handler) throws Exception {
//request 和response存到 上下文中
GlobalHolder.setHttpResponse(response);
......@@ -34,9 +33,9 @@ public class RequestInterceptor extends HandlerInterceptorAdapter {
return super.preHandle(request, response, handler);
}
/**
* 处理完成 从上下文中移除 request 和respseon
*
* @param request
* @param response
* @param handler
......
package cn.wise.sc.cement.business.config;
import cn.wise.sc.cement.business.filter.SwaggerInterceptor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
......@@ -24,10 +23,10 @@ import static com.google.common.collect.Lists.newArrayList;
@EnableSwagger2
public class Swagger2Configuration {
//api接口包扫描路径
public static final String SWAGGER_SCAN_BASE_PACKAGE = "cn.wise.sc.cement.business.controller";
//api接口包扫描路径
public static final String SWAGGER_SCAN_BASE_PACKAGE = "cn.wise.sc.cement.business.controller";
public static final String VERSION = "1.0.0";
public static final String VERSION = "1.0.0";
@Bean
public Docket docket() {
......@@ -45,8 +44,6 @@ public class Swagger2Configuration {
;
}
private ApiKey apiKey() {
return new ApiKey("BearerToken", "Authorization", "header");
}
......@@ -57,6 +54,7 @@ public class Swagger2Configuration {
.forPaths(PathSelectors.regex("/.*"))
.build();
}
List<SecurityReference> defaultAuth() {
AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
......@@ -65,14 +63,14 @@ public class Swagger2Configuration {
}
@Value("${swagger.basic.username}")
private String username;
@Value("${swagger.basic.password}")
private String password;
private String username;
@Value("${swagger.basic.password}")
private String password;
/* 必须在此处配置拦截器,要不然拦不到swagger的静态资源 */
@Bean
@ConditionalOnProperty(name = "swagger.basic.enable", havingValue = "true")
public MappedInterceptor getMappedInterceptor() {
return new MappedInterceptor(new String[]{"/swagger-ui.html", "/webjars/**"}, new SwaggerInterceptor(username, password));
}
/* 必须在此处配置拦截器,要不然拦不到swagger的静态资源 */
@Bean
@ConditionalOnProperty(name = "swagger.basic.enable", havingValue = "true")
public MappedInterceptor getMappedInterceptor() {
return new MappedInterceptor(new String[]{"/swagger-ui.html", "/webjars/**"}, new SwaggerInterceptor(username, password));
}
}
\ No newline at end of file
......@@ -7,36 +7,36 @@ package cn.wise.sc.cement.business.config;
* @date 2020/2/4
*/
public class UrlConstant {
private static final String HOST = "https://oapi.dingtalk.com";
/**
* 钉钉网关 gettoken 地址
*/
public static final String URL_GET_TOKEN = HOST + "/gettoken";
/**
* 获取 jsapi_ticket 地址
*/
public static final String URL_GET_JSTICKET = HOST + "/get_jsapi_ticket";
/**
* 获取用户在企业内 userId 的接口URL
*/
public static final String URL_GET_USER_INFO = HOST + "/user/getuserinfo";
/**
* 获取用户姓名的接口URL
*/
public static final String URL_USER_GET = HOST + "/user/get";
/**
* 获取部门列表接口URL
*/
public static final String URL_DEPARTMENT_LIST = HOST + "/department/list";
/**
* 获取部门用户接口URL
*/
public static final String URL_USER_SIMPLELIST = HOST + "/user/simplelist";
private static final String HOST = "https://oapi.dingtalk.com";
/**
* 钉钉网关 gettoken 地址
*/
public static final String URL_GET_TOKEN = HOST + "/gettoken";
/**
* 获取 jsapi_ticket 地址
*/
public static final String URL_GET_JSTICKET = HOST + "/get_jsapi_ticket";
/**
* 获取用户在企业内 userId 的接口URL
*/
public static final String URL_GET_USER_INFO = HOST + "/user/getuserinfo";
/**
* 获取用户姓名的接口URL
*/
public static final String URL_USER_GET = HOST + "/user/get";
/**
* 获取部门列表接口URL
*/
public static final String URL_DEPARTMENT_LIST = HOST + "/department/list";
/**
* 获取部门用户接口URL
*/
public static final String URL_USER_SIMPLELIST = HOST + "/user/simplelist";
}
......@@ -17,7 +17,6 @@ public class WebSocketConfig extends ServerEndpointConfig.Configurator {
private static final Logger log = LoggerFactory.getLogger(WebSocketConfig.class);
/**
* 修改握手信息
*/
......@@ -34,10 +33,9 @@ public class WebSocketConfig extends ServerEndpointConfig.Configurator {
}
/**
* WebSocket的支持
*
* @return
*/
@Bean
......@@ -46,7 +44,4 @@ public class WebSocketConfig extends ServerEndpointConfig.Configurator {
return new ServerEndpointExporter();
}
}
......@@ -8,19 +8,19 @@ import java.util.function.Function;
public interface DistributedLocker {
RLock lock(String lockKey);
RLock lock(String lockKey);
RLock lock(String lockKey, int timeout);
RLock lock(String lockKey, int timeout);
RLock lock(String lockKey, TimeUnit unit, int timeout);
RLock lock(String lockKey, TimeUnit unit, int timeout);
boolean tryLock(String lockKey, TimeUnit unit, int waitTime, int leaseTime);
boolean tryLock(String lockKey, TimeUnit unit, int waitTime, int leaseTime);
void unlock(String lockKey);
void unlock(String lockKey);
void unlock(RLock lock);
void unlock(RLock lock);
<T> T executeLock(String key, Function<String, T> consumer, String t);
<T> T executeLock(String key, Function<String, T> consumer, String t);
<T> void executeLock(String lockKey, Consumer<T> consumer, T t);
<T> void executeLock(String lockKey, Consumer<T> consumer, T t);
}
\ No newline at end of file
......@@ -7,46 +7,45 @@ import java.util.function.Consumer;
import java.util.function.Function;
public class RedissLockUtil {
private static DistributedLocker redissLock;
public static void setLocker(DistributedLocker locker) {
redissLock = locker;
}
private static DistributedLocker redissLock;
public static RLock lock(String lockKey) {
return redissLock.lock(lockKey);
}
public static void setLocker(DistributedLocker locker) {
redissLock = locker;
}
public static RLock lock(String lockKey) {
return redissLock.lock(lockKey);
}
public static <T> T readWriteLock(String lockKey, Function<String,T> function) {
return redissLock.executeLock(lockKey,function,null);
}
public static <T> T readWriteLock(String lockKey, Function<String, T> function) {
return redissLock.executeLock(lockKey, function, null);
}
public static <T> void playersLock(String lockKey, Consumer<T> consumer,T t){
redissLock.executeLock(lockKey,consumer,null);
}
public static <T> void playersLock(String lockKey, Consumer<T> consumer, T t) {
redissLock.executeLock(lockKey, consumer, null);
}
public static void unlock(String lockKey) {
redissLock.unlock(lockKey);
}
public static void unlock(String lockKey) {
redissLock.unlock(lockKey);
}
public static void unlock(RLock lock) {
redissLock.unlock(lock);
}
public static void unlock(RLock lock) {
redissLock.unlock(lock);
}
public static RLock lock(String lockKey, int timeout) {
return redissLock.lock(lockKey, timeout);
}
public static RLock lock(String lockKey, int timeout) {
return redissLock.lock(lockKey, timeout);
}
public static RLock lock(String lockKey, TimeUnit unit , int timeout) {
return redissLock.lock(lockKey, unit, timeout);
}
public static RLock lock(String lockKey, TimeUnit unit, int timeout) {
return redissLock.lock(lockKey, unit, timeout);
}
public static boolean tryLock(String lockKey, int waitTime, int leaseTime) {
return redissLock.tryLock(lockKey, TimeUnit.SECONDS, waitTime, leaseTime);
}
public static boolean tryLock(String lockKey, int waitTime, int leaseTime) {
return redissLock.tryLock(lockKey, TimeUnit.SECONDS, waitTime, leaseTime);
}
public static boolean tryLock(String lockKey, TimeUnit unit, int waitTime, int leaseTime) {
return redissLock.tryLock(lockKey, unit, waitTime, leaseTime);
}
public static boolean tryLock(String lockKey, TimeUnit unit, int waitTime, int leaseTime) {
return redissLock.tryLock(lockKey, unit, waitTime, leaseTime);
}
}
\ No newline at end of file
......@@ -11,95 +11,94 @@ import java.util.function.Function;
@Slf4j
public class RedissonDistributedLocker implements DistributedLocker {
private RedissonClient redissonClient;
@Override
public RLock lock(String lockKey) {
RLock lock = redissonClient.getLock(lockKey);
lock.lock();
return lock;
}
@Override
public RLock lock(String lockKey, int leaseTime) {
RLock lock = redissonClient.getLock(lockKey);
lock.lock(leaseTime, TimeUnit.SECONDS);
return lock;
}
@Override
public RLock lock(String lockKey, TimeUnit unit, int timeout) {
RLock lock = redissonClient.getLock(lockKey);
lock.lock(timeout, unit);
return lock;
}
@Override
public boolean tryLock(String lockKey, TimeUnit unit, int waitTime, int leaseTime) {
RLock lock = redissonClient.getLock(lockKey);
try {
return lock.tryLock(waitTime, leaseTime, unit);
} catch (InterruptedException e) {
return false;
}
}
public static void realeaseLock(RLock fairLock) {
fairLock.unlock();
}
@Override
public void unlock(String lockKey) {
RLock lock = redissonClient.getLock(lockKey);
lock.unlock();
}
@Override
public void unlock(RLock lock) {
lock.unlock();
}
@Override
public <T> T executeLock(String key, Function<String, T> function, String t) {
RLock lock = redissonClient.getLock(key);
boolean locked = false;
try {
lock.lock();
return (T) function.apply(t);
} catch (Exception e) {
e.printStackTrace();
} finally {
lock.unlock();
}
return null;
}
@Override
public <T> void executeLock(String lockKey, Consumer<T> consumer, T t) {
RLock lock = redissonClient.getLock(lockKey);
boolean locked = false;
try {
while (true) {
locked = lock.tryLock();
if (locked) break;
}
if (locked) {
consumer.accept(t);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (locked) {
lock.unlock();
}
}
}
public void setRedissonClient(RedissonClient redissonClient) {
this.redissonClient = redissonClient;
}
private RedissonClient redissonClient;
@Override
public RLock lock(String lockKey) {
RLock lock = redissonClient.getLock(lockKey);
lock.lock();
return lock;
}
@Override
public RLock lock(String lockKey, int leaseTime) {
RLock lock = redissonClient.getLock(lockKey);
lock.lock(leaseTime, TimeUnit.SECONDS);
return lock;
}
@Override
public RLock lock(String lockKey, TimeUnit unit, int timeout) {
RLock lock = redissonClient.getLock(lockKey);
lock.lock(timeout, unit);
return lock;
}
@Override
public boolean tryLock(String lockKey, TimeUnit unit, int waitTime, int leaseTime) {
RLock lock = redissonClient.getLock(lockKey);
try {
return lock.tryLock(waitTime, leaseTime, unit);
} catch (InterruptedException e) {
return false;
}
}
public static void realeaseLock(RLock fairLock) {
fairLock.unlock();
}
@Override
public void unlock(String lockKey) {
RLock lock = redissonClient.getLock(lockKey);
lock.unlock();
}
@Override
public void unlock(RLock lock) {
lock.unlock();
}
@Override
public <T> T executeLock(String key, Function<String, T> function, String t) {
RLock lock = redissonClient.getLock(key);
boolean locked = false;
try {
lock.lock();
return (T) function.apply(t);
} catch (Exception e) {
e.printStackTrace();
} finally {
lock.unlock();
}
return null;
}
@Override
public <T> void executeLock(String lockKey, Consumer<T> consumer, T t) {
RLock lock = redissonClient.getLock(lockKey);
boolean locked = false;
try {
while (true) {
locked = lock.tryLock();
if (locked) break;
}
if (locked) {
consumer.accept(t);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (locked) {
lock.unlock();
}
}
}
public void setRedissonClient(RedissonClient redissonClient) {
this.redissonClient = redissonClient;
}
}
\ No newline at end of file
package cn.wise.sc.cement.business.controller;
import cn.wise.sc.cement.business.entity.Cabinet;
import cn.wise.sc.cement.business.model.BaseResponse;
import cn.wise.sc.cement.business.model.PageQuery;
......@@ -33,53 +32,53 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping("/business/cabinet")
public class CabinetController {
final
ICabinetService iCabinetService;
final
ICabinetService iCabinetService;
public CabinetController(ICabinetService iCabinetService) {
this.iCabinetService = iCabinetService;
}
public CabinetController(ICabinetService iCabinetService) {
this.iCabinetService = iCabinetService;
}
@PostMapping("/new")
@ApiOperation("新增柜子")
public BaseResponse<Boolean> newCabinet(@RequestBody Cabinet cabinet) {
@PostMapping("/new")
@ApiOperation("新增柜子")
public BaseResponse<Boolean> newCabinet(@RequestBody Cabinet cabinet) {
boolean save = iCabinetService.save(cabinet);
if (save) {
return BaseResponse.okData(true);
} else {
return BaseResponse.errorMsg("添加失败!");
}
}
boolean save = iCabinetService.save(cabinet);
if (save) {
return BaseResponse.okData(true);
} else {
return BaseResponse.errorMsg("添加失败!");
}
}
@PutMapping("/edit")
@ApiOperation("编辑柜子")
public BaseResponse<Boolean> editCabinet(@RequestBody Cabinet cabinet) {
boolean b = iCabinetService.updateById(cabinet);
if (b) {
return BaseResponse.okData(true);
} else {
return BaseResponse.errorMsg("更新失败失败!");
}
}
@PutMapping("/edit")
@ApiOperation("编辑柜子")
public BaseResponse<Boolean> editCabinet(@RequestBody Cabinet cabinet) {
boolean b = iCabinetService.updateById(cabinet);
if (b) {
return BaseResponse.okData(true);
} else {
return BaseResponse.errorMsg("更新失败失败!");
}
}
@GetMapping("/page")
@ApiOperation("查询柜子分页")
public BaseResponse<IPage<Cabinet>> page(PageQuery pageQuery) {
IPage<Cabinet> page = new Page<>(pageQuery.getPageNo(), pageQuery.getPageSize());
return BaseResponse.okData(iCabinetService.page(page));
}
@GetMapping("/page")
@ApiOperation("查询柜子分页")
public BaseResponse<IPage<Cabinet>> page(PageQuery pageQuery) {
IPage<Cabinet> page = new Page<>(pageQuery.getPageNo(), pageQuery.getPageSize());
return BaseResponse.okData(iCabinetService.page(page));
}
@DeleteMapping("/{id}")
@ApiOperation("删除柜子")
public BaseResponse<Boolean> delete(@PathVariable("id") Integer id){
boolean removeById = iCabinetService.removeById(id);
if (removeById){
return BaseResponse.okData(true);
}else {
return BaseResponse.errorMsg("删除失败!");
}
}
@DeleteMapping("/{id}")
@ApiOperation("删除柜子")
public BaseResponse<Boolean> delete(@PathVariable("id") Integer id) {
boolean removeById = iCabinetService.removeById(id);
if (removeById) {
return BaseResponse.okData(true);
} else {
return BaseResponse.errorMsg("删除失败!");
}
}
}
......@@ -14,7 +14,7 @@ import org.springframework.web.bind.annotation.*;
/**
* <p>
* 前端控制器
* 前端控制器
* </p>
*
* @author wlb
......@@ -24,82 +24,80 @@ import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/tcdri/capability_management")
public class CapabilityManagementController {
private static final Logger log = LoggerFactory.getLogger("CapabilityManagementController");
private static final Logger log = LoggerFactory.getLogger("CapabilityManagementController");
@Autowired
private ICapabilityManagementService capabilityManagementService;
@Autowired
private ICapabilityManagementService capabilityManagementService;
@ApiOperation(value = "能力管理分页,可通过用户id查询能力信息")
@GetMapping("/getPage")
public BaseResponse getPage(PageQuery pageQuery,Integer userId) {
try {
return capabilityManagementService.getPage(pageQuery, userId);
} catch (Exception e) {
log.debug("能力信息管理分页列表{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "能力管理分页,可通过用户id查询能力信息")
@GetMapping("/getPage")
public BaseResponse getPage(PageQuery pageQuery, Integer userId) {
try {
return capabilityManagementService.getPage(pageQuery, userId);
} catch (Exception e) {
log.debug("能力信息管理分页列表{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "根据默认ID查找能力信息")
@GetMapping("/{id}")
public BaseResponse getById(@PathVariable Integer id){
try {
CapabilityManagement e = capabilityManagementService.getById(id);
if(e == null){
return BaseResponse.errorMsg("信息错误!");
}
return BaseResponse.okData(e);
}catch (Exception e){
log.debug("能力管理详情{}",e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "根据默认ID查找能力信息")
@GetMapping("/{id}")
public BaseResponse getById(@PathVariable Integer id) {
try {
CapabilityManagement e = capabilityManagementService.getById(id);
if (e == null) {
return BaseResponse.errorMsg("信息错误!");
}
return BaseResponse.okData(e);
} catch (Exception e) {
log.debug("能力管理详情{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "获取所有能力信息")
@GetMapping("/getList")
public BaseResponse getList() {
try {
return capabilityManagementService.getList();
} catch (Exception e) {
log.debug("获取所有的能力管理信息{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "获取所有能力信息")
@GetMapping("/getList")
public BaseResponse getList() {
try {
return capabilityManagementService.getList();
} catch (Exception e) {
log.debug("获取所有的能力管理信息{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "新增能力管理信息")
@PostMapping("/create")
public BaseResponse create(@RequestBody CapabilityManagementQuery query){
try {
return capabilityManagementService.create(query);
}catch (Exception e){
log.debug("新增能力管理信息{}",e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "新增能力管理信息")
@PostMapping("/create")
public BaseResponse create(@RequestBody CapabilityManagementQuery query) {
try {
return capabilityManagementService.create(query);
} catch (Exception e) {
log.debug("新增能力管理信息{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "更新能力管理信息")
@PostMapping("/update")
public BaseResponse update(@RequestBody CapabilityManagementQuery capabilityManagementQuery){
try {
return capabilityManagementService.update(capabilityManagementQuery);
}catch (Exception e){
log.debug("更新能力管理信息{}",e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "更新能力管理信息")
@PostMapping("/update")
public BaseResponse update(@RequestBody CapabilityManagementQuery capabilityManagementQuery) {
try {
return capabilityManagementService.update(capabilityManagementQuery);
} catch (Exception e) {
log.debug("更新能力管理信息{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "删除能力管理信息")
@PostMapping("/delete/{id}")
public BaseResponse delete(@PathVariable Integer id){
try {
return capabilityManagementService.delete(id);
}catch (Exception e){
log.debug("删除能力管理信息{}",e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "删除能力管理信息")
@PostMapping("/delete/{id}")
public BaseResponse delete(@PathVariable Integer id) {
try {
return capabilityManagementService.delete(id);
} catch (Exception e) {
log.debug("删除能力管理信息{}", e);
}
return BaseResponse.errorMsg("失败!");
}
/* @ApiOperation(value = "根据用户id查询数据")
@PostMapping("/delete")
......
......@@ -30,7 +30,7 @@ import java.util.Map;
/**
* <p>
* 前端控制器
* 前端控制器
* </p>
*
* @author ztw
......@@ -62,7 +62,6 @@ public class ClientController {
return BaseResponse.errorMsg("失败!");
}
@ApiOperation("委托单位导出")
@PostMapping("/export")
public void export(Integer status, String region, String principal, String fileName, HttpServletResponse response) {
......@@ -75,15 +74,15 @@ public class ClientController {
@ApiOperation(value = "委托单位详情")
@GetMapping("/{id}")
public BaseResponse getById(@PathVariable Integer id){
public BaseResponse getById(@PathVariable Integer id) {
try {
Client e = clientService.getById(id);
if(e == null){
if (e == null) {
return BaseResponse.errorMsg("信息错误!");
}
return BaseResponse.okData(e);
}catch (Exception e){
log.debug("委托单位详情{}",e);
} catch (Exception e) {
log.debug("委托单位详情{}", e);
}
return BaseResponse.errorMsg("失败!");
}
......@@ -101,39 +100,36 @@ public class ClientController {
@ApiOperation(value = "新增委托单位")
@PostMapping("/create")
public BaseResponse create(@RequestBody ClientQuery clientQuery){
public BaseResponse create(@RequestBody ClientQuery clientQuery) {
try {
return clientService.create(clientQuery);
}catch (Exception e){
log.debug("新增委托单位{}",e);
} catch (Exception e) {
log.debug("新增委托单位{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "更新委托单位")
@PostMapping("/update")
public BaseResponse update(@RequestBody ClientQuery clientQuery){
public BaseResponse update(@RequestBody ClientQuery clientQuery) {
try {
return clientService.update(clientQuery);
}catch (Exception e){
log.debug("更新委托单位{}",e);
} catch (Exception e) {
log.debug("更新委托单位{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "启用禁用")
@PostMapping("/status")
public BaseResponse status(Integer status, Integer id){
public BaseResponse status(Integer status, Integer id) {
try {
return clientService.status(status, id);
}catch (Exception e){
log.debug("启用禁用{}",e);
} catch (Exception e) {
log.debug("启用禁用{}", e);
}
return BaseResponse.errorMsg("失败!");
}
}
package cn.wise.sc.cement.business.controller;
import cn.wise.sc.cement.business.entity.Consumables;
import cn.wise.sc.cement.business.entity.Equipment;
import cn.wise.sc.cement.business.model.BaseResponse;
......@@ -23,13 +22,13 @@ import java.util.List;
/**
* <p>
* 前端控制器
* 前端控制器
* </p>
*
* @author ztw
* @since 2020-09-03
*/
@Api(tags="资源管理-消耗品管理")
@Api(tags = "资源管理-消耗品管理")
@RestController
@RequestMapping("/business/consumables")
public class ConsumablesController {
......@@ -39,8 +38,6 @@ public class ConsumablesController {
@Autowired
private IConsumablesService consumablesService;
@ApiOperation(value = "消耗品分页列表")
@ApiImplicitParams(value = {
@ApiImplicitParam(name = "name", value = "易耗品名称", paramType = "query", dataType = "String"),
......@@ -66,16 +63,13 @@ public class ConsumablesController {
}
}
@ApiOperation(value = "新增消耗品")
@PostMapping("/create")
public BaseResponse create(@RequestBody Consumables query) {
try {
return consumablesService.create(query);
}catch (Exception e) {
log.debug("新增消耗品{}",e);
} catch (Exception e) {
log.debug("新增消耗品{}", e);
}
return BaseResponse.errorMsg("失败!");
}
......@@ -85,44 +79,44 @@ public class ConsumablesController {
public BaseResponse update(@RequestBody Consumables query) {
try {
return consumablesService.update(query);
}catch (Exception e) {
log.debug("修改消耗品{}",e);
} catch (Exception e) {
log.debug("修改消耗品{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "消耗品详情")
@GetMapping("/{id}")
public BaseResponse getById(@PathVariable Integer id){
public BaseResponse getById(@PathVariable Integer id) {
try {
Consumables consumables = consumablesService.getById(id);
return BaseResponse.okData(consumables);
}catch (Exception e){
log.debug("消耗品详情{}",e);
} catch (Exception e) {
log.debug("消耗品详情{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "消耗品列表")
@GetMapping("/getList")
public BaseResponse getList(){
public BaseResponse getList() {
try {
List<Consumables> list = consumablesService.list();
return BaseResponse.okData(list);
}catch (Exception e){
log.debug("消耗品列表{}",e);
} catch (Exception e) {
log.debug("消耗品列表{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "删除消耗品")
@PostMapping("/delete/{id}")
public BaseResponse delete(@PathVariable Integer id){
public BaseResponse delete(@PathVariable Integer id) {
try {
consumablesService.removeById(id);
return BaseResponse.okData("删除成功");
}catch (Exception e){
log.debug("删除消耗品{}",e);
} catch (Exception e) {
log.debug("删除消耗品{}", e);
}
return BaseResponse.errorMsg("失败!");
}
......@@ -132,8 +126,8 @@ public class ConsumablesController {
public BaseResponse enter(@RequestBody ChangeStockQuery query) {
try {
return consumablesService.enter(query);
}catch (Exception e) {
log.debug("新增入库{}",e);
} catch (Exception e) {
log.debug("新增入库{}", e);
}
return BaseResponse.errorMsg("失败!");
}
......@@ -143,8 +137,8 @@ public class ConsumablesController {
public BaseResponse out(@RequestBody ChangeStockQuery query) {
try {
return consumablesService.out(query);
}catch (Exception e) {
log.debug("领用出库{}",e);
} catch (Exception e) {
log.debug("领用出库{}", e);
}
return BaseResponse.errorMsg("失败!");
}
......@@ -154,8 +148,8 @@ public class ConsumablesController {
public BaseResponse changeValidDate(@RequestBody ChangeValidDateQuery query) {
try {
return consumablesService.changeValidDate(query);
}catch (Exception e) {
log.debug("变更有效期{}",e);
} catch (Exception e) {
log.debug("变更有效期{}", e);
}
return BaseResponse.errorMsg("失败!");
}
......@@ -165,33 +159,11 @@ public class ConsumablesController {
public BaseResponse overdue(Integer id) {
try {
return consumablesService.overdue(id);
}catch (Exception e) {
log.debug("过期处置{}",e);
} catch (Exception e) {
log.debug("过期处置{}", e);
}
return BaseResponse.errorMsg("失败!");
}
}
package cn.wise.sc.cement.business.controller;
import cn.wise.sc.cement.business.entity.Equipment;
import cn.wise.sc.cement.business.entity.SysPost;
import cn.wise.sc.cement.business.model.BaseResponse;
......@@ -27,13 +26,13 @@ import java.util.Map;
/**
* <p>
* 前端控制器
* 前端控制器
* </p>
*
* @author ztw
* @since 2020-09-01
*/
@Api(tags="资源管理-设备管理")
@Api(tags = "资源管理-设备管理")
@RestController
@RequestMapping("/business/equipment")
public class EquipmentController {
......@@ -43,7 +42,6 @@ public class EquipmentController {
@Autowired
private IEquipmentService equipmentService;
@ApiOperation(value = "设备分页列表 (设备列表,设备检定列表)")
@ApiImplicitParams(value = {
@ApiImplicitParam(name = "brand", value = "设备品牌", paramType = "query", dataType = "String"),
......@@ -65,8 +63,8 @@ public class EquipmentController {
public BaseResponse test(@RequestBody EquipmentTestQuery query) {
try {
return equipmentService.test(query);
}catch (Exception e) {
log.debug("检定设备{}",e);
} catch (Exception e) {
log.debug("检定设备{}", e);
}
return BaseResponse.errorMsg("失败!");
}
......@@ -110,8 +108,8 @@ public class EquipmentController {
public BaseResponse create(@RequestBody EquipmentQuery query) {
try {
return equipmentService.create(query);
}catch (Exception e) {
log.debug("新增设备{}",e);
} catch (Exception e) {
log.debug("新增设备{}", e);
}
return BaseResponse.errorMsg("失败!");
}
......@@ -121,45 +119,45 @@ public class EquipmentController {
public BaseResponse update(@RequestBody EquipmentQuery query) {
try {
return equipmentService.update(query);
}catch (Exception e) {
log.debug("修改设备{}",e);
} catch (Exception e) {
log.debug("修改设备{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "设备详情")
@GetMapping("/{id}")
public BaseResponse getById(@PathVariable Integer id){
public BaseResponse getById(@PathVariable Integer id) {
try {
return equipmentService.getDetail(id);
}catch (Exception e){
log.debug("设备详情{}",e);
} catch (Exception e) {
log.debug("设备详情{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "设备列表")
@GetMapping("/getList")
public BaseResponse getList(){
public BaseResponse getList() {
try {
QueryWrapper<Equipment> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("status", 1);
List<Equipment> list = equipmentService.list(queryWrapper);
return BaseResponse.okData(list);
}catch (Exception e){
log.debug("设备列表{}",e);
} catch (Exception e) {
log.debug("设备列表{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "删除设备")
@PostMapping("/delete/{id}")
public BaseResponse delete(@PathVariable Integer id){
public BaseResponse delete(@PathVariable Integer id) {
try {
equipmentService.removeById(id);
return BaseResponse.okData("删除成功");
}catch (Exception e){
log.debug("删除设备{}",e);
} catch (Exception e) {
log.debug("删除设备{}", e);
}
return BaseResponse.errorMsg("失败!");
}
......@@ -180,14 +178,13 @@ public class EquipmentController {
}
*/
@ApiOperation(value = "设备故障维修登记 (不传id为添加记录,传id为修改记录)")
@PostMapping("/troubleshooting")
public BaseResponse troubleshooting(@RequestBody EquipmentTroubleshootingQuery query) {
try {
return equipmentService.troubleshooting(query);
}catch (Exception e) {
log.debug("设备故障维修登记{}",e);
} catch (Exception e) {
log.debug("设备故障维修登记{}", e);
}
return BaseResponse.errorMsg("失败!");
}
......@@ -208,7 +205,7 @@ public class EquipmentController {
@ApiOperation("设备维修列表导出")
@PostMapping("/exportTroubleshooting")
public void exportTroubleshooting( String name, String fileName, HttpServletResponse response) {
public void exportTroubleshooting(String name, String fileName, HttpServletResponse response) {
try {
equipmentService.exportTroubleshooting(name, fileName, response);
} catch (Exception e) {
......@@ -218,11 +215,11 @@ public class EquipmentController {
@ApiOperation(value = "维修登记详情")
@GetMapping("getTroubleshootingDetail/{id}")
public BaseResponse getTroubleshootingDetail(@PathVariable Integer id){
public BaseResponse getTroubleshootingDetail(@PathVariable Integer id) {
try {
return equipmentService.getTroubleshootingDetail(id);
}catch (Exception e){
log.debug("维修登记详情{}",e);
} catch (Exception e) {
log.debug("维修登记详情{}", e);
}
return BaseResponse.errorMsg("失败!");
}
......@@ -232,8 +229,8 @@ public class EquipmentController {
public BaseResponse scrap(@RequestBody EquipmentScrapQuery query) {
try {
return equipmentService.scrap(query);
}catch (Exception e) {
log.debug("设备报废申请{}",e);
} catch (Exception e) {
log.debug("设备报废申请{}", e);
}
return BaseResponse.errorMsg("失败!");
}
......@@ -243,8 +240,8 @@ public class EquipmentController {
public BaseResponse scrapApproval(@RequestBody EquipmentScrapApprovalQuery query) {
try {
return equipmentService.scrapApproval(query);
}catch (Exception e) {
log.debug("设备报废审批{}",e);
} catch (Exception e) {
log.debug("设备报废审批{}", e);
}
return BaseResponse.errorMsg("失败!");
}
......@@ -277,11 +274,11 @@ public class EquipmentController {
@ApiOperation(value = "报废申请详情")
@GetMapping("getscrapApprovalDetail/{id}")
public BaseResponse getscrapApprovalDetail(@PathVariable Integer id){
public BaseResponse getscrapApprovalDetail(@PathVariable Integer id) {
try {
return equipmentService.getscrapApprovalDetail(id);
}catch (Exception e){
log.debug("报废申请详情{}",e);
} catch (Exception e) {
log.debug("报废申请详情{}", e);
}
return BaseResponse.errorMsg("失败!");
}
......@@ -312,6 +309,5 @@ public class EquipmentController {
}
}
}
package cn.wise.sc.cement.business.controller;
import cn.wise.sc.cement.business.entity.Handle;
import cn.wise.sc.cement.business.entity.Method;
import cn.wise.sc.cement.business.entity.TeamGroup;
......@@ -23,7 +22,7 @@ import java.util.List;
/**
* <p>
* 前端控制器
* 前端控制器
* </p>
*
* @author ztw
......@@ -39,7 +38,6 @@ public class HandleController {
@Autowired
private IHandleService handleService;
@ApiOperation(value = "处理项分页列表")
@ApiImplicitParams(value = {
@ApiImplicitParam(name = "name", value = "标准名称", paramType = "query", dataType = "String")
......@@ -56,15 +54,15 @@ public class HandleController {
@ApiOperation(value = "处理项详情")
@GetMapping("/{id}")
public BaseResponse getById(@PathVariable Integer id){
public BaseResponse getById(@PathVariable Integer id) {
try {
Handle e = handleService.getById(id);
if(e == null){
if (e == null) {
return BaseResponse.errorMsg("信息错误!");
}
return BaseResponse.okData(e);
}catch (Exception e){
log.debug("处理项详情{}",e);
} catch (Exception e) {
log.debug("处理项详情{}", e);
}
return BaseResponse.errorMsg("失败!");
}
......@@ -84,11 +82,11 @@ public class HandleController {
@ApiOperation(value = "新增处理项")
@PostMapping("/create")
@Transactional
public BaseResponse create(@RequestBody Handle query){
public BaseResponse create(@RequestBody Handle query) {
try {
return handleService.create(query);
}catch (Exception e){
log.debug("新增处理项{}",e);
} catch (Exception e) {
log.debug("新增处理项{}", e);
}
return BaseResponse.errorMsg("失败!");
}
......@@ -96,27 +94,26 @@ public class HandleController {
@ApiOperation(value = "更新处理项")
@PostMapping("/update")
@Transactional
public BaseResponse update(@RequestBody Handle query){
public BaseResponse update(@RequestBody Handle query) {
try {
return handleService.update(query);
}catch (Exception e){
log.debug("更新处理项{}",e);
} catch (Exception e) {
log.debug("更新处理项{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "删除处理项")
@PostMapping("/delete/{id}")
public BaseResponse delete(@PathVariable Integer id){
public BaseResponse delete(@PathVariable Integer id) {
try {
handleService.removeById(id);
return BaseResponse.okData("删除成功");
}catch (Exception e){
log.debug("删除处理项{}",e);
} catch (Exception e) {
log.debug("删除处理项{}", e);
}
return BaseResponse.errorMsg("失败!");
}
}
......@@ -16,81 +16,79 @@ import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/tcdri/history_archives")
public class HistoryArchivesController {
private static final Logger log = LoggerFactory.getLogger("HistoryArchivesController");
private static final Logger log = LoggerFactory.getLogger("HistoryArchivesController");
@Autowired
private IHistoryArchivesService iHistoryArchivesService;
@Autowired
private IHistoryArchivesService iHistoryArchivesService;
@ApiOperation(value = "历史档案分页,可通过用户id查询信息")
@GetMapping("/getPage")
public BaseResponse getPage(PageQuery pageQuery,Integer userId) {
try {
return iHistoryArchivesService.getPage(pageQuery,userId);
} catch (Exception e) {
log.debug("历史档案分页列表{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "历史档案分页,可通过用户id查询信息")
@GetMapping("/getPage")
public BaseResponse getPage(PageQuery pageQuery, Integer userId) {
try {
return iHistoryArchivesService.getPage(pageQuery, userId);
} catch (Exception e) {
log.debug("历史档案分页列表{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "根据默认ID查找历史档案信息")
@GetMapping("/{id}")
public BaseResponse getById(@PathVariable Integer id) {
try {
HistoryArchives e = iHistoryArchivesService.getById(id);
if (e == null) {
return BaseResponse.errorMsg("信息错误!");
}
return BaseResponse.okData(e);
} catch (Exception e) {
log.debug("档案信息详情{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "获取所有历史档案信息")
@GetMapping("/getList")
public BaseResponse getList() {
try {
return iHistoryArchivesService.getList();
} catch (Exception e) {
log.debug("获取其的历史档案信息{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "根据默认ID查找历史档案信息")
@GetMapping("/{id}")
public BaseResponse getById(@PathVariable Integer id){
try {
HistoryArchives e = iHistoryArchivesService.getById(id);
if(e == null){
return BaseResponse.errorMsg("信息错误!");
}
return BaseResponse.okData(e);
}catch (Exception e){
log.debug("档案信息详情{}",e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "新增历史档案")
@PostMapping("/create")
public BaseResponse create(@RequestBody HistoryArchivesQuery query) {
try {
return iHistoryArchivesService.create(query);
} catch (Exception e) {
log.debug("新增历史档案{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "获取所有历史档案信息")
@GetMapping("/getList")
public BaseResponse getList() {
try {
return iHistoryArchivesService.getList();
} catch (Exception e) {
log.debug("获取其的历史档案信息{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "更新历史档案")
@PostMapping("/update")
public BaseResponse update(@RequestBody HistoryArchivesQuery historyArchivesQuery) {
try {
return iHistoryArchivesService.update(historyArchivesQuery);
} catch (Exception e) {
log.debug("更新历史档案{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "新增历史档案")
@PostMapping("/create")
public BaseResponse create(@RequestBody HistoryArchivesQuery query){
try {
return iHistoryArchivesService.create(query);
}catch (Exception e){
log.debug("新增历史档案{}",e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "更新历史档案")
@PostMapping("/update")
public BaseResponse update(@RequestBody HistoryArchivesQuery historyArchivesQuery){
try {
return iHistoryArchivesService.update(historyArchivesQuery);
}catch (Exception e){
log.debug("更新历史档案{}",e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "删除历史档案")
@PostMapping("/delete/{id}")
public BaseResponse delete(@PathVariable Integer id){
try {
return iHistoryArchivesService.delete(id);
}catch (Exception e){
log.debug("删除历史档案{}",e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "删除历史档案")
@PostMapping("/delete/{id}")
public BaseResponse delete(@PathVariable Integer id) {
try {
return iHistoryArchivesService.delete(id);
} catch (Exception e) {
log.debug("删除历史档案{}", e);
}
return BaseResponse.errorMsg("失败!");
}
}
package cn.wise.sc.cement.business.controller;
import cn.wise.sc.cement.business.entity.Method;
import cn.wise.sc.cement.business.entity.Team;
import cn.wise.sc.cement.business.model.BaseResponse;
......@@ -23,7 +22,7 @@ import javax.servlet.http.HttpServletResponse;
/**
* <p>
* 前端控制器
* 前端控制器
* </p>
*
* @author ztw
......@@ -63,18 +62,17 @@ public class MethodController {
}
}
@ApiOperation(value = "检测依据详情")
@GetMapping("/{id}")
public BaseResponse getById(@PathVariable Integer id){
public BaseResponse getById(@PathVariable Integer id) {
try {
Method e = methodService.getById(id);
if(e == null){
if (e == null) {
return BaseResponse.errorMsg("信息错误!");
}
return BaseResponse.okData(e);
}catch (Exception e){
log.debug("检测依据详情{}",e);
} catch (Exception e) {
log.debug("检测依据详情{}", e);
}
return BaseResponse.errorMsg("失败!");
}
......@@ -93,11 +91,11 @@ public class MethodController {
@ApiOperation(value = "新增检测依据")
@PostMapping("/create")
@Transactional
public BaseResponse create(@RequestBody MethodQuery query){
public BaseResponse create(@RequestBody MethodQuery query) {
try {
return methodService.create(query);
}catch (Exception e){
log.debug("新增检测依据{}",e);
} catch (Exception e) {
log.debug("新增检测依据{}", e);
}
return BaseResponse.errorMsg("失败!");
}
......@@ -105,22 +103,22 @@ public class MethodController {
@ApiOperation(value = "更新检测依据")
@PostMapping("/update")
@Transactional
public BaseResponse update(@RequestBody MethodQuery query){
public BaseResponse update(@RequestBody MethodQuery query) {
try {
return methodService.update(query);
}catch (Exception e){
log.debug("更新检测依据{}",e);
} catch (Exception e) {
log.debug("更新检测依据{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "删除检测依据")
@PostMapping("/delete/{id}")
public BaseResponse delete(@PathVariable Integer id){
public BaseResponse delete(@PathVariable Integer id) {
try {
return methodService.delete(id);
}catch (Exception e){
log.debug("删除检测依据{}",e);
} catch (Exception e) {
log.debug("删除检测依据{}", e);
}
return BaseResponse.errorMsg("失败!");
}
......
......@@ -18,13 +18,13 @@ import java.util.List;
/**
* <p>
* 前端控制器
* 前端控制器
* </p>
*
* @author wlb
* @since 2020-09-23
*/
@Api(tags="非标产值-非标产值申请")
@Api(tags = "非标产值-非标产值申请")
@RestController
@RequestMapping("/tcdri/nonstandard_apply")
public class NonStandardApplyController {
......@@ -35,9 +35,9 @@ public class NonStandardApplyController {
@ApiOperation(value = "非标产值申请分页")
@GetMapping("/getPage")
public BaseResponse getPage(PageQuery pageQuery, String name) {
public BaseResponse getPage(PageQuery pageQuery, String name,Integer userId) {
try {
return iNonStandardApplyService.getPage(pageQuery,name);
return iNonStandardApplyService.getPage(pageQuery, name,userId);
} catch (Exception e) {
log.debug("非标产值申请分页列表{}", e);
}
......@@ -46,15 +46,15 @@ public class NonStandardApplyController {
@ApiOperation(value = "根据id查询指定非标产值申请信息")
@GetMapping("/{id}")
public BaseResponse getById(@PathVariable Integer id){
public BaseResponse getById(@PathVariable Integer id) {
try {
BaseResponse<List<NonStandardApplyVo>> e = iNonStandardApplyService.getById(id);
if(e == null){
if (e == null) {
return BaseResponse.errorMsg("信息错误!");
}
return BaseResponse.okData(e);
}catch (Exception e){
log.debug("通过id查询非标产值申请信息{}",e);
} catch (Exception e) {
log.debug("通过id查询非标产值申请信息{}", e);
}
return BaseResponse.errorMsg("失败!");
}
......@@ -72,44 +72,44 @@ public class NonStandardApplyController {
@ApiOperation(value = "提交申请")
@PostMapping("/create")
public BaseResponse create(@RequestBody NonStandardApplyQuery query){
public BaseResponse create(@RequestBody NonStandardApplyQuery query) {
try {
return iNonStandardApplyService.create(query);
}catch (Exception e){
log.debug("提交申请{}",e);
} catch (Exception e) {
log.debug("提交申请{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "修改非标产值信息")
@PostMapping("/update")
public BaseResponse update(@RequestBody NonStandardApplyQuery nonStandardApplyQuery){
public BaseResponse update(@RequestBody NonStandardApplyQuery nonStandardApplyQuery) {
try {
return iNonStandardApplyService.update(nonStandardApplyQuery);
}catch (Exception e){
log.debug("修改非标产值信息{}",e);
} catch (Exception e) {
log.debug("修改非标产值信息{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "提交操作按钮实现")
@PostMapping("/status")
public BaseResponse status(Integer status, Integer id){
public BaseResponse status(Integer status, Integer id) {
try {
return iNonStandardApplyService.status(status, id);
}catch (Exception e){
log.debug("提交操作实现{}",e);
} catch (Exception e) {
log.debug("提交操作实现{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "删除非标产值申请")
@PostMapping("/delete/{id}")
public BaseResponse delete(@PathVariable Integer id){
public BaseResponse delete(@PathVariable Integer id) {
try {
return iNonStandardApplyService.delete(id);
}catch (Exception e){
log.debug("删除非标产值申请{}",e);
} catch (Exception e) {
log.debug("删除非标产值申请{}", e);
}
return BaseResponse.errorMsg("失败!");
}
......@@ -118,7 +118,7 @@ public class NonStandardApplyController {
@PostMapping("/exportList")
public void exportList(String filename, Integer userId, String name, HttpServletResponse response) {
try {
iNonStandardApplyService.exportList(filename, userId,name,response);
iNonStandardApplyService.exportList(filename, userId, name, response);
} catch (Exception e) {
log.debug("非标产值申请导出列表{}", e);
}
......
......@@ -19,13 +19,13 @@ import java.util.List;
/**
* <p>
* 前端控制器
* 前端控制器
* </p>
*
* @author wlb
* @since 2020-09-23
*/
@Api(tags="非标产值-非标产值审批")
@Api(tags = "非标产值-非标产值审批")
@RestController
@RequestMapping("/tcdri/nonestandard_approval")
public class NonStandardApprovalController {
......@@ -36,9 +36,9 @@ public class NonStandardApprovalController {
@ApiOperation(value = "非标产值审批分页")
@GetMapping("/getPage")
public BaseResponse getPage(PageQuery pageQuery,String name,Integer status) {
public BaseResponse getPage(PageQuery pageQuery, String name, Integer status) {
try {
return iNonStandardApprovalService.getPage(pageQuery,name,status);
return iNonStandardApprovalService.getPage(pageQuery, name, status);
} catch (Exception e) {
log.debug("非标产值审批分页列表{}", e);
}
......@@ -47,15 +47,15 @@ public class NonStandardApprovalController {
@ApiOperation(value = "根据id查询指定非标产值审批信息")
@GetMapping("/{id}")
public BaseResponse getById(@PathVariable Integer id){
public BaseResponse getById(@PathVariable Integer id) {
try {
BaseResponse<List<NonStandardApprovalVo>> e = iNonStandardApprovalService.getById(id);
if(e == null){
if (e == null) {
return BaseResponse.errorMsg("信息错误!");
}
return BaseResponse.okData(e);
}catch (Exception e){
log.debug("通过id查询非标产值审批信息{}",e);
} catch (Exception e) {
log.debug("通过id查询非标产值审批信息{}", e);
}
return BaseResponse.errorMsg("失败!");
}
......@@ -73,33 +73,33 @@ public class NonStandardApprovalController {
@ApiOperation(value = "审批通过/驳回")
@PostMapping("/update")
public BaseResponse update(@RequestBody NonStandardApprovalQuery nonStandardApprovalQuery){
public BaseResponse update(@RequestBody NonStandardApprovalQuery nonStandardApprovalQuery) {
try {
return iNonStandardApprovalService.update(nonStandardApprovalQuery);
}catch (Exception e){
log.debug("审批通过/驳回{}",e);
} catch (Exception e) {
log.debug("审批通过/驳回{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "审批操作按钮实现")
@PostMapping("/status")
public BaseResponse status(Integer status, Integer id){
public BaseResponse status(Integer status, Integer id) {
try {
return iNonStandardApprovalService.status(status, id);
}catch (Exception e){
log.debug("审批操作实现{}",e);
} catch (Exception e) {
log.debug("审批操作实现{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "删除非标产值审批")
@PostMapping("/delete/{id}")
public BaseResponse delete(@PathVariable Integer id){
public BaseResponse delete(@PathVariable Integer id) {
try {
return iNonStandardApprovalService.delete(id);
}catch (Exception e){
log.debug("删除非标产值审批{}",e);
} catch (Exception e) {
log.debug("删除非标产值审批{}", e);
}
return BaseResponse.errorMsg("失败!");
}
......
......@@ -36,69 +36,69 @@ import java.util.List;
@RestController
@RequestMapping("/tcdri/nonestandard_value")
public class NonStandardValueController {
private static final Logger log = LoggerFactory.getLogger("NoneStandardValueController");
private static final Logger log = LoggerFactory.getLogger("NoneStandardValueController");
@Autowired
private INonStandardValueService inonStandardValueService;
@Autowired
private INonStandardValueService inonStandardValueService;
@ApiOperation(value = "非标产值分页")
@GetMapping("/getPage")
public BaseResponse getPage(PageQuery pageQuery, Integer userId, String name) {
try {
return inonStandardValueService.getPage(pageQuery, userId, name);
} catch (Exception e) {
log.debug("非标产值分页列表{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "非标产值分页")
@GetMapping("/getPage")
public BaseResponse getPage(PageQuery pageQuery, Integer userId, String name) {
try {
return inonStandardValueService.getPage(pageQuery, userId, name);
} catch (Exception e) {
log.debug("非标产值分页列表{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@GetMapping("/user_id")
@ApiOperation("非标产值统计")
public BaseResponse nonValue(PageQuery pageQuery, String start, String end,Integer groups) {
Date startParse = null;
if (StrUtil.isNotBlank(start)) {
startParse = DateUtil.parse(start);
}
Date endParse = null;
if (StrUtil.isNotBlank(end)) {
endParse = DateUtil.parse(end);
}
//将list拆分成分页
BaseResponse<List<NonStandardValue>> baseResponse = inonStandardValueService.nonValue(startParse, endParse, groups);
List<NonStandardValue> data = baseResponse.getData();
if (data.size() != 0) {
Page<NonStandardValue> rts = PageUtil.listConvertToPage(data, pageQuery);
return BaseResponse.okData(rts);
}
return baseResponse;
}
@GetMapping("/user_id")
@ApiOperation("非标产值统计")
public BaseResponse nonValue(PageQuery pageQuery, String start, String end, Integer groups) {
Date startParse = null;
if (StrUtil.isNotBlank(start)) {
startParse = DateUtil.parse(start);
}
Date endParse = null;
if (StrUtil.isNotBlank(end)) {
endParse = DateUtil.parse(end);
}
//将list拆分成分页
BaseResponse<List<NonStandardValue>> baseResponse = inonStandardValueService.nonValue(startParse, endParse, groups);
List<NonStandardValue> data = baseResponse.getData();
if (data.size() != 0) {
Page<NonStandardValue> rts = PageUtil.listConvertToPage(data, pageQuery);
return BaseResponse.okData(rts);
}
return baseResponse;
}
@ApiOperation(value = "获取所有已通过的非标产值")
@GetMapping("/getList")
public BaseResponse getList(String start, String end, Integer groups) {
Date startParse = null;
if (StrUtil.isNotBlank(start)) {
startParse = DateUtil.parse(start);
}
Date endParse = null;
if (StrUtil.isNotBlank(end)) {
endParse = DateUtil.parse(end);
}
try {
return inonStandardValueService.getList(startParse, endParse,groups);
} catch (Exception e) {
log.debug("获取所有已通过的非标产值{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "获取所有已通过的非标产值")
@GetMapping("/getList")
public BaseResponse getList(String start, String end, Integer groups) {
Date startParse = null;
if (StrUtil.isNotBlank(start)) {
startParse = DateUtil.parse(start);
}
Date endParse = null;
if (StrUtil.isNotBlank(end)) {
endParse = DateUtil.parse(end);
}
try {
return inonStandardValueService.getList(startParse, endParse, groups);
} catch (Exception e) {
log.debug("获取所有已通过的非标产值{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation("非标产值信息导出列表")
@PostMapping("/exportList")
public void exportList(String filename, Integer userId, String name, HttpServletResponse response) {
try {
inonStandardValueService.exportList(filename, userId, name, response);
} catch (Exception e) {
log.debug("非标产值信息导出列表{}", e);
}
}
@ApiOperation("非标产值信息导出列表")
@PostMapping("/exportList")
public void exportList(String filename, Integer userId, String name, HttpServletResponse response) {
try {
inonStandardValueService.exportList(filename, userId, name, response);
} catch (Exception e) {
log.debug("非标产值信息导出列表{}", e);
}
}
}
package cn.wise.sc.cement.business.controller;
import cn.wise.sc.cement.business.model.BaseResponse;
import cn.wise.sc.cement.business.model.PageQuery;
import cn.wise.sc.cement.business.model.query.PlanConsumablesPurchaseQuery;
......@@ -19,13 +18,13 @@ import javax.servlet.http.HttpServletResponse;
/**
* <p>
* 前端控制器
* 前端控制器
* </p>
*
* @author ztw
* @since 2020-09-28
*/
@Api(tags="计划管理-消耗品采购计划")
@Api(tags = "计划管理-消耗品采购计划")
@RestController
@RequestMapping("/business/plan-consumables-purchase")
public class PlanConsumablesPurchaseController {
......@@ -35,7 +34,6 @@ public class PlanConsumablesPurchaseController {
@Autowired
private IPlanConsumablesPurchaseService consumablesPurchaseService;
@ApiOperation(value = "消耗品采购计划分页列表")
@ApiImplicitParams(value = {
@ApiImplicitParam(name = "name", value = "产品名称", paramType = "query", dataType = "String")
......@@ -60,59 +58,57 @@ public class PlanConsumablesPurchaseController {
}
}
@ApiOperation(value = "新增消耗品采购计划")
@PostMapping("/create")
public BaseResponse create(@RequestBody PlanConsumablesPurchaseQuery query){
public BaseResponse create(@RequestBody PlanConsumablesPurchaseQuery query) {
try {
return consumablesPurchaseService.create(query);
}catch (Exception e){
log.debug("新增消耗品采购计划{}",e);
} catch (Exception e) {
log.debug("新增消耗品采购计划{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "更新消耗品采购计划")
@PostMapping("/update")
public BaseResponse update(@RequestBody PlanConsumablesPurchaseQuery query){
public BaseResponse update(@RequestBody PlanConsumablesPurchaseQuery query) {
try {
return consumablesPurchaseService.update(query);
}catch (Exception e){
log.debug("更新消耗品采购计划{}",e);
} catch (Exception e) {
log.debug("更新消耗品采购计划{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "消耗品采购计划详情")
@GetMapping("/{id}")
public BaseResponse getDetail(@PathVariable Integer id){
public BaseResponse getDetail(@PathVariable Integer id) {
try {
return consumablesPurchaseService.getDetail(id);
}catch (Exception e){
log.debug("消耗品采购计划详情{}",e);
} catch (Exception e) {
log.debug("消耗品采购计划详情{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "采购完成")
@PostMapping("/finish")
public BaseResponse finish(Integer id){
public BaseResponse finish(Integer id) {
try {
return consumablesPurchaseService.finish(id);
}catch (Exception e){
log.debug("采购完成{}",e);
} catch (Exception e) {
log.debug("采购完成{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "删除")
@PostMapping("/delete/{id}")
public BaseResponse delete(@PathVariable Integer id){
public BaseResponse delete(@PathVariable Integer id) {
try {
return consumablesPurchaseService.delete(id);
}catch (Exception e){
log.debug("删除{}",e);
} catch (Exception e) {
log.debug("删除{}", e);
}
return BaseResponse.errorMsg("失败!");
}
......
package cn.wise.sc.cement.business.controller;
import cn.wise.sc.cement.business.model.BaseResponse;
import cn.wise.sc.cement.business.model.PageQuery;
import cn.wise.sc.cement.business.model.query.PlanEquipmentMaintainQuery;
......@@ -19,13 +18,13 @@ import javax.servlet.http.HttpServletResponse;
/**
* <p>
* 前端控制器
* 前端控制器
* </p>
*
* @author ztw
* @since 2020-09-28
*/
@Api(tags="计划管理-设备维护计划")
@Api(tags = "计划管理-设备维护计划")
@RestController
@RequestMapping("/business/plan-equipment-maintain")
public class PlanEquipmentMaintainController {
......@@ -59,74 +58,60 @@ public class PlanEquipmentMaintainController {
}
}
@ApiOperation(value = "新增设设备维护计划分页列表")
@PostMapping("/create")
public BaseResponse create(@RequestBody PlanEquipmentMaintainQuery query){
public BaseResponse create(@RequestBody PlanEquipmentMaintainQuery query) {
try {
return equipmentMaintainService.create(query);
}catch (Exception e){
log.debug("新增设备维护计划分页列表{}",e);
} catch (Exception e) {
log.debug("新增设备维护计划分页列表{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "更新设备维护计划")
@PostMapping("/update")
public BaseResponse update(@RequestBody PlanEquipmentMaintainQuery query){
public BaseResponse update(@RequestBody PlanEquipmentMaintainQuery query) {
try {
return equipmentMaintainService.update(query);
}catch (Exception e){
log.debug("更新设备维护计划{}",e);
} catch (Exception e) {
log.debug("更新设备维护计划{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "设备维护计划详情")
@GetMapping("/{id}")
public BaseResponse getDetail(@PathVariable Integer id){
public BaseResponse getDetail(@PathVariable Integer id) {
try {
return equipmentMaintainService.getDetail(id);
}catch (Exception e){
log.debug("设备维护计划详情{}",e);
} catch (Exception e) {
log.debug("设备维护计划详情{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "维护完成")
@PostMapping("/finish")
public BaseResponse finish(Integer id){
public BaseResponse finish(Integer id) {
try {
return equipmentMaintainService.finish(id);
}catch (Exception e){
log.debug("维护完成{}",e);
} catch (Exception e) {
log.debug("维护完成{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "删除")
@PostMapping("/delete/{id}")
public BaseResponse delete(@PathVariable Integer id){
public BaseResponse delete(@PathVariable Integer id) {
try {
return equipmentMaintainService.delete(id);
}catch (Exception e){
log.debug("删除{}",e);
} catch (Exception e) {
log.debug("删除{}", e);
}
return BaseResponse.errorMsg("失败!");
}
}
package cn.wise.sc.cement.business.controller;
import cn.wise.sc.cement.business.model.BaseResponse;
import cn.wise.sc.cement.business.model.PageQuery;
import cn.wise.sc.cement.business.model.query.PlanEquipmentPurchaseQuery;
......@@ -19,13 +18,13 @@ import javax.servlet.http.HttpServletResponse;
/**
* <p>
* 前端控制器
* 前端控制器
* </p>
*
* @author ztw
* @since 2020-09-28
*/
@Api(tags="计划管理-设备采购计划")
@Api(tags = "计划管理-设备采购计划")
@RestController
@RequestMapping("/business/plan-equipment-purchase")
public class PlanEquipmentPurchaseController {
......@@ -61,59 +60,58 @@ public class PlanEquipmentPurchaseController {
@ApiOperation(value = "新增设备采购计划")
@PostMapping("/create")
public BaseResponse create(@RequestBody PlanEquipmentPurchaseQuery query){
public BaseResponse create(@RequestBody PlanEquipmentPurchaseQuery query) {
try {
return equipmentPurchaseService.create(query);
}catch (Exception e){
log.debug("新增设备采购计划{}",e);
} catch (Exception e) {
log.debug("新增设备采购计划{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "更新设备采购计划")
@PostMapping("/update")
public BaseResponse update(@RequestBody PlanEquipmentPurchaseQuery query){
public BaseResponse update(@RequestBody PlanEquipmentPurchaseQuery query) {
try {
return equipmentPurchaseService.update(query);
}catch (Exception e){
log.debug("更新设备采购计划{}",e);
} catch (Exception e) {
log.debug("更新设备采购计划{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "设备采购计划详情")
@GetMapping("/{id}")
public BaseResponse getDetail(@PathVariable Integer id){
public BaseResponse getDetail(@PathVariable Integer id) {
try {
return equipmentPurchaseService.getDetail(id);
}catch (Exception e){
log.debug("设备采购计划详情{}",e);
} catch (Exception e) {
log.debug("设备采购计划详情{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "采购完成")
@PostMapping("/finish")
public BaseResponse finish(Integer id){
public BaseResponse finish(Integer id) {
try {
return equipmentPurchaseService.finish(id);
}catch (Exception e){
log.debug("采购完成{}",e);
} catch (Exception e) {
log.debug("采购完成{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "删除")
@PostMapping("/delete/{id}")
public BaseResponse delete(@PathVariable Integer id){
public BaseResponse delete(@PathVariable Integer id) {
try {
return equipmentPurchaseService.delete(id);
}catch (Exception e){
log.debug("删除{}",e);
} catch (Exception e) {
log.debug("删除{}", e);
}
return BaseResponse.errorMsg("失败!");
}
}
package cn.wise.sc.cement.business.controller;
import cn.wise.sc.cement.business.model.BaseResponse;
import cn.wise.sc.cement.business.model.PageQuery;
import cn.wise.sc.cement.business.model.query.PlanEquipmentPurchaseQuery;
......@@ -19,13 +18,13 @@ import javax.servlet.http.HttpServletResponse;
/**
* <p>
* 前端控制器
* 前端控制器
* </p>
*
* @author ztw
* @since 2020-09-28
*/
@Api(tags="计划管理-设备维修计划")
@Api(tags = "计划管理-设备维修计划")
@RestController
@RequestMapping("/business/plan-equipment-repair")
public class PlanEquipmentRepairController {
......@@ -59,62 +58,60 @@ public class PlanEquipmentRepairController {
}
}
@ApiOperation(value = "新增设备维修计划")
@PostMapping("/create")
public BaseResponse create(@RequestBody PlanEquipmentRepairQuery query){
public BaseResponse create(@RequestBody PlanEquipmentRepairQuery query) {
try {
return equipmentRepairService.create(query);
}catch (Exception e){
log.debug("新增设备维修计划{}",e);
} catch (Exception e) {
log.debug("新增设备维修计划{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "更新设备维修计划")
@PostMapping("/update")
public BaseResponse update(@RequestBody PlanEquipmentRepairQuery query){
public BaseResponse update(@RequestBody PlanEquipmentRepairQuery query) {
try {
return equipmentRepairService.update(query);
}catch (Exception e){
log.debug("更新设备维修计划{}",e);
} catch (Exception e) {
log.debug("更新设备维修计划{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "设备维修计划详情")
@GetMapping("/{id}")
public BaseResponse getDetail(@PathVariable Integer id){
public BaseResponse getDetail(@PathVariable Integer id) {
try {
return equipmentRepairService.getDetail(id);
}catch (Exception e){
log.debug("设备维修计划详情{}",e);
} catch (Exception e) {
log.debug("设备维修计划详情{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "维修完成")
@PostMapping("/finish")
public BaseResponse finish(Integer id){
public BaseResponse finish(Integer id) {
try {
return equipmentRepairService.finish(id);
}catch (Exception e){
log.debug("维修完成{}",e);
} catch (Exception e) {
log.debug("维修完成{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "删除")
@PostMapping("/delete/{id}")
public BaseResponse delete(@PathVariable Integer id){
public BaseResponse delete(@PathVariable Integer id) {
try {
return equipmentRepairService.delete(id);
}catch (Exception e){
log.debug("删除{}",e);
} catch (Exception e) {
log.debug("删除{}", e);
}
return BaseResponse.errorMsg("失败!");
}
}
......@@ -31,9 +31,9 @@ public class PlanPeopleController {
@ApiOperation(value = "培训计划审批分页")
@GetMapping("/getPage")
public BaseResponse getPage(PageQuery pageQuery,Integer planId) {
public BaseResponse getPage(PageQuery pageQuery, Integer planId) {
try {
return iPlanPeopleService.getPage(pageQuery,planId);
return iPlanPeopleService.getPage(pageQuery, planId);
} catch (Exception e) {
log.debug("培训计划分页{}", e);
}
......@@ -53,11 +53,11 @@ public class PlanPeopleController {
@ApiOperation(value = "考核结果")
@PostMapping("/status")
public BaseResponse status(Integer status, Integer id){
public BaseResponse status(Integer status, Integer id) {
try {
return iPlanPeopleService.status(status, id);
}catch (Exception e){
log.debug("审批操作实现{}",e);
} catch (Exception e) {
log.debug("审批操作实现{}", e);
}
return BaseResponse.errorMsg("失败!");
}
......@@ -75,11 +75,11 @@ public class PlanPeopleController {
@ApiOperation(value = "同步历史档案")
@PostMapping("/synchronization/{id}")
public BaseResponse synchronization(@PathVariable Integer id){
public BaseResponse synchronization(@PathVariable Integer id) {
try {
return iPlanPeopleService.synchronization(id);
}catch (Exception e){
log.debug("同步历史档案{}",e);
} catch (Exception e) {
log.debug("同步历史档案{}", e);
}
return BaseResponse.errorMsg("失败!");
}
......
package cn.wise.sc.cement.business.controller;
import cn.wise.sc.cement.business.model.BaseResponse;
import cn.wise.sc.cement.business.model.PageQuery;
import cn.wise.sc.cement.business.model.query.PlanEquipmentPurchaseQuery;
......@@ -19,13 +18,13 @@ import javax.servlet.http.HttpServletResponse;
/**
* <p>
* 前端控制器
* 前端控制器
* </p>
*
* @author ztw
* @since 2020-09-28
*/
@Api(tags="计划管理-标样采购计划")
@Api(tags = "计划管理-标样采购计划")
@RestController
@RequestMapping("/business/plan-standard-purchase")
public class PlanStandardPurchaseController {
......@@ -59,65 +58,60 @@ public class PlanStandardPurchaseController {
}
}
@ApiOperation(value = "新增标样采购计划")
@PostMapping("/create")
public BaseResponse create(@RequestBody PlanStandardPurchaseQuery query){
public BaseResponse create(@RequestBody PlanStandardPurchaseQuery query) {
try {
return standardPurchaseService.create(query);
}catch (Exception e){
log.debug("新增标样采购计划{}",e);
} catch (Exception e) {
log.debug("新增标样采购计划{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "更新标样采购计划")
@PostMapping("/update")
public BaseResponse update(@RequestBody PlanStandardPurchaseQuery query){
public BaseResponse update(@RequestBody PlanStandardPurchaseQuery query) {
try {
return standardPurchaseService.update(query);
}catch (Exception e){
log.debug("更新标样采购计划{}",e);
} catch (Exception e) {
log.debug("更新标样采购计划{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "标样采购计划详情")
@GetMapping("/{id}")
public BaseResponse getDetail(@PathVariable Integer id){
public BaseResponse getDetail(@PathVariable Integer id) {
try {
return standardPurchaseService.getDetail(id);
}catch (Exception e){
log.debug("标样采购计划详情{}",e);
} catch (Exception e) {
log.debug("标样采购计划详情{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "采购完成")
@PostMapping("/finish")
public BaseResponse finish(Integer id){
public BaseResponse finish(Integer id) {
try {
return standardPurchaseService.finish(id);
}catch (Exception e){
log.debug("采购完成{}",e);
} catch (Exception e) {
log.debug("采购完成{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "删除")
@PostMapping("/delete/{id}")
public BaseResponse delete(@PathVariable Integer id){
public BaseResponse delete(@PathVariable Integer id) {
try {
return standardPurchaseService.delete(id);
}catch (Exception e){
log.debug("删除{}",e);
} catch (Exception e) {
log.debug("删除{}", e);
}
return BaseResponse.errorMsg("失败!");
}
}
......@@ -67,49 +67,49 @@ public class PlanTrainingController {
@ApiOperation(value = "根据id查询指定培训计划")
@GetMapping("/{id}")
public BaseResponse getById(@PathVariable Integer id){
public BaseResponse getById(@PathVariable Integer id) {
try {
BaseResponse<List<PlanTrainingVo>> e = iplanTrainingService.getById(id);
if(e == null){
if (e == null) {
return BaseResponse.errorMsg("信息错误!");
}
return BaseResponse.okData(e);
}catch (Exception e){
log.debug("通过id查询培训计划{}",e);
} catch (Exception e) {
log.debug("通过id查询培训计划{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "添加培训")
@PostMapping("/create")
public BaseResponse create(@RequestBody PlanTrainingQuery query){
if (query.getRemind()==0 && query.getRemindTime()!=null){
public BaseResponse create(@RequestBody PlanTrainingQuery query) {
if (query.getRemind() == 0 && query.getRemindTime() != null) {
return BaseResponse.errorMsg("没有确认提醒");
}
if (query.getRemind()==1 && query.getRemindTime()==null){
if (query.getRemind() == 1 && query.getRemindTime() == null) {
return BaseResponse.errorMsg("请选择提醒时间");
}
try {
return iplanTrainingService.create(query);
}catch (Exception e){
log.debug("添加培训{}",e);
} catch (Exception e) {
log.debug("添加培训{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "修改培训计划")
@PostMapping("/update")
public BaseResponse update(@RequestBody PlanTrainingQuery planTrainingQuery){
if (planTrainingQuery.getRemind()==0 && planTrainingQuery.getRemindTime()!=null){
public BaseResponse update(@RequestBody PlanTrainingQuery planTrainingQuery) {
if (planTrainingQuery.getRemind() == 0 && planTrainingQuery.getRemindTime() != null) {
return BaseResponse.errorMsg("没有确认提醒");
}
if (planTrainingQuery.getRemind()==1 && planTrainingQuery.getRemindTime()==null){
if (planTrainingQuery.getRemind() == 1 && planTrainingQuery.getRemindTime() == null) {
return BaseResponse.errorMsg("请选择提醒时间");
}
try {
return iplanTrainingService.update(planTrainingQuery);
}catch (Exception e){
log.debug("修改培训计划{}",e);
} catch (Exception e) {
log.debug("修改培训计划{}", e);
}
return BaseResponse.errorMsg("失败!");
}
......@@ -127,20 +127,20 @@ public class PlanTrainingController {
@ApiOperation(value = "删除培训信息")
@PostMapping("/delete/{id}")
public BaseResponse delete(@PathVariable Integer id){
public BaseResponse delete(@PathVariable Integer id) {
try {
return iplanTrainingService.delete(id);
}catch (Exception e){
log.debug("删除培训信息{}",e);
} catch (Exception e) {
log.debug("删除培训信息{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation("培训计划导出")
@PostMapping("/exportList")
public void exportList(String filename,String objective, HttpServletResponse response) {
public void exportList(String filename, String objective, HttpServletResponse response) {
try {
iplanTrainingService.exportList(filename,objective,response);
iplanTrainingService.exportList(filename, objective, response);
} catch (Exception e) {
log.debug("培训计划导出{}", e);
}
......
......@@ -23,7 +23,7 @@ import javax.servlet.http.HttpServletResponse;
/**
* <p>
* 前端控制器
* 前端控制器
* </p>
*
* @author ztw
......@@ -68,15 +68,15 @@ public class ProjectController {
@ApiOperation(value = "项目详情")
@GetMapping("/{id}")
public BaseResponse getById(@PathVariable Integer id){
public BaseResponse getById(@PathVariable Integer id) {
try {
Project e = projectService.getById(id);
if(e == null){
if (e == null) {
return BaseResponse.errorMsg("信息错误!");
}
return BaseResponse.okData(e);
}catch (Exception e){
log.debug("项目详情{}",e);
} catch (Exception e) {
log.debug("项目详情{}", e);
}
return BaseResponse.errorMsg("失败!");
}
......@@ -94,49 +94,48 @@ public class ProjectController {
@ApiOperation(value = "新增项目")
@PostMapping("/create")
public BaseResponse create(@RequestBody ProjectQuery query){
public BaseResponse create(@RequestBody ProjectQuery query) {
try {
return projectService.create(query);
}catch (Exception e){
log.debug("新增项目{}",e);
} catch (Exception e) {
log.debug("新增项目{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "更新项目")
@PostMapping("/update")
public BaseResponse update(@RequestBody ProjectQuery query){
public BaseResponse update(@RequestBody ProjectQuery query) {
try {
return projectService.update(query);
}catch (Exception e){
log.debug("更新项目{}",e);
} catch (Exception e) {
log.debug("更新项目{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "启用禁用")
@PostMapping("/status")
public BaseResponse status(Integer status, Integer id){
public BaseResponse status(Integer status, Integer id) {
try {
return projectService.status(status, id);
}catch (Exception e){
log.debug("启用禁用{}",e);
} catch (Exception e) {
log.debug("启用禁用{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "根据项目名称判断是否存在")
@GetMapping("/getByName")
public BaseResponse getByName(String name){
public BaseResponse getByName(String name) {
try {
return projectService.getByName(name);
}catch (Exception e){
log.debug("根据项目名称判断是否存在{}",e);
} catch (Exception e) {
log.debug("根据项目名称判断是否存在{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "根据委托单位id获取项目列表")
@GetMapping("/getProjectList")
public BaseResponse getProjectList(Integer clientId) {
......@@ -148,8 +147,5 @@ public class ProjectController {
return BaseResponse.errorMsg("失败!");
}
}
package cn.wise.sc.cement.business.controller;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import cn.wise.sc.cement.business.entity.QualityApply;
......@@ -41,38 +40,37 @@ import java.util.List;
@RequestMapping("/business/qualityApply")
public class QualityApplyController {
final
IQualityApplyService iQualityApplyService;
public QualityApplyController(IQualityApplyService iQualityApplyService) {
this.iQualityApplyService = iQualityApplyService;
}
final
IQualityApplyService iQualityApplyService;
@PostMapping("/apply")
@ApiOperation("质量详情审核")
public BaseResponse<Boolean> applyQuality(@RequestBody List<QualityApply> qualityApply) {
boolean save = iQualityApplyService.saveBatch(qualityApply);
if (save) {
return BaseResponse.okData(true);
} else {
return BaseResponse.errorMsg("添加失败!");
}
}
public QualityApplyController(IQualityApplyService iQualityApplyService) {
this.iQualityApplyService = iQualityApplyService;
}
@PostMapping("/apply")
@ApiOperation("质量详情审核")
public BaseResponse<Boolean> applyQuality(@RequestBody List<QualityApply> qualityApply) {
boolean save = iQualityApplyService.saveBatch(qualityApply);
if (save) {
return BaseResponse.okData(true);
} else {
return BaseResponse.errorMsg("添加失败!");
}
}
@PostMapping("/export")
@ApiOperation("导出质量监控")
public void exportQuality(String startDate, String endDate, HttpServletResponse response) {
@PostMapping("/export")
@ApiOperation("导出质量监控")
public void exportQuality(String startDate, String endDate, HttpServletResponse response) {
Date startParse = null;
if (StrUtil.isNotBlank(startDate)) {
startParse = DateUtil.parse(startDate);
}
Date endParse = null;
if (StrUtil.isNotBlank(endDate)) {
endParse = DateUtil.parse(endDate);
}
iQualityApplyService.exportQuality(startParse, endParse, response);
}
Date startParse = null;
if (StrUtil.isNotBlank(startDate)) {
startParse = DateUtil.parse(startDate);
}
Date endParse = null;
if (StrUtil.isNotBlank(endDate)) {
endParse = DateUtil.parse(endDate);
}
iQualityApplyService.exportQuality(startParse, endParse, response);
}
}
......@@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
......@@ -31,57 +32,56 @@ import java.util.stream.Collectors;
@RequestMapping("/business/quality")
public class QualityController {
final
IEntrustService iEntrustService;
final
IQualityApplyService iQualityApplyService;
public QualityController(IEntrustService iEntrustService, IQualityApplyService iQualityApplyService) {
this.iEntrustService = iEntrustService;
this.iQualityApplyService = iQualityApplyService;
}
final
IEntrustService iEntrustService;
final
IQualityApplyService iQualityApplyService;
@ApiOperation(value = "质量检测分页列表")
@ApiImplicitParams(value = {
@ApiImplicitParam(name = "startDate", value = "开始日期", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "endDate", value = "结束日期", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "clientId", value = "委托单位id", paramType = "query", dataType = "Integer"),
@ApiImplicitParam(name = "projectName", value = "项目名称", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "projectCode", value = "项目编号", paramType = "query", dataType = "String")
})
@GetMapping("/getPage")
public BaseResponse<IPage<EntrustVo>> page(PageQuery pageQuery, String startDate, String endDate,
Integer clientId, String projectName, String projectCode) {
BaseResponse<IPage<EntrustVo>> baseResponse = iEntrustService.getQualityPage(
pageQuery, startDate, endDate, clientId, projectName, projectCode);
public QualityController(IEntrustService iEntrustService, IQualityApplyService iQualityApplyService) {
this.iEntrustService = iEntrustService;
this.iQualityApplyService = iQualityApplyService;
}
//判断是否已经评审过
if (baseResponse.getCode() == 200) {
@ApiOperation(value = "质量检测分页列表")
@ApiImplicitParams(value = {
@ApiImplicitParam(name = "startDate", value = "开始日期", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "endDate", value = "结束日期", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "clientId", value = "委托单位id", paramType = "query", dataType = "Integer"),
@ApiImplicitParam(name = "projectName", value = "项目名称", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "projectCode", value = "项目编号", paramType = "query", dataType = "String")
})
@GetMapping("/getPage")
public BaseResponse<IPage<EntrustVo>> page(PageQuery pageQuery, String startDate, String endDate,
Integer clientId, String projectName, String projectCode) {
BaseResponse<IPage<EntrustVo>> baseResponse = iEntrustService.getQualityPage(
pageQuery, startDate, endDate, clientId, projectName, projectCode);
List<EntrustVo> records = baseResponse.getData().getRecords();
if (records.size() == 0) {
return BaseResponse.errorMsg("没找到相关数据!");
}
List<Integer> projectIds = records.stream().map(EntrustVo::getId).collect(Collectors.toList());
Set<Integer> qualityApplyIds = iQualityApplyService.selectQualityApplyStatusByProIds(projectIds);
records.forEach(arg->{
if (qualityApplyIds.contains(arg.getId())){
arg.setStatusValue("审核完成");
arg.setStatus(10);
}else {
arg.setStatusValue("待审核");
arg.setStatus(9);
}
});
}
return baseResponse;
}
//判断是否已经评审过
if (baseResponse.getCode() == 200) {
@GetMapping("/{entrustId}")
@ApiOperation("获取质量详情")
public BaseResponse<QualityDetailVo> getReportDetail(@PathVariable("entrustId") Integer entrustId) {
return BaseResponse.okData(iEntrustService.getQualityDetail(entrustId));
}
List<EntrustVo> records = baseResponse.getData().getRecords();
if (records.size() == 0) {
return BaseResponse.errorMsg("没找到相关数据!");
}
List<Integer> projectIds = records.stream().map(EntrustVo::getId).collect(Collectors.toList());
Set<Integer> qualityApplyIds = iQualityApplyService.selectQualityApplyStatusByProIds(projectIds);
records.forEach(arg -> {
if (qualityApplyIds.contains(arg.getId())) {
arg.setStatusValue("审核完成");
arg.setStatus(10);
} else {
arg.setStatusValue("待审核");
arg.setStatus(9);
}
});
}
return baseResponse;
}
@GetMapping("/{entrustId}")
@ApiOperation("获取质量详情")
public BaseResponse<QualityDetailVo> getReportDetail(@PathVariable("entrustId") Integer entrustId) {
return BaseResponse.okData(iEntrustService.getQualityDetail(entrustId));
}
}
package cn.wise.sc.cement.business.controller;
import cn.wise.sc.cement.business.entity.Supplier;
import cn.wise.sc.cement.business.entity.SysPost;
import cn.wise.sc.cement.business.model.BaseResponse;
......@@ -21,13 +20,13 @@ import java.util.List;
/**
* <p>
* 前端控制器
* 前端控制器
* </p>
*
* @author ztw
* @since 2020-09-01
*/
@Api(tags="资源管理-供应商管理")
@Api(tags = "资源管理-供应商管理")
@RestController
@RequestMapping("/business/supplier")
public class SupplierController {
......@@ -56,8 +55,8 @@ public class SupplierController {
public BaseResponse create(@RequestBody SupplierQuery query) {
try {
return supplierService.create(query);
}catch (Exception e) {
log.debug("新增供应商{}",e);
} catch (Exception e) {
log.debug("新增供应商{}", e);
}
return BaseResponse.errorMsg("失败!");
}
......@@ -67,53 +66,50 @@ public class SupplierController {
public BaseResponse update(@RequestBody SupplierQuery query) {
try {
return supplierService.update(query);
}catch (Exception e) {
log.debug("修改供应商{}",e);
} catch (Exception e) {
log.debug("修改供应商{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "供应商详情")
@GetMapping("/{id}")
public BaseResponse getById(@PathVariable Integer id){
public BaseResponse getById(@PathVariable Integer id) {
try {
Supplier supplier = supplierService.getById(id);
if(supplier == null){
if (supplier == null) {
return BaseResponse.errorMsg("信息错误!");
}
return BaseResponse.okData(supplier);
}catch (Exception e){
log.debug("供应商详情{}",e);
} catch (Exception e) {
log.debug("供应商详情{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "供应商列表")
@GetMapping("/getList")
public BaseResponse getList(){
public BaseResponse getList() {
try {
List<Supplier> list = supplierService.list();
return BaseResponse.okData(list);
}catch (Exception e){
log.debug("供应商列表{}",e);
} catch (Exception e) {
log.debug("供应商列表{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "删除供应商")
@PostMapping("/delete/{id}")
public BaseResponse delete(@PathVariable Integer id){
public BaseResponse delete(@PathVariable Integer id) {
try {
supplierService.removeById(id);
return BaseResponse.okData("删除成功");
}catch (Exception e){
log.debug("删除供应商{}",e);
} catch (Exception e) {
log.debug("删除供应商{}", e);
}
return BaseResponse.errorMsg("失败!");
}
}
......@@ -2,14 +2,16 @@ package cn.wise.sc.cement.business.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* <p>
*
*
* </p>
*
* @author ztw
......@@ -20,12 +22,11 @@ import lombok.experimental.Accessors;
@Accessors(chain = true)
public class Cabinet implements Serializable {
private static final long serialVersionUID=1L;
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
private static final long serialVersionUID = 1L;
private String name;
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
private String name;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment