Explorar el Código

Merge branch 'dev' of chenweida/patient-co-management into dev

chenweida hace 8 años
padre
commit
d063f2add6
Se han modificado 26 ficheros con 3878 adiciones y 9 borrados
  1. 15 5
      patient-co-figure/pom.xml
  2. 9 3
      patient-co-figure/src/main/java/com/yihu/figure/config/SwaggerConfig.java
  3. 4 0
      patient-co-figure/src/main/java/com/yihu/figure/config/war/ServletInitializer.java
  4. 512 0
      patient-co-figure/src/main/java/com/yihu/figure/controller/BaseController.java
  5. 20 0
      patient-co-figure/src/main/java/com/yihu/figure/controller/DietController.java
  6. 20 0
      patient-co-figure/src/main/java/com/yihu/figure/controller/DiseaseController.java
  7. 20 0
      patient-co-figure/src/main/java/com/yihu/figure/controller/MedicinalController.java
  8. 20 0
      patient-co-figure/src/main/java/com/yihu/figure/controller/SportsController.java
  9. 64 0
      patient-co-figure/src/main/java/com/yihu/figure/controller/data/DataController.java
  10. 140 0
      patient-co-figure/src/main/java/com/yihu/figure/controller/jw/RecordController.java
  11. 20 0
      patient-co-figure/src/main/java/com/yihu/figure/dao/dict/SystemDictDao.java
  12. 12 0
      patient-co-figure/src/main/java/com/yihu/figure/dao/dict/SystemDictListDao.java
  13. 100 0
      patient-co-figure/src/main/java/com/yihu/figure/model/dict/SystemDict.java
  14. 146 0
      patient-co-figure/src/main/java/com/yihu/figure/model/dict/SystemDictList.java
  15. 10 0
      patient-co-figure/src/main/java/com/yihu/figure/service/DietService.java
  16. 10 0
      patient-co-figure/src/main/java/com/yihu/figure/service/DiseaseService.java
  17. 10 0
      patient-co-figure/src/main/java/com/yihu/figure/service/MedicinalService.java
  18. 10 0
      patient-co-figure/src/main/java/com/yihu/figure/service/SportsService.java
  19. 56 0
      patient-co-figure/src/main/java/com/yihu/figure/service/data/DataService.java
  20. 93 0
      patient-co-figure/src/main/java/com/yihu/figure/service/dict/SystemDictService.java
  21. 805 0
      patient-co-figure/src/main/java/com/yihu/figure/service/jw/JwArchivesService.java
  22. 64 0
      patient-co-figure/src/main/java/com/yihu/figure/service/jw/JwSignService.java
  23. 727 0
      patient-co-figure/src/main/java/com/yihu/figure/service/jw/JwSmjkService.java
  24. 720 0
      patient-co-figure/src/main/java/com/yihu/figure/util/DateUtil.java
  25. 241 0
      patient-co-figure/src/main/java/com/yihu/figure/util/HttpClientUtil.java
  26. 30 1
      patient-co-figure/src/main/resources/application.yml

+ 15 - 5
patient-co-figure/pom.xml

@ -9,6 +9,7 @@
    <artifactId>patient-co-figure</artifactId>
    <packaging>jar</packaging>
    <!--<packaging>war</packaging>-->
    <properties>
@ -387,17 +388,26 @@
            <artifactId>json-lib</artifactId>
            <version>2.4</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-redis</artifactId>
            <version>1.7.2.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>redis.clients</groupId>
            <artifactId>jedis</artifactId>
            <version>${version.jedis}</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <!--打成war包需要的配置-->
            <!--<plugin>-->
            <!--<artifactId>maven-war-plugin</artifactId>-->
            <!--<configuration>-->
            <!--<failOnMissingWebXml>false</failOnMissingWebXml>-->
            <!--</configuration>-->
                <!--<artifactId>maven-war-plugin</artifactId>-->
                <!--<configuration>-->
                    <!--<failOnMissingWebXml>false</failOnMissingWebXml>-->
                <!--</configuration>-->
            <!--</plugin>-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>

+ 9 - 3
patient-co-figure/src/main/java/com/yihu/figure/config/SwaggerConfig.java

@ -20,6 +20,7 @@ import static springfox.documentation.builders.PathSelectors.regex;
@EnableSwagger2
public class SwaggerConfig extends WebMvcConfigurerAdapter {
    private static final String PUBLIC_API = "Default";
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("swagger-ui.html")
@ -28,6 +29,7 @@ public class SwaggerConfig extends WebMvcConfigurerAdapter {
        registry.addResourceHandler("/webjars/**")
                .addResourceLocations("classpath:/META-INF/resources/webjars/");
    }
    @Bean
    public Docket publicAPI() {
        return new Docket(DocumentationType.SWAGGER_2)
@ -38,15 +40,19 @@ public class SwaggerConfig extends WebMvcConfigurerAdapter {
                .pathMapping("/")
                .select()
                .paths(or(
                        regex("/job/.*")
                        regex("/medicinal/.*"),
                        regex("/diet/.*"),
                        regex("/disease/.*"),
                        regex("/data/.*"),
                        regex("/health/.*")
                ))
                .build()
                .apiInfo(publicApiInfo());
    }
    private ApiInfo publicApiInfo() {
        ApiInfo apiInfo = new ApiInfo("三师平台统计分析API",
                "统计分析接口。",
        ApiInfo apiInfo = new ApiInfo("居民画像API",
                "居民画像接口。",
                "1.0",
                "No terms of service",
                "admin@jkzl.com",

+ 4 - 0
patient-co-figure/src/main/java/com/yihu/figure/config/war/ServletInitializer.java

@ -1,5 +1,9 @@
package com.yihu.figure.config.war;
import com.yihu.figure.Application;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer;
/**
 * Created by Administrator on 2016.10.14.
 */

+ 512 - 0
patient-co-figure/src/main/java/com/yihu/figure/controller/BaseController.java

@ -0,0 +1,512 @@
package com.yihu.figure.controller;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.figure.model.IdEntity;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.util.ReflectionUtils;
import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Field;
import java.util.*;
public class BaseController {
    private static Logger logger = LoggerFactory.getLogger(BaseController.class);
    @Autowired
    protected HttpServletRequest request;
    /**
     * 獲取髮送請求用戶的uid
     *
     * @return
     */
    public String getUID() {
        try {
            String userAgent = request.getHeader("userAgent");
            if (StringUtils.isEmpty(userAgent)) {
                userAgent = request.getHeader("User-Agent");
            }
            JSONObject json = new JSONObject(userAgent);
            return json.getString("uid");
        } catch (Exception e) {
            return null;
        }
    }
    /**
     * 獲取髮送請求用戶的uid
     *
     * @return
     */
    public String getLastUid() {
        try {
            String userAgent = request.getHeader("userAgent");
            if (StringUtils.isEmpty(userAgent)) {
                userAgent = request.getHeader("User-Agent");
            }
            JSONObject json = new JSONObject(userAgent);
            return json.getString("lastUid");
        } catch (Exception e) {
            return null;
        }
    }
    public String getOpenid() {
        try {
            String userAgent = request.getHeader("userAgent");
            if (StringUtils.isEmpty(userAgent)) {
                userAgent = request.getHeader("User-Agent");
            }
            JSONObject json = new JSONObject(userAgent);
            return json.getString("openid");
        } catch (Exception e) {
            return null;
        }
    }
    /**
     * 获取用户ID
     *
     * @return
     */
    public long getId() {
        try {
            String userAgent = request.getHeader("userAgent");
            if (StringUtils.isEmpty(userAgent)) {
                userAgent = request.getHeader("User-Agent");
            }
            JSONObject json = new JSONObject(userAgent);
            return json.getLong("id");
        } catch (Exception e) {
            return 0;
        }
    }
    public String getIMEI() {
        try {
            String userAgent = request.getHeader("userAgent");
            if (StringUtils.isEmpty(userAgent)) {
                userAgent = request.getHeader("User-Agent");
            }
            JSONObject json = new JSONObject(userAgent);
            return json.getString("imei");
        } catch (Exception e) {
            return null;
        }
    }
    public String getToken() {
        try {
            String userAgent = request.getHeader("userAgent");
            if (StringUtils.isEmpty(userAgent)) {
                userAgent = request.getHeader("User-Agent");
            }
            JSONObject json = new JSONObject(userAgent);
            return json.getString("token");
        } catch (Exception e) {
            return null;
        }
    }
    public void error(Exception e) {
        logger.error(getClass().getName() + ":", e.getMessage());
        e.printStackTrace();
    }
    public void warn(Exception e) {
        logger.warn(getClass().getName() + ":", e.getMessage());
        e.printStackTrace();
    }
    public void infoMessage(String message) {
        logger.info(message);
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @param value 结果数据
     * @return
     */
    public String error(int code, String msg) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("status", code);
            map.put("msg", msg);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            error(e);
            return null;
        }
    }
    /**
     * 接口处理成功
     *
     * @param msg
     * @return
     */
    public String success(String msg) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("status", 200);
            map.put("msg", msg);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            error(e);
            return null;
        }
    }
    public String write(int code, String msg) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("status", code);
            map.put("msg", msg);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            error(e);
            return null;
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @param value 结果数据
     * @return
     */
    public String write(int code, String msg, String key, List<?> list) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("status", code);
            map.put("msg", msg);
            map.put(key, list);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @param value 结果数据
     * @return
     */
    public String write(int code, String msg, String key, JSONObject value) {
        try {
            JSONObject json = new JSONObject();
            json.put("status", code);
            json.put("msg", msg);
            json.put(key, value);
            return json.toString();
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @param value 结果数据
     * @return
     */
    public String write(int code, String msg, String key, JSONArray value) {
        try {
            JSONObject json = new JSONObject();
            json.put("status", code);
            json.put("msg", msg);
            json.put(key, value);
            return json.toString();
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @param total 总数
     * @param value 结果数据
     * @return
     */
    public String write(int code, String msg, int total, String key, JSONArray value) {
        try {
            JSONObject json = new JSONObject();
            json.put("status", code);
            json.put("msg", msg);
            json.put("total", total);
            json.put(key, value);
            return json.toString();
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @param value 结果数据
     * @return
     */
    public String write(int code, String msg, String key, Object value) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("status", code);
            map.put("msg", msg);
            map.put(key, value);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @param value 结果数据
     * @return
     */
    public String write(int code, String msg, String key, Page<?> list) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("status", code);
            map.put("msg", msg);
            // 是否为第一页
            map.put("isFirst", list.isFirst());
            // 是否为最后一页
            map.put("isLast", list.isLast());
            // 总条数
            map.put("total", list.getTotalElements());
            // 总页数
            map.put("totalPages", list.getTotalPages());
            map.put(key, list.getContent());
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @param value 结果数据
     * @return
     */
    public String write(int code, String msg, String key, Page<?> page, JSONArray array) {
        try {
            JSONObject json = new JSONObject();
            json.put("status", code);
            json.put("msg", msg);
            // 是否为第一页
            json.put("isFirst", page == null ? false : page.isFirst());
            // 是否为最后一页
            json.put("isLast", page == null ? true : page.isLast());
            // 总条数
            json.put("total", page == null ? 0 : page.getTotalElements());
            // 总页数
            json.put("totalPages", page == null ? 0 : page.getTotalPages());
            json.put(key, array);
            return json.toString();
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @param value 结果数据
     * @return
     */
    public String write(int code, String msg, String key, Map<?, ?> value) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("status", code);
            map.put("msg", msg);
            map.put(key, value);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @param value 结果数据
     * @return
     */
    public String write(int code, String msg, String key, String value) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("status", code);
            map.put("msg", msg);
            map.put(key, value);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @param value 结果数据
     * @return
     */
    public String write(int code, String msg, String key, IdEntity entity) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("status", code);
            map.put("msg", msg);
            map.put(key, entity);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @param value 结果数据
     * @return
     */
    public String write(int code, String msg, boolean isFirst, boolean isLast, long total, int totalPages, String key, Object values) {
        try {
            JSONObject json = new JSONObject();
            json.put("status", code);
            json.put("msg", msg);
            // 是否为第一页
            json.put("isFirst", isFirst);
            // 是否为最后一页
            json.put("isLast", isLast);
            // 总条数
            json.put("total", total);
            // 总页数
            json.put("totalPages", totalPages);
            json.put(key, values);
            return json.toString();
        } catch (Exception e) {
            logger.error("BaseController:", e.getMessage());
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    public String trimEnd(String param, String trimChars) {
        if (param.endsWith(trimChars)) {
            param = param.substring(0, param.length() - trimChars.length());
        }
        return param;
    }
    /**
     * 无效用户消息返回
     *
     * @param e
     * @param defaultCode
     * @param defaultMsg
     * @return
     */
    public String invalidUserException(Exception e, int defaultCode, String defaultMsg) {
        try {
            // if (e instanceof UndeclaredThrowableException) {
            // UndeclaredThrowableException ute = (UndeclaredThrowableException) e;
            // InvalidUserException iue = (InvalidUserException) ute.getUndeclaredThrowable();
            // if (iue != null) {
            // return error(iue.getCode(), iue.getMsg());
            // }
            // }
            return error(defaultCode, defaultMsg);
        } catch (Exception e2) {
            return null;
        }
    }
    public List<Map<String, Object>> copyBeans(Collection<? extends Object> beans, String... propertyNames) {
        List<Map<String, Object>> result = new ArrayList<>();
        for (Object bean : beans) {
            result.add(copyBeanProperties(bean, propertyNames));
        }
        return result;
    }
    /**
     * 复制特定属性。
     *
     * @param bean
     * @param propertyNames
     * @return
     */
    public Map<String, Object> copyBeanProperties(Object bean, String... propertyNames) {
        Map<String, Object> simplifiedBean = new HashMap<>();
        for (String propertyName : propertyNames) {
            Field field = ReflectionUtils.findField(bean.getClass(), propertyName);
            if (field != null) {
                field.setAccessible(true);
                Object value = ReflectionUtils.getField(field, bean);
                simplifiedBean.put(propertyName, value == null ? "" : value);
            } else {
                simplifiedBean.put(propertyName, "");
            }
        }
        return simplifiedBean;
    }
}

+ 20 - 0
patient-co-figure/src/main/java/com/yihu/figure/controller/DietController.java

@ -0,0 +1,20 @@
package com.yihu.figure.controller;
import com.yihu.figure.service.DietService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created by chenweida on 2017/3/6.
 * 饮食
 */
@RestController
@RequestMapping(value = "/diet", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "饮食")
public class DietController {
    @Autowired
    private DietService dietService;
}

+ 20 - 0
patient-co-figure/src/main/java/com/yihu/figure/controller/DiseaseController.java

@ -0,0 +1,20 @@
package com.yihu.figure.controller;
import com.yihu.figure.service.DiseaseService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created by chenweida on 2017/3/6.
 * 近期疾病
 */
@RestController
@RequestMapping(value = "/disease", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "近期疾病")
public class DiseaseController {
    @Autowired
    private DiseaseService diseaseService;
}

+ 20 - 0
patient-co-figure/src/main/java/com/yihu/figure/controller/MedicinalController.java

@ -0,0 +1,20 @@
package com.yihu.figure.controller;
import com.yihu.figure.service.MedicinalService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created by chenweida on 2017/3/6.
 * 用药建议
 */
@RestController
@RequestMapping(value = "/medicinal", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "用药建议")
public class MedicinalController {
    @Autowired
    private MedicinalService medicinalService;
}

+ 20 - 0
patient-co-figure/src/main/java/com/yihu/figure/controller/SportsController.java

@ -0,0 +1,20 @@
package com.yihu.figure.controller;
import com.yihu.figure.service.SportsService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created by chenweida on 2017/3/6.
 * 运动
 */
@RestController
@RequestMapping(value = "/sports", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "运动")
public class SportsController {
    @Autowired
    private SportsService sportsService;
}

+ 64 - 0
patient-co-figure/src/main/java/com/yihu/figure/controller/data/DataController.java

@ -0,0 +1,64 @@
package com.yihu.figure.controller.data;
import com.yihu.figure.controller.BaseController;
import com.yihu.figure.service.data.DataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created by chenweida on 2017/3/6.
 */
@RestController
@RequestMapping(value = "/data", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "数据爬取")
public class DataController extends BaseController {
    @Autowired
    private DataService dataService;
    /**
     * 根据健康卡号抓取数据某个病人的全部就诊事件列表接口
     * /smjk/GetResidentEventListJson
     *
     * @param strSSID 健康卡号
     * @return
     */
    @ApiOperation(value = "根据健康卡号抓取数据某个病人的全部就诊事件")
    @RequestMapping(value = "getResidentEventListJson", method = RequestMethod.GET)
    public String getResidentEventListJson(
            @ApiParam(name = "strSSID", value = "健康卡号", required = true) @RequestParam(value = "strSSID", required = true) String strSSID) {
        try {
            String data = dataService.getResidentEventListJson(strSSID);
            return data;
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "启动失败:" + e.getMessage());
        }
    }
    /**
     * 根据健康卡号抓取数据某个病人的全部检查检验事件
     * /smjk/GetResidentEventListJson
     *
     * @param strSSID 健康卡号
     * @return
     */
    @ApiOperation(value = "根据健康卡号抓取数据某个病人的全部检查检验事件")
    @RequestMapping(value = "GetRecordListByCatalogcodesJson", method = RequestMethod.GET)
    public String GetRecordListByCatalogcodesJson(
            @ApiParam(name = "strSSID", value = "健康卡号", required = true) @RequestParam(value = "strSSID", required = true) String strSSID) {
        try {
            String data = dataService.GetRecordListByCatalogcodesJson(strSSID);
            return data;
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "启动失败:" + e.getMessage());
        }
    }
}

+ 140 - 0
patient-co-figure/src/main/java/com/yihu/figure/controller/jw/RecordController.java

@ -0,0 +1,140 @@
package com.yihu.figure.controller.jw;
import com.yihu.figure.controller.BaseController;
import com.yihu.figure.service.jw.JwSmjkService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.json.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
/**
 * Created by zhenglingfeng on 2016/10/17.
 */
@Controller
@RequestMapping(value = "/wlyy_service/record", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "医生端-健康档案服务(旧版本接口)")
public class RecordController extends BaseController {
    @Autowired
    private JwSmjkService jwSmjkService;
    @RequestMapping(value = "/hospitalization", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取住院记录")
    public String getHospitalizationRecord(@ApiParam(name="strSSID",value="健康卡号",defaultValue = "A20140513123")
                                           @RequestParam(value="strSSID",required = true) String strSSID,
                                           @ApiParam(name="startNum",value="需要获取的起始行数",defaultValue = "0")
                                           @RequestParam(value="startNum",required = true) String startNum,
                                           @ApiParam(name="endNum",value="需要获取的结束的行数",defaultValue = "10")
                                           @RequestParam(value="endNum",required = true) String endNum) {
        try {
            String result = jwSmjkService.getHospitalizationRecord(strSSID, startNum, endNum);
            if (result.startsWith("error")) {
                return write(200, result, "data", new JSONArray().toString());
            }
            return write(200, "获取住院记录成功!", "data", result);
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "获取住院记录失败!");
        }
    }
    /**
     * 获取门/急诊数据
     *
     * @return
     */
    @ApiOperation("获取门/急诊数据")
    @RequestMapping(value = "/outpatient", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ResponseBody
    public String getOutpatientRecord(@ApiParam(name="strSSID",value="健康卡号",defaultValue = "B09036263193")
                                      @RequestParam(value="strSSID",required = true) String strSSID,
                                      @ApiParam(name="startNum",value="需要获取的起始行数",defaultValue = "0")
                                      @RequestParam(value="startNum",required = true) String startNum,
                                      @ApiParam(name="endNum",value="需要获取的结束的行数",defaultValue = "10")
                                      @RequestParam(value="endNum",required = true) String endNum) {
        try {
            String result = jwSmjkService.getOutpatientRecord(strSSID, startNum, endNum);
            if (result.startsWith("error")) {
                return write(200, result, "data", new JSONArray().toString());
            }
            return write(200, "获取门/急诊数据成功!", "data", result);
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "获取门/急诊数据失败!");
        }
    }
    @RequestMapping(value = "/healthData", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取健康档案信息")
    public String getHealthData(@ApiParam(name="strSSID",value="健康卡号",defaultValue = "A20140513123")
                                @RequestParam(value="strSSID",required = true) String strSSID,
                                @ApiParam(name="strEvent",value="事件ID",defaultValue = "")
                                @RequestParam(value="strEvent",required = true) String strEvent,
                                @ApiParam(name="strCatalog",value="档案类型",defaultValue = "")
                                @RequestParam(value="strCatalog",required = true) String strCatalog,
                                @ApiParam(name="strSerial",value="该类别顺序号,默认填1",defaultValue = "1")
                                @RequestParam(value="strSerial",required = true) String strSerial) {
        try {
            String result = jwSmjkService.getHealthData(strSSID, strEvent, strCatalog, strSerial);
            if (result.startsWith("error")) {
                return write(200, result, "data", new JSONArray().toString());
            }
            return write(200, "获取健康档案信息成功!", "data", result);
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "获取健康档案信息失败!");
        }
    }
    @RequestMapping(value = "/residentEventList", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取健康档案信息列表")
    public String getResidentEventListJson(@ApiParam(name="strSSID",value="健康卡号",defaultValue = "A20140513123")
                                @RequestParam(value="strSSID",required = true) String strSSID,
                                @ApiParam(name="type",value="类型",defaultValue = "")
                                @RequestParam(value="type",required = true) String type,
                                @ApiParam(name="page",value="第几页",defaultValue = "")
                                @RequestParam(value="page",required = true) String page,
                                @ApiParam(name="pageSize",value="",defaultValue = "10")
                                @RequestParam(value="pageSize",required = true) String pageSize) {
        try {
            String result = jwSmjkService.getResidentEventListJson(strSSID, type, page, pageSize);
            return write(200, "获取健康档案信息成功!", "data", result);
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, e.getMessage());
        }
    }
    @RequestMapping(value = "/drug", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取用药记录")
    public String getDrugsList(@ApiParam(name="strSSID",value="健康卡号",defaultValue = "A20140513123")
                               @RequestParam(value="strSSID",required = true) String strSSID,
                               @RequestParam(value="startNum",required = true) String startNum,
                               @ApiParam(name="endNum",value="需要获取的结束的行数",defaultValue = "10")
                               @RequestParam(value="endNum",required = true) String endNum) {
        try {
            String result = jwSmjkService.getDrugsList(strSSID, startNum, endNum);
            if (result.startsWith("error")) {
                return write(200, result, "data", new JSONArray().toString());
            }
            return write(200, "获取用药记录成功!", "data", result);
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "获取用药记录失败!");
        }
    }
}

+ 20 - 0
patient-co-figure/src/main/java/com/yihu/figure/dao/dict/SystemDictDao.java

@ -0,0 +1,20 @@
package com.yihu.figure.dao.dict;
import com.yihu.figure.model.dict.SystemDict;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by Administrator on 2016/8/13.
 */
public interface SystemDictDao extends PagingAndSortingRepository<SystemDict, Long>, JpaSpecificationExecutor<SystemDict> {
    @Query("from SystemDict s where s.dictName=?1 order by sort asc ")
    List<SystemDict> findByDictName(String name);
    @Query("select s.value from SystemDict s where s.dictName=?1 and s.code =?2")
    String findByDictNameAndCode(String dictName, String code);
}

+ 12 - 0
patient-co-figure/src/main/java/com/yihu/figure/dao/dict/SystemDictListDao.java

@ -0,0 +1,12 @@
package com.yihu.figure.dao.dict;
import com.yihu.figure.model.dict.SystemDictList;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Administrator on 2016/8/13.
 */
public interface SystemDictListDao extends PagingAndSortingRepository<SystemDictList, Long>, JpaSpecificationExecutor<SystemDictList> {
}

+ 100 - 0
patient-co-figure/src/main/java/com/yihu/figure/model/dict/SystemDict.java

@ -0,0 +1,100 @@
package com.yihu.figure.model.dict;
import javax.persistence.*;
/**
 * SystemDict entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "system_dict")
public class SystemDict  implements java.io.Serializable {
	// Fields
	private String dictName;
	private String code;
	private String value;
	private String pyCode;
	private Integer sort;
	private Integer id;
	// Constructors
	/** default constructor */
	public SystemDict() {
	}
	/** minimal constructor */
	public SystemDict(String dictName, String code, String value) {
		this.dictName = dictName;
		this.code = code;
		this.value = value;
	}
	// Property accessors
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	/** full constructor */
	public SystemDict(String dictName, String code, String value,
			String pyCode, Integer sort) {
		this.dictName = dictName;
		this.code = code;
		this.value = value;
		this.pyCode = pyCode;
		this.sort = sort;
	}
	@Column(name = "dict_name", nullable = false, length = 50)
	public String getDictName() {
		return this.dictName;
	}
	public void setDictName(String dictName) {
		this.dictName = dictName;
	}
	@Column(name = "code", nullable = false, length = 50)
	public String getCode() {
		return this.code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	@Column(name = "value", nullable = false, length = 50)
	public String getValue() {
		return this.value;
	}
	public void setValue(String value) {
		this.value = value;
	}
	@Column(name = "py_code", length = 50)
	public String getPyCode() {
		return this.pyCode;
	}
	public void setPyCode(String pyCode) {
		this.pyCode = pyCode;
	}
	@Column(name = "sort")
	public Integer getSort() {
		return this.sort;
	}
	public void setSort(Integer sort) {
		this.sort = sort;
	}
}

+ 146 - 0
patient-co-figure/src/main/java/com/yihu/figure/model/dict/SystemDictList.java

@ -0,0 +1,146 @@
package com.yihu.figure.model.dict;
import javax.persistence.*;
/**
 * SystemDictList entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "system_dict_list")
public class SystemDictList   implements java.io.Serializable {
	// Fields
	private String dictName;
	private String chineseName;
	private String pyCode;
	private String pid;
	private String remark;
	private String relationTable;
	private String relationColCode;
	private String relationColValue;
	private String relationColExtend;
	private Integer id;
	// Constructors
	/** default constructor */
	public SystemDictList() {
	}
	/** minimal constructor */
	public SystemDictList(String dictName, String chineseName, String pid) {
		this.dictName = dictName;
		this.chineseName = chineseName;
		this.pid = pid;
	}
	/** full constructor */
	public SystemDictList(String dictName, String chineseName, String pyCode,
			String pid, String remark, String relationTable,
			String relationColCode, String relationColValue,
			String relationColExtend) {
		this.dictName = dictName;
		this.chineseName = chineseName;
		this.pyCode = pyCode;
		this.pid = pid;
		this.remark = remark;
		this.relationTable = relationTable;
		this.relationColCode = relationColCode;
		this.relationColValue = relationColValue;
		this.relationColExtend = relationColExtend;
	}
	// Property accessors
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	@Column(name = "dict_name", nullable = false, length = 50)
	public String getDictName() {
		return this.dictName;
	}
	public void setDictName(String dictName) {
		this.dictName = dictName;
	}
	@Column(name = "chinese_name", nullable = false, length = 50)
	public String getChineseName() {
		return this.chineseName;
	}
	public void setChineseName(String chineseName) {
		this.chineseName = chineseName;
	}
	@Column(name = "py_code", length = 50)
	public String getPyCode() {
		return this.pyCode;
	}
	public void setPyCode(String pyCode) {
		this.pyCode = pyCode;
	}
	@Column(name = "pid", nullable = false, length = 50)
	public String getPid() {
		return this.pid;
	}
	public void setPid(String pid) {
		this.pid = pid;
	}
	@Column(name = "remark", length = 200)
	public String getRemark() {
		return this.remark;
	}
	public void setRemark(String remark) {
		this.remark = remark;
	}
	@Column(name = "relation_table", length = 50)
	public String getRelationTable() {
		return this.relationTable;
	}
	public void setRelationTable(String relationTable) {
		this.relationTable = relationTable;
	}
	@Column(name = "relation_col_code", length = 50)
	public String getRelationColCode() {
		return this.relationColCode;
	}
	public void setRelationColCode(String relationColCode) {
		this.relationColCode = relationColCode;
	}
	@Column(name = "relation_col_value", length = 50)
	public String getRelationColValue() {
		return this.relationColValue;
	}
	public void setRelationColValue(String relationColValue) {
		this.relationColValue = relationColValue;
	}
	@Column(name = "relation_col_extend", length = 50)
	public String getRelationColExtend() {
		return this.relationColExtend;
	}
	public void setRelationColExtend(String relationColExtend) {
		this.relationColExtend = relationColExtend;
	}
}

+ 10 - 0
patient-co-figure/src/main/java/com/yihu/figure/service/DietService.java

@ -0,0 +1,10 @@
package com.yihu.figure.service;
import org.springframework.stereotype.Service;
/**
 * Created by chenweida on 2017/3/6.
 */
@Service
public class DietService {
}

+ 10 - 0
patient-co-figure/src/main/java/com/yihu/figure/service/DiseaseService.java

@ -0,0 +1,10 @@
package com.yihu.figure.service;
import org.springframework.stereotype.Service;
/**
 * Created by chenweida on 2017/3/6.
 */
@Service
public class DiseaseService {
}

+ 10 - 0
patient-co-figure/src/main/java/com/yihu/figure/service/MedicinalService.java

@ -0,0 +1,10 @@
package com.yihu.figure.service;
import org.springframework.stereotype.Service;
/**
 * Created by chenweida on 2017/3/6.
 */
@Service
public class MedicinalService {
}

+ 10 - 0
patient-co-figure/src/main/java/com/yihu/figure/service/SportsService.java

@ -0,0 +1,10 @@
package com.yihu.figure.service;
import org.springframework.stereotype.Service;
/**
 * Created by chenweida on 2017/3/6.
 */
@Service
public class SportsService {
}

+ 56 - 0
patient-co-figure/src/main/java/com/yihu/figure/service/data/DataService.java

@ -0,0 +1,56 @@
package com.yihu.figure.service.data;
import com.yihu.figure.service.jw.JwArchivesService;
import com.yihu.figure.service.jw.JwSignService;
import com.yihu.figure.service.jw.JwSmjkService;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
 * Created by chenweida on 2017/3/6.
 */
@Service
public class DataService {
    @Autowired
    private JwArchivesService jwArchivesService;
    @Autowired
    private JwSignService jwSignService;
    @Autowired
    private JwSmjkService jwSmjkService;
    public String getResidentEventListJson(String strSSID) {
        JSONObject jo = new JSONObject();
        try {
            Integer page = 1;
            Integer pageSize = 100;
            //门诊
            String ehrList1 = jwSmjkService.getResidentEventListJson(strSSID, "1", page + "", pageSize + "");
            //住院
            String ehrList2 = jwSmjkService.getResidentEventListJson(strSSID, "2", page + "", pageSize + "");
            jo.put("status", 10000);
            jo.put("门诊", new JSONArray(ehrList1));
            jo.put("住院", new JSONArray(ehrList2));
        }catch (Exception e){
            jo.put("status", 10001);
        }
        return jo.toString();
    }
    public String GetRecordListByCatalogcodesJson(String strSSID) {
        JSONObject jo = new JSONObject();
        try {
            Integer page = 1;
            Integer pageSize = 100;
            //检查
            String ehrList1 = jwSmjkService.getExamAndLabReport(strSSID, page + "", pageSize + "");
            jo.put("status", 10000);
            jo.put("检查", new JSONArray(ehrList1));
        }catch (Exception e){
            jo.put("status", 10001);
        }
        return jo.toString();
    }
}

+ 93 - 0
patient-co-figure/src/main/java/com/yihu/figure/service/dict/SystemDictService.java

@ -0,0 +1,93 @@
package com.yihu.figure.service.dict;
import com.yihu.figure.dao.dict.SystemDictDao;
import com.yihu.figure.model.dict.SystemDict;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import java.util.List;
/**
 * Created by Administrator on 2016/8/13.
 */
@Service
public class SystemDictService {
    @Autowired
    private SystemDictDao systemDictDao;
    @Autowired
    private StringRedisTemplate redisTemplate;
    public List<SystemDict> getDictByDictName(String name) {
        return systemDictDao.findByDictName(name);
    }
    private String dictName =  "SYSTEM_PARAMS";
    /**
     * 字典转译
     * @param dictName
     * @param code
     * @return
     */
    public String getDictValue(String dictName,String code){
        String re = "";
        try {
            if(!StringUtils.isEmpty(code))
            {
                //判断该字典redis是否存在
                String exit = redisTemplate.opsForValue().get("systemDict:"+dictName);
                if(!StringUtils.isEmpty(exit))
                {
                    re =  redisTemplate.opsForValue().get("systemDict:"+dictName+":"+code);
                }
                else{
                    List<SystemDict> list = systemDictDao.findByDictName(dictName);
                    if(list!=null && list.size()>0)
                    {
                        redisTemplate.opsForValue().set("systemDict:"+dictName,"1");
                        for(SystemDict item:list)
                        {
                            redisTemplate.opsForValue().set("systemDict:"+dictName+":"+item.getCode(),item.getValue());
                            if(code.equals(item.getCode()))
                            {
                                re = item.getValue();
                            }
                        }
                    }
                }
            }
        }
        catch (Exception ex)
        {
            ex.printStackTrace();
            re = systemDictDao.findByDictNameAndCode(dictName,code);
        }
        return re;
    }
    /************************************** 其他参数 ****************************************/
    /**
     * http_log是否记录成功消息
     * @return
     */
    public Boolean getSaveSuccessLog()
    {
        try{
            String re = systemDictDao.findByDictNameAndCode(dictName, "SAVE_SUCCESS_LOG");
            if("1".equals(re))
            {
                return true;
            }
            else{
                return false;
            }
        }
        catch (Exception ex)
        {
            ex.printStackTrace();
            return false;
        }
    }
}

+ 805 - 0
patient-co-figure/src/main/java/com/yihu/figure/service/jw/JwArchivesService.java

@ -0,0 +1,805 @@
package com.yihu.figure.service.jw;
import com.yihu.figure.service.dict.SystemDictService;
import com.yihu.figure.util.HttpClientUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
/**
 * Created by hzp on 2016/11/15.
 * 基卫健康档案服务
 */
@Service("JwArchivesService")
public class JwArchivesService {
    //基卫服务地址
    @Value("${jiwei.url}")
    private String jwUrl ;
    @Autowired
    private SystemDictService systemDictService;
    /**
     *  查询居民健康体检列表信息接口
     */
    public JSONArray getEhrSickMedicalList(String idcard,Integer pageIndex,Integer pageSize)  throws Exception
    {
        JSONArray re =  new JSONArray();
        String url = jwUrl + "/third/archives/getEhrSickMedicalList";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("idcard", idcard));
        String response = HttpClientUtil.post(url, params, "UTF-8");
        if(!StringUtils.isEmpty(response))
        {
            JSONObject json = new JSONObject(response);
            if (!"200".equals(json.optString("status"))) {
                throw new Exception(json.optString("msg"));
            }else{
                String dataStr = json.getString("data");
                if(!StringUtils.isEmpty(dataStr)){
                    JSONObject data = new JSONObject(dataStr);
                    if("1".equals(data.optString("CODE")))
                    {
                        JSONArray jsonArray = data.getJSONArray("DATA");
                        List<JSONObject> jsonValues = new ArrayList<JSONObject>();
                        for (int i = 0; i < jsonArray.length(); i++) {
                            JSONObject jsonObject = jsonArray.getJSONObject(i);
                            JSONObject mjson = new JSONObject();
                            String medicalNo  = jsonObject.get("MEDICAL_NO").toString();
                            mjson.put("orgName",jsonObject.get("ORG_NAME").toString());
                            mjson.put("medicalNo",medicalNo);
                            mjson.put("medicalTime",jsonObject.get("MEDICAL_TIME").toString());
                            jsonValues.add(mjson);
                        }
                        Collections.sort( jsonValues, new Comparator<JSONObject>() {
                            @Override
                            public int compare(JSONObject a, JSONObject b) {
                                String valA = a.get("medicalTime").toString();
                                String valB = b.get("medicalTime").toString();
                                return valB.compareTo(valA);
                            }
                        });
                        for (JSONObject temp:jsonValues){
                            re.put(temp);
                        }
                    }
                    else{
                        throw new Exception(json.optString("MESSAGE"));
                    }
                }else{
                    throw new Exception("返回结果为空!");
                }
            }
        }
        else{
            throw new Exception("返回结果为空!");
        }
        return re;
    }
    /**
     *  查询居民健康体检详情接口
     */
    public JSONObject getEhrSickMedicalRecord(String medicalNo)  throws Exception
    {
        JSONObject re = new JSONObject();
        String url = jwUrl + "/third/archives/getEhrSickMedicalRecord";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("medicalNo", medicalNo));
        String response = HttpClientUtil.post(url, params, "UTF-8");
        if(!StringUtils.isEmpty(response))
        {
            JSONObject json = new JSONObject(response);
            if (!"200".equals(json.optString("status"))) {
                throw new Exception(json.optString("msg"));
            }else {
                String dataStr = json.getString("data");
                if(!StringUtils.isEmpty(dataStr)){
                    JSONObject data = new JSONObject(dataStr);
                    if("1".equals(data.optString("CODE")))
                    {
                        JSONArray jsonArray = data.getJSONArray("DATA");
                        if(jsonArray.length()==0){
                            throw new Exception("返回结果为空!");
                        }
                        JSONObject jsonObject = jsonArray.getJSONObject(0);
                        //报告信息
                        re.put("medicalTime",jsonObject.get("MEDICAL_TIME").toString());//体检时间
                        re.put("doctorName",jsonObject.get("MEDICAL_OPERATOR").toString());//体检医生
                        re.put("orgName",jsonObject.get("ORG_NAME").toString());//机构名称
                        // 健康评价
                        String isExaminationExcep = jsonObject.get("IS_EXAMINATION_EXCEP").toString();//是否异常2为异常,空或非2为正常
                        JSONArray jsonArrayEx = new JSONArray();
                        if("2".equals(isExaminationExcep)){
                            re.put("isExaminationExcep","1");//(0.无异常;1.异常)
                            String name = "EXAMINATION_EXCEP";
                            Boolean flag = true;
                            int i = 0;
                            while (flag){
                                i++;
                                if(jsonObject.isNull(name+i)){
                                    flag = false;
                                }else {
                                    Object ex = jsonObject.get(name+i);
                                    String examinationExcep = ex.toString();
                                    if(StringUtils.isEmpty(examinationExcep)){
                                        flag = false;
                                    }else {
                                        jsonArrayEx.put(examinationExcep);
                                    }
                                }
                            }
                            re.put("examinationList",jsonArrayEx);//异常
                        }else{
                            re.put("isExaminationExcep","0");
                            re.put("examinationList",jsonArrayEx);//异常
                        }
                        // 健康指导-定期随访
                        String healthRegularFollowUp = jsonObject.get("HEALTH_REGULAR_FOLLOW_UP").toString();//是否有定期随访
                        String healthGuidanceSlowDisease = jsonObject.get("HEALTH_GUIDANCE_SLOW_DISEASE").toString();//纳入慢性病患者健康管理
                        String healthGuidanceInhospital = jsonObject.get("HEALTH_GUIDANCE_INHOSPITAL").toString();//建议复查
                        String healthGuidanceReview = jsonObject.get("HEALTH_GUIDANCE_REVIEW").toString();//建议转诊
                        String healthGuidanceOther = jsonObject.get("HEALTH_GUIDANCE_OTHER").toString();//其他0.无 1.有
                        String healthGuidanceOtherStr = jsonObject.get("HEALTH_GUIDANCE_OTHER_STR").toString();//其它内容
                        re.put("healthRegularFollowUp",healthRegularFollowUp);
                        re.put("healthGuidanceSlowDisease",healthGuidanceSlowDisease);
                        re.put("healthGuidanceInhospital",healthGuidanceInhospital);
                        re.put("healthGuidanceReview",healthGuidanceReview);
                        re.put("healthGuidanceOther",healthGuidanceOther);
                        re.put("healthGuidanceOtherStr",healthGuidanceOtherStr);
                        //危险因素控制
                        String hazardQuitSmocking = jsonObject.get("HAZARD_QUIT_SMOCKING").toString();//戒烟
                        String hazardHealthDrink = jsonObject.get("HAZARD_HEALTH_DRINK").toString();//健康饮酒
                        String hazardFood = jsonObject.get("HAZARD_FOOD").toString();//饮食
                        String hazardHardening = jsonObject.get("HAZARD_HARDENING").toString();//锻炼
                        String hazardLoseWeight = jsonObject.get("HAZARD_LOSE_WEIGHT").toString();//减体重
                        String hazardLoseWeightTarget = jsonObject.get("HAZARD_LOSE_WEIGHT_TARGET").toString();//减体重其它内容
                        String hazardVaccination = jsonObject.get("HAZARD_VACCINATION").toString();//建议接种疫苗
                        String hazardVaccinationStr = jsonObject.get("HAZARD_VACCINATION_STR").toString();//建议接种疫苗其它内容
                        String hazardOthers = jsonObject.get("HAZARD_OTHERS").toString();//其它
                        String hazardOthersStr = jsonObject.get("HAZARD_OTHERS_STR").toString();//其它内容
                        re.put("hazardQuitSmocking",hazardQuitSmocking);
                        re.put("hazardHealthDrink",hazardHealthDrink);
                        re.put("hazardFood",hazardFood);
                        re.put("hazardHardening",hazardHardening);
                        re.put("hazardLoseWeight",hazardLoseWeight);
                        re.put("hazardLoseWeightTarget",hazardLoseWeightTarget);
                        re.put("hazardVaccination",hazardVaccination);
                        re.put("hazardVaccinationStr",hazardVaccinationStr);
                        re.put("hazardOthers",hazardOthers);
                        re.put("hazardOthersStr",hazardOthersStr);
                        // 症状
                        String asymptomatic = jsonObject.get("ASYMPTOMATIC").toString();//0.无 1.有
                        String symptomHeadache = jsonObject.get("SYMPTOM_HEADACHE").toString();//头痛
                        String symptomDizziness = jsonObject.get("SYMPTOM_DIZZINESS").toString();//头晕
                        String symptomPalpitation = jsonObject.get("SYMPTOM_PALPITATION").toString();//心悸
                        String symptomChestStuffiness = jsonObject.get("SYMPTOM_CHEST_STUFFINESS").toString();//胸闷
                        String symptomChestPain = jsonObject.get("SYMPTOM_CHEST_PAIN").toString();//胸痛
                        String symptomChronicCough = jsonObject.get("SYMPTOM_CHRONIC_COUGH").toString();//慢性咳嗽
                        String symptomExpectoration = jsonObject.get("SYMPTOM_EXPECTORATION").toString();//咳痰
                        String symptomDyspnea = jsonObject.get("SYMPTOM_DYSPNEA").toString();//呼吸困难
                        String symptomPolydipsia = jsonObject.get("SYMPTOM_POLYDIPSIA").toString();//多饮
                        String symptomPolyuria = jsonObject.get("SYMPTOM_POLYURIA").toString();//多尿
                        String symptomWeightLoss = jsonObject.get("SYMPTOM_WEIGHT_LOSS").toString();//体重下降
                        String symptomLackOfPower = jsonObject.get("SYMPTOM_LACK_OF_POWER").toString();//乏力
                        String symptomJointGall = jsonObject.get("SYMPTOM_JOINT_GALL").toString();//关节肿痛
                        String symptomBlurredVision = jsonObject.get("SYMPTOM_BLURRED_VISION").toString();//视力模糊
                        String symptomHandFootNumbness = jsonObject.get("SYMPTOM_HAND_FOOT_NUMBNESS").toString();//手脚麻木
                        String symptomUrinaryUrgency = jsonObject.get("SYMPTOM_URINARY_URGENCY").toString();//尿急
                        String symptomDysuria = jsonObject.get("SYMPTOM_DYSURIA").toString();//尿痛
                        String symptomConstipation = jsonObject.get("SYMPTOM_CONSTIPATION").toString();//便秘
                        String symptomDiarrhea = jsonObject.get("SYMPTOM_DIARRHEA").toString();//腹泻
                        String symptomNauseaVomiting = jsonObject.get("SYMPTOM_NAUSEA_VOMITING").toString();//恶心呕吐
                        String symptomDazzle = jsonObject.get("SYMPTOM_DAZZLE").toString();//眼花
                        String symptomTinnitus = jsonObject.get("SYMPTOM_TINNITUS").toString();//耳鸣
                        String symptomBreastBursting = jsonObject.get("SYMPTOM_BREAST_BURSTING").toString();//乳房胀痛
                        String symptomOther = jsonObject.get("SYMPTOM_OTHER").toString();//症状其它
                        String symptomOtherStr = jsonObject.get("SYMPTOM_OTHER_STR").toString();//症状其它内容
                        re.put("asymptomatic",asymptomatic);
                        re.put("symptomHeadache",symptomHeadache);
                        re.put("symptomDizziness",symptomDizziness);
                        re.put("symptomPalpitation",symptomPalpitation);
                        re.put("symptomChestStuffiness",symptomChestStuffiness);
                        re.put("symptomChestPain",symptomChestPain);
                        re.put("symptomChronicCough",symptomChronicCough);
                        re.put("symptomExpectoration",symptomExpectoration);
                        re.put("symptomDyspnea",symptomDyspnea);
                        re.put("symptomPolydipsia",symptomPolydipsia);
                        re.put("symptomPolyuria",symptomPolyuria);
                        re.put("symptomWeightLoss",symptomWeightLoss);
                        re.put("symptomLackOfPower",symptomLackOfPower);
                        re.put("symptomJointGall",symptomJointGall);
                        re.put("symptomBlurredVision",symptomBlurredVision);
                        re.put("symptomHandFootNumbness",symptomHandFootNumbness);
                        re.put("symptomUrinaryUrgency",symptomUrinaryUrgency);
                        re.put("symptomDysuria",symptomDysuria);
                        re.put("symptomConstipation",symptomConstipation);
                        re.put("symptomDiarrhea",symptomDiarrhea);
                        re.put("symptomNauseaVomiting",symptomNauseaVomiting);
                        re.put("symptomDazzle",symptomDazzle);
                        re.put("symptomTinnitus",symptomTinnitus);
                        re.put("symptomBreastBursting",symptomBreastBursting);
                        re.put("symptomOther",symptomOther);
                        re.put("symptomOtherStr",symptomOtherStr);
                        // 一般情况
                        re.put("bodyTemperature",jsonObject.get("BODY_TEMPERATURE").toString());// 体温
                        re.put("pulseFrequency",jsonObject.get("PULSE_FREQUENCY").toString());//   脉率
                        re.put("respiratoryRate",jsonObject.get("RESPIRATORY_RATE").toString());// 呼吸频率
                        re.put("bloodPressureLeftD",jsonObject.get("BLOOD_PRESSURE_LEFT_D").toString());// 血压(左)
                        re.put("bloodPressureLeftU",jsonObject.get("BLOOD_PRESSURE_LEFT_U").toString());// 血压(左)
                        re.put("bloodPressureRigthD",jsonObject.get("BLOOD_PRESSURE_RIGTH_D").toString());// 血压(右)
                        re.put("bloodPressureRigthU",jsonObject.get("BLOOD_PRESSURE_RIGTH_U").toString());// 血压(右)
                        re.put("height",jsonObject.get("HEIGHT").toString());// 身高
                        re.put("weight",jsonObject.get("WEIGHT").toString());// 体重
                        re.put("waist",jsonObject.get("WAIST").toString());// 腰围
                        re.put("bmi",jsonObject.get("BMI").toString());// 体质指数(BMI)
                        String elderlyHealthStatus = jsonObject.get("ELDERLY_HEALTH_STATUS").toString();
                        String elderlySelfCare = jsonObject.get("ELDERLY_SELF_CARE").toString();
                        if(!StringUtils.isEmpty(elderlyHealthStatus)){
                            elderlyHealthStatus = systemDictService.getDictValue("ELDERLY_HEALTH_STATUS",elderlyHealthStatus);
                        }
                        if(!StringUtils.isEmpty(elderlySelfCare)){
                            elderlySelfCare = systemDictService.getDictValue("ELDERLY_SELF_CARE",elderlySelfCare);
                        }
                        re.put("elderlyHealthStatus",elderlyHealthStatus);// 老年人健康状态自我评估
                        re.put("elderlySelfCare",elderlySelfCare);// 老年人生活自理能力评估
                        re.put("elderlyCognitiveFun",jsonObject.get("ELDERLY_COGNITIVE_FUN").toString());// 老年人认知功能
                        re.put("miniMentalStateExamination",jsonObject.get("MINI_MENTAL_STATE_EXAMINATION").toString());//  --简易智力状态检查
                        re.put("elderlyAffectiveState",jsonObject.get("ELDERLY_AFFECTIVE_STATE").toString());//                            老年人情感状态
                        re.put("elderlyDepressionCheck",jsonObject.get("ELDERLY_DEPRESSION_CHECK").toString());//  --老年人抑郁评分
                        // 生活方式
                        // 体育锻炼
                        re.put("hardeningMode",jsonObject.get("HARDENING_MODE").toString());// 锻炼方式
                        String hardeningFrequency = jsonObject.get("HARDENING_FREQUENCY").toString();
                        if(!StringUtils.isEmpty(hardeningFrequency)){
                            hardeningFrequency = systemDictService.getDictValue("HARDENING_FREQUENCY",hardeningFrequency);
                        }
                        re.put("hardeningFrequency",hardeningFrequency);// 锻炼频率
                        re.put("everyHardeningTime",jsonObject.get("EVERY_HARDENING_TIME").toString());// 每次锻炼时间
                        re.put("insistHardeningTime",jsonObject.get("INSIST_HARDENING_TIME").toString());// 坚持锻炼时间
                        //         饮食习惯
                        String eatClitocybineEqualization = jsonObject.get("EAT_CLITOCYBINE_EQUALIZATION").toString();//荤素均衡
                        String eatMeatdietFlash = jsonObject.get("EAT_MEATDIET_FLASH").toString();//荤食为主
                        String eatVegetarianFlash = jsonObject.get("EAT_VEGETARIAN_FLASH").toString();//素食为主
                        String eatHobbySalt = jsonObject.get("EAT_HOBBY_SALT").toString();//嗜盐
                        String eatHobbyOil = jsonObject.get("EAT_HOBBY_OIL").toString();//嗜油
                        String eatHobbySugar = jsonObject.get("EAT_HOBBY_SUGAR").toString();//嗜糖
                        re.put("eatClitocybineEqualization",eatClitocybineEqualization);
                        re.put("eatMeatdietFlash",eatMeatdietFlash);
                        re.put("eatVegetarianFlash",eatVegetarianFlash);
                        re.put("eatHobbySalt",eatHobbySalt);
                        re.put("eatHobbyOil",eatHobbyOil);
                        re.put("eatHobbySugar",eatHobbySugar);
                        //         吸烟情况
                        re.put("smokingCircumstance",jsonObject.get("SMOKING_CIRCUMSTANCE").toString());// 吸烟状况
                        re.put("dailySmokingQuantity",jsonObject.get("DAILY_SMOKING_QUANTITY").toString());// 日吸烟量
                        re.put("beginSmokingAge",jsonObject.get("BEGIN_SMOKING_AGE").toString());// 开始吸烟年龄
                        re.put("quitSmokingAge",jsonObject.get("QUIT_SMOKING_AGE").toString());// 戒烟年龄
                        //         饮酒情况
                        String drinkFrequency = jsonObject.get("DRINK_FREQUENCY").toString();
                        if(!StringUtils.isEmpty(drinkFrequency)){
                            drinkFrequency = systemDictService.getDictValue("DRINK_FREQUENCY",drinkFrequency);
                        }
                        re.put("drinkFrequency",drinkFrequency);// 饮酒频率
                        re.put("everyAlcohol_tolerance",jsonObject.get("EVERY_ALCOHOL_TOLERANCE").toString());// 日饮酒量
                        re.put("isDryOut",jsonObject.get("IS_DRY_OUT").toString());// 是否戒酒
                        re.put("dryOutAge",jsonObject.get("DRY_OUT_AGE").toString());//  --戒酒年龄
                        re.put("beginDrinkAge",jsonObject.get("BEGIN_DRINK_AGE").toString());// 开始饮酒年龄
                        re.put("oneYearIsTemulentia",jsonObject.get("ONE_YEAR_IS_TEMULENTIA").toString());// 近一年内是否曾醉酒
                        // 饮酒种类:drinks
                        String drinkWhiteSpirits  = jsonObject.get("DRINK_WHITE_SPIRITS").toString();//白酒
                        String drinkBeer = jsonObject.get("DRINK_BEER").toString();//啤酒
                        String drinkRedWine = jsonObject.get("DRINK_RED_WINE").toString();//红酒
                        String drinkYellowWine = jsonObject.get("DRINK_YELLOW_WINE").toString();//黄酒
                        String drinkOthers = jsonObject.get("DRINK_OTHERS").toString();//饮酒种类其它
                        String drinkOthersStr = jsonObject.get("DRINK_OTHERS_STR").toString();//饮酒种类其它内容
                        re.put("drinkWhiteSpirits",drinkWhiteSpirits);
                        re.put("drinkBeer",drinkBeer);
                        re.put("drinkRedWine",drinkRedWine);
                        re.put("drinkYellowWine",drinkYellowWine);
                        re.put("drinkOthers",drinkOthers);
                        re.put("drinkOthersStr",drinkOthersStr);
                        //         职业暴露情况
                        re.put("occupationalDisease",jsonObject.get("OCCUPATIONAL_DISEASE").toString());// 有接触史
                        re.put("occDiseaseTrades",jsonObject.get("OCC_DISEASE_TRADES").toString());//--工种
                        re.put("occupationalDiseaseWorkTime",jsonObject.get("OCCUPATIONAL_DISEASE_WORK_TIME").toString());//--从业时间
                        re.put("poisonDust",jsonObject.get("POISON_DUST").toString());//  粉尘
                        re.put("poisonDustIspre",jsonObject.get("POISON_DUST_ISPRE").toString());//-- 是否有防护措施
                        re.put("poisonDustPreStr",jsonObject.get("POISON_DUST_PRE_STR").toString());//--防护措施
                        re.put("poisonRadiogen",jsonObject.get("POISON_RADIOGEN").toString());//  放射物质
                        re.put("poisonRadiogenIspre",jsonObject.get("POISON_RADIOGEN_ISPRE").toString());//-- 是否有防护措施
                        re.put("poisonRadiogenPreStr",jsonObject.get("POISON_RADIOGEN_PRE_STR").toString());//--防护措施
                        re.put("poisonPhysicalfactor",jsonObject.get("POISON_PHYSICALFACTOR").toString());//  物理因素
                        re.put("poisonPhysicalIspre",jsonObject.get("POISON_PHYSICAL_ISPRE").toString());//-- 是否有防护措施
                        re.put("poisonPhysicalPreStr",jsonObject.get("POISON_PHYSICAL_PRE_STR").toString());//--防护措施
                        re.put("poisonChemical",jsonObject.get("POISON_CHEMICAL").toString());//  化学物质
                        re.put("poisonChemicalIspre",jsonObject.get("POISON_CHEMICAL_ISPRE").toString());//-- 是否有防护措施
                        re.put("poisonChemicalPreStr",jsonObject.get("POISON_CHEMICAL_PRE_STR").toString());//--防护措施
                        re.put("poisonOthers",jsonObject.get("POISON_OTHERS").toString());//  其他
                        re.put("poisonOthersIspre",jsonObject.get("POISON_OTHERS_ISPRE").toString());//-- 是否有防护措施
                        re.put("poisonOthersPreStr",jsonObject.get("POISON_OTHERS_PRE_STR").toString());//--防护措施
                        //  脏器功能
                        //  口腔
                        re.put("lips",jsonObject.get("LIPS").toString());//  --口唇
                        String dentitiondentureNormal = jsonObject.get("DENTITIONDENTURE_NORMAL").toString();//齿列--名称【正常】【0.无 1.有】",
                        String  dentitiondentureMissTeeth = jsonObject.get("DENTITIONDENTURE_MISS_TEETH").toString();//缺齿
                        String dentitiondentureDentalCaries = jsonObject.get("DENTITIONDENTURE_DENTAL_CARIES").toString();//龋齿
                        String dentitiondentureDenture = jsonObject.get("DENTITIONDENTURE_DENTURE").toString();//义齿(假牙)
                        re.put("dentitiondentureNormal",dentitiondentureNormal);
                        re.put("dentitiondentureMissTeeth",dentitiondentureMissTeeth);
                        re.put("dentitiondentureDentalCaries",dentitiondentureDentalCaries);
                        re.put("dentitiondentureDenture",dentitiondentureDenture);
                        String pharyngealportionNo = jsonObject.get("PHARYNGEALPORTION_NO").toString();//咽部--名称【无充血】【0.无 1.有】",
                        String pharyngealportionYes = jsonObject.get("PHARYNGEALPORTION_YES").toString();//充血
                        String pharyngealportionAdd = jsonObject.get("PHARYNGEALPORTION_ADD").toString();//淋巴滤泡增生
                        re.put("pharyngealportionNo",pharyngealportionNo);
                        re.put("pharyngealportionYes",pharyngealportionYes);
                        re.put("pharyngealportionAdd",pharyngealportionAdd);
                        //   视力
                        re.put("visionLeftEye",jsonObject.get("VISION_LEFT_EYE").toString());//  --左眼
                        re.put("visionRightEye",jsonObject.get("VISION_RIGHT_EYE").toString());//  --右眼
                        //   矫正视力
                        re.put("straightenVisionLeftEye",jsonObject.get("STRAIGHTEN_VISION_LEFT_EYE").toString());//  --左眼
                        re.put("straightenVisionRightEye",jsonObject.get("STRAIGHTEN_VISION_RIGHT_EYE").toString());//  --右眼
                        String audition = jsonObject.get("AUDITION").toString();
                        String motorFunction = jsonObject.get("MOTOR_FUNCTION").toString();
                        if(!StringUtils.isEmpty(audition)){
                            audition = systemDictService.getDictValue("AUDITION",audition);
                        }
                        if(!StringUtils.isEmpty(motorFunction)){
                            motorFunction = systemDictService.getDictValue("MOTOR_FUNCTION",motorFunction);
                        }
                        re.put("audition",audition);// 听力
                        re.put("motorFunction",motorFunction);// 运动功能
                        // 查体
                        String eyeground = jsonObject.get("EYEGROUND").toString();//眼底【1.正常;2.异常;】
                        String eyegroundException = jsonObject.get("EYEGROUND_EXCEPTION").toString();//眼底异常内容
                        String skin = jsonObject.get("SKIN").toString();//皮肤
                        String skinOthers = jsonObject.get("SKIN_OTHERS").toString();//皮肤其它内容
                        String sclera = jsonObject.get("SCLERA").toString();//巩膜
                        String scleraOthers = jsonObject.get("SCLERA_OTHERS").toString();//巩膜其它
                        if(!StringUtils.isEmpty(skin)){
                            skin = systemDictService.getDictValue("SKIN",skin);
                        }
                        if(!StringUtils.isEmpty(sclera)){
                            sclera = systemDictService.getDictValue("SCLERA",sclera);
                        }
                        re.put("eyeground",eyeground);// 眼底
                        re.put("eyegroundException",eyegroundException);// 眼底
                        re.put("skin",skin);// 皮肤
                        re.put("skinOthers",skinOthers);// 皮肤
                        re.put("sclera",sclera);// 巩膜
                        re.put("scleraOthers",scleraOthers);// 巩膜
                        String lymphNodeNotTouch = jsonObject.get("LYMPH_NODE_NOT_TOUCH").toString();//淋巴结--名称【未触及】(1未触及)
                        String lymphNodeClavicle = jsonObject.get("LYMPH_NODE_CLAVICLE").toString();//锁骨上
                        String lymphNodeRrmprt = jsonObject.get("LYMPH_NODE_RRMPRT").toString();//腋窝
                        String lymphNode = jsonObject.get("LYMPH_NODE").toString();//淋巴结--名称【其他】
                        String lymphNodeOthers = jsonObject.get("LYMPH_NODE_OTHERS").toString();//其他内容
                        re.put("lymphNodeNotTouch",lymphNodeNotTouch);
                        re.put("lymphNodeClavicle",lymphNodeClavicle);
                        re.put("lymphNodeRrmprt",lymphNodeRrmprt);
                        re.put("lymphNode",lymphNode);
                        re.put("lymphNodeOthers",lymphNodeOthers);
                        // 肺
                        String lungBarrelChest = jsonObject.get("LUNG_BARREL_CHEST").toString();//  --肺桶状胸【1否;2.是;】
                        String lungBreathSound = jsonObject.get("LUNG_BREATH_SOUND").toString();//  --肺呼吸音【1.正常;2.异常】
                        String lungBreathSoundExcep = jsonObject.get("LUNG_BREATH_SOUND_EXCEP").toString();//  --呼吸音异常内容
                        String lungRhonchus = jsonObject.get("LUNG_RHONCHUS").toString();//  --罗音
                        String lungRhonchusException = jsonObject.get("LUNG_RHONCHUS_EXCEPTION").toString();// -- 罗音异常内容
                        if(!StringUtils.isEmpty(lungRhonchus)){
                            lungRhonchus = systemDictService.getDictValue("LUNG_RHONCHUS",lungRhonchus);
                        }
                        re.put("lungBarrelChest",lungBarrelChest);
                        re.put("lungBreathSound",lungBreathSound);
                        re.put("lungBreathSoundExcep",lungBreathSoundExcep);
                        re.put("lungRhonchus",lungRhonchus);
                        re.put("lungRhonchusException",lungRhonchusException);
                        //    心脏
                        re.put("heartRate",jsonObject.get("HEART_RATE").toString());//--心率
                        String cardiacRhythm = jsonObject.get("CARDIAC_RHYTHM").toString();
                        if(!StringUtils.isEmpty(cardiacRhythm)){
                            cardiacRhythm = systemDictService.getDictValue("CARDIAC_RHYTHM",cardiacRhythm);
                        }
                        re.put("cardiacRhythm",cardiacRhythm);//--心律
                        //  --杂音
                        String cardiacSouffle = jsonObject.get("CARDIAC_SOUFFLE").toString();//--杂音
                        String cardiacSouffleOthers = jsonObject.get("CARDIAC_SOUFFLE_OTHERS").toString();//--杂音其它内容
                        re.put("cardiacSouffle",cardiacSouffle);
                        re.put("cardiacSouffleOthers",cardiacSouffleOthers);
                        //   腹部
                        String abdoPressPain = jsonObject.get("ABDO_PRESS_PAIN").toString();//压痛
                        String abdoPressPainOth = jsonObject.get("ABDO_PRESS_PAIN_OTH").toString();//压痛其它内容
                        String abdoMasses = jsonObject.get("ABDO_MASSES").toString();//包块
                        String abdoMassesOthers = jsonObject.get("ABDO_MASSES_OTHERS").toString();//包块其它内容
                        String abdoHepatomegaly = jsonObject.get("ABDO_HEPATOMEGALY").toString();//肝大
                        String abdoHepatomegalyOth = jsonObject.get("ABDO_HEPATOMEGALY_OTH").toString();//肝大其它内容
                        String abdoSplenomegaly = jsonObject.get("ABDO_SPLENOMEGALY").toString();//脾大
                        String abdoSplenomegalyOth = jsonObject.get("ABDO_SPLENOMEGALY_OTH").toString();//脾大其它内容
                        String abdoShiftingDull = jsonObject.get("ABDO_SHIFTING_DULL").toString();//移动性浊音
                        String abdoShiftingDullOth = jsonObject.get("ABDO_SHIFTING_DULL_OTH").toString();//移动性浊音其它内容
                        re.put("abdoPressPain",abdoPressPain);
                        re.put("abdoPressPainOth",abdoPressPainOth);
                        re.put("abdoMasses",abdoMasses);
                        re.put("abdoMassesOthers",abdoMassesOthers);
                        re.put("abdoHepatomegaly",abdoHepatomegaly);
                        re.put("abdoHepatomegalyOth",abdoHepatomegalyOth);
                        re.put("abdoSplenomegaly",abdoSplenomegaly);
                        re.put("abdoSplenomegalyOth",abdoSplenomegalyOth);
                        re.put("abdoShiftingDull",abdoShiftingDull);
                        re.put("abdoShiftingDullOth",abdoShiftingDullOth);
                        String immersionFoot = jsonObject.get("IMMERSION_FOOT").toString();//下肢水肿
                        String dorsumOfFootArteriopalmus = jsonObject.get("DORSUM_OF_FOOT_ARTERIOPALMUS").toString();//足背动脉博动
                        String fundamentFingerp = jsonObject.get("FUNDAMENT_FINGERP").toString();//肛门指诊
                        String fundamentFingerpOth = jsonObject.get("FUNDAMENT_FINGERP_OTH").toString();//肛门指诊其它内容
                        if(!StringUtils.isEmpty(immersionFoot)){
                            immersionFoot = systemDictService.getDictValue("IMMERSION_FOOT",immersionFoot);
                        }
                        if(!StringUtils.isEmpty(dorsumOfFootArteriopalmus)){
                            dorsumOfFootArteriopalmus = systemDictService.getDictValue("DORSUM_OF_FOOT_ARTERIOPALMUS",dorsumOfFootArteriopalmus);
                        }
                        re.put("immersionFoot",immersionFoot);
                        re.put("dorsumOfFootArteriopalmus",dorsumOfFootArteriopalmus);
                        re.put("fundamentFingerp",fundamentFingerp);
                        re.put("fundamentFingerpOth",fundamentFingerpOth);
                        //   乳腺 breast
                        String breastNotTroubleFind = jsonObject.get("BREAST_NOT_TROUBLE_FIND").toString();//乳腺--名称【未见异常】
                        String breastMastectomy = jsonObject.get("BREAST_MASTECTOMY").toString();//乳房切除
                        String breastAbnormalLactation = jsonObject.get("BREAST_ABNORMAL_LACTATION").toString();//异常泌乳
                        String breastMasses = jsonObject.get("BREAST_MASSES").toString();//乳腺包块
                        String breastOthers = jsonObject.get("BREAST_OTHERS").toString();//其它
                        String breastOthersStr = jsonObject.get("BREAST_OTHERS_STR").toString();//其它内容
                        re.put("breastNotTroubleFind",breastNotTroubleFind);
                        re.put("breastMastectomy",breastMastectomy);
                        re.put("breastAbnormalLactation",breastAbnormalLactation);
                        re.put("breastMasses",breastMasses);
                        re.put("breastOthers",breastOthers);
                        re.put("breastOthersStr",breastOthersStr);
                        //   妇科
                        String vulva = jsonObject.get("VULVA").toString();//外阴
                        String vulvaException = jsonObject.get("VULVA_EXCEPTION").toString();//外阴异常
                        String vagina = jsonObject.get("VAGINA").toString();//阴道
                        String vaginaException = jsonObject.get("VAGINA_EXCEPTION").toString();//阴道异常
                        String cervix = jsonObject.get("CERVIX").toString();//宫颈
                        String cervixException = jsonObject.get("CERVIX_EXCEPTION").toString();//宫颈异常
                        String corpus = jsonObject.get("CORPUS").toString();//宫体
                        String corpusException = jsonObject.get("CORPUS_EXCEPTION").toString();//宫体异常
                        String attachment = jsonObject.get("ATTACHMENT").toString();//附件
                        String attachmentException = jsonObject.get("ATTACHMENT_EXCEPTION").toString();//附件异常
                        re.put("vulva",vulva);
                        re.put("vulvaException",vulvaException);
                        re.put("vagina",vagina);
                        re.put("vaginaException",vaginaException);
                        re.put("cervix",cervix);
                        re.put("cervixException",cervixException);
                        re.put("corpus",corpus);
                        re.put("corpusException",corpusException);
                        re.put("attachment",attachment);
                        re.put("attachmentException",attachmentException);
                        re.put("physicalExaminationOth",jsonObject.get("PHYSICAL_EXAMINATION_OTH").toString());// 其他
                        // 辅助检查
                        //         血常规
                        re.put("hemoglobin",jsonObject.get("HEMOGLOBIN").toString());// 血红蛋白
                        re.put("leukocyte",jsonObject.get("LEUKOCYTE").toString());// 白细胞
                        re.put("platelet",jsonObject.get("PLATELET").toString());// 血小板
                        re.put("bloodRoutineOthers",jsonObject.get("BLOOD_ROUTINE_OTHERS").toString());// 其他
                        //         尿常规
                        re.put("proteinuria",jsonObject.get("PROTEINURIA").toString());// 尿蛋白
                        re.put("urineSugar",jsonObject.get("URINE_SUGAR").toString());// 尿糖
                        re.put("ket",jsonObject.get("KET").toString());// 尿酮体:
                        re.put("urinaryOccultBlood",jsonObject.get("URINARY_OCCULT_BLOOD").toString());// 尿潜血
                        re.put("urineRoutineOthers",jsonObject.get("URINE_ROUTINE_OTHERS").toString());// 其他
                        //         空腹血糖
                        re.put("fastingPlasmaGlucoseL",jsonObject.get("FASTING_PLASMA_GLUCOSE_L").toString());//
                        re.put("fastingPlasmaGlucoseDL",jsonObject.get("FASTING_PLASMA_GLUCOSE_DL").toString());//
                        //         心电图
                        re.put("electrocardiogram",jsonObject.get("ELECTROCARDIOGRAM").toString());// 是否异常
                        re.put("electrocardiogramExcep",jsonObject.get("ELECTROCARDIOGRAM_EXCEP").toString());// 异常情况
                        re.put("microalbuminuria",jsonObject.get("MICROALBUMINURIA").toString());//尿微量白蛋白
                        re.put("upcr",jsonObject.get("UP_CR").toString());//尿白蛋白/肌酥比值
                        re.put("stoolOccultBlood",jsonObject.get("STOOL_OCCULT_BLOOD").toString());//大便潜血
                        re.put("glycolatedHemoglobin",jsonObject.get("GLYCOLATED_HEMOGLOBIN").toString());//糖化血红蛋白
                        re.put("hbsag",jsonObject.get("HBSAG").toString());//乙型肝炎表面抗原
                        //         肾功能
                        re.put("liverFunctionSalt",jsonObject.get("LIVER_FUNCTION_SALT").toString());// 血清谷丙转氨酶
                        re.put("liverFunctionSgot",jsonObject.get("LIVER_FUNCTION_SGOT").toString());// 血清谷草转氨酶
                        re.put("liverFunctionAlbumin",jsonObject.get("LIVER_FUNCTION_ALBUMIN").toString());// 白蛋白
                        re.put("liverFunctionTotalBilirubin",jsonObject.get("LIVER_FUNCTION_TOTAL_BILIRUBIN").toString());// 总胆红素
                        re.put("liverFunctionCb",jsonObject.get("LIVER_FUNCTION_CB").toString());// 结合胆红素
                        //         肝功能
                        re.put("renalFunctionCreatinine",jsonObject.get("RENAL_FUNCTION_CREATININE").toString());// 血清肌酥:
                        re.put("renalFunctionBun",jsonObject.get("RENAL_FUNCTION_BUN").toString());// 血尿素氮:
                        re.put("renalFunctionBloodPotassium",jsonObject.get("RENAL_FUNCTION_BLOOD_POTASSIUM").toString());// 血钾浓度:
                        re.put("renalFunctionNatremia",jsonObject.get("RENAL_FUNCTION_NATREMIA").toString());// 血钠浓度:
                        re.put("uricAcid",jsonObject.get("URIC_ACID").toString());// 尿酸
                        //         血脂
                        re.put("bloodFatTc",jsonObject.get("BLOOD_FAT_TC").toString());// 总胆固醇
                        re.put("bloodFatTriglyceride",jsonObject.get("BLOOD_FAT_TRIGLYCERIDE").toString());// 甘油三酯
                        re.put("bloodFatLdlc",jsonObject.get("BLOOD_FAT_LDLC").toString());// 血清低密度脂蛋白胆固醇
                        re.put("bloodFatHdlc",jsonObject.get("BLOOD_FAT_HDLC").toString());// 血清告密的脂蛋白胆固醇
                        //         胸部X线片
                        re.put("cxr",jsonObject.get("CXR").toString());// 是否异常
                        re.put("cxrException",jsonObject.get("CXR_EXCEPTION").toString());// 异常情况
                        //         B超
                        re.put("typeBUltrasonic",jsonObject.get("TYPE_B_ULTRASONIC").toString());// 是否异常
                        re.put("typeBUltrasonicExcep",jsonObject.get("TYPE_B_ULTRASONIC_EXCEP").toString());// 异常情况
                        //         宫颈涂片
                        re.put("cervicalPapSmears",jsonObject.get("CERVICAL_PAP_SMEARS").toString());// 是否异常
                        re.put("cervicalPapSmearsExcep",jsonObject.get("CERVICAL_PAP_SMEARS_EXCEP").toString());// 异常情况
                        //         其他
                        re.put("assistantInvesOth",jsonObject.get("ASSISTANT_INVES_OTH").toString());//
                        //         中医体质辨识
                        re.put("corporeityGentle",jsonObject.get("CORPOREITY_GENTLE").toString());// 平和质
                        re.put("corporeityQiAsthenia",jsonObject.get("CORPOREITY_QI_ASTHENIA").toString());// 气虚质
                        re.put("corporeityYangDeficiency",jsonObject.get("CORPOREITY_YANG_DEFICIENCY").toString());// 阳虚质
                        re.put("corporeityYinDeficiency",jsonObject.get("CORPOREITY_YIN_DEFICIENCY").toString());// 阴虚质
                        re.put("corporeityPhlegmDamp",jsonObject.get("CORPOREITY_PHLEGM_DAMP").toString());// 痰湿质
                        re.put("corporeityDampHeat",jsonObject.get("CORPOREITY_DAMP_HEAT").toString());// 湿热质
                        re.put("corporeityHaemostasis",jsonObject.get("CORPOREITY_HAEMOSTASIS").toString());// 血瘀质
                        re.put("corporeityQiDepression",jsonObject.get("CORPOREITY_QI_DEPRESSION").toString());// 气郁质
                        re.put("corporeityTeBing",jsonObject.get("CORPOREITY_TE_BING").toString());// 特秉质
                        // 现存主要健康问题
                        //         脑血管疾病
                        re.put("cvdUndiscovered",jsonObject.get("CVD_UNDISCOVERED").toString());//名称【未发现】【0.无 1.有】
                        re.put("cvdIschemicStroke",jsonObject.get("CVD_ISCHEMIC_STROKE").toString());//缺血性卒中
                        re.put("cvdCerebralHemorrhage",jsonObject.get("CVD_CEREBRAL_HEMORRHAGE").toString());//脑出血
                        re.put("cvdSah",jsonObject.get("CVD_SAH").toString());//蛛网膜下腔出血
                        re.put("cvdTia",jsonObject.get("CVD_TIA").toString());//短暂性脑缺血发作
                        re.put("cvdOthers",jsonObject.get("CVD_OTHERS").toString());//其他
                        re.put("cvdOthersStr",jsonObject.get("CVD_OTHERS_STR").toString());//其他内容
                        //         肾脏疾病
                        re.put("renalUndiscovered",jsonObject.get("RENAL_UNDISCOVERED").toString());//名称【未发现】【0.无 1.有】
                        re.put("renalDn",jsonObject.get("RENAL_DN").toString());//糖尿病肾病
                        re.put("renalFailure",jsonObject.get("RENAL_FAILURE").toString());//肾功能衰竭
                        re.put("renalAgn",jsonObject.get("RENAL_AGN").toString());//急性肾炎
                        re.put("renalCgn",jsonObject.get("RENAL_CGN").toString());//慢性肾炎
                        re.put("renalOthers",jsonObject.get("RENAL_OTHERS").toString());//其他
                        re.put("renalOthersStr",jsonObject.get("RENAL_OTHERS_STR").toString());//其他内容
                        //         心脏疾病
                        re.put("heartUndiscovered",jsonObject.get("HEART_UNDISCOVERED").toString());//名称【未发现】【0.无 1.有】
                        re.put("heartMyocardialInfarction",jsonObject.get("HEART_MYOCARDIAL_INFARCTION").toString());//心肌梗死
                        re.put("heartAnginaPectoris",jsonObject.get("HEART_ANGINA_PECTORIS").toString());//心绞痛
                        re.put("heartCoronaryArtery",jsonObject.get("HEART_CORONARY_ARTERY").toString());//冠状动脉血运重建
                        re.put("heartChf",jsonObject.get("HEART_CHF").toString());//充血性心力衰竭
                        re.put("heartPrecordialpain",jsonObject.get("HEART_PRECORDIALPAIN").toString());//心前区疼痛
                        re.put("heartOthers",jsonObject.get("HEART_OTHERS").toString());//其他
                        re.put("heartOthersStr",jsonObject.get("HEART_OTHERS_STR").toString());//其他内容
                        //         血管疾病
                        re.put("angiosisUndiscovered",jsonObject.get("ANGIOSIS_UNDISCOVERED").toString());//名称【未发现】【0.无 1.有】
                        re.put("angiosisDa",jsonObject.get("ANGIOSIS_DA").toString());//夹层动脉瘤
                        re.put("angiosisOcclusionArteries",jsonObject.get("ANGIOSIS_OCCLUSION_ARTERIES").toString());//动脉闭塞性疾病
                        re.put("angiosisOthers",jsonObject.get("ANGIOSIS_OTHERS").toString());//其他
                        re.put("angiosisOthersStr",jsonObject.get("ANGIOSIS_OTHERS_STR").toString());//其他内容
                        //         眼部疾病
                        re.put("eyeDiseaseUndiscovered",jsonObject.get("EYE_DISEASE_UNDISCOVERED").toString());//名称【未发现】【0.无 1.有】
                        re.put("retinalHemorrhage",jsonObject.get("RETINAL_HEMORRHAGE").toString());//视网膜出血
                        re.put("papilledema",jsonObject.get("PAPILLEDEMA").toString());//视乳头水肿
                        re.put("eyeDiseaseCataract",jsonObject.get("EYE_DISEASE_CATARACT").toString());//名称【白内障】【0.无 1.有】
                        re.put("eyeDiseaseOthers",jsonObject.get("EYE_DISEASE_OTHERS").toString());//其他
                        re.put("eyeDiseaseOthersStr",jsonObject.get("EYE_DISEASE_OTHERS_STR").toString());//其他内容
                        //         神经系统疾病
                        re.put("nervousSystemDisease",jsonObject.get("NERVOUS_SYSTEM_DISEASE").toString());//
                        re.put("nervousSystemDiseaseStr",jsonObject.get("NERVOUS_SYSTEM_DISEASE_STR").toString());// 神经系统疾病有内容
                        //         其他系统疾病
                        re.put("othersSystemDisease",jsonObject.get("OTHERS_SYSTEM_DISEASE").toString());//
                        re.put("othersSystemDiseaseStr",jsonObject.get("OTHERS_SYSTEM_DISEASE_STR").toString());//其他系统疾病有内容
                        //         住院治疗情况
                        // 住院史 inhospitalList
                        JSONArray jsonArrayinhospital = new JSONArray();
                        String inhospitalAdmissiondate = "INHOSPITAL_ADMISSIONDATE";// 入院时间
                        String inhospitalLeavedate = "INHOSPITAL_LEAVEDATE";// 出院时间
                        String inhospitalCause = "INHOSPITAL_CAUSE";// 原因
                        String inhospitalPatientId = "INHOSPITAL_PATIENT_ID";// 病案号
                        String inhospitalOrgName = "INHOSPITAL_ORG_NAME";// inhospitalOrgNameN
                        Boolean inhospitalFlag = true;
                        int inhospitali = 0;
                        while (inhospitalFlag){
                            inhospitali++;
                            if(jsonObject.isNull(inhospitalPatientId+inhospitali)){
                                inhospitalFlag = false;
                            }else {
                                Object ex = jsonObject.get(inhospitalPatientId+inhospitali);
                                String examinationExcep = ex.toString();
                                if(StringUtils.isEmpty(examinationExcep)){
                                    inhospitalFlag = false;
                                }else {
                                    JSONObject inhospital = new JSONObject();
                                    inhospital.put("inhospitalAdmissiondate",jsonObject.get(inhospitalAdmissiondate+inhospitali));
                                    inhospital.put("inhospitalLeavedate",jsonObject.get(inhospitalLeavedate+inhospitali));
                                    inhospital.put("inhospitalCause",jsonObject.get(inhospitalCause+inhospitali));
                                    inhospital.put("inhospitalPatientId",jsonObject.get(inhospitalPatientId+inhospitali));
                                    inhospital.put("inhospitalOrgName",jsonObject.get(inhospitalOrgName+inhospitali+"_N"));
                                    jsonArrayinhospital.put(inhospital);
                                }
                            }
                        }
                        re.put("inhospitalList",jsonArrayinhospital);//异常
                        // 家庭病床史 fpList
                        JSONArray jsonArrayFp = new JSONArray();
                        String fpEstablishDate = "FP_ESTABLISH_DATE";// 建床时间
                        String fpCancelDate = "FP_CANCEL_DATE";// 撤床时间
                        String fpCause = "FP_CAUSE";// 原因
                        String fpPatientId = "FP_PATIENT_ID";// 病案号
                        String fpOrgName = "FP_ORG_NAME";// 名称
                        Boolean fpFlag = true;
                        int fpi = 0;
                        while (fpFlag){
                            fpi++;
                            if(jsonObject.isNull(fpPatientId+fpi)){
                                fpFlag = false;
                            }else {
                                Object ex = jsonObject.get(fpPatientId+fpi);
                                String examinationExcep = ex.toString();
                                if(StringUtils.isEmpty(examinationExcep)){
                                    fpFlag = false;
                                }else {
                                    JSONObject fp = new JSONObject();
                                    fp.put("fpEstablishDate",jsonObject.get(fpEstablishDate+fpi));
                                    fp.put("fpCancelDate",jsonObject.get(fpCancelDate+fpi));
                                    fp.put("fpCause",jsonObject.get(fpCause+fpi));
                                    fp.put("fpPatientId",jsonObject.get(fpPatientId+fpi));
                                    fp.put("fpOrgName",jsonObject.get(fpOrgName+fpi+"_N"));
                                    jsonArrayFp.put(fp);
                                }
                            }
                        }
                        re.put("fpList",jsonArrayFp);
                        // 主要用药情况 drugList
                        JSONArray jsonArrayDrug = new JSONArray();
                        String drugName = "DRUG_NAME";// 药品名称
                        String drugUsage = "DRUG_USAGE";// 用法文字
                        String drugDosage = "DRUG_DOSAGE";// 用量内容
                        String drugDate = "DRUG_DATE";//用药时间
                        String drugCompliance = "DRUG_COMPLIANCE";// 服药依从性
                        Boolean drugFlag = true;
                        int drugi = 0;
                        while (drugFlag){
                            drugi++;
                            if(jsonObject.isNull(drugName+drugi)){
                                drugFlag = false;
                            }else {
                                Object ex = jsonObject.get(drugName+drugi);
                                String examinationExcep = ex.toString();
                                if(StringUtils.isEmpty(examinationExcep)){
                                    drugFlag = false;
                                }else {
                                    JSONObject drug = new JSONObject();
                                    drug.put("drugName",jsonObject.get(drugName+drugi));
                                    drug.put("drugUsage",jsonObject.get(drugUsage+drugi));
                                    drug.put("drugDosage",jsonObject.get(drugDosage+drugi));
                                    drug.put("drugDate",jsonObject.get(drugDate+drugi));
                                    drug.put("drugCompliance",jsonObject.get(drugCompliance+drugi));
                                    jsonArrayDrug.put(drug);
                                }
                            }
                        }
                        re.put("drugList",jsonArrayDrug);
                        // 非免疫规划预防接种史 niVaccinationList
                        JSONArray jsonArrayNiVaccination = new JSONArray();
                        String niVaccinationName = "NI_VACCINATION_NAME";// 接种名称
                        String niVaccinationDate = "NI_VACCINATION_DATE";// 接种日期
                        String niVaccinationOrg = "NI_VACCINATION_ORG";// 接种机构
                        Boolean niVaccinationFlag = true;
                        int niVaccinationi = 0;
                        while (niVaccinationFlag){
                            niVaccinationi++;
                            if(jsonObject.isNull(niVaccinationName+niVaccinationi)){
                                niVaccinationFlag = false;
                            }else {
                                Object ex = jsonObject.get(niVaccinationName+niVaccinationi);
                                String examinationExcep = ex.toString();
                                if(StringUtils.isEmpty(examinationExcep)){
                                    niVaccinationFlag = false;
                                }else {
                                    JSONObject niVaccination = new JSONObject();
                                    niVaccination.put("niVaccinationName",jsonObject.get(niVaccinationName+niVaccinationi));
                                    niVaccination.put("niVaccinationDate",jsonObject.get(niVaccinationDate+niVaccinationi));
                                    niVaccination.put("niVaccinationOrg",jsonObject.get(niVaccinationOrg+niVaccinationi+"_N"));
                                    jsonArrayNiVaccination.put(niVaccination);
                                }
                            }
                        }
                        re.put("niVaccinationList",jsonArrayNiVaccination);
                    }
                    else{
                        throw new Exception(json.optString("MESSAGE"));
                    }
                }else{
                    throw new Exception("返回结果为空!");
                }
            }
        }
        else{
            throw new Exception("返回结果为空!");
        }
        return re;
    }
    /**
     *  上传体征指标接口
     */
    public void uploadHealthIndex(String id)  throws Exception
    {
        String url = jwUrl + "/third/archives/uploadHealthIndex";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("id", id));
        String response = HttpClientUtil.post(url, params, "UTF-8");
        if(!StringUtils.isEmpty(response))
        {
            JSONObject json = new JSONObject(response);
            if (!"200".equals(json.optString("status"))) {
                throw new Exception(json.optString("msg"));
            }
        }
        else{
            throw new Exception("返回结果为空!");
        }
    }
    /**
     * 上传随访记录接口
     */
    public void uploadFollowup(String id) throws Exception
    {
        String url = jwUrl + "/third/archives/uploadFollowup";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("id", id));
        String response = HttpClientUtil.post(url, params, "UTF-8");
        if(!StringUtils.isEmpty(response))
        {
            JSONObject json = new JSONObject(response);
            if (!"200".equals(json.optString("status"))) {
                throw new Exception(json.optString("msg"));
            }
        }
        else{
            throw new Exception("返回结果为空!");
        }
    }
}

+ 64 - 0
patient-co-figure/src/main/java/com/yihu/figure/service/jw/JwSignService.java

@ -0,0 +1,64 @@
package com.yihu.figure.service.jw;
import com.yihu.figure.util.HttpClientUtil;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
 * Created by hzp on 2016/12/19.
 * 基卫签约服务
 */
@Service
public class JwSignService {
    //基卫服务地址
    @Value("${jiwei.url}")
    private String jwUrl ;
    /****************************************************************************************************************************/
    /**
     * 上传家庭签约记录
     */
    public String uploadSignFamily(String code) {
        String url = jwUrl + "/third/sign/UploadSignFamily";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("code", code));
        return HttpClientUtil.post(url, params, "UTF-8");
    }
    /**
     * 获取患者三师签约信息
     */
    public String getSignSanshi(String idcard) {
        String url = jwUrl + "/third/zysoftservice/getSickSanShiTeamSignInfo";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("idcard", idcard));
        return HttpClientUtil.post(url, params, "UTF-8");
    }
    /**
     * 获取患者家庭签约信息
     */
    public String getSignFamily(String idcard) {
        String url = jwUrl + "/third/zysoftservice/getSickCurrnetFamilySignInfo";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("idcard", idcard));
        return HttpClientUtil.post(url, params, "UTF-8");
    }
}

+ 727 - 0
patient-co-figure/src/main/java/com/yihu/figure/service/jw/JwSmjkService.java

@ -0,0 +1,727 @@
package com.yihu.figure.service.jw;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.figure.model.dict.SystemDict;
import com.yihu.figure.service.dict.SystemDictService;
import com.yihu.figure.util.DateUtil;
import com.yihu.figure.util.HttpClientUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * Created by hzp on 2016/11/14.
 * 基卫健康市民健康服务
 */
@Service
public class JwSmjkService {
    //基卫服务地址
    @Value("${jiwei.url}")
    private String jwUrl;
    @Autowired
    private ObjectMapper objectMapper = new ObjectMapper();
    @Autowired
    private SystemDictService systemDictService;
    /****************************************************************************************************************************/
    /**
     * 获取门/急诊记录 + 住院记录
     */
    public String getResidentEventListJson(String strSSID, String type, String page, String pageSize) {
        String re = "";
        try {
            String url = jwUrl + "/third/smjk/ResidentEventList";
            List<NameValuePair> params = new ArrayList<>();
            params.add(new BasicNameValuePair("strSSID", strSSID));
            if (!StringUtils.isEmpty(type)) {
                params.add(new BasicNameValuePair("type", type));
            }
            params.add(new BasicNameValuePair("page", page));
            params.add(new BasicNameValuePair("pageSize", pageSize));
            String response = HttpClientUtil.post(url, params, "UTF-8");
            if (!StringUtils.isEmpty(response)) {
                JSONObject responseObject = new JSONObject(response);
                int status = responseObject.getInt("status");
                if (status == 200) {
                    String data = responseObject.getString("data");
                    if (!StringUtils.isEmpty(data) && data.startsWith("error")) {
                        throw new Exception(data);
                    } else {
                        JSONObject jsonData = new JSONObject(data);
                        Integer count = jsonData.getJSONArray("EventCount").getJSONObject(0).getInt("COUNT");
                        if (count <= Integer.valueOf(pageSize)) {
                            JSONArray jsonArray = jsonData.getJSONArray("EventList");
                            re = jsonArray.toString();
                        }else{
                            re=getResidentEventListJson(strSSID,type,page,count+"");
                        }
                    }
                } else {
                    throw new Exception(responseObject.getString("msg"));
                }
            } else {
                throw new Exception("null response.");
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        if (re.equals("[{}]")) {
            re = "";
        }
        return re;
    }
    /**
     * 通过event获取档案类型列表
     */
    public String getEventCatalog(String strSSID, String strEvent) {
        try {
            String url = jwUrl + "/third/smjk/EventCatalog";
            List<NameValuePair> params = new ArrayList<>();
            params.add(new BasicNameValuePair("strSSID", strSSID));
            params.add(new BasicNameValuePair("strEvent", strEvent));
            String response = HttpClientUtil.post(url, params, "UTF-8");
            String result = "";
            if (!StringUtils.isEmpty(response)) {
                JSONObject jsonObject = new JSONObject(response);
                int status = jsonObject.getInt("status");
                if (status == 200) {
                    result = jsonObject.getString("data");
                } else {
                    throw new Exception(jsonObject.getString("msg"));
                }
            } else {
                throw new Exception("null response.");
            }
            return result;
        } catch (Exception ex) {
            ex.printStackTrace();
            return "";
        }
    }
    /**
     * 获取健康档案信息详情
     */
    public String getHealthData(String strSSID, String strEvent, String strCatalog, String strSerial) {
        try {
            String url = jwUrl + "/third/smjk/HealthData";
            List<NameValuePair> params = new ArrayList<>();
            params.add(new BasicNameValuePair("strSSID", strSSID));
            params.add(new BasicNameValuePair("strEvent", strEvent));
            params.add(new BasicNameValuePair("strCatalog", strCatalog));
            params.add(new BasicNameValuePair("strSerial", strSerial));
            String response = HttpClientUtil.post(url, params, "UTF-8");
            String result = "";
            if (!StringUtils.isEmpty(response)) {
                JSONObject jsonObject = new JSONObject(response);
                int status = jsonObject.getInt("status");
                if (status == 200) {
                    result = jsonObject.getString("data");
                    result = result.replaceAll("<\\?xml version=\"1.0\" encoding=\"utf-8\"\\?>", "");
                    if (result.startsWith("error")) {
                        throw new Exception(result);
                    }
                } else {
                    throw new Exception(jsonObject.getString("msg"));
                }
            } else {
                throw new Exception("null response.");
            }
            return result;
        } catch (Exception ex) {
            ex.printStackTrace();
            return "";
        }
    }
    /**
     * 获取检查检验列表
     */
    public String getExamAndLabReport(String strSSID, String page, String pageSize) {
        try {
            String url = jwUrl + "/third/smjk/ExamAndLabReport";
            List<NameValuePair> params = new ArrayList<>();
            params.add(new BasicNameValuePair("strSSID", strSSID));
            params.add(new BasicNameValuePair("page", page));
            params.add(new BasicNameValuePair("pageSize", pageSize));
            String response = HttpClientUtil.post(url, params, "UTF-8");
            String re = "";
            if (!StringUtils.isEmpty(response)) {
                JSONObject jsonObject = new JSONObject(response);
                int status = jsonObject.getInt("status");
                if (status == 200) {
                    String data = jsonObject.getString("data");
                    if (!StringUtils.isEmpty(data) && data.startsWith("error")) {
                        throw new Exception(data);
                    } else {
                        JSONObject jsonData = new JSONObject(data);
                        Integer count = jsonData.getJSONArray("EhrCount").getJSONObject(0).getInt("COUNT");
                        if (count <= Integer.valueOf(pageSize)) {
                            JSONArray jsonArray = jsonData.getJSONArray("EhrList");
                            re = jsonArray.toString();
                        }else{
                            re=getExamAndLabReport(strSSID,page,count+"");
                        }
                    }
                } else {
                    throw new Exception(jsonObject.getString("msg"));
                }
            } else {
                throw new Exception("null response.");
            }
            if (re.equals("[{}]")) {
                re = "";
            }
            return re;
        } catch (Exception ex) {
            ex.printStackTrace();
            return "";
        }
    }
    /**
     * 获取用药列表
     */
    public String getDrugsListPage(String strSSID, String page, String pageSize) throws Exception {
        String url = jwUrl + "/third/smjk/DrugsListPage";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("strSSID", strSSID));
        params.add(new BasicNameValuePair("page", page));
        params.add(new BasicNameValuePair("pageSize", pageSize));
        String response = HttpClientUtil.post(url, params, "UTF-8");
        String result = "";
        if (!StringUtils.isEmpty(response)) {
            JSONObject jsonObject = new JSONObject(response);
            int status = jsonObject.getInt("status");
            if (status == 200) {
                result = jsonObject.getString("data");
            } else {
                throw new Exception(jsonObject.getString("msg"));
            }
        } else {
            throw new Exception("null response.");
        }
        if (result.equals("[{}]")) {
            result = "";
        }
        return result;
    }
    /****************************************************************************************************************************/
    /**
     * (内网)获取转诊预约医生号源信息
     */
    public String getRegDeptSpeDoctorSectionList(String OrgCode, String DeptCode, String strStart, String strEnd, String DocCode) throws Exception {
        String re = "";
        String url = jwUrl + "/third/smjk/RegDeptSpeDoctorSectionList";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("OrgCode", OrgCode));
        params.add(new BasicNameValuePair("DeptCode", DeptCode));
        params.add(new BasicNameValuePair("strStart", strStart));
        params.add(new BasicNameValuePair("strEnd", strEnd));
        params.add(new BasicNameValuePair("DocCode", DocCode));
        String response = HttpClientUtil.post(url, params, "UTF-8");
        if (!StringUtils.isEmpty(response)) {
            JSONObject jsonObject = new JSONObject(response);
            int status = jsonObject.getInt("status");
            if (status == 200) {
                String data = jsonObject.getString("data");
                if (!StringUtils.isEmpty(data) && (data.startsWith("error") || data.startsWith("System-Error"))) {
                    throw new Exception(data);
                } else {
                    re = data;
                }
            } else {
                throw new Exception(jsonObject.getString("msg"));
            }
        } else {
            throw new Exception("null response.");
        }
        return re;
    }
    /**
     * (内网)预约挂号接口
     */
    public String webRegisterByFamily(String idcard, String patientName, String ssid, String sectionType, String startTime, String orgCode, String deptCode, String deptName, String doctorCode, String doctorName, String patientPhone) throws Exception {
        String re = "";
        String url = jwUrl + "/third/smjk/WebRegisterByFamily";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("idcard", idcard));
        params.add(new BasicNameValuePair("patientName", patientName));
        params.add(new BasicNameValuePair("ssid", ssid));
        params.add(new BasicNameValuePair("sectionType", sectionType));
        params.add(new BasicNameValuePair("startTime", startTime));
        params.add(new BasicNameValuePair("orgCode", orgCode));
        params.add(new BasicNameValuePair("deptCode", deptCode));
        params.add(new BasicNameValuePair("deptName", deptName));
        params.add(new BasicNameValuePair("doctorCode", doctorCode));
        params.add(new BasicNameValuePair("doctorName", doctorName));
        params.add(new BasicNameValuePair("patientPhone", patientPhone));
        String response = HttpClientUtil.post(url, params, "UTF-8");
        if (!StringUtils.isEmpty(response)) {
            JSONObject jsonObject = new JSONObject(response);
            int status = jsonObject.getInt("status");
            if (status == 200) {
                String data = jsonObject.getString("data");
                if (!StringUtils.isEmpty(data) && (data.startsWith("error") || data.startsWith("System-Error"))) {
                    throw new Exception(data);
                } else {
                    re = data;
                }
            } else {
                throw new Exception(jsonObject.getString("msg"));
            }
        } else {
            throw new Exception("null response.");
        }
        //返回挂号单
        return re;
    }
    /*************************************** 旧版本函数 *************************************************************************/
    /**
     * 获取住院记录(X)
     */
    public String getHospitalizationRecord(String strSSID, String startNum, String endNum) throws Exception {
        String startDate = "1900-01-01";
        String endDate = DateUtil.dateToStr(DateUtil.getNowDate(), DateUtil.YYYY_MM_DD);
        String url = jwUrl + "/third/smjk/InpatientRecord";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("strSSID", strSSID));
        params.add(new BasicNameValuePair("startDate", startDate));
        params.add(new BasicNameValuePair("endDate", endDate));
        params.add(new BasicNameValuePair("startNum", startNum));
        params.add(new BasicNameValuePair("endNum", endNum));
        String response = HttpClientUtil.post(url, params, "UTF-8");
        JSONArray resultArray = new JSONArray();
        List<SystemDict> systemDictList = systemDictService.getDictByDictName("EHR_CATALOG");
        Map<String, String> systemDictMap = new HashMap<>();
        for (SystemDict systemDict : systemDictList) {
            systemDictMap.put(systemDict.getCode(), systemDict.getValue());
        }
        if (!StringUtils.isEmpty(response)) {
            JSONObject responseObject = new JSONObject(response);
            int status = responseObject.getInt("status");
            if (status == 200) {
                String data = responseObject.getString("data");
                if (!StringUtils.isEmpty(data)) {
                    if (data.startsWith("error")) {
                        return data;
                    }
                    JSONObject jsonData = new JSONObject(data);
                    JSONArray jsonArray = jsonData.getJSONArray("EhrList");
                    if (!jsonArray.isNull(0) && jsonArray.getJSONObject(0).length() != 0) {
                        Map<String, JSONObject> jsonObjectMap = new HashMap<>();
                        for (int i = 0; i < jsonArray.length(); i++) {
                            JSONObject jsonObject = jsonArray.getJSONObject(i);
                            String patientId = jsonObject.getString("XMAN_ID");
                            String eventNo = jsonObject.getString("EVENT");
                            Integer orgId = jsonObject.getInt("ORG_ID");
                            String key = patientId + eventNo + orgId;
                            JSONObject catalogObject = new JSONObject();
                            String catalogCode = jsonObject.get("CATALOG_CODE").toString();
                            String endTimeNew = jsonObject.get("END_TIME").toString();
                            String catalogValue = systemDictMap.get(catalogCode);
                            jsonObject.remove("CATALOG_CODE");
                            if (jsonObjectMap.containsKey(key)) {
                                jsonObject = jsonObjectMap.get(key);
                                String endTimeOld = jsonObject.get("END_TIME").toString();
                                if (endTimeNew.compareTo(endTimeOld) < 0) {
                                    endTimeNew = endTimeOld;
                                }
                                catalogObject = jsonObject.getJSONObject("CATALOG");
                            }
                            catalogObject.put(catalogCode, catalogValue);
                            jsonObject.put("CATALOG", catalogObject);
                            jsonObject.put("END_TIME", endTimeNew);
                            jsonObjectMap.put(key, jsonObject);
                        }
                        for (String key : jsonObjectMap.keySet()) {
                            resultArray.put(jsonObjectMap.get(key));
                        }
                        JSONObject temp;
                        for (int i = 0; i < resultArray.length(); i++) {
                            for (int j = i + 1; j < resultArray.length(); j++) {
                                String endTimeNew = resultArray.getJSONObject(j).get("END_TIME").toString();
                                String endTimeOld = resultArray.getJSONObject(i).get("END_TIME").toString();
                                if (endTimeNew.compareTo(endTimeOld) > 0) {
                                    temp = resultArray.getJSONObject(i);
                                    resultArray.put(i, resultArray.getJSONObject(j));
                                    resultArray.put(j, temp);  // 两个数交换位置
                                }
                            }
                        }
                    }
                }
            }
        }
        return resultArray.toString();
    }
    /**
     * 获取门/急诊记录(X)
     */
    public String getOutpatientRecord(String strSSID, String startNum, String endNum) throws Exception {
        String startDate = "1900-01-01";
        String endDate = DateUtil.dateToStr(DateUtil.getNowDate(), DateUtil.YYYY_MM_DD);
        String url = jwUrl + "/third/smjk/OutpatientRecord";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("strSSID", strSSID));
        params.add(new BasicNameValuePair("startDate", startDate));
        params.add(new BasicNameValuePair("endDate", endDate));
        params.add(new BasicNameValuePair("startNum", startNum));
        params.add(new BasicNameValuePair("endNum", endNum));
        String response = HttpClientUtil.post(url, params, "UTF-8");
        JSONArray resultArray = new JSONArray();
        List<SystemDict> systemDictList = systemDictService.getDictByDictName("EHR_CATALOG");
        Map<String, String> systemDictMap = new HashMap<>();
        for (SystemDict systemDict : systemDictList) {
            systemDictMap.put(systemDict.getCode(), systemDict.getValue());
        }
        if (!StringUtils.isEmpty(response)) {
            JSONObject responseObject = new JSONObject(response);
            int status = responseObject.getInt("status");
            if (status == 200) {
                String data = responseObject.getString("data");
                if (!StringUtils.isEmpty(data)) {
                    if (data.startsWith("error")) {
                        return data;
                    }
                    JSONObject jsonData = new JSONObject(data);
                    JSONArray jsonArray = jsonData.getJSONArray("EhrList");
                    if (!jsonArray.isNull(0) && jsonArray.getJSONObject(0).length() != 0) {
                        Map<String, JSONObject> jsonObjectMap = new HashMap<>();
                        for (int i = 0; i < jsonArray.length(); i++) {
                            JSONObject jsonObject = jsonArray.getJSONObject(i);
                            String patientId = jsonObject.getString("XMAN_ID");
                            String eventNo = jsonObject.getString("EVENT");
                            Integer orgId = jsonObject.getInt("ORG_ID");
                            String key = patientId + eventNo + orgId;
                            JSONObject catalogObject = new JSONObject();
                            String catalogCode = jsonObject.get("CATALOG_CODE").toString();
                            String endTimeNew = jsonObject.get("END_TIME").toString();
                            String catalogValue = systemDictMap.get(catalogCode);
                            jsonObject.remove("CATALOG_CODE");
                            if (jsonObjectMap.containsKey(key)) {
                                jsonObject = jsonObjectMap.get(key);
                                String endTimeOld = jsonObject.get("END_TIME").toString();
                                if (endTimeNew.compareTo(endTimeOld) < 0) {
                                    endTimeNew = endTimeOld;
                                }
                                catalogObject = jsonObject.getJSONObject("CATALOG");
                            }
                            catalogObject.put(catalogCode, catalogValue);
                            jsonObject.put("CATALOG", catalogObject);
                            jsonObject.put("END_TIME", endTimeNew);
                            jsonObjectMap.put(key, jsonObject);
                        }
                        for (String key : jsonObjectMap.keySet()) {
                            resultArray.put(jsonObjectMap.get(key));
                        }
                        JSONObject temp;
                        for (int i = 0; i < resultArray.length(); i++) {
                            for (int j = i + 1; j < resultArray.length(); j++) {
                                String endTimeNew = resultArray.getJSONObject(j).get("END_TIME").toString();
                                String endTimeOld = resultArray.getJSONObject(i).get("END_TIME").toString();
                                if (endTimeNew.compareTo(endTimeOld) > 0) {
                                    temp = resultArray.getJSONObject(i);
                                    resultArray.put(i, resultArray.getJSONObject(j));
                                    resultArray.put(j, temp);  // 两个数交换位置
                                }
                            }
                        }
                    }
                }
            }
        }
        return resultArray.toString();
    }
    /**
     * 获取检查报告信息 (X)
     */
    private JSONArray getChecking(String strSSID, String startNum, String endNum) throws Exception {
        String api = "/third/smjk/ExamReport";
        return getResult(api, strSSID, startNum, endNum);
    }
    /**
     * 获取检验报告信息(X)
     */
    private JSONArray getInspection(String strSSID, String startNum, String endNum) throws Exception {
        String api = "/third/smjk/LabReport";
        return getResult(api, strSSID, startNum, endNum);
    }
    private JSONArray getResult(String api, String strSSID, String startNum, String endNum) {
        String startDate = "1900-01-01";
        String endDate = DateUtil.dateToStr(DateUtil.getNowDate(), DateUtil.YYYY_MM_DD);
        String url = jwUrl + api;
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("strSSID", strSSID));
        params.add(new BasicNameValuePair("startDate", startDate));
        params.add(new BasicNameValuePair("endDate", endDate));
        params.add(new BasicNameValuePair("startNum", startNum));
        params.add(new BasicNameValuePair("endNum", endNum));
        String response = HttpClientUtil.post(url, params, "UTF-8");
        JSONArray resultArray = new JSONArray();
        List<SystemDict> systemDictList = systemDictService.getDictByDictName("EHR_CATALOG");
        Map<String, String> systemDictMap = new HashMap<>();
        for (SystemDict systemDict : systemDictList) {
            systemDictMap.put(systemDict.getCode(), systemDict.getValue());
        }
        if (!StringUtils.isEmpty(response)) {
            JSONObject responseObject = new JSONObject(response);
            int status = responseObject.getInt("status");
            if (status == 200) {
                String data = responseObject.getString("data");
                if (!StringUtils.isEmpty(data)) {
                    if (data.startsWith("error")) {
                        JSONObject jsonObject = new JSONObject();
                        jsonObject.put("error", data);
                        resultArray.put(jsonObject);
                        return resultArray;
                    }
                    JSONObject jsonData = new JSONObject(data);
                    JSONArray jsonArray = jsonData.getJSONArray("EhrList");
                    if (!jsonArray.isNull(0) && jsonArray.getJSONObject(0).length() != 0) {
                        Map<String, JSONObject> jsonObjectMap = new HashMap<>();
                        for (int i = 0; i < jsonArray.length(); i++) {
                            JSONObject jsonObject = jsonArray.getJSONObject(i);
                            String patientId = jsonObject.getString("XMAN_ID");
                            String eventNo = jsonObject.getString("EVENT");
                            Integer orgId = jsonObject.getInt("ORG_ID");
                            String key = patientId + eventNo + orgId;
                            JSONObject catalogObject = new JSONObject();
                            String catalogCode = jsonObject.get("CATALOG_CODE").toString();
                            String endTimeNew = jsonObject.get("END_TIME").toString();
                            String catalogValue = systemDictMap.get(catalogCode);
                            jsonObject.remove("CATALOG_CODE");
                            if (jsonObjectMap.containsKey(key)) {
                                jsonObject = jsonObjectMap.get(key);
                                String endTimeOld = jsonObject.get("END_TIME").toString();
                                if (endTimeNew.compareTo(endTimeOld) < 0) {
                                    endTimeNew = endTimeOld;
                                }
                                catalogObject = jsonObject.getJSONObject("CATALOG");
                            }
                            catalogObject.put(catalogCode, catalogValue);
                            jsonObject.put("CATALOG", catalogObject);
                            jsonObject.put("END_TIME", endTimeNew);
                            jsonObjectMap.put(key, jsonObject);
                        }
                        for (String key : jsonObjectMap.keySet()) {
                            resultArray.put(jsonObjectMap.get(key));
                        }
                    }
                }
            }
        }
        return resultArray;
    }
    /**
     * 获取检查检验 信息(X)
     *
     * @param strSSID
     * @param startNum
     * @param endNum
     * @return
     * @throws Exception
     */
    public String getInspectionAndChecking(String strSSID, String startNum, String endNum) throws Exception {
        JSONArray total = new JSONArray();
        JSONArray check = getChecking(strSSID, startNum, endNum);
        if (!check.isNull(0)) {
            JSONObject jsonObject = check.getJSONObject(0);
            if (jsonObject.has("error")) {
                return jsonObject.get("error").toString();
            }
        }
        JSONArray inspect = getInspection(strSSID, startNum, endNum);
        if (!inspect.isNull(0)) {
            JSONObject jsonObject = inspect.getJSONObject(0);
            if (jsonObject.has("error")) {
                return jsonObject.get("error").toString();
            }
        }
        //TODO 检查检验数据合并
        for (int i = 0; i < check.length(); i++) {
            total.put(check.getJSONObject(i));
        }
        for (int i = 0; i < inspect.length(); i++) {
            total.put(inspect.getJSONObject(i));
        }
        JSONObject temp;
        for (int i = 0; i < total.length(); i++) {
            for (int j = i + 1; j < total.length(); j++) {
                String endTimeNew = total.getJSONObject(j).get("END_TIME").toString();
                String endTimeOld = total.getJSONObject(i).get("END_TIME").toString();
                if (endTimeNew.compareTo(endTimeOld) > 0) {
                    temp = total.getJSONObject(i);
                    total.put(i, total.getJSONObject(j));
                    total.put(j, temp);  // 两个数交换位置
                }
            }
        }
        return total.toString();
    }
    /**
     * 获取用药记录(X)
     */
    public String getDrugsList(String strSSID, String startNum, String endNum) throws Exception {
        String startDate = "1900-01-01";
        String endDate = DateUtil.dateToStr(DateUtil.getNowDate(), DateUtil.YYYY_MM_DD);
        String url = jwUrl + "/third/smjk/DrugsList";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("strSSID", strSSID));
        params.add(new BasicNameValuePair("startDate", startDate));
        params.add(new BasicNameValuePair("endDate", endDate));
        params.add(new BasicNameValuePair("startNum", startNum));
        params.add(new BasicNameValuePair("endNum", endNum));
        String response = HttpClientUtil.post(url, params, "UTF-8");
        JSONArray resultArray = new JSONArray();
        List<SystemDict> systemDictList = systemDictService.getDictByDictName("EHR_CATALOG");
        Map<String, String> systemDictMap = new HashMap<>();
        for (SystemDict systemDict : systemDictList) {
            systemDictMap.put(systemDict.getCode(), systemDict.getValue());
        }
        if (!StringUtils.isEmpty(response)) {
            JSONObject responseObject = new JSONObject(response);
            int status = responseObject.getInt("status");
            if (status == 200) {
                String data = responseObject.getString("data");
                if (!StringUtils.isEmpty(data)) {
                    if (data.startsWith("error")) {
                        return data;
                    }
                    JSONObject jsonData = new JSONObject(data);
                    JSONArray jsonArray = jsonData.getJSONArray("EhrList");
                    if (!jsonArray.isNull(0) && jsonArray.getJSONObject(0).length() != 0) {
                        Map<String, JSONObject> jsonObjectMap = new HashMap<>();
                        for (int i = 0; i < jsonArray.length(); i++) {
                            JSONObject jsonObject = jsonArray.getJSONObject(i);
                            String patientId = jsonObject.getString("XMAN_ID");
                            String eventNo = jsonObject.getString("EVENT");
                            Integer orgId = jsonObject.getInt("ORG_ID");
                            String key = patientId + eventNo + orgId;
                            JSONObject catalogObject = new JSONObject();
                            String catalogCode = jsonObject.get("CATALOG_CODE").toString();
                            String endTimeNew = jsonObject.get("END_TIME").toString();
                            String catalogValue = systemDictMap.get(catalogCode);
                            jsonObject.remove("CATALOG_CODE");
                            if (jsonObjectMap.containsKey(key)) {
                                jsonObject = jsonObjectMap.get(key);
                                String endTimeOld = jsonObject.get("END_TIME").toString();
                                if (endTimeNew.compareTo(endTimeOld) < 0) {
                                    endTimeNew = endTimeOld;
                                }
                                catalogObject = jsonObject.getJSONObject("CATALOG");
                            }
                            catalogObject.put(catalogCode, catalogValue);
                            jsonObject.put("CATALOG", catalogObject);
                            jsonObject.put("END_TIME", endTimeNew);
                            jsonObjectMap.put(key, jsonObject);
                        }
                        for (String key : jsonObjectMap.keySet()) {
                            resultArray.put(jsonObjectMap.get(key));
                        }
                        JSONObject temp;
                        for (int i = 0; i < resultArray.length(); i++) {
                            for (int j = i + 1; j < resultArray.length(); j++) {
                                String endTimeNew = resultArray.getJSONObject(j).get("END_TIME").toString();
                                String endTimeOld = resultArray.getJSONObject(i).get("END_TIME").toString();
                                if (endTimeNew.compareTo(endTimeOld) > 0) {
                                    temp = resultArray.getJSONObject(i);
                                    resultArray.put(i, resultArray.getJSONObject(j));
                                    resultArray.put(j, temp);  // 两个数交换位置
                                }
                            }
                        }
                    }
                }
            }
        }
        return resultArray.toString();
    }
}

+ 720 - 0
patient-co-figure/src/main/java/com/yihu/figure/util/DateUtil.java

@ -0,0 +1,720 @@
package com.yihu.figure.util;
import org.apache.commons.lang3.StringUtils;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.*;
public class DateUtil {
	public static final String HH_MM = "HH:mm";
	public static final String HH_MM_SS = "HH:mm:ss";
	public static final String YY = "yy";
	public static final String YYYYMM = "yyyyMM";
	public static final String YYYYMMDD = "yyyyMMdd";
	public static final String YYYY_MM_DD = "yyyy-MM-dd";
	public static final String YYYYMMDDHHMMSS = "yyyyMMddHHmmss";
	public static final String YYYY_MM_DD_HH = "yyyy-MM-dd HH";
	public static final String YYYY_MM_DD_HH_MM = "yyyy-MM-dd HH:mm";
	public static final String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
	/**
	 * 字符串转时间格式
	 */
	public static Date strToDate(String strDate) {
		if (StringUtils.isEmpty(strDate)) {
			return null;
		}
		else{
			int length = strDate.length();
			if(strDate.contains("-"))
			{
				if(length == 10)
				{
					 return strToDate(strDate,YYYY_MM_DD);
				}
				else if(length == 19)
				{
					return strToDate(strDate,YYYY_MM_DD_HH_MM_SS);
				}
			}
			else{
				if(length == 8)
				{
					return strToDate(strDate,YYYYMMDD);
				}
				else if(length == 14)
				{
					return strToDate(strDate,YYYYMMDDHHMMSS);
				}
			}
		}
		return null;
	}
	/**
	  * 获取现在时间
	  * 
	  * @return 返回时间类型 yyyy-MM-dd HH:mm:ss
	  */
	public static Date getNowDate() {
		Date currentTime = new Date();
		SimpleDateFormat formatter = new SimpleDateFormat(YYYY_MM_DD_HH_MM_SS);
		String dateString = formatter.format(currentTime);
		ParsePosition pos = new ParsePosition(0);
		return formatter.parse(dateString, pos);
	}
	/**
	 * 获取现在时间
	 * 
	 * @return返回短时间格式 yyyy-MM-dd
	 */
	public static Date getNowDateShort() {
		Date currentTime = new Date();
		SimpleDateFormat formatter = new SimpleDateFormat(YYYY_MM_DD);
		String dateString = formatter.format(currentTime);
		return strToDate(dateString, YYYY_MM_DD);
	}
	/**
	 * 获取现在时间
	 * 
	 * @return返回字符串格式 yyyy-MM-dd HH:mm:ss
	 */
	public static String getStringDate() {
		Date currentTime = new Date();
		SimpleDateFormat formatter = new SimpleDateFormat(YYYY_MM_DD_HH_MM_SS);
		return formatter.format(currentTime);
	}
	/**
	 * 获取现在时间
	 * 
	 * @return返回字符串格式 yyyy-MM-dd HH:mm:ss
	 */
	public static String getStringDate(String format) {
		Date currentTime = new Date();
		SimpleDateFormat formatter = new SimpleDateFormat(format);
		return formatter.format(currentTime);
	}
	/**
	 * 获取现在时间
	 * 
	 * @return 返回短时间字符串格式yyyy-MM-dd
	 */
	public static String getStringDateShort() {
		Date currentTime = new Date();
		SimpleDateFormat formatter = new SimpleDateFormat(YYYY_MM_DD);
		return formatter.format(currentTime);
	}
	/**
	 * 获取时间 小时:分;秒 HH:mm:ss
	 * 
	 * @return
	 */
	public static String getTimeShort() {
		SimpleDateFormat formatter = new SimpleDateFormat(HH_MM_SS);
		Date currentTime = new Date();
		return formatter.format(currentTime);
	}
	/**
	 * 将长时间格式字符串转换为时间 yyyy-MM-dd HH:mm:ss
	 * 
	 * @param strDate
	 * @return
	 */
	public static Date strToDateLong(String strDate) {
		if (StringUtils.isEmpty(strDate)) {
			return null;
		}
		SimpleDateFormat formatter = new SimpleDateFormat(YYYY_MM_DD_HH_MM_SS);
		ParsePosition pos = new ParsePosition(0);
		return formatter.parse(strDate, pos);
	}
	public static Date strToDateShort(String strDate) {
		if (StringUtils.isEmpty(strDate)) {
			return null;
		}
		SimpleDateFormat formatter = new SimpleDateFormat(YYYY_MM_DD);
		ParsePosition pos = new ParsePosition(0);
		return formatter.parse(strDate, pos);
	}
	/**
	 * 将长时间格式时间转换为字符串 yyyy-MM-dd HH:mm:ss
	 * 
	 * @param dateDate
	 * @return
	 */
	public static String dateToStrLong(Date dateDate) {
		if (dateDate == null) {
			return "";
		}
		SimpleDateFormat formatter = new SimpleDateFormat(YYYY_MM_DD_HH_MM_SS);
		return formatter.format(dateDate);
	}
	public static String dateToStrNoSecond(Date dateDate) {
		if (dateDate == null) {
			return "";
		}
		SimpleDateFormat formatter = new SimpleDateFormat(YYYY_MM_DD_HH_MM);
		return formatter.format(dateDate);
	}
	/**
	 * 将长时间格式时间转换为字符串 yyyy-MM-dd
	 *
	 * @param dateDate
	 * @return
	 */
	public static String dateToStrShort(Date dateDate) {
		if (dateDate == null) {
			return "";
		}
		SimpleDateFormat formatter = new SimpleDateFormat(YYYY_MM_DD);
		return formatter.format(dateDate);
	}
	/**
	 * 将短时间格式时间转换为字符串 yyyy-MM-dd
	 *
	 * @param dateDate
	 * @param format
	 * @return
	 */
	public static String dateToStr(Date dateDate, String format) {
		if (dateDate == null) {
			return "";
		}
		SimpleDateFormat formatter = new SimpleDateFormat(format);
		return formatter.format(dateDate);
	}
	/**
	 * 将短时间格式字符串转换为时间
	 *
	 * @param strDate
	 * @return
	 */
	public static Date strToDate(String strDate, String format) {
		if (StringUtils.isEmpty(strDate)) {
			return null;
		}
		SimpleDateFormat formatter = new SimpleDateFormat(format);
		ParsePosition pos = new ParsePosition(0);
		return formatter.parse(strDate, pos);
	}
	public static Date strToDateAppendNowTime(String strDate, String format) {
		if (StringUtils.isEmpty(strDate)) {
			return null;
		}
		strDate += " " + getTimeShort();
		SimpleDateFormat formatter = new SimpleDateFormat(format);
		ParsePosition pos = new ParsePosition(0);
		return formatter.parse(strDate, pos);
	}
	/**
	 * 得到现在时间
	 *
	 * @return
	 */
	public static Date getNow() {
		Date currentTime = new Date();
		return currentTime;
	}
	/**
	 * 提取一个月中的最后一天
	 *
	 * @param day
	 * @return
	 */
	public static Date getLastDate(long day) {
		Date date = new Date();
		long date_3_hm = date.getTime() - 3600000 * 34 * day;
		Date date_3_hm_date = new Date(date_3_hm);
		return date_3_hm_date;
	}
	/**
	 * 得到现在时间
	 *
	 * @return 字符串 yyyyMMdd HHmmss
	 */
	public static String getStringToday() {
		Date currentTime = new Date();
		SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd HHmmss");
		String dateString = formatter.format(currentTime);
		return dateString;
	}
	/**
	 * 得到现在小时
	 */
	public static String getHour() {
		Date currentTime = new Date();
		SimpleDateFormat formatter = new SimpleDateFormat(YYYY_MM_DD_HH_MM_SS);
		String dateString = formatter.format(currentTime);
		String hour;
		hour = dateString.substring(11, 13);
		return hour;
	}
	/**
	 * 得到现在分钟
	 *
	 * @return
	 */
	public static String getTime() {
		Date currentTime = new Date();
		SimpleDateFormat formatter = new SimpleDateFormat(YYYY_MM_DD_HH_MM_SS);
		String dateString = formatter.format(currentTime);
		String min;
		min = dateString.substring(14, 16);
		return min;
	}
	/**
	 * 根据用户传入的时间表示格式,返回当前时间的格式 如果是yyyyMMdd,注意字母y不能大写。
	 *
	 * @param sformat
	 *            yyyyMMddhhmmss
	 * @return
	 */
	public static String getUserDate(String sformat) {
		Date currentTime = new Date();
		SimpleDateFormat formatter = new SimpleDateFormat(sformat);
		String dateString = formatter.format(currentTime);
		return dateString;
	}
	/**
	 * 二个小时时间间的差值,必须保证二个时间都是"HH:MM"的格式,返回字符型的分钟
	 */
	public static String getTwoHour(String st1, String st2) {
		String[] kk = null;
		String[] jj = null;
		kk = st1.split(":");
		jj = st2.split(":");
		if (Integer.parseInt(kk[0]) < Integer.parseInt(jj[0]))
			return "0";
		else {
			double y = Double.parseDouble(kk[0]) + Double.parseDouble(kk[1]) / 60;
			double u = Double.parseDouble(jj[0]) + Double.parseDouble(jj[1]) / 60;
			if ((y - u) > 0)
				return y - u + "";
			else
				return "0";
		}
	}
	/**
	 * 得到二个日期间的间隔天数
	 */
	public static String getTwoDay(String sj1, String sj2) {
		SimpleDateFormat myFormatter = new SimpleDateFormat(YYYY_MM_DD);
		long day = 0;
		try {
			Date date = myFormatter.parse(sj1);
			Date mydate = myFormatter.parse(sj2);
			day = (date.getTime() - mydate.getTime()) / (24 * 60 * 60 * 1000);
		} catch (Exception e) {
			return "";
		}
		return day + "";
	}
	/**
	 * 时间前推或后推分钟,其中JJ表示分钟.
	 */
	public static String getPreTime(String sj1, String jj) {
		SimpleDateFormat format = new SimpleDateFormat(YYYY_MM_DD_HH_MM_SS);
		String mydate1 = "";
		try {
			Date date1 = format.parse(sj1);
			long Time = (date1.getTime() / 1000) + Integer.parseInt(jj) * 60;
			date1.setTime(Time * 1000);
			mydate1 = format.format(date1);
		} catch (Exception e) {
		}
		return mydate1;
	}
	/**
	 * 得到一个时间延后或前移几分钟的时间,nowdate为时间,delay为前移或后延的分钟数
	 */
	public static Date getNextMin(Date date, int delay) {
		try {
			Calendar cal = Calendar.getInstance();
			cal.setTime(date);
			cal.add(Calendar.MINUTE, delay);
			return cal.getTime();
		} catch (Exception e) {
			return null;
		}
	}
	/**
	 * 得到一个时间延后或前移几天的时间,nowdate为时间,delay为前移或后延的天数
	 */
	public static String getNextDay(String nowdate, int delay) {
		try {
			SimpleDateFormat format = new SimpleDateFormat(YYYY_MM_DD);
			String mdate = "";
			Date d = strToDate(nowdate, YYYY_MM_DD);
			long myTime = (d.getTime() / 1000) + delay * 24 * 60 * 60;
			d.setTime(myTime * 1000);
			mdate = format.format(d);
			return mdate;
		} catch (Exception e) {
			return "";
		}
	}
	// public static String getNextDay(Date d, int delay) {
	// try {
	// SimpleDateFormat format = new SimpleDateFormat(YYYY_MM_DD);
	// String mdate = "";
	// long myTime = (d.getTime() / 1000) + delay * 24 * 60 * 60;
	// d.setTime(myTime * 1000);
	// mdate = format.format(d);
	// return mdate;
	// } catch (Exception e) {
	// return "";
	// }
	// }
	public static String getNextDay(Date d, int days) {
		Calendar c = Calendar.getInstance();
		c.setTime(d);
		c.add(Calendar.DATE, days);
		return dateToStrShort(c.getTime());
	}
	public static String getNextMonth(Date d, int months) {
		Calendar c = Calendar.getInstance();
		c.setTime(d);
		c.add(Calendar.MONTH, months);
		return dateToStrShort(c.getTime());
	}
	public static String getNextYear(Date d, int year) {
		Calendar c = Calendar.getInstance();
		c.setTime(d);
		c.add(Calendar.YEAR, year);
		return dateToStrShort(c.getTime());
	}
	/**
	 * 获取本月第一天
	 * @return
     */
	public static String getCurMonthFirstDayShort(){
		Calendar c = Calendar.getInstance();
		c.set(Calendar.DAY_OF_MONTH,1);//设置为1号,当前日期既为本月第一天
		return dateToStrShort(c.getTime());
	}
	/**
	 * 判断是否润年
	 *
	 * @param ddate
	 * @return
	 */
	public static boolean isLeapYear(String ddate) {
		/**
		 * 详细设计: 1.被400整除是闰年,否则: 2.不能被4整除则不是闰年 3.能被4整除同时不能被100整除则是闰年
		 * 3.能被4整除同时能被100整除则不是闰年
		 */
		Date d = strToDate(ddate, YYYY_MM_DD);
		GregorianCalendar gc = (GregorianCalendar) Calendar.getInstance();
		gc.setTime(d);
		int year = gc.get(Calendar.YEAR);
		if ((year % 400) == 0)
			return true;
		else if ((year % 4) == 0) {
			if ((year % 100) == 0)
				return false;
			else
				return true;
		} else
			return false;
	}
	/**
	 * 返回美国时间格式 26 Apr 2006
	 *
	 * @param str
	 * @return
	 */
	public static String getEDate(String str) {
		SimpleDateFormat formatter = new SimpleDateFormat(YYYY_MM_DD);
		ParsePosition pos = new ParsePosition(0);
		Date strtodate = formatter.parse(str, pos);
		String j = strtodate.toString();
		String[] k = j.split(" ");
		return k[2] + k[1].toUpperCase() + k[5].substring(2, 4);
	}
	/**
	 * 获取一个月的最后一天
	 *
	 * @param dat
	 * @return
	 */
	public static String getEndDateOfMonth(String dat) {// yyyy-MM-dd
		String str = dat.substring(0, 8);
		String month = dat.substring(5, 7);
		int mon = Integer.parseInt(month);
		if (mon == 1 || mon == 3 || mon == 5 || mon == 7 || mon == 8 || mon == 10 || mon == 12) {
			str += "31";
		} else if (mon == 4 || mon == 6 || mon == 9 || mon == 11) {
			str += "30";
		} else {
			if (isLeapYear(dat)) {
				str += "29";
			} else {
				str += "28";
			}
		}
		return str;
	}
	/**
	 * 判断二个时间是否在同一个周
	 *
	 * @param date1
	 * @param date2
	 * @return
	 */
	public static boolean isSameWeekDates(Date date1, Date date2) {
		Calendar cal1 = Calendar.getInstance();
		Calendar cal2 = Calendar.getInstance();
		cal1.setTime(date1);
		cal2.setTime(date2);
		int subYear = cal1.get(Calendar.YEAR) - cal2.get(Calendar.YEAR);
		if (0 == subYear) {
			if (cal1.get(Calendar.WEEK_OF_YEAR) == cal2.get(Calendar.WEEK_OF_YEAR))
				return true;
		} else if (1 == subYear && 11 == cal2.get(Calendar.MONTH)) {
			// 如果12月的最后一周横跨来年第一周的话则最后一周即算做来年的第一周
			if (cal1.get(Calendar.WEEK_OF_YEAR) == cal2.get(Calendar.WEEK_OF_YEAR))
				return true;
		} else if (-1 == subYear && 11 == cal1.get(Calendar.MONTH)) {
			if (cal1.get(Calendar.WEEK_OF_YEAR) == cal2.get(Calendar.WEEK_OF_YEAR))
				return true;
		}
		return false;
	}
	/**
	 * 产生周序列,即得到当前时间所在的年度是第几周
	 *
	 * @return
	 */
	public static String getSeqWeek() {
		Calendar c = Calendar.getInstance(Locale.CHINA);
		String week = Integer.toString(c.get(Calendar.WEEK_OF_YEAR));
		if (week.length() == 1)
			week = "0" + week;
		String year = Integer.toString(c.get(Calendar.YEAR));
		return year + week;
	}
	/**
	 * 获得一个日期所在的周的星期几的日期,如要找出2002年2月3日所在周的星期一是几号
	 *
	 * @param sdate
	 * @param num
	 * @return
	 */
	public static String getWeek(String sdate, String num) {
		// 再转换为时间
		Date dd = DateUtil.strToDate(sdate, YYYY_MM_DD);
		Calendar c = Calendar.getInstance();
		c.setTime(dd);
		if (num.equals("1")) // 返回星期一所在的日期
			c.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
		else if (num.equals("2")) // 返回星期二所在的日期
			c.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY);
		else if (num.equals("3")) // 返回星期三所在的日期
			c.set(Calendar.DAY_OF_WEEK, Calendar.WEDNESDAY);
		else if (num.equals("4")) // 返回星期四所在的日期
			c.set(Calendar.DAY_OF_WEEK, Calendar.THURSDAY);
		else if (num.equals("5")) // 返回星期五所在的日期
			c.set(Calendar.DAY_OF_WEEK, Calendar.FRIDAY);
		else if (num.equals("6")) // 返回星期六所在的日期
			c.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);
		else if (num.equals("0")) // 返回星期日所在的日期
			c.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
		return new SimpleDateFormat("yyyy-MM-dd").format(c.getTime());
	}
	/**
	 * 根据一个日期,返回是星期几的字符串
	 *
	 * @param sdate
	 * @return
	 */
	public static String getWeek(String sdate) {
		// 再转换为时间
		Date date = DateUtil.strToDate(sdate, YYYY_MM_DD);
		Calendar c = Calendar.getInstance();
		c.setTime(date);
		// int hour=c.get(Calendar.DAY_OF_WEEK);
		// hour中存的就是星期几了,其范围 1~7
		// 1=星期日 7=星期六,其他类推
		return new SimpleDateFormat("EEEE").format(c.getTime());
	}
	public static String getWeekStr(String sdate) {
		String str = "";
		str = DateUtil.getWeek(sdate);
		if ("1".equals(str)) {
			str = "星期日";
		} else if ("2".equals(str)) {
			str = "星期一";
		} else if ("3".equals(str)) {
			str = "星期二";
		} else if ("4".equals(str)) {
			str = "星期三";
		} else if ("5".equals(str)) {
			str = "星期四";
		} else if ("6".equals(str)) {
			str = "星期五";
		} else if ("7".equals(str)) {
			str = "星期六";
		}
		return str;
	}
	/**
	 * 两个时间之间的天数
	 *
	 * @param date1
	 * @param date2
	 * @return
	 */
	public static long getDays(String date1, String date2) {
		if (date1 == null || date1.equals(""))
			return 0;
		if (date2 == null || date2.equals(""))
			return 0;
		// 转换为标准时间
		SimpleDateFormat myFormatter = new SimpleDateFormat(YYYY_MM_DD);
		Date date = null;
		Date mydate = null;
		try {
			date = myFormatter.parse(date1);
			mydate = myFormatter.parse(date2);
		} catch (Exception e) {
		}
		long day = (date.getTime() - mydate.getTime()) / (24 * 60 * 60 * 1000);
		return day;
	}
	/**
	 * 返回两个日期相差的天数
	 * @param date1
	 * @param date2
	 * @return
	 */
	public static long getDays(Date date1, Date date2) {
		if (date1 == null || date2 == null)
			return 0;
		long day = (date1.getTime() - date2.getTime()) / (24 * 60 * 60 * 1000);
		return day;
	}
	/**
	 * 形成如下的日历 , 根据传入的一个时间返回一个结构 星期日 星期一 星期二 星期三 星期四 星期五 星期六 下面是当月的各个时间
	 * 此函数返回该日历第一行星期日所在的日期
	 * 
	 * @param sdate
	 * @return
	 */
	public static String getNowMonth(String sdate) {
		// 取该时间所在月的一号
		sdate = sdate.substring(0, 8) + "01";
		// 得到这个月的1号是星期几
		Date date = DateUtil.strToDate(sdate, YYYY_MM_DD);
		Calendar c = Calendar.getInstance();
		c.setTime(date);
		int u = c.get(Calendar.DAY_OF_WEEK);
		String newday = DateUtil.getNextDay(sdate, 1 - u);
		return newday;
	}
	/**
	 * 取得数据库主键 生成格式为yyyymmddhhmmss+k位随机数
	 * 
	 * @param k 表示是取几位随机数,可以自己定
	 */
	public static String getNo(int k) {
		return getUserDate("yyyyMMddhhmmss") + getRandom(k);
	}
	/**
	 * 返回一个随机数
	 * 
	 * @param i
	 * @return
	 */
	public static String getRandom(int i) {
		Random jjj = new Random();
		if (i == 0)
			return "";
		String jj = "";
		for (int k = 0; k < i; k++) {
			jj = jj + jjj.nextInt(9);
		}
		return jj;
	}
	/**
	 * 根据用户生日计算年龄
	 */
	public static int getAgeByBirthday(Date birthday) {
		try {
			int age = 0;
			if (birthday == null) {
				return age;
			}
			String birth = new SimpleDateFormat("yyyyMMdd").format(birthday);
			int year = Integer.valueOf(birth.substring(0, 4));
			int month = Integer.valueOf(birth.substring(4, 6));
			int day = Integer.valueOf(birth.substring(6));
			Calendar cal = Calendar.getInstance();
			age = cal.get(Calendar.YEAR) - year;
			//周岁计算
			if (cal.get(Calendar.MONTH) < (month - 1) || (cal.get(Calendar.MONTH) == (month - 1) && cal.get(Calendar.DATE) < day)) {
				age--;
			}
			return age;
		} catch (Exception e) {
			return 0;
		}
	}
	public static void main(String[] args) {
//		String hour = "12:22:12";
//		System.out.println(Time.valueOf(hour));
//		System.out.println(getNowDate());
//
		System.out.println(getNextYear(new Date(), -65));
	}
}

+ 241 - 0
patient-co-figure/src/main/java/com/yihu/figure/util/HttpClientUtil.java

@ -0,0 +1,241 @@
package com.yihu.figure.util;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.ParseException;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.json.JSONObject;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.web.client.RestTemplate;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
public class HttpClientUtil {
	/**
	 * 发送post请求
	 * @param url 请求地址
	 * @param params 请求参数
	 * @param chatSet 编码格式
	 * @return
	 */
	public static String post(String url, List<NameValuePair> params, String chatSet) {
		// 创建默认的httpClient实例.
		CloseableHttpClient httpclient = HttpClients.createDefault();
		// 创建httppost
		HttpPost httppost = new HttpPost(url);
		UrlEncodedFormEntity uefEntity;
		try {
			uefEntity = new UrlEncodedFormEntity(params, chatSet);
			httppost.setEntity(uefEntity);
			CloseableHttpResponse response = httpclient.execute(httppost);
			try {
				HttpEntity entity = response.getEntity();
				if (entity != null) {
					return EntityUtils.toString(entity, chatSet);
				}
			} finally {
				response.close();
			}
		} catch (ClientProtocolException e) {
			e.printStackTrace();
		} catch (UnsupportedEncodingException e1) {
			e1.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			// 关闭连接,释放资源
			try {
				httpclient.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return null;
	}
	/**
	 * http post调用方法
	 * @param url
	 * @param xmlData 格式字符串
	 * @return
	 * @throws Exception
	 */
	public String httpPost(String url, String xmlData)throws Exception {
		CloseableHttpClient httpclient = HttpClients.createDefault();
		String strResult="";
		try {
		HttpPost post = new HttpPost(url);
		StringEntity entity = new StringEntity(xmlData);
		post.setEntity(entity);
		post.setHeader("Content-Type", "text/xml;charset=UTF-8");
		HttpResponse response = httpclient.execute(post);
		if(response.getStatusLine().getStatusCode()==200){
			try {
//				读取服务器返回过来的json字符串数据
				strResult = EntityUtils.toString(response.getEntity(),"UTF-8");
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		} catch (ClientProtocolException e) {
			e.printStackTrace();
		} catch (ParseException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			// 关闭连接,释放资源
			try {
				httpclient.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return strResult;
	}
	/**
	 * 发送get请求
	 * @param url 请求地址
	 * @param chatSet 编码格式
	 * @return
	 */
	public static String get(String url, String chatSet) {
		CloseableHttpClient httpclient = HttpClients.createDefault();
		try {
			// 创建httpget.
			HttpGet httpget = new HttpGet(url);
			// 执行get请求.
			CloseableHttpResponse response = httpclient.execute(httpget);
			try {
				// 获取响应实体
				HttpEntity entity = response.getEntity();
				if (entity != null) {
					return EntityUtils.toString(entity, chatSet);
				}
			} finally {
				response.close();
			}
		} catch (ClientProtocolException e) {
			e.printStackTrace();
		} catch (ParseException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			// 关闭连接,释放资源
			try {
				httpclient.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return null;
	}
	/**
	 * http调用方法,(健康之路开放平台)
	 * @param url
	 * @param params
	 * @return
	 * @throws Exception
	 */
	public static String httpPost(String url, Map<String, String> params) throws Exception {
		CloseableHttpClient httpclient = HttpClients.createDefault();
		try {
			HttpPost httpPost = new HttpPost(url);
			if(params!=null&&params.size()>0){
				List<NameValuePair> valuePairs = new ArrayList<NameValuePair>(params.size());
				for (Map.Entry<String, String> entry : params.entrySet()) {
					NameValuePair nameValuePair = new BasicNameValuePair(entry.getKey(), String.valueOf(entry.getValue()));
					valuePairs.add(nameValuePair);
				}
				UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(	valuePairs, "UTF-8");
				httpPost.setEntity(formEntity);
			}
			CloseableHttpResponse resp = httpclient.execute(httpPost);
			try {
				HttpEntity entity = resp.getEntity();
				String respContent = EntityUtils.toString(entity, "UTF-8").trim();
				return respContent;
			} finally {
				resp.close();
			}
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}finally {
			httpclient.close();
		}
	}
	/**
	 * 获取加密后参数集合(健康之路开放平台)
	 * @param params
	 * @return
	 */
	public static Map<String,String> getSecretParams(Map<String, String> params,String appId,String secret)
	{
		String timestamp = Long.toString(System.currentTimeMillis());
		params.put("timestamp", timestamp);
		StringBuilder stringBuilder = new StringBuilder();
		// 对参数名进行字典排序  
		String[] keyArray = params.keySet().toArray(new String[0]);
		Arrays.sort(keyArray);
		// 拼接有序的参数名-值串  
		stringBuilder.append(appId);
		for(String key : keyArray)
		{
			stringBuilder.append(key).append(params.get(key));
		}
		String codes = stringBuilder.append(secret).toString();
		String sign = org.apache.commons.codec.digest.DigestUtils.shaHex(codes).toUpperCase();
		// 添加签名,并发送请求  
		params.put("appId", appId);
		params.put("sign", sign);
		return params;
	}
	public static String postBody(String url,JSONObject params){
		RestTemplate restTemplate = new RestTemplate();
		HttpHeaders headers = new HttpHeaders();
		MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
		headers.setContentType(type);
		headers.add("Accept", MediaType.APPLICATION_JSON.toString());
		org.springframework.http.HttpEntity<String> formEntity = new org.springframework.http.HttpEntity<String>(params.toString(), headers);
		String ret = restTemplate.postForObject(url, formEntity, String.class);
		return ret;
	}
	public static void putBody(String url,JSONObject params){
		RestTemplate restTemplate = new RestTemplate();
		HttpHeaders headers = new HttpHeaders();
		MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
		headers.setContentType(type);
		headers.add("Accept", MediaType.APPLICATION_JSON.toString());
		org.springframework.http.HttpEntity<String> formEntity = new org.springframework.http.HttpEntity<String>(params.toString(), headers);
		restTemplate.put(url, formEntity, String.class);
	}
}

+ 30 - 1
patient-co-figure/src/main/resources/application.yml

@ -1,6 +1,8 @@
server:
  port: 8080
jiwei:
  url:  http://59.61.92.90:8072/wlyy_service
spring:
  datasource:
@ -21,6 +23,20 @@ spring:
    min-evictable-idle-time-millis: 3600000 #连接池中连接,在时间段内一直空闲,被逐出连接池的时间(1000*60*60),以毫秒为单位
    time-between-eviction-runs-millis: 300000 #在空闲连接回收器线程运行期间休眠的时间值,以毫秒为单位,一般比minEvictableIdleTimeMillis小
  redis:
    database: 0 # Database index used by the connection factory.
    password: # Login password of the redis server.
    timeout: 0 # Connection timeout in milliseconds.
        #sentinel:
        #  master: # Name of Redis server.
        #  nodes: # Comma-separated list of host:port pairs.
    pool:
      max-active: 8 # Max number of connections that can be allocated by the pool at a given time. Use a negative value for no limit.
      max-idle: 8 # Max number of "idle" connections in the pool. Use a negative value to indicate an unlimited number of idle connections.
      max-wait: -1 # Maximum amount of time (in milliseconds) a connection allocation should block before throwing an exception when the pool is exhausted. Use a negative value to block indefinitely.
      min-idle: 1 # Target for the minimum number of idle connections to maintain in the pool. This setting only has an effect if it is positive.
#security:
#  basic:
#    username: jkzl
@ -30,6 +46,9 @@ logging:
  level:
    root: INFO
#基卫的地址
---
spring:
  profiles: test
@ -44,6 +63,9 @@ spring:
    username: root
    password: 123456
  redis:
    host: 172.19.103.88
    port: 6379 # Redis server port.
---
@ -53,4 +75,11 @@ spring:
  datasource:
    url: jdbc:mysql://59.61.92.94:3306/wlyy?useUnicode=true&amp;characterEncoding=utf-8&amp;autoReconnect=true
    username: wlyy
    password: jkzlehr@123
    password: jkzlehr@123
  redis:
    host: 120.41.253.95 # Redis server host.
    port: 6380 # Redis server port.
    password: jkzl_ehr