dev
This commit is contained in:
parent
6da5b102df
commit
f10ddf1ed2
|
|
@ -34,6 +34,10 @@ public class DateUtil {
|
||||||
return LocalDateTime.parse(dateTimeStr, DateTimeFormatter.ofPattern(DATE_TIME_FORMAT));
|
return LocalDateTime.parse(dateTimeStr, DateTimeFormatter.ofPattern(DATE_TIME_FORMAT));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static DateTimeFormatter getDateTimeFormatter(String dateTimeStr) {
|
||||||
|
return DateTimeFormatter.ofPattern(dateTimeStr);
|
||||||
|
}
|
||||||
|
|
||||||
//加一天
|
//加一天
|
||||||
public static LocalDateTime addDay(LocalDateTime dateTime) {
|
public static LocalDateTime addDay(LocalDateTime dateTime) {
|
||||||
return dateTime.plusDays(1);
|
return dateTime.plusDays(1);
|
||||||
|
|
|
||||||
|
|
@ -194,6 +194,11 @@ public class HttpUtil {
|
||||||
JSONObject output = post(config.get("social", "url"), JSON.toJSONString(getparms(infno, tag, input)),true);
|
JSONObject output = post(config.get("social", "url"), JSON.toJSONString(getparms(infno, tag, input)),true);
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
public JSONObject callBackMsgId(String infno, String tag, Map<String, Object> input) {
|
||||||
|
|
||||||
|
JSONObject output = post(config.get("social", "url"), JSON.toJSONString(getparms(infno, tag, input)),true);
|
||||||
|
return output;
|
||||||
|
}
|
||||||
public JSONObject callWithOutLog(String infno, String tag, Map<String, Object> input) {
|
public JSONObject callWithOutLog(String infno, String tag, Map<String, Object> input) {
|
||||||
|
|
||||||
JSONObject output = post(config.get("social", "url"), JSON.toJSONString(getparms(infno, tag, input)), false);
|
JSONObject output = post(config.get("social", "url"), JSON.toJSONString(getparms(infno, tag, input)), false);
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,10 @@ package com.syjiaer.clinic.server.mapper.social;
|
||||||
|
|
||||||
import com.syjiaer.clinic.server.entity.social.SocialDirectory;
|
import com.syjiaer.clinic.server.entity.social.SocialDirectory;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.syjiaer.clinic.server.entity.social.dto.SocialDirectoryView;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -14,5 +18,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
*/
|
*/
|
||||||
public interface SocialDirectoryMapper extends BaseMapper<SocialDirectory> {
|
public interface SocialDirectoryMapper extends BaseMapper<SocialDirectory> {
|
||||||
|
|
||||||
|
List<SocialDirectoryView> selectSocialDirectoryView(@Param("codeList") List<String> codeList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -81,11 +81,11 @@ public abstract class BaseService {
|
||||||
return managerUser;
|
return managerUser;
|
||||||
|
|
||||||
}
|
}
|
||||||
protected Page pageHelper(int pageNum, int pageSize, QueryWrapper queryWrapper, BaseMapper mapper){
|
protected <T> Page<T> pageHelper(int pageNum, int pageSize, QueryWrapper<T> queryWrapper, BaseMapper<T> mapper){
|
||||||
Long totalCount = mapper.selectCount(queryWrapper);
|
Long totalCount = mapper.selectCount(queryWrapper);
|
||||||
queryWrapper.last("LIMIT " + (pageNum - 1) * pageSize + ", " + pageSize);
|
queryWrapper.last("LIMIT " + (pageNum - 1) * pageSize + ", " + pageSize);
|
||||||
List list = mapper.selectList(queryWrapper);
|
List<T> list = mapper.selectList(queryWrapper);
|
||||||
Page page = new Page();
|
Page<T> page = new Page<>();
|
||||||
page.setList(list);
|
page.setList(list);
|
||||||
page.setTotal_count(totalCount);
|
page.setTotal_count(totalCount);
|
||||||
page.setTotal_page((int) Math.ceil(totalCount / (double) pageSize));
|
page.setTotal_page((int) Math.ceil(totalCount / (double) pageSize));
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,193 @@
|
||||||
package com.syjiaer.clinic.server.service.social;
|
package com.syjiaer.clinic.server.service.social;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.syjiaer.clinic.server.common.config.Config;
|
||||||
|
import com.syjiaer.clinic.server.common.exception.MessageException;
|
||||||
|
import com.syjiaer.clinic.server.common.util.*;
|
||||||
import com.syjiaer.clinic.server.common.vo.Page;
|
import com.syjiaer.clinic.server.common.vo.Page;
|
||||||
|
import com.syjiaer.clinic.server.entity.social.SocialDirectory;
|
||||||
|
import com.syjiaer.clinic.server.entity.social.SocialDirectoryVersion;
|
||||||
import com.syjiaer.clinic.server.entity.social.dto.SocialDirectoryView;
|
import com.syjiaer.clinic.server.entity.social.dto.SocialDirectoryView;
|
||||||
|
import com.syjiaer.clinic.server.mapper.social.SocialDirectoryMapper;
|
||||||
|
import com.syjiaer.clinic.server.mapper.social.SocialDirectoryVersionMapper;
|
||||||
import com.syjiaer.clinic.server.service.BaseService;
|
import com.syjiaer.clinic.server.service.BaseService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Service
|
||||||
public class SocialDirectoryService extends BaseService {
|
public class SocialDirectoryService extends BaseService {
|
||||||
|
@Autowired
|
||||||
|
private HttpUtil httpUtil;
|
||||||
|
@Autowired
|
||||||
|
private Config config;
|
||||||
|
@Autowired
|
||||||
|
private FileUtil fileUtil;
|
||||||
|
@Autowired
|
||||||
|
private DictoryUtil dictoryUtil;
|
||||||
|
@Autowired
|
||||||
|
private StringUtil stringUtil;
|
||||||
|
@Autowired
|
||||||
|
private SocialDirectoryMapper socialDirectoryMapper;
|
||||||
|
@Autowired
|
||||||
|
private SocialDirectoryVersionMapper socialDirectoryVersionMapper;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 下载接口
|
* 下载接口
|
||||||
* @param version_name 版本名称
|
* @param version_name 版本名称
|
||||||
* @param type 类型
|
* @param type 类型
|
||||||
*/
|
*/
|
||||||
public void download(String version_name,int type){
|
public JSONObject download(String version_name,int type){
|
||||||
|
Map<String, Object> input = new HashMap<>();
|
||||||
|
input.put("ver", version_name);
|
||||||
|
String infno = String.valueOf(type);
|
||||||
|
System.out.println("上个版本号:" + version_name);
|
||||||
|
JSONObject result=null;
|
||||||
|
try {
|
||||||
|
result = httpUtil.callBackMsgId(infno,"data", input);
|
||||||
|
}catch (Exception e){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
String filename = result.getString("filename");
|
||||||
|
String file_qury_no = result.getString("file_qury_no");
|
||||||
|
String fixmedins_code = config.get("social", "fixmedinsCode");
|
||||||
|
String path = "";
|
||||||
|
try {
|
||||||
|
// 创建临时目录
|
||||||
|
Path tempDir = Files.createTempDirectory("temp");
|
||||||
|
path = tempDir.toString();
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new MessageException("创建临时下载目录失败");
|
||||||
|
}
|
||||||
|
Map<String, Object> input_dw = new HashMap<>();
|
||||||
|
input_dw.put("file_qury_no", file_qury_no);
|
||||||
|
input_dw.put("fixmedins_code", fixmedins_code);
|
||||||
|
input_dw.put("filename", filename);
|
||||||
|
System.out.println("文件地址:"+path+"/"+filename);
|
||||||
|
httpUtil.callToFile("9102", "fsDownloadIn", input_dw, path + "/" + filename);
|
||||||
|
List<String> file_list = fileUtil.unzip(path, filename);
|
||||||
|
List<String> read_list = fileUtil.readToList(file_list);
|
||||||
|
List<String[]> tab_list = new ArrayList<>();
|
||||||
|
//将read_list中的每一行按tab分割,存入tab_list中
|
||||||
|
for (String s : read_list) {
|
||||||
|
String[] line_array = s.split("\t");
|
||||||
|
for (int j = 0; j < line_array.length; j++) {
|
||||||
|
if (line_array[j].equals("null")) {
|
||||||
|
line_array[j] = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tab_list.add(line_array);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//清楚原有的code
|
||||||
|
int batchSize = 100;
|
||||||
|
for (int i = 0; i < tab_list.size(); i += batchSize) {
|
||||||
|
List<String> code_list = new ArrayList<>();
|
||||||
|
for (int j = i; j < i + batchSize && j < tab_list.size(); j++) {
|
||||||
|
String[] line_array = tab_list.get(j);
|
||||||
|
String val = line_array[0];
|
||||||
|
code_list.add(val);
|
||||||
|
}
|
||||||
|
QueryWrapper<SocialDirectory> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.in("code", code_list);
|
||||||
|
socialDirectoryMapper.delete(queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
//将tab_list中的每一行存入数据库
|
||||||
|
Map<String, String> title_map = dictoryUtil.getTitleMap(infno);
|
||||||
|
List<SocialDirectory> list = new ArrayList<>();
|
||||||
|
HashMap<String, SocialDirectory> tmp_map = new HashMap<>();
|
||||||
|
for (String[] line_array : tab_list) {
|
||||||
|
SocialDirectory socialDirectory = new SocialDirectory();
|
||||||
|
socialDirectory.setType(type);
|
||||||
|
String code = line_array[0];
|
||||||
|
socialDirectory.setId(code);
|
||||||
|
socialDirectory.setCode(code);
|
||||||
|
Map<String, String> map = new HashMap<>();
|
||||||
|
for (String key_str : title_map.keySet()) {
|
||||||
|
int key = Integer.parseInt(key_str);
|
||||||
|
String title = title_map.get(key_str);
|
||||||
|
if (!title.startsWith("json.")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
title = title.substring(5);
|
||||||
|
String val = line_array[key - 1];
|
||||||
|
map.put(title, val);
|
||||||
|
}
|
||||||
|
socialDirectory.setData(JSONObject.toJSONString(map));
|
||||||
|
socialDirectory.setName(map.get("name"));
|
||||||
|
socialDirectory.setVersionName(map.get("version_name"));
|
||||||
|
String flag = "";
|
||||||
|
DateTimeFormatter dateTimeFormatter = DateUtil.getDateTimeFormatter(DateUtil.DATE_TIME_FORMAT);
|
||||||
|
if (type == 1301) {
|
||||||
|
flag = line_array[78];
|
||||||
|
socialDirectory.setProducer(line_array[53]);
|
||||||
|
socialDirectory.setKeyword(line_array[1] + "," + line_array[3] + "," + line_array[61]);
|
||||||
|
socialDirectory.setCreateDatetime(LocalDateTime.parse(line_array[80], dateTimeFormatter));
|
||||||
|
socialDirectory.setUpdateDatetime(LocalDateTime.parse(line_array[81], dateTimeFormatter));
|
||||||
|
}
|
||||||
|
if (type == 1302) {
|
||||||
|
flag = line_array[13];
|
||||||
|
socialDirectory.setKeyword(line_array[19]);
|
||||||
|
socialDirectory.setCreateDatetime(LocalDateTime.parse(line_array[15], dateTimeFormatter));
|
||||||
|
socialDirectory.setUpdateDatetime(LocalDateTime.parse(line_array[16], dateTimeFormatter));
|
||||||
|
}
|
||||||
|
if (type == 1305) {
|
||||||
|
flag = line_array[6];
|
||||||
|
socialDirectory.setKeyword(line_array[9] + "," + line_array[2]);
|
||||||
|
}
|
||||||
|
if (type == 1306) {
|
||||||
|
flag = line_array[67];
|
||||||
|
socialDirectory.setProducer(line_array[59]);
|
||||||
|
socialDirectory.setKeyword(line_array[4]);
|
||||||
|
}
|
||||||
|
if (type == 1307) {
|
||||||
|
flag = line_array[18];
|
||||||
|
socialDirectory.setKeyword(line_array[5] + "," + line_array[7]);
|
||||||
|
}
|
||||||
|
if (type == 1309) {
|
||||||
|
flag = line_array[5];
|
||||||
|
//因为1309不使用版本名称,而是版本编号,所以需要手动设置
|
||||||
|
socialDirectory.setVersionName(line_array[11]);
|
||||||
|
}
|
||||||
|
if (type == 1320) {
|
||||||
|
flag = line_array[28];
|
||||||
|
socialDirectory.setKeyword(line_array[23] + "," + line_array[3] + "," + line_array[4]);
|
||||||
|
}
|
||||||
|
if (type == 1321) {
|
||||||
|
flag = line_array[13];
|
||||||
|
socialDirectory.setKeyword(line_array[6] + "," + line_array[10]);
|
||||||
|
}
|
||||||
|
SocialDirectory tmp_socialDirectory = tmp_map.get(code);
|
||||||
|
if (tmp_socialDirectory == null && flag.equals("1")) {
|
||||||
|
list.add(socialDirectory);
|
||||||
|
tmp_map.put(code, socialDirectory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
socialDirectoryMapper.insert(list, 100);
|
||||||
|
SocialDirectoryVersion socialDirectoryVersion = new SocialDirectoryVersion();
|
||||||
|
socialDirectoryVersion.setId(stringUtil.generateRandomId());
|
||||||
|
socialDirectoryVersion.setType(type);
|
||||||
|
socialDirectoryVersion.setPreVersionName(version_name);
|
||||||
|
socialDirectoryVersion.setCurrentVersionName(list.get(0).getVersionName());
|
||||||
|
socialDirectoryVersion.setSize(list.size());
|
||||||
|
socialDirectoryVersion.setCreateDatetime(LocalDateTime.now());
|
||||||
|
socialDirectoryVersionMapper.insert(socialDirectoryVersion);
|
||||||
|
JSONObject result_object = new JSONObject();
|
||||||
|
result_object.put("current_version_name", list.get(0).getVersionName());
|
||||||
|
result_object.put("pre_version_name", version_name);
|
||||||
|
return result_object;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,31 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.syjiaer.clinic.server.modules.social.mapper.SocialDirectoryMapper">
|
<mapper namespace="com.syjiaer.clinic.server.mapper.social.SocialDirectoryMapper">
|
||||||
|
|
||||||
|
|
||||||
|
<select id="selectSocialDirectoryView"
|
||||||
|
resultType="com.syjiaer.clinic.server.entity.social.dto.SocialDirectoryView">
|
||||||
|
SELECT social_directory.id,
|
||||||
|
social_directory.code,
|
||||||
|
social_directory.name,
|
||||||
|
social_directory.keyword,
|
||||||
|
social_directory.type,
|
||||||
|
social_directory.producer,
|
||||||
|
social_directory.create_datetime,
|
||||||
|
social_directory.update_datetime,
|
||||||
|
social_directory.version_name,
|
||||||
|
social_directory.data,
|
||||||
|
social_directory_limit.hilist_lmtpric_type,
|
||||||
|
social_directory_limit.hilist_pric_uplmt_amt,
|
||||||
|
social_directory_self.selfpay_prop_type,
|
||||||
|
social_directory_self.selfpay_prop,
|
||||||
|
social_directory_upinfo.begndate,
|
||||||
|
social_directory_upinfo.enddate,
|
||||||
|
social_directory_upinfo.wubi,
|
||||||
|
social_directory_upinfo.pinyin
|
||||||
|
FROM social_directory
|
||||||
|
LEFT JOIN social_directory_limit ON social_directory.code = social_directory_limit.code
|
||||||
|
LEFT JOIN social_directory_upinfo ON social_directory.code::text = social_directory_upinfo.code::text
|
||||||
|
LEFT JOIN social_directory_self ON social_directory.code::text = social_directory_self.code::text
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,10 @@
|
||||||
package com.syjiaer.clinic.server;
|
package com.syjiaer.clinic.server;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.syjiaer.clinic.server.common.vo.Page;
|
||||||
|
import com.syjiaer.clinic.server.entity.social.dto.SocialDirectoryView;
|
||||||
import com.syjiaer.clinic.server.mapper.social.SocialDirectoryMapper;
|
import com.syjiaer.clinic.server.mapper.social.SocialDirectoryMapper;
|
||||||
|
import com.syjiaer.clinic.server.service.social.SocialDirectoryService;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
@ -10,12 +13,10 @@ import org.springframework.boot.test.context.SpringBootTest;
|
||||||
class ServerApplicationTests {
|
class ServerApplicationTests {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SocialDirectoryMapper socialDirectoryMapper;
|
private SocialDirectoryService socialDirectoryService;
|
||||||
@Test
|
@Test
|
||||||
void contextLoads() {
|
void contextLoads() {
|
||||||
QueryWrapper queryWrapper = new QueryWrapper();
|
|
||||||
queryWrapper.last("limit 100");
|
|
||||||
socialDirectoryMapper.selectList(queryWrapper);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue