commit
298a694881
@ -0,0 +1,15 @@ |
||||
FROM moxm/java:1.8-full |
||||
|
||||
RUN mkdir -p /dlp-sewage-job |
||||
|
||||
WORKDIR /dlp-sewage-job |
||||
|
||||
ARG JAR_FILE=target/dlp-sewage-job.jar |
||||
|
||||
COPY ${JAR_FILE} app.jar |
||||
|
||||
EXPOSE 5203 |
||||
|
||||
ENV TZ=Asia/Shanghai JAVA_OPTS="-Xms128m -Xmx256m -Djava.security.egd=file:/dev/./urandom" |
||||
|
||||
CMD sleep 60; java -jar app.jar $JAVA_OPTS |
@ -0,0 +1,221 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" |
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
<parent> |
||||
<groupId>digital.laboratory.platform</groupId> |
||||
<artifactId>DigitalLaboratoryPlatform</artifactId> |
||||
<version>2022.10.11-snapshots</version> |
||||
</parent> |
||||
|
||||
<artifactId>dlp-sewage-job</artifactId> |
||||
<packaging>jar</packaging> |
||||
|
||||
<description>污水检测任务</description> |
||||
|
||||
<dependencies> |
||||
<!--注册中心客户端--> |
||||
<!-- https://mvnrepository.com/artifact/com.alibaba.cloud/spring-cloud-starter-alibaba-nacos-discovery --> |
||||
<dependency> |
||||
<groupId>com.alibaba.cloud</groupId> |
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> |
||||
<version>2021.1</version> |
||||
</dependency> |
||||
|
||||
<!--配置中心客户端--> |
||||
<!-- https://mvnrepository.com/artifact/com.alibaba.cloud/spring-cloud-starter-alibaba-nacos-config --> |
||||
<dependency> |
||||
<groupId>com.alibaba.cloud</groupId> |
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId> |
||||
<version>2021.1</version> |
||||
</dependency> |
||||
|
||||
<!-- swagger --> |
||||
<dependency> |
||||
<groupId>digital.laboratory.platform</groupId> |
||||
<artifactId>dlp-common-swagger</artifactId> |
||||
</dependency> |
||||
|
||||
<!--断路器依赖--> |
||||
<dependency> |
||||
<groupId>digital.laboratory.platform</groupId> |
||||
<artifactId>dlp-common-feign</artifactId> |
||||
<version>2022.10.11-snapshots</version> |
||||
</dependency> |
||||
|
||||
<!--security--> |
||||
<dependency> |
||||
<groupId>digital.laboratory.platform</groupId> |
||||
<artifactId>dlp-common-security</artifactId> |
||||
<version>2022.10.11-snapshots</version> |
||||
</dependency> |
||||
<!--JDBC相关--> |
||||
<dependency> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-starter-jdbc</artifactId> |
||||
</dependency> |
||||
|
||||
<!-- 数据库 mysql依赖 --> |
||||
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java --> |
||||
<dependency> |
||||
<groupId>mysql</groupId> |
||||
<artifactId>mysql-connector-java</artifactId> |
||||
<version>${mysql-connector-java.version}</version> |
||||
</dependency> |
||||
<!--undertow容器--> |
||||
<dependency> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-starter-undertow</artifactId> |
||||
</dependency> |
||||
<!-- log --> |
||||
<dependency> |
||||
<groupId>digital.laboratory.platform</groupId> |
||||
<artifactId>dlp-common-log</artifactId> |
||||
<version>2022.10.11-snapshots</version> |
||||
</dependency> |
||||
<!-- 业务数据的依赖 --> |
||||
<dependency> |
||||
<groupId>digital.laboratory.platform</groupId> |
||||
<artifactId>dlp-admin-api</artifactId> |
||||
<version>2022.10.11-snapshots</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>digital.laboratory.platform</groupId> |
||||
<artifactId>dlp-sewage-api</artifactId> |
||||
<version>2022.10.11-snapshots</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>digital.laboratory.platform</groupId> |
||||
<artifactId>dlp-othersys-api</artifactId> |
||||
<version>2022.10.11-snapshots</version> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>digital.laboratory.platform</groupId> |
||||
<artifactId>dlp-common-oss</artifactId> |
||||
<version>2022.10.11-snapshots</version> |
||||
<scope>compile</scope> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>digital.laboratory.platform</groupId> |
||||
<artifactId>dlp-common-remote-word2pdf</artifactId> |
||||
<version>2022.10.11-snapshots</version> |
||||
<scope>compile</scope> |
||||
</dependency> |
||||
|
||||
<!-- https://mvnrepository.com/artifact/cglib/cglib-nodep --> |
||||
<!-- 主要使用 beanToMap --> |
||||
<dependency> |
||||
<groupId>cglib</groupId> |
||||
<artifactId>cglib-nodep</artifactId> |
||||
<version>3.3.0</version> |
||||
</dependency> |
||||
|
||||
|
||||
<!-- mybatis 字段类型处理器TypeHandler --> |
||||
<dependency> |
||||
<groupId>com.fasterxml.jackson.datatype</groupId> |
||||
<artifactId>jackson-datatype-jsr310</artifactId> |
||||
<version>2.12.5</version> |
||||
</dependency> |
||||
<!-- fastjson --> |
||||
<dependency> |
||||
<groupId>com.alibaba</groupId> |
||||
<artifactId>fastjson</artifactId> |
||||
<version>1.2.9</version> |
||||
</dependency> |
||||
|
||||
<!-- 模板引擎: 生成打印标签 --> |
||||
<dependency> |
||||
<artifactId>velocity</artifactId> |
||||
<groupId>org.apache.velocity</groupId> |
||||
<version>${velocity.version}</version> |
||||
</dependency> |
||||
|
||||
<!-- for MockMultipartFile--> |
||||
<dependency> |
||||
<groupId>org.springframework</groupId> |
||||
<artifactId>spring-test</artifactId> |
||||
</dependency> |
||||
<!-- seata分布式事务--> |
||||
<dependency> |
||||
<groupId>digital.laboratory.platform</groupId> |
||||
<artifactId>dlp-common-seata</artifactId> |
||||
<version>2022.10.11-snapshots</version> |
||||
</dependency> |
||||
|
||||
</dependencies> |
||||
|
||||
|
||||
|
||||
<build> |
||||
<plugins> |
||||
<plugin> |
||||
<groupId>org.apache.maven.plugins</groupId> |
||||
<artifactId>maven-compiler-plugin</artifactId> |
||||
<configuration> |
||||
<compilerArgument>-Xlint:unchecked</compilerArgument> |
||||
</configuration> |
||||
<version>3.8.1</version> |
||||
</plugin> |
||||
<plugin> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-maven-plugin</artifactId> |
||||
</plugin> |
||||
<plugin> |
||||
<groupId>io.fabric8</groupId> |
||||
<artifactId>docker-maven-plugin</artifactId> |
||||
</plugin> |
||||
|
||||
<plugin> |
||||
<groupId>org.codehaus.mojo</groupId> |
||||
<artifactId>build-helper-maven-plugin</artifactId> |
||||
<version>3.0.0</version> |
||||
<executions> |
||||
<execution> |
||||
<id>timestamp-property</id> |
||||
<goals> |
||||
<goal>timestamp-property</goal> |
||||
</goals> |
||||
<configuration> |
||||
<name>timestamp</name> |
||||
<pattern>yyyy-MM-dd HH:mm:ss</pattern> |
||||
<locale>zh_CN</locale> |
||||
<timeZone>Asia/Shanghai</timeZone> |
||||
</configuration> |
||||
</execution> |
||||
</executions> |
||||
</plugin> |
||||
|
||||
|
||||
<plugin> |
||||
<groupId>org.apache.maven.plugins</groupId> |
||||
<artifactId>maven-resources-plugin</artifactId> |
||||
<version>3.1.0</version> |
||||
<executions> |
||||
<execution> |
||||
<id>copy-resource-one</id> |
||||
<phase>install</phase> |
||||
<goals> |
||||
<goal>copy-resources</goal> |
||||
</goals> |
||||
<configuration> |
||||
<outputDirectory>${basedir}/../../out</outputDirectory> |
||||
<resources> |
||||
<resource> |
||||
<directory>${basedir}/target</directory> |
||||
<includes> |
||||
<include>${project.artifactId}.jar</include> |
||||
</includes> |
||||
</resource> |
||||
</resources> |
||||
</configuration> |
||||
</execution> |
||||
</executions> |
||||
</plugin> |
||||
|
||||
</plugins> |
||||
</build> |
||||
|
||||
</project> |
@ -0,0 +1,37 @@ |
||||
package digital.laboratory.platform.sewage.Interceptor; |
||||
|
||||
import feign.RequestInterceptor; |
||||
import feign.RequestTemplate; |
||||
import org.springframework.context.annotation.Configuration; |
||||
import org.springframework.security.core.Authentication; |
||||
import org.springframework.security.core.context.SecurityContext; |
||||
import org.springframework.security.core.context.SecurityContextHolder; |
||||
import org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationDetails; |
||||
|
||||
/** |
||||
* Feign 请求拦截器 |
||||
* Feign Client 向业务系统发出请求的时候, 把 Token 带上, 以用户自己的身份调用业务系统。 |
||||
* 目的是在业务系统中识别用户是谁, 允许或禁止用户进行对应的操作。 |
||||
*/ |
||||
|
||||
|
||||
@Configuration |
||||
public class FeignOauth2RequestInterceptor implements RequestInterceptor { |
||||
|
||||
private final String AUTHORIZATION_HEADER = "Authorization"; |
||||
private final String BEARER_TOKEN_TYPE = "Bearer"; |
||||
|
||||
@Override |
||||
public void apply(RequestTemplate requestTemplate) { |
||||
System.out.println(String.format("dlp-entrustment, FeignOauth2RequestInterceptor()...")); |
||||
SecurityContext securityContext = SecurityContextHolder.getContext(); |
||||
Authentication authentication = securityContext.getAuthentication(); |
||||
if (authentication != null && authentication.getDetails() instanceof OAuth2AuthenticationDetails) { |
||||
OAuth2AuthenticationDetails details = (OAuth2AuthenticationDetails) authentication.getDetails(); |
||||
System.out.println(String.format("FeignOauth2RequestInterceptor() Authorization, token=%s", details.getTokenValue())); |
||||
requestTemplate.header(AUTHORIZATION_HEADER, String.format("%s %s", BEARER_TOKEN_TYPE, details.getTokenValue())); |
||||
} |
||||
|
||||
} |
||||
} |
||||
|
@ -0,0 +1,20 @@ |
||||
package digital.laboratory.platform.sewage; |
||||
|
||||
import digital.laboratory.platform.common.feign.annotation.EnableDLPFeignClients; |
||||
import digital.laboratory.platform.common.security.annotation.EnableDLPResourceServer; |
||||
import digital.laboratory.platform.common.swagger.annotation.EnableDLPSwagger2; |
||||
import org.springframework.boot.SpringApplication; |
||||
import org.springframework.boot.autoconfigure.SpringBootApplication; |
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient; |
||||
|
||||
@EnableDLPSwagger2 |
||||
@EnableDLPFeignClients |
||||
@EnableDiscoveryClient |
||||
@EnableDLPResourceServer |
||||
@SpringBootApplication(scanBasePackages="digital.laboratory.platform") |
||||
public class SewageJobApplication { |
||||
public static void main(String[] args) { |
||||
SpringApplication.run(SewageJobApplication.class, args); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,57 @@ |
||||
package digital.laboratory.platform.sewage.config; |
||||
|
||||
import com.alibaba.fastjson.JSON; |
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
||||
import org.apache.ibatis.type.BaseTypeHandler; |
||||
import org.apache.ibatis.type.JdbcType; |
||||
|
||||
import java.sql.CallableStatement; |
||||
import java.sql.PreparedStatement; |
||||
import java.sql.ResultSet; |
||||
import java.sql.SQLException; |
||||
import java.util.List; |
||||
|
||||
public abstract class BaseMybatisList2JsonHandler<T> extends BaseTypeHandler<List<T>> { |
||||
|
||||
@Override |
||||
public void setNonNullParameter(PreparedStatement ps, int i, List<T> parameter, JdbcType jdbcType) throws SQLException { |
||||
ps.setString(i, JSON.toJSONString(parameter)); |
||||
} |
||||
|
||||
@Override |
||||
public List<T> getNullableResult(ResultSet rs, String columnName) |
||||
throws SQLException { |
||||
String data = rs.getString(columnName); |
||||
List<T> r = StringUtils.isBlank(data) ? null : JSON.parseArray(data, (Class<T>) getRawType()); |
||||
return r; |
||||
} |
||||
|
||||
@Override |
||||
public List<T> getNullableResult(ResultSet rs, int columnIndex) throws SQLException { |
||||
String data = rs.getString(columnIndex); |
||||
return StringUtils.isBlank(data) ? null : JSON.parseArray(data, (Class<T>) getRawType()); |
||||
} |
||||
|
||||
@Override |
||||
public List<T> getNullableResult(CallableStatement cs, int columnIndex) |
||||
throws SQLException { |
||||
String data = cs.getString(columnIndex); |
||||
return StringUtils.isBlank(data) ? null : JSON.parseArray(data, (Class<T>) getRawType()); |
||||
} |
||||
|
||||
@Override |
||||
public List<T> getResult(ResultSet rs, String columnName) throws SQLException { |
||||
List<T> r = super.getResult(rs, columnName); |
||||
return r; |
||||
} |
||||
|
||||
@Override |
||||
public List<T> getResult(ResultSet rs, int columnIndex) throws SQLException { |
||||
return super.getResult(rs, columnIndex); |
||||
} |
||||
|
||||
@Override |
||||
public List<T> getResult(CallableStatement cs, int columnIndex) throws SQLException { |
||||
return super.getResult(cs, columnIndex); |
||||
} |
||||
} |
@ -0,0 +1,60 @@ |
||||
package digital.laboratory.platform.sewage.config; |
||||
|
||||
import com.alibaba.fastjson.JSON; |
||||
import com.alibaba.fastjson.TypeReference; |
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
||||
import org.apache.ibatis.type.BaseTypeHandler; |
||||
import org.apache.ibatis.type.JdbcType; |
||||
|
||||
import java.sql.CallableStatement; |
||||
import java.sql.PreparedStatement; |
||||
import java.sql.ResultSet; |
||||
import java.sql.SQLException; |
||||
import java.util.HashMap; |
||||
|
||||
public abstract class BaseMybatisMap2JsonHandler<T> extends BaseTypeHandler<HashMap<String, T>> { |
||||
|
||||
protected abstract TypeReference getType(); |
||||
// typeReference = new InstructionBoHashMap();
|
||||
|
||||
@Override |
||||
public void setNonNullParameter(PreparedStatement ps, int i, HashMap<String, T> parameter, JdbcType jdbcType) throws SQLException { |
||||
ps.setString(i, JSON.toJSONString(parameter)); |
||||
} |
||||
|
||||
@Override |
||||
public HashMap<String, T> getNullableResult(ResultSet rs, String columnName) |
||||
throws SQLException { |
||||
String data = rs.getString(columnName); |
||||
|
||||
return StringUtils.isBlank(data) ? null : (HashMap<String, T>)JSON.parseObject(data, getType()); |
||||
} |
||||
|
||||
@Override |
||||
public HashMap<String, T> getNullableResult(ResultSet rs, int columnIndex) throws SQLException { |
||||
String data = rs.getString(columnIndex); |
||||
return StringUtils.isBlank(data) ? null : (HashMap<String, T>)JSON.parseObject(data, getType()); |
||||
} |
||||
|
||||
@Override |
||||
public HashMap<String, T> getNullableResult(CallableStatement cs, int columnIndex) |
||||
throws SQLException { |
||||
String data = cs.getString(columnIndex); |
||||
return StringUtils.isBlank(data) ? null : (HashMap<String, T>)JSON.parseObject(data, getType()); |
||||
} |
||||
|
||||
@Override |
||||
public HashMap<String, T> getResult(ResultSet rs, String columnName) throws SQLException { |
||||
return super.getResult(rs, columnName); |
||||
} |
||||
|
||||
@Override |
||||
public HashMap<String, T> getResult(ResultSet rs, int columnIndex) throws SQLException { |
||||
return super.getResult(rs, columnIndex); |
||||
} |
||||
|
||||
@Override |
||||
public HashMap<String, T> getResult(CallableStatement cs, int columnIndex) throws SQLException { |
||||
return super.getResult(cs, columnIndex); |
||||
} |
||||
} |
@ -0,0 +1,72 @@ |
||||
package digital.laboratory.platform.sewage.config; |
||||
|
||||
import digital.laboratory.platform.common.core.util.R; |
||||
import org.springframework.http.HttpStatus; |
||||
import org.springframework.http.ResponseEntity; |
||||
import org.springframework.web.bind.annotation.ControllerAdvice; |
||||
import org.springframework.web.bind.annotation.ExceptionHandler; |
||||
import org.springframework.web.bind.annotation.ResponseBody; |
||||
import org.springframework.web.servlet.NoHandlerFoundException; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* Spring Boot 自定义异常处理 |
||||
* 所有的异常都派生自 Exception, 如果我们定义了某个异常的处理 Handler, Spring Boot 会调用用对应的异常 Handler, 否则会调用 Exception Handler. |
||||
* 有一个前提是在 application.yml 中定义两个属性, 让 springboot 在没有找到 url 的处理器触发异常; 让 springboot 不要自作多情加 /error 这个 map |
||||
* mvc: |
||||
* throw-exception-if-no-handler-found: true |
||||
* web: |
||||
* resources: |
||||
* add-mappings: false |
||||
* 只有如此, springboot 才会触发异常。 |
||||
* |
||||
*/ |
||||
|
||||
|
||||
@ControllerAdvice |
||||
public class ErrorController { |
||||
|
||||
@ExceptionHandler(Exception.class) |
||||
@ResponseBody |
||||
public ResponseEntity error(Exception ex) { |
||||
System.out.println("ErrorController.error Exception"); |
||||
ex.printStackTrace(); |
||||
Map<String, Object> map = new HashMap<>(); |
||||
map.put("Exception", ex.getClass().getName()); |
||||
map.put("message", ex.getMessage()); |
||||
map.put("localizedMessage", ex.getLocalizedMessage()); |
||||
map.put("toString", ex.toString()); |
||||
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(R.failed(map, "发生异常 "+ex.getMessage())); |
||||
} |
||||
|
||||
|
||||
@ExceptionHandler(value = {NoHandlerFoundException.class}) |
||||
@ResponseBody |
||||
public ResponseEntity error(NoHandlerFoundException ex) { |
||||
//System.out.println("ErrorController.error NoHandlerFoundException");
|
||||
//ex.printStackTrace();
|
||||
// //ex.getRawStatusCode()
|
||||
Map<String, Object> map = new HashMap<>(); |
||||
map.put("Exception", ex.getClass().getName()); |
||||
map.put("message", ex.getMessage()); |
||||
map.put("localizedMessage", ex.getLocalizedMessage()); |
||||
map.put("requestURL", ex.getRequestURL()); |
||||
map.put("httpMethod", ex.getHttpMethod()); |
||||
// map.put("cause", ex.getCause().toString());
|
||||
map.put("toString", ex.toString()); |
||||
// map.put("comments", "单独的 ExceptionHandler, 系统管理捕获的全局异常 NoHandlerFoundException");
|
||||
// //return map;
|
||||
// //ResponseEntity<Map<String,Object>> r = new ResponseEntity<Map<String,Object>>(map, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
// //ResponseEntity<Map<String,Object>> r = new ResponseEntity<Map<String,Object>>(map, HttpStatus.NOT_FOUND);
|
||||
// //return r;
|
||||
// return ResponseEntity.status(HttpStatus.NOT_FOUND).body(map);
|
||||
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(R.failed(map, "没有找到")); |
||||
} |
||||
|
||||
|
||||
} |
||||
|
@ -0,0 +1,68 @@ |
||||
package digital.laboratory.platform.sewage.config; |
||||
|
||||
import com.alibaba.fastjson.JSON; |
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
||||
import digital.laboratory.platform.sewage.entity.UpdateInfo; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.apache.ibatis.type.BaseTypeHandler; |
||||
import org.apache.ibatis.type.JdbcType; |
||||
import org.apache.ibatis.type.MappedJdbcTypes; |
||||
import org.apache.ibatis.type.MappedTypes; |
||||
|
||||
import java.sql.CallableStatement; |
||||
import java.sql.PreparedStatement; |
||||
import java.sql.ResultSet; |
||||
import java.sql.SQLException; |
||||
import java.util.List; |
||||
|
||||
@Slf4j |
||||
@MappedTypes({List.class}) // 指定与其关联的 Java 类型列表。 如果在 javaType 属性中也同时指定,则注解上的配置将被忽略。
|
||||
@MappedJdbcTypes(JdbcType.JAVA_OBJECT) // 注解指定与其关联的 JDBC 类型列表。 如果在 jdbcType 属性中也同时指定,则注解上的配置将被忽略。
|
||||
// public class ProcessInfoListJsonHandler extends BaseMybatisList2JsonHandler<ProcessInfo> {
|
||||
// }
|
||||
public class ProcessInfoListJsonHandler extends BaseTypeHandler<List<UpdateInfo>> { |
||||
|
||||
@Override |
||||
public void setNonNullParameter(PreparedStatement ps, int i, List<UpdateInfo> parameter, JdbcType jdbcType) throws SQLException { |
||||
ps.setString(i, JSON.toJSONString(parameter)); |
||||
} |
||||
|
||||
@Override |
||||
public List<UpdateInfo> getNullableResult(ResultSet rs, String columnName) |
||||
throws SQLException { |
||||
String data = rs.getString(columnName); |
||||
//List<ProcessInfo> r = StringUtils.isBlank(data) ? null : JSON.parseArray(data, (Class<ProcessInfo>) getRawType());
|
||||
System.out.println(String.format("ProcessInfoListJsonHandler.getNullableResult, data=%s", data)); |
||||
List<UpdateInfo> r = StringUtils.isBlank(data) ? null : JSON.parseArray(data, UpdateInfo.class); |
||||
return r; |
||||
} |
||||
|
||||
@Override |
||||
public List<UpdateInfo> getNullableResult(ResultSet rs, int columnIndex) throws SQLException { |
||||
String data = rs.getString(columnIndex); |
||||
return StringUtils.isBlank(data) ? null : JSON.parseArray(data, UpdateInfo.class); |
||||
} |
||||
|
||||
@Override |
||||
public List<UpdateInfo> getNullableResult(CallableStatement cs, int columnIndex) |
||||
throws SQLException { |
||||
String data = cs.getString(columnIndex); |
||||
return StringUtils.isBlank(data) ? null : JSON.parseArray(data, UpdateInfo.class); |
||||
} |
||||
|
||||
@Override |
||||
public List<UpdateInfo> getResult(ResultSet rs, String columnName) throws SQLException { |
||||
List<UpdateInfo> r = super.getResult(rs, columnName); |
||||
return r; |
||||
} |
||||
|
||||
@Override |
||||
public List<UpdateInfo> getResult(ResultSet rs, int columnIndex) throws SQLException { |
||||
return super.getResult(rs, columnIndex); |
||||
} |
||||
|
||||
@Override |
||||
public List<UpdateInfo> getResult(CallableStatement cs, int columnIndex) throws SQLException { |
||||
return super.getResult(cs, columnIndex); |
||||
} |
||||
} |
@ -0,0 +1,70 @@ |
||||
package digital.laboratory.platform.sewage.config; |
||||
|
||||
import com.alibaba.fastjson.JSON; |
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.apache.ibatis.type.BaseTypeHandler; |
||||
import org.apache.ibatis.type.JdbcType; |
||||
import org.apache.ibatis.type.MappedJdbcTypes; |
||||
import org.apache.ibatis.type.MappedTypes; |
||||
|
||||
import java.sql.CallableStatement; |
||||
import java.sql.PreparedStatement; |
||||
import java.sql.ResultSet; |
||||
import java.sql.SQLException; |
||||
import java.util.List; |
||||
|
||||
@Slf4j |
||||
@MappedTypes({List.class}) // 指定与其关联的 Java 类型列表。 如果在 javaType 属性中也同时指定,则注解上的配置将被忽略。
|
||||
@MappedJdbcTypes(JdbcType.VARCHAR) |
||||
// public class StringListJsonHandler extends BaseMybatisList2JsonHandler<String> {
|
||||
// }
|
||||
public class StringListJsonHandler extends BaseTypeHandler<List<String>> { |
||||
|
||||
@Override |
||||
public void setNonNullParameter(PreparedStatement ps, int i, List<String> parameter, JdbcType jdbcType) throws SQLException { |
||||
ps.setString(i, JSON.toJSONString(parameter)); |
||||
} |
||||
|
||||
@Override |
||||
public List<String> getNullableResult(ResultSet rs, String columnName) |
||||
throws SQLException { |
||||
String data = rs.getString(columnName); |
||||
//List<String> r = StringUtils.isBlank(data) ? null : JSON.parseArray(data, (Class<String>) getRawType());
|
||||
List<String> r = StringUtils.isBlank(data) ? null : JSON.parseArray(data, String.class); |
||||
System.out.println(String.format("StringListJsonHandler.getNullableResult, columnName=%s data=%s r=%s", columnName, data, r)); |
||||
return r; |
||||
} |
||||
|
||||
@Override |
||||
public List<String> getNullableResult(ResultSet rs, int columnIndex) throws SQLException { |
||||
String data = rs.getString(columnIndex); |
||||
return StringUtils.isBlank(data) ? null : JSON.parseArray(data, String.class); |
||||
} |
||||
|
||||
@Override |
||||
public List<String> getNullableResult(CallableStatement cs, int columnIndex) |
||||
throws SQLException { |
||||
String data = cs.getString(columnIndex); |
||||
return StringUtils.isBlank(data) ? null : JSON.parseArray(data, String.class); |
||||
} |
||||
|
||||
@Override |
||||
public List<String> getResult(ResultSet rs, String columnName) throws SQLException { |
||||
List<String> r = super.getResult(rs, columnName); |
||||
System.out.println(String.format("StringListJsonHandler.getResult, columnName=%s r=%s", columnName, r)); |
||||
return r; |
||||
} |
||||
|
||||
@Override |
||||
public List<String> getResult(ResultSet rs, int columnIndex) throws SQLException { |
||||
return super.getResult(rs, columnIndex); |
||||
} |
||||
|
||||
@Override |
||||
public List<String> getResult(CallableStatement cs, int columnIndex) throws SQLException { |
||||
return super.getResult(cs, columnIndex); |
||||
} |
||||
} |
||||
|
||||
|
@ -0,0 +1,28 @@ |
||||
package digital.laboratory.platform.sewage.config; |
||||
|
||||
import org.springframework.context.annotation.Configuration; |
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity; |
||||
import org.springframework.security.config.annotation.web.builders.WebSecurity; |
||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; |
||||
import org.springframework.security.core.context.SecurityContextHolder; |
||||
|
||||
//@EnableOAuth2Sso
|
||||
@Configuration |
||||
|
||||
public class WebSecurityConfigurer extends WebSecurityConfigurerAdapter { |
||||
|
||||
@Override |
||||
public void configure(WebSecurity web) { |
||||
SecurityContextHolder.setStrategyName(SecurityContextHolder.MODE_INHERITABLETHREADLOCAL); |
||||
web.ignoring().antMatchers("/", "/static/**", "/static/dist/**", "/hello**", "/favicon.ico**", "/login", "/login-callback", "/v2/**", "/papp/v2/**", "/papp/entrustment/common/**"); |
||||
} |
||||
|
||||
@Override |
||||
public void configure(HttpSecurity http) throws Exception { |
||||
|
||||
http.csrf().disable() |
||||
.authorizeRequests() |
||||
.antMatchers("/", "/static/**", "/static/dist/**", "/hello**", "/favicon.ico**", "/login", "/login-callback", "/v2/**", "/papp/v2/**", "/papp/entrustment/common/**").permitAll() |
||||
.anyRequest().permitAll(); |
||||
} |
||||
} |
@ -0,0 +1,12 @@ |
||||
package digital.laboratory.platform.sewage.constant; |
||||
|
||||
/** |
||||
* 污水系统常量类 |
||||
*/ |
||||
public interface SewageConstants { |
||||
|
||||
String SX_SUB_CENTER = "国家毒品实验室陕西分中心"; |
||||
|
||||
String GY_DRUG_INSPECT_CENTER = "贵阳市公安局毒品检验中心"; |
||||
|
||||
} |
@ -0,0 +1,126 @@ |
||||
package digital.laboratory.platform.sewage.controller; |
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
import digital.laboratory.platform.common.core.util.R; |
||||
import digital.laboratory.platform.common.log.annotation.SysLog; |
||||
import digital.laboratory.platform.common.mybatis.security.service.DLPUser; |
||||
import digital.laboratory.platform.sewage.entity.SewageImportLog; |
||||
import digital.laboratory.platform.sewage.service.SewageImportLogService; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import lombok.RequiredArgsConstructor; |
||||
import org.springframework.security.oauth2.provider.OAuth2Authentication; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.security.Principal; |
||||
import java.util.List; |
||||
|
||||
|
||||
/** |
||||
* 污水导入日志 |
||||
* |
||||
* @author Zhang Xiaolong created at 2022-10-06 |
||||
* @describe 污水导入日志 前端控制器 |
||||
*/ |
||||
@RestController |
||||
@RequiredArgsConstructor |
||||
@RequestMapping("/sewage_import_log" ) |
||||
@Api(value = "sewage_import_log", tags = "114-污水导入日志管理") |
||||
public class SewageImportLogController { |
||||
|
||||
private final SewageImportLogService sewageImportLogService; |
||||
|
||||
/** |
||||
* 通过id查询污水导入日志 |
||||
* @param id id |
||||
* @return R |
||||
*/ |
||||
@ApiOperation(value = "通过id查询", notes = "通过id查询") |
||||
@GetMapping("/{id}" ) |
||||
// @PreAuthorize("@pms.hasPermission('entrustment_sewage_import_log_get')" )
|
||||
public R getById(@PathVariable("id" ) String id) { |
||||
return R.ok(sewageImportLogService.getById(id)); |
||||
} |
||||
|
||||
/** |
||||
* 分页查询 |
||||
* @param page 分页对象 |
||||
* @param sewageImportLog 污水导入日志 |
||||
* @return |
||||
*/ |
||||
@ApiOperation(value = "分页查询", notes = "分页查询") |
||||
@GetMapping("/page" ) |
||||
// @PreAuthorize("@pms.hasPermission('entrustment_sewage_import_log_get')" )
|
||||
public R getSewageImportLogPage(Page page, SewageImportLog sewageImportLog, HttpServletRequest theHttpServletRequest) { |
||||
Principal principal = theHttpServletRequest.getUserPrincipal(); |
||||
DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal(); |
||||
|
||||
IPage<SewageImportLog> logList = sewageImportLogService.page(page, Wrappers.<SewageImportLog>query() |
||||
// .eq("create_by", dlpUser.getId())
|
||||
.orderByDesc("create_time") |
||||
); |
||||
return R.ok(logList); |
||||
} |
||||
|
||||
/** |
||||
* 列表查询 |
||||
* @param sewageImportLog 污水导入日志 |
||||
* @return |
||||
*/ |
||||
@ApiOperation(value = "列表查询", notes = "列表查询") |
||||
@GetMapping("/list" ) |
||||
// @PreAuthorize("@pms.hasPermission('entrustment_sewage_import_log_get')" )
|
||||
public R getSewageImportLogList(SewageImportLog sewageImportLog, HttpServletRequest theHttpServletRequest) { |
||||
Principal principal = theHttpServletRequest.getUserPrincipal(); |
||||
DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal(); |
||||
|
||||
List<SewageImportLog> logList = sewageImportLogService.list(Wrappers.<SewageImportLog>query() |
||||
// .eq("create_by", dlpUser.getId())
|
||||
.orderByDesc("create_time") |
||||
); |
||||
return R.ok(logList); |
||||
} |
||||
|
||||
/** |
||||
* 新增污水导入日志 |
||||
* @param sewageImportLog 污水导入日志 |
||||
* @return R |
||||
*/ |
||||
@ApiOperation(value = "新增污水导入日志 <<--- 正式版将取消", notes = "新增污水导入日志 <<--- 正式版将取消") |
||||
@SysLog("新增污水导入日志" ) |
||||
@PostMapping |
||||
// @PreAuthorize("@pms.hasPermission('entrustment_sewage_import_log_add')" )
|
||||
public R postAddObject(@RequestBody SewageImportLog sewageImportLog) { |
||||
return R.ok(sewageImportLogService.save(sewageImportLog)); |
||||
} |
||||
|
||||
/** |
||||
* 修改污水导入日志 |
||||
* @param sewageImportLog 污水导入日志 |
||||
* @return R |
||||
*/ |
||||
@ApiOperation(value = "修改污水导入日志 <<--- 正式版将取消", notes = "修改污水导入日志 <<--- 正式版将取消") |
||||
@SysLog("修改污水导入日志" ) |
||||
@PutMapping |
||||
// @PreAuthorize("@pms.hasPermission('entrustment_sewage_import_log_edit')" )
|
||||
public R putUpdateById(@RequestBody SewageImportLog sewageImportLog) { |
||||
return R.ok(sewageImportLogService.updateById(sewageImportLog)); |
||||
} |
||||
|
||||
/** |
||||
* 通过id删除污水导入日志 |
||||
* @param id id |
||||
* @return R |
||||
*/ |
||||
@ApiOperation(value = "通过id删除污水导入日志 <<--- 正式版将取消", notes = "通过id删除污水导入日志 <<--- 正式版将取消") |
||||
@SysLog("通过id删除污水导入日志" ) |
||||
@DeleteMapping("/{id}" ) |
||||
// @PreAuthorize("@pms.hasPermission('entrustment_sewage_import_log_del')" )
|
||||
public R deleteById(@PathVariable String id) { |
||||
return R.ok(sewageImportLogService.removeById(id)); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,669 @@ |
||||
package digital.laboratory.platform.sewage.controller; |
||||
|
||||
import cn.hutool.core.lang.Assert; |
||||
import cn.hutool.core.util.StrUtil; |
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker; |
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
import digital.laboratory.platform.common.core.constant.CommonConstants; |
||||
import digital.laboratory.platform.common.core.util.R; |
||||
import digital.laboratory.platform.common.log.annotation.SysLog; |
||||
import digital.laboratory.platform.common.mybatis.security.service.DLPUser; |
||||
import digital.laboratory.platform.sewage.dto.StatisticsDiffStatusJobDTO; |
||||
import digital.laboratory.platform.sewage.entity.SewageJob; |
||||
import digital.laboratory.platform.sewage.entity.SewageJobIdentificationMaterial; |
||||
import digital.laboratory.platform.sewage.entity.SewageTreatmentPlant; |
||||
import digital.laboratory.platform.sewage.entity.*; |
||||
import digital.laboratory.platform.sewage.service.SewageJobIdentificationMaterialService; |
||||
import digital.laboratory.platform.sewage.service.SewageJobItemService; |
||||
import digital.laboratory.platform.sewage.service.SewageJobService; |
||||
import digital.laboratory.platform.sewage.service.SewageTreatmentPlantService; |
||||
import digital.laboratory.platform.sewage.vo.SewageJobIdentificationMaterialVO; |
||||
import digital.laboratory.platform.sewage.vo.SewageJobVO; |
||||
import digital.laboratory.platform.sys.entity.SysOrg; |
||||
import digital.laboratory.platform.sys.vo.entrustment.MarkersVO; |
||||
import digital.laboratory.platform.sewage.vo.SewageJobItemVO; |
||||
import digital.laboratory.platform.sys.feign.RemoteOrgService; |
||||
import digital.laboratory.platform.sys.feign.RemoteUserService; |
||||
import org.apache.commons.lang.StringUtils; |
||||
import org.springframework.security.access.prepost.PreAuthorize; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import lombok.RequiredArgsConstructor; |
||||
import org.springframework.security.oauth2.provider.OAuth2Authentication; |
||||
import org.springframework.transaction.annotation.Transactional; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.security.Principal; |
||||
import java.time.LocalDateTime; |
||||
import java.util.List; |
||||
|
||||
|
||||
/** |
||||
* 污水检测任务 |
||||
* |
||||
* @author Zhang Xiaolong created at 2022-07-26 |
||||
* @describe 污水检测任务 前端控制器 |
||||
*/ |
||||
@RestController |
||||
@RequiredArgsConstructor |
||||
@RequestMapping("/sewage_job") |
||||
@Api(value = "sewage_job", tags = "111-污水检测任务管理") |
||||
public class SewageJobController { |
||||
|
||||
private final SewageJobService sewageJobService; |
||||
private final SewageJobItemService sewageJobItemService; |
||||
private final SewageJobIdentificationMaterialService sewageJobIdentificationMaterialService; |
||||
private final SewageTreatmentPlantService sewageTreatmentPlantService; |
||||
|
||||
private final RemoteUserService remoteUserService; |
||||
private final RemoteOrgService remoteOrgService; |
||||
|
||||
/** |
||||
* 通过id查询污水检测任务 |
||||
* |
||||
* @param id id |
||||
* @return R |
||||
*/ |
||||
@ApiOperation(value = "通过id查询", notes = "通过id查询") |
||||
@GetMapping("/{id}") |
||||
@PreAuthorize("@pms.hasPermission('SewageJobGet')") |
||||
public R getById(@PathVariable("id") String id, HttpServletRequest theHttpServletRequest) { |
||||
Principal principal = theHttpServletRequest.getUserPrincipal(); |
||||
DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal(); |
||||
|
||||
List<SewageJobVO> sjList = sewageJobService.getSewageJobVOList(Wrappers.<SewageJob>query() |
||||
.eq("id", id) |
||||
); |
||||
if ((sjList == null) || (sjList.size() == 0)) { |
||||
throw new RuntimeException(String.format("没有找到id为 %s 的污水检测任务", id)); |
||||
} |
||||
|
||||
SewageJobVO sewageJob = sjList.get(0); |
||||
if (sewageJob == null) { |
||||
throw new RuntimeException(String.format("没有找到id为 %s 的污水检测任务", id)); |
||||
} |
||||
|
||||
return R.ok(sewageJob); |
||||
} |
||||
|
||||
/** |
||||
* 通过id查询污水检测任务 |
||||
* |
||||
* @param id id |
||||
* @return R |
||||
*/ |
||||
@ApiOperation(value = "通过id查询污水任务", notes = "通过id查询污水任务") |
||||
@GetMapping("/getSewageJobById") |
||||
public R<SewageJob> getSewageJobById(@RequestParam("id") String id) { |
||||
return R.ok(sewageJobService.getById(id)); |
||||
} |
||||
|
||||
/** |
||||
* 分页查询 |
||||
* |
||||
* @param page 分页对象 |
||||
* @param sewageJob 污水检测任务 |
||||
* @return |
||||
*/ |
||||
@ApiOperation(value = "分页查询任务", notes = "分页查询任务\n" + |
||||
"参数:\n" + |
||||
"page - 分页信息: current, size。例如: current=1&size=10\n" + |
||||
"keyword - 查询关键字, 仅对分中心员工有效。 keyword 查询逻辑如下:\n" + |
||||
" 如果 keyword 与某个检材编号、样本1编号、样本2编号相符,则返回该检材对象\n" + |
||||
"statuses - 状态列表, 例如: statuses=1,2,3\n" + |
||||
"status - 单个状态, 例如: status=1\n" + |
||||
"name - 任务名称") |
||||
@GetMapping("/page") |
||||
@PreAuthorize("@pms.hasPermission('SewageJobList')") |
||||
public R getSewageJobPage(Page page, String keyword, SewageJob sewageJob, @RequestParam(value = "statuses", required = false) List<Integer> statuses, HttpServletRequest theHttpServletRequest) { |
||||
Principal principal = theHttpServletRequest.getUserPrincipal(); |
||||
DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal(); |
||||
|
||||
final SysOrg userOrg; // 定义成 final才可以被后面的 Lambda 表达式使用
|
||||
R r = remoteOrgService.getById(dlpUser.getOrgId()); |
||||
if (r.getCode() == CommonConstants.SUCCESS) { |
||||
userOrg = (SysOrg) r.getData(); |
||||
} else { |
||||
return R.failed(String.format("没有找到 orgId 为 %s 的机构, 请确认用户所属机构的正确性!", dlpUser.getOrgId())); |
||||
} |
||||
if (StrUtil.isNotBlank(keyword)) { |
||||
keyword = keyword.trim(); |
||||
} |
||||
final String theKeyword = keyword; |
||||
|
||||
|
||||
//IPage<SewageJobVO> thePage = null;
|
||||
if (dlpUser.isStaff()) { |
||||
// 是鉴定中心员工
|
||||
|
||||
if (StrUtil.isNotBlank(theKeyword)) { |
||||
// 有提供 keyword, 模糊查询
|
||||
|
||||
// 先查是不是检材编号
|
||||
List<SewageJobIdentificationMaterialVO> theList = sewageJobIdentificationMaterialService.getSewageJobIdentificationMaterialVOList(Wrappers.<SewageJobIdentificationMaterial>query() |
||||
.eq("sjim.im_no", theKeyword) |
||||
.or() |
||||
.eq("sjim.sample1_no", theKeyword) |
||||
.or() |
||||
.eq("sjim.sample2_no", theKeyword) |
||||
); |
||||
if (theList.size() == 1) { |
||||
// 查到数据了, 直接返回; =0或>1都不对
|
||||
return R.ok(theList.get(0)); |
||||
} |
||||
} |
||||
|
||||
IPage<SewageJobVO> thePage = sewageJobService.getSewageJobVOPage(page, Wrappers.<SewageJob>query() |
||||
.and(StrUtil.isNotBlank(theKeyword), qw -> qw |
||||
.like("name", theKeyword) |
||||
.or() |
||||
.like("job_no", theKeyword)) |
||||
.in(statuses != null && statuses.size() > 0, "status", statuses) |
||||
.eq(sewageJob.getStatus() != null, "status", sewageJob.getStatus()) |
||||
.like(StrUtil.isNotBlank(sewageJob.getName()), "name", sewageJob.getName()) |
||||
//.orderByDesc("expiration_date")
|
||||
//.orderByDesc("job_year")
|
||||
//.orderByDesc("job_season")
|
||||
//.orderByAsc("name")
|
||||
.orderByDesc("create_time") |
||||
); |
||||
return R.ok(thePage); |
||||
} else { |
||||
String jobIdSql = "SELECT ji.job_id FROM b_sewage_job_item ji LEFT JOIN b_sewage_treatment_plant stp ON ji.plant_id=stp.id "; |
||||
if (StrUtil.endWith(userOrg.getAreaCode(), "0000")) { |
||||
// 省级
|
||||
jobIdSql += "WHERE stp.province_code='" + userOrg.getAreaCode() + "'"; |
||||
} else if (StrUtil.endWith(userOrg.getAreaCode(), "00")) { |
||||
// 市级
|
||||
jobIdSql += "WHERE stp.city_code='" + userOrg.getAreaCode() + "'"; |
||||
} else { |
||||
// 区级
|
||||
jobIdSql += "WHERE stp.district_code='" + userOrg.getAreaCode() + "'"; |
||||
} |
||||
|
||||
IPage<SewageJobVO> thePage = sewageJobService.getSewageJobVOPage(page, Wrappers.<SewageJob>query() |
||||
.in(statuses != null && statuses.size() > 0, "status", statuses) |
||||
.eq(sewageJob.getStatus() != null, "status", sewageJob.getStatus()) |
||||
.like(StrUtil.isNotBlank(sewageJob.getName()), "name", sewageJob.getName()) |
||||
.like(StrUtil.isNotBlank(theKeyword), "name", theKeyword) |
||||
.inSql("id", jobIdSql) // 只查包含本用户所在区域的污水厂的任务
|
||||
//.orderByDesc("expiration_date")
|
||||
//.orderByDesc("job_year")
|
||||
//.orderByDesc("job_season")
|
||||
//.orderByAsc("name")
|
||||
.orderByDesc("create_time") |
||||
); |
||||
return R.ok(thePage); |
||||
} |
||||
|
||||
|
||||
} |
||||
|
||||
/** |
||||
* 列表查询 |
||||
* 鉴定中心员工全部可看 |
||||
* 其他用户只可看到包含有其下污水处理厂的任务 |
||||
* |
||||
* @param sewageJob 污水检测任务 |
||||
* @return |
||||
*/ |
||||
@ApiOperation(value = "列表查询", notes = "列表查询") |
||||
@GetMapping("/list") |
||||
@PreAuthorize("@pms.hasPermission('SewageJobList')") |
||||
public R getSewageJobList(SewageJob sewageJob, @RequestParam(value = "statuses", required = false) List<Integer> statuses, HttpServletRequest theHttpServletRequest) { |
||||
Principal principal = theHttpServletRequest.getUserPrincipal(); |
||||
DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal(); |
||||
|
||||
final SysOrg userOrg; // 定义成 final才可以被后面的 Lambda 表达式使用
|
||||
R r = remoteOrgService.getById(dlpUser.getOrgId()); |
||||
if (r.getCode() == CommonConstants.SUCCESS) { |
||||
userOrg = (SysOrg) r.getData(); |
||||
} else { |
||||
return R.failed(String.format("没有找到 orgId 为 %s 的机构, 请确认用户所属机构的正确性!", dlpUser.getOrgId())); |
||||
} |
||||
|
||||
List<SewageJobVO> list = null; |
||||
if (dlpUser.isStaff()) { |
||||
// 是鉴定中心员工
|
||||
list = sewageJobService.getSewageJobVOList(Wrappers.<SewageJob>query() |
||||
// .eq("launche_org_id", dlpUser.getOrgId()) // 只查询当前用户的机构下的任务
|
||||
.in(statuses != null && statuses.size() > 0, "status", statuses) |
||||
.eq(sewageJob.getStatus() != null, "status", sewageJob.getStatus()) |
||||
.like(StrUtil.isNotBlank(sewageJob.getName()), "name", sewageJob.getName()) |
||||
.orderByDesc("expiration_date") |
||||
.orderByDesc("job_year") |
||||
.orderByDesc("job_season") |
||||
.orderByAsc("name") |
||||
); |
||||
} else { |
||||
String jobIdSql = "SELECT ji.job_id FROM b_sewage_job_item ji LEFT JOIN b_sewage_treatment_plant stp ON ji.plant_id=stp.id "; |
||||
if (StrUtil.endWith(userOrg.getAreaCode(), "0000")) { |
||||
// 省级
|
||||
jobIdSql += "WHERE stp.province_code='" + userOrg.getAreaCode() + "'"; |
||||
} else if (StrUtil.endWith(userOrg.getAreaCode(), "00")) { |
||||
// 市级
|
||||
jobIdSql += "WHERE stp.city_code='" + userOrg.getAreaCode() + "'"; |
||||
} else { |
||||
// 区级
|
||||
jobIdSql += "WHERE stp.district_code='" + userOrg.getAreaCode() + "'"; |
||||
} |
||||
|
||||
list = sewageJobService.getSewageJobVOList(Wrappers.<SewageJob>query() |
||||
.eq("status", 1) // 非鉴定中心用户只能看开到发布后的任务
|
||||
.like(StrUtil.isNotBlank(sewageJob.getName()), "name", sewageJob.getName()) |
||||
.inSql("id", jobIdSql) // 只查包含本用户所在区域的污水厂的任务
|
||||
.orderByDesc("expiration_date") |
||||
.orderByDesc("job_year") |
||||
.orderByDesc("job_season") |
||||
.orderByAsc("name") |
||||
); |
||||
|
||||
} |
||||
return R.ok(list); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 新增污水检测任务 |
||||
* |
||||
* @param sewageJob 污水检测任务 |
||||
* @return R |
||||
*/ |
||||
@ApiOperation(value = "新增污水检测任务", notes = "新增污水检测任务") |
||||
@SysLog("新增污水检测任务") |
||||
@PostMapping |
||||
@PreAuthorize("@pms.hasPermission('SewageJobCreate')") |
||||
public R postAddObject(@RequestBody SewageJob sewageJob, HttpServletRequest theHttpServletRequest) { |
||||
Principal principal = theHttpServletRequest.getUserPrincipal(); |
||||
DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal(); |
||||
|
||||
if (StrUtil.isBlank(sewageJob.getName())) { |
||||
return R.failed(sewageJob, "新的污水检测任务创建失败, 任务名称不能为空"); |
||||
} |
||||
if (sewageJob.getJobYear() == null) { |
||||
return R.failed(sewageJob, "新的污水检测任务创建失败, 任务年份不能为空"); |
||||
} |
||||
if (sewageJob.getJobSeason() == null) { |
||||
return R.failed(sewageJob, "新的污水检测任务创建失败, 任务季度不能为空"); |
||||
} |
||||
// if ((sewageJob.getJobSeason()<1) || (sewageJob.getJobSeason()>4)) {
|
||||
// return R.failed(sewageJob, "新的污水检测任务创建失败, 任务季度的有效值为1~4");
|
||||
// }
|
||||
|
||||
sewageJob.setId(IdWorker.get32UUID().toUpperCase()); |
||||
sewageJob.setJobNo(sewageJobService.getNewJobNo(sewageJob.getJobYear(), sewageJob.getJobSeason())); |
||||
sewageJob.setLauncheOrgId(dlpUser.getOrgId()); |
||||
sewageJob.setStatus(0); // 初始的状态是刚创建
|
||||
long count = sewageJobService.count(Wrappers.<SewageJob>lambdaQuery().eq(SewageJob::getJobYear, sewageJob.getJobYear()).eq(SewageJob::getJobSeason, sewageJob.getJobSeason())); |
||||
if (count>0){ |
||||
return R.failed(sewageJob, "当前月份任务已创建,创建失败!"); |
||||
} |
||||
if (sewageJobService.save(sewageJob)) { |
||||
return R.ok(sewageJob, "新的污水检测任务创建成功"); |
||||
} else { |
||||
return R.failed(sewageJob, "新的污水检测任务创建失败"); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 修改污水检测任务 |
||||
* |
||||
* @param sewageJob 污水检测任务 |
||||
* @return R |
||||
*/ |
||||
@ApiOperation(value = "修改污水检测任务 <--- 这个接口会被禁止,", notes = "修改污水检测任务 <--- 这个接口会被禁止,") |
||||
@SysLog("修改污水检测任务") |
||||
@PutMapping |
||||
// @PreAuthorize("@pms.hasPermission('SewageJobEdit')" )
|
||||
public R putUpdateById(@RequestBody SewageJob sewageJob, HttpServletRequest theHttpServletRequest) { |
||||
|
||||
return R.ok(sewageJobService.updateById(sewageJob)); |
||||
} |
||||
|
||||
/** |
||||
* 发布者修改污水检测任务 |
||||
* |
||||
* @param sewageJob 污水检测任务 |
||||
* @return R |
||||
*/ |
||||
@ApiOperation(value = "发布者修改污水检测任务", notes = "发布者修改污水检测任务<br>" + |
||||
"保存提交的以下属性:\n" + |
||||
"job_no \n" + |
||||
"name 任务名称\n" + |
||||
"job_year 任务所属年份\n" + |
||||
"job_season 任务所属季度\n" + |
||||
"description 任务描述\n" + |
||||
"launche_org_id 发布单位id(强制设置为当前用户所属机构的id)\n" + |
||||
"source 任务来源\n" + |
||||
"expiration_date 过期时间\n" + |
||||
"start_date 开始时间\n" + |
||||
"comments 备注说明\n" + |
||||
"launche_user_id 发布用户id (强制设置为当前用户id)\n" |
||||
) |
||||
@SysLog("发布者修改污水检测任务") |
||||
@PutMapping("/launcher_save") |
||||
@PreAuthorize("@pms.hasPermission('SewageJobEdit')") |
||||
public R launcherSave(@RequestBody SewageJob sewageJob, HttpServletRequest theHttpServletRequest) { |
||||
Principal principal = theHttpServletRequest.getUserPrincipal(); |
||||
DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal(); |
||||
|
||||
SewageJob oldSewageJob = sewageJobService.getById(sewageJob.getId()); |
||||
if (oldSewageJob == null) { |
||||
throw new RuntimeException(String.format("没有找到id为 %s 的污水检测任务", sewageJob.getId())); |
||||
} |
||||
|
||||
if (!StrUtil.equalsIgnoreCase(dlpUser.getOrgId(), oldSewageJob.getLauncheOrgId())) { |
||||
throw new RuntimeException(String.format("你没有权限修改id为 %s 的污水检测任务的数据", sewageJob.getId())); |
||||
} |
||||
|
||||
if (StrUtil.isBlank(sewageJob.getJobNo())) { |
||||
sewageJob.setJobNo(sewageJobService.getNewJobNo(sewageJob.getJobYear(), sewageJob.getJobSeason())); |
||||
} |
||||
|
||||
// if (oldSewageJob.getStatus() != SewageJobStatusConstants.JOB_STATUS_CREATED.getStatus() // 刚创建未发布
|
||||
// && oldSewageJob.getStatus() != SewageJobStatusConstants.JOB_STATUS_REVOCATION.getStatus() // 被撤回
|
||||
// && oldSewageJob.getStatus() != SewageJobStatusConstants.JOB_STATUS_REFUSED.getStatus() // 被拒绝
|
||||
// )
|
||||
// {
|
||||
// throw new RuntimeException(String.format("id为 %s 的污水检测任务已经不能修改", sewageJob.getId()));
|
||||
// }
|
||||
|
||||
UpdateWrapper<SewageJob> updateWrapper = new UpdateWrapper<SewageJob>(); |
||||
updateWrapper.eq("id", sewageJob.getId()); // 查询条件是 id 相等
|
||||
|
||||
updateWrapper.set("job_no", sewageJob.getJobNo()); |
||||
updateWrapper.set("name", sewageJob.getName()); |
||||
updateWrapper.set("job_year", sewageJob.getJobYear()); |
||||
updateWrapper.set("job_season", sewageJob.getJobSeason()); |
||||
updateWrapper.set("description", sewageJob.getDescription()); |
||||
updateWrapper.set("launche_org_id", dlpUser.getOrgId()); |
||||
updateWrapper.set("source", sewageJob.getSource()); |
||||
updateWrapper.set("expiration_date", sewageJob.getExpirationDate()); |
||||
updateWrapper.set("start_date", sewageJob.getStartDate()); |
||||
updateWrapper.set("comments", sewageJob.getComments()); |
||||
updateWrapper.set("launche_user_id", dlpUser.getId()); |
||||
|
||||
if (!sewageJobService.update(null, updateWrapper)) { |
||||
throw new RuntimeException("保存污水检测任务信息失败"); |
||||
} |
||||
|
||||
return R.ok(sewageJobService.getById(sewageJob.getId()), "保存污水检测任务信息成功"); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 发布者发布污水检测任务 |
||||
* |
||||
* @param sewageJob 污水检测任务 |
||||
* @return R |
||||
*/ |
||||
@ApiOperation(value = "发布者发布污水检测任务", notes = "发布者发布污水检测任务<br>" + |
||||
"保存提交的以下属性:\n" + |
||||
"job_no \n" + |
||||
"name 任务名称\n" + |
||||
"job_year 任务所属年份\n" + |
||||
"job_season 任务所属季度\n" + |
||||
"description 任务描述\n" + |
||||
"launche_org_id 发布单位id(强制设置为当前用户所属机构的id)\n" + |
||||
"source 任务来源\n" + |
||||
"expiration_date 过期时间\n" + |
||||
"start_date 开始时间\n" + |
||||
"comments 备注说明\n" + |
||||
"launche_user_id 发布用户id (强制设置为当前用户id)\n" |
||||
) |
||||
@SysLog("发布者发布污水检测任务") |
||||
@PutMapping("/launche") |
||||
@PreAuthorize("@pms.hasPermission('SewageJobEdit')") |
||||
public R launche(@RequestBody SewageJob sewageJob, HttpServletRequest theHttpServletRequest) { |
||||
Principal principal = theHttpServletRequest.getUserPrincipal(); |
||||
DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal(); |
||||
SewageJob oldSewageJob = sewageJobService.getById(sewageJob.getId()); |
||||
if (oldSewageJob == null) { |
||||
throw new RuntimeException(String.format("没有找到id为 %s 的污水检测任务", sewageJob.getId())); |
||||
} |
||||
if (!StrUtil.equalsIgnoreCase(dlpUser.getOrgId(), oldSewageJob.getLauncheOrgId())) { |
||||
throw new RuntimeException(String.format("你没有权限修改id为 %s 的污水检测任务的数据", sewageJob.getId())); |
||||
} |
||||
UpdateWrapper<SewageJob> updateWrapper = new UpdateWrapper<SewageJob>(); |
||||
updateWrapper.eq("id", sewageJob.getId()); // 查询条件是 id 相等
|
||||
//updateWrapper.set(sewageJob.getJobNo() != null, "name", sewageJob.getName());
|
||||
//updateWrapper.set(sewageJob.getJobYear() != null, "job_year", sewageJob.getJobYear());
|
||||
//updateWrapper.set(sewageJob.getJobSeason() != null, "job_season", sewageJob.getJobSeason());
|
||||
//updateWrapper.set(sewageJob.getDescription() != null, "description", sewageJob.getDescription());
|
||||
updateWrapper.set("launche_org_id", dlpUser.getOrgId()); |
||||
//updateWrapper.set(sewageJob.getSource() != null, "source", sewageJob.getSource());
|
||||
//updateWrapper.set(sewageJob.getExpirationDate() != null, "expiration_date", sewageJob.getExpirationDate());
|
||||
//updateWrapper.set(sewageJob.getStartDate() != null, "start_date", sewageJob.getStartDate());
|
||||
//updateWrapper.set(sewageJob.getComments() != null, "comments", sewageJob.getComments());
|
||||
updateWrapper.set("launche_user_id", dlpUser.getId()); |
||||
|
||||
updateWrapper.set("status", 1); |
||||
updateWrapper.set("launche_date", LocalDateTime.now()); |
||||
|
||||
if (!sewageJobService.update(null, updateWrapper)) { |
||||
throw new RuntimeException("发布污水检测任务失败"); |
||||
} |
||||
//生成检材信息
|
||||
System.out.println("开始生成检材信息"); |
||||
sewageJobService.generateSewageMaterial(oldSewageJob); |
||||
return R.ok(sewageJobService.getById(sewageJob.getId()), "发布污水检测任务成功"); |
||||
} |
||||
|
||||
/** |
||||
* 发布者取消发布污水检测任务 |
||||
* |
||||
* @param sewageJob 污水检测任务 |
||||
* @return R |
||||
*/ |
||||
@ApiOperation(value = "发布者取消发布污水检测任务", notes = "发布者取消发布污水检测任务<br>" + |
||||
"保存提交的以下属性:\n" + |
||||
"job_no \n" + |
||||
"name 任务名称\n" + |
||||
"job_year 任务所属年份\n" + |
||||
"job_season 任务所属季度\n" + |
||||
"description 任务描述\n" + |
||||
"launche_org_id 发布单位id(强制设置为当前用户所属机构的id)\n" + |
||||
"source 任务来源\n" + |
||||
"expiration_date 过期时间\n" + |
||||
"start_date 开始时间\n" + |
||||
"comments 备注说明\n" + |
||||
"launche_user_id 发布用户id (强制设置为当前用户id)\n" + |
||||
"\n" + |
||||
"如果一个任务,已经录入了检材,则不能取消发布。" |
||||
) |
||||
@SysLog("发布者取消发布污水检测任务") |
||||
@PutMapping("/unlaunche") |
||||
@PreAuthorize("@pms.hasPermission('SewageJobEdit')") |
||||
public R unlaunche(@RequestBody SewageJob sewageJob, HttpServletRequest theHttpServletRequest) { |
||||
Principal principal = theHttpServletRequest.getUserPrincipal(); |
||||
DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal(); |
||||
|
||||
SewageJob oldSewageJob = sewageJobService.getById(sewageJob.getId()); |
||||
if (oldSewageJob == null) { |
||||
throw new RuntimeException(String.format("没有找到id为 %s 的污水检测任务", sewageJob.getId())); |
||||
} |
||||
|
||||
if (!StrUtil.equalsIgnoreCase(dlpUser.getOrgId(), oldSewageJob.getLauncheOrgId())) { |
||||
throw new RuntimeException(String.format("你没有权限修改id为 %s 的污水检测任务的数据", sewageJob.getId())); |
||||
} |
||||
|
||||
// 看一下 任务清单的情况
|
||||
String jobId = sewageJob.getId(); |
||||
List<SewageJobItemVO> jiList = sewageJobItemService.getSewageJobItemVOList(Wrappers.<SewageJobItem>query() |
||||
.eq(StrUtil.isNotBlank(jobId), "ji.job_id", jobId) |
||||
); |
||||
|
||||
List<SewageJobIdentificationMaterialVO> jimList = sewageJobIdentificationMaterialService.getSewageJobIdentificationMaterialVOList(Wrappers.<SewageJobIdentificationMaterial>query() |
||||
.eq(StrUtil.isNotBlank(jobId), "sjim.job_id", jobId) |
||||
); |
||||
if (jimList.size() > 0) { |
||||
throw new RuntimeException("这个任务存在已录入的检材信息, 不能撤回了"); |
||||
} |
||||
|
||||
UpdateWrapper<SewageJob> updateWrapper = new UpdateWrapper<SewageJob>(); |
||||
updateWrapper.eq("id", sewageJob.getId()); // 查询条件是 id 相等
|
||||
|
||||
updateWrapper.set(sewageJob.getJobNo() != null, "name", sewageJob.getName()); |
||||
updateWrapper.set(sewageJob.getJobYear() != null, "job_year", sewageJob.getJobYear()); |
||||
updateWrapper.set(sewageJob.getJobSeason() != null, "job_season", sewageJob.getJobSeason()); |
||||
updateWrapper.set(sewageJob.getDescription() != null, "description", sewageJob.getDescription()); |
||||
updateWrapper.set("launche_org_id", dlpUser.getOrgId()); |
||||
updateWrapper.set(sewageJob.getSource() != null, "source", sewageJob.getSource()); |
||||
updateWrapper.set(sewageJob.getExpirationDate() != null, "expiration_date", sewageJob.getExpirationDate()); |
||||
updateWrapper.set(sewageJob.getStartDate() != null, "start_date", sewageJob.getStartDate()); |
||||
updateWrapper.set(sewageJob.getComments() != null, "comments", sewageJob.getComments()); |
||||
updateWrapper.set("launche_user_id", dlpUser.getId()); |
||||
|
||||
updateWrapper.set("status", 0); |
||||
updateWrapper.set("launche_date", null); |
||||
|
||||
if (!sewageJobService.update(null, updateWrapper)) { |
||||
throw new RuntimeException("取消发布污水检测任务失败"); |
||||
} |
||||
|
||||
return R.ok(sewageJobService.getById(sewageJob.getId()), "取消发布污水检测任务成功"); |
||||
} |
||||
|
||||
//撤回发布的任务
|
||||
@ApiOperation(value = "撤回发布的任务", notes = "撤回发布的任务") |
||||
@PostMapping("/undoTask") |
||||
public R undoTask(String taskID) { |
||||
Assert.notBlank(taskID, "参数任务ID不能为空"); |
||||
return R.ok(sewageJobService.undoTask(taskID), ""); |
||||
} |
||||
|
||||
/** |
||||
* 通过id删除污水检测任务 |
||||
* |
||||
* @param id id |
||||
* @return R |
||||
*/ |
||||
@ApiOperation(value = "通过id删除污水检测任务", notes = "通过id删除污水检测任务") |
||||
@SysLog("通过id删除污水检测任务") |
||||
@DeleteMapping("/{id}") |
||||
@PreAuthorize("@pms.hasPermission('SewageJobDelete')") |
||||
@Transactional(rollbackFor = {RuntimeException.class, Exception.class}) |
||||
public R deleteById(@PathVariable String id, HttpServletRequest theHttpServletRequest) { |
||||
Principal principal = theHttpServletRequest.getUserPrincipal(); |
||||
DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal(); |
||||
|
||||
SewageJob oldSewageJob = sewageJobService.getById(id); |
||||
if (oldSewageJob == null) { |
||||
throw new RuntimeException(String.format("没有找到id为 %s 的污水检测任务", id)); |
||||
} |
||||
|
||||
if (!StrUtil.equalsIgnoreCase(dlpUser.getOrgId(), oldSewageJob.getLauncheOrgId())) { |
||||
throw new RuntimeException(String.format("你没有权限修改id为 %s 的污水检测任务的数据", id)); |
||||
} |
||||
|
||||
if (oldSewageJob.getStatus() > 0) { |
||||
throw new RuntimeException(String.format("id为 %s 的污水检测任务已经发布, 只能删除未发布的任务", id)); |
||||
} |
||||
|
||||
sewageJobItemService.remove(Wrappers.<SewageJobItem>query().eq("job_id", id)); |
||||
|
||||
return R.ok(sewageJobService.removeById(id)); |
||||
} |
||||
|
||||
/** |
||||
* 统计各污水厂的送检情况 |
||||
*/ |
||||
@ApiOperation(value = "统计各污水厂的送检情况", notes = "统计各污水厂的送检情况") |
||||
@GetMapping("/querySendData") |
||||
public R querySendData(String jobId, String areaCode, String materialStatus, String treeLayer, HttpServletRequest theHttpServletRequest) { |
||||
Assert.notNull(jobId, "任务ID不能为空"); |
||||
Principal principal = theHttpServletRequest.getUserPrincipal(); |
||||
DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal(); |
||||
R ret = remoteOrgService.getById(dlpUser.getOrgId()); |
||||
String currentUserAreaCode = ""; |
||||
if (ret.getCode() == CommonConstants.SUCCESS) { |
||||
currentUserAreaCode = ((SysOrg) ret.getData()).getAreaCode(); |
||||
} else { |
||||
return R.failed(String.format("没有找到 orgId 为 %s 的机构, 请确认用户所属机构的正确性!", dlpUser.getOrgId())); |
||||
} |
||||
int targetTreeLayer = StringUtils.isNotBlank(treeLayer) ? Integer.parseInt(treeLayer) : 5; |
||||
return R.ok(sewageJobService.querySewageJcSendData(jobId, currentUserAreaCode, materialStatus, targetTreeLayer), "获取数据信息成功"); |
||||
} |
||||
|
||||
/** |
||||
* 初始化污水系统 |
||||
*/ |
||||
@GetMapping("/initSewageJobData") |
||||
public R initSewageJobData() { |
||||
//1、清除污水任务之前,需要先清除污水任务明细,污水检材明细,污水厂数据,必须严格按照顺序,防止脏数据的产生
|
||||
//1、清除检材表 2、清除任务明细表,3、清除污水厂表,4、清除任务表
|
||||
List<SewageJob> sewageJobList = sewageJobService.list(); |
||||
for (SewageJob sewageJob : sewageJobList) { |
||||
//删除该任务对应的明细任务项
|
||||
sewageJobItemService.remove(Wrappers.<SewageJobItem>query().eq("job_id", sewageJob.getId())); |
||||
//获取该任务下的检材明细
|
||||
sewageJobIdentificationMaterialService.remove(Wrappers.<SewageJobIdentificationMaterial>query().eq("job_id", sewageJob.getId())); |
||||
sewageJobService.removeById(sewageJob); |
||||
} |
||||
//清除污水厂
|
||||
sewageTreatmentPlantService.remove(Wrappers.<SewageTreatmentPlant>query().ne("id", "999999")); |
||||
return R.ok(1, "操作成功"); |
||||
} |
||||
|
||||
@PostMapping("/lead/into/{year}/{month}") |
||||
@ApiOperation(value = "导入污水任务Excel",notes = "参数:sewageJobIdentificationMaterialList:传入的Excel行的对象数组,year:拼接在路径上的任务年份,month:拼接在对象上的任务月份") |
||||
public R LeadIntoJob(@RequestBody List<SewageJobIdentificationMaterial> sewageJobIdentificationMaterialList, @PathVariable(value = "year") int year, @PathVariable(value = "month") int month, HttpServletRequest theHttpServletRequest) { |
||||
Principal principal = theHttpServletRequest.getUserPrincipal(); |
||||
DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal(); |
||||
return sewageJobService.LeadIntoJob(sewageJobIdentificationMaterialList, year, month, dlpUser) ? R.ok("导入成功") : R.failed("导入失败"); |
||||
} |
||||
|
||||
@GetMapping("/getJobAndMaterial/page") |
||||
@ApiOperation(value = "分页查询污水任务以及污水检材") |
||||
public R getJobAndMaterialPage(Page page, Integer status, String keywords) { |
||||
return R.ok(sewageJobService.getJobAndMaterialPage(page, status, keywords)); |
||||
} |
||||
|
||||
@GetMapping("/statisticsDiffStatusJob") |
||||
@ApiOperation(value = "根据任务状态 统计不同状态下的任务数量") |
||||
public R<StatisticsDiffStatusJobDTO> statisticsDiffStatusJob() { |
||||
return sewageJobService.statisticsDiffStatusJob(); |
||||
} |
||||
|
||||
@GetMapping("/querySewageJobByStartDate") |
||||
@ApiOperation(value = "根据任务发布时间查询在这之前的任务,并根据发布时间降序,然后根据limit 取不同数量的值") |
||||
public R<List<SewageJobVO>> querySewageJobByStartDate(@RequestParam("startDate") String startDate, |
||||
@RequestParam("limit") int limit) { |
||||
return sewageJobService.querySewageJobByStartDate(startDate, limit); |
||||
} |
||||
|
||||
@GetMapping("/getIMQuantity") |
||||
@ApiOperation(value = "查询这个账户(机构)下面所送检且已受理的所有污水检材的数量") |
||||
public R<Integer> getIMQuantity(@RequestParam("orgId") String orgId) { |
||||
final SysOrg userOrg = getOrgInfo(orgId); |
||||
return R.ok(sewageJobService.getIMQuantity(userOrg.getAreaCode())); |
||||
} |
||||
|
||||
@GetMapping("/getSewageMarkers") |
||||
@ApiOperation(value = "查询各个状态下的检材数量") |
||||
public R<List<MarkersVO>> getSewageMarkers(@RequestParam("orgId") String orgId) { |
||||
final SysOrg userOrg = getOrgInfo(orgId); |
||||
return R.ok(sewageJobService.getSewageMarkers(userOrg.getAreaCode())); |
||||
} |
||||
|
||||
@GetMapping("/getImQuantityForAccept") |
||||
@ApiOperation(value = "受理系统统计已受理的污水检材数量") |
||||
public R<Integer> getImQuantityForAccept() { |
||||
return R.ok(sewageJobService.getImQuantityForAccept()); |
||||
} |
||||
|
||||
private SysOrg getOrgInfo(String orgId) { |
||||
SysOrg userOrg = null; |
||||
R<SysOrg> r = remoteOrgService.getById(orgId); |
||||
if (r.getCode() == CommonConstants.SUCCESS) { |
||||
userOrg = r.getData(); |
||||
} else { |
||||
throw new RuntimeException(String.format("没有找到 orgId 为 %s 的机构, 请确认用户所属机构的正确性!", orgId)); |
||||
} |
||||
return userOrg; |
||||
} |
||||
} |
@ -0,0 +1,821 @@ |
||||
package digital.laboratory.platform.sewage.controller; |
||||
|
||||
import cn.hutool.core.lang.Assert; |
||||
import cn.hutool.core.util.StrUtil; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
import digital.laboratory.platform.common.core.constant.CommonConstants; |
||||
import digital.laboratory.platform.common.core.util.R; |
||||
import digital.laboratory.platform.common.log.annotation.SysLog; |
||||
import digital.laboratory.platform.common.mybatis.security.service.DLPUser; |
||||
import digital.laboratory.platform.sewage.entity.SewageJobGAB; |
||||
import digital.laboratory.platform.othersys.dto.QueryCondition; |
||||
import digital.laboratory.platform.sewage.service.*; |
||||
import digital.laboratory.platform.sewage.vo.SewageJobGABVO; |
||||
import digital.laboratory.platform.sewage.entity.SewageJob; |
||||
import digital.laboratory.platform.sewage.entity.SewageJobIdentificationMaterial; |
||||
import digital.laboratory.platform.sys.entity.SysOrg; |
||||
import digital.laboratory.platform.sys.feign.RemoteOrgService; |
||||
import digital.laboratory.platform.sys.feign.RemoteUserService; |
||||
import digital.laboratory.platform.sewage.vo.SewageJobIdentificationMaterialVO; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import lombok.RequiredArgsConstructor; |
||||
import org.apache.commons.lang.StringUtils; |
||||
import org.springframework.security.access.prepost.PreAuthorize; |
||||
import org.springframework.security.oauth2.provider.OAuth2Authentication; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.security.Principal; |
||||
import java.util.List; |
||||
|
||||
|
||||
/** |
||||
* 污水检测任务 |
||||
* |
||||
* @author Zhang Xiaolong created at 2022-07-26 |
||||
* @describe 污水检测任务 前端控制器 |
||||
*/ |
||||
@RestController |
||||
@RequiredArgsConstructor |
||||
@RequestMapping("/sewage_job_gab") |
||||
@Api(value = "sewage_job_gab", tags = "111-污水检测任务管理(公安部下发)") |
||||
public class SewageJobGABController { |
||||
|
||||
private final SewageJobService sewageJobService; |
||||
private final SewageJobItemService sewageJobItemService; |
||||
private final SewageJobIdentificationMaterialService sewageJobIdentificationMaterialService; |
||||
private final SewageTreatmentPlantService sewageTreatmentPlantService; |
||||
|
||||
private final SewageJobGABService sewageJobGABService; |
||||
|
||||
private final RemoteUserService remoteUserService; |
||||
private final RemoteOrgService remoteOrgService; |
||||
|
||||
/** |
||||
* 通过id查询污水检测任务 |
||||
* |
||||
* @param id id |
||||
* |
||||
* @return R |
||||
*/ |
||||
@ApiOperation(value = "通过id查询", notes = "通过id查询") |
||||
@GetMapping("/{id}") |
||||
@PreAuthorize("@pms.hasPermission('SewageJobGet')") |
||||
public R getById(@PathVariable("id") String id, HttpServletRequest theHttpServletRequest) { |
||||
Principal principal = theHttpServletRequest.getUserPrincipal(); |
||||
DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal(); |
||||
|
||||
List<SewageJobGABVO> sewageJobGABVOS = sewageJobGABService.getSewageJobGABVOList(Wrappers.<SewageJobGAB>query() |
||||
.eq("id", id) |
||||
); |
||||
|
||||
if ((sewageJobGABVOS == null) || (sewageJobGABVOS.size() == 0)) { |
||||
throw new RuntimeException(String.format("没有找到id为 %s 的污水检测任务", id)); |
||||
} |
||||
|
||||
SewageJobGABVO sewageJob = sewageJobGABVOS.get(0); |
||||
if (sewageJob == null) { |
||||
throw new RuntimeException(String.format("没有找到id为 %s 的污水检测任务", id)); |
||||
} |
||||
|
||||
return R.ok(sewageJob); |
||||
} |
||||
|
||||
/** |
||||
* 分页查询 |
||||
* |
||||
* @param page 分页对象 |
||||
* @param sewageJob 污水检测任务 |
||||
* |
||||
* @return |
||||
*/ |
||||
@ApiOperation(value = "分页查询任务", notes = "分页查询任务\n" + |
||||
"参数:\n" + |
||||
"page - 分页信息: current, size。例如: current=1&size=10\n" + |
||||
"keyword - 查询关键字, 仅对分中心员工有效。 keyword 查询逻辑如下:\n" + |
||||
" 如果 keyword 与某个检材编号、样本1编号、样本2编号相符,则返回该检材对象\n" + |
||||
"statuses - 状态列表, 例如: statuses=1,2,3\n" + |
||||
"status - 单个状态, 例如: status=1\n" + |
||||
"name - 任务名称") |
||||
@GetMapping("/page") |
||||
@PreAuthorize("@pms.hasPermission('SewageJobList')") |
||||
public R getSewageJobPage(Page page, String keyword, SewageJob sewageJob, @RequestParam(value = "statuses", required = false)List<Integer> statuses, HttpServletRequest theHttpServletRequest) { |
||||
Principal principal = theHttpServletRequest.getUserPrincipal(); |
||||
DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal(); |
||||
|
||||
final SysOrg userOrg; // 定义成 final才可以被后面的 Lambda 表达式使用
|
||||
R r = remoteOrgService.getById(dlpUser.getOrgId()); |
||||
if (r.getCode() == CommonConstants.SUCCESS) { |
||||
userOrg = (SysOrg) r.getData(); |
||||
} |
||||
else { |
||||
return R.failed(String.format("没有找到 orgId 为 %s 的机构, 请确认用户所属机构的正确性!", dlpUser.getOrgId())); |
||||
} |
||||
if (StrUtil.isNotBlank(keyword)) { |
||||
keyword = keyword.trim(); |
||||
} |
||||
final String theKeyword = keyword; |
||||
|
||||
|
||||
//IPage<SewageJobVO> thePage = null;
|
||||
if (dlpUser.isStaff()) { |
||||
// 是鉴定中心员工
|
||||
|
||||
if (StrUtil.isNotBlank(theKeyword)) { |
||||
// 有提供 keyword, 模糊查询
|
||||
|
||||
// 先查是不是检材编号
|
||||
List<SewageJobIdentificationMaterialVO> theList = sewageJobIdentificationMaterialService.getSewageJobIdentificationMaterialVOList(Wrappers.<SewageJobIdentificationMaterial>query() |
||||
.eq("sjim.im_no", theKeyword) |
||||
.or() |
||||
.eq("sjim.sample1_no", theKeyword) |
||||
.or() |
||||
.eq("sjim.sample2_no", theKeyword) |
||||
); |
||||
if (theList.size()==1) { |
||||
// 查到数据了, 直接返回; =0或>1都不对
|
||||
return R.ok(theList.get(0)); |
||||
} |
||||
} |
||||
|
||||
IPage<SewageJobGABVO> thePage = sewageJobGABService.getSewageJobGABVOPage(page, Wrappers.<SewageJobGAB>query() |
||||
.in(statuses!=null && statuses.size()>0, "status", statuses) |
||||
.eq(sewageJob.getStatus()!=null, "status", sewageJob.getStatus()) |
||||
.like(StrUtil.isNotBlank(sewageJob.getName()), "name", sewageJob.getName()) |
||||
.like(StrUtil.isNotBlank(theKeyword), "name", theKeyword) |
||||
.orderByDesc("expiration_date") |
||||
.orderByDesc("job_year") |
||||
.orderByDesc("job_season") |
||||
.orderByAsc("name") |
||||
); |
||||
return R.ok(thePage); |
||||
} |
||||
else { |
||||
String jobIdSql = "SELECT ji.job_id FROM b_sewage_job_item ji LEFT JOIN b_sewage_treatment_plant stp ON ji.plant_id=stp.id "; |
||||
if (StrUtil.endWith(userOrg.getAreaCode(), "0000")) { |
||||
// 省级
|
||||
jobIdSql += "WHERE stp.province_code='" + userOrg.getAreaCode() + "'"; |
||||
} |
||||
else if (StrUtil.endWith(userOrg.getAreaCode(), "00")) { |
||||
// 市级
|
||||
jobIdSql += "WHERE stp.city_code='" + userOrg.getAreaCode() + "'"; |
||||
} |
||||
else { |
||||
// 区级
|
||||
jobIdSql += "WHERE stp.district_code='" + userOrg.getAreaCode() + "'"; |
||||
} |
||||
|
||||
IPage<SewageJobGABVO> thePage = sewageJobGABService.getSewageJobGABVOPage(page, Wrappers.<SewageJobGAB>query() |
||||
.in(statuses!=null && statuses.size()>0, "status", statuses) |
||||
.eq(sewageJob.getStatus()!=null, "status", sewageJob.getStatus()) |
||||
.like(StrUtil.isNotBlank(sewageJob.getName()), "name", sewageJob.getName()) |
||||
.like(StrUtil.isNotBlank(theKeyword), "name", theKeyword) |
||||
.inSql("id", jobIdSql) // 只查包含本用户所在区域的污水厂的任务
|
||||
//.orderByDesc("expiration_date")
|
||||
//.orderByDesc("job_year")
|
||||
//.orderByDesc("job_season")
|
||||
//.orderByAsc("name")
|
||||
.orderByDesc("create_time") |
||||
); |
||||
return R.ok(thePage); |
||||
} |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 列表查询 |
||||
* 鉴定中心员工全部可看 |
||||
* 其他用户只可看到包含有其下污水处理厂的任务 |
||||
* |
||||
* @param sewageJob 污水检测任务 |
||||
* |
||||
* @return |
||||
*/ |
||||
@ApiOperation(value = "列表查询", notes = "列表查询") |
||||
@GetMapping("/list") |
||||
@PreAuthorize("@pms.hasPermission('SewageJobList')") |
||||
public R getSewageJobList(SewageJob sewageJob, @RequestParam(value = "statuses", required = false)List<Integer> statuses, HttpServletRequest theHttpServletRequest) { |
||||
Principal principal = theHttpServletRequest.getUserPrincipal(); |
||||
DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal(); |
||||
|
||||
final SysOrg userOrg; // 定义成 final才可以被后面的 Lambda 表达式使用
|
||||
R r = remoteOrgService.getById(dlpUser.getOrgId()); |
||||
if (r.getCode() == CommonConstants.SUCCESS) { |
||||
userOrg = (SysOrg) r.getData(); |
||||
} |
||||
else { |
||||
return R.failed(String.format("没有找到 orgId 为 %s 的机构, 请确认用户所属机构的正确性!", dlpUser.getOrgId())); |
||||
} |
||||
|
||||
List<SewageJobGABVO> list = null; |
||||
if (dlpUser.isStaff()) { |
||||
// 是鉴定中心员工
|
||||
list = sewageJobGABService.getSewageJobGABVOList(Wrappers.<SewageJobGAB>query() |
||||
// .eq("launche_org_id", dlpUser.getOrgId()) // 只查询当前用户的机构下的任务
|
||||
.in(statuses!=null && statuses.size()>0, "status", statuses) |
||||
.eq(sewageJob.getStatus()!=null, "status", sewageJob.getStatus()) |
||||
.like(StrUtil.isNotBlank(sewageJob.getName()), "name", sewageJob.getName()) |
||||
.orderByDesc("expiration_date") |
||||
.orderByDesc("job_year") |
||||
.orderByDesc("job_season") |
||||
.orderByAsc("name") |
||||
); |
||||
} |
||||
else { |
||||
String jobIdSql = "SELECT ji.job_id FROM b_sewage_job_item ji LEFT JOIN b_sewage_treatment_plant stp ON ji.plant_id=stp.id "; |
||||
if (StrUtil.endWith(userOrg.getAreaCode(), "0000")) { |
||||
// 省级
|
||||
jobIdSql += "WHERE stp.province_code='" + userOrg.getAreaCode() + "'"; |
||||
} |
||||
else if (StrUtil.endWith(userOrg.getAreaCode(), "00")) { |
||||
// 市级
|
||||
jobIdSql += "WHERE stp.city_code='" + userOrg.getAreaCode() + "'"; |
||||
} |
||||
else { |
||||
// 区级
|
||||
jobIdSql += "WHERE stp.district_code='" + userOrg.getAreaCode() + "'"; |
||||
} |
||||
|
||||
list = sewageJobGABService.getSewageJobGABVOList(Wrappers.<SewageJobGAB>query() |
||||
.eq("status", 1) // 非鉴定中心用户只能看开到发布后的任务
|
||||
.like(StrUtil.isNotBlank(sewageJob.getName()), "name", sewageJob.getName()) |
||||
.inSql("id", jobIdSql) // 只查包含本用户所在区域的污水厂的任务
|
||||
.orderByDesc("expiration_date") |
||||
.orderByDesc("job_year") |
||||
.orderByDesc("job_season") |
||||
.orderByAsc("name") |
||||
); |
||||
|
||||
} |
||||
return R.ok(list); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 新增污水检测任务 |
||||
* |
||||
* @param sewageJob 污水检测任务 |
||||
* |
||||
* @return R |
||||
*/ |
||||
// @ApiOperation(value = "新增污水检测任务", notes = "新增污水检测任务")
|
||||
// @SysLog("新增污水检测任务")
|
||||
// @PostMapping
|
||||
// @PreAuthorize("@pms.hasPermission('SewageJobCreate')")
|
||||
// public R postAddObject(@RequestBody SewageJob sewageJob, HttpServletRequest theHttpServletRequest) {
|
||||
// Principal principal = theHttpServletRequest.getUserPrincipal();
|
||||
// DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal();
|
||||
//
|
||||
// if (StrUtil.isBlank(sewageJob.getName())) {
|
||||
// return R.failed(sewageJob, "新的污水检测任务创建失败, 任务名称不能为空");
|
||||
// }
|
||||
// if (sewageJob.getJobYear() == null) {
|
||||
// return R.failed(sewageJob, "新的污水检测任务创建失败, 任务年份不能为空");
|
||||
// }
|
||||
// if (sewageJob.getJobSeason() == null) {
|
||||
// return R.failed(sewageJob, "新的污水检测任务创建失败, 任务季度不能为空");
|
||||
// }
|
||||
//// if ((sewageJob.getJobSeason()<1) || (sewageJob.getJobSeason()>4)) {
|
||||
//// return R.failed(sewageJob, "新的污水检测任务创建失败, 任务季度的有效值为1~4");
|
||||
//// }
|
||||
//
|
||||
// sewageJob.setId(IdWorker.get32UUID().toUpperCase());
|
||||
// sewageJob.setJobNo(sewageJobService.getNewJobNo(sewageJob.getJobYear(), sewageJob.getJobSeason()));
|
||||
// sewageJob.setLauncheOrgId(dlpUser.getOrgId());
|
||||
// sewageJob.setStatus(0); // 初始的状态是刚创建
|
||||
//
|
||||
// if (sewageJobService.save(sewageJob)) {
|
||||
// return R.ok(sewageJob, "新的污水检测任务创建成功");
|
||||
// }
|
||||
// else {
|
||||
// return R.failed(sewageJob, "新的污水检测任务创建失败");
|
||||
// }
|
||||
// }
|
||||
|
||||
/** |
||||
* 修改污水检测任务 |
||||
* |
||||
* @param sewageJob 污水检测任务 |
||||
* |
||||
* @return R |
||||
*/ |
||||
@ApiOperation(value = "修改污水检测任务 <--- 这个接口会被禁止,", notes = "修改污水检测任务 <--- 这个接口会被禁止,") |
||||
@SysLog("修改污水检测任务") |
||||
@PutMapping |
||||
// @PreAuthorize("@pms.hasPermission('SewageJobEdit')" )
|
||||
public R putUpdateById(@RequestBody SewageJobGAB sewageJob, HttpServletRequest theHttpServletRequest) { |
||||
|
||||
return R.ok(sewageJobGABService.updateById(sewageJob)); |
||||
} |
||||
|
||||
/** |
||||
* 发布者修改污水检测任务 |
||||
* |
||||
* @param sewageJob 污水检测任务 |
||||
* |
||||
* @return R |
||||
*/ |
||||
// @ApiOperation(value = "发布者修改污水检测任务", notes = "发布者修改污水检测任务<br>" +
|
||||
// "保存提交的以下属性:\n" +
|
||||
// "job_no \n" +
|
||||
// "name 任务名称\n" +
|
||||
// "job_year 任务所属年份\n" +
|
||||
// "job_season 任务所属季度\n" +
|
||||
// "description 任务描述\n" +
|
||||
// "launche_org_id 发布单位id(强制设置为当前用户所属机构的id)\n" +
|
||||
// "source 任务来源\n" +
|
||||
// "expiration_date 过期时间\n" +
|
||||
// "start_date 开始时间\n" +
|
||||
// "comments 备注说明\n" +
|
||||
// "launche_user_id 发布用户id (强制设置为当前用户id)\n"
|
||||
// )
|
||||
// @SysLog("发布者修改污水检测任务")
|
||||
// @PutMapping("/launcher_save")
|
||||
// @PreAuthorize("@pms.hasPermission('SewageJobEdit')")
|
||||
// public R launcherSave(@RequestBody SewageJobGAB sewageJob, HttpServletRequest theHttpServletRequest) {
|
||||
// Principal principal = theHttpServletRequest.getUserPrincipal();
|
||||
// DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal();
|
||||
//
|
||||
// SewageJobGAB oldSewageJob = sewageJobGABService.getById(sewageJob.getId());
|
||||
// if (oldSewageJob == null) {
|
||||
// throw new RuntimeException(String.format("没有找到id为 %s 的污水检测任务", sewageJob.getId()));
|
||||
// }
|
||||
//
|
||||
// if (!StrUtil.equalsIgnoreCase(dlpUser.getOrgId(), oldSewageJob.getLauncheOrgId())) {
|
||||
// throw new RuntimeException(String.format("你没有权限修改id为 %s 的污水检测任务的数据", sewageJob.getId()));
|
||||
// }
|
||||
//
|
||||
// if (StrUtil.isBlank(sewageJob.getJobNo())) {
|
||||
// sewageJob.setJobNo(sewageJobService.getNewJobNo(sewageJob.getJobYear(), sewageJob.getJobSeason()));
|
||||
// }
|
||||
//
|
||||
//// if (oldSewageJob.getStatus() != SewageJobStatusConstants.JOB_STATUS_CREATED.getStatus() // 刚创建未发布
|
||||
//// && oldSewageJob.getStatus() != SewageJobStatusConstants.JOB_STATUS_REVOCATION.getStatus() // 被撤回
|
||||
//// && oldSewageJob.getStatus() != SewageJobStatusConstants.JOB_STATUS_REFUSED.getStatus() // 被拒绝
|
||||
//// )
|
||||
//// {
|
||||
//// throw new RuntimeException(String.format("id为 %s 的污水检测任务已经不能修改", sewageJob.getId()));
|
||||
//// }
|
||||
//
|
||||
// UpdateWrapper<SewageJobGAB> updateWrapper = new UpdateWrapper<SewageJobGAB>();
|
||||
//
|
||||
// updateWrapper.eq("id", sewageJob.getId()); // 查询条件是 id 相等
|
||||
//
|
||||
// updateWrapper.set("job_no", sewageJob.getJobNo());
|
||||
// updateWrapper.set("name", sewageJob.getName());
|
||||
// updateWrapper.set("job_year", sewageJob.getJobYear());
|
||||
// updateWrapper.set("job_season", sewageJob.getJobSeason());
|
||||
// updateWrapper.set("description", sewageJob.getDescription());
|
||||
// updateWrapper.set("launche_org_id", dlpUser.getOrgId());
|
||||
// updateWrapper.set("source", sewageJob.getSource());
|
||||
// updateWrapper.set("expiration_date", sewageJob.getExpirationDate());
|
||||
// updateWrapper.set("start_date", sewageJob.getStartDate());
|
||||
// updateWrapper.set("comments", sewageJob.getComments());
|
||||
// updateWrapper.set("launche_user_id", dlpUser.getId());
|
||||
//
|
||||
// if (!sewageJobGABService.update(null, updateWrapper)) {
|
||||
// throw new RuntimeException("保存污水检测任务信息失败");
|
||||
// }
|
||||
//
|
||||
// return R.ok(sewageJobGABService.getById(sewageJob.getId()), "保存污水检测任务信息成功");
|
||||
// }
|
||||
|
||||
|
||||
/** |
||||
* 发布者发布污水检测任务 |
||||
* |
||||
* @param sewageJob 污水检测任务 |
||||
* |
||||
* @return R |
||||
*/ |
||||
// @ApiOperation(value = "发布者发布污水检测任务", notes = "发布者发布污水检测任务<br>" +
|
||||
// "保存提交的以下属性:\n" +
|
||||
// "job_no \n" +
|
||||
// "name 任务名称\n" +
|
||||
// "job_year 任务所属年份\n" +
|
||||
// "job_season 任务所属季度\n" +
|
||||
// "description 任务描述\n" +
|
||||
// "launche_org_id 发布单位id(强制设置为当前用户所属机构的id)\n" +
|
||||
// "source 任务来源\n" +
|
||||
// "expiration_date 过期时间\n" +
|
||||
// "start_date 开始时间\n" +
|
||||
// "comments 备注说明\n" +
|
||||
// "launche_user_id 发布用户id (强制设置为当前用户id)\n"
|
||||
// )
|
||||
// @SysLog("发布者发布污水检测任务")
|
||||
// @PutMapping("/launche")
|
||||
// @PreAuthorize("@pms.hasPermission('SewageJobEdit')")
|
||||
// public R launche(@RequestBody SewageJobGAB sewageJob, HttpServletRequest theHttpServletRequest) {
|
||||
// Principal principal = theHttpServletRequest.getUserPrincipal();
|
||||
// DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal();
|
||||
// SewageJobGAB oldSewageJob = sewageJobGABService.getById(sewageJob.getId());
|
||||
// if (oldSewageJob == null) {
|
||||
// throw new RuntimeException(String.format("没有找到id为 %s 的污水检测任务", sewageJob.getId()));
|
||||
// }
|
||||
// if (!StrUtil.equalsIgnoreCase(dlpUser.getOrgId(), oldSewageJob.getLauncheOrgId())) {
|
||||
// throw new RuntimeException(String.format("你没有权限修改id为 %s 的污水检测任务的数据", sewageJob.getId()));
|
||||
// }
|
||||
// UpdateWrapper<SewageJobGAB> updateWrapper = new UpdateWrapper<SewageJobGAB>();
|
||||
// updateWrapper.eq("id", sewageJob.getId()); // 查询条件是 id 相等
|
||||
// //updateWrapper.set(sewageJob.getJobNo() != null, "name", sewageJob.getName());
|
||||
// //updateWrapper.set(sewageJob.getJobYear() != null, "job_year", sewageJob.getJobYear());
|
||||
// //updateWrapper.set(sewageJob.getJobSeason() != null, "job_season", sewageJob.getJobSeason());
|
||||
// //updateWrapper.set(sewageJob.getDescription() != null, "description", sewageJob.getDescription());
|
||||
// updateWrapper.set("launche_org_id", dlpUser.getOrgId());
|
||||
// //updateWrapper.set(sewageJob.getSource() != null, "source", sewageJob.getSource());
|
||||
// //updateWrapper.set(sewageJob.getExpirationDate() != null, "expiration_date", sewageJob.getExpirationDate());
|
||||
// //updateWrapper.set(sewageJob.getStartDate() != null, "start_date", sewageJob.getStartDate());
|
||||
// //updateWrapper.set(sewageJob.getComments() != null, "comments", sewageJob.getComments());
|
||||
// updateWrapper.set("launche_user_id", dlpUser.getId());
|
||||
//
|
||||
// updateWrapper.set("status", 1);
|
||||
// updateWrapper.set("launche_date", LocalDateTime.now());
|
||||
//
|
||||
// if (!sewageJobGABService.update(null, updateWrapper)) {
|
||||
// throw new RuntimeException("发布污水检测任务失败");
|
||||
// }
|
||||
// //生成检材信息
|
||||
// System.out.println("开始生成检材信息");
|
||||
// sewageJobGABService.generateSewageMaterial(oldSewageJob);
|
||||
// return R.ok(sewageJobGABService.getById(sewageJob.getId()), "发布污水检测任务成功");
|
||||
// }
|
||||
|
||||
/** |
||||
* 发布者取消发布污水检测任务 |
||||
* |
||||
* @param sewageJob 污水检测任务 |
||||
* |
||||
* @return R |
||||
*/ |
||||
// @ApiOperation(value = "发布者取消发布污水检测任务", notes = "发布者取消发布污水检测任务<br>" +
|
||||
// "保存提交的以下属性:\n" +
|
||||
// "job_no \n" +
|
||||
// "name 任务名称\n" +
|
||||
// "job_year 任务所属年份\n" +
|
||||
// "job_season 任务所属季度\n" +
|
||||
// "description 任务描述\n" +
|
||||
// "launche_org_id 发布单位id(强制设置为当前用户所属机构的id)\n" +
|
||||
// "source 任务来源\n" +
|
||||
// "expiration_date 过期时间\n" +
|
||||
// "start_date 开始时间\n" +
|
||||
// "comments 备注说明\n" +
|
||||
// "launche_user_id 发布用户id (强制设置为当前用户id)\n" +
|
||||
// "\n" +
|
||||
// "如果一个任务,已经录入了检材,则不能取消发布。"
|
||||
// )
|
||||
// @SysLog("发布者取消发布污水检测任务")
|
||||
// @PutMapping("/unlaunche")
|
||||
// @PreAuthorize("@pms.hasPermission('SewageJobEdit')")
|
||||
// public R unlaunche(@RequestBody SewageJob sewageJob, HttpServletRequest theHttpServletRequest) {
|
||||
// Principal principal = theHttpServletRequest.getUserPrincipal();
|
||||
// DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal();
|
||||
//
|
||||
// SewageJob oldSewageJob = sewageJobService.getById(sewageJob.getId());
|
||||
// if (oldSewageJob == null) {
|
||||
// throw new RuntimeException(String.format("没有找到id为 %s 的污水检测任务", sewageJob.getId()));
|
||||
// }
|
||||
//
|
||||
// if (!StrUtil.equalsIgnoreCase(dlpUser.getOrgId(), oldSewageJob.getLauncheOrgId())) {
|
||||
// throw new RuntimeException(String.format("你没有权限修改id为 %s 的污水检测任务的数据", sewageJob.getId()));
|
||||
// }
|
||||
//
|
||||
// // 看一下 任务清单的情况
|
||||
// String jobId = sewageJob.getId();
|
||||
// List<SewageJobItemVO> jiList = sewageJobItemService.getSewageJobItemVOList(Wrappers.<SewageJobItem>query()
|
||||
// .eq(StrUtil.isNotBlank(jobId), "ji.job_id", jobId)
|
||||
// );
|
||||
//
|
||||
// List<SewageJobIdentificationMaterialVO> jimList = sewageJobIdentificationMaterialService.getSewageJobIdentificationMaterialVOList(Wrappers.<SewageJobIdentificationMaterial>query()
|
||||
// .eq(StrUtil.isNotBlank(jobId), "sjim.job_id", jobId)
|
||||
// );
|
||||
// if (jimList.size()>0) {
|
||||
// throw new RuntimeException("这个任务存在已录入的检材信息, 不能撤回了");
|
||||
// }
|
||||
//
|
||||
// UpdateWrapper<SewageJob> updateWrapper = new UpdateWrapper<SewageJob>();
|
||||
// updateWrapper.eq("id", sewageJob.getId()); // 查询条件是 id 相等
|
||||
//
|
||||
// updateWrapper.set(sewageJob.getJobNo() != null, "name", sewageJob.getName());
|
||||
// updateWrapper.set(sewageJob.getJobYear() != null, "job_year", sewageJob.getJobYear());
|
||||
// updateWrapper.set(sewageJob.getJobSeason() != null, "job_season", sewageJob.getJobSeason());
|
||||
// updateWrapper.set(sewageJob.getDescription() != null, "description", sewageJob.getDescription());
|
||||
// updateWrapper.set("launche_org_id", dlpUser.getOrgId());
|
||||
// updateWrapper.set(sewageJob.getSource() != null, "source", sewageJob.getSource());
|
||||
// updateWrapper.set(sewageJob.getExpirationDate() != null, "expiration_date", sewageJob.getExpirationDate());
|
||||
// updateWrapper.set(sewageJob.getStartDate() != null, "start_date", sewageJob.getStartDate());
|
||||
// updateWrapper.set(sewageJob.getComments() != null, "comments", sewageJob.getComments());
|
||||
// updateWrapper.set("launche_user_id", dlpUser.getId());
|
||||
//
|
||||
// updateWrapper.set("status", 0);
|
||||
// updateWrapper.set("launche_date", null);
|
||||
//
|
||||
// if (!sewageJobService.update(null, updateWrapper)) {
|
||||
// throw new RuntimeException("取消发布污水检测任务失败");
|
||||
// }
|
||||
//
|
||||
// return R.ok(sewageJobService.getById(sewageJob.getId()), "取消发布污水检测任务成功");
|
||||
// }
|
||||
|
||||
|
||||
/** |
||||
* 通过id删除污水检测任务 |
||||
* |
||||
* @param id id |
||||
* |
||||
* @return R |
||||
*/ |
||||
// @ApiOperation(value = "通过id删除污水检测任务", notes = "通过id删除污水检测任务")
|
||||
// @SysLog("通过id删除污水检测任务")
|
||||
// @DeleteMapping("/{id}")
|
||||
// @PreAuthorize("@pms.hasPermission('SewageJobDelete')")
|
||||
// @Transactional(rollbackFor = {RuntimeException.class, Exception.class})
|
||||
// public R deleteById(@PathVariable String id, HttpServletRequest theHttpServletRequest) {
|
||||
// Principal principal = theHttpServletRequest.getUserPrincipal();
|
||||
// DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal();
|
||||
//
|
||||
// SewageJob oldSewageJob = sewageJobService.getById(id);
|
||||
// if (oldSewageJob == null) {
|
||||
// throw new RuntimeException(String.format("没有找到id为 %s 的污水检测任务", id));
|
||||
// }
|
||||
//
|
||||
// if (!StrUtil.equalsIgnoreCase(dlpUser.getOrgId(), oldSewageJob.getLauncheOrgId())) {
|
||||
// throw new RuntimeException(String.format("你没有权限修改id为 %s 的污水检测任务的数据", id));
|
||||
// }
|
||||
//
|
||||
// if (oldSewageJob.getStatus()>0) {
|
||||
// throw new RuntimeException(String.format("id为 %s 的污水检测任务已经发布, 只能删除未发布的任务", id));
|
||||
// }
|
||||
//
|
||||
// sewageJobItemService.remove(Wrappers.<SewageJobItem>query().eq("job_id", id));
|
||||
//
|
||||
// return R.ok(sewageJobService.removeById(id));
|
||||
// }
|
||||
|
||||
/** |
||||
* 统计各污水厂的送检情况 |
||||
*/ |
||||
@ApiOperation(value = "统计各污水厂的送检情况",notes="统计各污水厂的送检情况") |
||||
@GetMapping("/querySendData") |
||||
public R querySendData(String jobId,String areaCode,String materialStatus,String treeLayer,HttpServletRequest theHttpServletRequest){ |
||||
Assert.notNull(jobId,"任务ID不能为空"); |
||||
Principal principal = theHttpServletRequest.getUserPrincipal(); |
||||
DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal(); |
||||
|
||||
R ret = remoteOrgService.getById(dlpUser.getOrgId()); |
||||
String currentUserAreaCode=""; |
||||
if (ret.getCode() == CommonConstants.SUCCESS) { |
||||
currentUserAreaCode = ((SysOrg) ret.getData()).getAreaCode(); |
||||
} |
||||
else { |
||||
return R.failed(String.format("没有找到 orgId 为 %s 的机构, 请确认用户所属机构的正确性!", dlpUser.getOrgId())); |
||||
} |
||||
int targetTreeLayer=StringUtils.isNotBlank(treeLayer)?Integer.parseInt(treeLayer):5; |
||||
return R.ok(sewageJobGABService.querySewageJcSendData(jobId,currentUserAreaCode,materialStatus,targetTreeLayer),"获取数据信息成功"); |
||||
} |
||||
|
||||
/** |
||||
* |
||||
* 初始化污水系统 |
||||
*/ |
||||
// @GetMapping("/initSewageJobData")
|
||||
// public R initSewageJobData(){
|
||||
// //1、清除污水任务之前,需要先清除污水任务明细,污水检材明细,污水厂数据,必须严格按照顺序,防止脏数据的产生
|
||||
// //1、清除检材表 2、清除任务明细表,3、清除污水厂表,4、清除任务表
|
||||
// List<SewageJob> sewageJobList=sewageJobService.list();
|
||||
// for (SewageJob sewageJob:sewageJobList) {
|
||||
// //删除该任务对应的明细任务项
|
||||
// sewageJobItemService.remove(Wrappers.<SewageJobItem>query().eq("job_id",sewageJob.getId()));
|
||||
// //获取该任务下的检材明细
|
||||
// sewageJobIdentificationMaterialService.remove(Wrappers.<SewageJobIdentificationMaterial>query().eq("job_id",sewageJob.getId()));
|
||||
// sewageJobService.removeById(sewageJob);
|
||||
// }
|
||||
// //清除污水厂
|
||||
// sewageTreatmentPlantService.remove(Wrappers.<SewageTreatmentPlant>query().ne("id","999999"));
|
||||
// return R.ok(1,"操作成功");
|
||||
// }
|
||||
|
||||
/** |
||||
************************************************************************** 获取禁毒平台上的污水任务数据*************************************** |
||||
*/ |
||||
|
||||
/** |
||||
* 根据id 去平台上获取数据 |
||||
* @return |
||||
*/ |
||||
@GetMapping("/sync_drug_platform_data/{id}") |
||||
// @PreAuthorize("@pms.hasPermission('SewageJobGet')")
|
||||
public R getDataOne(@PathVariable String id, HttpServletRequest theHttpServletRequest) { |
||||
Principal principal = theHttpServletRequest.getUserPrincipal(); |
||||
DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal(); |
||||
if (!dlpUser.isStaff()) { |
||||
throw new RuntimeException(String.format("用户名为 %s 的用户没有权限操作该功能", dlpUser.getName())); |
||||
} |
||||
SewageJobIdentificationMaterial sewageJobIdentificationMaterial = sewageJobGABService.querySewageDataOne(id, dlpUser); |
||||
if (sewageJobIdentificationMaterial != null) { |
||||
return R.ok(sewageJobIdentificationMaterial, "操作成功"); |
||||
} else { |
||||
return R.ok("操作失败"); |
||||
} |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 从禁毒大数据平台获取污水数据 |
||||
* @return |
||||
*/ |
||||
@GetMapping("/sync_drug_platform_data") |
||||
@PreAuthorize("@pms.hasPermission('SewageJobGet')") |
||||
public R getDataFromDrugPlatform(QueryCondition queryCondition, HttpServletRequest theHttpServletRequest) { |
||||
Principal principal = theHttpServletRequest.getUserPrincipal(); |
||||
DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal(); |
||||
if (!dlpUser.isStaff()) { |
||||
throw new RuntimeException(String.format("用户名为 %s 的用户没有权限操作该功能", dlpUser.getName())); |
||||
} |
||||
sewageJobGABService.getSewageJobDataFromDrugPlatform(queryCondition, dlpUser); |
||||
|
||||
return R.ok("操作成功"); |
||||
} |
||||
|
||||
/** |
||||
* 签收 |
||||
* @param ids id |
||||
* @return R |
||||
*/ |
||||
@ApiOperation(value = "签收", notes = "签收") |
||||
@SysLog("签收" ) |
||||
@PutMapping("/sample/receive" ) |
||||
// @PreAuthorize("@pms.hasPermission('FeatureAnalysisAllPermission')" )
|
||||
public R receiveSampleList(@RequestBody List<String> ids, |
||||
@RequestParam("jobId") String jobId, |
||||
HttpServletRequest theHttpServletRequest) { |
||||
Principal principal = theHttpServletRequest.getUserPrincipal(); |
||||
DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal(); |
||||
|
||||
if (!dlpUser.isStaff()) { |
||||
throw new RuntimeException(String.format("用户名为 %s 的用户没有权限操作该功能", dlpUser.getName())); |
||||
} |
||||
|
||||
if (!StrUtil.isNotBlank(jobId)) { |
||||
throw new RuntimeException("任务id 不能为空"); |
||||
} |
||||
|
||||
SewageJobGAB byId = sewageJobGABService.getById(jobId); |
||||
if (byId == null) { |
||||
throw new RuntimeException(String.format("id 为 %s 的任务找不到", jobId)); |
||||
} |
||||
|
||||
if (ids == null || ids.size() == 0) { |
||||
throw new RuntimeException("id不能为空,请检查是否勾选样品!"); |
||||
} |
||||
|
||||
List<SewageJobIdentificationMaterial> sewageJobIdentificationMaterials = sewageJobIdentificationMaterialService.listByIds(ids); |
||||
|
||||
for (SewageJobIdentificationMaterial sewageJobIdentificationMaterial : sewageJobIdentificationMaterials) { |
||||
if (sewageJobIdentificationMaterial.getStatus() != 2 ) { |
||||
throw new RuntimeException(String.format("id 为 %s 的样品不在送检中的状态,不能签收", sewageJobIdentificationMaterial.getId())); |
||||
} |
||||
} |
||||
|
||||
return R.ok(sewageJobGABService.receiveSampleList(ids, dlpUser), |
||||
"签收成功"); |
||||
} |
||||
|
||||
/** |
||||
* 拒收 |
||||
* @param ids id |
||||
* @return R |
||||
*/ |
||||
@ApiOperation(value = "拒收样品", notes = "拒收样品") |
||||
@SysLog("拒收样品" ) |
||||
@PutMapping("/sample/reject" ) |
||||
// @PreAuthorize("@pms.hasPermission('FeatureAnalysisAllPermission')" )
|
||||
public R rejectReceiveSampleList(@RequestBody List<String> ids, |
||||
@RequestParam("jobId") String jobId, |
||||
@RequestParam("reason") String reason, |
||||
HttpServletRequest theHttpServletRequest) { |
||||
Principal principal = theHttpServletRequest.getUserPrincipal(); |
||||
DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal(); |
||||
|
||||
if (!dlpUser.isStaff()) { |
||||
throw new RuntimeException(String.format("用户名为 %s 的用户没有权限操作该功能", dlpUser.getName())); |
||||
} |
||||
|
||||
if (!StrUtil.isNotBlank(jobId)) { |
||||
throw new RuntimeException("任务id 不能为空"); |
||||
} |
||||
|
||||
SewageJobGAB byId = sewageJobGABService.getById(jobId); |
||||
if (byId == null) { |
||||
throw new RuntimeException(String.format("id 为 %s 的任务找不到", jobId)); |
||||
} |
||||
|
||||
if (ids == null || ids.size() == 0) { |
||||
throw new RuntimeException("id不能为空,请检查是否勾选样品!"); |
||||
} |
||||
|
||||
List<SewageJobIdentificationMaterial> sewageJobIdentificationMaterials = sewageJobIdentificationMaterialService.listByIds(ids); |
||||
|
||||
for (SewageJobIdentificationMaterial sewageJobIdentificationMaterial : sewageJobIdentificationMaterials) { |
||||
if (sewageJobIdentificationMaterial.getStatus() != 2 ) { |
||||
throw new RuntimeException(String.format("id 为 %s 的样品不在送检中的状态,不能签收", sewageJobIdentificationMaterial.getId())); |
||||
} |
||||
} |
||||
|
||||
return R.ok(sewageJobGABService.rejectReceiveSample(ids, reason, dlpUser), |
||||
"拒收成功"); |
||||
} |
||||
|
||||
/** |
||||
* 退回样品 |
||||
* @param ids id |
||||
* @return R |
||||
*/ |
||||
@ApiOperation(value = "退回样品", notes = "退回样品") |
||||
@SysLog("签收" ) |
||||
@PutMapping("/sample/return" ) |
||||
// @PreAuthorize("@pms.hasPermission('FeatureAnalysisAllPermission')" )
|
||||
public R returnSampleList(@RequestBody List<String> ids, |
||||
@RequestParam("jobId") String jobId, |
||||
@RequestParam("reason") String reason, |
||||
HttpServletRequest theHttpServletRequest) { |
||||
Principal principal = theHttpServletRequest.getUserPrincipal(); |
||||
DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal(); |
||||
|
||||
if (!dlpUser.isStaff()) { |
||||
throw new RuntimeException(String.format("用户名为 %s 的用户没有权限操作该功能", dlpUser.getName())); |
||||
} |
||||
|
||||
if (!StrUtil.isNotBlank(jobId)) { |
||||
throw new RuntimeException("任务id 不能为空"); |
||||
} |
||||
|
||||
SewageJobGAB byId = sewageJobGABService.getById(jobId); |
||||
if (byId == null) { |
||||
throw new RuntimeException(String.format("id 为 %s 的任务找不到", jobId)); |
||||
} |
||||
|
||||
if (ids == null || ids.size() == 0) { |
||||
throw new RuntimeException("id不能为空,请检查是否勾选样品!"); |
||||
} |
||||
|
||||
List<SewageJobIdentificationMaterial> sewageJobIdentificationMaterials = sewageJobIdentificationMaterialService.listByIds(ids); |
||||
|
||||
for (SewageJobIdentificationMaterial sewageJobIdentificationMaterial : sewageJobIdentificationMaterials) { |
||||
if (sewageJobIdentificationMaterial.getStatus() != 3 ) { |
||||
throw new RuntimeException(String.format("id 为 %s 的样品不在签收中的状态,不能退回", sewageJobIdentificationMaterial.getId())); |
||||
} |
||||
} |
||||
|
||||
return R.ok(sewageJobGABService.returnSample(ids, reason, dlpUser), |
||||
"退回样品成功"); |
||||
} |
||||
|
||||
/** |
||||
* 样品作废 |
||||
* @param ids id |
||||
* @return R |
||||
*/ |
||||
@ApiOperation(value = "样品作废", notes = "样品作废") |
||||
@SysLog("拒收样品" ) |
||||
@PutMapping("/sample/close" ) |
||||
// @PreAuthorize("@pms.hasPermission('FeatureAnalysisAllPermission')" )
|
||||
public R closeSampleList(@RequestBody List<String> ids, |
||||
@RequestParam("jobId") String jobId, |
||||
@RequestParam("reason") String reason, |
||||
HttpServletRequest theHttpServletRequest) { |
||||
Principal principal = theHttpServletRequest.getUserPrincipal(); |
||||
DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal(); |
||||
|
||||
if (!dlpUser.isStaff()) { |
||||
throw new RuntimeException(String.format("用户名为 %s 的用户没有权限操作该功能", dlpUser.getName())); |
||||
} |
||||
|
||||
if (!StrUtil.isNotBlank(jobId)) { |
||||
throw new RuntimeException("任务id 不能为空"); |
||||
} |
||||
|
||||
SewageJobGAB byId = sewageJobGABService.getById(jobId); |
||||
if (byId == null) { |
||||
throw new RuntimeException(String.format("id 为 %s 的任务找不到", jobId)); |
||||
} |
||||
|
||||
if (ids == null || ids.size() == 0) { |
||||
throw new RuntimeException("id不能为空,请检查是否勾选样品!"); |
||||
} |
||||
|
||||
List<SewageJobIdentificationMaterial> sewageJobIdentificationMaterials = sewageJobIdentificationMaterialService.listByIds(ids); |
||||
|
||||
for (SewageJobIdentificationMaterial sewageJobIdentificationMaterial : sewageJobIdentificationMaterials) { |
||||
if (sewageJobIdentificationMaterial.getStatus() != 2 ) { |
||||
throw new RuntimeException(String.format("id 为 %s 的样品不在送检中的状态,不能签收", sewageJobIdentificationMaterial.getId())); |
||||
} |
||||
} |
||||
|
||||
return R.ok(sewageJobGABService.closeSample(ids, reason, dlpUser), |
||||
"样品作废成功"); |
||||
} |
||||
|
||||
} |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,822 @@ |
||||
package digital.laboratory.platform.sewage.controller; |
||||
|
||||
import cn.hutool.core.util.StrUtil; |
||||
import com.alibaba.fastjson.JSONArray; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker; |
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
import digital.laboratory.platform.common.core.constant.CommonConstants; |
||||
import digital.laboratory.platform.common.core.util.R; |
||||
import digital.laboratory.platform.common.log.annotation.SysLog; |
||||
import digital.laboratory.platform.common.mybatis.security.service.DLPUser; |
||||
import digital.laboratory.platform.sewage.entity.SewageJobIdentificationMaterial; |
||||
import digital.laboratory.platform.sewage.entity.SewageTreatmentPlant; |
||||
import digital.laboratory.platform.sewage.entity.*; |
||||
import digital.laboratory.platform.sewage.service.*; |
||||
import digital.laboratory.platform.sewage.vo.SewageJobIdentificationMaterialVO; |
||||
import digital.laboratory.platform.sewage.vo.SewageJobItemVO; |
||||
import digital.laboratory.platform.sys.entity.SysOrg; |
||||
import digital.laboratory.platform.sys.feign.RemoteOrgService; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiImplicitParam; |
||||
import io.swagger.annotations.ApiImplicitParams; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import lombok.RequiredArgsConstructor; |
||||
import org.springframework.security.access.prepost.PreAuthorize; |
||||
import org.springframework.security.oauth2.provider.OAuth2Authentication; |
||||
import org.springframework.transaction.annotation.Transactional; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.security.Principal; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
|
||||
/** |
||||
* 污水检测任务清单 |
||||
* |
||||
* @author Zhang Xiaolong created at 2022-09-13 |
||||
* @describe 污水检测任务清单 前端控制器 |
||||
*/ |
||||
@RestController |
||||
@RequiredArgsConstructor |
||||
@RequestMapping("/sewage_job_item") |
||||
@Api(value = "sewage_job_item", tags = "112-污水检测任务清单管理") |
||||
public class SewageJobItemController { |
||||
|
||||
private final SewageJobItemService sewageJobItemService; |
||||
private final SewageJobIdentificationMaterialService sewageJobIdentificationMaterialService; |
||||
private final SewageTreatmentPlantService sewageTreatmentPlantService; |
||||
private final SewageImportLogService sewageImportLogService; |
||||
|
||||
private final SewageJobService sewageJobService; |
||||
|
||||
private final RemoteOrgService remoteOrgService; |
||||
|
||||
/** |
||||
* 通过id查询污水检测任务清单 |
||||
* |
||||
* @param id id |
||||
* |
||||
* @return R |
||||
*/ |
||||
@ApiOperation(value = "通过id查询", notes = "通过id查询") |
||||
@GetMapping("/{id}") |
||||
@PreAuthorize("@pms.hasPermission('SewageJobItemGet')") |
||||
public R getById(@PathVariable("id") String id, HttpServletRequest theHttpServletRequest) { |
||||
Principal principal = theHttpServletRequest.getUserPrincipal(); |
||||
DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal(); |
||||
|
||||
List<SewageJobItemVO> theList = sewageJobItemService.getSewageJobItemVOList(Wrappers.<SewageJobItem>query() |
||||
.eq("ji.id", id) |
||||
); |
||||
|
||||
if ((theList == null) && (theList.size() == 0)) { |
||||
return R.failed(String.format("没有找到 id 为 %s 的任务项", id)); |
||||
} |
||||
|
||||
return R.ok(theList.get(0)); |
||||
} |
||||
|
||||
/** |
||||
* 分页查询 |
||||
* |
||||
* @param page 分页对象 |
||||
* @param jobId |
||||
* @param name |
||||
* @param address |
||||
* |
||||
* @return |
||||
*/ |
||||
@ApiOperation(value = "分页查询", notes = "分页查询, 查询条件是 jobId 或 污水处理厂名字 或 污水处理厂地址") |
||||
@GetMapping("/page") |
||||
@PreAuthorize("@pms.hasPermission('SewageJobItemList')") |
||||
public R getSewageJobItemPage(Page page, |
||||
@RequestParam(value = "jobId", required = false) String jobId, |
||||
@RequestParam(value = "name", required = false) String name, |
||||
@RequestParam(value = "address", required = false) String address, |
||||
HttpServletRequest theHttpServletRequest) { |
||||
Principal principal = theHttpServletRequest.getUserPrincipal(); |
||||
DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal(); |
||||
|
||||
final SysOrg userOrg; // 定义成 final才可以被后面的 Lambda 表达式使用
|
||||
R r = remoteOrgService.getById(dlpUser.getOrgId()); |
||||
if (r.getCode() == CommonConstants.SUCCESS) { |
||||
userOrg = (SysOrg) r.getData(); |
||||
} |
||||
else { |
||||
return R.failed(String.format("没有找到 orgId 为 %s 的机构, 请确认用户所属机构的正确性!", dlpUser.getOrgId())); |
||||
} |
||||
|
||||
IPage<SewageJobItemVO> thePage = sewageJobItemService.getSewageJobItemVOPage(page, Wrappers.<SewageJobItem>query() |
||||
.eq(StrUtil.isNotBlank(jobId), "ji.job_id", jobId) |
||||
.and(!dlpUser.isStaff(), (wrapper) -> wrapper // 如果不是分中心员工
|
||||
.eq("stp.province_code", userOrg.getAreaCode()) // 污水处理厂的省级地区码与用户机构所在地区一致
|
||||
.or() |
||||
.eq("stp.city_code", userOrg.getAreaCode()) // 污水处理厂的市级地区码与用户机构所在地区一致
|
||||
.or() |
||||
.eq("stp.district_code", userOrg.getAreaCode()) // 污水处理厂的区级地区码与用户机构所在地区一致
|
||||
) |
||||
.like(StrUtil.isNotBlank(name), "stp.name", name) |
||||
.like(StrUtil.isNotBlank(address), "stp.address", address) |
||||
.orderByDesc("stp.province_code") |
||||
.orderByDesc("stp.city_code") |
||||
.orderByDesc("stp.district_code") |
||||
.orderByDesc("stp.name") |
||||
); |
||||
|
||||
|
||||
for (SewageJobItemVO item : thePage.getRecords()) { |
||||
item.setCanEdit(false); |
||||
if (dlpUser.isStaff()) { |
||||
item.setCanEdit(true); |
||||
} |
||||
else { |
||||
if (item.getCreateByOrgLevel()>=userOrg.getOrgLevel()) { |
||||
item.setCanEdit(true); |
||||
} |
||||
} |
||||
} |
||||
|
||||
return R.ok(thePage); |
||||
} |
||||
//获取任务清单项
|
||||
@ApiOperation(value = "污水厂列表查询 --add", notes = "通过任务ID污水厂列表查询 --add") |
||||
@PreAuthorize("@pms.hasPermission('SewageJobItemList')") |
||||
@PostMapping("/getSewageJobItemListByTaskID") |
||||
public R getSewageJobItemListByTaskID(@RequestBody JSONObject jsonParms){ |
||||
String taskId=jsonParms.getString("taskId"); |
||||
List<String> areaCodeList=JSONObject.parseObject(jsonParms.getJSONArray("areaCodeList").toJSONString(),List.class); |
||||
List<String> test=new ArrayList<>(); |
||||
List<String> sewageJobItemList=sewageJobItemService.getSewageJobItemListByTaskID(taskId,areaCodeList); |
||||
return R.ok(sewageJobItemList,"获取数据成功"); |
||||
} |
||||
//从任务项里,获取检材
|
||||
@ApiOperation(value = "查询检材根据污水厂ID --add", notes = "查询检材根据污水厂ID --add") |
||||
@PreAuthorize("@pms.hasPermission('SewageJobItemList')") |
||||
@PostMapping("/getSewageMaterialByTaskItem") |
||||
public R getSewageMaterialByTaskItem(@RequestBody JSONObject jsonParms){ |
||||
String taskId=jsonParms.getString("taskId"); |
||||
List<String> stpIdList=JSONObject.parseObject(jsonParms.getJSONArray("stpList").toJSONString(),List.class); |
||||
return R.ok(sewageJobItemService.getSewageMaterialListByStpId(taskId,stpIdList),"获取数据成功"); |
||||
} |
||||
/** |
||||
* 列表查询 |
||||
* |
||||
* @param sewageJobItem 污水检测任务清单 |
||||
* |
||||
* @return |
||||
*/ |
||||
@ApiOperation(value = "列表查询", notes = "列表查询, 查询条件是 jobId 或 污水处理厂名字 或 污水处理厂地址") |
||||
@GetMapping("/list") |
||||
@PreAuthorize("@pms.hasPermission('SewageJobItemList')") |
||||
public R getSewageJobItemList(SewageJobItem sewageJobItem, |
||||
@RequestParam(value = "jobId", required = false) String jobId, |
||||
@RequestParam(value = "name", required = false) String name, |
||||
@RequestParam(value = "address", required = false) String address, |
||||
HttpServletRequest theHttpServletRequest) { |
||||
Principal principal = theHttpServletRequest.getUserPrincipal(); |
||||
DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal(); |
||||
|
||||
final SysOrg userOrg; // 定义成 final才可以被后面的 Lambda 表达式使用
|
||||
R r = remoteOrgService.getById(dlpUser.getOrgId()); |
||||
if (r.getCode() == CommonConstants.SUCCESS) { |
||||
userOrg = (SysOrg) r.getData(); |
||||
} |
||||
else { |
||||
return R.failed(String.format("没有找到 orgId 为 %s 的机构, 请确认用户所属机构的正确性!", dlpUser.getOrgId())); |
||||
} |
||||
|
||||
List<SewageJobItemVO> theList = sewageJobItemService.getSewageJobItemVOList(Wrappers.<SewageJobItem>query() |
||||
.eq(StrUtil.isNotBlank(jobId), "ji.job_id", jobId) |
||||
.and(!dlpUser.isStaff(), (wrapper) -> wrapper // 如果不是分中心员工
|
||||
.eq("stp.province_code", userOrg.getAreaCode()) // 污水处理厂的省级地区码与用户机构所在地区一致
|
||||
.or() |
||||
.eq("stp.city_code", userOrg.getAreaCode()) // 污水处理厂的市级地区码与用户机构所在地区一致
|
||||
.or() |
||||
.eq("stp.district_code", userOrg.getAreaCode()) // 污水处理厂的区级地区码与用户机构所在地区一致
|
||||
) |
||||
.like(StrUtil.isNotBlank(name), "stp.name", name) |
||||
.like(StrUtil.isNotBlank(address), "stp.address", address) |
||||
.orderByDesc("stp.province_code") |
||||
.orderByDesc("stp.city_code") |
||||
.orderByDesc("stp.district_code") |
||||
.orderByDesc("stp.name") |
||||
); |
||||
//将污水厂下的样品一起加载出来,传回客户端
|
||||
for (SewageJobItemVO item : theList) { |
||||
item.setCanEdit(false); |
||||
List<SewageJobIdentificationMaterialVO> tmpList=sewageJobIdentificationMaterialService.getSewageJobIdentificationMaterialVOList(Wrappers.<SewageJobIdentificationMaterial>query() |
||||
.eq("job_item_id",item.getId())); |
||||
item.setSewageJobIdentificationMaterialVO(tmpList); |
||||
if (dlpUser.isStaff()) { |
||||
item.setCanEdit(true); |
||||
} |
||||
else { |
||||
if (item.getCreateByOrgLevel()>=userOrg.getOrgLevel()) { |
||||
item.setCanEdit(true); |
||||
} |
||||
} |
||||
} |
||||
return R.ok(theList); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 新增污水检测任务清单 |
||||
* |
||||
* @param sewageJobItem 污水检测任务清单 |
||||
* |
||||
* @return R |
||||
*/ |
||||
@ApiOperation(value = "新增污水检测任务清单", notes = "新增污水检测任务清单") |
||||
@SysLog("新增污水检测任务清单") |
||||
@PostMapping |
||||
@PreAuthorize("@pms.hasPermission('SewageJobItemCreate')") |
||||
public R postAddObject(@RequestBody SewageJobItem sewageJobItem, HttpServletRequest theHttpServletRequest) { |
||||
Principal principal = theHttpServletRequest.getUserPrincipal(); |
||||
DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal(); |
||||
|
||||
final SysOrg userOrg; // 定义成 final才可以被后面的 Lambda 表达式使用
|
||||
R r = remoteOrgService.getById(dlpUser.getOrgId()); |
||||
if (r.getCode() == CommonConstants.SUCCESS) { |
||||
userOrg = (SysOrg) r.getData(); |
||||
} |
||||
else { |
||||
return R.failed(String.format("没有找到 orgId 为 %s 的机构, 请确认用户所属机构的正确性!", dlpUser.getOrgId())); |
||||
} |
||||
int userLevel = 99; |
||||
if (dlpUser.isStaff()) { |
||||
// 分中心
|
||||
userLevel = 0; |
||||
} |
||||
else if (StrUtil.endWith(userOrg.getAreaCode(), "0000")) { |
||||
// 省级
|
||||
userLevel = 1; |
||||
} |
||||
else if (StrUtil.endWith(userOrg.getAreaCode(), "00")) { |
||||
// 市级
|
||||
userLevel = 2; |
||||
} |
||||
else { |
||||
// 区级
|
||||
userLevel = 3; |
||||
} |
||||
|
||||
sewageJobItem.setCreateByOrgLevel(userLevel); |
||||
|
||||
sewageJobItem.setId(IdWorker.get32UUID().toUpperCase()); |
||||
return R.ok(sewageJobItemService.save(sewageJobItem)); |
||||
|
||||
} |
||||
|
||||
|
||||
/** |
||||
* 批量导入污水检测任务清单 |
||||
* |
||||
* @param jsonParam 污水检测任务清单 |
||||
* |
||||
* @return R |
||||
*/ |
||||
@ApiOperation(value = "批量导入污水检测任务清单", notes = "批量导入污水检测任务清单, json格式, 格式大致如下:\n" + |
||||
"<pre>\n格式:\n" + |
||||
"{\n" + |
||||
" \"jobId\": \"179DE0C6CEAAA5F11ED0B9FFA7044023\",\n" + |
||||
" \"sheetList\": [\n" + |
||||
" {\n" + |
||||
" \"name\": \"sheet1\",\n" + |
||||
" \"dataList\": [\n" + |
||||
" {\n" + |
||||
" \"序号\": 1,\n" + |
||||
" \"污水处理厂名称\":\"第9个污水处理厂\"\n" + |
||||
" },\n" + |
||||
" {\n" + |
||||
" \"序号\": 2,\n" + |
||||
" \"污水处理厂名称\":\"第19个污水处理厂\"\n" + |
||||
" }\n" + |
||||
" ]\n" + |
||||
" },\n" + |
||||
" {\n" + |
||||
" \"name\": \"sheet2\",\n" + |
||||
" \"dataList\": [\n" + |
||||
" {\n" + |
||||
" \"序号\": 11,\n" + |
||||
" \"污水处理厂名称\":\"第11个污水处理厂\"\n" + |
||||
" },\n" + |
||||
" {\n" + |
||||
" \"序号\": 12,\n" + |
||||
" \"污水处理厂名称\":\"第12个污水处理厂\"\n" + |
||||
" }\n" + |
||||
" ]\n" + |
||||
" }\n" + |
||||
" ]\n" + |
||||
"}\n" + |
||||
"</pre>") |
||||
@ApiImplicitParams({ |
||||
@ApiImplicitParam(name = "jsonParam", value = "需要导入的数据", required = true, paramType = "body"), |
||||
}) |
||||
@SysLog("批量导入污水检测任务清单") |
||||
@PostMapping("/excel") |
||||
@PreAuthorize("@pms.hasPermission('SewageJobItemCreate')") |
||||
@Transactional(rollbackFor = {RuntimeException.class, Exception.class}) |
||||
public R postImportObjectBatch(@RequestBody JSONObject jsonParam, HttpServletRequest theHttpServletRequest) { |
||||
Principal principal = theHttpServletRequest.getUserPrincipal(); |
||||
DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal(); |
||||
|
||||
final SysOrg userOrg; // 定义成 final才可以被后面的 Lambda 表达式使用
|
||||
R r = remoteOrgService.getById(dlpUser.getOrgId()); |
||||
if (r.getCode() == CommonConstants.SUCCESS) { |
||||
userOrg = (SysOrg) r.getData(); |
||||
} |
||||
else { |
||||
return R.failed(String.format("没有找到 orgId 为 %s 的机构, 请确认用户所属机构的正确性!", dlpUser.getOrgId())); |
||||
} |
||||
int userLevel = 99; |
||||
if (dlpUser.isStaff()) { |
||||
// 分中心
|
||||
userLevel = 0; |
||||
} |
||||
else if (StrUtil.endWith(userOrg.getAreaCode(), "0000")) { |
||||
// 省级
|
||||
userLevel = 1; |
||||
} |
||||
else if (StrUtil.endWith(userOrg.getAreaCode(), "00")) { |
||||
// 市级
|
||||
userLevel = 2; |
||||
} |
||||
else { |
||||
// 区级
|
||||
userLevel = 3; |
||||
} |
||||
String errorInfo = ""; // 错误信息
|
||||
Boolean errorExists = false; |
||||
|
||||
List<SewageJobItem> itemList = new ArrayList<SewageJobItem>(); |
||||
String jobId = jsonParam.getString("jobId"); |
||||
JSONArray sheetList = jsonParam.getJSONArray("sheetList"); |
||||
for (int i=0; i<sheetList.size(); i++) { |
||||
JSONObject sheet = sheetList.getJSONObject(i); |
||||
String sheetName = sheet.getString("name"); // sheet 的名称
|
||||
JSONArray dataList = sheet.getJSONArray("dataList"); |
||||
for (int j=0; j<dataList.size(); j++) { |
||||
JSONObject jsonSJI = dataList.getJSONObject(j); |
||||
Integer itemNo = jsonSJI.getInteger("序号"); |
||||
String stpName = jsonSJI.getString("污水处理厂名称"); |
||||
|
||||
List<SewageTreatmentPlant> stpList = sewageTreatmentPlantService.list(Wrappers.<SewageTreatmentPlant>query() |
||||
.eq("name", stpName) |
||||
); |
||||
String stpId = ""; |
||||
if ((stpList!=null) && (stpList.size()==1)) { |
||||
stpId = stpList.get(0).getId(); |
||||
|
||||
|
||||
List<SewageJobItem> oldItemList = sewageJobItemService.list(Wrappers.<SewageJobItem>query() |
||||
.eq("plant_id", stpId) |
||||
.eq("job_id", jobId) |
||||
); |
||||
if ((oldItemList != null) && (oldItemList.size()==0)) { |
||||
SewageJobItem sji = new SewageJobItem(); |
||||
sji.setId(IdWorker.get32UUID().toUpperCase()); |
||||
sji.setJobId(jobId); |
||||
sji.setCreateByOrgLevel(userOrg.getOrgLevel()); |
||||
sji.setPlantId(stpId); |
||||
sji.setComments("导入的数据"); |
||||
itemList.add(sji); |
||||
} |
||||
else if (oldItemList==null) { |
||||
errorInfo += String.format("错误! sheet:%s 序号:%d 污水处理厂名称:%s, 错误信息: 查询现有任务清单出错, 返回数据为 null\n", sheetName, itemNo, stpName ); |
||||
errorExists = true; |
||||
} |
||||
else if (oldItemList.size()>0) { |
||||
errorInfo += String.format("错误! sheet:%s 序号:%d 污水处理厂名称:%s, 错误信息: 现有任务清单中已经有该污水处理厂, 无需再次添加\n", sheetName, itemNo, stpName ); |
||||
errorExists = true; |
||||
} |
||||
} |
||||
else if (stpList==null) { |
||||
errorInfo += String.format("错误! sheet:%s 序号:%d 污水处理厂名称:%s, 错误信息: 查询污水处理厂信息返回数据为 null\n", sheetName, itemNo, stpName ); |
||||
errorExists = true; |
||||
} |
||||
else if (stpList.size()==0) { |
||||
errorInfo += String.format("错误! sheet:%s 序号:%d 污水处理厂名称:%s, 错误信息: 污水处理厂不存在, 应该先添加污水处理厂后才能导入此条数据\n", sheetName, itemNo, stpName ); |
||||
errorExists = true; |
||||
} |
||||
|
||||
|
||||
} |
||||
} |
||||
|
||||
|
||||
// sewageJobItem.setCreateByOrgLevel(userLevel);
|
||||
//
|
||||
// sewageJobItem.setId(IdWorker.get32UUID().toUpperCase());
|
||||
// return R.ok(sewageJobItemService.save(sewageJobItem));
|
||||
|
||||
if (errorExists) { |
||||
// 出错了
|
||||
itemList = null; |
||||
} |
||||
else { |
||||
// 没有出错
|
||||
for (SewageJobItem sji : itemList) { |
||||
sewageJobItemService.save(sji); |
||||
} |
||||
if (StrUtil.isBlank(errorInfo)) { |
||||
errorInfo = String.format("导入数据成功, 共有 %d 条任务清单数据", itemList.size()); |
||||
} |
||||
} |
||||
|
||||
SewageImportLog siLog = new SewageImportLog(); |
||||
siLog.setId(IdWorker.get32UUID().toUpperCase()); |
||||
siLog.setModule("任务清单导入"); |
||||
siLog.setLog(errorInfo); |
||||
sewageImportLogService.save(siLog); |
||||
|
||||
return R.ok(itemList, errorInfo); |
||||
|
||||
} |
||||
|
||||
|
||||
|
||||
/** |
||||
* 修改污水检测任务清单 |
||||
* |
||||
* @param sewageJobItem 污水检测任务清单 |
||||
* |
||||
* @return R |
||||
*/ |
||||
@ApiOperation(value = "修改污水检测任务清单", notes = "修改污水检测任务清单" + |
||||
"用户只能修改本级机构或下级机构创建的任务清单。\n" + |
||||
"只能修改 comments 属性\n" + |
||||
"其他属性应该保持原样\n" + |
||||
"如果需要修改 jobId, 正确的做法是删除本条任务清单, 然后为对应的任务添加任务清单\n" + |
||||
"如果需要修改污水处理 plantId, 正确的做法是新加一条任务清单, 并指定正确的污水处理厂\n" |
||||
) |
||||
@SysLog("修改污水检测任务清单") |
||||
@PutMapping |
||||
@PreAuthorize("@pms.hasPermission('SewageJobItemEdit')") |
||||
public R putUpdateById(@RequestBody SewageJobItem sewageJobItem, HttpServletRequest theHttpServletRequest) { |
||||
Principal principal = theHttpServletRequest.getUserPrincipal(); |
||||
DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal(); |
||||
|
||||
final SysOrg userOrg; // 定义成 final才可以被后面的 Lambda 表达式使用
|
||||
R r = remoteOrgService.getById(dlpUser.getOrgId()); |
||||
if (r.getCode() == CommonConstants.SUCCESS) { |
||||
userOrg = (SysOrg) r.getData(); |
||||
} |
||||
else { |
||||
return R.failed(String.format("没有找到 orgId 为 %s 的机构, 请确认用户所属机构的正确性!", dlpUser.getOrgId())); |
||||
} |
||||
int userLevel = 99; |
||||
if (dlpUser.isStaff()) { |
||||
// 分中心
|
||||
userLevel = 0; |
||||
} |
||||
else if (StrUtil.endWith(userOrg.getAreaCode(), "0000")) { |
||||
// 省级
|
||||
userLevel = 1; |
||||
} |
||||
else if (StrUtil.endWith(userOrg.getAreaCode(), "00")) { |
||||
// 市级
|
||||
userLevel = 2; |
||||
} |
||||
else { |
||||
// 区级
|
||||
userLevel = 3; |
||||
} |
||||
|
||||
SewageJobItem oldsji = sewageJobItemService.getById(sewageJobItem.getId()); |
||||
if (oldsji.getCreateByOrgLevel() < userLevel) { |
||||
return R.failed(String.format("这条任务清单项 %s 是由上级机构创建的,你没有权限修改!", sewageJobItem.getId())); |
||||
} |
||||
|
||||
if (!StrUtil.equals(oldsji.getJobId(), sewageJobItem.getJobId())) { |
||||
return R.failed(String.format("任务清单项中的任务id不能修改!")); |
||||
} |
||||
|
||||
if (!StrUtil.equals(oldsji.getPlantId(), sewageJobItem.getPlantId())) { |
||||
return R.failed(String.format("任务清单项中的污水处理厂不能修改!")); |
||||
} |
||||
|
||||
if (sewageJobItemService.updateById(sewageJobItem)) { |
||||
return R.ok(sewageJobItem, "修改任务清单项成功"); |
||||
} |
||||
else { |
||||
return R.failed(sewageJobItem, "修改任务清单项失败"); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 通过id删除污水检测任务清单 |
||||
* |
||||
* @param id id |
||||
* |
||||
* @return R |
||||
*/ |
||||
@ApiOperation(value = "通过id删除污水检测任务清单", notes = "通过id删除污水检测任务清单" + |
||||
"用户只能删除本级机构或下级机构创建的任务清单。\n" |
||||
) |
||||
@SysLog("通过id删除污水检测任务清单") |
||||
@DeleteMapping("/{id}") |
||||
@PreAuthorize("@pms.hasPermission('SewageJobItemDelete')") |
||||
public R deleteById(@PathVariable String id, HttpServletRequest theHttpServletRequest) { |
||||
Principal principal = theHttpServletRequest.getUserPrincipal(); |
||||
DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal(); |
||||
|
||||
final SysOrg userOrg; // 定义成 final才可以被后面的 Lambda 表达式使用
|
||||
R r = remoteOrgService.getById(dlpUser.getOrgId()); |
||||
if (r.getCode() == CommonConstants.SUCCESS) { |
||||
userOrg = (SysOrg) r.getData(); |
||||
} |
||||
else { |
||||
return R.failed(String.format("没有找到 orgId 为 %s 的机构, 请确认用户所属机构的正确性!", dlpUser.getOrgId())); |
||||
} |
||||
int userLevel = 99; |
||||
if (dlpUser.isStaff()) { |
||||
// 分中心
|
||||
userLevel = 0; |
||||
} |
||||
else if (StrUtil.endWith(userOrg.getAreaCode(), "0000")) { |
||||
// 省级
|
||||
userLevel = 1; |
||||
} |
||||
else if (StrUtil.endWith(userOrg.getAreaCode(), "00")) { |
||||
// 市级
|
||||
userLevel = 2; |
||||
} |
||||
else { |
||||
// 区级
|
||||
userLevel = 3; |
||||
} |
||||
|
||||
SewageJobItem oldsji = sewageJobItemService.getById(id); |
||||
if (oldsji.getCreateByOrgLevel() < userLevel) { |
||||
return R.failed(String.format("这条任务清单项 %s 是由上级机构创建的,你没有权限删除!", id)); |
||||
} |
||||
|
||||
List<SewageJobIdentificationMaterial> sjimList = sewageJobIdentificationMaterialService.list(Wrappers.<SewageJobIdentificationMaterial>query() |
||||
.eq("job_item_id", id)); |
||||
if (sjimList.size() > 0) { |
||||
return R.failed(String.format("这条任务清单项 %s 已经创建了对应的检材, 不能删除它", id)); |
||||
} |
||||
|
||||
if (sewageJobItemService.removeById(id)) { |
||||
return R.ok(oldsji, "任务清单项删除成功"); |
||||
} |
||||
else { |
||||
return R.failed(oldsji, "任务清单项删除失败"); |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
/** |
||||
* 批量新增污水检测任务清单 |
||||
* |
||||
* @param jsonParam 污水检测任务清单 |
||||
* |
||||
* @return R |
||||
*/ |
||||
@ApiOperation(value = "批量新增污水检测任务清单", notes = "批量新增污水检测任务清单, json格式, 格式大致如下:\n" + |
||||
"<pre>\n格式:\n" + |
||||
"{\n" + |
||||
" \"jobId\": \"179DE0C6CEAAA5F11ED0B9FFA7044023\",\n" + |
||||
" \"sewageTreatmentPlantIds\": [\"179DE0C6CEAAA5F11ED0B9FFA7044023\", \"123DE0C6CEAAA5F11ED0B9FFA7044123\"]\n" + |
||||
"}\n" + |
||||
"</pre>") |
||||
@ApiImplicitParams({ |
||||
@ApiImplicitParam(name = "jsonParam", value = "需要新增的数据", required = true, paramType = "body"), |
||||
}) |
||||
@SysLog("批量新增污水检测任务清单") |
||||
@PostMapping("/batch") |
||||
@PreAuthorize("@pms.hasPermission('SewageJobItemCreate')") |
||||
@Transactional(rollbackFor = {RuntimeException.class, Exception.class}) |
||||
public R postAddObjectBatch(@RequestBody JSONObject jsonParam, HttpServletRequest theHttpServletRequest) { |
||||
Principal principal = theHttpServletRequest.getUserPrincipal(); |
||||
DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal(); |
||||
|
||||
final SysOrg userOrg; // 定义成 final才可以被后面的 Lambda 表达式使用
|
||||
R r = remoteOrgService.getById(dlpUser.getOrgId()); |
||||
if (r.getCode() == CommonConstants.SUCCESS) { |
||||
userOrg = (SysOrg) r.getData(); |
||||
} |
||||
else { |
||||
return R.failed(String.format("没有找到 orgId 为 %s 的机构, 请确认用户所属机构的正确性!", dlpUser.getOrgId())); |
||||
} |
||||
//int userLevel = getUserLvByAreaCode(userOrg.getAreaCode());//获取用户级别
|
||||
//保存清单的逻辑是:获取污水厂的ID,如果发现该任务已经有清单了,那么我们就删除之前清单,以现在提交的清单为主,如果之前的清单没有,则直接插入
|
||||
JSONArray sewageTreatmentPlantList = jsonParam.getJSONArray("sewageTreatmentPlantIds");//本次提交的污水厂名单
|
||||
String taskJobId=jsonParam.getString("jobId");//获取本次任务的任务ID
|
||||
List<SewageJobItem> retItemList=sewageJobItemService.batchAddJobItemToTask(taskJobId,userOrg,sewageTreatmentPlantList,dlpUser); |
||||
return R.ok(retItemList, String.format("批量加入任务清单成功, 共有 %d 条任务清单数据", retItemList.size())); |
||||
//下面为之前的历史代码,看起来有点混乱,我修改一下,增加一点可读性 xy add 07-01,
|
||||
/* |
||||
List<SewageJobItem> itemList = new ArrayList<SewageJobItem>(); |
||||
List<SewageJobIdentificationMaterial> jcList = new ArrayList<SewageJobIdentificationMaterial>(); |
||||
|
||||
String jobId = jsonParam.getString("jobId"); |
||||
JSONArray sewageTreatmentPlantIds = jsonParam.getJSONArray("sewageTreatmentPlantIds");//获取到本次选择的污水厂ID
|
||||
|
||||
for (int i = 0; i < sewageTreatmentPlantIds.size(); i++) { |
||||
String sewageTreatmentPlantId = sewageTreatmentPlantIds.getString(i); |
||||
|
||||
List<SewageTreatmentPlant> stpList = sewageTreatmentPlantService.list(Wrappers.<SewageTreatmentPlant>query() |
||||
.eq("id", sewageTreatmentPlantId) |
||||
); |
||||
String stpId = ""; |
||||
if ((stpList != null) && (stpList.size() == 1)) { |
||||
SewageTreatmentPlant stp = stpList.get(0); |
||||
//如果不是分中心的员工,则
|
||||
if (!dlpUser.isStaff()) { |
||||
if (!(StrUtil.equals(userOrg.getAreaCode(), stp.getProvinceCode()) |
||||
|| StrUtil.equals(userOrg.getAreaCode(), stp.getCityCode()) |
||||
|| StrUtil.equals(userOrg.getAreaCode(), stp.getDistrictCode()) |
||||
)) |
||||
{ |
||||
throw new RuntimeException(String.format("[%s]不在你管辖范围内,你没有权限添加到任务清单中", stp.getName())); |
||||
} |
||||
} |
||||
stpId = stp.getId(); |
||||
|
||||
List<SewageJobItem> oldItemList = sewageJobItemService.list(Wrappers.<SewageJobItem>query() |
||||
.eq("plant_id", stpId) |
||||
.eq("job_id", jobId) |
||||
); |
||||
if ((oldItemList != null) && (oldItemList.size() == 0)) { |
||||
|
||||
SewageJobItem sji = new SewageJobItem(); |
||||
sji.setId(IdWorker.get32UUID().toUpperCase()); |
||||
sji.setJobId(jobId); |
||||
sji.setCreateByOrgLevel(userOrg.getOrgLevel()); |
||||
sji.setPlantId(stpId); |
||||
sji.setComments(""); |
||||
itemList.add(sji); |
||||
} |
||||
else if (oldItemList == null) { |
||||
throw new RuntimeException(String.format("错误信息: 查询现有任务清单出错, 返回数据为 null! 污水处理厂id为 %s\n", sewageTreatmentPlantIds)); |
||||
} |
||||
else if (oldItemList.size() > 0) { |
||||
|
||||
System.out.println(String.format("错误信息: 现有任务清单中已经有该污水处理厂, 无需再次添加! 污水处理厂id为 %s, 名称为: %s\n", sewageTreatmentPlantIds, stp.getName())); |
||||
//throw new RuntimeException(String.format("错误信息: 现有任务清单中已经有该污水处理厂, 无需再次添加! 污水处理厂id为 %s\n", sewageTreatmentPlantIds));
|
||||
} |
||||
} |
||||
else if (stpList == null) { |
||||
throw new RuntimeException(String.format("错误信息: 查询污水处理厂信息返回数据为 null! 污水处理厂id为 %s\n", sewageTreatmentPlantIds)); |
||||
} |
||||
else if (stpList.size() == 0) { |
||||
throw new RuntimeException(String.format("错误信息: 污水处理厂不存在, 应该先添加污水处理厂后才能导入此条数据! 污水处理厂id为 %s\n", sewageTreatmentPlantIds)); |
||||
} |
||||
} |
||||
|
||||
for (SewageJobItem sji : itemList) { |
||||
sewageJobItemService.save(sji); |
||||
|
||||
//获取检材编号
|
||||
List<String> ImNoList=GenJCNo(sji.getPlantId(),sji.getJobId()); |
||||
List<SewageJobIdentificationMaterial> jcBeanList=new ArrayList<SewageJobIdentificationMaterial>(); |
||||
for (String jcNo:ImNoList) { |
||||
//插入检材
|
||||
SewageJobIdentificationMaterial sewageJobIdentificationMaterial=new SewageJobIdentificationMaterial(); |
||||
sewageJobIdentificationMaterial.setId(IdWorker.get32UUID().toUpperCase()); |
||||
sewageJobIdentificationMaterial.setJobId(sji.getJobId()); |
||||
sewageJobIdentificationMaterial.setJobItemId(sji.getId()); |
||||
sewageJobIdentificationMaterial.setImNo(jcNo); |
||||
jcBeanList.add(sewageJobIdentificationMaterial); |
||||
} |
||||
sewageJobIdentificationMaterialService.saveBatch(jcBeanList); |
||||
|
||||
} |
||||
return R.ok(itemList, String.format("批量加入任务清单成功, 共有 %d 条任务清单数据", itemList.size())); |
||||
*/ |
||||
} |
||||
|
||||
/** |
||||
* 批量删除污水检测任务清单 |
||||
* |
||||
* @param jsonParam json格式的参数 |
||||
* |
||||
* @return R |
||||
*/ |
||||
@ApiOperation(value = "批量删除污水检测任务清单", notes = "批量删除污水检测任务清单\n" + |
||||
"用户只能删除本级机构或下级机构创建的任务清单。<b>注意: 这是POST方法, 参数在请求体 RequestBody 中</b>\n" + |
||||
"<pre>\n" + |
||||
"参数(RequestBody):\n" + |
||||
" jobId 任务id" + |
||||
" sewageTreatmentPlantIds 污水处理厂id数组\n" + |
||||
"\n" + |
||||
"格式:\n" + |
||||
"{\n" + |
||||
" \"jobId\": \"179DE0C6CEAAA5F11ED0B9FFA7044023\",\n" + |
||||
" \"sewageTreatmentPlantIds\": [\"179DE0C6CEAAA5F11ED0B9FFA7044023\", \"123DE0C6CEAAA5F11ED0B9FFA7044123\"]\n" + |
||||
"}\n" + |
||||
"</pre>" |
||||
) |
||||
@SysLog("批量删除污水检测任务清单") |
||||
@PostMapping("/delete_batch") |
||||
@PreAuthorize("@pms.hasPermission('SewageJobItemDelete')") |
||||
@Transactional(rollbackFor = {RuntimeException.class, Exception.class}) |
||||
public R deleteBatch(@RequestBody JSONObject jsonParam, HttpServletRequest theHttpServletRequest) { |
||||
Principal principal = theHttpServletRequest.getUserPrincipal(); |
||||
DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal(); |
||||
|
||||
final SysOrg userOrg; // 定义成 final才可以被后面的 Lambda 表达式使用
|
||||
R r = remoteOrgService.getById(dlpUser.getOrgId()); |
||||
if (r.getCode() == CommonConstants.SUCCESS) { |
||||
userOrg = (SysOrg) r.getData(); |
||||
} |
||||
else { |
||||
return R.failed(String.format("没有找到 orgId 为 %s 的机构, 请确认用户所属机构的正确性!", dlpUser.getOrgId())); |
||||
} |
||||
int userLevel = 99; |
||||
if (dlpUser.isStaff()) { |
||||
// 分中心
|
||||
userLevel = 0; |
||||
} |
||||
else if (StrUtil.endWith(userOrg.getAreaCode(), "0000")) { |
||||
// 省级
|
||||
userLevel = 1; |
||||
} |
||||
else if (StrUtil.endWith(userOrg.getAreaCode(), "00")) { |
||||
// 市级
|
||||
userLevel = 2; |
||||
} |
||||
else { |
||||
// 区级
|
||||
userLevel = 3; |
||||
} |
||||
|
||||
String jobId = jsonParam.getString("jobId"); |
||||
JSONArray jonSewageTreatmentPlantIds = jsonParam.getJSONArray("sewageTreatmentPlantIds"); |
||||
|
||||
ArrayList<String> sewageTreatmentPlantIds = new ArrayList<>(); |
||||
for (int i = 0; i < jonSewageTreatmentPlantIds.size(); i++) { |
||||
String sewageTreatmentPlantId = jonSewageTreatmentPlantIds.getString(i); |
||||
sewageTreatmentPlantIds.add(sewageTreatmentPlantId); |
||||
} |
||||
|
||||
ArrayList<String> jobItemIdList = new ArrayList<>(); |
||||
for (String sewageTreatmentPlantId : sewageTreatmentPlantIds) { |
||||
List<SewageJobItemVO> theList = sewageJobItemService.getSewageJobItemVOList(Wrappers.<SewageJobItem>query() |
||||
.eq("ji.job_id", jobId) |
||||
.eq("stp.id", sewageTreatmentPlantId) |
||||
// .and(!dlpUser.isStaff(), (wrapper) -> wrapper // 如果不是分中心员工
|
||||
// .eq("stp.province_code", userOrg.getAreaCode()) // 污水处理厂的省级地区码与用户机构所在地区一致
|
||||
// .or()
|
||||
// .eq("stp.city_code", userOrg.getAreaCode()) // 污水处理厂的市级地区码与用户机构所在地区一致
|
||||
// .or()
|
||||
// .eq("stp.district_code", userOrg.getAreaCode()) // 污水处理厂的区级地区码与用户机构所在地区一致
|
||||
// )
|
||||
// .orderByDesc("stp.province_code")
|
||||
// .orderByDesc("stp.city_code")
|
||||
// .orderByDesc("stp.district_code")
|
||||
// .orderByDesc("stp.name")
|
||||
); |
||||
if ((theList == null) || (theList.size() == 0)) { |
||||
// throw new RuntimeException(String.format("任务清单中不存在 id 为 %d 的污水处理厂", sewageTreatmentPlantId));
|
||||
} |
||||
else { |
||||
SewageJobItemVO sji = theList.get(0); |
||||
if (!dlpUser.isStaff()) { |
||||
if (sji.getCreateByOrgLevel() == 0) { |
||||
throw new RuntimeException(String.format("[%s]是分中心创建的任务清单项,你没有权限删除", sji.getSewageTreatmentPlantName())); |
||||
} |
||||
if (userOrg.getOrgLevel() > sji.getCreateByOrgLevel()) { |
||||
throw new RuntimeException(String.format("[%s]是上级机构创建的任务清单项,你没有权限删除", sji.getSewageTreatmentPlantName())); |
||||
} |
||||
if (!(StrUtil.equals(userOrg.getAreaCode(), sji.getSewageTreatmentPlantProvinceCode()) |
||||
|| StrUtil.equals(userOrg.getAreaCode(), sji.getSewageTreatmentPlantCityCode()) |
||||
|| StrUtil.equals(userOrg.getAreaCode(), sji.getSewageTreatmentPlantDistrictCode()) |
||||
)) |
||||
{ |
||||
throw new RuntimeException(String.format("[%s]不在你管辖范围内,你没有权限删除", sji.getSewageTreatmentPlantName())); |
||||
} |
||||
} |
||||
|
||||
// 看一下有没有检材, 如果有检材, 就不能删除了
|
||||
List<SewageJobIdentificationMaterial> sjimList = sewageJobIdentificationMaterialService.list( |
||||
Wrappers.<SewageJobIdentificationMaterial>query() |
||||
.eq( "job_item_id", sji.getId()) |
||||
); |
||||
|
||||
if ((sjimList!=null) && (sjimList.size()>0)) { |
||||
throw new RuntimeException(String.format("[%s]这条任务清单项已经录入检材信息, 不能删除", sji.getSewageTreatmentPlantName())); |
||||
} |
||||
|
||||
jobItemIdList.add(sji.getId()); |
||||
} |
||||
} |
||||
|
||||
for (String id : jobItemIdList) { |
||||
//System.out.println(String.format("sewageJobItemService.removeById -> %s ", id));
|
||||
sewageJobItemService.removeById(id); |
||||
} |
||||
return R.ok(sewageTreatmentPlantIds, "任务清单项删除成功"); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,708 @@ |
||||
package digital.laboratory.platform.sewage.controller; |
||||
|
||||
import cn.hutool.core.util.RandomUtil; |
||||
import cn.hutool.core.util.StrUtil; |
||||
import com.alibaba.fastjson.JSONArray; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker; |
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
import digital.laboratory.platform.common.core.constant.CommonConstants; |
||||
import digital.laboratory.platform.common.core.util.R; |
||||
import digital.laboratory.platform.common.core.util.TestUtils; |
||||
import digital.laboratory.platform.sewage.mapper.SewageJobMapper; |
||||
import digital.laboratory.platform.sewage.service.SewageJobService; |
||||
import digital.laboratory.platform.sys.entity.Area; |
||||
import digital.laboratory.platform.common.log.annotation.SysLog; |
||||
import digital.laboratory.platform.common.mybatis.security.service.DLPUser; |
||||
import digital.laboratory.platform.sewage.entity.SewageImportLog; |
||||
import digital.laboratory.platform.sewage.service.SewageImportLogService; |
||||
import digital.laboratory.platform.sewage.service.SewageTreatmentPlantService; |
||||
import digital.laboratory.platform.sewage.vo.SewageTreatmentPlantVO; |
||||
import digital.laboratory.platform.sewage.entity.SewageTreatmentPlant; |
||||
import digital.laboratory.platform.sys.entity.SysOrg; |
||||
import digital.laboratory.platform.sys.feign.RemoteAreaService; |
||||
import digital.laboratory.platform.sys.feign.RemoteOrgService; |
||||
import digital.laboratory.platform.sys.feign.RemoteUserService; |
||||
import org.springframework.security.access.prepost.PreAuthorize; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import lombok.RequiredArgsConstructor; |
||||
import org.springframework.security.oauth2.provider.OAuth2Authentication; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.security.Principal; |
||||
import java.util.ArrayList; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
|
||||
/** |
||||
* 污水处理厂 |
||||
* |
||||
* @author Zhang Xiaolong created at 2022-03-22 |
||||
* @describe 污水处理厂 前端控制器 |
||||
*/ |
||||
@RestController |
||||
@RequiredArgsConstructor |
||||
@RequestMapping("/sewage_treatment_plant") |
||||
@Api(tags = "110-污水处理厂管理") |
||||
public class SewageTreatmentPlantController { |
||||
|
||||
private final SewageTreatmentPlantService sewageTreatmentPlantService; |
||||
private final SewageImportLogService sewageImportLogService; |
||||
|
||||
private final RemoteAreaService remoteAreaService; |
||||
private final RemoteUserService remoteUserService; |
||||
private final RemoteOrgService remoteOrgService; |
||||
|
||||
private final SewageJobMapper sewageJobMapper; |
||||
|
||||
private final SewageJobService sewageJobService; |
||||
|
||||
/** |
||||
* 通过id查询污水处理厂 |
||||
* |
||||
* @param id id |
||||
* @return R |
||||
*/ |
||||
@ApiOperation(value = "通过id查询", notes = "通过id查询") |
||||
@GetMapping("/{id}") |
||||
@PreAuthorize("@pms.hasPermission('SewageTreatmentPlantGet')") |
||||
public R getById(@PathVariable("id") String id, HttpServletRequest theHttpServletRequest) { |
||||
Principal principal = theHttpServletRequest.getUserPrincipal(); |
||||
DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal(); |
||||
SysOrg userOrg = null; |
||||
R r = remoteOrgService.getById(dlpUser.getOrgId()); |
||||
if (r.getCode() == CommonConstants.SUCCESS) { |
||||
userOrg = (SysOrg) r.getData(); |
||||
} else { |
||||
return R.failed(String.format("没有找到 orgId 为 %s 的机构, 请确认用户所属机构的正确性!", dlpUser.getOrgId())); |
||||
} |
||||
|
||||
SewageTreatmentPlant sewageTreatmentPlant = sewageTreatmentPlantService.getById(id); |
||||
if (sewageTreatmentPlant != null) { |
||||
if (dlpUser.isStaff() || |
||||
StrUtil.equalsIgnoreCase(userOrg.getAreaCode(), sewageTreatmentPlant.getProvinceCode()) || |
||||
StrUtil.equalsIgnoreCase(userOrg.getAreaCode(), sewageTreatmentPlant.getCityCode()) || |
||||
StrUtil.equalsIgnoreCase(userOrg.getAreaCode(), sewageTreatmentPlant.getDistrictCode()) |
||||
) { |
||||
return R.ok(sewageTreatmentPlant); |
||||
} else { |
||||
return R.failed(String.format("你没有权限访问id为 %s 的污水处理厂的数据", id)); |
||||
} |
||||
} else { |
||||
return R.failed(String.format("没有找到id为 %s 的污水处理厂", id)); |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
/** |
||||
* 列表查询 |
||||
* |
||||
* @param sewageTreatmentPlant – 污水处理厂 查询条件 |
||||
* @return |
||||
*/ |
||||
@ApiOperation(value = "列表查询", notes = "列表查询") |
||||
@GetMapping("/list") |
||||
@PreAuthorize("@pms.hasPermission('SewageTreatmentPlantList')") |
||||
public R getSewageTreatmentPlantList(SewageTreatmentPlant sewageTreatmentPlant, HttpServletRequest theHttpServletRequest) { |
||||
Principal principal = theHttpServletRequest.getUserPrincipal(); |
||||
DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal(); |
||||
final SysOrg userOrg; // 定义成 final才可以被后面的 Lambda 表达式使用
|
||||
R r = remoteOrgService.getById(dlpUser.getOrgId()); |
||||
if (r.getCode() == CommonConstants.SUCCESS) { |
||||
userOrg = (SysOrg) r.getData(); |
||||
} else { |
||||
return R.failed(String.format("没有找到 orgId 为 %s 的机构, 请确认用户所属机构的正确性!", dlpUser.getOrgId())); |
||||
} |
||||
|
||||
List<SewageTreatmentPlantVO> list = sewageTreatmentPlantService.getSewageTreatmentPlantVOList(Wrappers.<SewageTreatmentPlant>query() |
||||
.like(StrUtil.isNotBlank(sewageTreatmentPlant.getName()), "name", sewageTreatmentPlant.getName()) |
||||
.and(!dlpUser.isStaff(), (wrapper) -> wrapper // 如果不是分中心员工
|
||||
.eq("province_code", userOrg.getAreaCode()) // 污水处理厂的省级地区码与用户机构所在地区一致
|
||||
.or() |
||||
.eq("city_code", userOrg.getAreaCode()) // 污水处理厂的市级地区码与用户机构所在地区一致
|
||||
.or() |
||||
.eq("district_code", userOrg.getAreaCode()) // 污水处理厂的区级地区码与用户机构所在地区一致
|
||||
) |
||||
.eq(StrUtil.isNotBlank(sewageTreatmentPlant.getProvinceCode()), "province_code", sewageTreatmentPlant.getProvinceCode()) |
||||
.eq(StrUtil.isNotBlank(sewageTreatmentPlant.getCityCode()), "city_code", sewageTreatmentPlant.getCityCode()) |
||||
.eq(StrUtil.isNotBlank(sewageTreatmentPlant.getDistrictCode()), "district_code", sewageTreatmentPlant.getDistrictCode()) |
||||
.orderByDesc("name") |
||||
); |
||||
return R.ok(list); |
||||
} |
||||
|
||||
/** |
||||
* 分页查询 |
||||
* |
||||
* @param page 分页对象 |
||||
* @param sewageTreatmentPlant 污水处理厂 |
||||
* @return |
||||
*/ |
||||
@ApiOperation(value = "分页查询", notes = "分页查询") |
||||
@GetMapping("/page") |
||||
@PreAuthorize("@pms.hasPermission('SewageTreatmentPlantList')") |
||||
public R getSewageTreatmentPlantPage(Page page, SewageTreatmentPlant sewageTreatmentPlant, HttpServletRequest theHttpServletRequest) { |
||||
Principal principal = theHttpServletRequest.getUserPrincipal(); |
||||
DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal(); |
||||
final SysOrg userOrg; // 定义成 final才可以被后面的 Lambda 表达式使用
|
||||
R r = remoteOrgService.getById(dlpUser.getOrgId()); |
||||
if (r.getCode() == CommonConstants.SUCCESS) { |
||||
userOrg = (SysOrg) r.getData(); |
||||
} else { |
||||
return R.failed(String.format("没有找到 orgId 为 %s 的机构, 请确认用户所属机构的正确性!", dlpUser.getOrgId())); |
||||
} |
||||
return R.ok(sewageTreatmentPlantService.getSewageTreatmentPlantVOPage(page, Wrappers.<SewageTreatmentPlant>query() |
||||
.like(StrUtil.isNotBlank(sewageTreatmentPlant.getName()), "name", sewageTreatmentPlant.getName().trim()) |
||||
.and(!dlpUser.isStaff(), (wrapper) -> wrapper // 如果不是分中心员工
|
||||
.eq("province_code", userOrg.getAreaCode()) // 污水处理厂的省级地区码与用户机构所在地区一致
|
||||
.or() |
||||
.eq("city_code", userOrg.getAreaCode()) // 污水处理厂的市级地区码与用户机构所在地区一致
|
||||
.or() |
||||
.eq("district_code", userOrg.getAreaCode()) // 污水处理厂的区级地区码与用户机构所在地区一致
|
||||
) |
||||
.eq(StrUtil.isNotBlank(sewageTreatmentPlant.getProvinceCode()), "province_code", sewageTreatmentPlant.getProvinceCode()) |
||||
.eq(StrUtil.isNotBlank(sewageTreatmentPlant.getCityCode()), "city_code", sewageTreatmentPlant.getCityCode()) |
||||
.eq(StrUtil.isNotBlank(sewageTreatmentPlant.getDistrictCode()), "district_code", sewageTreatmentPlant.getDistrictCode()) |
||||
.orderByDesc("name") |
||||
)); |
||||
|
||||
} |
||||
|
||||
|
||||
/** |
||||
* 新增污水处理厂 |
||||
* |
||||
* @param sewageTreatmentPlant 污水处理厂 |
||||
* @return R |
||||
*/ |
||||
@ApiOperation(value = "新增污水处理厂", notes = "新增污水处理厂") |
||||
@SysLog("新增污水处理厂") |
||||
@PostMapping |
||||
@PreAuthorize("@pms.hasPermission('SewageTreatmentPlantCreate')") |
||||
public R postAddObject(@RequestBody SewageTreatmentPlant sewageTreatmentPlant, HttpServletRequest theHttpServletRequest) { |
||||
Principal principal = theHttpServletRequest.getUserPrincipal(); |
||||
DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal(); |
||||
final SysOrg userOrg; // 定义成 final才可以被后面的 Lambda 表达式使用
|
||||
R r = remoteOrgService.getById(dlpUser.getOrgId()); |
||||
if (r.getCode() == CommonConstants.SUCCESS) { |
||||
userOrg = (SysOrg) r.getData(); |
||||
} else { |
||||
return R.failed(String.format("没有找到 orgId 为 %s 的机构, 请确认用户所属机构的正确性!", dlpUser.getOrgId())); |
||||
} |
||||
sewageTreatmentPlant.setId(IdWorker.get32UUID().toUpperCase()); |
||||
|
||||
if (sewageTreatmentPlantService.save(sewageTreatmentPlant)) { |
||||
return R.ok(sewageTreatmentPlant, "新增污水处理厂成功"); |
||||
} else { |
||||
return R.failed(sewageTreatmentPlant, "新增污水处理厂失败"); |
||||
} |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 批量新增污水处理厂 |
||||
* |
||||
* @param jsonParam 污水处理厂 |
||||
* @return R |
||||
*/ |
||||
@ApiOperation(value = "批量新增污水处理厂", notes = "批量新增污水处理厂\n" + |
||||
"格式:\n" + |
||||
"<pre>\n" + |
||||
"{\n" + |
||||
"\t\"sheetList\": [\n" + |
||||
"\t\t{\n" + |
||||
"\t\t\t\"name\": \"sheet1\",\n" + |
||||
"\t\t\t\"dataList\": [\n" + |
||||
"\t\t\t\t{\n" + |
||||
"\t\t\t\t\t\"序号\": 1,\n" + |
||||
"\t\t\t\t\t\"污水处理厂名称\": \"xxxxxxxxx\",\n" + |
||||
"\t\t\t\t\t\"污水处理厂简称\": \"xx\",\n" + |
||||
"\t\t\t\t\t\"地址\": \"某省某市某区某某街道某某号\",\n" + |
||||
"\t\t\t\t\t\"管网覆盖区域\": \"大部分城区\",\n" + |
||||
"\t\t\t\t\t\"省行政区编码\": \"610000\",\n" + |
||||
"\t\t\t\t\t\"省禁毒办联系人和电话\": \"张三 13900000000\",\n" + |
||||
"\t\t\t\t\t\"市行政区编码\": \"610100\",\n" + |
||||
"\t\t\t\t\t\"市禁毒办联系人和电话\": \"李四 13700000000\",\n" + |
||||
"\t\t\t\t\t\"区县行政区编码\": \"610112\",\n" + |
||||
"\t\t\t\t\t\"区县禁毒办联系人和电话\": \"王五 18900000000\",\n" + |
||||
"\t\t\t\t\t\"污水进水口数量\": 5,\n" + |
||||
"\t\t\t\t\t\"设计日均处理污水总量(万立方米/日)\": 180.30,\n" + |
||||
"\t\t\t\t\t\"实际日均处理污水总量(万立方米/日)\": 179.21,\n" + |
||||
"\t\t\t\t\t\"生活污水占比(%)\": 20.23,\n" + |
||||
"\t\t\t\t\t\"服务人口数(万人)\": 23.32,\n" + |
||||
"\t\t\t\t\t\"备注\": \"某某县2021年1月上报\"\n" + |
||||
"\t\t\t\t},\n" + |
||||
"\t\t\t\t{\n" + |
||||
"\t\t\t\t\t\"序号\": 1,\n" + |
||||
"\t\t\t\t\t\"污水处理厂名称\": \"测试潜水处理厂\",\n" + |
||||
"\t\t\t\t\t\"污水处理厂简称\": \"测厂\",\n" + |
||||
"\t\t\t\t\t\"地址\": \"xx某省某市某区某某街道某某号\",\n" + |
||||
"\t\t\t\t\t\"管网覆盖区域\": \"大部分城区\",\n" + |
||||
"\t\t\t\t\t\"省行政区编码\": \"610000\",\n" + |
||||
"\t\t\t\t\t\"省禁毒办联系人和电话\": \"x张三 15900000000\",\n" + |
||||
"\t\t\t\t\t\"市行政区编码\": \"610100\",\n" + |
||||
"\t\t\t\t\t\"市禁毒办联系人和电话\": \"李四x 14700000000\",\n" + |
||||
"\t\t\t\t\t\"区县行政区编码\": \"610112\",\n" + |
||||
"\t\t\t\t\t\"区县禁毒办联系人和电话\": \"王x五 12900000000\",\n" + |
||||
"\t\t\t\t\t\"污水进水口数量\": 3,\n" + |
||||
"\t\t\t\t\t\"设计日均处理污水总量(万立方米/日)\": 80.30,\n" + |
||||
"\t\t\t\t\t\"实际日均处理污水总量(万立方米/日)\": 79.21,\n" + |
||||
"\t\t\t\t\t\"生活污水占比(%)\": 90.23,\n" + |
||||
"\t\t\t\t\t\"服务人口数(万人)\": 123.32,\n" + |
||||
"\t\t\t\t\t\"备注\": \"某某县2020年5月上报\"\n" + |
||||
"\t\t\t\t}\n" + |
||||
"\t\t\t]\n" + |
||||
"\t\t}\n" + |
||||
"\t]\n" + |
||||
"}\n" + |
||||
"</pre>") |
||||
@SysLog("批量新增污水处理厂") |
||||
@PostMapping("/excel") |
||||
@PreAuthorize("@pms.hasPermission('SewageTreatmentPlantCreate')") |
||||
public R postAddObjectBatch(@RequestBody JSONObject jsonParam, HttpServletRequest theHttpServletRequest) { |
||||
Principal principal = theHttpServletRequest.getUserPrincipal(); |
||||
DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal(); |
||||
final SysOrg userOrg; // 定义成 final才可以被后面的 Lambda 表达式使用
|
||||
R r = remoteOrgService.getById(dlpUser.getOrgId()); |
||||
if (r.getCode() == CommonConstants.SUCCESS) { |
||||
userOrg = (SysOrg) r.getData(); |
||||
} else { |
||||
return R.failed(String.format("没有找到 orgId 为 %s 的机构, 请确认用户所属机构的正确性!", dlpUser.getOrgId())); |
||||
} |
||||
String errorInfo = ""; // 错误信息
|
||||
Boolean errorExists = false; |
||||
List<SewageTreatmentPlant> stpListRet = new ArrayList<SewageTreatmentPlant>(); |
||||
JSONObject excelDataObj = (JSONObject) jsonParam.getJSONArray("sheetList").get(0); |
||||
JSONArray excelDataObjDetailList = (JSONArray) excelDataObj.get("dataList"); |
||||
for (int j = 0; j < excelDataObjDetailList.size(); j++) { |
||||
JSONObject jobj = (JSONObject) excelDataObjDetailList.get(j); |
||||
String provinceName = jobj.get("省").toString().trim(); |
||||
String cityName = jobj.get("市").toString().trim(); |
||||
String districtName = jobj.get("区县").toString().trim(); |
||||
String status = jobj.get("状态").toString().trim(); |
||||
// String provinceCode=jobj.get("省级编码").toString().trim();
|
||||
// String cityCode=jobj.get("市级编码").toString().trim();
|
||||
// String districtCode=jobj.get("县级编码").toString().trim();
|
||||
// 根据名称去查询地区编码
|
||||
R<Map<String, String>> mapR = remoteAreaService.listAreaVOByName(provinceName, cityName, districtName); |
||||
Map<String, String> areaMap = new HashMap<>(); |
||||
if (mapR.getCode() == CommonConstants.SUCCESS) { |
||||
areaMap = mapR.getData(); |
||||
} else { |
||||
throw new RuntimeException(String.format("省市县名字导入出错,请检查名称的正确性!")); |
||||
} |
||||
|
||||
String factoryName = jobj.get("污水处理厂名称").toString().trim(); |
||||
String factoryNo = jobj.get("污水厂编号").toString().trim(); |
||||
String factoryAddress = jobj.get("地址").toString().trim(); |
||||
SewageTreatmentPlant sewageTreatmentPlant = new SewageTreatmentPlant(); |
||||
sewageTreatmentPlant.setId(IdWorker.get32UUID()); |
||||
sewageTreatmentPlant.setNumber(factoryNo); |
||||
sewageTreatmentPlant.setName(factoryName); |
||||
sewageTreatmentPlant.setAddress(factoryAddress); |
||||
sewageTreatmentPlant.setProvinceName(provinceName); |
||||
sewageTreatmentPlant.setCityName(cityName); |
||||
sewageTreatmentPlant.setDistrictName(districtName); |
||||
sewageTreatmentPlant.setProvinceCode(areaMap.get("provinceId")); |
||||
sewageTreatmentPlant.setCityCode(areaMap.get("cityId")); |
||||
|
||||
String districtCode = areaMap.get("areaId"); |
||||
|
||||
//如果没有查到行政编码,就从99递增创建区县级的行政编码
|
||||
if (!StrUtil.isNotBlank(districtCode)) { |
||||
String code = sewageJobService.getDistrictCode(provinceName, cityName, districtName); |
||||
sewageTreatmentPlant.setDistrictCode(code); |
||||
} else { |
||||
sewageTreatmentPlant.setDistrictCode(districtCode); |
||||
} |
||||
sewageTreatmentPlant.setWaterInletCount(1); |
||||
if (status.equals("启用")) { |
||||
sewageTreatmentPlant.setStatus(1); |
||||
} else if (status.equals("停用")) { |
||||
sewageTreatmentPlant.setStatus(-1); |
||||
} else { |
||||
throw new RuntimeException(String.format("未填写状态或状态填写有误,请填入启用/停用即可!!!")); |
||||
} |
||||
SewageTreatmentPlant temp = sewageTreatmentPlantService.getOne(Wrappers.<SewageTreatmentPlant>query() |
||||
.eq("name", sewageTreatmentPlant.getName()) |
||||
.eq("city_name", sewageTreatmentPlant.getCityName()) |
||||
.eq("province_name", sewageTreatmentPlant.getProvinceName()) |
||||
.eq("district_name", sewageTreatmentPlant.getDistrictName())); |
||||
|
||||
if (temp != null) { |
||||
System.out.println("污水厂:【" + sewageTreatmentPlant.getCityName() + "】【" + sewageTreatmentPlant.getName() + "】已经导入,请不要重复导入"); |
||||
errorInfo += String.format("错误! 污水处理厂名称:%s, 错误信息: 同名的污水处理厂已经存在!\n", sewageTreatmentPlant.getName()); |
||||
errorExists = true; |
||||
} else { |
||||
stpListRet.add(sewageTreatmentPlant); |
||||
sewageTreatmentPlantService.save(sewageTreatmentPlant); |
||||
} |
||||
} |
||||
System.out.println("本次导入污水厂数量:" + stpListRet.size()); |
||||
|
||||
// sewageTreatmentPlantService.saveBatch(stpListRet);
|
||||
SewageImportLog siLog = new SewageImportLog(); |
||||
siLog.setId(IdWorker.get32UUID().toUpperCase()); |
||||
siLog.setModule("污水处理厂导入"); |
||||
siLog.setLog(errorInfo); |
||||
sewageImportLogService.save(siLog); |
||||
return R.ok(stpListRet, errorInfo); |
||||
|
||||
/* |
||||
String errorInfo = ""; // 错误信息
|
||||
Boolean errorExists = false; |
||||
List<SewageTreatmentPlant> stpList = new ArrayList<SewageTreatmentPlant>(); |
||||
JSONArray sheetList = jsonParam.getJSONArray("sheetList"); |
||||
for (int i=0; i<sheetList.size(); i++) { |
||||
JSONObject sheet = sheetList.getJSONObject(i); |
||||
String sheetName = sheet.getString("name"); // sheet 的名称
|
||||
JSONArray dataList = sheet.getJSONArray("dataList"); |
||||
for (int j = 0; j < dataList.size(); j++) { |
||||
JSONObject jsonSTP = dataList.getJSONObject(j); |
||||
|
||||
JSONObject formSTP = new JSONObject(); |
||||
|
||||
// 因为前端提交的 key 有可能会含有空格或回车, 我们需要专门判断一下
|
||||
for (String key : jsonSTP.keySet()) { |
||||
String pureKey = BusinessCodeUtils.removeSymbols(key); |
||||
if (StrUtil.equals(pureKey, "序号")) { |
||||
formSTP.put("序号", jsonSTP.get(key)); |
||||
} |
||||
else if (StrUtil.equals(pureKey, "污水处理厂名称")) { |
||||
formSTP.put("污水处理厂名称", jsonSTP.get(key)); |
||||
} |
||||
else if (StrUtil.equals(pureKey, "名称")) { |
||||
formSTP.put("污水处理厂名称", jsonSTP.get(key)); |
||||
} |
||||
else if (StrUtil.equals(pureKey, "污水处理厂简称")) { |
||||
formSTP.put("污水处理厂简称", jsonSTP.get(key)); |
||||
} |
||||
else if (StrUtil.equals(pureKey, "简称")) { |
||||
formSTP.put("污水处理厂简称", jsonSTP.get(key)); |
||||
} |
||||
else if (StrUtil.equals(pureKey, "地址")) { |
||||
formSTP.put("地址", jsonSTP.get(key)); |
||||
} |
||||
else if (StrUtil.equals(pureKey, "管网覆盖区域")) { |
||||
formSTP.put("管网覆盖区域", jsonSTP.get(key)); |
||||
} |
||||
else if (StrUtil.equals(pureKey, "管网覆盖")) { |
||||
formSTP.put("管网覆盖区域", jsonSTP.get(key)); |
||||
} |
||||
else if (StrUtil.equals(pureKey, "省行政区编码")) { |
||||
formSTP.put("省行政区编码", jsonSTP.get(key)); |
||||
} |
||||
else if (StrUtil.equals(pureKey, "省禁毒办联系人和电话")) { |
||||
formSTP.put("省禁毒办联系人和电话", jsonSTP.get(key)); |
||||
} |
||||
else if (StrUtil.equals(pureKey, "省禁毒办联系人")) { |
||||
formSTP.put("省禁毒办联系人和电话", jsonSTP.get(key)); |
||||
} |
||||
else if (StrUtil.equals(pureKey, "市行政区编码")) { |
||||
formSTP.put("市行政区编码", jsonSTP.get(key)); |
||||
} |
||||
else if (StrUtil.equals(pureKey, "市禁毒办联系人和电话")) { |
||||
formSTP.put("市禁毒办联系人和电话", jsonSTP.get(key)); |
||||
} |
||||
else if (StrUtil.equals(pureKey, "市禁毒办联系人")) { |
||||
formSTP.put("市禁毒办联系人和电话", jsonSTP.get(key)); |
||||
} |
||||
else if (StrUtil.equals(pureKey, "区县行政区编码")) { |
||||
formSTP.put("区县行政区编码", jsonSTP.get(key)); |
||||
} |
||||
else if (StrUtil.equals(pureKey, "区县行政区编码")) { |
||||
formSTP.put("区县行政区编码", jsonSTP.get(key)); |
||||
} |
||||
else if (StrUtil.equals(pureKey, "区行政区编码")) { |
||||
formSTP.put("区县行政区编码", jsonSTP.get(key)); |
||||
} |
||||
else if (StrUtil.equals(pureKey, "区县禁毒办联系人和电话")) { |
||||
formSTP.put("区县禁毒办联系人和电话", jsonSTP.get(key)); |
||||
} |
||||
else if (StrUtil.equals(pureKey, "县禁毒办联系人和电话")) { |
||||
formSTP.put("区县禁毒办联系人和电话", jsonSTP.get(key)); |
||||
} |
||||
else if (StrUtil.equals(pureKey, "县禁毒办联系人和电话")) { |
||||
formSTP.put("区县禁毒办联系人和电话", jsonSTP.get(key)); |
||||
} |
||||
else if (StrUtil.equals(pureKey, "区禁毒办联系人和电话")) { |
||||
formSTP.put("区县禁毒办联系人和电话", jsonSTP.get(key)); |
||||
} |
||||
else if (StrUtil.equals(pureKey, "区县禁毒办联系人")) { |
||||
formSTP.put("区县禁毒办联系人和电话", jsonSTP.get(key)); |
||||
} |
||||
else if (StrUtil.equals(pureKey, "区县禁毒办")) { |
||||
formSTP.put("区县禁毒办联系人和电话", jsonSTP.get(key)); |
||||
} |
||||
else if (StrUtil.equals(pureKey, "污水进水口数量")) { |
||||
formSTP.put("污水进水口数量", jsonSTP.get(key)); |
||||
} |
||||
else if (StrUtil.equals(pureKey, "污水进水口")) { |
||||
formSTP.put("污水进水口数量", jsonSTP.get(key)); |
||||
} |
||||
else if (StrUtil.equals(pureKey, "进水口数量")) { |
||||
formSTP.put("污水进水口数量", jsonSTP.get(key)); |
||||
} |
||||
else if (StrUtil.equals(pureKey, "进水口")) { |
||||
formSTP.put("污水进水口数量", jsonSTP.get(key)); |
||||
} |
||||
else if (StrUtil.equals(pureKey, "设计日均处理污水总量(万立方米/日)")) { |
||||
formSTP.put("设计日均处理污水总量(万立方米/日)", jsonSTP.get(key)); |
||||
} |
||||
else if (StrUtil.equals(pureKey, "设计日均处理污水总量")) { |
||||
formSTP.put("设计日均处理污水总量(万立方米/日)", jsonSTP.get(key)); |
||||
} |
||||
else if (StrUtil.equals(pureKey, "设计日均处理污水")) { |
||||
formSTP.put("设计日均处理污水总量(万立方米/日)", jsonSTP.get(key)); |
||||
} |
||||
else if (StrUtil.equals(pureKey, "实际日均处理污水总量(万立方米/日)")) { |
||||
formSTP.put("实际日均处理污水总量(万立方米/日)", jsonSTP.get(key)); |
||||
} |
||||
else if (StrUtil.equals(pureKey, "实际日均处理污水总量")) { |
||||
formSTP.put("实际日均处理污水总量(万立方米/日)", jsonSTP.get(key)); |
||||
} |
||||
else if (StrUtil.equals(pureKey, "实际日均处理污水")) { |
||||
formSTP.put("实际日均处理污水总量(万立方米/日)", jsonSTP.get(key)); |
||||
} |
||||
else if (StrUtil.equals(pureKey, "生活污水占比(%)")) { |
||||
formSTP.put("生活污水占比(%)", jsonSTP.get(key)); |
||||
} |
||||
else if (StrUtil.equals(pureKey, "生活污水占比")) { |
||||
formSTP.put("生活污水占比(%)", jsonSTP.get(key)); |
||||
} |
||||
else if (StrUtil.equals(pureKey, "服务人口数(万人)")) { |
||||
formSTP.put("服务人口数(万人)", jsonSTP.get(key)); |
||||
} |
||||
else if (StrUtil.equals(pureKey, "服务人口数")) { |
||||
formSTP.put("服务人口数(万人)", jsonSTP.get(key)); |
||||
} |
||||
else if (StrUtil.equals(pureKey, "服务人口")) { |
||||
formSTP.put("服务人口数(万人)", jsonSTP.get(key)); |
||||
} |
||||
else if (StrUtil.equals(pureKey, "备注")) { |
||||
formSTP.put("备注", jsonSTP.get(key)); |
||||
} |
||||
} |
||||
|
||||
Integer itemNo = formSTP.getInteger("序号"); |
||||
String name = formSTP.getString("污水处理厂名称"); |
||||
String shortName = formSTP.getString("污水处理厂简称"); |
||||
String address = formSTP.getString("地址"); |
||||
String coverageArea = formSTP.getString("管网覆盖区域"); |
||||
String provinceCode = formSTP.getString("省行政区编码"); |
||||
String provinceContacts = formSTP.getString("省禁毒办联系人和电话"); |
||||
String cityCode = formSTP.getString("市行政区编码"); |
||||
String cityContacts = formSTP.getString("市禁毒办联系人和电话"); |
||||
String districtCode = formSTP.getString("区县行政区编码"); |
||||
String districtContacts = formSTP.getString("区县禁毒办联系人和电话"); |
||||
Integer waterInletCount = formSTP.getInteger("污水进水口数量"); |
||||
Double dailyFlowDesign = formSTP.getDouble("设计日均处理污水总量(万立方米/日)"); |
||||
Double dailyFlowReal = formSTP.getDouble("实际日均处理污水总量(万立方米/日)"); |
||||
Double domesticSewageProportion = formSTP.getDouble("生活污水占比(%)"); |
||||
Double servicePopulation = formSTP.getDouble("服务人口数(万人)"); |
||||
String comments = formSTP.getString("备注"); |
||||
|
||||
SewageTreatmentPlant oldstp =sewageTreatmentPlantService.getOne(Wrappers.<SewageTreatmentPlant>query() |
||||
.eq("name", name) |
||||
); |
||||
if (oldstp == null) { |
||||
SewageTreatmentPlant stp = new SewageTreatmentPlant(); |
||||
stp.setId(IdWorker.get32UUID().toUpperCase()); |
||||
stp.setName(name); |
||||
stp.setShortName(shortName); |
||||
stp.setAddress(address); |
||||
stp.setCoverageArea(coverageArea); |
||||
stp.setProvinceCode(provinceCode); |
||||
stp.setProvinceContacts(provinceContacts); |
||||
stp.setCityCode(cityCode); |
||||
stp.setCityContacts(cityContacts); |
||||
stp.setDistrictCode(districtCode); |
||||
stp.setDistrictContacts(districtContacts); |
||||
stp.setWaterInletCount(waterInletCount); |
||||
stp.setDailyFlowDesign(dailyFlowDesign); |
||||
stp.setDailyFlowReal(dailyFlowReal); |
||||
stp.setDomesticSewageProportion(domesticSewageProportion); |
||||
stp.setServicePopulation(servicePopulation); |
||||
stp.setComments(comments); |
||||
stpList.add(stp); |
||||
} |
||||
else { |
||||
errorInfo += String.format("错误! sheet:%s 序号:%d 污水处理厂名称:%s, 错误信息: 同名的污水处理厂已经存在!\n", sheetName, itemNo, name ); |
||||
errorExists = true; |
||||
} |
||||
} |
||||
} |
||||
|
||||
|
||||
// sewageJobItem.setCreateByOrgLevel(userLevel);
|
||||
//
|
||||
// sewageJobItem.setId(IdWorker.get32UUID().toUpperCase());
|
||||
// return R.ok(sewageJobItemService.save(sewageJobItem));
|
||||
|
||||
if (errorExists) { |
||||
// 出错了
|
||||
stpList = null; |
||||
} |
||||
else { |
||||
// 没有出错
|
||||
for (SewageTreatmentPlant stp : stpList) { |
||||
sewageTreatmentPlantService.save(stp); |
||||
} |
||||
if (StrUtil.isBlank(errorInfo)) { |
||||
errorInfo = String.format("导入数据成功, 共有 %d 条污水处理厂数据", stpList.size()); |
||||
} |
||||
} |
||||
|
||||
SewageImportLog siLog = new SewageImportLog(); |
||||
siLog.setId(IdWorker.get32UUID().toUpperCase()); |
||||
siLog.setModule("污水处理厂导入"); |
||||
siLog.setLog(errorInfo); |
||||
sewageImportLogService.save(siLog); |
||||
|
||||
return R.ok(stpList, errorInfo);*/ |
||||
} |
||||
|
||||
/** |
||||
* 修改污水处理厂 |
||||
* |
||||
* @param sewageTreatmentPlant 污水处理厂 |
||||
* @return R |
||||
*/ |
||||
@ApiOperation(value = "修改污水处理厂", notes = "修改污水处理厂") |
||||
@SysLog("修改污水处理厂") |
||||
@PutMapping |
||||
@PreAuthorize("@pms.hasPermission('SewageTreatmentPlantEdit')") |
||||
public R putUpdateById(@RequestBody SewageTreatmentPlant sewageTreatmentPlant, HttpServletRequest |
||||
theHttpServletRequest) { |
||||
Principal principal = theHttpServletRequest.getUserPrincipal(); |
||||
DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal(); |
||||
final SysOrg userOrg; // 定义成 final才可以被后面的 Lambda 表达式使用
|
||||
R r = remoteOrgService.getById(dlpUser.getOrgId()); |
||||
if (r.getCode() == CommonConstants.SUCCESS) { |
||||
userOrg = (SysOrg) r.getData(); |
||||
} else { |
||||
return R.failed(String.format("没有找到 orgId 为 %s 的机构, 请确认用户所属机构的正确性!", dlpUser.getOrgId())); |
||||
} |
||||
|
||||
SewageTreatmentPlant oldSewageTreatmentPlant = sewageTreatmentPlantService.getById(sewageTreatmentPlant.getId()); |
||||
if (oldSewageTreatmentPlant != null) { |
||||
if (dlpUser.isStaff() || |
||||
StrUtil.equalsIgnoreCase(userOrg.getAreaCode(), oldSewageTreatmentPlant.getProvinceCode()) || |
||||
StrUtil.equalsIgnoreCase(userOrg.getAreaCode(), oldSewageTreatmentPlant.getCityCode()) || |
||||
StrUtil.equalsIgnoreCase(userOrg.getAreaCode(), oldSewageTreatmentPlant.getDistrictCode()) |
||||
) { |
||||
return R.ok(sewageTreatmentPlantService.updateById(sewageTreatmentPlant)); |
||||
} else { |
||||
return R.failed(String.format("你没有权限修改id为 %s 的污水处理厂的数据", sewageTreatmentPlant.getId())); |
||||
} |
||||
} else { |
||||
return R.failed(String.format("没有找到id为 %s 的污水处理厂", sewageTreatmentPlant.getId())); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 通过id删除污水处理厂 |
||||
* |
||||
* @param id id |
||||
* @return R |
||||
*/ |
||||
@ApiOperation(value = "通过id删除污水处理厂", notes = "通过id删除污水处理厂") |
||||
@SysLog("通过id删除污水处理厂") |
||||
@DeleteMapping("/{id}") |
||||
@PreAuthorize("@pms.hasPermission('SewageTreatmentPlantDelete')") |
||||
public R deleteById(@PathVariable String id, HttpServletRequest theHttpServletRequest) { |
||||
Principal principal = theHttpServletRequest.getUserPrincipal(); |
||||
DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal(); |
||||
final SysOrg userOrg; // 定义成 final才可以被后面的 Lambda 表达式使用
|
||||
R r = remoteOrgService.getById(dlpUser.getOrgId()); |
||||
if (r.getCode() == CommonConstants.SUCCESS) { |
||||
userOrg = (SysOrg) r.getData(); |
||||
} else { |
||||
return R.failed(String.format("没有找到 orgId 为 %s 的机构, 请确认用户所属机构的正确性!", dlpUser.getOrgId())); |
||||
} |
||||
|
||||
SewageTreatmentPlant oldSewageTreatmentPlant = sewageTreatmentPlantService.getById(id); |
||||
if (oldSewageTreatmentPlant != null) { |
||||
if (dlpUser.isStaff() || |
||||
StrUtil.equalsIgnoreCase(userOrg.getAreaCode(), oldSewageTreatmentPlant.getProvinceCode()) || |
||||
StrUtil.equalsIgnoreCase(userOrg.getAreaCode(), oldSewageTreatmentPlant.getCityCode()) || |
||||
StrUtil.equalsIgnoreCase(userOrg.getAreaCode(), oldSewageTreatmentPlant.getDistrictCode()) |
||||
) { |
||||
if (sewageTreatmentPlantService.removeById(id)) { |
||||
return R.ok(oldSewageTreatmentPlant, "污水处理厂删除成功"); |
||||
} else { |
||||
return R.failed(oldSewageTreatmentPlant, "污水处理厂删除失败"); |
||||
} |
||||
} else { |
||||
return R.failed(String.format("你没有权限删除id为 %s 的污水处理厂", id)); |
||||
} |
||||
} else { |
||||
return R.failed(String.format("没有找到id为 %s 的污水处理厂", id)); |
||||
} |
||||
|
||||
} |
||||
|
||||
//获取污水厂的树形结构
|
||||
@ApiOperation(value = "获取污水厂的树形结构", notes = "获取污水厂的树形结构") |
||||
@GetMapping("/getSewageTreatmentTreeData") |
||||
public R getSewageTreatmentTreeData(HttpServletRequest theHttpServletRequest) { |
||||
Principal principal = theHttpServletRequest.getUserPrincipal(); |
||||
DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal(); |
||||
R r = remoteOrgService.getById(dlpUser.getOrgId()); |
||||
String userAreaCode = ""; |
||||
if (r.getCode() == CommonConstants.SUCCESS) { |
||||
userAreaCode = ((SysOrg) r.getData()).getAreaCode(); |
||||
} else { |
||||
return R.failed(String.format("没有找到 orgId 为 %s 的机构, 请确认用户所属机构的正确性!", dlpUser.getOrgId())); |
||||
} |
||||
return R.ok(sewageTreatmentPlantService.getSewageTreatmentTreeList(userAreaCode), "获取数据成功"); |
||||
} |
||||
|
||||
@ApiOperation(value = "获取污水厂省市县3级联动数据", notes = "获取污水厂省市县3级联动数据") |
||||
@GetMapping("/getThreeAreaTreeData") |
||||
public R getThreeAreaTreeData() { |
||||
return R.ok(sewageTreatmentPlantService.getThreeAreaTreeData()); |
||||
} |
||||
|
||||
//=====================================================================================
|
||||
// 测试, 创建 100 个污水处理厂
|
||||
@GetMapping("/create100") |
||||
public R xxx_TestCreate100() { |
||||
String provinceCode = "610000"; |
||||
for (int i = 0; i < 100; i++) { |
||||
SewageTreatmentPlant stp = new SewageTreatmentPlant(); |
||||
stp.setId(IdWorker.get32UUID().toUpperCase()); |
||||
stp.setName("第" + i + "个污水处理厂"); |
||||
stp.setShortName(i + "污水厂"); |
||||
stp.setAddress(RandomUtil.randomString(100)); |
||||
stp.setCoverageArea("全部城区"); |
||||
stp.setProvinceCode(provinceCode); |
||||
List<Area> citis = remoteAreaService.getCitys(provinceCode).getData(); |
||||
Area city = RandomUtil.randomEle(citis); |
||||
stp.setCityCode(city.getId()); |
||||
List<Area> districts = remoteAreaService.getDistricts(city.getId()).getData(); |
||||
Area district = RandomUtil.randomEle(districts); |
||||
stp.setDistrictCode(district.getId()); |
||||
stp.setProvinceContacts(TestUtils.genPersonName() + " " + TestUtils.genMobile()); |
||||
stp.setCityContacts(TestUtils.genPersonName() + " " + TestUtils.genMobile()); |
||||
stp.setDistrictContacts(TestUtils.genPersonName() + " " + TestUtils.genMobile()); |
||||
stp.setWaterInletCount(RandomUtil.randomInt(1, 5)); |
||||
stp.setDailyFlowDesign(Math.round(100 * RandomUtil.randomDouble(10, 200)) / 100.0); |
||||
stp.setDailyFlowReal(Math.round(100 * RandomUtil.randomDouble(10, 200)) / 100.0); |
||||
stp.setDomesticSewageProportion(Math.round(100 * RandomUtil.randomDouble(50, 100)) / 100.0); |
||||
stp.setServicePopulation(Math.round(100 * RandomUtil.randomDouble(100, 200)) / 100.0); |
||||
stp.setComments("这是第" + i + "个污水处理厂的备注"); |
||||
//stp.setUpdateLog();
|
||||
|
||||
sewageTreatmentPlantService.save(stp); |
||||
} |
||||
return R.ok("100 个污水处理厂已成功创建."); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,22 @@ |
||||
package digital.laboratory.platform.sewage.dto; |
||||
|
||||
import lombok.Data; |
||||
|
||||
import java.util.List; |
||||
|
||||
@Data |
||||
public class SewageJobIdentificationMaterialDTO { |
||||
|
||||
private List<String> ids; |
||||
private String expressNumber; |
||||
private String expressCompany; |
||||
private String deliverMethod;//送检类型,是人工现场送检,还是快递
|
||||
|
||||
//送检人信息
|
||||
private String delivererName; |
||||
private String delivererPhone; |
||||
private String delivererCert; |
||||
private String delivererId; |
||||
private String acceptComments; |
||||
|
||||
} |
@ -0,0 +1,47 @@ |
||||
package digital.laboratory.platform.sewage.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import digital.laboratory.platform.common.mybatis.base.BaseEntity; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import java.io.Serializable; |
||||
import java.time.LocalDateTime; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
|
||||
|
||||
/** |
||||
* 污水导入日志 |
||||
* |
||||
* @author Zhang Xiaolong created at 2022-10-06 |
||||
* @describe 污水导入日志 实体类 |
||||
*/ |
||||
@Data |
||||
@TableName(value = "b_sewage_import_log", autoResultMap = true) |
||||
@EqualsAndHashCode(callSuper = true) |
||||
@ApiModel(value = "污水导入日志") |
||||
public class SewageImportLog extends BaseEntity { |
||||
|
||||
/** |
||||
* id |
||||
*/ |
||||
@TableId(value = "id", type = IdType.ASSIGN_UUID) |
||||
@ApiModelProperty(value="id") |
||||
private String id; |
||||
|
||||
/** |
||||
* 模块 |
||||
*/ |
||||
@ApiModelProperty(value="模块") |
||||
private String module; |
||||
|
||||
/** |
||||
* 日志记录 |
||||
*/ |
||||
@ApiModelProperty(value="日志记录") |
||||
private String log; |
||||
|
||||
|
||||
} |
@ -0,0 +1,124 @@ |
||||
package digital.laboratory.platform.sewage.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import digital.laboratory.platform.common.mybatis.base.BaseEntity; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
|
||||
import java.time.LocalDate; |
||||
import java.time.LocalDateTime; |
||||
|
||||
|
||||
/** |
||||
* 污水检测任务 |
||||
* |
||||
* @author Zhang Xiaolong created at 2022-07-26 |
||||
* @describe 污水检测任务(公安部下发) 实体类 |
||||
*/ |
||||
@Data |
||||
@TableName(value = "b_sewage_job_gab", autoResultMap = true) |
||||
@EqualsAndHashCode(callSuper = true) |
||||
@ApiModel(value = "污水检测任务-公安部下发") |
||||
public class SewageJobGAB extends BaseEntity { |
||||
|
||||
/** |
||||
* id |
||||
*/ |
||||
@TableId(value = "id", type = IdType.ASSIGN_UUID) |
||||
@ApiModelProperty(value="id") |
||||
private String id; |
||||
|
||||
/** |
||||
* 任务编号 |
||||
*/ |
||||
@ApiModelProperty(value="任务编号") |
||||
private String jobNo; |
||||
|
||||
/** |
||||
* 任务名称 |
||||
*/ |
||||
@ApiModelProperty(value="任务名称") |
||||
private String name; |
||||
|
||||
/** |
||||
* 任务年份 |
||||
*/ |
||||
@ApiModelProperty(value="任务年份") |
||||
private Integer jobYear; |
||||
|
||||
/** |
||||
* 任务季度 |
||||
*/ |
||||
@ApiModelProperty(value="任务季度") |
||||
private Integer jobSeason; |
||||
|
||||
// /**
|
||||
// * 任务范围(区域id)
|
||||
// */
|
||||
// @ApiModelProperty(value="任务范围(区域id)")
|
||||
// private String jobRegion;
|
||||
|
||||
/** |
||||
* 任务内容描述说明 |
||||
*/ |
||||
@ApiModelProperty(value="任务内容描述说明") |
||||
private String description; |
||||
|
||||
/** |
||||
* 任务发布单位 |
||||
*/ |
||||
@ApiModelProperty(value="任务发布单位") |
||||
private String launcheOrgId; |
||||
|
||||
/** |
||||
* 任务来源 |
||||
*/ |
||||
@ApiModelProperty(value="任务来源") |
||||
private String source; |
||||
|
||||
/** |
||||
* 任务截止日期 |
||||
*/ |
||||
@ApiModelProperty(value="任务截止日期") |
||||
private LocalDateTime expirationDate; |
||||
|
||||
/** |
||||
* 任务开始日期 |
||||
*/ |
||||
@ApiModelProperty(value="任务开始日期") |
||||
private LocalDateTime startDate; |
||||
|
||||
/** |
||||
* 任务备注 |
||||
*/ |
||||
@ApiModelProperty(value="任务备注") |
||||
private String comments; |
||||
|
||||
/** |
||||
* 有效:0=未发布,1=已发布,2=已停止接收样本,3=已完成 |
||||
*/ |
||||
@ApiModelProperty(value="有效:0=未发布,1=已发布,2=已停止接收样本,3=已完成") |
||||
private Integer status; |
||||
|
||||
/** |
||||
* 发布任务人的userId |
||||
*/ |
||||
@ApiModelProperty(value="发布任务人的userId") |
||||
private String launcheUserId; |
||||
|
||||
/** |
||||
* 任务分配日期 |
||||
*/ |
||||
@ApiModelProperty(value="任务分配日期") |
||||
private LocalDateTime launcheDate; |
||||
|
||||
/** |
||||
*污水任务区域列表 |
||||
*/ |
||||
private String sewageAreaList; |
||||
|
||||
} |
@ -0,0 +1,60 @@ |
||||
package digital.laboratory.platform.sewage.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import digital.laboratory.platform.common.mybatis.base.BaseEntity; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import java.io.Serializable; |
||||
import java.time.LocalDateTime; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
|
||||
|
||||
/** |
||||
* 污水检测任务清单 |
||||
* |
||||
* @author Zhang Xiaolong created at 2022-09-18 |
||||
* @describe 污水检测任务清单 实体类 |
||||
*/ |
||||
@Data |
||||
@TableName(value = "b_sewage_job_item", autoResultMap = true) |
||||
@EqualsAndHashCode(callSuper = true) |
||||
@ApiModel(value = "污水检测任务清单") |
||||
public class SewageJobItem extends BaseEntity { |
||||
|
||||
/** |
||||
* 任务项id |
||||
*/ |
||||
@TableId(value = "id", type = IdType.ASSIGN_UUID) |
||||
@ApiModelProperty(value="任务项id") |
||||
private String id; |
||||
|
||||
/** |
||||
* 任务id |
||||
*/ |
||||
@ApiModelProperty(value="任务id") |
||||
private String jobId; |
||||
|
||||
/** |
||||
* 污水处理厂id |
||||
*/ |
||||
@ApiModelProperty(value="污水处理厂id") |
||||
private String plantId; |
||||
|
||||
/** |
||||
* 创建者单位级别: 0=分中心,1=省, 2=市, 3=区县 |
||||
*/ |
||||
@ApiModelProperty(value="创建者单位级别: 0=分中心,1=省, 2=市, 3=区县") |
||||
private Integer createByOrgLevel; |
||||
|
||||
/** |
||||
* 备注 用来设置是否已经选择,没有具体的意义,主要是做客户端显示用 |
||||
*/ |
||||
@ApiModelProperty(value="备注") |
||||
private String comments; |
||||
|
||||
|
||||
|
||||
} |
@ -0,0 +1,54 @@ |
||||
package digital.laboratory.platform.sewage.enums; |
||||
|
||||
import lombok.Getter; |
||||
import lombok.RequiredArgsConstructor; |
||||
|
||||
/** |
||||
* 污水检测任务状态类 |
||||
* <p> |
||||
*/ |
||||
|
||||
@Getter |
||||
@RequiredArgsConstructor |
||||
public enum SewageJobStatusConstants { |
||||
/*JOB_STATUS_CREATED(0, "待发布"), // 已创建待发布
|
||||
JOB_STATUS_REVOCATION(1, "已撤回"), // 已发布的任务在认领前被撤回
|
||||
JOB_STATUS_REFUSED(2, "被拒绝"), // 已发布的任务被拒绝
|
||||
|
||||
JOB_STATUS_WAITING_CLAIM(10, "已发布, 待认领"), // 已发布, 待任务接受机构认领
|
||||
JOB_STATUS_WAITING_EXEC(11, "已认领, 正在执行中"), // 已认领, 正在执行中
|
||||
|
||||
JOB_STATUS_WAITING_FINISH(99, "任务结束"), // 任务结束
|
||||
JOB_STATUS_ABORT(-1, "任务终止"); // 执行了期间执行者终止*/
|
||||
JOB_STATUS_CREATED(0, "待发布"), // 已创建待发布
|
||||
JOB_STATUS_PUBLISH(1, "已发布"), // 已发布的任务
|
||||
|
||||
JOB_STATUS_STOP_RECEIVE(2, "已停止接收样本"), // 已停止接收样本
|
||||
|
||||
JOB_STATUS_WAITING_FINISH(3, "任务结束") // 任务结束
|
||||
; |
||||
/** |
||||
* 状态值 |
||||
*/ |
||||
private final int status; |
||||
|
||||
/** |
||||
* 描述 |
||||
*/ |
||||
private final String description; |
||||
|
||||
public static String getStatusDescription(int theStatus) { |
||||
String r = ""; |
||||
for (SewageJobStatusConstants st : SewageJobStatusConstants.values()) { |
||||
if (st.getStatus() == theStatus) { |
||||
return r = st.description; |
||||
} |
||||
} |
||||
return "未知状态"; |
||||
} |
||||
|
||||
|
||||
public int getStatus() { |
||||
return status; |
||||
} |
||||
} |
@ -0,0 +1,87 @@ |
||||
package digital.laboratory.platform.sewage.handler; |
||||
|
||||
import digital.laboratory.platform.common.core.constant.CommonConstants; |
||||
import digital.laboratory.platform.common.core.util.R; |
||||
import digital.laboratory.platform.sys.entity.Dictionary; |
||||
import digital.laboratory.platform.sys.feign.RemoteDictionaryService; |
||||
import lombok.RequiredArgsConstructor; |
||||
import org.springframework.beans.factory.annotation.Value; |
||||
import org.springframework.boot.ApplicationArguments; |
||||
import org.springframework.boot.ApplicationRunner; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
import java.util.Optional; |
||||
|
||||
/** |
||||
* App 启动类 |
||||
* 当 Spring Application 启动完成后, 会调用这个类的 run() 方法进行一些最后的初始化。 |
||||
* 我们在这个方法中从数据库加载一些全局的配置 |
||||
* |
||||
* @author Zhang Xiaolong |
||||
*/ |
||||
|
||||
@Component |
||||
@RequiredArgsConstructor |
||||
public class AppStartupRunner implements ApplicationRunner { |
||||
@Value("${dlp.entrustment.entrustmentLetterTemplate}") |
||||
public static String entrustmentLetterTemplate; |
||||
|
||||
private final RemoteDictionaryService remoteDictionaryService; |
||||
|
||||
public static Map<String, String> entrustmentConfig = new HashMap<>(); |
||||
public static Map<String, Dictionary> thirdSysConfig = new HashMap<>(); |
||||
|
||||
public static String getCfg(String code) { |
||||
return entrustmentConfig.get(code); |
||||
} |
||||
public static Dictionary getThirdSysCfg(String key) { |
||||
return thirdSysConfig.get(key); |
||||
} |
||||
|
||||
/** |
||||
* |
||||
* @param args 参数 |
||||
* @throws Exception 异常 |
||||
* |
||||
* // @SysLog("委托受理模块初始化") 这里不能使用 @SysLog(), 因为 SysLog 还没有初始化
|
||||
*/ |
||||
@Override |
||||
public void run(ApplicationArguments args) throws Exception { |
||||
// BusinessCodeUtils.removeSymbols("x-*/)——0*&……%¥#@xasdf!*&^&%^ 中文、/+)(()\n\\xx\rx");
|
||||
|
||||
{ |
||||
// 加载 entrustment 在字典中的配置
|
||||
loadDictData(CommonConstants.DLP_TYPE_ENTRUSTMENT,1); |
||||
//加载第三方系统的对接信息
|
||||
loadDictData("920f9dd9cd14281e8b488a34c649ff70",2); |
||||
|
||||
for (String key : entrustmentConfig.keySet()) { |
||||
System.out.println(String.format("entrustmentConfig[%s]=%s", key, entrustmentConfig.get(key))); |
||||
} |
||||
} |
||||
} |
||||
//读取的数据添加到配置中
|
||||
public void loadDictData(String type,int loadWhere) |
||||
{ |
||||
R<List<Dictionary>> r = remoteDictionaryService.getDictionaryByType(type); |
||||
if (Optional.ofNullable(r).isPresent() && (r.getData() != null)) { |
||||
List<Dictionary> itemList = r.getData(); |
||||
if(loadWhere==1) |
||||
{ |
||||
for (Dictionary item : itemList) { |
||||
entrustmentConfig.put(item.getCode(), item.getLabel()); |
||||
} |
||||
} |
||||
if(loadWhere==2) |
||||
{ |
||||
for (Dictionary item : itemList) { |
||||
thirdSysConfig.put(item.getLabel(),item); |
||||
} |
||||
} |
||||
|
||||
} |
||||
} |
||||
} |
@ -0,0 +1,16 @@ |
||||
package digital.laboratory.platform.sewage.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import digital.laboratory.platform.sewage.entity.SewageImportLog; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
|
||||
/** |
||||
* 污水导入日志 Mapper 接口 |
||||
* |
||||
* @author Zhang Xiaolong created at 2022-10-06 |
||||
* @describe 污水导入日志 Mapper 类 |
||||
*/ |
||||
@Mapper |
||||
public interface SewageImportLogMapper extends BaseMapper<SewageImportLog> { |
||||
|
||||
} |
@ -0,0 +1,26 @@ |
||||
package digital.laboratory.platform.sewage.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.baomidou.mybatisplus.core.toolkit.Constants; |
||||
import digital.laboratory.platform.sewage.entity.SewageJobGAB; |
||||
import digital.laboratory.platform.sewage.vo.SewageJobGABVO; |
||||
import digital.laboratory.platform.sewage.vo.SewageTreeVO; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
import org.apache.ibatis.annotations.Param; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 污水检测任务 Mapper 接口 |
||||
* |
||||
* @author Zhang Xiaolong created at 2022-07-26 |
||||
* @describe 污水检测任务 Mapper 类 |
||||
*/ |
||||
@Mapper |
||||
public interface SewageJobGABMapper extends BaseMapper<SewageJobGAB> { |
||||
IPage<SewageJobGABVO> getSewageJobGABVOPage(@Param("page") IPage<SewageJobGAB> page, @Param(Constants.WRAPPER) QueryWrapper<SewageJobGAB> qw); |
||||
List<SewageJobGABVO> getSewageJobGABVOList(@Param(Constants.WRAPPER) QueryWrapper<SewageJobGAB> qw); |
||||
List<SewageTreeVO> getSewageSendData(@Param(Constants.WRAPPER) QueryWrapper<SewageTreeVO> qw); |
||||
} |
@ -0,0 +1,54 @@ |
||||
package digital.laboratory.platform.sewage.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.baomidou.mybatisplus.core.toolkit.Constants; |
||||
import digital.laboratory.platform.sewage.entity.SewageJobIdentificationMaterial; |
||||
import digital.laboratory.platform.sewage.vo.SewageJobIdentificationMaterialVO; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
import org.apache.ibatis.annotations.Param; |
||||
|
||||
import java.util.List; |
||||
/** |
||||
* 污水任务的检材信息 Mapper 接口 |
||||
* |
||||
* @author Zhang Xiaolong created at 2022-07-26 |
||||
* @describe 污水任务的检材信息 Mapper 类 |
||||
*/ |
||||
@Mapper |
||||
public interface SewageJobIdentificationMaterialMapper extends BaseMapper<SewageJobIdentificationMaterial> { |
||||
IPage<SewageJobIdentificationMaterialVO> getSewageJobIdentificationMaterialVOPage(@Param("page") IPage<SewageJobIdentificationMaterial> page, @Param(Constants.WRAPPER) QueryWrapper<SewageJobIdentificationMaterial> qw); |
||||
|
||||
List<SewageJobIdentificationMaterialVO> getSewageJobIdentificationMaterialVOList(@Param(Constants.WRAPPER) QueryWrapper<SewageJobIdentificationMaterial> qw); |
||||
|
||||
IPage<SewageJobIdentificationMaterialVO> getSewageJobGABIdentificationMaterialVOPage(@Param("page") IPage<SewageJobIdentificationMaterial> page, @Param(Constants.WRAPPER) QueryWrapper<SewageJobIdentificationMaterial> qw); |
||||
|
||||
List<SewageJobIdentificationMaterialVO> getSewageJobGABIdentificationMaterialVOList(@Param(Constants.WRAPPER) QueryWrapper<SewageJobIdentificationMaterial> qw); |
||||
|
||||
/** |
||||
* 批量添加(foreach ) |
||||
* |
||||
* @param list |
||||
* @return |
||||
*/ |
||||
int rewriteSaveBatch(@Param("list") List<SewageJobIdentificationMaterial> list); |
||||
|
||||
List<SewageJobIdentificationMaterial> getAcceptIMQuantity(@Param(value = "orgId") String orgId); |
||||
|
||||
List<SewageJobIdentificationMaterial> getFoundIMQuantity(@Param(value = "orgId") String orgId); |
||||
|
||||
List<SewageJobIdentificationMaterial> getWriteIMQuantity(@Param(value = "orgId") String orgId); |
||||
|
||||
List<SewageJobIdentificationMaterial> getRejectionIMQuantity(@Param(value = "orgId") String orgId); |
||||
|
||||
List<SewageJobIdentificationMaterial> getInspectIMQuantity(@Param(value = "orgId") String orgId); |
||||
|
||||
IPage<SewageJobIdentificationMaterialVO> getAnyIm(@Param(value = "page") IPage<SewageJobIdentificationMaterial> page, @Param(Constants.WRAPPER) QueryWrapper<SewageJobIdentificationMaterialVO> queryWrapper); |
||||
List<String> getItemId(String orgId); |
||||
List<String> getNotTimeOutItemId(String orgId); |
||||
List<SewageJobIdentificationMaterialVO> getByImNo(@Param("imNo") String imNo); |
||||
List<SewageJobIdentificationMaterialVO> getByImNoGAB(@Param("imNo") String imNo); |
||||
List<SewageJobIdentificationMaterialVO> getSewageJobIdentificationMaterialVOListByJobId(@Param(Constants.WRAPPER) QueryWrapper<SewageJobIdentificationMaterial> lqw); |
||||
|
||||
} |
@ -0,0 +1,24 @@ |
||||
package digital.laboratory.platform.sewage.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.baomidou.mybatisplus.core.toolkit.Constants; |
||||
import digital.laboratory.platform.sewage.entity.SewageJobItem; |
||||
import digital.laboratory.platform.sewage.vo.SewageJobItemVO; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
import org.apache.ibatis.annotations.Param; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 污水检测任务清单 Mapper 接口 |
||||
* |
||||
* @author Zhang Xiaolong created at 2022-09-13 |
||||
* @describe 污水检测任务清单 Mapper 类 |
||||
*/ |
||||
@Mapper |
||||
public interface SewageJobItemMapper extends BaseMapper<SewageJobItem> { |
||||
IPage<SewageJobItemVO> getSewageJobItemVOPage(@Param("page") IPage<SewageJobItem> page, @Param(Constants.WRAPPER) QueryWrapper<SewageJobItem> qw); |
||||
List<SewageJobItemVO> getSewageJobItemVOList(@Param(Constants.WRAPPER) QueryWrapper<SewageJobItem> qw); |
||||
} |
@ -0,0 +1,55 @@ |
||||
package digital.laboratory.platform.sewage.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.baomidou.mybatisplus.core.toolkit.Constants; |
||||
import digital.laboratory.platform.sewage.dto.StatisticsDiffStatusJobDTO; |
||||
import digital.laboratory.platform.sewage.entity.SewageJob; |
||||
import digital.laboratory.platform.sewage.vo.SewageJobVO; |
||||
import digital.laboratory.platform.sewage.vo.SewageTreeVO; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
import org.apache.ibatis.annotations.Param; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 污水检测任务 Mapper 接口 |
||||
* |
||||
* @author Zhang Xiaolong created at 2022-07-26 |
||||
* @describe 污水检测任务 Mapper 类 |
||||
*/ |
||||
@Mapper |
||||
public interface SewageJobMapper extends BaseMapper<SewageJob> { |
||||
IPage<SewageJobVO> getSewageJobVOPage(@Param("page") IPage<SewageJob> page, @Param(Constants.WRAPPER) QueryWrapper<SewageJob> qw); |
||||
|
||||
IPage<SewageJob> getAllJob(@Param("page") IPage<SewageJob> page, @Param("name") String name); |
||||
|
||||
List<SewageJobVO> getSewageJobVOList(@Param(Constants.WRAPPER) QueryWrapper<SewageJob> qw); |
||||
|
||||
List<SewageTreeVO> getSewageSendData(@Param(Constants.WRAPPER) QueryWrapper<SewageTreeVO> qw); |
||||
|
||||
String getArea(@Param(value = "fullname") String fullname); |
||||
|
||||
/** |
||||
* 根据任务发布时间查询在这之前的任务,并根据发布时间降序,然后根据limit 取不同数量的值 |
||||
* @param startDate |
||||
* @param limit |
||||
* @return |
||||
*/ |
||||
List<SewageJobVO> querySewageJobByStartDate(@Param("startDate") String startDate, @Param("limit") int limit); |
||||
|
||||
/** |
||||
* 根据任务状态 统计不同状态下的任务数量 |
||||
* @param created 待发布状态 |
||||
* @param publish 已发布状态 |
||||
* @param stopReceive 已停止接收样本状态 |
||||
* @param finished 已完成状态 |
||||
* @return |
||||
*/ |
||||
StatisticsDiffStatusJobDTO statisticsDiffStatusJob(@Param("created") Integer created, |
||||
@Param("publish") Integer publish, |
||||
@Param("stopReceive") Integer stopReceive, |
||||
@Param("finished") Integer finished); |
||||
|
||||
} |
@ -0,0 +1,43 @@ |
||||
package digital.laboratory.platform.sewage.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.baomidou.mybatisplus.core.toolkit.Constants; |
||||
import digital.laboratory.platform.sewage.vo.SewageTreatmentPlantVO; |
||||
import digital.laboratory.platform.sewage.entity.SewageTreatmentPlant; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
import org.apache.ibatis.annotations.Param; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 污水处理厂 Mapper 接口 |
||||
* |
||||
* @author Zhang Xiaolong created at 2022-03-22 |
||||
* @describe 污水处理厂 Mapper 类 |
||||
*/ |
||||
@Mapper |
||||
public interface SewageTreatmentPlantMapper extends BaseMapper<SewageTreatmentPlant> { |
||||
IPage<SewageTreatmentPlantVO> getSewageTreatmentPlantVOPage(@Param("page") IPage<SewageTreatmentPlant> page, @Param(Constants.WRAPPER) QueryWrapper<SewageTreatmentPlant> qw); |
||||
List<SewageTreatmentPlantVO> getSewageTreatmentPlantVOList(@Param(Constants.WRAPPER) QueryWrapper<SewageTreatmentPlant> qw); |
||||
|
||||
SewageTreatmentPlantVO getSewageTreatmentPlantGABVOOne(@Param(Constants.WRAPPER) QueryWrapper<SewageTreatmentPlant> qw); |
||||
|
||||
List<SewageTreatmentPlantVO> getSewageTreatmentPlantGABVOList(@Param(Constants.WRAPPER) QueryWrapper<SewageTreatmentPlant> qw); |
||||
|
||||
/*** |
||||
* 根据id 更新污水厂编号,这里因为excel上的污水厂编号和从公安部平台同步下来的污水厂编号不一致 |
||||
* @param number |
||||
* @param id |
||||
* @return |
||||
*/ |
||||
int updateSewageTreatmentPlantGABNumber(@Param("number") String number, @Param("id") String id); |
||||
|
||||
/** |
||||
* 新增公安部大数据平台的污水厂 |
||||
* @param sewageTreatmentPlant |
||||
* @return |
||||
*/ |
||||
int insertSewageTreatmentPlantGAB(SewageTreatmentPlant sewageTreatmentPlant); |
||||
} |
@ -0,0 +1,17 @@ |
||||
package digital.laboratory.platform.sewage.properties; |
||||
|
||||
import lombok.Data; |
||||
import org.springframework.boot.context.properties.ConfigurationProperties; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
@Component |
||||
@ConfigurationProperties(prefix = "countrydrugsystem.apipath") |
||||
@Data |
||||
public class ApiPathProperties { |
||||
private String tokenPath; |
||||
private String taskListPath; |
||||
private String receivePath; |
||||
private String closePath; |
||||
private String rejectPath; |
||||
private String returnPath; |
||||
} |
@ -0,0 +1,14 @@ |
||||
package digital.laboratory.platform.sewage.service; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
import digital.laboratory.platform.sewage.entity.SewageImportLog; |
||||
|
||||
/** |
||||
* 污水导入日志服务类 |
||||
* |
||||
* @author Zhang Xiaolong created at 2022-10-06 |
||||
* @describe 污水导入日志 服务类 |
||||
*/ |
||||
public interface SewageImportLogService extends IService<SewageImportLog> { |
||||
|
||||
} |
@ -0,0 +1,56 @@ |
||||
package digital.laboratory.platform.sewage.service; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
import digital.laboratory.platform.common.mybatis.security.service.DLPUser; |
||||
import digital.laboratory.platform.sewage.entity.SewageJobGAB; |
||||
import digital.laboratory.platform.othersys.dto.QueryCondition; |
||||
import digital.laboratory.platform.sewage.vo.SewageJobGABVO; |
||||
import digital.laboratory.platform.sewage.entity.SewageJobIdentificationMaterial; |
||||
import digital.laboratory.platform.sewage.vo.SewageTreeVO; |
||||
import digital.laboratory.platform.sewage.vo.TreeVo; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 污水检测任务服务类 |
||||
* |
||||
* @author Zhang Xiaolong created at 2022-07-26 |
||||
* @describe 污水检测任务 服务类 |
||||
*/ |
||||
public interface SewageJobGABService extends IService<SewageJobGAB> { |
||||
/** |
||||
* 取新的任务号 |
||||
* 前缀为 WS, 加4位 年份, 加1位季度, 加 2 位序号 |
||||
* 格式为: "WS" + jobYear + jobSeason + "nn" |
||||
* 例如: WS2022201 |
||||
* @param jobYear |
||||
* @param jobSeason |
||||
* @return |
||||
*/ |
||||
String getNewJobNo(int jobYear, int jobSeason); |
||||
|
||||
IPage<SewageJobGABVO> getSewageJobGABVOPage(IPage<SewageJobGAB> page, QueryWrapper<SewageJobGAB> qw); |
||||
List<SewageJobGABVO> getSewageJobGABVOList(QueryWrapper<SewageJobGAB> qw); |
||||
|
||||
//查询统计各个污水厂的检材送检,受理情况
|
||||
List<TreeVo> querySewageJcSendData(String jobId, String areaCode, String materialStatus, Integer treeLayer); |
||||
List<SewageTreeVO> querySewageJcSendData(String areaCode, int lv); |
||||
//生成检材
|
||||
Boolean generateSewageMaterial(SewageJobGAB sewageJob); |
||||
|
||||
|
||||
SewageJobIdentificationMaterial querySewageDataOne(String id, DLPUser dlpUser); |
||||
|
||||
boolean getSewageJobDataFromDrugPlatform(QueryCondition queryCondition, DLPUser dlpUser); |
||||
|
||||
boolean receiveSampleList(List<String> ids, DLPUser dlpUser); |
||||
|
||||
boolean closeSample(List<String> ids, String reason, DLPUser dlpUser); |
||||
|
||||
boolean rejectReceiveSample(List<String> ids, String rejectReason, DLPUser dlpUser); |
||||
|
||||
|
||||
boolean returnSample(List<String> ids, String returnReason, DLPUser dlpUser); |
||||
} |
@ -0,0 +1,52 @@ |
||||
package digital.laboratory.platform.sewage.service; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
import digital.laboratory.platform.sewage.dto.SewageJobIdentificationMaterialDTO; |
||||
import digital.laboratory.platform.sewage.entity.SewageJobIdentificationMaterial; |
||||
import digital.laboratory.platform.sewage.vo.SewageJobIdentificationMaterialVO; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 污水任务的检材信息服务类 |
||||
* |
||||
* @author Zhang Xiaolong created at 2022-07-26 |
||||
* @describe 污水任务的检材信息 服务类 |
||||
*/ |
||||
public interface SewageJobIdentificationMaterialService extends IService<SewageJobIdentificationMaterial> { |
||||
/** |
||||
* 取新的检材编号 |
||||
* 前缀为 WJ, 加任务号后7位, 加6位 污水厂地区码, 加2位顺序号 |
||||
* 格式为: "WJ" + jobYear + jobSeason + "nn" + AreaCode + "nn" |
||||
* 例如: WJ2022201 520111 001 |
||||
* @param jobId |
||||
* @param jobItemId |
||||
* @return |
||||
*/ |
||||
String getNewCode(String jobId, String jobItemId); |
||||
|
||||
SewageJobIdentificationMaterialVO getVOById(String id); |
||||
|
||||
IPage<SewageJobIdentificationMaterialVO> getSewageJobIdentificationMaterialVOPage(IPage<SewageJobIdentificationMaterial> page, QueryWrapper<SewageJobIdentificationMaterial> qw); |
||||
List<SewageJobIdentificationMaterialVO> getSewageJobIdentificationMaterialVOList(QueryWrapper<SewageJobIdentificationMaterial> qw); |
||||
|
||||
IPage<SewageJobIdentificationMaterialVO> getSewageJobGABIdentificationMaterialVOPage(IPage<SewageJobIdentificationMaterial> page, QueryWrapper<SewageJobIdentificationMaterial> qw); |
||||
|
||||
List<SewageJobIdentificationMaterialVO> getSewageJobGABIdentificationMaterialVOList(QueryWrapper<SewageJobIdentificationMaterial> qw); |
||||
|
||||
String buildSewageSampleLableContent(String id, String sampleNo) throws Exception; |
||||
|
||||
List<SewageJobIdentificationMaterial> getSewageJobIdentificationMaterialList(List<String> ids); |
||||
//批量送检污水检材
|
||||
List<SewageJobIdentificationMaterial> batchSendMaterial(SewageJobIdentificationMaterialDTO sewageJobIdentificationMaterialDTO); |
||||
//作废污水检材
|
||||
List<SewageJobIdentificationMaterial> cancellationMaterial(List<String> materialIdList, String causeOfCancellation); |
||||
//获取污水送检联系人
|
||||
String getContactsInfo(); |
||||
//获取未签收的检材数量
|
||||
int getSewageMaterialNoSignCount(List<Integer> materialStatus); |
||||
|
||||
SewageJobIdentificationMaterial getByImNo(String imNo); |
||||
} |
@ -0,0 +1,30 @@ |
||||
package digital.laboratory.platform.sewage.service; |
||||
|
||||
import com.alibaba.fastjson.JSONArray; |
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
import digital.laboratory.platform.common.mybatis.security.service.DLPUser; |
||||
import digital.laboratory.platform.sewage.entity.SewageJobIdentificationMaterial; |
||||
import digital.laboratory.platform.sewage.entity.SewageJobItem; |
||||
import digital.laboratory.platform.sewage.vo.SewageJobItemVO; |
||||
import digital.laboratory.platform.sys.entity.SysOrg; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 污水检测任务清单服务类 |
||||
* |
||||
* @author Zhang Xiaolong created at 2022-09-13 |
||||
* @describe 污水检测任务清单 服务类 |
||||
*/ |
||||
public interface SewageJobItemService extends IService<SewageJobItem> { |
||||
IPage<SewageJobItemVO> getSewageJobItemVOPage(IPage<SewageJobItem> page, QueryWrapper<SewageJobItem> qw); |
||||
List<SewageJobItemVO> getSewageJobItemVOList(QueryWrapper<SewageJobItem> qw); |
||||
//批量添加任务项 xy
|
||||
List<SewageJobItem> batchAddJobItemToTask(String taskJobId, SysOrg userOrg, JSONArray sewageTreatmentPlantList, DLPUser dlpUser); |
||||
//获取任务清单项数据列表 xy
|
||||
List<String> getSewageJobItemListByTaskID(String taskId,List<String> areaCodeList); |
||||
//根据污水厂ID获取检材
|
||||
List<SewageJobIdentificationMaterial> getSewageMaterialListByStpId(String taskId, List<String> stpIdList); |
||||
} |
@ -0,0 +1,101 @@ |
||||
package digital.laboratory.platform.sewage.service; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
import digital.laboratory.platform.common.core.util.R; |
||||
import digital.laboratory.platform.common.mybatis.security.service.DLPUser; |
||||
import digital.laboratory.platform.sewage.dto.StatisticsDiffStatusJobDTO; |
||||
import digital.laboratory.platform.sewage.entity.SewageJob; |
||||
import digital.laboratory.platform.sewage.entity.SewageJobIdentificationMaterial; |
||||
import digital.laboratory.platform.sewage.vo.SewageJobVO; |
||||
import digital.laboratory.platform.sewage.vo.SewageTreeVO; |
||||
import digital.laboratory.platform.sewage.vo.TreeVo; |
||||
import digital.laboratory.platform.sys.vo.entrustment.MarkersVO; |
||||
import digital.laboratory.platform.sys.entity.entrustment.Sample; |
||||
import org.springframework.transaction.annotation.Transactional; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* 污水检测任务服务类 |
||||
* |
||||
* @author Zhang Xiaolong created at 2022-07-26 |
||||
* @describe 污水检测任务 服务类 |
||||
*/ |
||||
public interface SewageJobService extends IService<SewageJob> { |
||||
/** |
||||
* 取新的任务号 |
||||
* 前缀为 WS, 加4位 年份, 加1位季度, 加 2 位序号 |
||||
* 格式为: "WS" + jobYear + jobSeason + "nn" |
||||
* 例如: WS2022201 |
||||
* @param jobYear |
||||
* @param jobSeason |
||||
* @return |
||||
*/ |
||||
String getNewJobNo(int jobYear, int jobSeason); |
||||
|
||||
IPage<SewageJobVO> getSewageJobVOPage(IPage<SewageJob> page, QueryWrapper<SewageJob> qw); |
||||
List<SewageJobVO> getSewageJobVOList(QueryWrapper<SewageJob> qw); |
||||
|
||||
//查询统计各个污水厂的检材送检,受理情况
|
||||
List<TreeVo> querySewageJcSendData(String jobId, String areaCode, String materialStatus, Integer treeLayer); |
||||
List<SewageTreeVO> querySewageJcSendData(String areaCode, int lv); |
||||
//生成检材
|
||||
Boolean generateSewageMaterial(SewageJob sewageJob); |
||||
|
||||
String getNewSampleNo(String IdentificationMaterialNo, int sampleSerialNumber); |
||||
|
||||
//撤回任务
|
||||
Boolean undoTask(String taskID); |
||||
|
||||
@Transactional |
||||
boolean LeadIntoJob(List<SewageJobIdentificationMaterial> sewageJobIdentificationMaterialList, Integer year, Integer month, DLPUser dlpUser); |
||||
|
||||
String getDistrictCode(String provinceName, String cityName, String districtName); |
||||
|
||||
String getNumber(String prefix); |
||||
|
||||
/* |
||||
* 查询这个账户(机构)下面所送检且已受理的所有污水检材的数量*/ |
||||
Integer getIMQuantity(String orgId); |
||||
|
||||
/** |
||||
* 查询各个状态下的检材数量 |
||||
* @param orgId |
||||
* @return |
||||
*/ |
||||
abstract List<MarkersVO> getSewageMarkers(String orgId); |
||||
|
||||
Map<String, List> getDetails(DLPUser dlpUser, Integer status); |
||||
|
||||
Integer getImQuantityForAccept(); |
||||
|
||||
IPage<SewageJob> getJobAndMaterialPage(Page page, Integer status, String keywords); |
||||
|
||||
/** |
||||
* 根据任务状态 统计不同状态下的任务数量 |
||||
* @return |
||||
*/ |
||||
R<StatisticsDiffStatusJobDTO> statisticsDiffStatusJob(); |
||||
|
||||
/** |
||||
* 根据任务发布时间查询在这之前的任务,并根据发布时间降序,然后根据limit 取不同数量的值 |
||||
* @param startDate |
||||
* @param limit |
||||
* @return |
||||
*/ |
||||
R<List<SewageJobVO>> querySewageJobByStartDate(String startDate, int limit); |
||||
|
||||
/** |
||||
* 根据污水检材创建样本 |
||||
* @param sewageJobIdentificationMaterial |
||||
* |
||||
* @return |
||||
*/ |
||||
List<Sample> createSample(SewageJobIdentificationMaterial sewageJobIdentificationMaterial, String dlpUserId); |
||||
|
||||
List<Sample> createSample(List<SewageJobIdentificationMaterial> sewageJobIdentificationMaterialList, String dlpUserId); |
||||
} |
@ -0,0 +1,24 @@ |
||||
package digital.laboratory.platform.sewage.service; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
import digital.laboratory.platform.sewage.vo.SewageTreatmentPlantVO; |
||||
import digital.laboratory.platform.sewage.entity.SewageTreatmentPlant; |
||||
import digital.laboratory.platform.sewage.vo.TreeVo; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 污水处理厂服务类 |
||||
* |
||||
* @author Zhang Xiaolong created at 2022-03-22 |
||||
* @describe 污水处理厂服务类 |
||||
*/ |
||||
public interface SewageTreatmentPlantService extends IService<SewageTreatmentPlant> { |
||||
IPage<SewageTreatmentPlantVO> getSewageTreatmentPlantVOPage(IPage<SewageTreatmentPlant> page, QueryWrapper<SewageTreatmentPlant> qw); |
||||
List<SewageTreatmentPlantVO> getSewageTreatmentPlantVOList(QueryWrapper<SewageTreatmentPlant> qw); |
||||
//按行政区划获取污水厂的树形结构
|
||||
TreeVo getSewageTreatmentTreeList(String parentId); |
||||
List<TreeVo> getThreeAreaTreeData(); |
||||
} |
@ -0,0 +1,26 @@ |
||||
package digital.laboratory.platform.sewage.service; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
import com.fasterxml.jackson.core.JsonProcessingException; |
||||
import digital.laboratory.platform.othersys.vo.SynConnInfoVo; |
||||
|
||||
|
||||
/** |
||||
* @ClassName SynchronizeDataService |
||||
* @Description 第三方数据同步服务 |
||||
* @Author xy |
||||
* @Date 2023/6/13 11:00 |
||||
* @Version 1.0 |
||||
**/ |
||||
public interface SynchronizeDataService{ |
||||
|
||||
|
||||
// 获取系统配置
|
||||
SynConnInfoVo getSysSynConnInfo(); |
||||
|
||||
// 获取token 信息
|
||||
String getTokenInfo(String whoUse, SynConnInfoVo synConnInfoVo); |
||||
|
||||
|
||||
|
||||
} |
@ -0,0 +1,18 @@ |
||||
package digital.laboratory.platform.sewage.service.impl; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import digital.laboratory.platform.sewage.entity.SewageImportLog; |
||||
import digital.laboratory.platform.sewage.mapper.SewageImportLogMapper; |
||||
import digital.laboratory.platform.sewage.service.SewageImportLogService; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
/** |
||||
* 污水导入日志服务实现类 |
||||
* |
||||
* @author Zhang Xiaolong created at 2022-10-06 |
||||
* @describe 污水导入日志 服务实现类 |
||||
*/ |
||||
@Service |
||||
public class SewageImportLogServiceImpl extends ServiceImpl<SewageImportLogMapper, SewageImportLog> implements SewageImportLogService { |
||||
|
||||
} |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,279 @@ |
||||
package digital.laboratory.platform.sewage.service.impl; |
||||
|
||||
import cn.hutool.core.util.StrUtil; |
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import digital.laboratory.platform.common.core.constant.CommonConstants; |
||||
import digital.laboratory.platform.common.feign.RemoteTemplate2htmlService; |
||||
import digital.laboratory.platform.common.mybatis.security.service.DLPUser; |
||||
import digital.laboratory.platform.sewage.dto.SewageJobIdentificationMaterialDTO; |
||||
import digital.laboratory.platform.sewage.service.SewageJobIdentificationMaterialService; |
||||
import digital.laboratory.platform.sewage.service.SewageTreatmentPlantService; |
||||
import digital.laboratory.platform.sewage.entity.SewageJobItem; |
||||
import digital.laboratory.platform.sewage.handler.AppStartupRunner; |
||||
import digital.laboratory.platform.sewage.mapper.SewageJobIdentificationMaterialMapper; |
||||
import digital.laboratory.platform.sewage.service.SewageJobItemService; |
||||
import digital.laboratory.platform.sewage.service.SewageJobService; |
||||
import digital.laboratory.platform.sewage.entity.SewageJob; |
||||
import digital.laboratory.platform.sewage.entity.SewageJobIdentificationMaterial; |
||||
import digital.laboratory.platform.sewage.entity.SewageTreatmentPlant; |
||||
import digital.laboratory.platform.sys.entity.SysOrg; |
||||
import digital.laboratory.platform.sewage.vo.SewageJobIdentificationMaterialVO; |
||||
import lombok.RequiredArgsConstructor; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.util.ArrayList; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* 污水任务的检材信息服务实现类 |
||||
* |
||||
* @author Zhang Xiaolong created at 2022-07-26 |
||||
* @describe 污水任务的检材信息 服务实现类 |
||||
*/ |
||||
@RequiredArgsConstructor |
||||
@Service |
||||
public class SewageJobIdentificationMaterialServiceImpl extends ServiceImpl<SewageJobIdentificationMaterialMapper, SewageJobIdentificationMaterial> implements SewageJobIdentificationMaterialService { |
||||
@Resource |
||||
private SewageJobService sewageJobService; |
||||
@Resource |
||||
private SewageJobItemService sewageJobItemService; |
||||
@Resource |
||||
private SewageTreatmentPlantService sewageTreatmentPlantService; |
||||
|
||||
private final RemoteTemplate2htmlService remoteTemplate2htmlService; |
||||
|
||||
|
||||
/** |
||||
* 取新的检材编号 |
||||
* 前缀为 WJ, 加任务号后7位, 加6位 污水厂地区码, 加2位顺序号 |
||||
* 格式为: "WJ" + jobYear + jobSeason + "nn" + AreaCode + "nn" |
||||
* 例如: WJ2022201 520111 001 |
||||
* |
||||
* @param jobId |
||||
* @param jobItemId |
||||
* @return |
||||
*/ |
||||
@Override |
||||
public String getNewCode(String jobId, String jobItemId) { |
||||
SewageJob sj = sewageJobService.getById(jobId); |
||||
if (sj == null) { |
||||
throw new RuntimeException("这个检材对应的污水任务没有查询到"); |
||||
} |
||||
String jobNo = sj.getJobNo(); |
||||
if (StrUtil.isBlank(jobNo)) { |
||||
throw new RuntimeException("这个检材对应的污水任务的任务编号为空, 无法为检材生成编号"); |
||||
} |
||||
String prefix = CommonConstants.CODE_PREFIX_SEWAGE_IDENTIFICATION_MATERIAL + StrUtil.removePrefixIgnoreCase(jobNo, CommonConstants.CODE_PREFIX_SEWAGE_JOB); |
||||
//-- 到这里, prefix 中包含 WJ + 任务号后7位
|
||||
|
||||
|
||||
SewageJobItem sji = sewageJobItemService.getById(jobItemId); |
||||
if (sji == null) { |
||||
throw new RuntimeException("这个检材对应的污水任务清单项没有查询到"); |
||||
} |
||||
SewageTreatmentPlant stp = sewageTreatmentPlantService.getById(sji.getPlantId()); |
||||
if (stp == null) { |
||||
throw new RuntimeException("这个检材对应的污水任务清单项的污水处理厂没有查询到"); |
||||
} |
||||
|
||||
prefix = prefix + stp.getDistrictCode(); // 前缀 = "WJ" + <纯任务号> + 地区码
|
||||
|
||||
List<SewageJobIdentificationMaterial> list = this.list(Wrappers.<SewageJobIdentificationMaterial>query() |
||||
.likeRight("im_no", prefix) // LIKE '值%'
|
||||
.orderByDesc("im_no") |
||||
); |
||||
|
||||
int newNo = 1; |
||||
if ((list != null) && (list.size() > 0)) { |
||||
SewageJobIdentificationMaterial sjimMax = list.get(0); |
||||
String strMaxNo = StrUtil.removePrefixIgnoreCase(sjimMax.getImNo(), prefix); |
||||
try { |
||||
int maxno = Integer.parseUnsignedInt(strMaxNo); |
||||
newNo = maxno + 1; |
||||
} catch (NumberFormatException e) { |
||||
// 如果后缀有非数字, 则无视之, 重头编码
|
||||
newNo = 1; |
||||
} |
||||
} |
||||
|
||||
String newCode = prefix + String.format("%02d", newNo); |
||||
|
||||
return newCode; |
||||
} |
||||
|
||||
@Override |
||||
public SewageJobIdentificationMaterialVO getVOById(String id) { |
||||
List<SewageJobIdentificationMaterialVO> list = this.getSewageJobIdentificationMaterialVOList(Wrappers.<SewageJobIdentificationMaterial>query() |
||||
.eq("sjim.id", id) |
||||
); |
||||
if (list.size() == 1) { |
||||
return list.get(0); |
||||
} else if (list.size() == 0) { |
||||
throw new RuntimeException(String.format("没有找到指定的污水检材, id=%s", id)); |
||||
} else { |
||||
throw new RuntimeException(String.format("找到多个 id 相同的污水检材, id=%s", id)); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public IPage<SewageJobIdentificationMaterialVO> getSewageJobIdentificationMaterialVOPage(IPage<SewageJobIdentificationMaterial> page, QueryWrapper<SewageJobIdentificationMaterial> qw) { |
||||
IPage<SewageJobIdentificationMaterialVO> r = baseMapper.getSewageJobIdentificationMaterialVOPage(page, qw); |
||||
return r; |
||||
} |
||||
|
||||
@Override |
||||
public List<SewageJobIdentificationMaterialVO> getSewageJobIdentificationMaterialVOList(QueryWrapper<SewageJobIdentificationMaterial> qw) { |
||||
List<SewageJobIdentificationMaterialVO> list = baseMapper.getSewageJobIdentificationMaterialVOList(qw); |
||||
return list; |
||||
} |
||||
|
||||
@Override |
||||
public IPage<SewageJobIdentificationMaterialVO> getSewageJobGABIdentificationMaterialVOPage(IPage<SewageJobIdentificationMaterial> page, QueryWrapper<SewageJobIdentificationMaterial> qw) { |
||||
IPage<SewageJobIdentificationMaterialVO> r = baseMapper.getSewageJobGABIdentificationMaterialVOPage(page, qw); |
||||
return r; |
||||
} |
||||
|
||||
@Override |
||||
public List<SewageJobIdentificationMaterialVO> getSewageJobGABIdentificationMaterialVOList(QueryWrapper<SewageJobIdentificationMaterial> qw) { |
||||
List<SewageJobIdentificationMaterialVO> list = baseMapper.getSewageJobGABIdentificationMaterialVOList(qw); |
||||
return list; |
||||
} |
||||
|
||||
@Override |
||||
public String buildSewageSampleLableContent(String id, String sampleNo) throws Exception { |
||||
SewageJobIdentificationMaterial sewageJobIdentificationMaterial = this.getById(id); |
||||
if (sewageJobIdentificationMaterial == null) { |
||||
throw new RuntimeException(String.format("没有找到 id 为 %s 的检材", id)); |
||||
} |
||||
Map<String, Object> data = new HashMap<>(); |
||||
data.put("sewageJobIdentificationMaterial", sewageJobIdentificationMaterial); |
||||
if (StrUtil.isNotBlank(sampleNo)) { |
||||
if (StrUtil.equals(sampleNo, "1")) { |
||||
data.put("sampleNo", sewageJobIdentificationMaterial.getSample1No()); |
||||
} |
||||
if (StrUtil.equals(sampleNo, "2")) { |
||||
data.put("sampleNo", sewageJobIdentificationMaterial.getSample2No()); |
||||
} |
||||
String templateFileName = AppStartupRunner.getCfg(CommonConstants.DLP_CODE_SEWAGE_JOB_IDENTIFICATION_MATERIAL_SAMPLE_LABEL); |
||||
return remoteTemplate2htmlService.getHtml(templateFileName, data); |
||||
} else { |
||||
String templateFileName = AppStartupRunner.getCfg(CommonConstants.DLP_CODE_SEWAGE_JOB_IDENTIFICATION_MATERIAL_LABEL); |
||||
return remoteTemplate2htmlService.getHtml(templateFileName, data); |
||||
} |
||||
} |
||||
|
||||
|
||||
@Override |
||||
public List<SewageJobIdentificationMaterial> getSewageJobIdentificationMaterialList(List<String> ids) { |
||||
return this.list(Wrappers.<SewageJobIdentificationMaterial>query().in("id", ids)); |
||||
} |
||||
|
||||
/** |
||||
* 批量送检污水检材 |
||||
* |
||||
* @param materialDTO |
||||
* @return |
||||
*/ |
||||
@Override |
||||
public List<SewageJobIdentificationMaterial> batchSendMaterial(SewageJobIdentificationMaterialDTO materialDTO/*,int userLv,DLPUser dlpUser,SysOrg userOrg*/) { |
||||
List<String> materialIdList = materialDTO.getIds(); |
||||
String expressNumber = materialDTO.getExpressNumber(); |
||||
String expressCompany = materialDTO.getExpressCompany(); |
||||
String sendType = materialDTO.getDeliverMethod(); |
||||
List<SewageJobIdentificationMaterial> materialList = this.list(Wrappers.<SewageJobIdentificationMaterial>query() |
||||
.in("id", materialIdList)); |
||||
materialList.forEach(item -> { |
||||
//StringUtils.isNotBlank(checkOptOk(userLv,item,dlpUser,));
|
||||
item.setStatus(2); |
||||
item.setDeliverMethod(sendType); |
||||
if (sendType.equals("2")) { |
||||
//如果送检方式是快递,则填写快递公司和快递单号
|
||||
item.setExpressCompany(expressCompany); |
||||
item.setExpressNumber(expressNumber); |
||||
} |
||||
if (sendType.equals("1")) { |
||||
//则需要填写送检人信息
|
||||
item.setDelivererName(materialDTO.getDelivererName()); |
||||
item.setDelivererPhone(materialDTO.getDelivererPhone()); |
||||
item.setDelivererCert(materialDTO.getDelivererCert()); |
||||
item.setDelivererId(materialDTO.getDelivererId()); |
||||
} |
||||
}); |
||||
if (this.updateBatchById(materialList)) { |
||||
return materialList; |
||||
} else { |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
//作废污水检材
|
||||
@Override |
||||
public List<SewageJobIdentificationMaterial> cancellationMaterial(List<String> materialIdList, String causeOfCancellation) { |
||||
//
|
||||
List<SewageJobIdentificationMaterial> materialBeanList = this.list(Wrappers.<SewageJobIdentificationMaterial>query() |
||||
.in("id", materialIdList)); |
||||
materialBeanList.forEach(item -> { |
||||
item.setStatus(-2); |
||||
item.setCauseOfCancellation(causeOfCancellation); |
||||
}); |
||||
this.updateBatchById(materialBeanList); |
||||
return materialBeanList; |
||||
} |
||||
|
||||
//获取送检联系人信息
|
||||
@Override |
||||
public String getContactsInfo() { |
||||
|
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public int getSewageMaterialNoSignCount(List<Integer> materialStatus) { |
||||
return this.list(Wrappers.<SewageJobIdentificationMaterial>query() |
||||
.in("status", materialStatus)).size(); |
||||
} |
||||
|
||||
//判断是否有符合操作
|
||||
private String checkOptOk(int userLevel, SewageJobIdentificationMaterial sewageJobIdentificationMaterial, |
||||
DLPUser dlpUser, SewageTreatmentPlant stp, SysOrg userOrg) { |
||||
if (userLevel == 3) { |
||||
// 区县一级的机构码必须完全一致
|
||||
if (!StrUtil.equals(sewageJobIdentificationMaterial.getDeliverOrgId(), dlpUser.getOrgId())) { |
||||
return String.format("你没有权限修改这个检材, id=%s", sewageJobIdentificationMaterial.getId()); |
||||
} |
||||
} else if (userLevel == 2) { |
||||
// 市一级要确认是送检机构的上级
|
||||
if (!StrUtil.equalsIgnoreCase(stp.getCityCode(), userOrg.getAreaCode())) { |
||||
return String.format("你没有权限修改这个检材, id=%s", sewageJobIdentificationMaterial.getId()); |
||||
} |
||||
} else if (userLevel == 1) { |
||||
// 省一级要确认是送检机构的上级的上级
|
||||
if (!StrUtil.equalsIgnoreCase(stp.getProvinceCode(), userOrg.getAreaCode())) { |
||||
return String.format("你没有权限修改这个检材, id=%s", sewageJobIdentificationMaterial.getId()); |
||||
} |
||||
} |
||||
return ""; |
||||
} |
||||
|
||||
@Override//通过样品编号查询污水检材信息
|
||||
public SewageJobIdentificationMaterial getByImNo(String imNo) { |
||||
List<SewageJobIdentificationMaterialVO> list = new ArrayList<>(); |
||||
//公安部污水检材的编号是以H开头的,所以我们要分开查询
|
||||
if (imNo.startsWith("H")) { |
||||
list = baseMapper.getByImNoGAB(imNo); |
||||
} else { |
||||
list = baseMapper.getByImNo(imNo); |
||||
} |
||||
if (list.size() == 1) { |
||||
return list.get(0); |
||||
} else return null; |
||||
} |
||||
} |
||||
|
||||
|
@ -0,0 +1,173 @@ |
||||
package digital.laboratory.platform.sewage.service.impl; |
||||
|
||||
import cn.hutool.core.util.StrUtil; |
||||
import com.alibaba.fastjson.JSONArray; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker; |
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import digital.laboratory.platform.common.mybatis.security.service.DLPUser; |
||||
import digital.laboratory.platform.sewage.entity.SewageJob; |
||||
import digital.laboratory.platform.sewage.entity.SewageJobIdentificationMaterial; |
||||
import digital.laboratory.platform.sewage.entity.SewageTreatmentPlant; |
||||
import digital.laboratory.platform.sewage.entity.*; |
||||
import digital.laboratory.platform.sewage.service.SewageJobIdentificationMaterialService; |
||||
import digital.laboratory.platform.sewage.service.SewageTreatmentPlantService; |
||||
import digital.laboratory.platform.sewage.mapper.SewageJobItemMapper; |
||||
import digital.laboratory.platform.sewage.service.SewageJobItemService; |
||||
import digital.laboratory.platform.sewage.service.SewageJobService; |
||||
import digital.laboratory.platform.sewage.vo.SewageJobItemVO; |
||||
import digital.laboratory.platform.sys.entity.SysOrg; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.util.ArrayList; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* 污水检测任务清单服务实现类 |
||||
* |
||||
* @author Zhang Xiaolong created at 2022-09-13 |
||||
* @describe 污水检测任务清单 服务实现类 |
||||
*/ |
||||
@Service |
||||
public class SewageJobItemServiceImpl extends ServiceImpl<SewageJobItemMapper, SewageJobItem> implements SewageJobItemService { |
||||
@Resource |
||||
SewageJobService sewageJobService; |
||||
@Resource |
||||
SewageTreatmentPlantService sewageTreatmentPlantService; |
||||
@Resource |
||||
SewageJobIdentificationMaterialService sewageJobIdentificationMaterialService; |
||||
@Override |
||||
public IPage<SewageJobItemVO> getSewageJobItemVOPage(IPage<SewageJobItem> page, QueryWrapper<SewageJobItem> qw) { |
||||
IPage<SewageJobItemVO> r =baseMapper.getSewageJobItemVOPage(page, qw); |
||||
return r; |
||||
} |
||||
|
||||
@Override |
||||
public List<SewageJobItemVO> getSewageJobItemVOList(QueryWrapper<SewageJobItem> qw) { |
||||
List<SewageJobItemVO> list = baseMapper.getSewageJobItemVOList(qw); |
||||
return list; |
||||
} |
||||
|
||||
@Override |
||||
public List<SewageJobIdentificationMaterial> getSewageMaterialListByStpId(String taskId, List<String> stpIdList) { |
||||
List<SewageJobItem> itemList=this.list(Wrappers.<SewageJobItem>query() |
||||
.in(stpIdList.size()>0,"plant_id",stpIdList) |
||||
.eq("job_id",taskId)); |
||||
//
|
||||
List<String> itemIdList=new ArrayList<>(); |
||||
itemList.forEach(item->{ |
||||
itemIdList.add(item.getId()); |
||||
}); |
||||
List<SewageJobIdentificationMaterial> materialList=sewageJobIdentificationMaterialService |
||||
.list(Wrappers.<SewageJobIdentificationMaterial>query() |
||||
.eq("job_id",taskId) |
||||
.in(itemIdList.size()>0,"job_item_id",itemIdList)); |
||||
|
||||
return materialList; |
||||
} |
||||
|
||||
//根据任务ID获取任务清单项
|
||||
@Override |
||||
public List<String> getSewageJobItemListByTaskID(String taskId,List<String> areaCodeList) { |
||||
SewageJob sewageJob = sewageJobService.getById(taskId); |
||||
|
||||
List<SewageJobItem> sewageJobItemList=this.list(Wrappers.<SewageJobItem>query() |
||||
.eq("job_id",sewageJob.getId())); |
||||
List<String> stpIds=new ArrayList<>(); |
||||
sewageJobItemList.forEach(item->{ |
||||
stpIds.add(item.getPlantId()); |
||||
}); |
||||
//已选
|
||||
List<SewageTreatmentPlant> stpObjSelectedList=new ArrayList<>(); |
||||
//总的厂数量
|
||||
List<SewageTreatmentPlant> stpObjUnSelectedList=new ArrayList<>(); |
||||
if(stpIds.size()>0){ |
||||
stpObjSelectedList=sewageTreatmentPlantService.list(Wrappers.<SewageTreatmentPlant>query() |
||||
.in(stpIds.size()>0,"id",stpIds)); |
||||
stpObjUnSelectedList=sewageTreatmentPlantService.list(Wrappers.<SewageTreatmentPlant>query() |
||||
.notIn(stpIds.size()>0,"id",stpIds) |
||||
.in(areaCodeList.size()>0,"district_code",areaCodeList)); |
||||
}else { |
||||
stpObjUnSelectedList=sewageTreatmentPlantService.list(Wrappers.<SewageTreatmentPlant>query() |
||||
.in(areaCodeList.size()>0,"district_code",areaCodeList)); |
||||
} |
||||
String dataString1=JSONArray.toJSONString(stpObjSelectedList); |
||||
String dataString2=JSONArray.toJSONString(stpObjUnSelectedList); |
||||
String dataAreaString=sewageJob.getSewageAreaList(); |
||||
List<String> retData=new ArrayList<>(); |
||||
retData.add(dataAreaString); |
||||
retData.add(dataString1); |
||||
retData.add(dataString2); |
||||
return retData; |
||||
} |
||||
/** |
||||
* 批量添加清单项 |
||||
* @param taskJobId |
||||
* @param sewageTreatmentPlantList |
||||
* @return |
||||
* @author:xy |
||||
* @date:23-0701 |
||||
*/ |
||||
@Override |
||||
public List<SewageJobItem> batchAddJobItemToTask(String taskJobId, SysOrg userOrg, JSONArray sewageTreatmentPlantList, DLPUser dlpUser) { |
||||
List<SewageJobItem> thisTimeItemList = new ArrayList<SewageJobItem>();//存储本次任务清单项
|
||||
Map<String, List<String>> sewageAreaHashMap= new HashMap<String, List<String>>();//区域
|
||||
//构造本次提交的清单项
|
||||
sewageTreatmentPlantList.forEach(item->{ |
||||
JSONObject stpObject=JSONObject.parseObject(item.toString()); |
||||
String stpID=stpObject.getString("stpId"); |
||||
String provinceCode=stpObject.getString("provinceCode"); |
||||
String cityCode=stpObject.getString("cityCode"); |
||||
String districtCode=stpObject.getString("districtCode"); |
||||
String stpName=stpObject.getString("stpName"); |
||||
//判断如果不是分中心员工,则需要判断是否在管辖范围内
|
||||
if (!dlpUser.isStaff()) { |
||||
if (!(StrUtil.equals(userOrg.getAreaCode(), provinceCode) |
||||
|| StrUtil.equals(userOrg.getAreaCode(),cityCode) |
||||
|| StrUtil.equals(userOrg.getAreaCode(), districtCode) |
||||
)) |
||||
{ |
||||
throw new RuntimeException(String.format("[%s]不在你管辖范围内,你没有权限添加到任务清单中", stpName)); |
||||
} |
||||
} |
||||
//构建清单项
|
||||
SewageJobItem eg = new SewageJobItem(); |
||||
eg.setId(IdWorker.get32UUID().toUpperCase()); |
||||
eg.setJobId(taskJobId); |
||||
eg.setCreateByOrgLevel(userOrg.getOrgLevel()); |
||||
eg.setPlantId(stpID); |
||||
eg.setComments("1"); |
||||
thisTimeItemList.add(eg); |
||||
//设置任务的区域数据
|
||||
String haskKey=provinceCode+"-"+cityCode+"-"+districtCode; |
||||
List<String> areaCodeValue=new ArrayList<>(); |
||||
areaCodeValue.add(provinceCode); |
||||
areaCodeValue.add(cityCode); |
||||
areaCodeValue.add(districtCode); |
||||
sewageAreaHashMap.put(haskKey,areaCodeValue); |
||||
}); |
||||
//根据任务ID判断是否有历史清单
|
||||
List<SewageJobItem> historyItemList=this.list(Wrappers.<SewageJobItem>query() |
||||
.eq("job_id",taskJobId)); |
||||
if(historyItemList.size()>0){ |
||||
this.removeBatchByIds(historyItemList);//如果有就删除
|
||||
} |
||||
this.saveBatch(thisTimeItemList);//保存清单项
|
||||
//添加之后,更新任务的区域列表
|
||||
List<List<String>> taskAreaList=new ArrayList<List<String>>(); |
||||
sewageAreaHashMap.forEach((k,v)->{ |
||||
taskAreaList.add(v); |
||||
}); |
||||
//持久化到数据库
|
||||
SewageJob sjob=sewageJobService.getById(taskJobId); |
||||
sjob.setSewageAreaList(JSONArray.toJSONString(taskAreaList)); |
||||
sewageJobService.updateById(sjob); |
||||
return thisTimeItemList; |
||||
} |
||||
} |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,106 @@ |
||||
package digital.laboratory.platform.sewage.service.impl; |
||||
|
||||
import cn.hutool.core.lang.tree.TreeNode; |
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import digital.laboratory.platform.sewage.utils.QRCodeUtils; |
||||
import digital.laboratory.platform.sewage.mapper.SewageTreatmentPlantMapper; |
||||
import digital.laboratory.platform.sewage.service.SewageJobService; |
||||
import digital.laboratory.platform.sewage.service.SewageTreatmentPlantService; |
||||
import digital.laboratory.platform.sewage.vo.SewageTreatmentPlantVO; |
||||
import digital.laboratory.platform.sewage.entity.SewageTreatmentPlant; |
||||
import digital.laboratory.platform.sewage.vo.SewageTreeVO; |
||||
import digital.laboratory.platform.sewage.vo.TreeVo; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.util.*; |
||||
import java.util.function.Function; |
||||
|
||||
/** |
||||
* 污水处理厂服务实现类 |
||||
* |
||||
* @author Zhang Xiaolong created at 2022-03-22 |
||||
* @describe 污水处理厂服务实现类 |
||||
*/ |
||||
@Service |
||||
public class SewageTreatmentPlantServiceImpl extends ServiceImpl<SewageTreatmentPlantMapper, SewageTreatmentPlant> implements SewageTreatmentPlantService { |
||||
@Resource |
||||
private SewageJobService sewageJobService; |
||||
@Override |
||||
public IPage<SewageTreatmentPlantVO> getSewageTreatmentPlantVOPage(IPage<SewageTreatmentPlant> page, QueryWrapper<SewageTreatmentPlant> qw) { |
||||
IPage<SewageTreatmentPlantVO> r =baseMapper.getSewageTreatmentPlantVOPage(page, qw); |
||||
return r; |
||||
} |
||||
|
||||
@Override |
||||
public List<SewageTreatmentPlantVO> getSewageTreatmentPlantVOList(QueryWrapper<SewageTreatmentPlant> qw) { |
||||
List<SewageTreatmentPlantVO> list = baseMapper.getSewageTreatmentPlantVOList(qw); |
||||
return list; |
||||
} |
||||
|
||||
@Override |
||||
public List<TreeVo> getThreeAreaTreeData() { |
||||
List<SewageTreatmentPlant> list=this.list(); |
||||
|
||||
return QRCodeUtils.buildThreeGrade(list); |
||||
} |
||||
|
||||
@Override |
||||
public TreeVo getSewageTreatmentTreeList(String areaCode) { |
||||
//检查这个areaCode是省,还是市,还是县
|
||||
int lv=0; |
||||
List<SewageTreatmentPlant> sewageTreatmentPlantList=new ArrayList<>(); |
||||
List<SewageTreeVO> treeInitData=new ArrayList<>(); |
||||
String parentNodeName=""; |
||||
|
||||
|
||||
if(areaCode.equals("0")) |
||||
{ |
||||
treeInitData=sewageJobService.querySewageJcSendData(areaCode,0);//查询全部
|
||||
}else if(areaCode.endsWith("0000")) |
||||
{ |
||||
lv=1;//省级
|
||||
treeInitData=sewageJobService.querySewageJcSendData(areaCode,1);//查询省的数据
|
||||
}else if(areaCode.endsWith("00")) |
||||
{ |
||||
lv=2;//市级
|
||||
treeInitData=sewageJobService.querySewageJcSendData(areaCode,2);//查询市的数据
|
||||
}else if(!areaCode.endsWith("00")) |
||||
{ |
||||
lv=3;//县级
|
||||
treeInitData=sewageJobService.querySewageJcSendData(areaCode,3);//查询县的数据
|
||||
} |
||||
|
||||
return QRCodeUtils.buildTreeDataByList(treeInitData,lv); |
||||
} |
||||
private Function<SewageTreatmentPlant, TreeNode<String>> getNodeFunction(int lv) { |
||||
return Obj -> { |
||||
// 扩展属性
|
||||
Map<String, Object> extra = new HashMap<>(); |
||||
|
||||
TreeNode<String> node = new TreeNode<>(); |
||||
node.setId(Obj.getId()); |
||||
if(lv==0){ |
||||
node.setParentId("root"); |
||||
node.setName(Obj.getProvinceName()); |
||||
extra.put("label", Obj.getProvinceName()); |
||||
extra.put("areaCode", Obj.getProvinceCode()); |
||||
}else if(lv==1){ |
||||
node.setParentId(Obj.getProvinceCode()); |
||||
node.setName(Obj.getCityName()); |
||||
extra.put("label", Obj.getCityName()); |
||||
extra.put("areaCode", Obj.getCityCode()); |
||||
}else if(lv==2){ |
||||
node.setParentId(Obj.getCityCode()); |
||||
node.setName(Obj.getDistrictName()); |
||||
extra.put("label", Obj.getDistrictName()); |
||||
extra.put("areaCode", Obj.getDistrictCode()); |
||||
} |
||||
node.setExtra(extra); |
||||
return node; |
||||
}; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,317 @@ |
||||
package digital.laboratory.platform.sewage.service.impl; |
||||
|
||||
import cn.hutool.core.lang.tree.Tree; |
||||
import cn.hutool.core.lang.tree.TreeNode; |
||||
import cn.hutool.core.lang.tree.TreeUtil; |
||||
import digital.laboratory.platform.common.core.constant.CommonConstants; |
||||
import digital.laboratory.platform.common.core.util.R; |
||||
import digital.laboratory.platform.othersys.utils.HttpsUtils; |
||||
import digital.laboratory.platform.othersys.vo.*; |
||||
import digital.laboratory.platform.sewage.service.SynchronizeDataService; |
||||
import digital.laboratory.platform.sys.entity.Dictionary; |
||||
import digital.laboratory.platform.sys.entity.DrugLite; |
||||
import digital.laboratory.platform.sys.feign.RemoteDictionaryService; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.util.ArrayList; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
import java.util.function.Function; |
||||
import java.util.stream.Collectors; |
||||
|
||||
/** |
||||
* @ClassName SynchronizeDataServiceImpl |
||||
* @Description |
||||
* @Author xy |
||||
* @Date 2023/6/13 11:02 |
||||
* @Version 1.0 |
||||
**/ |
||||
@Slf4j |
||||
@Service |
||||
public class SynchronizeDataServiceImpl implements SynchronizeDataService { |
||||
|
||||
@Resource |
||||
private RemoteDictionaryService remoteDictionaryService;//字典接口
|
||||
|
||||
|
||||
//一些要用到的公共方法--------------------------------------------------------
|
||||
|
||||
/** |
||||
* 获取第三方系统中的配置参数 |
||||
* |
||||
* @return 返回连接的数据结构对象 |
||||
*/ |
||||
@Override |
||||
public SynConnInfoVo getSysSynConnInfo() { |
||||
final SynConnInfoVo synConnInfoVo = new SynConnInfoVo(); |
||||
String parentID = "920f9dd9cd14281e8b488a34c649ff70"; |
||||
List<Dictionary> retDataList = remoteDictionaryService.insideTreeData(parentID); |
||||
List<Tree<String>> treeData = genTreeData(retDataList, parentID); |
||||
if (treeData.size() > 0) { |
||||
treeData.forEach(sourceObj -> { |
||||
if (sourceObj.get("code").equals("tokenFetch"))//如果是token获取
|
||||
{ |
||||
SynConnInfoTokenVo synConnInfoTokenVo = buildTokenInfo(sourceObj.getChildren()); |
||||
synConnInfoVo.setProvinceTokenInfo(synConnInfoTokenVo.getProvinceTokenInfo()); |
||||
synConnInfoVo.setSubCenterTokenInfo(synConnInfoTokenVo.getSubCenterTokenInfo()); |
||||
synConnInfoVo.setTokenInfo(synConnInfoTokenVo); |
||||
} |
||||
if (sourceObj.get("code").equals("dataPath"))//如果是token获取
|
||||
{ |
||||
SynConnInfoDataPathVo synConnInfoDataPathVo = buildDataPath(sourceObj.getChildren()); |
||||
synConnInfoVo.setApiHost(synConnInfoDataPathVo.getApiHost()); |
||||
synConnInfoVo.setDataPathInfo(synConnInfoDataPathVo); |
||||
} |
||||
}); |
||||
|
||||
} else { |
||||
System.out.println("没有获取到连接信息,请检查参数"); |
||||
} |
||||
return synConnInfoVo; |
||||
} |
||||
|
||||
/** |
||||
* 构造token对象信息 |
||||
* |
||||
* @param tokenAbout |
||||
* @return |
||||
*/ |
||||
public SynConnInfoTokenVo buildTokenInfo(List<Tree<String>> tokenAbout) { |
||||
SynConnInfoTokenVo synConnInfoTokenVo = new SynConnInfoTokenVo(); |
||||
tokenAbout.forEach(itemObj -> { |
||||
String retKey = itemObj.get("label").toString(); |
||||
String retValue = itemObj.get("code").toString(); |
||||
String keyID = itemObj.get("id").toString(); |
||||
switch (retKey) { |
||||
case "sx_sub_center_token": |
||||
synConnInfoTokenVo.setSubCenterTokenInfo(retValue); |
||||
synConnInfoTokenVo.setSubCenterTokenID(keyID); |
||||
break; |
||||
case "sx_province_token": |
||||
synConnInfoTokenVo.setProvinceTokenInfo(retValue); |
||||
synConnInfoTokenVo.setProvinceTokenID(keyID); |
||||
break; |
||||
case "accessKey": |
||||
synConnInfoTokenVo.setAccessSubCenterKey(retValue); |
||||
break; |
||||
case "accessSecret": |
||||
synConnInfoTokenVo.setAccessSubCenterSecret(retValue); |
||||
break; |
||||
case "accessProvinceKey": |
||||
synConnInfoTokenVo.setAccessProvinceKey(retValue); |
||||
break; |
||||
case "accessProvinceSecret": |
||||
synConnInfoTokenVo.setAccessProvinceSecret(retValue); |
||||
break; |
||||
} |
||||
}); |
||||
return synConnInfoTokenVo; |
||||
} |
||||
//
|
||||
|
||||
/** |
||||
* 构建数据路径信息 |
||||
* |
||||
* @param dataPathAbout |
||||
* @return |
||||
*/ |
||||
public SynConnInfoDataPathVo buildDataPath(List<Tree<String>> dataPathAbout) { |
||||
SynConnInfoDataPathVo synConnInfoDataPathVo = new SynConnInfoDataPathVo(); |
||||
dataPathAbout.forEach(itemObj -> { |
||||
String retKey = itemObj.get("label").toString(); |
||||
String retValue = itemObj.get("code").toString(); |
||||
switch (retKey) { |
||||
case "ApiHost": |
||||
synConnInfoDataPathVo.setApiHost(retValue); |
||||
break; |
||||
case "tokenPath": |
||||
synConnInfoDataPathVo.setTokenPath(retValue); |
||||
break; |
||||
case "entrustDataPath": |
||||
synConnInfoDataPathVo.setEntrustDataPath(retValue); |
||||
break; |
||||
case "wtsStatus": |
||||
synConnInfoDataPathVo.setWtsStatus(retValue); |
||||
break; |
||||
case "uploadSewageJobDataPath": |
||||
synConnInfoDataPathVo.setUploadSewageJobDataUrl(retValue); |
||||
break; |
||||
case "province_audit_url": |
||||
synConnInfoDataPathVo.setProvinceAuditUrl(retValue); |
||||
break; |
||||
case "sx_subcenter_audit_url": |
||||
synConnInfoDataPathVo.setSxSubCenterAuditUrl(retValue); |
||||
break; |
||||
case "sx_subcenter_accept_url": |
||||
synConnInfoDataPathVo.setSxSubCenterAcceptUrl(retValue); |
||||
break; |
||||
} |
||||
}); |
||||
return synConnInfoDataPathVo; |
||||
} |
||||
|
||||
//根据数组返回一个树形结构
|
||||
public List<Tree<String>> genTreeData(List<Dictionary> dictionaryList, String parentID) { |
||||
List<TreeNode<String>> collect = dictionaryList |
||||
.stream() |
||||
.map(getNodeFunction()).collect(Collectors.toList()); |
||||
return TreeUtil.build(collect, parentID); |
||||
} |
||||
|
||||
//构造树形节点数据
|
||||
private Function<Dictionary, TreeNode<String>> getNodeFunction() { |
||||
return dictionary -> { |
||||
TreeNode<String> node = new TreeNode<>(); |
||||
node.setId(dictionary.getId()); |
||||
node.setParentId(dictionary.getType()); |
||||
node.setName(dictionary.getLabel()); |
||||
// 扩展属性
|
||||
Map<String, Object> extra = new HashMap<>(); |
||||
extra.put("type", dictionary.getType()); |
||||
extra.put("sort", dictionary.getSort()); |
||||
extra.put("code", dictionary.getCode()); |
||||
extra.put("label", dictionary.getLabel()); |
||||
extra.put("comments", dictionary.getComments()); |
||||
node.setExtra(extra); |
||||
return node; |
||||
}; |
||||
} |
||||
|
||||
/** |
||||
* 根据禁毒系统中的检材序号,查出同步到我们系统中的物证ID |
||||
* |
||||
* @param index |
||||
* @param evidIdList |
||||
* @return |
||||
*/ |
||||
public String getEvidIdByIndex(String index, List<Map<String, String>> evidIdList) { |
||||
|
||||
String retEvid = ""; |
||||
for (Map<String, String> mp : evidIdList) { |
||||
String evidIndex = mp.entrySet().stream().findFirst().map(Map.Entry::getKey).get(); |
||||
if (evidIndex.equals(index)) { |
||||
if (retEvid.length() > 0) { |
||||
System.out.println("注意:出现重复的物证ID----------------"); |
||||
} |
||||
retEvid = mp.entrySet().stream().findFirst().map(Map.Entry::getValue).get(); |
||||
} |
||||
} |
||||
return retEvid; |
||||
} |
||||
|
||||
/** |
||||
* 根据label和type 查到code |
||||
* |
||||
* @param dictLabel |
||||
* @param parentType |
||||
* @return |
||||
*/ |
||||
public String getDictCode(String dictLabel, String parentType) { |
||||
String source = ""; |
||||
R sourceR = remoteDictionaryService.queryDictionaryVO(dictLabel, parentType); |
||||
if (sourceR.getCode() == CommonConstants.SUCCESS) { |
||||
source = (String) sourceR.getData(); |
||||
} |
||||
return source; |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
/** |
||||
* 获取token 并更新字典 |
||||
* |
||||
* @param remoteUrl |
||||
* @param tokenPath |
||||
* @param accessKey |
||||
* @param accessSecret |
||||
* @param tokenDictID |
||||
* @return |
||||
*/ |
||||
public String getTokenAndUpdate(String remoteUrl, String tokenPath, String accessKey, String accessSecret, String tokenDictID) { |
||||
String retToken = ""; |
||||
Dictionary dictToken = remoteDictionaryService.getDictByID(tokenDictID); |
||||
DataModelVo dataModelVoTmp = HttpsUtils.fetchTokenFromRemote(remoteUrl, tokenPath, accessKey, accessSecret); |
||||
if (dataModelVoTmp.getStatusCode().equals("SUCCESS")) { |
||||
retToken = dataModelVoTmp.getResult().getToken(); |
||||
System.out.println("重新申请第三方的数据token成功--"); |
||||
//将token 存储起来
|
||||
dictToken.setCode(retToken); |
||||
remoteDictionaryService.updateById(dictToken); |
||||
System.out.println("更新第三方数据token成功--"); |
||||
} else { |
||||
System.out.println("获取第三方token失败,请检查网络或参数"); |
||||
} |
||||
return retToken; |
||||
} |
||||
|
||||
/** |
||||
* 根据参数不同,获取访问单位的token |
||||
* |
||||
* @param whoUse |
||||
* @return |
||||
*/ |
||||
@Override |
||||
public String getTokenInfo(String whoUse, SynConnInfoVo synConnInfoVo) { |
||||
String retToken = ""; |
||||
String accCheckTokenPath = "/api/sample/drug/task"; |
||||
//如果是分中心申请
|
||||
if (whoUse.equals("SubCenter")) { |
||||
|
||||
DataModelVo retData = HttpsUtils.checkTokenValid(synConnInfoVo.getApiHost(), accCheckTokenPath, synConnInfoVo.getSubCenterTokenInfo()); |
||||
if (retData.getStatusCode().equals("UNAUTHORIZED")) { |
||||
//已经过期
|
||||
retToken = getTokenAndUpdate(synConnInfoVo.getApiHost(), synConnInfoVo.getDataPathInfo().getTokenPath(), |
||||
synConnInfoVo.getTokenInfo().getAccessSubCenterKey().trim(), synConnInfoVo.getTokenInfo().getAccessSubCenterSecret().trim(), |
||||
synConnInfoVo.getTokenInfo().getSubCenterTokenID()); |
||||
} else { |
||||
retToken = synConnInfoVo.getSubCenterTokenInfo(); |
||||
} |
||||
|
||||
} else { |
||||
//否则就认为是省总队申请
|
||||
DataModelVo retData = HttpsUtils.checkTokenValid(synConnInfoVo.getApiHost(), accCheckTokenPath, synConnInfoVo.getProvinceTokenInfo()); |
||||
if (retData.getStatusCode().equals("UNAUTHORIZED")) { |
||||
//已经过期
|
||||
retToken = getTokenAndUpdate(synConnInfoVo.getApiHost(), synConnInfoVo.getDataPathInfo().getTokenPath(), |
||||
synConnInfoVo.getTokenInfo().getAccessProvinceKey().trim(), synConnInfoVo.getTokenInfo().getAccessProvinceSecret().trim(), |
||||
synConnInfoVo.getTokenInfo().getProvinceTokenID()); |
||||
} else { |
||||
retToken = synConnInfoVo.getProvinceTokenInfo(); |
||||
} |
||||
} |
||||
return retToken; |
||||
} |
||||
|
||||
/** |
||||
* 获取远程系统中的数据 |
||||
* |
||||
* @return DataModelVo 远程系统中获取到的数据对象 |
||||
*/ |
||||
public DataModelVo fetchDataFromRemote(String entrustStatus) { |
||||
SynConnInfoVo synConnInfoVo = getSysSynConnInfo(); |
||||
String token = getTokenInfo("SubCenter", synConnInfoVo); |
||||
String remoteUrl = synConnInfoVo.getApiHost(); |
||||
String wtDataPath = synConnInfoVo.getDataPathInfo().getEntrustDataPath(); |
||||
String wtStatus = entrustStatus;//synConnInfoVo.getDataPathInfo().getWtsStatus();
|
||||
DataModelVo retDataModelVo = HttpsUtils.fetchWtDataFromRemote(remoteUrl, wtDataPath, token, wtStatus); |
||||
return retDataModelVo; |
||||
} |
||||
|
||||
//毒品筛查目标物转换函数
|
||||
private List<DrugLite> getDrugLiteList(MaterialVo materialVo) { |
||||
List<DrugLite> retDruglist = new ArrayList<>(); |
||||
List<String> dta1 = materialVo.getTargetObjectTypeList(); |
||||
dta1.forEach(item -> { |
||||
DrugLite eg = new DrugLite(); |
||||
eg.setCode(item); |
||||
eg.setAlias(item); |
||||
eg.setName(item); |
||||
retDruglist.add(eg); |
||||
}); |
||||
return retDruglist; |
||||
} |
||||
} |
@ -0,0 +1,270 @@ |
||||
package digital.laboratory.platform.sewage.utils; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.apache.http.*; |
||||
import org.apache.http.client.config.RequestConfig; |
||||
import org.apache.http.client.methods.CloseableHttpResponse; |
||||
import org.apache.http.client.methods.HttpGet; |
||||
import org.apache.http.client.methods.HttpPost; |
||||
import org.apache.http.client.methods.HttpPut; |
||||
import org.apache.http.config.Registry; |
||||
import org.apache.http.config.RegistryBuilder; |
||||
import org.apache.http.conn.socket.ConnectionSocketFactory; |
||||
import org.apache.http.conn.socket.PlainConnectionSocketFactory; |
||||
import org.apache.http.conn.ssl.NoopHostnameVerifier; |
||||
import org.apache.http.conn.ssl.SSLConnectionSocketFactory; |
||||
import org.apache.http.entity.StringEntity; |
||||
import org.apache.http.impl.client.CloseableHttpClient; |
||||
import org.apache.http.impl.client.HttpClientBuilder; |
||||
import org.apache.http.impl.client.HttpClients; |
||||
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; |
||||
import org.apache.http.message.BasicHeader; |
||||
import org.apache.http.ssl.SSLContextBuilder; |
||||
import org.apache.http.ssl.TrustStrategy; |
||||
import org.apache.http.util.EntityUtils; |
||||
|
||||
import javax.net.ssl.SSLContext; |
||||
import java.io.IOException; |
||||
import java.nio.charset.StandardCharsets; |
||||
import java.security.cert.CertificateException; |
||||
import java.security.cert.X509Certificate; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
import java.util.Set; |
||||
|
||||
@Slf4j |
||||
public class HttpClientUtils { |
||||
private static CloseableHttpClient closeableHttpClient; |
||||
private static PoolingHttpClientConnectionManager cm; |
||||
// 自定义Http
|
||||
static { |
||||
HttpClientBuilder httpClientBuilder = HttpClients.custom(); |
||||
|
||||
/** |
||||
* 1 绕过不安全的https请求证书认证 |
||||
*/ |
||||
Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create() |
||||
.register("http", PlainConnectionSocketFactory.INSTANCE) |
||||
.register("https", trustHttpsCertificates()) |
||||
.build(); |
||||
|
||||
/** |
||||
* 2 创建连接池管理对象 |
||||
*/ |
||||
cm = new PoolingHttpClientConnectionManager(registry); |
||||
cm.setMaxTotal(50); // 最大连接池有50个连接
|
||||
/** |
||||
* ip+port/域名 就是一个路由 |
||||
* |
||||
*/ |
||||
cm.setDefaultMaxPerRoute(50); // 每个路由默认最大有多少连接
|
||||
|
||||
httpClientBuilder.setConnectionManager(cm); |
||||
|
||||
/** |
||||
* 3 设置请求默认配置 |
||||
*/ |
||||
RequestConfig requestConfig = RequestConfig.custom() |
||||
.setConnectTimeout(5000) |
||||
.setSocketTimeout(3000) |
||||
.setConnectionRequestTimeout(5000) |
||||
.build(); |
||||
httpClientBuilder.setDefaultRequestConfig(requestConfig); |
||||
|
||||
/** |
||||
* 设置默认的一些header |
||||
*/ |
||||
List<Header> defHeaders = new ArrayList<>(); |
||||
BasicHeader basicHeader = new BasicHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) " + |
||||
"AppleWebKit/537.36 (KHTML, like Gecko) " + |
||||
"Chrome/114.0.0.0 Safari/537.36"); |
||||
defHeaders.add(basicHeader); |
||||
httpClientBuilder.setDefaultHeaders(defHeaders); |
||||
|
||||
// 设置连接管理共享
|
||||
httpClientBuilder.setConnectionManagerShared(true); |
||||
|
||||
// 线程安全,此处初始化一次即可,通过上面的配置来生成一个用于管理多个连接池closeableHttpClient
|
||||
closeableHttpClient = httpClientBuilder.build(); |
||||
} |
||||
|
||||
// 创建安全链接协议得工厂
|
||||
private static ConnectionSocketFactory trustHttpsCertificates(){ |
||||
SSLContextBuilder sslContextBuilder = new SSLContextBuilder(); |
||||
try { |
||||
sslContextBuilder.loadTrustMaterial(null, new TrustStrategy() { |
||||
@Override |
||||
public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException { |
||||
return true; |
||||
} |
||||
}); |
||||
|
||||
SSLContext sslContext = sslContextBuilder.build(); |
||||
return new SSLConnectionSocketFactory(sslContext, |
||||
new String[]{"SSLv2Hello", "SSLv3", "TLSv1", "TLSv1.1", "TLSv1.2"}, |
||||
null, |
||||
NoopHostnameVerifier.INSTANCE |
||||
); |
||||
} catch (Exception e) { |
||||
log.error("构造连接工厂失败", e); |
||||
throw new RuntimeException("构造连接工厂失败"); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* post方式访问,通过携带json 参数 |
||||
* @param url |
||||
* @param body |
||||
* @param headers |
||||
* @return |
||||
*/ |
||||
public static JSONObject postJson(String url, String body, Map<String, String> headers) { |
||||
HttpPost httpPost = new HttpPost(url); |
||||
|
||||
// 设置请求头
|
||||
if (headers != null) { |
||||
Set<Map.Entry<String, String>> entries = headers.entrySet(); |
||||
for (Map.Entry<String, String> entry : entries) { |
||||
httpPost.addHeader(new BasicHeader(entry.getKey(), entry.getValue())); |
||||
} |
||||
} |
||||
// 文档要求Content-Type 必须是 application/x-www-form
|
||||
httpPost.addHeader("Content-Type", "application/x-www-form"); |
||||
|
||||
// 设置请求体
|
||||
StringEntity jsonEntity = new StringEntity(body, Consts.UTF_8); |
||||
// 设置entity 里面得内容
|
||||
jsonEntity.setContentType(new BasicHeader("Content-Type", "application/json; charset=utf-8")); |
||||
// 设置entity里面得编码
|
||||
jsonEntity.setContentEncoding(Consts.UTF_8.name()); |
||||
httpPost.setEntity(jsonEntity); |
||||
|
||||
CloseableHttpResponse response = null; |
||||
try { |
||||
response = closeableHttpClient.execute(httpPost); |
||||
StatusLine statusLine = response.getStatusLine(); |
||||
if (HttpStatus.SC_OK == statusLine.getStatusCode()) { |
||||
HttpEntity entity = response.getEntity(); |
||||
// EntityUtils.consume(entity);
|
||||
return JSONObject.parseObject(EntityUtils.toString(entity, StandardCharsets.UTF_8)); |
||||
} else { |
||||
log.error("响应失败,响应码:"+statusLine.getStatusCode()); |
||||
} |
||||
} catch (Exception e) { |
||||
log.error("postJson error, url:{}", url, e); |
||||
e.printStackTrace(); |
||||
} finally { |
||||
consumeRes(response); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
/** |
||||
* 发送get请求 |
||||
* @param url 请求的geturl |
||||
* @param headers 请求头 |
||||
* @return |
||||
*/ |
||||
public static JSONObject executeGet(String url, Map<String, String> headers) { |
||||
// 构造httpGet 请求对象
|
||||
HttpGet httpGet = new HttpGet(url); |
||||
// 设置请求头
|
||||
if (headers != null) { |
||||
Set<Map.Entry<String, String>> entries = headers.entrySet(); |
||||
for (Map.Entry<String, String> entry : entries) { |
||||
httpGet.addHeader(new BasicHeader(entry.getKey(), entry.getValue())); |
||||
} |
||||
} |
||||
|
||||
// 可关闭的响应
|
||||
CloseableHttpResponse response = null; |
||||
try { |
||||
log.info("prepare to execute url:{}", url); |
||||
response = closeableHttpClient.execute(httpGet); |
||||
StatusLine statusLine = response.getStatusLine(); |
||||
if (statusLine.getStatusCode() == HttpStatus.SC_OK) { |
||||
HttpEntity entity = response.getEntity(); |
||||
return JSONObject.parseObject(EntityUtils.toString(entity, StandardCharsets.UTF_8)); |
||||
} else { |
||||
log.error("响应失败,响应码:"+statusLine.getStatusCode()); |
||||
} |
||||
} catch (Exception e) { |
||||
log .error("executeGet error,url:(]",url,e); |
||||
e.printStackTrace(); |
||||
} finally { |
||||
consumeRes(response); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
/** |
||||
* put方式访问,通过携带json 参数 |
||||
* @param url |
||||
* @param body |
||||
* @param headers |
||||
* @return |
||||
*/ |
||||
public static JSONObject putJson(String url, String body, Map<String, String> headers) { |
||||
HttpPut httpPut = new HttpPut(url); |
||||
|
||||
// 设置请求头
|
||||
if (headers != null) { |
||||
Set<Map.Entry<String, String>> entries = headers.entrySet(); |
||||
for (Map.Entry<String, String> entry : entries) { |
||||
httpPut.addHeader(new BasicHeader(entry.getKey(), entry.getValue())); |
||||
} |
||||
} |
||||
|
||||
// 设置请求体
|
||||
StringEntity jsonEntity = new StringEntity(body, Consts.UTF_8); |
||||
// 设置entity 里面得内容
|
||||
jsonEntity.setContentType(new BasicHeader("Content-Type", "application/json; charset=utf-8")); |
||||
// 设置entity里面得编码
|
||||
jsonEntity.setContentEncoding(Consts.UTF_8.name()); |
||||
httpPut.setEntity(jsonEntity); |
||||
|
||||
CloseableHttpResponse response = null; |
||||
try { |
||||
response = closeableHttpClient.execute(httpPut); |
||||
StatusLine statusLine = response.getStatusLine(); |
||||
if (HttpStatus.SC_OK == statusLine.getStatusCode()) { |
||||
HttpEntity entity = response.getEntity(); |
||||
// EntityUtils.consume(entity);
|
||||
return JSONObject.parseObject(EntityUtils.toString(entity, StandardCharsets.UTF_8)); |
||||
} else { |
||||
log.error("响应失败,响应码:"+statusLine.getStatusCode()); |
||||
} |
||||
} catch (Exception e) { |
||||
log.error("putJson error, url:{}", url, e); |
||||
e.printStackTrace(); |
||||
} finally { |
||||
consumeRes(response); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
/** |
||||
* 关闭流 |
||||
* @param response |
||||
*/ |
||||
public static void consumeRes(CloseableHttpResponse response) { |
||||
|
||||
if (closeableHttpClient != null) { |
||||
try { |
||||
closeableHttpClient.close(); |
||||
} catch (IOException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
if (response != null) { |
||||
try { |
||||
response.close(); |
||||
} catch (IOException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,14 @@ |
||||
package digital.laboratory.platform.sewage.vo; |
||||
|
||||
import digital.laboratory.platform.sewage.entity.SewageJob; |
||||
import lombok.Data; |
||||
|
||||
@Data |
||||
public class SewageJobGABVO extends SewageJob { |
||||
String launcheOrgName; // 发布机构名称
|
||||
String launcheUserName; // 发布用户姓名
|
||||
String createUserName; // 创建人姓名
|
||||
String updateUserName; // 更新人姓名
|
||||
|
||||
// String statusDescription; // 状态描述
|
||||
} |
@ -0,0 +1,47 @@ |
||||
package digital.laboratory.platform.sewage.vo; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField; |
||||
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler; |
||||
import digital.laboratory.platform.sewage.vo.SewageJobIdentificationMaterialVO; |
||||
import digital.laboratory.platform.sewage.entity.SewageJobItem; |
||||
import digital.laboratory.platform.sewage.entity.UpdateInfo; |
||||
import lombok.Data; |
||||
|
||||
import java.util.List; |
||||
|
||||
@Data |
||||
public class SewageJobItemVO extends SewageJobItem { |
||||
String createUserName; // 创建人姓名
|
||||
String updateUserName; // 更新人姓名
|
||||
|
||||
//---- 污水处理厂 ---
|
||||
String sewageTreatmentPlantName; // 厂名
|
||||
String sewageTreatmentPlantShortName; // 污水处理厂简称
|
||||
String sewageTreatmentPlantAddress; // 地址
|
||||
String sewageTreatmentPlantCoverageArea; // 管网覆盖区域
|
||||
String sewageTreatmentPlantProvinceCode; // 所属省级行政区编码
|
||||
String sewageTreatmentPlantProvinceContacts; // 所属省禁毒办联系人和电话
|
||||
String sewageTreatmentPlantCityCode; // 所属市级行政区编码
|
||||
String sewageTreatmentPlantCityContacts; // 所属市禁毒办联系人和电话
|
||||
String sewageTreatmentPlantDistrictCode; // 所属区县级行政区编码
|
||||
String sewageTreatmentPlantDistrictContacts; // 所属区县禁毒办联系人和电话
|
||||
Integer sewageTreatmentPlantWaterInletCount; // 污水进水口数量
|
||||
Double sewageTreatmentPlantDailyFlowDesign; // 日均处理污水总量(万立方米/日)设计
|
||||
Double sewageTreatmentPlantDailyFlowReal; // 日均处理污水总量(万立方米/日)实际
|
||||
Double sewageTreatmentPlantDomesticSewageProportion; // 生活污水占比(%)
|
||||
Double sewageTreatmentPlantServicePopulation; // 服务人口数(万人)
|
||||
String sewageTreatmentPlantComments; // 备注
|
||||
|
||||
@TableField(typeHandler = FastjsonTypeHandler.class) |
||||
List<UpdateInfo> sewageTreatmentPlantUpdateLog; // 修改记录json格式
|
||||
|
||||
String sewageTreatmentPlantProvinceName; // 所属省级行政区名称
|
||||
String sewageTreatmentPlantCityName; // 所属市级行政区名称
|
||||
String sewageTreatmentPlantDistrictName; // 所属区县级行政区名称
|
||||
String sewageTreatmentPlantCreateUserName; // 污水处理厂创建人姓名
|
||||
String sewageTreatmentPlantUpdateUserName; // 污水处理厂更新人姓名
|
||||
|
||||
Boolean canEdit; // 是否可以修改, 包括 update 和 delete
|
||||
|
||||
List<SewageJobIdentificationMaterialVO> sewageJobIdentificationMaterialVO; //污水样品
|
||||
} |
@ -0,0 +1,17 @@ |
||||
package digital.laboratory.platform.sewage.vo; |
||||
|
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* @ClassName SewageMaterialVo |
||||
* @Description 自动生成污水检材的vo |
||||
* @Author xy |
||||
* @Date 2023/7/13 14:07 |
||||
* @Version 1.0 |
||||
**/ |
||||
@Data |
||||
public class SewageMaterialVo { |
||||
private String materialNo; |
||||
private String materialName; |
||||
private String materialType; |
||||
} |
@ -0,0 +1,15 @@ |
||||
package digital.laboratory.platform.sewage.vo; |
||||
|
||||
import digital.laboratory.platform.sewage.entity.SewageTreatmentPlant; |
||||
import lombok.Data; |
||||
|
||||
@Data |
||||
public class SewageTreatmentPlantVO extends SewageTreatmentPlant { |
||||
|
||||
String provinceName; // 所属省级行政区名称
|
||||
String cityName; // 所属市级行政区名称
|
||||
String districtName; // 所属区县级行政区名称
|
||||
|
||||
String createUserName; // 创建人姓名
|
||||
String updateUserName; // 更新人姓名
|
||||
} |
@ -0,0 +1,24 @@ |
||||
${AnsiColor.BRIGHT_GREEN} |
||||
|
||||
______ _____ __ ______ __ |
||||
/ \ | \ | \ / \ | \ |
||||
| $$$$$$\ ______ __ __ __ ______ ______ ______ \$$$$$ ______ | $$____ | $$$$$$\ __ __ _______ _| $$_ ______ ______ ____ |
||||
| $$___\$$ / \ | \ | \ | \ | \ / \ / \ | $$ / \ | $$ \ | $$___\$$| \ | \ / \| $$ \ / \ | \ \ |
||||
\$$ \ | $$$$$$\| $$ | $$ | $$ \$$$$$$\| $$$$$$\| $$$$$$\ __ | $$| $$$$$$\| $$$$$$$\ \$$ \ | $$ | $$| $$$$$$$ \$$$$$$ | $$$$$$\| $$$$$$\$$$$\ |
||||
_\$$$$$$\| $$ $$| $$ | $$ | $$ / $$| $$ | $$| $$ $$ | \ | $$| $$ | $$| $$ | $$ _\$$$$$$\| $$ | $$ \$$ \ | $$ __ | $$ $$| $$ | $$ | $$ |
||||
| \__| $$| $$$$$$$$| $$_/ $$_/ $$| $$$$$$$| $$__| $$| $$$$$$$$ | $$__| $$| $$__/ $$| $$__/ $$ | \__| $$| $$__/ $$ _\$$$$$$\ | $$| \| $$$$$$$$| $$ | $$ | $$ |
||||
\$$ $$ \$$ \ \$$ $$ $$ \$$ $$ \$$ $$ \$$ \ \$$ $$ \$$ $$| $$ $$ \$$ $$ \$$ $$| $$ \$$ $$ \$$ \| $$ | $$ | $$ |
||||
\$$$$$$ \$$$$$$$ \$$$$$\$$$$ \$$$$$$$ _\$$$$$$$ \$$$$$$$ \$$$$$$ \$$$$$$ \$$$$$$$ \$$$$$$ _\$$$$$$$ \$$$$$$$ \$$$$ \$$$$$$$ \$$ \$$ \$$ |
||||
| \__| $$ | \__| $$ |
||||
\$$ $$ \$$ $$ |
||||
\$$$$$$ \$$$$$$ |
||||
|
||||
|
||||
|
||||
SewageJob 污水检测任务管理系统 |
||||
|
||||
版本: ${version} |
||||
创建: ${timestamp} |
||||
|
||||
${AnsiColor.DEFAULT} |
||||
|
@ -0,0 +1,65 @@ |
||||
logging: |
||||
level: |
||||
digital.laboratory.platform.entrustment.mapper: debug |
||||
server: |
||||
port: 5242 |
||||
mybatis: |
||||
mapper-locations: classpath*:mapper/*.xml |
||||
|
||||
mybatis-plus: |
||||
type-handlers-package: digital.laboratory.platform.sewage.config |
||||
|
||||
spring: |
||||
application: |
||||
name: @artifactId@ |
||||
|
||||
cloud: |
||||
nacos: |
||||
discovery: |
||||
server-addr: ${NACOS_HOST:dlp-nacos}:${NACOS_PORT:8848} |
||||
config: |
||||
server-addr: ${spring.cloud.nacos.discovery.server-addr} |
||||
file-extension: yml |
||||
shared-configs: |
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} |
||||
|
||||
profiles: |
||||
active: @profiles.active@ |
||||
|
||||
datasource: |
||||
type: com.zaxxer.hikari.HikariDataSource |
||||
driver-class-name: com.mysql.cj.jdbc.Driver |
||||
username: dlp |
||||
password: 7990016 |
||||
url: jdbc:mysql://dlp-mysql:3306/dlp_sewage_job?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowMultiQueries=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true |
||||
|
||||
mvc: |
||||
pathmatch: |
||||
matching-strategy: ant-path-matcher |
||||
hiddenmethod: |
||||
filter: |
||||
enabled: true |
||||
servlet: |
||||
multipart: |
||||
# 根据实际需求作调整 |
||||
# 默认最大上传文件大小为1M, 单个文件大小 |
||||
max-file-size: 20MB |
||||
# 默认最大请求大小为10M, 总上传的数据大小 |
||||
max-request-size: 55MB |
||||
|
||||
|
||||
# 文件上传相关 支持阿里云、华为云、腾讯、minio |
||||
oss: |
||||
endpoint: http://127.0.0.1:9000 |
||||
accessKey: admin |
||||
secretKey: 87990016 |
||||
bucket-name: dlpfiles |
||||
|
||||
countryDrugSystem: |
||||
apiPath: |
||||
tokenPath: /api/token |
||||
taskListPath: /api/sample/environment/sample # 污水样品列表查询 |
||||
receivePath: /api/sample/environment/receive # 样品签收 |
||||
rejectPath: /api/sample/environment/reject # 样品拒收 |
||||
returnPath: /api/sample/environment/return # 样品退回 |
||||
closePath: /api/sample/environment/close # 样品作废申请 |
@ -0,0 +1,61 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<configuration debug="false" scan="false"> |
||||
<springProperty scop="context" name="spring.application.name" source="spring.application.name" defaultValue=""/> |
||||
<property name="log.path" value="logs/${spring.application.name}"/> |
||||
<!-- 彩色日志格式 --> |
||||
<property name="CONSOLE_LOG_PATTERN" |
||||
value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/> |
||||
<!-- 彩色日志依赖的渲染类 --> |
||||
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter"/> |
||||
<conversionRule conversionWord="wex" |
||||
converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter"/> |
||||
<conversionRule conversionWord="wEx" |
||||
converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter"/> |
||||
<!-- Console log output --> |
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender"> |
||||
<encoder> |
||||
<pattern>${CONSOLE_LOG_PATTERN}</pattern> |
||||
</encoder> |
||||
</appender> |
||||
|
||||
<!-- Log file debug output --> |
||||
<appender name="debug" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
||||
<file>${log.path}/debug.log</file> |
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> |
||||
<fileNamePattern>${log.path}/%d{yyyy-MM, aux}/debug.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern> |
||||
<maxFileSize>50MB</maxFileSize> |
||||
<maxHistory>30</maxHistory> |
||||
</rollingPolicy> |
||||
<encoder> |
||||
<pattern>%date [%thread] %-5level [%logger{50}] %file:%line - %msg%n</pattern> |
||||
</encoder> |
||||
</appender> |
||||
|
||||
<!-- Log file error output --> |
||||
<appender name="error" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
||||
<file>${log.path}/error.log</file> |
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> |
||||
<fileNamePattern>${log.path}/%d{yyyy-MM}/error.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern> |
||||
<maxFileSize>50MB</maxFileSize> |
||||
<maxHistory>30</maxHistory> |
||||
</rollingPolicy> |
||||
<encoder> |
||||
<pattern>%date [%thread] %-5level [%logger{50}] %file:%line - %msg%n</pattern> |
||||
</encoder> |
||||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter"> |
||||
<level>ERROR</level> |
||||
</filter> |
||||
</appender> |
||||
|
||||
<!--nacos 心跳 INFO 屏蔽--> |
||||
<logger name="com.alibaba.nacos" level="OFF"> |
||||
<appender-ref ref="error"/> |
||||
</logger> |
||||
|
||||
<!-- Level: FATAL 0 ERROR 3 WARN 4 INFO 6 DEBUG 7 --> |
||||
<root level="INFO"> |
||||
<appender-ref ref="console"/> |
||||
<appender-ref ref="debug"/> |
||||
<appender-ref ref="error"/> |
||||
</root> |
||||
</configuration> |
@ -0,0 +1,16 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
|
||||
<mapper namespace="digital.laboratory.platform.sewage.mapper.SewageImportLogMapper"> |
||||
|
||||
<resultMap id="sewageImportLogMap" type="digital.laboratory.platform.sewage.entity.SewageImportLog"> |
||||
<id property="id" column="id"/> |
||||
<result property="module" column="module"/> |
||||
<result property="log" column="log"/> |
||||
<result property="createTime" column="create_time"/> |
||||
<result property="createBy" column="create_by"/> |
||||
<result property="updateTime" column="update_time"/> |
||||
<result property="updateBy" column="update_by"/> |
||||
</resultMap> |
||||
</mapper> |
@ -0,0 +1,118 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
|
||||
<mapper namespace="digital.laboratory.platform.sewage.mapper.SewageJobGABMapper"> |
||||
|
||||
<resultMap id="sewageJobGABMap" type="digital.laboratory.platform.sewage.entity.SewageJobGAB"> |
||||
<id property="id" column="id"/> |
||||
<result property="jobNo" column="job_no"/> |
||||
<result property="name" column="name"/> |
||||
<result property="jobYear" column="job_year"/> |
||||
<result property="jobSeason" column="job_season"/> |
||||
<!-- <result property="jobRegion" column="job_region"/>--> |
||||
<result property="description" column="description"/> |
||||
<result property="launcheOrgId" column="launche_org_id"/> |
||||
<result property="source" column="source"/> |
||||
<result property="expirationDate" column="expiration_date"/> |
||||
<result property="startDate" column="start_date"/> |
||||
<result property="comments" column="comments"/> |
||||
<result property="status" column="status"/> |
||||
<result property="launcheUserId" column="launche_user_id"/> |
||||
<result property="launcheDate" column="launche_date"/> |
||||
<result property="createTime" column="create_time"/> |
||||
<result property="createBy" column="create_by"/> |
||||
<result property="updateTime" column="update_time"/> |
||||
<result property="updateBy" column="update_by"/> |
||||
<result property="sewageAreaList" column="sewage_area_list"/> |
||||
</resultMap> |
||||
|
||||
<resultMap id="sewageJobGABVO" type="digital.laboratory.platform.sewage.vo.SewageJobGABVO" extends="sewageJobGABMap"> |
||||
<result property="launcheOrgName" column ="launche_org_name"/> |
||||
<result property="launcheUserName" column ="launche_user_name"/> |
||||
|
||||
<result property="createUserName" column ="create_user_name"/> |
||||
<result property="updateUserName" column ="update_user_name"/> |
||||
</resultMap> |
||||
|
||||
<resultMap id="sewageTreeDataVo" type="digital.laboratory.platform.sewage.vo.SewageTreeVO"> |
||||
<id property="jcId" column="jc_id"/> |
||||
<result property="jobId" column="job_id"/> |
||||
<result property="jcName" column="jc_name"/> |
||||
<result property="jcNo" column="jc_no"/> |
||||
<result property="jcStatus" column="jc_status"/> |
||||
<result property="waterInletNo" column="water_Inlet_No"/> |
||||
<result property="waterFactoryId" column="water_factory_id"/> |
||||
<result property="waterFactoryName" column="water_factory_name"/> |
||||
<result property="provinceCode" column="province_code"/> |
||||
<result property="cityCode" column="city_code"/> |
||||
<result property="districtCode" column="district_code"/> |
||||
<result property="provinceName" column="province_name"/> |
||||
<result property="cityName" column="city_name"/> |
||||
<result property="districtName" column="district_name"/> |
||||
</resultMap> |
||||
|
||||
<sql id="getSewageJobGABVOSQL"> |
||||
SELECT sj.*, |
||||
( |
||||
SELECT org.name |
||||
FROM dlp_base.sys_org org |
||||
WHERE org.org_id=sj.launche_org_id |
||||
) AS launche_org_name, |
||||
( |
||||
SELECT user.name |
||||
FROM dlp_base.sys_user user |
||||
WHERE user.user_id=sj.launche_user_id |
||||
) AS launche_user_name, |
||||
( |
||||
SELECT user.name |
||||
FROM dlp_base.sys_user user |
||||
WHERE user.user_id=sj.create_by |
||||
) AS create_user_name, |
||||
( |
||||
SELECT user.name |
||||
FROM dlp_base.sys_user user |
||||
WHERE user.user_id=sj.update_by |
||||
) AS update_user_name |
||||
FROM b_sewage_job_gab sj |
||||
</sql> |
||||
<sql id="getSewageJobGABTreeData"> |
||||
SELECT tab1.jc_id, |
||||
tab1.jc_no, |
||||
tab1.jc_name, |
||||
tab1.jc_status, |
||||
tab1.water_inlet_no, |
||||
tab1.job_id, |
||||
tab1.water_factory_id, |
||||
tab2.name as water_factory_name, |
||||
tab2.province_code , |
||||
tab2.city_code, |
||||
tab2.district_code, |
||||
tab2.province_name, |
||||
tab2.city_name, |
||||
tab2.district_name |
||||
from |
||||
(SELECT t1.id as jc_id,t1.im_no as jc_no,t1.sample_name as jc_name,t1.`status` as jc_status, |
||||
t1.water_inlet_number as water_inlet_no,t1.job_id,t2.plant_id as water_factory_id |
||||
from b_sewage_job_identification_material t1 LEFT JOIN b_sewage_job_item t2 on t1.job_item_id=t2.id) tab1 |
||||
LEFT JOIN b_sewage_treatment_plant_gab tab2 on tab1.water_factory_id=tab2.id |
||||
</sql> |
||||
|
||||
<!-- 根据条件取 SewageJobVO 列表分页 --> |
||||
<select id="getSewageJobGABVOPage" resultMap="sewageJobGABVO" resultType="digital.laboratory.platform.sewage.vo.SewageJobGABVO"> |
||||
<include refid="getSewageJobGABVOSQL"/> |
||||
${ew.customSqlSegment} |
||||
</select> |
||||
|
||||
<!-- 根据条件取 SewageJobVO 列表 --> |
||||
<select id="getSewageJobGABVOList" resultMap="sewageJobGABVO" resultType="digital.laboratory.platform.sewage.vo.SewageJobGABVO"> |
||||
<include refid="getSewageJobGABVOSQL"/> |
||||
${ew.customSqlSegment} |
||||
</select> |
||||
<select id="getSewageSendData" resultMap="sewageTreeDataVo" resultType="digital.laboratory.platform.sewage.vo.SewageTreeVO"> |
||||
<include refid="getSewageJobGABTreeData" /> |
||||
${ew.customSqlSegment} |
||||
</select> |
||||
|
||||
|
||||
</mapper> |
@ -0,0 +1,474 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
|
||||
<mapper namespace="digital.laboratory.platform.sewage.mapper.SewageJobIdentificationMaterialMapper"> |
||||
<resultMap id="sewageJobIdentificationMaterialMap" |
||||
type="digital.laboratory.platform.sewage.entity.SewageJobIdentificationMaterial"> |
||||
<id property="id" column="id"/> |
||||
<result property="jobId" column="job_id"/> |
||||
<result property="jobItemId" column="job_item_id"/> |
||||
<result property="imNo" column="im_no"/> |
||||
<!-- <result property="sample1Present" column="sample1_present"/>--> |
||||
<result property="sample2Present" column="sample2_present"/> |
||||
<result property="sample1No" column="sample1_no"/> |
||||
<result property="sample2No" column="sample2_no"/> |
||||
<result property="sample1BoxId" column="sample1_box_id"/> |
||||
<result property="sample2BoxId" column="sample2_box_id"/> |
||||
<result property="sampleType" column="sample_type"/> |
||||
<result property="sampleName" column="sample_name"/> |
||||
<result property="collectPlaceAreaCode" column="collect_place_area_code"/> |
||||
<result property="collectPlace" column="collect_place"/> |
||||
<result property="dailyFlow" column="daily_flow"/> |
||||
<result property="waterInletCount" column="water_inlet_count"/> |
||||
<result property="waterInletNumber" column="water_inlet_number"/> |
||||
<result property="domesticSewageProportion" column="domestic_sewage_proportion"/> |
||||
<result property="servicePopulation" column="service_population"/> |
||||
<result property="samplePh" column="sample_ph"/> |
||||
<result property="samplingDepth" column="sampling_depth"/> |
||||
<result property="sampleProperties" column="sample_properties"/> |
||||
<result property="samplingMethod" column="sampling_method"/> |
||||
<result property="samplingMode" column="sampling_mode"/> |
||||
<result property="storageMethod" column="storage_method"/> |
||||
<result property="collector" column="collector"/> |
||||
<result property="collectorGroup" column="collector_group"/> |
||||
<result property="collectTime" column="collect_time"/> |
||||
<result property="deliverMethod" column="deliver_method"/> |
||||
<result property="delivererName" column="deliverer_name"/> |
||||
<result property="delivererPosition" column="deliverer_position"/> |
||||
<result property="delivererCert" column="deliverer_cert"/> |
||||
<result property="delivererId" column="deliverer_id"/> |
||||
<result property="delivererPhone" column="deliverer_phone"/> |
||||
<result property="deliverOrgId" column="deliver_org_id"/> |
||||
<result property="expressCompany" column="express_company"/> |
||||
<result property="expressNumber" column="express_number"/> |
||||
<result property="comments" column="comments"/> |
||||
<result property="acceptTime" column="accept_time"/> |
||||
<result property="acceptComments" column="accept_comments"/> |
||||
<result property="updateLog" column="update_log" |
||||
typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/> |
||||
<result property="status" column="status"/> |
||||
<result property="createTime" column="create_time"/> |
||||
<result property="createBy" column="create_by"/> |
||||
<result property="updateTime" column="update_time"/> |
||||
<result property="updateBy" column="update_by"/> |
||||
<result property="informantId" column="informant_id"/> |
||||
<result property="causeOfCancellation" column="cause_of_cancellation"/> |
||||
<result property="returnOrNot" column="return_or_not"/> |
||||
|
||||
</resultMap> |
||||
|
||||
|
||||
<resultMap id="sewageJobIdentificationMaterialVO" |
||||
type="digital.laboratory.platform.sewage.vo.SewageJobIdentificationMaterialVO" |
||||
extends="sewageJobIdentificationMaterialMap"> |
||||
<result property="collectPlaceProvinceCode" column="collect_place_province_code"/> |
||||
<result property="collectPlaceCityCode" column="collect_place_city_code"/> |
||||
|
||||
<result property="deliverOrgName" column="deliver_org_name"/> |
||||
<result property="collectPlaceAreaName" column="collect_place_area_name"/> |
||||
|
||||
<result property="createUserName" column="create_user_name"/> |
||||
<result property="updateUserName" column="update_user_name"/> |
||||
|
||||
<result property="provinceName" column="province_name"/> |
||||
<result property="cityName" column="city_name"/> |
||||
<result property="districtName" column="district_name"/> |
||||
<result property="jobName" column="job_name"/> |
||||
<result property="jobNum" column="job_num"/> |
||||
<result property="jobYear" column="job_year"/> |
||||
<result property="jobSeason" column="job_season"/> |
||||
|
||||
</resultMap> |
||||
|
||||
|
||||
<sql id="getSewageJobIdentificationMaterialVOSQL"> |
||||
|
||||
SELECT sjim.id, |
||||
sjim.job_id, |
||||
sjim.job_item_id, |
||||
sjim.im_no, |
||||
-- sjim.sample1_present, |
||||
sjim.sample2_present, |
||||
sjim.sample1_no, |
||||
sjim.sample2_no, |
||||
sjim.sample1_box_id, |
||||
sjim.sample2_box_id, |
||||
sjim.sample_type, |
||||
sjim.sample_name, |
||||
sjim.collect_place_area_code, |
||||
sjim.collect_place, |
||||
sjim.daily_flow, |
||||
sjim.water_inlet_count, |
||||
sjim.water_inlet_number, |
||||
sjim.domestic_sewage_proportion, |
||||
sjim.service_population, |
||||
sjim.sample_ph, |
||||
sjim.sampling_depth, |
||||
sjim.sample_properties, |
||||
sjim.sampling_method, |
||||
sjim.sampling_mode, |
||||
sjim.storage_method, |
||||
sjim.collector, |
||||
sjim.collector_group, |
||||
sjim.collect_time, |
||||
sjim.cause_of_cancellation, |
||||
sjim.deliver_method, |
||||
sjim.deliverer_name, |
||||
sjim.deliverer_position, |
||||
sjim.deliverer_cert, |
||||
sjim.deliverer_id, |
||||
sjim.deliverer_phone, |
||||
sjim.deliver_org_id, |
||||
sjim.express_number, |
||||
sjim.express_company, |
||||
sjim.comments, |
||||
sjim.accept_time, |
||||
sjim.status, |
||||
sjim.accept_comments, |
||||
sjim.create_time, |
||||
sjim.create_by, |
||||
sjim.update_time, |
||||
sjim.update_by, |
||||
sjim.return_or_not, |
||||
stp.province_name, |
||||
stp.city_name, |
||||
stp.district_name, |
||||
|
||||
stp.province_code AS collect_place_province_code, |
||||
stp.city_code AS collect_place_city_code, |
||||
(SELECT name |
||||
FROM dlp_base.b_area area |
||||
WHERE area.id = sjim.collect_place_area_code) AS collect_place_area_name, |
||||
(SELECT org.name |
||||
FROM dlp_base.sys_org org |
||||
WHERE org.org_id = sjim.deliver_org_id) AS deliver_org_name, |
||||
(SELECT user.name |
||||
FROM dlp_base.sys_user user |
||||
WHERE user.user_id=sjim.create_by |
||||
) AS create_user_name |
||||
, ( |
||||
SELECT user.name |
||||
FROM dlp_base.sys_user user |
||||
WHERE user.user_id=sjim.update_by |
||||
) AS update_user_name |
||||
FROM b_sewage_job_identification_material sjim |
||||
LEFT JOIN b_sewage_job_item ji |
||||
ON sjim.job_item_id = ji.id |
||||
LEFT JOIN b_sewage_treatment_plant stp ON ji.plant_id=stp.id |
||||
</sql> |
||||
|
||||
<sql id="getSewageJobGABIdentificationMaterialVOSQL"> |
||||
|
||||
SELECT sjim.id, |
||||
sjim.job_id, |
||||
sjim.job_item_id, |
||||
sjim.im_no, |
||||
-- sjim.sample1_present, |
||||
sjim.sample2_present, |
||||
sjim.sample1_no, |
||||
sjim.sample2_no, |
||||
sjim.sample1_box_id, |
||||
sjim.sample2_box_id, |
||||
sjim.sample_type, |
||||
sjim.sample_name, |
||||
sjim.collect_place_area_code, |
||||
sjim.collect_place, |
||||
sjim.daily_flow, |
||||
sjim.water_inlet_count, |
||||
sjim.water_inlet_number, |
||||
sjim.domestic_sewage_proportion, |
||||
sjim.service_population, |
||||
sjim.sample_ph, |
||||
sjim.sampling_depth, |
||||
sjim.sample_properties, |
||||
sjim.sampling_method, |
||||
sjim.sampling_mode, |
||||
sjim.storage_method, |
||||
sjim.collector, |
||||
sjim.collector_group, |
||||
sjim.collect_time, |
||||
sjim.cause_of_cancellation, |
||||
sjim.deliver_method, |
||||
sjim.deliverer_name, |
||||
sjim.deliverer_position, |
||||
sjim.deliverer_cert, |
||||
sjim.deliverer_id, |
||||
sjim.deliverer_phone, |
||||
sjim.deliver_org_id, |
||||
sjim.express_number, |
||||
sjim.express_company, |
||||
sjim.comments, |
||||
sjim.accept_time, |
||||
sjim.status, |
||||
sjim.accept_comments, |
||||
sjim.create_time, |
||||
sjim.create_by, |
||||
sjim.update_time, |
||||
sjim.update_by, |
||||
sjim.return_or_not, |
||||
stp.province_name, |
||||
stp.city_name, |
||||
stp.district_name, |
||||
stp.province_code AS collect_place_province_code, |
||||
stp.city_code AS collect_place_city_code, |
||||
(SELECT name |
||||
FROM dlp_base.b_area area |
||||
WHERE area.id = sjim.collect_place_area_code) AS collect_place_area_name, |
||||
(SELECT org.name |
||||
FROM dlp_base.sys_org org |
||||
WHERE org.org_id = sjim.deliver_org_id) AS deliver_org_name, |
||||
(SELECT user.name |
||||
FROM dlp_base.sys_user user |
||||
WHERE user.user_id=sjim.create_by |
||||
) AS create_user_name |
||||
, ( |
||||
SELECT user.name |
||||
FROM dlp_base.sys_user user |
||||
WHERE user.user_id=sjim.update_by |
||||
) AS update_user_name |
||||
FROM b_sewage_job_identification_material sjim |
||||
LEFT JOIN b_sewage_job_item ji |
||||
ON sjim.job_item_id = ji.id |
||||
LEFT JOIN b_sewage_treatment_plant_gab stp ON ji.plant_id=stp.id |
||||
</sql> |
||||
<select id="getByImNo" resultMap="sewageJobIdentificationMaterialVO" |
||||
resultType="digital.laboratory.platform.sewage.vo.SewageJobIdentificationMaterialVO"> |
||||
SELECT im.*, |
||||
sj.name AS job_name, |
||||
sj.job_no AS job_num, |
||||
sj.job_year, |
||||
sj.job_season, |
||||
stp.province_name, |
||||
stp.district_name, |
||||
stp.city_name |
||||
FROM b_sewage_job_identification_material im |
||||
LEFT JOIN b_sewage_job sj ON im.job_id = sj.id |
||||
LEFT JOIN b_sewage_job_item sji ON im.job_item_id = sji.id |
||||
LEFT JOIN b_sewage_treatment_plant stp ON sji.plant_id = stp.id |
||||
WHERE im.im_no = #{imNo}; |
||||
</select> |
||||
|
||||
<select id="getByImNoGAB" resultMap="sewageJobIdentificationMaterialVO" |
||||
resultType="digital.laboratory.platform.sewage.vo.SewageJobIdentificationMaterialVO"> |
||||
SELECT im.*, |
||||
sj.name AS job_name, |
||||
sj.job_no AS job_num, |
||||
sj.job_year, |
||||
sj.job_season, |
||||
stp.province_name, |
||||
stp.district_name, |
||||
stp.city_name |
||||
FROM b_sewage_job_identification_material im |
||||
LEFT JOIN b_sewage_job_gab sj ON im.job_id = sj.id |
||||
LEFT JOIN b_sewage_job_item sji ON im.job_item_id = sji.id |
||||
LEFT JOIN b_sewage_treatment_plant_gab stp ON sji.plant_id = stp.id |
||||
WHERE im.im_no = #{imNo}; |
||||
</select> |
||||
<!-- 根据条件取 SewageJobItemVO 列表分页 --> |
||||
<select id="getSewageJobIdentificationMaterialVOPage" resultMap="sewageJobIdentificationMaterialVO" |
||||
resultType="digital.laboratory.platform.sewage.vo.SewageJobIdentificationMaterialVO"> |
||||
<include refid="getSewageJobIdentificationMaterialVOSQL"/> |
||||
${ew.customSqlSegment} |
||||
</select> |
||||
|
||||
<!-- 根据条件取 SewageJobItemVO 列表 --> |
||||
<select id="getSewageJobIdentificationMaterialVOList" resultMap="sewageJobIdentificationMaterialVO" |
||||
resultType="digital.laboratory.platform.sewage.vo.SewageJobIdentificationMaterialVO"> |
||||
<include refid="getSewageJobIdentificationMaterialVOSQL"/> |
||||
${ew.customSqlSegment} |
||||
</select> |
||||
|
||||
<!-- 根据条件取 SewageJobItemVO 列表分页 --> |
||||
<select id="getSewageJobGABIdentificationMaterialVOPage" resultMap="sewageJobIdentificationMaterialVO" |
||||
resultType="digital.laboratory.platform.sewage.vo.SewageJobIdentificationMaterialVO"> |
||||
<include refid="getSewageJobGABIdentificationMaterialVOSQL"/> |
||||
${ew.customSqlSegment} |
||||
</select> |
||||
<!-- 根据条件取 SewageJobItemVO 列表 --> |
||||
<select id="getSewageJobGABIdentificationMaterialVOList" resultMap="sewageJobIdentificationMaterialVO" |
||||
resultType="digital.laboratory.platform.sewage.vo.SewageJobIdentificationMaterialVO"> |
||||
<include refid="getSewageJobGABIdentificationMaterialVOSQL"/> |
||||
${ew.customSqlSegment} |
||||
</select> |
||||
|
||||
<!--下属机构送检且已签收的检材列表 --> |
||||
|
||||
<select id="getAcceptIMQuantity" |
||||
resultType="digital.laboratory.platform.sewage.entity.SewageJobIdentificationMaterial"> |
||||
SELECT im.* |
||||
FROM b_sewage_job_identification_material im |
||||
WHERE im.job_item_id in (SELECT i.id |
||||
FROM b_sewage_job_item i |
||||
WHERE i.plant_id in |
||||
(SELECT p.id FROM b_sewage_treatment_plant p WHERE p.city_code = #{orgId} |
||||
OR p.district_code = #{orgId})) |
||||
and im.`status` = 3 |
||||
</select> |
||||
|
||||
<!--下属机构未填报且未超过截止日期的检材列表 --> |
||||
<select id="getFoundIMQuantity" |
||||
resultType="digital.laboratory.platform.sewage.entity.SewageJobIdentificationMaterial"> |
||||
SELECT im.* |
||||
FROM b_sewage_job_identification_material im |
||||
WHERE im.job_item_id in (SELECT i.id |
||||
FROM b_sewage_job_item i |
||||
WHERE i.plant_id in |
||||
(SELECT p.id FROM b_sewage_treatment_plant p WHERE p.city_code = #{orgId} |
||||
OR p.district_code = #{orgId}) |
||||
and i.job_id in (SELECT sj.id FROM b_sewage_job sj WHERE sj.expiration_date > NOW())) |
||||
and im.`status` = 0 |
||||
</select> |
||||
|
||||
<!--下属机构已填报未送检且未超过截止日期的检材列表 --> |
||||
<select id="getWriteIMQuantity" |
||||
resultType="digital.laboratory.platform.sewage.entity.SewageJobIdentificationMaterial"> |
||||
SELECT im.* |
||||
FROM b_sewage_job_identification_material im |
||||
WHERE im.job_item_id in (SELECT i.id |
||||
FROM b_sewage_job_item i |
||||
WHERE i.plant_id in |
||||
(SELECT p.id FROM b_sewage_treatment_plant p WHERE p.city_code = #{orgId} |
||||
OR p.district_code = #{orgId}) |
||||
and i.job_id in (SELECT sj.id FROM b_sewage_job sj WHERE sj.expiration_date > NOW())) |
||||
and im.`status` = 1 |
||||
</select> |
||||
|
||||
<!--下属机构已作废的检材列表 --> |
||||
<select id="getRejectionIMQuantity" |
||||
resultType="digital.laboratory.platform.sewage.entity.SewageJobIdentificationMaterial"> |
||||
SELECT im.* |
||||
FROM b_sewage_job_identification_material im |
||||
WHERE im.job_item_id in (SELECT i.id |
||||
FROM b_sewage_job_item i |
||||
WHERE i.plant_id in |
||||
(SELECT p.id FROM b_sewage_treatment_plant p WHERE p.city_code = #{orgId} |
||||
OR p.district_code = #{orgId})) |
||||
and im.`status` = -2 |
||||
</select> |
||||
|
||||
<!--下属机构已送检的检材列表 --> |
||||
<select id="getInspectIMQuantity" |
||||
resultType="digital.laboratory.platform.sewage.entity.SewageJobIdentificationMaterial"> |
||||
SELECT im.* |
||||
FROM b_sewage_job_identification_material im |
||||
WHERE im.job_item_id in (SELECT i.id |
||||
FROM b_sewage_job_item i |
||||
WHERE i.plant_id in |
||||
(SELECT p.id FROM b_sewage_treatment_plant p WHERE p.city_code = #{orgId} |
||||
OR p.district_code = #{orgId})) |
||||
and im.status in (2, 3) |
||||
|
||||
</select> |
||||
|
||||
<select id="getAnyIm" resultType="digital.laboratory.platform.sewage.vo.SewageJobIdentificationMaterialVO"> |
||||
SELECT im.*, |
||||
(SELECT s.name FROM b_sewage_job s where s.id = im.job_id) as job_name, |
||||
(SELECT s.job_no FROM b_sewage_job s where s.id = im.job_id) as job_num, |
||||
(SELECT s.job_year FROM b_sewage_job s where s.id = im.job_id) as job_year, |
||||
(SELECT s.job_season FROM b_sewage_job s where s.id = im.job_id) as job_season, |
||||
(SELECT p.province_name |
||||
FROM b_sewage_treatment_plant p |
||||
WHERE p.id = (SELECT si.plant_id |
||||
FROM b_sewage_job_item si |
||||
WHERE si.id = im.job_item_id)) as province_name, |
||||
(SELECT p.district_name |
||||
FROM b_sewage_treatment_plant p |
||||
WHERE p.id = (SELECT si.plant_id |
||||
FROM b_sewage_job_item si |
||||
WHERE si.id = im.job_item_id)) as district_name, |
||||
(SELECT p.city_name |
||||
FROM b_sewage_treatment_plant p |
||||
WHERE p.id = (SELECT si.plant_id FROM b_sewage_job_item si WHERE si.id = im.job_item_id)) as city_name |
||||
FROM b_sewage_job_identification_material im |
||||
${ew.customSqlSegment} |
||||
</select> |
||||
|
||||
|
||||
<select id="getItemId" resultType="String"> |
||||
SELECT i.id |
||||
FROM b_sewage_job_item i |
||||
WHERE i.job_id in (SELECT sj.id FROM b_sewage_job sj WHERE sj.expiration_date > NOW()) |
||||
and i.plant_id in |
||||
(SELECT p.id FROM b_sewage_treatment_plant p WHERE p.city_code = #{orgId} |
||||
OR p.district_code = #{orgId}) |
||||
</select> |
||||
|
||||
<select id="getNotTimeOutItemId" resultType="String"> |
||||
SELECT i.id |
||||
FROM b_sewage_job_item i |
||||
WHERE i.plant_id in |
||||
(SELECT p.id FROM b_sewage_treatment_plant p WHERE p.city_code = #{orgId} |
||||
OR p.district_code = #{orgId}) |
||||
</select> |
||||
<!-- 定义批量保存的xml--> |
||||
<insert id="rewriteSaveBatch"> |
||||
INSERT INTO |
||||
b_sewage_job_identification_material |
||||
(id, job_id, job_item_id, im_no, sample1_no, sample2_no, |
||||
sample1_present, sample2_present, sample1_box_id, sample2_box_id, |
||||
sample_type, sample_name, collect_place_area_code, collect_place, |
||||
daily_flow, water_inlet_count, water_inlet_number, domestic_sewage_proportion, |
||||
service_population, sample_ph, sampling_depth, sample_properties, sampling_method, |
||||
sampling_mode, storage_method, collector, collector_group, collect_time, deliver_method, |
||||
deliverer_name, deliverer_position, deliverer_cert, deliverer_id, deliverer_phone, deliver_org_id, |
||||
express_number, express_company, comments, accept_time, accept_comments, update_log, |
||||
create_by, update_by, informant_id, cause_of_cancellation) |
||||
VALUES |
||||
<foreach collection="list" item="item" index="index" separator=","> |
||||
(#{item.id}, |
||||
#{item.jobId}, |
||||
#{item.jobItemId}, |
||||
#{item.imNo}, |
||||
#{item.sample2Present}, |
||||
#{item.sample1No}, |
||||
#{item.sample2No}, |
||||
#{item.sample1BoxId}, |
||||
#{item.sample2BoxId}, |
||||
#{item.sampleType}, |
||||
#{item.sampleName}, |
||||
#{item.collectPlaceAreaCode}, |
||||
#{item.collectPlace}, |
||||
#{item.dailyFlow}, |
||||
#{item.waterInletCount}, |
||||
#{item.waterInletNumber}, |
||||
#{item.domesticSewageProportion}, |
||||
#{item.servicePopulation}, |
||||
#{item.samplePh}, |
||||
#{item.samplingDepth}, |
||||
#{item.sampleProperties}, |
||||
#{item.samplingMethod}, |
||||
#{item.samplingMode}, |
||||
#{item.storageMethod}, |
||||
#{item.collector}, |
||||
#{item.collectorGroup}, |
||||
#{item.collectTime}, |
||||
#{item.deliverMethod}, |
||||
#{item.delivererName}, |
||||
#{item.delivererPosition}, |
||||
#{item.delivererCert}, |
||||
#{item.delivererId}, |
||||
#{item.delivererPhone}, |
||||
#{item.deliverOrgId}, |
||||
#{item.expressNumber}, |
||||
#{item.expressCompany}, |
||||
#{item.comments}, |
||||
#{item.acceptTime}, |
||||
#{item.status}, |
||||
#{item.acceptComments}, |
||||
#{item.informantId}, |
||||
#{item.causeOfCancellation} |
||||
) |
||||
</foreach> |
||||
</insert> |
||||
|
||||
<select id="getSewageJobIdentificationMaterialVOListByJobId" resultMap="sewageJobIdentificationMaterialVO" resultType="digital.laboratory.platform.sewage.vo.SewageJobIdentificationMaterialVO"> |
||||
SELECT sm.* ,si.plant_id,sp.province_name,sp.city_name,sp.district_name,sj.job_year,sj.job_season |
||||
FROM b_sewage_job_identification_material sm |
||||
JOIN b_sewage_job_item si ON si.id = sm.job_item_id |
||||
JOIN b_sewage_treatment_plant sp ON sp.id = si.plant_id |
||||
JOIN b_sewage_job sj ON sj.id = sm.job_id |
||||
${ew.customSqlSegment} |
||||
</select> |
||||
|
||||
</mapper> |
@ -0,0 +1,132 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
|
||||
<mapper namespace="digital.laboratory.platform.sewage.mapper.SewageJobItemMapper"> |
||||
|
||||
<resultMap id="sewageJobItemMap" type="digital.laboratory.platform.sewage.entity.SewageJobItem"> |
||||
<id property="id" column="id"/> |
||||
<result property="jobId" column="job_id"/> |
||||
<result property="plantId" column="plant_id"/> |
||||
<result property="createByOrgLevel" column="create_by_org_level"/> |
||||
<result property="comments" column="comments"/> |
||||
<result property="createTime" column="create_time"/> |
||||
<result property="createBy" column="create_by"/> |
||||
<result property="updateTime" column="update_time"/> |
||||
<result property="updateBy" column="update_by"/> |
||||
</resultMap> |
||||
|
||||
<resultMap id="sewageJobItemVO" type="digital.laboratory.platform.sewage.vo.SewageJobItemVO" extends="sewageJobItemMap"> |
||||
<result property="createUserName" column ="create_user_name"/> |
||||
<result property="updateUserName" column ="update_user_name"/> |
||||
|
||||
<result property="sewageTreatmentPlantName" column="sewage_treatment_plant_name"/> |
||||
<result property="sewageTreatmentPlantShortName" column="sewage_treatment_plant_short_name"/> |
||||
<result property="sewageTreatmentPlantAddress" column="sewage_treatment_plant_address"/> |
||||
<result property="sewageTreatmentPlantCoverageArea" column="sewage_treatment_plant_coverage_area"/> |
||||
<result property="sewageTreatmentPlantProvinceCode" column="sewage_treatment_plant_province_code"/> |
||||
<result property="sewageTreatmentPlantProvinceContacts" column="sewage_treatment_plant_province_contacts"/> |
||||
<result property="sewageTreatmentPlantCityCode" column="sewage_treatment_plant_city_code"/> |
||||
<result property="sewageTreatmentPlantCityContacts" column="sewage_treatment_plant_city_contacts"/> |
||||
<result property="sewageTreatmentPlantDistrictCode" column="sewage_treatment_plant_district_code"/> |
||||
<result property="sewageTreatmentPlantDistrictContacts" column="sewage_treatment_plant_district_contacts"/> |
||||
<result property="sewageTreatmentPlantWaterInletCount" column="sewage_treatment_plant_water_inlet_count"/> |
||||
<result property="sewageTreatmentPlantDailyFlowDesign" column="sewage_treatment_plant_daily_flow_design"/> |
||||
<result property="sewageTreatmentPlantDailyFlowReal" column="sewage_treatment_plant_daily_flow_real"/> |
||||
<result property="sewageTreatmentPlantDomesticSewageProportion" column="sewage_treatment_plant_domestic_sewage_proportion"/> |
||||
<result property="sewageTreatmentPlantServicePopulation" column="sewage_treatment_plant_service_population"/> |
||||
<result property="sewageTreatmentPlantComments" column="sewage_treatment_plant_comments"/> |
||||
<result property="sewageTreatmentPlantUpdateLog" column="sewage_treatment_plant_update_log" typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/> |
||||
|
||||
<result property="sewageTreatmentPlantProvinceName" column="sewage_treatment_plant_province_name"/> |
||||
<result property="sewageTreatmentPlantCityName" column="sewage_treatment_plant_city_name"/> |
||||
<result property="sewageTreatmentPlantDistrictName" column="sewage_treatment_plant_district_name"/> |
||||
<result property="sewageTreatmentPlantCreateUserName" column ="sewage_treatment_plant_create_user_name"/> |
||||
<result property="sewageTreatmentPlantUpdateUserName" column ="sewage_treatment_plant_update_user_name"/> |
||||
|
||||
</resultMap> |
||||
|
||||
|
||||
<sql id="getSewageJobItemVOSQL"> |
||||
SELECT |
||||
ji.id, |
||||
ji.job_id, |
||||
ji.plant_id, |
||||
ji.create_by_org_level, |
||||
ji.comments, |
||||
ji.create_time, |
||||
ji.create_by, |
||||
ji.update_time, |
||||
ji.update_by, |
||||
( |
||||
SELECT user.name |
||||
FROM dlp_base.sys_user user |
||||
WHERE user.user_id=ji.create_by |
||||
) AS create_user_name, |
||||
( |
||||
SELECT user.name |
||||
FROM dlp_base.sys_user user |
||||
WHERE user.user_id=ji.update_by |
||||
) AS update_user_name, |
||||
stp.name AS sewage_treatment_plant_name, |
||||
stp.short_name AS sewage_treatment_plant_short_name, |
||||
stp.address AS sewage_treatment_plant_address, |
||||
stp.coverage_area AS sewage_treatment_plant_coverage_area, |
||||
stp.province_code AS sewage_treatment_plant_province_code, |
||||
stp.province_contacts AS sewage_treatment_plant_province_contacts, |
||||
stp.city_code AS sewage_treatment_plant_city_code, |
||||
stp.city_contacts AS sewage_treatment_plant_city_contacts, |
||||
stp.district_code AS sewage_treatment_plant_district_code, |
||||
stp.district_contacts AS sewage_treatment_plant_district_contacts, |
||||
stp.water_inlet_count AS sewage_treatment_plant_water_inlet_count, |
||||
stp.daily_flow_design AS sewage_treatment_plant_daily_flow_design, |
||||
stp.daily_flow_real AS sewage_treatment_plant_daily_flow_real, |
||||
stp.domestic_sewage_proportion AS sewage_treatment_plant_domestic_sewage_proportion, |
||||
stp.service_population AS sewage_treatment_plant_service_population, |
||||
stp.comments AS sewage_treatment_plant_comments, |
||||
stp.update_log AS sewage_treatment_plant_update_log, |
||||
( |
||||
SELECT name |
||||
FROM dlp_base.b_area area |
||||
WHERE area.id=stp.province_code |
||||
) AS sewage_treatment_plant_province_name, |
||||
( |
||||
SELECT name |
||||
FROM dlp_base.b_area area |
||||
WHERE area.id=stp.city_code |
||||
) AS sewage_treatment_plant_city_name, |
||||
( |
||||
SELECT name |
||||
FROM dlp_base.b_area area |
||||
WHERE area.id=stp.district_code |
||||
) AS sewage_treatment_plant_district_name, |
||||
( |
||||
SELECT user.name |
||||
FROM dlp_base.sys_user user |
||||
WHERE user.user_id=stp.create_by |
||||
) AS sewage_treatment_plant_create_user_name, |
||||
( |
||||
SELECT user.name |
||||
FROM dlp_base.sys_user user |
||||
WHERE user.user_id=stp.update_by |
||||
) AS sewage_treatment_plant_update_user_name |
||||
from b_sewage_job_item ji |
||||
LEFT JOIN b_sewage_treatment_plant stp ON ji.plant_id=stp.id |
||||
# WHERE ji.id='001CE29E49956D3106CFD7B86B53875B' |
||||
|
||||
</sql> |
||||
|
||||
<!-- 根据条件取 SewageJobItemVO 列表分页 --> |
||||
<select id="getSewageJobItemVOPage" resultMap="sewageJobItemVO" resultType="digital.laboratory.platform.sewage.vo.SewageJobItemVO"> |
||||
<include refid="getSewageJobItemVOSQL"/> |
||||
${ew.customSqlSegment} |
||||
</select> |
||||
|
||||
<!-- 根据条件取 SewageJobItemVO 列表 --> |
||||
<select id="getSewageJobItemVOList" resultMap="sewageJobItemVO" resultType="digital.laboratory.platform.sewage.vo.SewageJobItemVO"> |
||||
<include refid="getSewageJobItemVOSQL"/> |
||||
${ew.customSqlSegment} |
||||
</select> |
||||
|
||||
|
||||
</mapper> |
@ -0,0 +1,180 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
|
||||
<mapper namespace="digital.laboratory.platform.sewage.mapper.SewageJobMapper"> |
||||
|
||||
<resultMap id="sewageJobMap" type="digital.laboratory.platform.sewage.entity.SewageJob"> |
||||
<id property="id" column="id"/> |
||||
<result property="jobNo" column="job_no"/> |
||||
<result property="name" column="name"/> |
||||
<result property="jobYear" column="job_year"/> |
||||
<result property="jobSeason" column="job_season"/> |
||||
<!-- <result property="jobRegion" column="job_region"/>--> |
||||
<result property="description" column="description"/> |
||||
<result property="launcheOrgId" column="launche_org_id"/> |
||||
<result property="source" column="source"/> |
||||
<result property="expirationDate" column="expiration_date"/> |
||||
<result property="startDate" column="start_date"/> |
||||
<result property="comments" column="comments"/> |
||||
<result property="status" column="status"/> |
||||
<result property="launcheUserId" column="launche_user_id"/> |
||||
<result property="launcheDate" column="launche_date"/> |
||||
<result property="createTime" column="create_time"/> |
||||
<result property="createBy" column="create_by"/> |
||||
<result property="updateTime" column="update_time"/> |
||||
<result property="updateBy" column="update_by"/> |
||||
|
||||
</resultMap> |
||||
|
||||
<resultMap id="sewageJobVO" type="digital.laboratory.platform.sewage.vo.SewageJobVO" extends="sewageJobMap"> |
||||
<result property="launcheOrgName" column="launche_org_name"/> |
||||
<result property="launcheUserName" column="launche_user_name"/> |
||||
|
||||
<result property="createUserName" column="create_user_name"/> |
||||
<result property="updateUserName" column="update_user_name"/> |
||||
</resultMap> |
||||
|
||||
<resultMap id="sewageTreeDataVo" type="digital.laboratory.platform.sewage.vo.SewageTreeVO"> |
||||
<id property="jcId" column="jc_id"/> |
||||
<result property="jobId" column="job_id"/> |
||||
<result property="jcName" column="jc_name"/> |
||||
<result property="jcNo" column="jc_no"/> |
||||
<result property="jcStatus" column="jc_status"/> |
||||
<result property="waterInletNo" column="water_Inlet_No"/> |
||||
<result property="waterFactoryId" column="water_factory_id"/> |
||||
<result property="waterFactoryName" column="water_factory_name"/> |
||||
<result property="provinceCode" column="province_code"/> |
||||
<result property="cityCode" column="city_code"/> |
||||
<result property="districtCode" column="district_code"/> |
||||
<result property="provinceName" column="province_name"/> |
||||
<result property="cityName" column="city_name"/> |
||||
<result property="districtName" column="district_name"/> |
||||
</resultMap> |
||||
|
||||
<sql id="getSewageJobVOSQL"> |
||||
SELECT sj.*, |
||||
(SELECT org.name |
||||
FROM dlp_base.sys_org org |
||||
WHERE org.org_id = sj.launche_org_id) AS launche_org_name, |
||||
(SELECT user.name |
||||
FROM dlp_base.sys_user user |
||||
WHERE user.user_id=sj.launche_user_id |
||||
) AS launche_user_name |
||||
, ( |
||||
SELECT user.name |
||||
FROM dlp_base.sys_user user |
||||
WHERE user.user_id=sj.create_by |
||||
) AS create_user_name |
||||
, ( |
||||
SELECT user.name |
||||
FROM dlp_base.sys_user user |
||||
WHERE user.user_id=sj.update_by |
||||
) AS update_user_name |
||||
FROM b_sewage_job sj |
||||
</sql> |
||||
<sql id="getSewageJobTreeData"> |
||||
SELECT tab1.jc_id, |
||||
tab1.jc_no, |
||||
tab1.jc_name, |
||||
tab1.jc_status, |
||||
tab1.water_inlet_no, |
||||
tab1.job_id, |
||||
tab1.water_factory_id, |
||||
tab2.name as water_factory_name, |
||||
tab2.province_code, |
||||
tab2.city_code, |
||||
tab2.district_code, |
||||
tab2.province_name, |
||||
tab2.city_name, |
||||
tab2.district_name |
||||
from (SELECT t1.id as jc_id, |
||||
t1.im_no as jc_no, |
||||
t1.sample_name as jc_name, |
||||
t1.`status` as jc_status, |
||||
t1.water_inlet_number as water_inlet_no, |
||||
t1.job_id, |
||||
t2.plant_id as water_factory_id |
||||
from b_sewage_job_identification_material t1 |
||||
LEFT JOIN b_sewage_job_item t2 on t1.job_item_id = t2.id) tab1 |
||||
LEFT JOIN b_sewage_treatment_plant tab2 on tab1.water_factory_id = tab2.id |
||||
</sql> |
||||
|
||||
<!-- 根据条件取 SewageJobVO 列表分页 --> |
||||
<select id="getSewageJobVOPage" resultMap="sewageJobVO" |
||||
resultType="digital.laboratory.platform.sewage.vo.SewageJobVO"> |
||||
<include refid="getSewageJobVOSQL"/> |
||||
${ew.customSqlSegment} |
||||
</select> |
||||
|
||||
<!-- 根据条件取 SewageJobVO 列表 --> |
||||
<select id="getSewageJobVOList" resultMap="sewageJobVO" |
||||
resultType="digital.laboratory.platform.sewage.vo.SewageJobVO"> |
||||
<include refid="getSewageJobVOSQL"/> |
||||
${ew.customSqlSegment} |
||||
</select> |
||||
<select id="getSewageSendData" resultMap="sewageTreeDataVo" |
||||
resultType="digital.laboratory.platform.sewage.vo.SewageTreeVO"> |
||||
<include refid="getSewageJobTreeData"/> |
||||
${ew.customSqlSegment} |
||||
</select> |
||||
|
||||
<select id="getArea" resultType="String"> |
||||
select id |
||||
from dlp_base.b_area |
||||
where fullname = #{fullname} |
||||
</select> |
||||
|
||||
<select id="getAllJob" resultType="digital.laboratory.platform.sewage.entity.SewageJob"> |
||||
<include refid="getAllJobSql"></include> |
||||
</select> |
||||
<sql id="getAllJobSql"> |
||||
SELECT T.id, |
||||
T.start_date, |
||||
T.expiration_date, |
||||
T.name, |
||||
T.type, |
||||
T.create_time |
||||
FROM (select id, start_date, expiration_date, name, "月份任务" as type, create_time |
||||
from b_sewage_job |
||||
where status = 1 |
||||
and name LIKE CONCAT('%', #{name}, '%') |
||||
union all |
||||
select id, start_date, expiration_date, name, "公安部任务" as type, create_time |
||||
from b_sewage_job_gab |
||||
where name LIKE CONCAT('%', #{name}, '%')) T |
||||
order by create_time desc |
||||
</sql> |
||||
|
||||
<select id="querySewageJobByStartDate" resultMap="sewageJobVO"> |
||||
SELECT * |
||||
FROM (SELECT sj.*, |
||||
(SELECT org.name |
||||
FROM dlp_base.sys_org org |
||||
WHERE org.org_id = sj.launche_org_id) AS launche_org_name, |
||||
(SELECT user.name |
||||
FROM dlp_base.sys_user user |
||||
WHERE user.user_id = sj.launche_user_id) AS launche_user_name, |
||||
(SELECT user.name |
||||
FROM dlp_base.sys_user user |
||||
WHERE user.user_id = sj.create_by) AS create_user_name, |
||||
(SELECT user.name |
||||
FROM dlp_base.sys_user user |
||||
WHERE user.user_id = sj.update_by) AS update_user_name |
||||
FROM `b_sewage_job` sj |
||||
WHERE start_date <![CDATA[ < ]]> #{startDate} |
||||
ORDER BY start_date DESC) AS subquery |
||||
GROUP BY DATE_FORMAT(subquery.start_date, '%Y-%m') |
||||
LIMIT #{limit} |
||||
</select> |
||||
|
||||
<select id="statisticsDiffStatusJob" resultType="digital.laboratory.platform.sewage.dto.StatisticsDiffStatusJobDTO"> |
||||
SELECT |
||||
COUNT(status = #{created} OR NULL) as jobStatusCreatedNum, |
||||
COUNT(status = #{publish} OR NULL) as jobStatusClaimNum, |
||||
COUNT(status = #{stopReceive} OR NULL) as stopReceiveSampleNum, |
||||
COUNT(status = #{finished} OR NULL) as jobStatusFinishedNum |
||||
FROM b_sewage_job |
||||
</select> |
||||
|
||||
</mapper> |
@ -0,0 +1,192 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
|
||||
<mapper namespace="digital.laboratory.platform.sewage.mapper.SewageTreatmentPlantMapper"> |
||||
|
||||
<resultMap id="sewageTreatmentPlantMap" type="digital.laboratory.platform.sewage.entity.SewageTreatmentPlant"> |
||||
<id property="id" column="id"/> |
||||
<result property="name" column="name"/> |
||||
<result property="shortName" column="short_name"/> |
||||
<result property="number" column="number"/> |
||||
<result property="address" column="address"/> |
||||
<result property="coverageArea" column="coverage_area"/> |
||||
<result property="provinceCode" column="province_code"/> |
||||
<result property="provinceContacts" column="province_contacts"/> |
||||
<result property="cityCode" column="city_code"/> |
||||
<result property="cityContacts" column="city_contacts"/> |
||||
<result property="districtCode" column="district_code"/> |
||||
<result property="districtContacts" column="district_contacts"/> |
||||
<result property="waterInletCount" column="water_inlet_count"/> |
||||
<result property="dailyFlowDesign" column="daily_flow_design"/> |
||||
<result property="dailyFlowReal" column="daily_flow_real"/> |
||||
<result property="domesticSewageProportion" column="domestic_sewage_proportion"/> |
||||
<result property="servicePopulation" column="service_population"/> |
||||
<result property="comments" column="comments"/> |
||||
<result property="updateLog" column="update_log" |
||||
typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/> |
||||
<result property="createTime" column="create_time"/> |
||||
<result property="createBy" column="create_by"/> |
||||
<result property="updateTime" column="update_time"/> |
||||
<result property="updateBy" column="update_by"/> |
||||
<result property="status" column="status"/> |
||||
<result property="provinceName" column="province_name"/> |
||||
<result property="cityName" column="city_name"/> |
||||
<result property="districtName" column="district_name"/> |
||||
</resultMap> |
||||
|
||||
<resultMap id="SewageTreatmentPlantVO" type="digital.laboratory.platform.sewage.vo.SewageTreatmentPlantVO" |
||||
extends="sewageTreatmentPlantMap"> |
||||
<result property="createUserName" column="create_user_name"/> |
||||
<result property="updateUserName" column="update_user_name"/> |
||||
</resultMap> |
||||
|
||||
|
||||
<sql id="getSewageTreatmentPlantVOSQL"> |
||||
SELECT id, |
||||
name, |
||||
short_name, |
||||
address, |
||||
coverage_area, |
||||
province_code, |
||||
province_contacts, |
||||
city_code, |
||||
city_contacts, |
||||
district_code, |
||||
district_contacts, |
||||
water_inlet_count, |
||||
daily_flow_design, |
||||
daily_flow_real, |
||||
domestic_sewage_proportion, |
||||
service_population, |
||||
comments, |
||||
update_log, |
||||
create_time, |
||||
create_by, |
||||
update_time, |
||||
update_by, |
||||
province_name, |
||||
city_name, |
||||
district_name, |
||||
number, |
||||
status, |
||||
(SELECT user.name |
||||
FROM dlp_base.sys_user user |
||||
WHERE user.user_id = stp.create_by) AS create_user_name, |
||||
(SELECT user.name |
||||
FROM dlp_base.sys_user user |
||||
WHERE user.user_id = stp.update_by) AS update_user_name |
||||
FROM b_sewage_treatment_plant stp |
||||
</sql> |
||||
|
||||
<!-- 根据条件取 SewageTreatmentPlantVO 列表分页 --> |
||||
<select id="getSewageTreatmentPlantVOPage" resultMap="SewageTreatmentPlantVO" |
||||
resultType="digital.laboratory.platform.sewage.vo.SewageTreatmentPlantVO"> |
||||
<include refid="getSewageTreatmentPlantVOSQL"/> |
||||
${ew.customSqlSegment} |
||||
</select> |
||||
|
||||
<!-- 根据条件取 SewageTreatmentPlantVO 列表 --> |
||||
<select id="getSewageTreatmentPlantVOList" resultMap="SewageTreatmentPlantVO" |
||||
resultType="digital.laboratory.platform.sewage.vo.SewageTreatmentPlantVO"> |
||||
<include refid="getSewageTreatmentPlantVOSQL"/> |
||||
${ew.customSqlSegment} |
||||
</select> |
||||
|
||||
|
||||
<sql id="getSewageTreatmentPlantGABVOSQL"> |
||||
SELECT id, |
||||
name, |
||||
short_name, |
||||
address, |
||||
coverage_area, |
||||
province_code, |
||||
province_contacts, |
||||
city_code, |
||||
city_contacts, |
||||
district_code, |
||||
district_contacts, |
||||
water_inlet_count, |
||||
daily_flow_design, |
||||
daily_flow_real, |
||||
domestic_sewage_proportion, |
||||
service_population, |
||||
comments, |
||||
update_log, |
||||
create_time, |
||||
create_by, |
||||
update_time, |
||||
update_by, |
||||
province_name, |
||||
city_name, |
||||
district_name, |
||||
number, |
||||
status, |
||||
(SELECT user.name |
||||
FROM dlp_base.sys_user user |
||||
WHERE user.user_id = stpg.create_by) AS create_user_name, |
||||
(SELECT user.name |
||||
FROM dlp_base.sys_user user |
||||
WHERE user.user_id = stpg.update_by) AS update_user_name |
||||
FROM b_sewage_treatment_plant_gab stpg |
||||
</sql> |
||||
|
||||
<!-- 查询公安部对应的污水厂--> |
||||
<select id="getSewageTreatmentPlantGABVOOne" resultMap="SewageTreatmentPlantVO" |
||||
resultType="digital.laboratory.platform.sewage.vo.SewageTreatmentPlantVO"> |
||||
<include refid="getSewageTreatmentPlantGABVOSQL"></include> |
||||
${ew.customSqlSegment} |
||||
</select> |
||||
|
||||
<select id="getSewageTreatmentPlantGABVOList" resultMap="SewageTreatmentPlantVO" |
||||
resultType="digital.laboratory.platform.sewage.vo.SewageTreatmentPlantVO"> |
||||
<include refid="getSewageTreatmentPlantGABVOSQL"></include> |
||||
${ew.customSqlSegment} |
||||
</select> |
||||
|
||||
<!-- 更新公安部的污水厂编号--> |
||||
<update id="updateSewageTreatmentPlantGABNumber" parameterType="string"> |
||||
UPDATE b_sewage_treatment_plant_gab |
||||
SET |
||||
<if test="number != null and number != ''"> |
||||
number = #{number} |
||||
</if> |
||||
WHERE id = #{id} |
||||
</update> |
||||
|
||||
<!-- 新增公安部大数据平台的污水厂--> |
||||
<insert id="insertSewageTreatmentPlantGAB"> |
||||
INSERT INTO b_sewage_treatment_plant_gab |
||||
(`id`, |
||||
`name`, |
||||
`number`, |
||||
`address`, |
||||
`province_code`, |
||||
`province_name`, |
||||
`city_code`, |
||||
`city_name`, |
||||
`district_code`, |
||||
`district_name`, |
||||
`water_inlet_count`, |
||||
`daily_flow_design`, |
||||
`daily_flow_real`, |
||||
`domestic_sewage_proportion`, |
||||
`service_population`) |
||||
VALUES (#{id}, |
||||
#{name}, |
||||
#{number}, |
||||
#{address}, |
||||
#{provinceCode}, |
||||
#{provinceName}, |
||||
#{cityCode}, |
||||
#{cityName}, |
||||
#{districtCode}, |
||||
#{districtName}, |
||||
#{waterInletCount}, |
||||
#{dailyFlowDesign}, |
||||
#{dailyFlowReal}, |
||||
#{domesticSewageProportion}, |
||||
#{servicePopulation}) |
||||
</insert> |
||||
|
||||
</mapper> |
Loading…
Reference in new issue