|
@ -0,0 +1,123 @@
|
|
|
package com.yihu.jw.care.endpoint.admin;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yihu.jw.care.dao.label.BaseCapacityLabelDao;
|
|
|
import com.yihu.jw.entity.base.patient.BasePatientDO;
|
|
|
import com.yihu.jw.entity.care.label.BaseCapacityLabelDO;
|
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
|
import com.yihu.jw.restmodel.web.Envelop;
|
|
|
import com.yihu.jw.restmodel.web.ObjEnvelop;
|
|
|
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
|
|
|
import com.yihu.jw.utils.ByteToInputStream;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.MediaType;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* Created by yeshijie on 2021/9/29.
|
|
|
*/
|
|
|
@RestController
|
|
|
@RequestMapping(value = "/common", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
|
|
@Api(value = "通用测试接口")
|
|
|
public class CommonEndpoint extends EnvelopRestEndpoint {
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(CommonEndpoint.class);
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
@Autowired
|
|
|
private BaseCapacityLabelDao baseCapacityLabelDao;
|
|
|
@Autowired
|
|
|
private BasePatientDao patientDao;
|
|
|
|
|
|
@GetMapping(value = "open/importCapLabel")
|
|
|
@ApiOperation(value = "导入居民能力状况")
|
|
|
public Envelop importCapLabel() {
|
|
|
try {
|
|
|
String sql = "select * from base_capacity_label_tmp";
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
List<BaseCapacityLabelDO> labelDOList = new ArrayList<>();
|
|
|
for (Map<String,Object> map:list){
|
|
|
String idcard = map.get("idcard")+"";
|
|
|
BasePatientDO patientDO = patientDao.findByIdcard(idcard);
|
|
|
if(patientDO == null){
|
|
|
logger.info("居民不存在:"+idcard);
|
|
|
continue;
|
|
|
}
|
|
|
String patientId = patientDO.getId();
|
|
|
BaseCapacityLabelDO capacityLabelDO = baseCapacityLabelDao.findByPatient(patientId);
|
|
|
if(capacityLabelDO != null){
|
|
|
logger.info("居民能力状况已经存在:"+idcard);
|
|
|
continue;
|
|
|
}
|
|
|
capacityLabelDO = new BaseCapacityLabelDO();
|
|
|
capacityLabelDO.setPatient(patientId);
|
|
|
capacityLabelDO.setFamily(transfor(map.get("family")+""));
|
|
|
capacityLabelDO.setHypertension(transfor(map.get("hypertension")+""));
|
|
|
capacityLabelDO.setHyperglycemia(transfor(map.get("hyperglycemia")+""));
|
|
|
capacityLabelDO.setHeartDisease(transfor(map.get("heart_disease")+""));
|
|
|
capacityLabelDO.setWorkStatus(transfor(map.get("work_status")+""));
|
|
|
capacityLabelDO.setDisability(transfor(map.get("disability")+""));
|
|
|
if("1".equals(capacityLabelDO.getDisability())){
|
|
|
capacityLabelDO.setDisabledPart(map.get("disabled_part")+"");
|
|
|
}
|
|
|
capacityLabelDO.setVisualCondition(transfor(map.get("visual_condition")+""));
|
|
|
capacityLabelDO.setAuditoryCondition(transfor(map.get("auditory_condition")+""));
|
|
|
capacityLabelDO.setCommunication(transfor(map.get("communication")+""));
|
|
|
capacityLabelDO.setMentalIllness(transfor(map.get("mental_illness")+""));
|
|
|
capacityLabelDO.setOftenGoOut(transfor(map.get("often_go_out")+""));
|
|
|
capacityLabelDO.setUsePhone(transfor(map.get("use_phone")+""));
|
|
|
capacityLabelDO.setTakeExercise(transfor(map.get("take_exercise")+""));
|
|
|
labelDOList.add(capacityLabelDO);
|
|
|
}
|
|
|
if(labelDOList.size()>0){
|
|
|
baseCapacityLabelDao.save(labelDOList);
|
|
|
}
|
|
|
|
|
|
return success("导入成功");
|
|
|
} catch (Exception e) {
|
|
|
return failedException2(e);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public String transfor(String label){
|
|
|
if(StringUtils.isBlank(label)){
|
|
|
return label;
|
|
|
}
|
|
|
if("是".equals(label)){
|
|
|
return "1";
|
|
|
}
|
|
|
if("否".equals(label)){
|
|
|
return "0";
|
|
|
}
|
|
|
if("迟缓".equals(label)||"看不见".equals(label)||"听不见".equals(label)||"不善于".equals(label)){
|
|
|
return "1";
|
|
|
}
|
|
|
if("大声量".equals(label)||"一般".equals(label)||"近距离".equals(label)){
|
|
|
return "2";
|
|
|
}
|
|
|
if("健步如飞".equals(label)||"正常".equals(label)||"善于".equals(label)){
|
|
|
return "3";
|
|
|
}
|
|
|
if("null".equals(label)){
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
return label;
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|