dev
This commit is contained in:
parent
28967b32c1
commit
61d0afe6fd
|
|
@ -89,12 +89,11 @@ public class HttpUtil {
|
||||||
Map<String, Object> input = new HashMap<>();
|
Map<String, Object> input = new HashMap<>();
|
||||||
input.put("ver", version_name);
|
input.put("ver", version_name);
|
||||||
String infno = String.valueOf(type);
|
String infno = String.valueOf(type);
|
||||||
System.out.println("上个版本号:" + version_name);
|
|
||||||
JSONObject result = null;
|
JSONObject result = null;
|
||||||
try {
|
try {
|
||||||
result = callBackMsgId(infno, "data", input);
|
result = call(infno, "data", input);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return null;
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
String filename = result.getString("filename");
|
String filename = result.getString("filename");
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import com.syjiaer.clinic.server.controller.BaseController;
|
||||||
import com.syjiaer.clinic.server.entity.social.SocialDirectory;
|
import com.syjiaer.clinic.server.entity.social.SocialDirectory;
|
||||||
import com.syjiaer.clinic.server.entity.social.vo.SocialDirectoryView;
|
import com.syjiaer.clinic.server.entity.social.vo.SocialDirectoryView;
|
||||||
import com.syjiaer.clinic.server.service.social.SocialDirectoryService;
|
import com.syjiaer.clinic.server.service.social.SocialDirectoryService;
|
||||||
|
import com.syjiaer.clinic.server.service.social.SocialItemService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
@ -30,6 +31,8 @@ public class SocialDirectoryController extends BaseController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private SocialDirectoryService socialDirectoryService;
|
private SocialDirectoryService socialDirectoryService;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
private SocialItemService socialItemService;
|
||||||
|
@Autowired
|
||||||
private DictoryUtil dictoryUtil;
|
private DictoryUtil dictoryUtil;
|
||||||
|
|
||||||
@RequestMapping("search")
|
@RequestMapping("search")
|
||||||
|
|
@ -57,10 +60,14 @@ public class SocialDirectoryController extends BaseController {
|
||||||
// 处理参数为空的情况,这里假设返回一个错误结果
|
// 处理参数为空的情况,这里假设返回一个错误结果
|
||||||
return error("参数 ver 不能为空");
|
return error("参数 ver 不能为空");
|
||||||
}
|
}
|
||||||
Map<String, Object> result= null;
|
String version_name= null;
|
||||||
if(type==1301||type==1302||type==1306){
|
if(type==1301||type==1302||type==1306){
|
||||||
result =socialDirectoryService.download(ver, type);
|
version_name =socialDirectoryService.download(ver, type);
|
||||||
return success(result);
|
return success(version_name);
|
||||||
|
}
|
||||||
|
if(type==1305){
|
||||||
|
version_name =socialItemService.download(ver);
|
||||||
|
return success(version_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return error("参数 type 不正确");
|
return error("参数 type 不正确");
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ public class SocialDirectoryService extends BaseService {
|
||||||
* @param type 类型
|
* @param type 类型
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Map<String, Object> download(String version_name, int type) {
|
public String download(String version_name, int type) {
|
||||||
Integer[] type_list = {1301, 1302, 1306};
|
Integer[] type_list = {1301, 1302, 1306};
|
||||||
//判断type在数组中
|
//判断type在数组中
|
||||||
if (!Arrays.asList(type_list).contains(type)) {
|
if (!Arrays.asList(type_list).contains(type)) {
|
||||||
|
|
@ -73,18 +73,16 @@ public class SocialDirectoryService extends BaseService {
|
||||||
queryWrapper.in("code", code_list);
|
queryWrapper.in("code", code_list);
|
||||||
socialDirectoryMapper.delete(queryWrapper);
|
socialDirectoryMapper.delete(queryWrapper);
|
||||||
}
|
}
|
||||||
String current_version_name = insertSocialDirectorys(version_name, type, tab_list);
|
return insertSocialDirectorys(version_name, type, tab_list);
|
||||||
Map<String, Object> hashMap = new HashMap<>();
|
|
||||||
hashMap.put("current_version_name", current_version_name);
|
|
||||||
hashMap.put("pre_version_name", version_name);
|
|
||||||
return hashMap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String insertSocialDirectorys(String version_name, int type, List<String[]> tab_list) {
|
private String insertSocialDirectorys(String version_name, int type, List<String[]> tab_list) {
|
||||||
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<>();
|
||||||
for (String[] line_array : tab_list) {
|
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 socialDirectory = new SocialDirectory();
|
||||||
socialDirectory.setType(type);
|
socialDirectory.setType(type);
|
||||||
String code = line_array[0];
|
String code = line_array[0];
|
||||||
|
|
@ -125,14 +123,22 @@ public class SocialDirectoryService extends BaseService {
|
||||||
socialDirectory.setKeyword(line_array[4]);
|
socialDirectory.setKeyword(line_array[4]);
|
||||||
}
|
}
|
||||||
SocialDirectory tmp_socialDirectory = tmp_map.get(code);
|
SocialDirectory tmp_socialDirectory = tmp_map.get(code);
|
||||||
|
if(i==0){
|
||||||
|
next_version_name=list.get(0).getVersionName();
|
||||||
|
}
|
||||||
if (tmp_socialDirectory == null && flag.equals("1")) {
|
if (tmp_socialDirectory == null && flag.equals("1")) {
|
||||||
list.add(socialDirectory);
|
list.add(socialDirectory);
|
||||||
tmp_map.put(code, socialDirectory);
|
tmp_map.put(code, socialDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if(list.isEmpty()){
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
socialDirectoryMapper.insert(list, 100);
|
socialDirectoryMapper.insert(list, 100);
|
||||||
socialDirectoryVersionService.setSocialDirectoryVersion(type, version_name, list.get(0).getVersionName(), list.size());
|
socialDirectoryVersionService.setSocialDirectoryVersion(type, version_name, list.get(0).getVersionName(), list.size());
|
||||||
return list.get(0).getVersionName();
|
return next_version_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -32,12 +32,14 @@ public class SocialItemService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private SocialDirectoryVersionService socialDirectoryVersionService;
|
private SocialDirectoryVersionService socialDirectoryVersionService;
|
||||||
|
|
||||||
public String download(int type, String version_name) {
|
public String download( String version_name) {
|
||||||
List<String[]> tab_list = httpUtil.download(version_name, type);
|
List<String[]> tab_list = httpUtil.download(version_name, 1305);
|
||||||
List<SocialItem> list = new ArrayList<>();
|
List<SocialItem> list = new ArrayList<>();
|
||||||
String value = String.valueOf(type);
|
String value = String.valueOf(1305);
|
||||||
List<String> codeList = new ArrayList<>();
|
List<String> codeList = new ArrayList<>();
|
||||||
for (String[] line_array : tab_list) {
|
String next_version_name="";
|
||||||
|
for (int i=0;i<tab_list.size();i++) {
|
||||||
|
String[] line_array= tab_list.get(i);
|
||||||
String flag = "";
|
String flag = "";
|
||||||
SocialItem socialItem = new SocialItem();
|
SocialItem socialItem = new SocialItem();
|
||||||
if (value.equals("1305")) {
|
if (value.equals("1305")) {
|
||||||
|
|
@ -45,7 +47,7 @@ public class SocialItemService {
|
||||||
String code = line_array[0];
|
String code = line_array[0];
|
||||||
socialItem.setSocialCode(code);
|
socialItem.setSocialCode(code);
|
||||||
socialItem.setName(line_array[9]);
|
socialItem.setName(line_array[9]);
|
||||||
socialItem.setVersionName(line_array[16]);
|
socialItem.setVersionName(line_array[15]);
|
||||||
socialItem.setUnit(line_array[1]);
|
socialItem.setUnit(line_array[1]);
|
||||||
}else if (value.equals("1321")) {
|
}else if (value.equals("1321")) {
|
||||||
flag = line_array[13];
|
flag = line_array[13];
|
||||||
|
|
@ -55,17 +57,27 @@ public class SocialItemService {
|
||||||
socialItem.setVersionName(line_array[21]);
|
socialItem.setVersionName(line_array[21]);
|
||||||
socialItem.setUnit(line_array[10]);
|
socialItem.setUnit(line_array[10]);
|
||||||
}
|
}
|
||||||
|
if(i==0){
|
||||||
|
next_version_name = line_array[15];
|
||||||
|
}
|
||||||
if (!flag.equals("1")) {
|
if (!flag.equals("1")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
codeList.add(socialItem.getSocialCode());
|
codeList.add(socialItem.getSocialCode());
|
||||||
list.add(socialItem);
|
list.add(socialItem);
|
||||||
}
|
}
|
||||||
QueryWrapper<SocialItem> queryWrapper = new QueryWrapper<>();
|
socialDirectoryVersionService.setSocialDirectoryVersion(1305, version_name, next_version_name, list.size());
|
||||||
queryWrapper.in("social_code", codeList);
|
if(list.isEmpty()){
|
||||||
socialItemMapper.delete(queryWrapper);
|
return next_version_name;
|
||||||
|
}
|
||||||
|
if(!codeList.isEmpty()){
|
||||||
|
QueryWrapper<SocialItem> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.in("social_code", codeList);
|
||||||
|
socialItemMapper.delete(queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
socialItemMapper.insert(list, 100);
|
socialItemMapper.insert(list, 100);
|
||||||
socialDirectoryVersionService.setSocialDirectoryVersion(type, version_name, list.get(0).getVersionName(), list.size());
|
|
||||||
return list.get(0).getVersionName();
|
return next_version_name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue