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