dev
This commit is contained in:
parent
2e467405a2
commit
6c84b8012e
5
pom.xml
5
pom.xml
|
|
@ -132,6 +132,11 @@
|
||||||
<artifactId>poi-ooxml</artifactId>
|
<artifactId>poi-ooxml</artifactId>
|
||||||
<version>5.2.3</version>
|
<version>5.2.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-j</artifactId>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ import com.syjiaer.clinic.server.entity.social.vo.SocialDirectoryView;
|
||||||
import com.syjiaer.clinic.server.mapper.goods.GoodsMapper;
|
import com.syjiaer.clinic.server.mapper.goods.GoodsMapper;
|
||||||
import com.syjiaer.clinic.server.mapper.social.*;
|
import com.syjiaer.clinic.server.mapper.social.*;
|
||||||
import com.syjiaer.clinic.server.service.BaseService;
|
import com.syjiaer.clinic.server.service.BaseService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.domain.Sort;
|
import org.springframework.data.domain.Sort;
|
||||||
|
|
@ -38,6 +39,7 @@ import java.util.stream.Collectors;
|
||||||
/*
|
/*
|
||||||
* 医保目录
|
* 医保目录
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class SocialDirectoryService extends BaseService {
|
public class SocialDirectoryService extends BaseService {
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|
@ -61,7 +63,6 @@ public class SocialDirectoryService extends BaseService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private GoodsMapper goodsMapper;
|
private GoodsMapper goodsMapper;
|
||||||
|
|
||||||
private Logger logger = Logger.getLogger(SocialDirectoryService.class.getName());
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 下载接口
|
* 下载接口
|
||||||
|
|
@ -71,7 +72,7 @@ public class SocialDirectoryService extends BaseService {
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public String download(String version_name, int type) {
|
public String download(String version_name, int type) {
|
||||||
List<String[]> tab_list = httpUtil.download(version_name, type);
|
List<String[]> tab_list = httpUtil.download(version_name, type);
|
||||||
if (tab_list.isEmpty()){
|
if (tab_list.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
//清楚原有的code
|
//清楚原有的code
|
||||||
|
|
@ -94,9 +95,9 @@ public class SocialDirectoryService extends BaseService {
|
||||||
Map<String, String> title_map = dictoryUtil.getTitleMap(String.valueOf(type));
|
Map<String, String> title_map = dictoryUtil.getTitleMap(String.valueOf(type));
|
||||||
List<SocialDirectory> list = new ArrayList<>();
|
List<SocialDirectory> list = new ArrayList<>();
|
||||||
HashMap<String, SocialDirectory> tmp_map = new HashMap<>();
|
HashMap<String, SocialDirectory> tmp_map = new HashMap<>();
|
||||||
String next_version_name="";
|
String next_version_name = "";
|
||||||
for (int i=0;i<tab_list.size();i++) {
|
for (int i = 0; i < tab_list.size(); i++) {
|
||||||
String[] line_array=tab_list.get(i);
|
String[] line_array = tab_list.get(i);
|
||||||
SocialDirectory socialDirectory = new SocialDirectory();
|
SocialDirectory socialDirectory = new SocialDirectory();
|
||||||
socialDirectory.setType(type);
|
socialDirectory.setType(type);
|
||||||
String code = line_array[0];
|
String code = line_array[0];
|
||||||
|
|
@ -136,23 +137,23 @@ public class SocialDirectoryService extends BaseService {
|
||||||
socialDirectory.setProducer(line_array[59]);
|
socialDirectory.setProducer(line_array[59]);
|
||||||
socialDirectory.setKeyword(line_array[4]);
|
socialDirectory.setKeyword(line_array[4]);
|
||||||
}
|
}
|
||||||
if (type == 1309){
|
if (type == 1309) {
|
||||||
flag = line_array[5];
|
flag = line_array[5];
|
||||||
socialDirectory.setCreateDatetime(LocalDateTime.parse(line_array[7],dateTimeFormatter));
|
socialDirectory.setCreateDatetime(LocalDateTime.parse(line_array[7], dateTimeFormatter));
|
||||||
socialDirectory.setCreateDatetime(LocalDateTime.parse(line_array[8],dateTimeFormatter));
|
socialDirectory.setCreateDatetime(LocalDateTime.parse(line_array[8], dateTimeFormatter));
|
||||||
}
|
}
|
||||||
if (type == 1314){
|
if (type == 1314) {
|
||||||
flag = line_array[8];
|
flag = line_array[8];
|
||||||
}
|
}
|
||||||
if (type == 1315){
|
if (type == 1315) {
|
||||||
flag = line_array[8];
|
flag = line_array[8];
|
||||||
}
|
}
|
||||||
if (type == 1320){
|
if (type == 1320) {
|
||||||
flag = line_array[28];
|
flag = line_array[28];
|
||||||
}
|
}
|
||||||
SocialDirectory tmp_socialDirectory = tmp_map.get(code);
|
SocialDirectory tmp_socialDirectory = tmp_map.get(code);
|
||||||
if(i==0){
|
if (i == 0) {
|
||||||
next_version_name=socialDirectory.getVersionName();
|
next_version_name = socialDirectory.getVersionName();
|
||||||
}
|
}
|
||||||
if (tmp_socialDirectory == null && flag.equals("1")) {
|
if (tmp_socialDirectory == null && flag.equals("1")) {
|
||||||
list.add(socialDirectory);
|
list.add(socialDirectory);
|
||||||
|
|
@ -161,11 +162,11 @@ public class SocialDirectoryService extends BaseService {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (next_version_name.isEmpty()){
|
if (next_version_name.isEmpty()) {
|
||||||
return next_version_name;
|
return next_version_name;
|
||||||
}
|
}
|
||||||
socialDirectoryVersionService.saveVersion(type, version_name, next_version_name, list.size());
|
socialDirectoryVersionService.saveVersion(type, version_name, next_version_name, list.size());
|
||||||
if(list.isEmpty()){
|
if (list.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -175,31 +176,31 @@ public class SocialDirectoryService extends BaseService {
|
||||||
return next_version_name;
|
return next_version_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveToMongoDb(SocialDirectory socialDirectory){
|
private void saveToMongoDb(SocialDirectory socialDirectory) {
|
||||||
SocialDirectoryMongodb socialDirectoryMongodb = new SocialDirectoryMongodb();
|
SocialDirectoryMongodb socialDirectoryMongodb = new SocialDirectoryMongodb();
|
||||||
BeanUtils.copyProperties(socialDirectory, socialDirectoryMongodb);
|
BeanUtils.copyProperties(socialDirectory, socialDirectoryMongodb);
|
||||||
Query query = new Query(Criteria.where("code").is(socialDirectoryMongodb.getCode()));
|
Query query = new Query(Criteria.where("code").is(socialDirectoryMongodb.getCode()));
|
||||||
if (mongoTemplate.exists(query, SocialDirectoryMongodb.class,"social_directory")) {
|
if (mongoTemplate.exists(query, SocialDirectoryMongodb.class, "social_directory")) {
|
||||||
|
|
||||||
Update update = new Update();
|
Update update = new Update();
|
||||||
update.set("name", socialDirectoryMongodb.getName());
|
update.set("name", socialDirectoryMongodb.getName());
|
||||||
update.set("keyword", socialDirectoryMongodb.getKeyword());
|
update.set("keyword", socialDirectoryMongodb.getKeyword());
|
||||||
update.set("type", socialDirectoryMongodb.getType());
|
update.set("type", socialDirectoryMongodb.getType());
|
||||||
update.set("producer", socialDirectoryMongodb.getProducer());
|
update.set("producer", socialDirectoryMongodb.getProducer());
|
||||||
mongoTemplate.updateFirst(query, update, SocialDirectoryMongodb.class,"social_directory");
|
mongoTemplate.updateFirst(query, update, SocialDirectoryMongodb.class, "social_directory");
|
||||||
}else{
|
} else {
|
||||||
mongoTemplate.insert(socialDirectoryMongodb, "social_directory");
|
mongoTemplate.insert(socialDirectoryMongodb, "social_directory");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void saveListToMongoDb(List<SocialDirectory> list){
|
private void saveListToMongoDb(List<SocialDirectory> list) {
|
||||||
for(SocialDirectory socialDirectory:list){
|
for (SocialDirectory socialDirectory : list) {
|
||||||
saveToMongoDb(socialDirectory);
|
saveToMongoDb(socialDirectory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initMongoDb(){
|
private void initMongoDb() {
|
||||||
if (!mongoTemplate.collectionExists("social_directory")) {
|
if (!mongoTemplate.collectionExists("social_directory")) {
|
||||||
System.out.println("创建了social_directory集合");
|
System.out.println("创建了social_directory集合");
|
||||||
mongoTemplate.createCollection("social_directory");
|
mongoTemplate.createCollection("social_directory");
|
||||||
|
|
@ -232,9 +233,6 @@ public class SocialDirectoryService extends BaseService {
|
||||||
//mongodb分页
|
//mongodb分页
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QueryWrapper<SocialDirectory> codeqw = new QueryWrapper<>();
|
QueryWrapper<SocialDirectory> codeqw = new QueryWrapper<>();
|
||||||
if (typeList.size() == 1) {
|
if (typeList.size() == 1) {
|
||||||
codeqw.eq("type", typeList.get(0));
|
codeqw.eq("type", typeList.get(0));
|
||||||
|
|
@ -244,8 +242,8 @@ public class SocialDirectoryService extends BaseService {
|
||||||
|
|
||||||
//模糊搜索
|
//模糊搜索
|
||||||
if (keyword != null && !keyword.trim().isEmpty()) {
|
if (keyword != null && !keyword.trim().isEmpty()) {
|
||||||
codeqw.and(wrapper->
|
codeqw.and(wrapper ->
|
||||||
wrapper.like("name", keyword).or().like("code", keyword).or().like("keyword", keyword)
|
wrapper.like("name", keyword).or().like("code", keyword).or().like("keyword", keyword)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// 执行查询
|
// 执行查询
|
||||||
|
|
@ -323,7 +321,7 @@ public class SocialDirectoryService extends BaseService {
|
||||||
* @param type 类型
|
* @param type 类型
|
||||||
*/
|
*/
|
||||||
public List<Map<String, Object>> getColumnList(int type) {
|
public List<Map<String, Object>> getColumnList(int type) {
|
||||||
Integer[] typeList = {1301, 1302, 1305, 1306, 1307, 1309, 1314, 1315, 1320, 1321,1361,1362};
|
Integer[] typeList = {1301, 1302, 1305, 1306, 1307, 1309, 1314, 1315, 1320, 1321, 1361, 1362};
|
||||||
//判断type在数组中
|
//判断type在数组中
|
||||||
if (!Arrays.asList(typeList).contains(type)) {
|
if (!Arrays.asList(typeList).contains(type)) {
|
||||||
throw new MessageException("参数 type 不能为空");
|
throw new MessageException("参数 type 不能为空");
|
||||||
|
|
@ -333,18 +331,19 @@ public class SocialDirectoryService extends BaseService {
|
||||||
// 资源文件的路径
|
// 资源文件的路径
|
||||||
String resourceName = "doc_title/" + type + ".json";
|
String resourceName = "doc_title/" + type + ".json";
|
||||||
StringBuilder content = new StringBuilder();
|
StringBuilder content = new StringBuilder();
|
||||||
try (InputStream inputStream = classLoader.getResourceAsStream(resourceName);
|
try {
|
||||||
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) {
|
InputStream inputStream = classLoader.getResourceAsStream(resourceName);
|
||||||
if (inputStream != null) {
|
if(inputStream==null){
|
||||||
String line;
|
return resultList;
|
||||||
while ((line = reader.readLine()) != null) {
|
}
|
||||||
content.append(line);
|
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
|
||||||
}
|
String line;
|
||||||
} else {
|
while ((line = reader.readLine()) != null) {
|
||||||
logger.info("未找到资源文件: " + resourceName);
|
content.append(line);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
log.error("doc_title解析错误:{} ", resourceName);
|
||||||
|
return resultList;
|
||||||
}
|
}
|
||||||
JSONArray list = JSON.parseArray(content.toString());
|
JSONArray list = JSON.parseArray(content.toString());
|
||||||
for (int i = 0; i < list.size(); i++) {
|
for (int i = 0; i < list.size(); i++) {
|
||||||
|
|
@ -371,7 +370,7 @@ public class SocialDirectoryService extends BaseService {
|
||||||
public List<SocialDirectoryView> fullList(List<String> codeList) {
|
public List<SocialDirectoryView> fullList(List<String> codeList) {
|
||||||
List<SocialDirectoryView> socialDirectoryViewList = new ArrayList<>();
|
List<SocialDirectoryView> socialDirectoryViewList = new ArrayList<>();
|
||||||
QueryWrapper queryWrapper = new QueryWrapper();
|
QueryWrapper queryWrapper = new QueryWrapper();
|
||||||
queryWrapper.in("code",codeList);
|
queryWrapper.in("code", codeList);
|
||||||
List<SocialDirectory> socialDirectoryList = socialDirectoryMapper.selectList(queryWrapper);
|
List<SocialDirectory> socialDirectoryList = socialDirectoryMapper.selectList(queryWrapper);
|
||||||
List<SocialDirectoryUpinfo> socialDirectoryUpinfoList = socialDirectoryUpinfoMapper.selectList(queryWrapper);
|
List<SocialDirectoryUpinfo> socialDirectoryUpinfoList = socialDirectoryUpinfoMapper.selectList(queryWrapper);
|
||||||
List<SocialDirectoryLimit> socialDirectoryLimitList = socialDirectoryLimitMapper.selectList(queryWrapper);
|
List<SocialDirectoryLimit> socialDirectoryLimitList = socialDirectoryLimitMapper.selectList(queryWrapper);
|
||||||
|
|
@ -383,7 +382,7 @@ public class SocialDirectoryService extends BaseService {
|
||||||
Map<String, SocialDirectorySelf> selfMap = socialDirectorySelfList.stream()
|
Map<String, SocialDirectorySelf> selfMap = socialDirectorySelfList.stream()
|
||||||
.collect(Collectors.toMap(SocialDirectorySelf::getCode, self -> self));
|
.collect(Collectors.toMap(SocialDirectorySelf::getCode, self -> self));
|
||||||
|
|
||||||
for(SocialDirectory socialDirectory : socialDirectoryList){
|
for (SocialDirectory socialDirectory : socialDirectoryList) {
|
||||||
SocialDirectoryView socialDirectoryView = new SocialDirectoryView();
|
SocialDirectoryView socialDirectoryView = new SocialDirectoryView();
|
||||||
socialDirectoryView.setJson(JSONObject.parseObject(socialDirectory.getData()));
|
socialDirectoryView.setJson(JSONObject.parseObject(socialDirectory.getData()));
|
||||||
socialDirectoryView.setData(null);
|
socialDirectoryView.setData(null);
|
||||||
|
|
@ -466,7 +465,7 @@ public class SocialDirectoryService extends BaseService {
|
||||||
goodsQueryWrapper.eq("hilist_code", code);
|
goodsQueryWrapper.eq("hilist_code", code);
|
||||||
goodsQueryWrapper.last("limit 1");
|
goodsQueryWrapper.last("limit 1");
|
||||||
Goods goods = goodsMapper.selectOne(goodsQueryWrapper);
|
Goods goods = goodsMapper.selectOne(goodsQueryWrapper);
|
||||||
if (goods!=null){
|
if (goods != null) {
|
||||||
socialDirectoryView.setMinPackagingUnit(goods.getMinPackagingUnit());
|
socialDirectoryView.setMinPackagingUnit(goods.getMinPackagingUnit());
|
||||||
socialDirectoryView.setPackagingUnit(goods.getPackagingUnit());
|
socialDirectoryView.setPackagingUnit(goods.getPackagingUnit());
|
||||||
socialDirectoryView.setInventoryWholeNumber(goods.getInventoryWholeNumber());
|
socialDirectoryView.setInventoryWholeNumber(goods.getInventoryWholeNumber());
|
||||||
|
|
@ -495,11 +494,11 @@ public class SocialDirectoryService extends BaseService {
|
||||||
Criteria.where("producer").regex(keyword, "i")
|
Criteria.where("producer").regex(keyword, "i")
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
long count = mongoTemplate.count(query, SocialDirectoryMongodb.class,"social_directory");
|
long count = mongoTemplate.count(query, SocialDirectoryMongodb.class, "social_directory");
|
||||||
query.skip((long) (page - 1) * size).limit(size);
|
query.skip((long) (page - 1) * size).limit(size);
|
||||||
List<SocialDirectoryMongodb> mongodbList = mongoTemplate.find(query, SocialDirectoryMongodb.class,"social_directory");
|
List<SocialDirectoryMongodb> mongodbList = mongoTemplate.find(query, SocialDirectoryMongodb.class, "social_directory");
|
||||||
List<String> codeList=new ArrayList<>();
|
List<String> codeList = new ArrayList<>();
|
||||||
for(SocialDirectoryMongodb mongodb:mongodbList){
|
for (SocialDirectoryMongodb mongodb : mongodbList) {
|
||||||
codeList.add(mongodb.getCode());
|
codeList.add(mongodb.getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -519,7 +518,7 @@ public class SocialDirectoryService extends BaseService {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<Map<String,Object>> searchProducer(String keyword, Integer type) {
|
public List<Map<String, Object>> searchProducer(String keyword, Integer type) {
|
||||||
QueryWrapper<SocialDirectory> codeqw = new QueryWrapper<>();
|
QueryWrapper<SocialDirectory> codeqw = new QueryWrapper<>();
|
||||||
codeqw.select("producer,count(1) as c");
|
codeqw.select("producer,count(1) as c");
|
||||||
if (type != null) {
|
if (type != null) {
|
||||||
|
|
@ -527,7 +526,7 @@ public class SocialDirectoryService extends BaseService {
|
||||||
}
|
}
|
||||||
//模糊搜索
|
//模糊搜索
|
||||||
if (keyword != null && !keyword.trim().isEmpty()) {
|
if (keyword != null && !keyword.trim().isEmpty()) {
|
||||||
codeqw.and(wrapper->
|
codeqw.and(wrapper ->
|
||||||
wrapper.like("name", keyword).or().like("code", keyword).or().like("keyword", keyword)
|
wrapper.like("name", keyword).or().like("code", keyword).or().like("keyword", keyword)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,9 @@ spring:
|
||||||
host: dev.jizhiweb.cn
|
host: dev.jizhiweb.cn
|
||||||
port: 6379
|
port: 6379
|
||||||
datasource:
|
datasource:
|
||||||
driver-class-name: org.postgresql.Driver
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
url: jdbc:postgresql://dev.jizhiweb.cn:15321/syjiaer_clinic
|
url: jdbc:mysql://dev.jizhiweb.cn:3306/syjiaer_clinic
|
||||||
username: postgres
|
username: root
|
||||||
password: i7L0BS91pADGuy7z
|
password: i7L0BS91pADGuy7z
|
||||||
config:
|
config:
|
||||||
import: optional:classpath:developer-config.yml
|
import: optional:classpath:developer-config.yml
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue