|
@ -3,10 +3,16 @@ package com.yihu.wlyy.service.manager.specialist;/**
|
|
|
*/
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yihu.wlyy.entity.specialist.SpecialistServiceItemDO;
|
|
|
import com.yihu.wlyy.repository.SystemDictDao;
|
|
|
import com.yihu.wlyy.service.BaseService;
|
|
|
import com.yihu.wlyy.service.common.excel.ExcelData;
|
|
|
import com.yihu.wlyy.util.HttpClientUtil;
|
|
|
import com.yihu.wlyy.util.ReadExcelUtil;
|
|
|
import jxl.Sheet;
|
|
|
import jxl.Workbook;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@ -167,58 +173,184 @@ public class ServiceItemService extends BaseService {
|
|
|
}
|
|
|
|
|
|
|
|
|
/*public JSONObject importData(HttpServletRequest request) throws Exception {
|
|
|
String response = null;
|
|
|
String url =getBaseUrl() + "importData";
|
|
|
JSONObject object =
|
|
|
try {
|
|
|
response = httpClientUtil.po;
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
logger.error(e.getMessage());
|
|
|
}
|
|
|
return JSONObject.parseObject(response);
|
|
|
}*/
|
|
|
|
|
|
/* public boolean importData(Workbook workbook) {
|
|
|
/**
|
|
|
* 导数据
|
|
|
*
|
|
|
* @param workbook
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject importData(Workbook workbook) {
|
|
|
Sheet[] sheets = workbook.getSheets();
|
|
|
Sheet sheet = sheets[0];
|
|
|
int rows = ReadExcelUtil.getRightRows(sheet);
|
|
|
JSONArray array = new JSONArray();
|
|
|
for (int row = 1; row < rows; row++) { //索引从0开始,第一行为标题
|
|
|
Hospital hospital = new Hospital();
|
|
|
Map<Integer, ExcelData> mapping = mapping(hospital);
|
|
|
SpecialistServiceItemDO itemDO = new SpecialistServiceItemDO();
|
|
|
Map<Integer, ExcelData> mapping = mapping(itemDO);
|
|
|
int finalRow = row;
|
|
|
mapping.forEach((index, excelData) -> {
|
|
|
String value = sheet.getCell(index, finalRow).getContents().trim();
|
|
|
excelData.transform(value);
|
|
|
});
|
|
|
JSONObject object = JSONObject.parseObject(itemDO.toString());
|
|
|
array.add(object);
|
|
|
}
|
|
|
String response = null;
|
|
|
String url =getBaseUrl() + "importData1";
|
|
|
Map<String,String> params = new HashMap<>();
|
|
|
params.put("serviceItems",array.toJSONString());
|
|
|
try {
|
|
|
response = httpClientUtil.httpPost(url,params);
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
logger.error(e.getMessage());
|
|
|
}
|
|
|
return JSONObject.parseObject(response);
|
|
|
}
|
|
|
|
|
|
//Additional Handel
|
|
|
String hospitalExist = this.isNameExist(hospital.getName());
|
|
|
if (hospitalExist.equals("true")) {//机构存在,但是未判断wlyyRole是否存在
|
|
|
hospital = hospitalDao.findByName(hospital.getName());
|
|
|
WlyyRole wlyyRole = new WlyyRole();
|
|
|
WlyyRole wlyyRole1 = wlyyRoleDao.findByName(hospital.getName());
|
|
|
if(wlyyRole1==null){//不存在则保存
|
|
|
wlyyRole.setName(hospital.getName());
|
|
|
wlyyRole.setCode(hospital.getCode());
|
|
|
wlyyRole.setCzrq(new Date());
|
|
|
wlyyRoleDao.save(wlyyRole);
|
|
|
}
|
|
|
continue;
|
|
|
/**
|
|
|
* 表格数据转为对象
|
|
|
*
|
|
|
* @param specialistServiceItemDO
|
|
|
* @return
|
|
|
*/
|
|
|
private Map<Integer, ExcelData> mapping(SpecialistServiceItemDO specialistServiceItemDO) {
|
|
|
Map<Integer, ExcelData> dataMap = new HashMap<>();
|
|
|
//项目名称
|
|
|
dataMap.put(1, new ExcelData() {
|
|
|
@Override
|
|
|
public void transform(String data) {
|
|
|
specialistServiceItemDO.setTitle(data);
|
|
|
}
|
|
|
//机构不存在,先保存机构,在判断wlyyRole是否存在
|
|
|
hospital.setDel("1");
|
|
|
hospital = hospitalDao.save(hospital);
|
|
|
WlyyRole wlyyRole = new WlyyRole();
|
|
|
WlyyRole wlyyRole1 = wlyyRoleDao.findByName(hospital.getName());
|
|
|
if(wlyyRole1==null){//不存在则保存
|
|
|
wlyyRole.setName(hospital.getName());
|
|
|
wlyyRole.setCode(hospital.getCode());
|
|
|
wlyyRole.setCzrq(new Date());
|
|
|
wlyyRoleDao.save(wlyyRole);
|
|
|
});
|
|
|
//项目内涵
|
|
|
dataMap.put(2, new ExcelData() {
|
|
|
@Override
|
|
|
public void transform(String data) {
|
|
|
specialistServiceItemDO.setContent(data);
|
|
|
}
|
|
|
}
|
|
|
return true;
|
|
|
}*/
|
|
|
});
|
|
|
//除去内容
|
|
|
dataMap.put(3, new ExcelData() {
|
|
|
@Override
|
|
|
public void transform(String data) {
|
|
|
specialistServiceItemDO.setExcludeContent(data);
|
|
|
}
|
|
|
});
|
|
|
//项目类型
|
|
|
dataMap.put(4, new ExcelData() {
|
|
|
@Override
|
|
|
public void transform(String data) {
|
|
|
Map<String, String> centerSite = new HashMap<>();
|
|
|
centerSite.put("康复服务", "1");
|
|
|
centerSite.put("健康服务", "2");
|
|
|
specialistServiceItemDO.setItemType(Integer.parseInt(centerSite.get(data)));
|
|
|
}
|
|
|
});
|
|
|
//医院等级
|
|
|
dataMap.put(5, new ExcelData() {
|
|
|
@Override
|
|
|
public void transform(String data) {
|
|
|
Map<String,Integer> grade = new HashMap<>();
|
|
|
grade.put("所有",0);
|
|
|
grade.put("一级及一级以下医疗机构",1);
|
|
|
grade.put("二级医院",2);
|
|
|
grade.put("三级医院",3);
|
|
|
specialistServiceItemDO.setHospitalGrade(grade.get(data));
|
|
|
}
|
|
|
});
|
|
|
//三级医院收费
|
|
|
dataMap.put(6, new ExcelData() {
|
|
|
@Override
|
|
|
public void transform(String data) {
|
|
|
specialistServiceItemDO.setThreeHospitals(Integer.parseInt(data));
|
|
|
}
|
|
|
});
|
|
|
//二级医院收费
|
|
|
dataMap.put(7, new ExcelData() {
|
|
|
@Override
|
|
|
public void transform(String data) {
|
|
|
specialistServiceItemDO.setTwoHospitals(Integer.parseInt(data));
|
|
|
|
|
|
}
|
|
|
});
|
|
|
//一级及下收费
|
|
|
dataMap.put(8, new ExcelData() {
|
|
|
@Override
|
|
|
public void transform(String data) {
|
|
|
specialistServiceItemDO.setOneHospitals(Integer.parseInt(data));
|
|
|
}
|
|
|
});
|
|
|
//计价单位
|
|
|
dataMap.put(9, new ExcelData() {
|
|
|
@Override
|
|
|
public void transform(String data) {
|
|
|
specialistServiceItemDO.setUnit(Integer.parseInt(data));
|
|
|
}
|
|
|
});
|
|
|
//加收项目
|
|
|
dataMap.put(10, new ExcelData() {
|
|
|
@Override
|
|
|
public void transform(String data) {
|
|
|
specialistServiceItemDO.setAddItem(data);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
//病案项目
|
|
|
dataMap.put(11, new ExcelData() {
|
|
|
@Override
|
|
|
public void transform(String data) {
|
|
|
specialistServiceItemDO.setDiseaseItem(data);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
|
|
|
//是否预约
|
|
|
dataMap.put(12, new ExcelData() {
|
|
|
@Override
|
|
|
public void transform(String data) {
|
|
|
Map<String,Integer> reserve = new HashMap<>();
|
|
|
reserve.put("是",1);
|
|
|
reserve.put("否",0);
|
|
|
specialistServiceItemDO.setReserve(reserve.get(data));
|
|
|
}
|
|
|
});
|
|
|
|
|
|
//完成方式
|
|
|
dataMap.put(13, new ExcelData() {
|
|
|
@Override
|
|
|
public void transform(String data) {
|
|
|
Map<String,Integer> type = new HashMap<>();
|
|
|
type.put("扫码",1);
|
|
|
type.put("上传附件",0);
|
|
|
type.put("健康教育",2);
|
|
|
type.put("健康指导",3);
|
|
|
type.put("随访",4);
|
|
|
specialistServiceItemDO.setType(type.get(data));
|
|
|
}
|
|
|
});
|
|
|
|
|
|
//是否评价
|
|
|
dataMap.put(14, new ExcelData() {
|
|
|
@Override
|
|
|
public void transform(String data) {
|
|
|
Map<String,Integer> evaluate = new HashMap<>();
|
|
|
evaluate.put("是",1);
|
|
|
evaluate.put("否",0);
|
|
|
specialistServiceItemDO.setEvaluation(evaluate.get(data));
|
|
|
}
|
|
|
});
|
|
|
|
|
|
//是否生效
|
|
|
dataMap.put(15, new ExcelData() {
|
|
|
@Override
|
|
|
public void transform(String data) {
|
|
|
Map<String,Integer> imediate = new HashMap<>();
|
|
|
imediate.put("是",1);
|
|
|
imediate.put("否",0);
|
|
|
specialistServiceItemDO.setEvaluation(imediate.get(data));
|
|
|
}
|
|
|
});
|
|
|
return dataMap;
|
|
|
}
|
|
|
}
|