Commit e1e35f27 by wang_jiaxing

甘肃法律文书入库

parent 3ac64ab1
package com.founder.config;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.SqlSessionTemplate;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import javax.sql.DataSource;
/**
* Created by summer on 2016/11/25.
*/
@Configuration
@MapperScan(basePackages = "com.founder.file.dao.xjxz", sqlSessionTemplateRef = "xjxzSqlSessionTemplate")
public class DataSourceXjxzConfig {
@Bean(name = "xjxzDataSource")
@ConfigurationProperties(prefix = "spring.datasource.xjxz")
public DataSource db1DataSource() {
return DataSourceBuilder.create().build();
}
@Bean(name = "xjxzSqlSessionFactory")
public SqlSessionFactory db1SqlSessionFactory(@Qualifier("xjxzDataSource") DataSource dataSource) throws Exception {
SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
bean.setDataSource(dataSource);
bean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath:mybatis/xjFlwsMpaaer/*.xml"));
return bean.getObject();
}
@Bean(name = "xjxzSqlSessionTemplate")
public SqlSessionTemplate db1SqlSessionTemplate(@Qualifier("xjxzSqlSessionFactory") SqlSessionFactory sqlSessionFactory) throws Exception {
return new SqlSessionTemplate(sqlSessionFactory);
}
}
package com.founder.config;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.SqlSessionTemplate;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import javax.sql.DataSource;
/**
* Created by summer on 2016/11/25.
*/
@Configuration
@MapperScan(basePackages = "com.founder.file.dao.xjxznew", sqlSessionTemplateRef = "xjxznewSqlSessionTemplate")
public class DataSourceXjxznewConfig {
@Bean(name = "xjxznewDataSource")
@ConfigurationProperties(prefix = "spring.datasource.xjxznew")
public DataSource db1DataSource() {
return DataSourceBuilder.create().build();
}
@Bean(name = "xjxznewSqlSessionFactory")
public SqlSessionFactory db1SqlSessionFactory(@Qualifier("xjxznewDataSource") DataSource dataSource) throws Exception {
SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
bean.setDataSource(dataSource);
bean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath:mybatis/xjnewFlwsMpaaer/*.xml"));
return bean.getObject();
}
@Bean(name = "xjxznewSqlSessionTemplate")
public SqlSessionTemplate db1SqlSessionTemplate(@Qualifier("xjxznewSqlSessionFactory") SqlSessionFactory sqlSessionFactory) throws Exception {
return new SqlSessionTemplate(sqlSessionFactory);
}
}
......@@ -5,10 +5,12 @@ import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.SqlSessionTemplate;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import javax.sql.DataSource;
......@@ -17,24 +19,24 @@ import javax.sql.DataSource;
* Created by summer on 2016/11/25.
*/
@Configuration
@MapperScan(basePackages = "com.founder.file.dao.jzzjk", sqlSessionTemplateRef = "jzzjkSqlSessionTemplate")
public class DataSourceJzzjkConfig {
@MapperScan(basePackages = "com.founder.file.dao.xzxt", sqlSessionTemplateRef = "xzxtSqlSessionTemplate")
public class DataSourceXzxtConfig {
@Bean(name = "jzzjkDataSource")
@ConfigurationProperties(prefix = "spring.datasource.jzzjk")
public DataSource db2DataSource() {
@Bean(name = "xzxtDataSource")
@ConfigurationProperties(prefix = "spring.datasource.xzxt")
public DataSource xzxtDataSource() {
return DataSourceBuilder.create().build();
}
@Bean(name = "jzzjkSqlSessionFactory")
public SqlSessionFactory db2SqlSessionFactory(@Qualifier("jzzjkDataSource") DataSource dataSource) throws Exception {
@Bean(name = "xzxtSqlSessionFactory")
public SqlSessionFactory xzxtSqlSessionFactory(@Qualifier("xzxtDataSource") DataSource dataSource) throws Exception {
SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
bean.setDataSource(dataSource);
bean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath:mybatis/xjFlwsMpaaer/*.xml"));
bean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath:mybatis/mapper/*.xml"));
return bean.getObject();
}
@Bean(name = "jzzjkSqlSessionTemplate")
public SqlSessionTemplate db2SqlSessionTemplate(@Qualifier("jzzjkSqlSessionFactory") SqlSessionFactory sqlSessionFactory) throws Exception {
@Bean(name = "xzxtSqlSessionTemplate")
public SqlSessionTemplate xzxtSqlSessionTemplate(@Qualifier("xzxtSqlSessionFactory") SqlSessionFactory sqlSessionFactory) throws Exception {
return new SqlSessionTemplate(sqlSessionFactory);
}
......
package com.founder.file.controller;
import com.founder.file.service.GxFlwsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
@Slf4j
public class GsFlwsController {
@Autowired
private GxFlwsService gxFlwsService;
@Value("${isStartFlws}")
private String isStartFlws;
@Value("${isStartRxzp}")
private String isStartRxzp;
@RequestMapping("/getFtpFlwsnrToAjFlws")
public String getFtpFlwsnrToAjFlws(@RequestParam(required = false) String xxzjbh){
try {
return gxFlwsService.getFtpFlwsnrToAjFlws(xxzjbh);
} catch (Exception e) {
e.printStackTrace();
log.error("错误信息", e);
return e.getMessage();
}
}
@Scheduled(cron = "${flwsCron}")
public void autoGetFtpFlwsnrToAjFlws(){
if ("true".equals(isStartFlws)){
getFtpFlwsnrToAjFlws(null);
}
}
@RequestMapping("/getFtpFlwsnrToAjRxzp")
public String getFtpFlwsnrToAjRxzp(@RequestParam(required = false) String xxzjbh){
try {
return gxFlwsService.getFtpFlwsnrToAjRxzp(xxzjbh);
} catch (Exception e) {
e.printStackTrace();
log.error("错误信息", e);
return e.getMessage();
}
}
@Scheduled(cron = "${rxzpCron}")
public void autoGetFtpFlwsnrToAjRxzp(){
if ("true".equals(isStartRxzp)){
getFtpFlwsnrToAjRxzp(null);
}
}
}
package com.founder.file.controller;
import com.founder.file.service.XzFlwsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@RestController
@Slf4j
public class XzFlwsController {
@Autowired
private XzFlwsService xzFlwsService;
@Value("${isStart}")
private String isStart;
@RequestMapping("/getJzzjkFlwsnrToXjxz")
public String getJzzjkFlwsnrToXjxz(@DateTimeFormat(pattern = "yyyyMMdd") Date date, @RequestParam(required = false) String xxzjbh){
try {
if (date == null){
Calendar calendar=Calendar.getInstance();
calendar.setTime(new Date());
calendar.add(Calendar.DATE, -1);
date = calendar.getTime();
}
return xzFlwsService.getJzzjkFlwsnrToXjxz(date, xxzjbh);
} catch (Exception e) {
e.printStackTrace();
log.error("错误信息", e);
return e.getMessage();
}
}
@Scheduled(cron = "${cron}")
public void autoGetJzzjkFlwsnrToXjxz(){
if ("true".equals(isStart)){
getJzzjkFlwsnrToXjxz(null, null);
}
}
@RequestMapping("/getRyzbnrToXzxz")
public String getRyzbnrToXzxz(@DateTimeFormat(pattern = "yyyyMMdd") Date date, @RequestParam(required = false) String xxzjbh){
try {
if (date == null){
Calendar calendar=Calendar.getInstance();
calendar.setTime(new Date());
calendar.add(Calendar.DATE, -1);
date = calendar.getTime();
}
return xzFlwsService.getRyzbnrToXzxz(date, xxzjbh);
} catch (Exception e) {
e.printStackTrace();
log.error("错误信息", e);
return e.getMessage();
}
}
@Scheduled(cron = "${zpCron}")
public void autoGetRyzbnrToXzxz(){
if ("true".equals(isStart)){
getRyzbnrToXzxz(null, null);
}
}
@RequestMapping("/getCqbgwsnrToXzxz")
public String getCqbgwsnrToXzxz(@DateTimeFormat(pattern = "yyyyMMdd") Date date, @RequestParam(required = false) String xxzjbh){
try {
if (date == null){
Calendar calendar=Calendar.getInstance();
calendar.setTime(new Date());
calendar.add(Calendar.DATE, -1);
date = calendar.getTime();
}
return xzFlwsService.getCqbgwsnrToXzxz(date, xxzjbh);
} catch (Exception e) {
e.printStackTrace();
log.error("错误信息", e);
return e.getMessage();
}
}
@Scheduled(cron = "${cqbgCron}")
public void autoGetCqbgwsnrToXzxz(){
if ("true".equals(isStart)){
getCqbgwsnrToXzxz(null, null);
}
}
@RequestMapping("/getMinioFlwsnrToXjxz")
public String getMinioFlwsnrToXjxz(@RequestParam(required = false) String xxzjbh){
try {
return xzFlwsService.getMinioFlwsnrToXjxz(xxzjbh);
} catch (Exception e) {
e.printStackTrace();
log.error("错误信息", e);
return e.getMessage();
}
}
@Scheduled(cron = "${minioCron}")
public void autoGetMinioFlwsnrToXjxz(){
if ("true".equals(isStart)){
getMinioFlwsnrToXjxz(null);
}
}
@RequestMapping("/getAllMinioTong")
public Map<String, Object> getAllMinioTong(){
try {
return xzFlwsService.getAllMinioTong();
} catch (Exception e) {
e.printStackTrace();
log.error("错误信息", e);
HashMap<String, Object> map = new HashMap<>();
map.put("error", e.getMessage());
return map;
}
}
@RequestMapping("/getMinioTongByid")
public Map<String, Object> getMinioTongByDcxxid(String id){
try {
String bucketName = xzFlwsService.getMinioTongByid(null, id);
HashMap<String, Object> map = new HashMap<>();
map.put("bucketName", bucketName);
map.put("isExists", bucketName != null);
return map;
} catch (Exception e) {
e.printStackTrace();
log.error("错误信息", e);
HashMap<String, Object> map = new HashMap<>();
map.put("error", e.getMessage());
return map;
}
}
}
package com.founder.file.dao.jzzjk;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.List;
import java.util.Map;
@Mapper
@Component
public interface JzzjkFlwsMapper {
List<Map<String, String>> getFlwsWzByDate(@Param("date") Date date, @Param("xxzjbh") String xxzjbh, @Param("page") Integer page, @Param("rows") Integer rows);
Integer getFlwsCountWzByDate(@Param("date") Date date, @Param("xxzjbh") String xxzjbh);
}
package com.founder.file.dao.xjxz;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.List;
import java.util.Map;
@Mapper
@Component
public interface XzxzFlwsMapper {
int update(@Param("xxzjbh") String xxzjbh, @Param("bytes") byte[] bytes);
List<String> getNoFileFlwsXxzjbh(@Param("flwsList") List<Map<String, String>> flwsList);
List<Map<String, String>> getFlwsWzByDate(@Param("date") Date date, @Param("xxzjbh") String xxzjbh, @Param("begin") Integer page, @Param("end") Integer rows);
Integer getFlwsCountWzByDate(@Param("date") Date date, @Param("xxzjbh") String xxzjbh);
List<String> getJzzjkFlwsList(@Param("date") Date date, @Param("xxzjbh") String xxzjbh);
List<String> getRyzpList(@Param("date") Date date, @Param("xxzjbh") String xxzjbh);
int updateZp(@Param("xxzjbh") String xxzjbh, @Param("bytes") byte[] bytes);
List<String> getCqbgList(@Param("date") Date date, @Param("xxzjbh") String xxzjbh);
int updateCqbg(@Param("xxzjbh") String xxzjbh, @Param("bytes") byte[] bytes);
}
package com.founder.file.dao.xjxznew;
package com.founder.file.dao.xzxt;
import com.founder.file.entity.FlwsEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;
......@@ -10,9 +11,13 @@ import java.util.Map;
@Mapper
@Component
public interface XzxznewFlwsMapper {
public interface GsFlwsMapper {
List<String> getJzzjkFlwsList(@Param("xxzjbh") String xxzjbh);
List<FlwsEntity> getPdfFileList(@Param("xxzjbh") String xxzjbh);
int update(@Param("id") String id, @Param("bytes") byte[] bytes);
int updateFlwsByPdfFile(@Param("id") String id, @Param("bytes") byte[] bytes);
List<FlwsEntity> getFileIdList(@Param("xxzjbh") String xxzjbh);
int updateFlwsByFileId(@Param("id") String id, @Param("bytes") byte[] bytes);
}
package com.founder.file.entity;
import lombok.Data;
/**
* TODO
*
* @author create by lystar
* @date 2023/10/18 16:51
*/
@Data
public class FlwsEntity {
private String id;
private String gs;
}
......@@ -9,16 +9,9 @@ import java.security.NoSuchAlgorithmException;
import java.util.Date;
import java.util.Map;
public interface XzFlwsService {
String getJzzjkFlwsnrToXjxz(Date date, String xxzjbh) throws IOException;
public interface GxFlwsService {
String getFtpFlwsnrToAjFlws(String xxzjbh);
String getRyzbnrToXzxz(Date date, String xxzjbh) throws IOException;
String getCqbgwsnrToXzxz(Date date, String xxzjbh);
String getMinioFlwsnrToXjxz(String xxzjbh);
Map<String, Object> getAllMinioTong() throws Exception;
String getMinioTongByid(MinioClient minioClient, String id) throws Exception;
String getFtpFlwsnrToAjRxzp(String xxzjbh);
}
package com.founder.file.service.impl;
import com.founder.file.dao.xzxt.GsFlwsMapper;
import com.founder.file.entity.FlwsEntity;
import com.founder.file.service.GxFlwsService;
import org.apache.commons.io.IOUtils;
import org.apache.commons.net.ftp.FTPClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
@Service
public class GxFlwsServiceImpl implements GxFlwsService {
@Autowired
private GsFlwsMapper gsFlwsMapper;
// FTP服务器地址
@Value("${ftpHost}")
private String ftpHost;
// FTP服务器端口号,默认为21
@Value("${ftpPort}")
private String ftpPort;
// FTP服务器用户名
@Value("${ftpUsername}")
private String ftpUsername;
// FTP服务器密码
@Value("${ftpPassword}")
private String ftpPassword;
@Value("${ftpFlwsPath}")
private String ftpFlwsPath;
@Value("${ftpRxzpPath}")
private String ftpRxzpPath;
@Override
public String getFtpFlwsnrToAjFlws(String xxzjbh) {
List<FlwsEntity> list = gsFlwsMapper.getPdfFileList(xxzjbh);
int wssl = list.size();
AtomicInteger cgsl = new AtomicInteger(0);
AtomicInteger cwsl = new AtomicInteger(0);
AtomicInteger wswzwksl = new AtomicInteger(0);
AtomicInteger wglsl = new AtomicInteger(0);
FTPClient ftpClient = connectToFTP();
if (ftpClient == null) {
throw new RuntimeException("FTP链接失败");
}
list.forEach(entity -> {
InputStream is = null;
try {
is = ftpClient.retrieveFileStream(ftpFlwsPath + entity.getId() + entity.getGs());
if (is != null) {
byte[] bytes = IOUtils.toByteArray(is);
if (bytes != null && bytes.length > 0) {
int update = gsFlwsMapper.updateFlwsByPdfFile(entity.getId(), bytes);
if (update > 0) {
cgsl.incrementAndGet();
} else {
wglsl.incrementAndGet();
}
}
} else {
wswzwksl.incrementAndGet();
}
} catch (Exception e) {
e.printStackTrace();
cwsl.incrementAndGet();
} finally {
if (is != null) {
try {
is.close();
ftpClient.completePendingCommand();
} catch (IOException e) {
e.printStackTrace();
}
}
}
});
try {
// 退出登录
ftpClient.logout();
// 断开连接
ftpClient.disconnect();
} catch (IOException e) {
e.printStackTrace();
}
int cg = cgsl.get();
int cw = cwsl.get();
int wswzwk = wswzwksl.get();
int wgl = wglsl.get();
int wnr = wssl - (cg + cw + wswzwk + wgl);
return "共" + wssl + "个文书准备更新," + "成功更新" + cg + "个,失败" + cw + "个,文书位置为空"
+ wswzwk + "个,未关联文书" + wgl + "个,文书内容为空" + wnr + "个";
}
@Override
public String getFtpFlwsnrToAjRxzp(String xxzjbh) {
List<FlwsEntity> list = gsFlwsMapper.getFileIdList(xxzjbh);
int wssl = list.size();
AtomicInteger cgsl = new AtomicInteger(0);
AtomicInteger cwsl = new AtomicInteger(0);
AtomicInteger wswzwksl = new AtomicInteger(0);
AtomicInteger wglsl = new AtomicInteger(0);
FTPClient ftpClient = connectToFTP();
if (ftpClient == null) {
throw new RuntimeException("FTP链接失败");
}
list.forEach(entity -> {
InputStream is = null;
try {
is = ftpClient.retrieveFileStream(ftpRxzpPath + entity.getId() + entity.getGs());
if (is != null) {
byte[] bytes = IOUtils.toByteArray(is);
if (bytes != null && bytes.length > 0) {
int update = gsFlwsMapper.updateFlwsByFileId(entity.getId(), bytes);
if (update > 0) {
cgsl.incrementAndGet();
} else {
wglsl.incrementAndGet();
}
}
} else {
wswzwksl.incrementAndGet();
}
} catch (Exception e) {
e.printStackTrace();
cwsl.incrementAndGet();
} finally {
if (is != null) {
try {
is.close();
ftpClient.completePendingCommand();
} catch (IOException e) {
e.printStackTrace();
}
}
}
});
try {
// 退出登录
ftpClient.logout();
// 断开连接
ftpClient.disconnect();
} catch (IOException e) {
e.printStackTrace();
}
int cg = cgsl.get();
int cw = cwsl.get();
int wswzwk = wswzwksl.get();
int wgl = wglsl.get();
int wnr = wssl - (cg + cw + wswzwk + wgl);
return "共" + wssl + "个文书准备更新," + "成功更新" + cg + "个,失败" + cw + "个,文书位置为空"
+ wswzwk + "个,未关联文书" + wgl + "个,文书内容为空" + wnr + "个";
}
private FTPClient connectToFTP() {
FTPClient ftpClient = new FTPClient();
try {
// 连接FTP服务器
ftpClient.connect(ftpHost, Integer.parseInt(ftpPort));
// 登录FTP服务器
ftpClient.login(ftpUsername, ftpPassword);
// 设置以二进制方式传输文件
ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);
return ftpClient;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
private boolean isNotEmpty(String str) {
return str != null && !str.isEmpty();
}
}
\ No newline at end of file
package com.founder.file.service.impl;
import com.founder.file.dao.xjxz.XzxzFlwsMapper;
import com.founder.file.dao.xjxznew.XzxznewFlwsMapper;
import com.founder.file.service.XzFlwsService;
import com.founder.util.HttpUtil;
import io.minio.BucketExistsArgs;
import io.minio.GetObjectArgs;
import io.minio.MinioClient;
import io.minio.StatObjectArgs;
import io.minio.errors.ErrorResponseException;
import io.minio.messages.Bucket;
import org.apache.commons.io.IOUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.io.InputStream;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
@Service
public class XzFlwsServiceImpl implements XzFlwsService {
@Autowired
private XzxzFlwsMapper xzxzFlwsMapper;
@Value("${wjwz}")
private String wjwz;
@Autowired
private XzxznewFlwsMapper xzxznewFlwsMapper;
@Value("${minioIp}")
private String minioIp;
@Value("${minioPort}")
private Integer minioPort;
@Value("${accessKey}")
private String accessKey;
@Value("${secretKey}")
private String secretKey;
@Value("${bucketName}")
private String bucketName;
@Value("${bucketCount}")
private Integer bucketCount;
@Value("${secure}")
private Boolean secure;
@Override
public String getJzzjkFlwsnrToXjxz(Date date, String xxzjbh) {
List<String> list = xzxzFlwsMapper.getJzzjkFlwsList(date, xxzjbh);
int wssl = list.size();
AtomicInteger cgsl = new AtomicInteger(0);
AtomicInteger cwsl = new AtomicInteger(0);
AtomicInteger wswzwksl = new AtomicInteger(0);
AtomicInteger wglsl = new AtomicInteger(0);
list.stream().parallel().forEach(id -> {
if (isNotEmpty(id) && isNotEmpty(wjwz)) {
try (InputStream is = HttpUtil.getInputStreamByUrl(wjwz + id)) {
if (is != null) {
byte[] bytes = IOUtils.toByteArray(is);
if (bytes != null && bytes.length > 0) {
int update = xzxzFlwsMapper.update(id, bytes);
if (update > 0) {
cgsl.incrementAndGet();
} else {
wglsl.incrementAndGet();
}
}
}
} catch (Exception e) {
e.printStackTrace();
cwsl.incrementAndGet();
}
} else {
System.out.println("文件位置为空");
wswzwksl.incrementAndGet();
}
});
int cg = cgsl.get();
int cw = cwsl.get();
int wswzwk = wswzwksl.get();
int wgl = wglsl.get();
int wnr = wssl - (cg + cw + wswzwk + wgl);
return "共" + wssl + "个文书准备更新," + "成功更新" + cg + "个,失败" + cw + "个,文书位置为空"
+ wswzwk + "个,未关联文书" + wgl + "个,文书内容为空" + wnr + "个";
}
@Override
public String getRyzbnrToXzxz(Date date, String xxzjbh) {
List<String> list = xzxzFlwsMapper.getRyzpList(date, xxzjbh);
int wssl = list.size();
AtomicInteger cgsl = new AtomicInteger(0);
AtomicInteger cwsl = new AtomicInteger(0);
AtomicInteger wswzwksl = new AtomicInteger(0);
AtomicInteger wglsl = new AtomicInteger(0);
list.stream().parallel().forEach(id -> {
if (isNotEmpty(id) && isNotEmpty(wjwz)) {
try (InputStream is = HttpUtil.getInputStreamByUrl(wjwz + id)) {
if (is != null) {
byte[] bytes = IOUtils.toByteArray(is);
if (bytes != null && bytes.length > 0) {
int update = xzxzFlwsMapper.updateZp(id, bytes);
if (update > 0) {
cgsl.incrementAndGet();
} else {
wglsl.incrementAndGet();
}
}
}
} catch (Exception e) {
e.printStackTrace();
cwsl.incrementAndGet();
}
} else {
System.out.println("文件位置为空");
wswzwksl.incrementAndGet();
}
});
int cg = cgsl.get();
int cw = cwsl.get();
int wswzwk = wswzwksl.get();
int wgl = wglsl.get();
int wnr = wssl - (cg + cw + wswzwk + wgl);
return "共" + wssl + "个文书准备更新," + "成功更新" + cg + "个,失败" + cw + "个,文书位置为空"
+ wswzwk + "个,未关联文书" + wgl + "个,文书内容为空" + wnr + "个";
}
@Override
public String getCqbgwsnrToXzxz(Date date, String xxzjbh) {
List<String> list = xzxzFlwsMapper.getCqbgList(date, xxzjbh);
int wssl = list.size();
AtomicInteger cgsl = new AtomicInteger(0);
AtomicInteger cwsl = new AtomicInteger(0);
AtomicInteger wswzwksl = new AtomicInteger(0);
AtomicInteger wglsl = new AtomicInteger(0);
list.stream().parallel().forEach(id -> {
if (isNotEmpty(id) && isNotEmpty(wjwz)) {
try (InputStream is = HttpUtil.getInputStreamByUrl(wjwz + id)) {
if (is != null) {
byte[] bytes = IOUtils.toByteArray(is);
if (bytes != null && bytes.length > 0) {
int update = xzxzFlwsMapper.updateCqbg(id, bytes);
if (update > 0) {
cgsl.incrementAndGet();
} else {
wglsl.incrementAndGet();
}
}
}
} catch (Exception e) {
e.printStackTrace();
cwsl.incrementAndGet();
}
} else {
System.out.println("文件位置为空");
wswzwksl.incrementAndGet();
}
});
int cg = cgsl.get();
int cw = cwsl.get();
int wswzwk = wswzwksl.get();
int wgl = wglsl.get();
int wnr = wssl - (cg + cw + wswzwk + wgl);
return "共" + wssl + "个文书准备更新," + "成功更新" + cg + "个,失败" + cw + "个,文书位置为空"
+ wswzwk + "个,未关联文书" + wgl + "个,文书内容为空" + wnr + "个";
}
@Override
public String getMinioFlwsnrToXjxz(String xxzjbh) {
List<String> list = xzxznewFlwsMapper.getJzzjkFlwsList(xxzjbh);
int wssl = list.size();
AtomicInteger cgsl = new AtomicInteger(0);
AtomicInteger cwsl = new AtomicInteger(0);
AtomicInteger wswzwksl = new AtomicInteger(0);
AtomicInteger wsidwksl = new AtomicInteger(0);
AtomicInteger wglsl = new AtomicInteger(0);
MinioClient minioClient = getMinioClient();
list.stream().parallel().forEach(id -> {
if (isNotEmpty(id)) {
String minioTongByid = null;
try {
minioTongByid = getMinioTongByid(minioClient, id);
} catch (Exception e) {
e.printStackTrace();
}
if (minioTongByid == null) {
wswzwksl.incrementAndGet();
} else {
try (InputStream is = minioClient.getObject(GetObjectArgs.builder().bucket(minioTongByid).object(id).build())) {
if (is != null) {
byte[] bytes = IOUtils.toByteArray(is);
if (bytes != null && bytes.length > 0) {
int update = xzxznewFlwsMapper.update(id, bytes);
if (update > 0) {
cgsl.incrementAndGet();
} else {
wglsl.incrementAndGet();
}
}
}
} catch (Exception e) {
e.printStackTrace();
cwsl.incrementAndGet();
}
}
} else {
System.out.println("文件id为空");
wsidwksl.incrementAndGet();
}
});
int cg = cgsl.get();
int cw = cwsl.get();
int wsidwk = wsidwksl.get();
int wswzwk = wswzwksl.get();
int wgl = wglsl.get();
return "共" + wssl + "个文书准备更新," + "成功更新" + cg + "个,失败" + cw + "个,文书dcxx_id为空"
+ wsidwk + "个,未关联文书" + wgl + "个,文书位置为空" + wswzwk + "个";
}
@Override
public Map<String, Object> getAllMinioTong() throws Exception {
MinioClient minioClient = getMinioClient();
List<Bucket> buckets = minioClient.listBuckets();
ArrayList<String> list = new ArrayList<>();
for (Bucket bucket : buckets) {
list.add(bucket.name());
}
HashMap<String, Object> map = new HashMap<>();
map.put("BucketList", list);
return map;
}
@Override
public String getMinioTongByid(MinioClient minioClient, String id) throws Exception {
if (minioClient == null) {
minioClient = getMinioClient();
}
HashMap<String, Object> map = new HashMap<>();
for (int i = 0; i < bucketCount; i++) {
boolean exists = minioClient.bucketExists(BucketExistsArgs.builder().bucket(bucketName + i).build());
if (exists) {
boolean fileExist = getBucketFileExist(minioClient, id, bucketName + i);
if (fileExist) {
return bucketName + i;
}
}
}
return null;
}
private boolean isNotEmpty(String str) {
return str != null && !str.isEmpty();
}
public MinioClient getMinioClient() {
return MinioClient.builder()
// .endpoint(url) //两种都可以,这种全路径的其实就是下面分开配置一样的
.endpoint(minioIp, minioPort, secure)
.credentials(accessKey, secretKey)
.build();
}
/**
* 检测某个桶内是否存在某个文件
*
* @param objectName 文件名称
* @param bucketName 桶名称
*/
private boolean getBucketFileExist(MinioClient minioClient, String objectName, String bucketName) throws Exception {
if (!StringUtils.hasLength(objectName) || !StringUtils.hasLength(bucketName)) {
throw new RuntimeException("检测文件的时候,文件名和桶名不能为空!");
}
try {
// 判断文件是否存在
return minioClient.bucketExists(BucketExistsArgs.builder().bucket(bucketName).build()) &&
minioClient.statObject(StatObjectArgs.builder().bucket(bucketName).object(objectName).build()) != null;
} catch (ErrorResponseException e) {
return false;
} catch (Exception e) {
throw new Exception(e);
}
}
}
\ No newline at end of file
......@@ -2,39 +2,9 @@ spring:
datasource:
xzxt:
driver-class-name: oracle.jdbc.OracleDriver
username: XZXT
password: XZXT
jdbc-url: jdbc:oracle:thin:@47.92.129.99:1600:orcl
type: com.alibaba.druid.pool.DruidDataSource
manager:
driver-class-name: oracle.jdbc.OracleDriver
username: manager
password: manager
jdbc-url: jdbc:oracle:thin:@47.92.129.99:1600:orcl
type: com.alibaba.druid.pool.DruidDataSource
xjxz:
# jdbc-url: jdbc:mysql://47.92.223.200:3365/xzxt?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8
# username: xzxt
# password: xzxt
jdbc-url: jdbc:mysql://155.200.1.23:1106/jzzjk?allowPublicKeyRetrieval=true&useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8
username: root
password: XzxtPwd#54
driver-class-name: com.mysql.cj.jdbc.Driver
type: com.alibaba.druid.pool.DruidDataSource
jzzjk:
jdbc-url: jdbc:oracle:thin:@10.20.2.208:6521:XJXZXT
username: JZZJK
password: JZZJK
driver-class-name: oracle.jdbc.driver.OracleDriver
type: com.alibaba.druid.pool.DruidDataSource
xjxznew:
# jdbc-url: jdbc:mysql://47.92.223.200:3365/xzxt?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8
# username: xzxt
# password: xzxt
jdbc-url: jdbc:mysql://155.200.1.23:1106/jzzjk?allowPublicKeyRetrieval=true&useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8
username: root
password: XzxtPwd#54
driver-class-name: com.mysql.cj.jdbc.Driver
username: GSJZ_KDXF
password: GSJZ_KDXF
jdbc-url: jdbc:oracle:thin:@10.178.8.72:1521:GSXZ2
type: com.alibaba.druid.pool.DruidDataSource
#配置jpa 使其展示sql语句
jpa:
......@@ -45,28 +15,20 @@ spring:
password: p!ssw0rd1
poorSize: 1000
clusterSize: 1
clusterId: 1
#最后以/结尾
wjwz: http://localhost:8080/
#开始定时使用true
isStart: false
#定时 0秒 0分开始每3分钟 每时 每日 每月 任意周
cron: 0 0/3 * * * ?
zpCron: 0 0/3 * * * ?
cqbgCron: 0 0/3 * * * ?
minioCron: 0 0 20 * * ?
minioIp: 155.3.2.230 #ip地址
minioPort: 3090 # 端口号
accessKey: minio-jz # 账号
secretKey: minio-jz0426 # 密码
secure: false #如果是true,则用的是https而不是http,默认值是true
bucketName: jz-zs # 桶的名字
bucketCount: 10 # 桶的名字
isStartFlws: false
isStartRxzp: false
#定时 0秒 0分 0时 每日 每月 任意周
flwsCron: 0 0 0 * * ?
rxzpCron: 0 0 1 * * ?
ftpHost: 95.3.202.80
ftpPort: 2121
ftpUsername: tp_ftp
ftpPassword: tp_ftp
ftpFlwsPath: /home/tp_ftp/flws/
ftpRxzpPath: /home/tp_ftp/ztry/
ftpserverip: 47.92.129.99
nginxport: 9053
......
<?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="com.founder.file.dao.xzxt.GsFlwsMapper">
<update id="updateFlwsByPdfFile">
UPDATE AJ_FLWS SET DZWJNR = #{bytes} where PDF_FILE = #{id}
</update>
<update id="updateFlwsByFileId">
UPDATE RXZPB SET DZWJNR = #{bytes} where FILE_ID = #{id}
</update>
<select id="getPdfFileList" resultType="com.founder.file.entity.FlwsEntity">
select PDF_FILE as id, GS as gs
FROM AJ_FLWS
where PDF_FILE is not null
and (DZWJNR is null or LENGTH(DZWJNR) = 0)
<if test="xxzjbh != null and xxzjbh != ''">
and PDF_FILE = #{xxzjbh}
</if>
</select>
<select id="getFileIdList" resultType="com.founder.file.entity.FlwsEntity">
select FILE_ID as id,GS as gs
FROM RXZPB
where FILE_ID is not null
and (DZWJNR is null or LENGTH(DZWJNR) = 0)
<if test="xxzjbh != null and xxzjbh != ''">
and FILE_ID = #{xxzjbh}
</if>
</select>
</mapper>
\ No newline at end of file
<?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="com.founder.file.dao.xjxznew.XzxznewFlwsMapper">
<update id="update">
UPDATE tb_st_jzgl
set nr = #{bytes}
where dxcc_id = #{id}
and xt_zxbz = '0'
</update>
<select id="getJzzjkFlwsList" resultType="java.lang.String">
select dxcc_id
from tb_st_jzgl
where xt_zxbz = '0' and (nr is null or length(nr) = 0)
<if test="xxzjbh != null and xxzjbh != ''">
and dxcc_id = #{xxzjbh}
</if>
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment