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