phi_platform_his/pom.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
phi_platform_his/src/main/java/com/hx/phip/his/util/ApiUtil.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
phi_platform_user/pom.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
phi_platform_user/src/main/java/com/hx/phip/config/HisParameter.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
phi_platform_user/src/main/java/com/hx/phip/controller/user/ProjectController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
phi_platform_user/src/main/resources/application-heTest.properties | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
phi_platform_user/src/main/resources/application-local.properties | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
phi_platform_user/src/main/resources/application-prod.properties | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
phi_platform_his/pom.xml
@@ -34,6 +34,12 @@ <version>0.0.1-SNAPSHOT</version> </dependency> <dependency> <groupId>com.hx.gitee</groupId> <artifactId>phi_platform_common</artifactId> <version>1.0-SNAPSHOT</version> </dependency> </dependencies> <build> phi_platform_his/src/main/java/com/hx/phip/his/util/ApiUtil.java
New file @@ -0,0 +1,118 @@ package com.hx.phip.his.util; import com.hx.common.service.CommonService; import com.hx.mybatisTool.SqlSentence; import com.hx.phiappt.model.BaseEntity; import com.hx.phiappt.model.SystemParameter; import com.hx.phip.dao.mapper.SystemParameterMapper; import com.hx.util.HttpMethodUtil; import com.hx.util.StringUtils; import net.sf.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.Calendar; import java.util.Date; import java.util.HashMap; import java.util.Map; /** * 同步接口工具 */ public class ApiUtil { private static Logger logger = LoggerFactory.getLogger(ApiUtil.class); /** * 获取poi token * @param appId * @param code * @param secret */ public static String getToken( String appId, String code, String secret, String url) { JSONObject param = new JSONObject(); param.put("appId", appId); param.put("code", code); param.put("secret", secret); return HttpMethodUtil.HttpURLUtilJson(url,param.toString(),null,null,"POST"); } /** * 获取PoiAPI访问token * @param appId * @param code * @param secret * @param commonService * @return */ public static String getPoiApiAccessToken(String appId, String code, String secret , String url,CommonService commonService) { SqlSentence ss = new SqlSentence(); Map<String, Object> map = new HashMap<String, Object>(); map.put("isDel", BaseEntity.NO); map.put("paramName", SystemParameter.KEY_POIAPI_ACCESS_TOKEN); ss.sqlSentence("SELECT * FROM system_parameter WHERE isDel = #{m.isDel} and paramName = #{m.paramName}",map); SystemParameter sp = commonService.selectOne(SystemParameterMapper.class,ss); int needGetAgain = 1; if(sp != null && !StringUtils.isEmpty(sp.getParamValue1())) { //需要判断一下是否过期 Calendar ca = Calendar.getInstance(); long curTime = ca.getTimeInMillis(); if(curTime < Long.parseLong(sp.getParamValue1())) { needGetAgain = 0; } } if(needGetAgain == 1) { String result = getToken(appId, code, secret, url); if(!StringUtils.isEmpty(result)) { JSONObject reObj = JSONObject.fromObject(result); if(reObj != null) { reObj = reObj.getJSONObject("data"); } if(reObj != null) { String at = reObj.optString("accessToken"); String ea = reObj.optString("expireAt"); if(!StringUtils.isEmpty(at)) { if(sp == null) { sp = new SystemParameter(); } sp.setCreateTime(new Date()); sp.setParamName(SystemParameter.KEY_POIAPI_ACCESS_TOKEN); sp.setParamValue(at); sp.setParamValue1(ea); if(StringUtils.isEmpty(sp.getId())) { commonService.insert(SystemParameterMapper.class,sp); }else{ commonService.updateAll(SystemParameterMapper.class,sp); } }else{ logger.error("获取token,返回没有token:" + reObj.toString()); } }else{ logger.error("获取token,返回没有:" + result); } }else{ logger.error("获取token,返回没有"); } } if(sp != null) { return sp.getParamValue(); } return null; } } phi_platform_user/pom.xml
@@ -164,12 +164,21 @@ <properties> <!--使用${environment}获取值--> <environment>local</environment> <logXml>local</logXml> </properties> </profile> <profile> <id>prod</id> <properties> <environment>prod</environment> <logXml>prod</logXml> </properties> </profile> <profile> <id>heTest</id> <properties> <environment>heTest</environment> <logXml>local</logXml> </properties> </profile> </profiles> @@ -193,7 +202,7 @@ <directory>src/main/resources</directory> <includes> <include>application-${environment}.properties</include> <include>log4j2-${environment}.xml</include> <include>log4j2-${logXml}.xml</include> </includes> </resource> </resources> phi_platform_user/src/main/java/com/hx/phip/config/HisParameter.java
@@ -17,6 +17,11 @@ private String poiSecret; @Value("${systemConfig.code}") private String poiCode; @Value("${his.url.projectItem}") private String projectItem; @Value("${his.url.getToken}") private String urlGetToken; public HisParameter() { @@ -53,4 +58,20 @@ public void setPoiCode(String poiCode) { this.poiCode = poiCode; } public String getProjectItem() { return projectItem; } public void setProjectItem(String projectItem) { this.projectItem = projectItem; } public String getUrlGetToken() { return urlGetToken; } public void setUrlGetToken(String urlGetToken) { this.urlGetToken = urlGetToken; } } phi_platform_user/src/main/java/com/hx/phip/controller/user/ProjectController.java
@@ -6,19 +6,30 @@ import com.hx.common.BaseController; import com.hx.mybatisTool.SqlSentence; import com.hx.phiappt.model.BaseEntity; import com.hx.phiappt.model.User; import com.hx.phip.config.HisParameter; import com.hx.phip.dao.mapper.EmployeeMapper; import com.hx.phip.dao.mapper.UserMapper; import com.hx.phip.entity.employee.EmployeeList; import com.hx.phip.entity.user.UserProjectList; import com.hx.phip.his.entity.ResponsesData; import com.hx.phip.his.tools.UserProjectUtil; import com.hx.phip.his.util.ApiUtil; import com.hx.util.HttpServletRequestUtil; import com.hx.util.StringUtils; import com.platform.exception.PlatTipsException; import com.platform.resultTool.PlatformCode; import com.platform.resultTool.PlatformResult; import net.sf.json.JSONArray; import org.apache.catalina.servlet4preview.http.HttpServletRequest; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -32,6 +43,13 @@ @RestController @RequestMapping("/user/project") public class ProjectController extends BaseController { //log4j日志 private static Logger logger = LoggerFactory.getLogger(ProjectController.class.getName()); @Resource private HisParameter hisParameter; /** * 用户购买项目列表 @@ -56,6 +74,14 @@ throw new PlatTipsException(PlatformCode.ERROR_BODY_DATA,"数据格式错误"); } if(StringUtils.isEmpty(userProjectList.getUserId())){ throw new PlatTipsException(PlatformCode.ERROR_TIPS,"用户标识不能为空!"); } User user = commonService.selectOneByKey(UserMapper.class,userProjectList.getUserId()); if(user == null){ throw new PlatTipsException(PlatformCode.ERROR_TIPS,"用户标识错误!"); } if (userProjectList.getPageNum() == null || userProjectList.getPageNum() <= 0) { userProjectList.setPageNum(1); } @@ -63,16 +89,48 @@ userProjectList.setPageSize(20); } String token = ApiUtil.getPoiApiAccessToken(hisParameter.getPoiAppId(),hisParameter.getPoiCode(),hisParameter.getPoiSecret(),hisParameter.getUrlGetToken(),commonService); ResponsesData responsesData = UserProjectUtil.projectItems(hisParameter.getProjectItem(), user.getApiId(), null, userProjectList.getPageNum(), userProjectList.getPageSize(), "executing", null, token); net.sf.json.JSONObject data = new net.sf.json.JSONObject(); data.put("total", 0); data.put("isLastPage", true); Map<String,Object> data = new HashMap<>(); /*data.put("employeeList",pageInfo.getList()); data.put("total",pageInfo.getTotal()); data.put("pages",pageInfo.getPages()); data.put("pageNum",pageInfo.getPageNum()); data.put("pageSize",pageInfo.getPageSize()); data.put("isLastPage",pageInfo.isIsLastPage());*/ List<Map<String, Object>> projectList = new ArrayList<>(); if ("1000".equals(responsesData.getCode())) { net.sf.json.JSONObject returnData = net.sf.json.JSONObject.fromObject(responsesData.getData()); JSONArray content = returnData.optJSONArray("content"); if (content == null) { content = new JSONArray(); } for (int i = 0; i < content.size(); i++) { net.sf.json.JSONObject contentObj = content.getJSONObject(i); Map<String, Object> projectObj = new HashMap<>(); projectObj.put("buyNum", contentObj.optInt("totalTimes")); projectObj.put("execute", contentObj.optInt("leftTimes")); projectObj.put("projectId", contentObj.optString("id")); net.sf.json.JSONObject itemObj = contentObj.optJSONObject("item"); projectObj.put("name", itemObj.optString("name")); projectObj.put("hisId", itemObj.optString("id")); projectList.add(projectObj); } data.put("total", returnData.optInt("totalElements")); data.put("isLastPage", returnData.optBoolean("last")); } else { logger.error("请求HIS出错(获取订单中的项目条目):" + responsesData.toString()); } data.put("list", projectList); data.put("pageNum", userProjectList.getPageNum()); data.put("pageSize", userProjectList.getPageSize()); return PlatformResult.success(data); } } phi_platform_user/src/main/resources/application-heTest.properties
New file @@ -0,0 +1,115 @@ #\u8BBE\u7F6E\u7AEF\u53E3 server.port=8659 #\u8BBE\u7F6E\u7A7A\u95F4\u540D\u79F0 server.servlet.context-path=/phip logging.config=classpath:log4j2-local.xml #\u8BBE\u7F6E\u6570\u636E\u5E93\u8FDE\u63A5 spring.datasource.url=jdbc:mysql://localhost:3306/phi_guide?useUnicode=true&characterEncoding=UTF-8 spring.datasource.username=root spring.datasource.password=root spring.datasource.driver-class-name=com.mysql.jdbc.Driver #\u8BBE\u7F6E\u76D1\u63A7\u8D26\u53F7 spring.datasource.druid.stat-view-servlet.login-username=admin spring.datasource.druid.stat-view-servlet.login-password=123456 #\u6307\u5B9A\u4E34\u65F6\u6587\u4EF6\u5B58\u653E\u4F4D\u7F6E server.tomcat.basedir = /usr/app/upload #\u6253\u5370 mybatis.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl spring.datasource.type=com.alibaba.druid.pool.DruidDataSource spring.datasource.druid.filters=stat,wall,log4j spring.datasource.druid.initial-size=10 spring.datasource.druid.max-active=50 spring.datasource.druid.min-idle=10 spring.datasource.druid.max-wait=20 spring.datasource.druid.time-between-eviction-runs-millis=60000 spring.datasource.druid.min-evictable-idle-time-millis=300000 spring.datasource.druid.test-on-borrow=true spring.datasource.druid.test-while-idle=false spring.datasource.druid.stat-view-servlet.enabled=true spring.datasource.druid.stat-view-servlet.allow=127.0.0.1 spring.datasource.druid.stat-view-servlet.url-pattern=/druid/* spring.datasource.druid.web-stat-filter.enabled= true spring.datasource.druid.web-stat-filter.url-pattern=/* spring.datasource.druid.web-stat-filter.exclusions='*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*' # mybatis \u6587\u4EF6\u52A0\u8F7D\u8BBE\u7F6E mybatis.type-aliases-package=com.hx.phip.model mybatis.mapperLocations=classpath*:/mapper/*.xml,classpath*:com/gitee/sunchenbin/mybatis/actable/mapping/*/*.xml #mysql\u81EA\u52A8\u5EFA\u8868 mybatis.table.auto=update mybatis.model.pack= com.hx.phip.model mybatis.database.type=mysql #\u8BBE\u7F6E\u65F6\u95F4\u683C\u5F0F spring.jackson.date-format = yyyy-MM-dd HH:mm:ss spring.jackson.time-zone = GMT+8 #\u8BBE\u7F6E\u6587\u4EF6\u5927\u5C0F spring.servlet.multipart.max-file-size=10MB spring.servlet.multipart.max-request-size=10MB #\u8BBE\u7F6E\u5206\u9875 pagehelper.helper-dialect=mysql pagehelper.params=count=countSql pagehelper.reasonable=true pagehelper.support-methods-arguments=true #redis\uFFFD\uFFFD\uFFFD\uFFFD # Redis\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u05B7 spring.redis.host= 101.200.173.220 # Redis\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u04F6\u02FF\uFFFD spring.redis.port=6379 # Redis\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uB8E8\u012C\uFFFD\uFFFD\u03AA\uFFFD\u0563\uFFFD spring.redis.password=cjh8899 # \uFFFD\uFFFD\uFFFD\u04F3\uFFFD\u02B1\u02B1\uFFFD\u48E8\uFFFD\uFFFD\uFFFD\uB8E9 spring.redis.timeout=1000 # set database spring.redis.database= 9 platform.pattern = test systemConfig.baseUrl=https://serv.phiskin.com systemConfig.appid=9d1a7c45-89d6-4241-b84a-32b36edc1283 systemConfig.secret=MDhkYmZiYjctNWU0ZS00YTM3LTgwNGYtYmMzYmRmMWQxZTYx systemConfig.code=phiskin-open #\u83B7\u53D6\u8BA2\u5355\u4E2D\u7684\u9879\u76EE\u6761\u76EE his.url.projectItem = ${systemConfig.baseUrl}/phiskin/v1/billing/execution-item #\u83B7\u53D6token his.url.getToken = ${systemConfig.baseUrl}/public/v1/token #appId rsa.appId = 99sdfa5454a4f5asd4f55saf4 #\u5C0F\u7A0B\u5E8F\u5728\u4F01\u4E1A\u5FAE\u4FE1\u7684\u5E94\u7528\u79D8\u94A5\uFF08HIS\u52A9\u624B\u5C0F\u7A0B\u5E8F\uFF09 rsa.privatekey = MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDNxEbL2XJWJykr6GOtOdkkdauW\ OL3xCw+4WXtvIZQ5ghRxxWm9i5jKHHrZ0gZNxuLpTEvnRIRqaU3ntWenlT7xkgQlgzW01Te7pjdG\ tH+sEY2mMFWnpM/IcrsJI5lBvrkQoSDH/Zu0UZNhDQHRaZ6XrKXGWal68coll8Ul8fJ8HcCpaeqJ\ +Q/W0cAH60WuF3Ly5BcR9eshqK+n8i7ssUU535HSHKCeOJrYSy2fRv1lEOsWDpTTmXfEGbwzHKsB\ 4sScBzuvVXvFECsQVyXGaJzL9MeO2LO4IhYjmQCQBK3bKCph3g1k1NLJ1re0BJBKFBr8g/T6P4Ob\ yoNqmfdgt55FAgMBAAECggEBALDH7Y8bXWj5Mh0gBesApTb2xZlFXKKnvzTB5BNhRQh3YnswgR0w\ vu79supKz9GoirCnNRsXObB2klD9AHXw+mfu7BMSfGTFPqHANwNO9dVuK0VZh22FYmKzd09tvzDF\ 3BeWZySLFWfBIh6iXyp8VJ243Z/gzoPrEaJklyN3j73jArvrLHChL8o4MDbgxgB5Q6Gr9lR70UzQ\ WRssIzyuFN1klOyMOGXr8ioLej1HxYtUbjeJa6lzn1AtoFQmBKxSWvG4uSVz4J/MfthXB1hYLcbI\ vGCpv/k0zq0E09wFuj+v8xOxEMZq93uXqjMerz9torILTLahrRjcfB8J8/Le4uECgYEA9O6nFNtv\ Js4C5wLMZ0nJ4D+0+ATxg1qGLpqPe/xG6cdG61xO6iIRKNL3qn8ZFi4Rim0oCo0jg6FDbAfcEFsa\ NR2eONFQ6COMeYGapjV/HAAicxThUrBpjcpY8VtsnrgthfSiH3vvec544IqUYnkwJVLICP/AYmvH\ qxI4SphOC4kCgYEA1xCPxiWQIf0XYh2Enny/zZDfSnqDjconxijDs0IanFu00xEhccjCYI6edB9w\ KsX1X1dk5Ub+9+7262b4osCKSJxln+GJcYvJDflNOFhsBhBL7gigYCzzLjrfJdSQ1CV0wyLyCzzz\ hkhG/D7V2GSI7PwiIJxrdkV6UoxSgwlDId0CgYBQ3jLgGgs63q3qo+vk9mHm3mHbuZYb7ll7LaDO\ KN8o9JifwNx1RUYxGmaXLluUDSXRdHTR9wOQxD/EfVvVMp8Whm7lB4cU/he1TmtHEUakcg7tvCkg\ 6goPvI1dMvhL9zdgkQKuLndE2jzith6D3Mtep1RQVFCqrjdAbkWTq3GpMQKBgH+UxZXIZs6i86Iy\ 3J+gZbAvByeJsk0E5b96I05OIrcq+ARWHz7+18CsGnfMxp+5O6zJjYMuMMcoLbbMKSdzjRUyIl9M\ Tlrbj/QINrT8T2jxdfnJiEpFoCWGqyYoCZqwdanlKy1bhSPd8K5nIDj0uv3LPPuXj3BkGwKpV7GA\ ZyDJAoGBAJJuG2gOJKOanKnRU190RzMxzunYbgVJN/sUofvGMfyJGg3kYT9X+xm7It4GGGOV6bYU\ 9n3HwKT5RmkboaoMQesefCQ/qz+wgbfoivudzzV3o41HgH3yD5V98g45SmxCgxndxswjR0Yiia5q\ 0dEpK65zWEXTvLLpeyhiXZmtiVCA phi_platform_user/src/main/resources/application-local.properties
@@ -84,6 +84,11 @@ systemConfig.secret=MDhkYmZiYjctNWU0ZS00YTM3LTgwNGYtYmMzYmRmMWQxZTYx systemConfig.code=phiskin-open #\u83B7\u53D6\u8BA2\u5355\u4E2D\u7684\u9879\u76EE\u6761\u76EE his.url.projectItem = ${systemConfig.baseUrl}/phiskin/v1/billing/execution-item #\u83B7\u53D6token his.url.getToken = ${systemConfig.baseUrl}/public/v1/token #appId rsa.appId = 99sdfa5454a4f5asd4f55saf4 #\u5C0F\u7A0B\u5E8F\u5728\u4F01\u4E1A\u5FAE\u4FE1\u7684\u5E94\u7528\u79D8\u94A5\uFF08HIS\u52A9\u624B\u5C0F\u7A0B\u5E8F\uFF09 phi_platform_user/src/main/resources/application-prod.properties
@@ -82,6 +82,11 @@ systemConfig.secret=MDhkYmZiYjctNWU0ZS00YTM3LTgwNGYtYmMzYmRmMWQxZTYx systemConfig.code=phiskin-open #\u83B7\u53D6\u8BA2\u5355\u4E2D\u7684\u9879\u76EE\u6761\u76EE his.url.projectItem = ${systemConfig.baseUrl}/phiskin/v1/billing/execution-item #\u83B7\u53D6token his.url.getToken = ${systemConfig.baseUrl}/public/v1/token #appId rsa.appId = 99sdfa5454a4f5asd4f55saf4 #\u5C0F\u7A0B\u5E8F\u5728\u4F01\u4E1A\u5FAE\u4FE1\u7684\u5E94\u7528\u79D8\u94A5\uFF08HIS\u52A9\u624B\u5C0F\u7A0B\u5E8F\uFF09