提交初始代码
commit
e5d91984bf
@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<annotationProcessing>
|
||||
<profile name="Maven default annotation processors profile" enabled="true">
|
||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
<module name="LianzhongCollect" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
</component>
|
||||
<component name="JavacSettings">
|
||||
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
|
||||
<module name="LianzhongCollect" options="-parameters" />
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RemoteRepositoriesConfiguration">
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="central" />
|
||||
<option name="url" value="https://maven.aliyun.com/nexus/content/groups/public" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="rdc-snapshots" />
|
||||
<option name="name" value="rdc-snapshots" />
|
||||
<option name="url" value="https://packages.aliyun.com/maven/repository/2360197-snapshot-rKvQJZ/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Central Repository" />
|
||||
<option name="url" value="https://repo.maven.apache.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="rdc-releases" />
|
||||
<option name="name" value="rdc-releases" />
|
||||
<option name="url" value="https://packages.aliyun.com/maven/repository/2360197-release-kcpW7u/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Maven Central repository" />
|
||||
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="jboss.community" />
|
||||
<option name="name" value="JBoss Community repository" />
|
||||
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="snapshots" />
|
||||
<option name="name" value="snapshots" />
|
||||
<option name="url" value="https://maven.aliyun.com/nexus/content/groups/public" />
|
||||
</remote-repository>
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="JpaBuddyIdeaProjectConfig">
|
||||
<option name="defaultUnitInitialized" value="true" />
|
||||
<option name="renamerInitialized" value="true" />
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
<option name="id" value="jpab" />
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Palette2">
|
||||
<group name="Swing">
|
||||
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||
</item>
|
||||
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||
<initial-values>
|
||||
<property name="text" value="Button" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="RadioButton" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="CheckBox" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="Label" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||
<preferred-size width="-1" height="20" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||
</item>
|
||||
</group>
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,81 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
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>
|
||||
|
||||
<groupId>org.example</groupId>
|
||||
<artifactId>LianzhongCollect</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.4.9</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<dependencies>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp -->
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<version>4.9.2</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.22</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.microsoft.sqlserver</groupId>
|
||||
<artifactId>sqljdbc4</artifactId>
|
||||
<version>4.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.8.6</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>2.3.4.RELEASE</version>
|
||||
</plugin>
|
||||
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
</project>
|
@ -0,0 +1,24 @@
|
||||
package com.jiashi;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @ClassName CommonResult
|
||||
* @Description
|
||||
* @Author linjj
|
||||
* @Date 2024/5/7 10:51
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Data
|
||||
public class CommonResult<T> {
|
||||
|
||||
|
||||
private Integer code;
|
||||
|
||||
private String msgCode;
|
||||
|
||||
private String msg;
|
||||
|
||||
private T data;
|
||||
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.jiashi;
|
||||
|
||||
import com.jiashi.service.UpdateService;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
@EnableAsync
|
||||
@SpringBootApplication
|
||||
@EnableJpaRepositories
|
||||
@EnableJpaAuditing
|
||||
@EnableScheduling
|
||||
public class Main {
|
||||
public static void main(String[] args) throws ExecutionException, InterruptedException {
|
||||
SpringApplication.run(Main.class, args);
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package com.jiashi;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Lazy(value = false)
|
||||
@Component
|
||||
public class SpringUtil implements ApplicationContextAware {
|
||||
private static ApplicationContext applicationContext;
|
||||
|
||||
//获取applicationContext
|
||||
public static ApplicationContext getApplicationContext() {
|
||||
return applicationContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
if (SpringUtil.applicationContext == null) {
|
||||
SpringUtil.applicationContext = applicationContext;
|
||||
}
|
||||
}
|
||||
|
||||
//通过class获取Bean.
|
||||
public static <T> T getBean(Class<T> clazz) {
|
||||
return getApplicationContext().getBean(clazz);
|
||||
}
|
||||
|
||||
|
||||
public static void publishEvent(ApplicationEvent event) {
|
||||
applicationContext.publishEvent(event);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package com.jiashi.dao;
|
||||
|
||||
import com.jiashi.service.CardInfo;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface CardInfoRepository extends JpaRepository<CardInfo, String>, JpaSpecificationExecutor<CardInfo> {
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Modifying
|
||||
@Query("update CardInfo set state=:state where id = :id")
|
||||
public void updateState(String id,Integer state);
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Modifying
|
||||
@Query("update CardInfo set state=:state where id in :ids")
|
||||
public void updateState(List<String> ids, Integer state);
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
package com.jiashi.dao;
|
||||
|
||||
import com.jiashi.service.CardInfo;
|
||||
import com.jiashi.service.Picture;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import javax.persistence.criteria.Predicate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
public class DataQuery {
|
||||
|
||||
|
||||
@Autowired
|
||||
private CardInfoRepository cardInfoRepository;
|
||||
|
||||
@Autowired
|
||||
private PictureRepository pictureRepository;
|
||||
|
||||
public List<CardInfo> dateQuery(){
|
||||
Specification<CardInfo> specification = (root, query, cb) -> {
|
||||
List<Predicate> predicates = new ArrayList<>();
|
||||
predicates.add(cb.equal(root.<String>get("state"), 0));
|
||||
return cb.and(predicates.toArray(new Predicate[predicates.size()]));
|
||||
};
|
||||
|
||||
Sort.Order sortCreateTime = Sort.Order.asc("outdate");
|
||||
Sort sort = Sort.by(sortCreateTime);
|
||||
Pageable pageable = PageRequest.of(0, 100, sort);
|
||||
Page<CardInfo> all = cardInfoRepository.findAll(specification, pageable);
|
||||
return all.toList();
|
||||
}
|
||||
|
||||
|
||||
public void updateBatch(List<CardInfo> cardInfos){
|
||||
for(CardInfo cardInfo:cardInfos){
|
||||
cardInfo.setState(1);
|
||||
}
|
||||
cardInfoRepository.saveAll(cardInfos);
|
||||
}
|
||||
|
||||
|
||||
public void updateBatchState(List<CardInfo> cardInfos,Integer state){
|
||||
List<String> ids = new ArrayList<>();
|
||||
for(CardInfo cardInfo:cardInfos){
|
||||
String id = cardInfo.getId();
|
||||
ids.add(id);
|
||||
}
|
||||
cardInfoRepository.updateState(ids,state);
|
||||
}
|
||||
|
||||
|
||||
public void updateBatchState(CardInfo cardInfo,Integer state){
|
||||
|
||||
cardInfoRepository.updateState(cardInfo.getId(),state);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public List<Picture> getPictures(String FileId){
|
||||
|
||||
Specification<Picture> specification = (root, query, cb) -> {
|
||||
List<Predicate> predicates = new ArrayList<>();
|
||||
predicates.add(cb.equal(root.<String>get("fileid"), FileId));
|
||||
return cb.and(predicates.toArray(new Predicate[predicates.size()]));
|
||||
};
|
||||
List<Picture> all = pictureRepository.findAll(specification);
|
||||
return all;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package com.jiashi.dao;
|
||||
|
||||
import com.jiashi.service.CardInfo;
|
||||
import com.jiashi.service.Picture;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface PictureRepository extends JpaRepository<Picture, String>, JpaSpecificationExecutor<Picture> {
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
package com.jiashi.service;
|
||||
|
||||
import com.jiashi.MyDateUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.boot.test.autoconfigure.data.cassandra.DataCassandraTest;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import java.util.Date;
|
||||
|
||||
@Entity
|
||||
@Table(name = "t_card_info_upload")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class CardInfo {
|
||||
|
||||
// t.id,t.patno,t.patname,t.outdate,t.indate,t.outdeptname,t.patsex,t.patbirthday
|
||||
|
||||
@Id
|
||||
private String id;
|
||||
@Column(name="patno")
|
||||
private String patno;
|
||||
@Column(name="patname")
|
||||
private String patname;
|
||||
|
||||
@Column(name="outdate")
|
||||
private Date outdate;
|
||||
@Column(name="indate")
|
||||
private Date indate;
|
||||
@Column(name="outdeptname")
|
||||
private String outdeptname;
|
||||
@Column(name="patsex")
|
||||
private String patsex;
|
||||
@Column(name="patbirthday")
|
||||
private Date patbirthday;
|
||||
private Integer state;
|
||||
|
||||
|
||||
public String getOutdateStr(){
|
||||
return MyDateUtil.dateToString(this.outdate,"yyyy-MM-dd");
|
||||
}
|
||||
|
||||
public String getOutdateStr2(){
|
||||
return MyDateUtil.dateToString(this.outdate,"yyyy-MM-dd HH:mm:ss");
|
||||
}
|
||||
|
||||
|
||||
public String getIndateStr(){
|
||||
return MyDateUtil.dateToString(this.indate,"yyyy-MM-dd HH:mm:ss");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,15 @@
|
||||
package com.jiashi.service;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public class FormField {
|
||||
|
||||
String key;
|
||||
String value;
|
||||
|
||||
public FormField(String key, String value) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package com.jiashi.service;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "T_Picture")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Picture {
|
||||
|
||||
@Id
|
||||
@Column(name="picid")
|
||||
private String picid;
|
||||
@Column(name="picname")
|
||||
private String picname;
|
||||
@Column(name="fileid")
|
||||
private String fileid;
|
||||
@Column(name="rotatedegree")
|
||||
private Double rotatedegree;
|
||||
|
||||
@Column(name="pickind")
|
||||
private String pickind;
|
||||
|
||||
public String getFileUrl(){
|
||||
String fileUrl = "d:/pic/" + this.getFileid() + "/" + this.getPicname();
|
||||
return fileUrl;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,157 @@
|
||||
package com.jiashi.service;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.jiashi.CommonResult;
|
||||
import com.jiashi.FileUploader;
|
||||
import com.jiashi.dao.DataQuery;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class UpdateService {
|
||||
|
||||
@Autowired
|
||||
private DataQuery dataQuery;
|
||||
|
||||
public List<CardInfo> updateData(){
|
||||
List<CardInfo> cardInfos = dataQuery.dateQuery();
|
||||
dataQuery.updateBatchState(cardInfos,1);
|
||||
return cardInfos;
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void upload() {
|
||||
String uniUrl = "http://10.2.3.24";
|
||||
List<CardInfo> cardInfos = null;
|
||||
ExecutorService executor2 = Executors.newFixedThreadPool(2);
|
||||
ExecutorService executor = Executors.newFixedThreadPool(5);
|
||||
do {
|
||||
try{
|
||||
cardInfos = this.updateData();
|
||||
List<Future> futures2 = new ArrayList<>();
|
||||
for (CardInfo cardInfo : cardInfos) {
|
||||
log.info("开始同步"+cardInfo.getPatno());
|
||||
Future future2 = executor2.submit(()->{
|
||||
try{
|
||||
List<Picture> pictures = dataQuery.getPictures(cardInfo.getId());
|
||||
if(pictures==null||pictures.size()==0){
|
||||
//如果是空的则不同步
|
||||
dataQuery.updateBatchState(cardInfo,5);
|
||||
return;
|
||||
}
|
||||
List<Future> futures = new ArrayList<>();
|
||||
for (Picture picture : pictures) {
|
||||
Future future = executor.submit(() -> {
|
||||
try {
|
||||
String dir = "d:\\pic\\"+picture.getFileid();
|
||||
// 创建File对象
|
||||
File directory = new File(dir);
|
||||
|
||||
// 判断目录是否存在
|
||||
if (!directory.exists()) {
|
||||
// 目录不存在,创建目录
|
||||
boolean created = directory.mkdirs();
|
||||
if (created) {
|
||||
log.info("目录创建成功:" + dir);
|
||||
} else {
|
||||
log.info("目录创建失败:" + dir);
|
||||
}
|
||||
}
|
||||
String cmd = "D:\\lianzhong\\Debug\\Debug\\lianzhong.exe 003 192.168.8.74 " + cardInfo.getId() + " " + picture.getPicid() + " " + cardInfo.getPatno() + " " + cardInfo.getOutdateStr() + " " + picture.getPicname() + " " + picture.getFileUrl() + " " + uniUrl + " " + picture.getRotatedegree();
|
||||
log.info(cmd);
|
||||
java.lang.Process process = java.lang.Runtime.getRuntime().exec(cmd);//执行命令生成cube
|
||||
process.waitFor();
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(),e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
});
|
||||
futures.add(future);
|
||||
}
|
||||
for (Future future : futures) {
|
||||
try {
|
||||
future.get();
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
List<File> files = new ArrayList<>();
|
||||
List<UploadInfo> uploadInfos = new ArrayList<>();
|
||||
for(Picture picture : pictures){
|
||||
files.add(new File(picture.getFileUrl()));
|
||||
UploadInfo uploadInfo = new UploadInfo(cardInfo.getPatno(), cardInfo.getOutdateStr2(), picture.getPicname(), picture.getPicname(), picture.getPickind(), cardInfo.getId(), cardInfo.getPatname(), cardInfo.getIndateStr(), cardInfo.getPatsex());
|
||||
uploadInfos.add(uploadInfo);
|
||||
}
|
||||
|
||||
|
||||
// 额外的表单字段参数
|
||||
List<FormField> params = new ArrayList<>();
|
||||
String s = new Gson().toJson(uploadInfos);
|
||||
params.add(new FormField("uploadFileParams", s));
|
||||
log.info("请求参数:"+s);
|
||||
// 上传
|
||||
try {
|
||||
CommonResult commonResult = FileUploader.uploadFilesWithParams(files, "http://10.2.130.59:8712/api/downplatform/fileUploadJpg", params);
|
||||
if(commonResult.getCode()==0){
|
||||
dataQuery.updateBatchState(cardInfo,3);
|
||||
|
||||
}else{
|
||||
dataQuery.updateBatchState(cardInfo,4);
|
||||
log.error(commonResult.getMsg());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
dataQuery.updateBatchState(cardInfo,4);
|
||||
log.error(e.getMessage(),e);
|
||||
}
|
||||
// 删除文件
|
||||
// String dir = "d:\\pic\\"+cardInfo.getId();
|
||||
// File file = new File(dir);
|
||||
// FileUploader.deleteFolder(file);
|
||||
}catch (Exception e){
|
||||
dataQuery.updateBatchState(cardInfo,4);
|
||||
log.error(e.getMessage(),e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
futures2.add(future2);
|
||||
|
||||
}
|
||||
|
||||
|
||||
for (Future future : futures2) {
|
||||
try {
|
||||
future.get();
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}catch(Exception e) {
|
||||
log.error(e.getMessage(),e);
|
||||
}
|
||||
|
||||
|
||||
}while (cardInfos != null && cardInfos.size() > 0) ;
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,150 @@
|
||||
package com.jiashi.service;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* [ {"inpatientNo":"35131", "disDate":"2020-07-30 00:00:00.000", "fileTitle":"0001.jpg", "uploadFileName":"1.jpg", "assortId":"078F7675CB0048EDBE586D59831C57B0" ,
|
||||
* "patientId":"12312312",
|
||||
* "name":"长三",
|
||||
* "admissDate":"住院时间",
|
||||
* "sex":"男女"
|
||||
* }
|
||||
* ]
|
||||
*/
|
||||
@Data
|
||||
|
||||
public class UploadInfo {
|
||||
private String inpatientNo;
|
||||
private String disDate;
|
||||
private String fileTitle;
|
||||
private String uploadFileName;
|
||||
private String assortId;
|
||||
private String patientId;
|
||||
private String name;
|
||||
private String admissDate;
|
||||
private String sex;
|
||||
|
||||
public UploadInfo(String inpatientNo, String disDate, String fileTitle, String uploadFileName, String assortId, String patientId, String name, String admissDate, String sex) {
|
||||
this.inpatientNo = inpatientNo;
|
||||
this.disDate = disDate;
|
||||
this.fileTitle = fileTitle;
|
||||
this.uploadFileName = uploadFileName;
|
||||
this.assortId = assortId;
|
||||
this.patientId = patientId;
|
||||
this.name = name;
|
||||
this.admissDate = admissDate;
|
||||
this.sex = sex;
|
||||
this.ssAssortId();
|
||||
}
|
||||
|
||||
|
||||
public void ssAssortId() {
|
||||
switch (assortId) {
|
||||
case "1":
|
||||
this.assortId = "2111";
|
||||
break;
|
||||
case "2":
|
||||
this.assortId = "2112";
|
||||
break;
|
||||
case "3":
|
||||
this.assortId = "2113";
|
||||
break;
|
||||
case "4":
|
||||
this.assortId = "2114";
|
||||
break;
|
||||
case "5":
|
||||
this.assortId = "2115";
|
||||
break;
|
||||
case "6":
|
||||
this.assortId = "2116";
|
||||
break;
|
||||
case "7":
|
||||
this.assortId = "2117";
|
||||
break;
|
||||
case "8":
|
||||
this.assortId = "2118";
|
||||
break;
|
||||
case "9":
|
||||
this.assortId = "2119";
|
||||
break;
|
||||
case "10":
|
||||
this.assortId = "21110";
|
||||
break;
|
||||
case "11":
|
||||
this.assortId = "21111";
|
||||
break;
|
||||
case "12":
|
||||
this.assortId = "21112";
|
||||
break;
|
||||
case "13":
|
||||
this.assortId = "21113";
|
||||
break;
|
||||
case "14":
|
||||
this.assortId = "21114";
|
||||
break;
|
||||
case "15":
|
||||
this.assortId = "21115";
|
||||
break;
|
||||
case "16":
|
||||
this.assortId = "21116";
|
||||
break;
|
||||
case "17":
|
||||
this.assortId = "21117";
|
||||
break;
|
||||
case "18":
|
||||
this.assortId = "21118";
|
||||
break;
|
||||
case "19":
|
||||
this.assortId = "21119";
|
||||
break;
|
||||
case "20":
|
||||
this.assortId = "21120";
|
||||
break;
|
||||
case "21":
|
||||
this.assortId = "21121";
|
||||
break;
|
||||
case "22":
|
||||
this.assortId = "21122";
|
||||
break;
|
||||
case "23":
|
||||
this.assortId = "21123";
|
||||
break;
|
||||
case "24":
|
||||
this.assortId = "21124";
|
||||
break;
|
||||
case "25":
|
||||
this.assortId = "21125";
|
||||
break;
|
||||
case "26":
|
||||
this.assortId = "21126";
|
||||
break;
|
||||
case "27":
|
||||
this.assortId = "21127";
|
||||
break;
|
||||
case "28":
|
||||
this.assortId = "21128";
|
||||
break;
|
||||
case "29":
|
||||
this.assortId = "21129";
|
||||
break;
|
||||
case "30":
|
||||
this.assortId = "21130";
|
||||
break;
|
||||
case "31":
|
||||
this.assortId = "21131";
|
||||
break;
|
||||
case "32":
|
||||
this.assortId = "21132";
|
||||
break;
|
||||
case "33":
|
||||
this.assortId = "21133";
|
||||
break;
|
||||
default:
|
||||
this.assortId = "21133";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
|
||||
server:
|
||||
port: 8282
|
||||
|
||||
spring:
|
||||
datasource:
|
||||
url: jdbc:sqlserver://10.2.130.59:1433;DatabaseName=u_medrecord
|
||||
username: sa
|
||||
password: admin123
|
||||
# url: jdbc:sqlserver://10.36.116.108:1433;DatabaseName=emr_record
|
||||
# username: sa
|
||||
# password: xjgs+docus911
|
||||
driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
|
||||
|
||||
jpa:
|
||||
database-platform: org.hibernate.dialect.SQLServerDialect
|
||||
|
@ -0,0 +1,15 @@
|
||||
SELECT * into t_card_info_upload from T_card_info ;
|
||||
|
||||
ALTER TABLE [dbo].[t_card_info_upload] ADD [state] tinyint NULL;
|
||||
|
||||
|
||||
CREATE NONCLUSTERED INDEX [index_state]
|
||||
ON [dbo].[t_card_info_upload] (
|
||||
[state]
|
||||
)
|
||||
|
||||
|
||||
CREATE NONCLUSTERED INDEX [index_outdate]
|
||||
ON [dbo].[t_card_info_upload] (
|
||||
[outdate]
|
||||
)
|
@ -0,0 +1,19 @@
|
||||
//package com.jiashi;
|
||||
//
|
||||
//import com.jiashi.dao.DataQuery;
|
||||
//import org.junit.jupiter.api.Test;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.boot.test.context.SpringBootTest;
|
||||
//import org.springframework.test.context.ContextConfiguration;
|
||||
//
|
||||
//@SpringBootTest
|
||||
//public class DataTest {
|
||||
//
|
||||
// @Autowired
|
||||
// private DataQuery dataQuery;
|
||||
//
|
||||
// @Test
|
||||
// public void test(){
|
||||
//// dataQuery.getCardInfo();
|
||||
// }
|
||||
//}
|
Loading…
Reference in New Issue