diff --git a/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/ISieveApplyOrderHuadaDao.java b/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/ISieveApplyOrderHuadaDao.java new file mode 100644 index 0000000..4e888a9 --- /dev/null +++ b/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/ISieveApplyOrderHuadaDao.java @@ -0,0 +1,34 @@ +package com.lyms.platform.biz.dal; + +import com.lyms.platform.common.dao.operator.MongoQuery; +import com.lyms.platform.pojo.SieveApplyOrderHuadaModel; + +import java.util.List; + +/** + * Created by Administrator on 2016/6/15 0015. + */ +public interface ISieveApplyOrderHuadaDao { + /** + * 增加产前检查信息 + * + * @param obj + * @return + */ + SieveApplyOrderHuadaModel addApplyOrder(SieveApplyOrderHuadaModel obj); + + /** + * 按条件查询转诊信息 + * + * @param mongoQuery + * @return + */ + List queryList(MongoQuery mongoQuery); + + /** + * 修改一条转诊信息 + * + * @param sieveApplyOrderHuadaModel + */ + void updateSieve(SieveApplyOrderHuadaModel sieveApplyOrderHuadaModel); +} diff --git a/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/SieveApplyOrderHuadaDaoImpl.java b/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/SieveApplyOrderHuadaDaoImpl.java new file mode 100644 index 0000000..43365c3 --- /dev/null +++ b/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/SieveApplyOrderHuadaDaoImpl.java @@ -0,0 +1,48 @@ +package com.lyms.platform.biz.dal.impl; + +import com.lyms.platform.biz.dal.ISieveApplyOrderDao; +import com.lyms.platform.biz.dal.ISieveApplyOrderHuadaDao; +import com.lyms.platform.common.dao.BaseMongoDAOImpl; +import com.lyms.platform.common.dao.operator.MongoCondition; +import com.lyms.platform.common.dao.operator.MongoOper; +import com.lyms.platform.common.dao.operator.MongoQuery; +import com.lyms.platform.common.enums.YnEnums; +import com.lyms.platform.pojo.SieveApplyOrderHuadaModel; +import com.lyms.platform.pojo.SieveApplyOrderModel; +import org.springframework.stereotype.Repository; + +import java.util.Date; +import java.util.List; + +/** + * + * 华大基因,产前筛查 + * + * Created by Administrator on 2016/6/15 0015. + */ +@Repository("sieveApplyOrderHuadaDao") +public class SieveApplyOrderHuadaDaoImpl extends BaseMongoDAOImpl implements ISieveApplyOrderHuadaDao { + @Override + public SieveApplyOrderHuadaModel addApplyOrder(SieveApplyOrderHuadaModel obj) { + obj.setStatus(0); + obj.setYn(YnEnums.YES.getId()); + obj.setCreated(new Date()); + obj.setModified(new Date()); + return save(obj); + } + + @Override + public List queryList(MongoQuery mongoQuery) { + return find(mongoQuery.convertToMongoQuery()); + } + + /** + * 修改一条转诊信息 + * + * @param sieveApplyOrderHuadaModel + */ + @Override + public void updateSieve(SieveApplyOrderHuadaModel sieveApplyOrderHuadaModel){ + update(new MongoQuery(new MongoCondition("id", sieveApplyOrderHuadaModel.getId(), MongoOper.IS)).convertToMongoQuery(), sieveApplyOrderHuadaModel); + } +} diff --git a/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/ApplyOrderHuadaService.java b/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/ApplyOrderHuadaService.java new file mode 100644 index 0000000..db6d23a --- /dev/null +++ b/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/ApplyOrderHuadaService.java @@ -0,0 +1,81 @@ +package com.lyms.platform.biz.service; + +import com.lyms.platform.biz.dal.IReferralApplyOrderDao; +import com.lyms.platform.biz.dal.ISieveApplyOrderDao; +import com.lyms.platform.biz.dal.ISieveApplyOrderHuadaDao; +import com.lyms.platform.common.dao.operator.MongoQuery; +import com.lyms.platform.pojo.ReferralApplyOrderModel; +import com.lyms.platform.pojo.SieveApplyOrderHuadaModel; +import com.lyms.platform.pojo.SieveApplyOrderModel; +import com.lyms.platform.query.ReferralApplyOrderQuery; +import com.lyms.platform.query.SieveApplyOrderQuery; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Sort; +import org.springframework.stereotype.Service; + +import java.util.Date; +import java.util.List; + +/** + * 华大基因,申请单service + *

+ * Created by Administrator on 2016/6/15 0015. + */ +@Service +public class ApplyOrderHuadaService { + +// @Autowired +// private IReferralApplyOrderDao iReferralApplyOrderDao; + + @Autowired + private ISieveApplyOrderHuadaDao iSieveApplyOrderHuadaDao; + + + /* public ReferralApplyOrderModel addOneReferralApplyOrder(ReferralApplyOrderModel obj) { + obj.setCreated(new Date()); + obj.setStatus(1); + return iReferralApplyOrderDao.addReferralApplyOrder(obj); + }*/ + + /* public List queryReferralApplyOrderWithQuery(ReferralApplyOrderQuery babyQuery) { + MongoQuery query = babyQuery.convertToQuery(); + if (StringUtils.isNotEmpty(babyQuery.getNeed())) { + babyQuery.mysqlBuild(iReferralApplyOrderDao.count(babyQuery.convertToQuery())); + query.start(babyQuery.getOffset()).end(babyQuery.getLimit()); + } + + return iReferralApplyOrderDao.queryList(query.addOrder(Sort.Direction.DESC, "modified")); +// return iReferralApplyOrderDao.queryList(babyQuery.convertToQuery()); + }*/ + + /* public ReferralApplyOrderModel findByIdReferralApplyOrder(String id) { + return iReferralApplyOrderDao.findOneReferral(id); + }*/ + + public SieveApplyOrderHuadaModel addOneSieveApplyOrder(SieveApplyOrderHuadaModel obj) { + obj.setStatus(0); + return iSieveApplyOrderHuadaDao.addApplyOrder(obj); + } + + public List querySieveApplyOrderWithQuery(SieveApplyOrderQuery sieveApplyOrderQuery) { + return iSieveApplyOrderHuadaDao.queryList(sieveApplyOrderQuery.convertToQuery()); + } + + /** + * 修改一条转诊信息 + * + * @param sieveApplyOrderModel + */ + public void updateSieve(SieveApplyOrderHuadaModel sieveApplyOrderModel) { + iSieveApplyOrderHuadaDao.updateSieve(sieveApplyOrderModel); + } + + /*public int queryCount(ReferralApplyOrderQuery babyQuery){ + return iReferralApplyOrderDao.count(babyQuery.convertToQuery()); + } + + public void updateByParentId(ReferralApplyOrderQuery referralApplyOrderQuery, ReferralApplyOrderModel orderModel) { + iReferralApplyOrderDao.findAndModify(referralApplyOrderQuery.convertToQuery(), orderModel); + }*/ +} diff --git a/platform-common/src/main/java/com/lyms/platform/common/utils/DateUtil.java b/platform-common/src/main/java/com/lyms/platform/common/utils/DateUtil.java index 80828cd..05ba2f1 100644 --- a/platform-common/src/main/java/com/lyms/platform/common/utils/DateUtil.java +++ b/platform-common/src/main/java/com/lyms/platform/common/utils/DateUtil.java @@ -29,7 +29,7 @@ public class DateUtil { public static SimpleDateFormat yyyy_mm = new SimpleDateFormat("yyyy-MM"); - public static SimpleDateFormat y_m_d_h_m = new SimpleDateFormat("yyyyMMddHHmm"); + public static SimpleDateFormat y_m_d_h_m = new SimpleDateFormat("yyyyyMMddHHmm"); public static SimpleDateFormat yyyyMMddHHmmssSSS = new SimpleDateFormat("yyyyMMddHHmmssSSS"); public static final int DAY_SECONDS = 86399; public static final int DAY_FULL_SECONDS = 86400; diff --git a/platform-common/src/main/java/com/lyms/platform/common/utils/HttpClientUtil.java b/platform-common/src/main/java/com/lyms/platform/common/utils/HttpClientUtil.java index f932368..28b2684 100644 --- a/platform-common/src/main/java/com/lyms/platform/common/utils/HttpClientUtil.java +++ b/platform-common/src/main/java/com/lyms/platform/common/utils/HttpClientUtil.java @@ -18,7 +18,10 @@ import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; import org.apache.http.message.BasicNameValuePair; import org.apache.http.util.EntityUtils; +import java.io.BufferedReader; import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; import java.util.*; import java.util.Map.Entry; @@ -50,7 +53,80 @@ public class HttpClientUtil { requestConfig = configBuilder.build(); } - + /** + * 发送POST请求 + * + * @param url 目的地址 + * @param parameters 请求参数,Map类型。 + * @return 远程响应结果 + */ + public static String sendPost(String url, Map parameters) { + String result = "";// 返回的结果 + BufferedReader in = null;// 读取响应输入流 + PrintWriter out = null; + StringBuffer sb = new StringBuffer();// 处理请求参数 + String params = "";// 编码之后的参数 + try { + // 编码请求参数 + if (parameters.size() == 1) { + for (String name : parameters.keySet()) { + sb.append(name).append("=").append( + java.net.URLEncoder.encode(parameters.get(name), + "UTF-8")); + } + params = sb.toString(); + } else { + for (String name : parameters.keySet()) { + sb.append(name).append("=").append( + java.net.URLEncoder.encode(parameters.get(name), + "UTF-8")).append("&"); + } + String temp_params = sb.toString(); + params = temp_params.substring(0, temp_params.length() - 1); + } + // 创建URL对象 + java.net.URL connURL = new java.net.URL(url); + // 打开URL连接 + java.net.HttpURLConnection httpConn = (java.net.HttpURLConnection) connURL + .openConnection(); + // 设置通用属性 + httpConn.setRequestProperty("Accept", "*/*"); + httpConn.setRequestProperty("Connection", "Keep-Alive"); + httpConn.setRequestProperty("User-Agent", + "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)"); + // 设置POST方式 + httpConn.setDoInput(true); + httpConn.setDoOutput(true); + // 获取HttpURLConnection对象对应的输出流 + out = new PrintWriter(httpConn.getOutputStream()); + // 发送请求参数 + out.write(params); + // flush输出流的缓冲 + out.flush(); + // 定义BufferedReader输入流来读取URL的响应,设置编码方式 + in = new BufferedReader(new InputStreamReader(httpConn + .getInputStream(), "UTF-8")); + String line; + // 读取返回的内容 + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + if (out != null) { + out.close(); + } + if (in != null) { + in.close(); + } + } catch (IOException ex) { + ex.printStackTrace(); + } + } + return result; + } public static String doPost(String url,Map map,String charset){ HttpClient httpClient = null; HttpPost httpPost = null; diff --git a/platform-common/src/main/java/com/lyms/platform/common/utils/MD5.java b/platform-common/src/main/java/com/lyms/platform/common/utils/MD5.java new file mode 100644 index 0000000..ce6a8fd --- /dev/null +++ b/platform-common/src/main/java/com/lyms/platform/common/utils/MD5.java @@ -0,0 +1,366 @@ +package com.lyms.platform.common.utils; + +/************************************************* + * md5 类实现了RSA Data Security, Inc.在提交给IETF 的RFC1321中的MD5 message-digest 算法。 + *************************************************/ +public class MD5 { + /* + * 下面这些S11-S44实际上是一个4*4的矩阵,在原始的C实现中是用#define 实现的, 这里把它们实现成为static + * final是表示了只读,切能在同一个进程空间内的多个 Instance间共享 + */ + static final int S11 = 7; + static final int S12 = 12; + static final int S13 = 17; + static final int S14 = 22; + + static final int S21 = 5; + static final int S22 = 9; + static final int S23 = 14; + static final int S24 = 20; + + static final int S31 = 4; + static final int S32 = 11; + static final int S33 = 16; + static final int S34 = 23; + + static final int S41 = 6; + static final int S42 = 10; + static final int S43 = 15; + static final int S44 = 21; + + static final byte[] PADDING = { -128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0 }; + /* + * 下面的三个成员是MD5计算过程中用到的3个核心数据,在原始的C实现中 被定义到MD5_CTX结构中 + * + */ + private long[] state = new long[4]; // state (ABCD) + private long[] count = new long[2]; // number of bits, modulo 2^64 (lsb first) + private byte[] buffer = new byte[64]; // input buffer + + /* + * digestHexStr是MD5的唯一一个公共成员,是最新一次计算结果的 16进制ASCII表示. + */ + public String digestHexStr; + + /* + * digest,是最新一次计算结果的2进制内部表示,表示128bit的MD5值. + */ + private byte[] digest = new byte[16]; + + /* + * getMD5ofStr是类MD5最主要的公共方法,入口参数是你想要进行MD5变换的字符串 + * 返回的是变换完的结果,这个结果是从公共成员digestHexStr取得的. + */ + public String getMD5ofStr(String inbuf) { + try { + md5Init(); + md5Update(inbuf.getBytes("UTF-8"), inbuf.length()); + md5Final(); + digestHexStr = ""; + for (int i = 0; i < 16; i++) { + digestHexStr += byteHEX(digest[i]); + } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + return digestHexStr; + + } + + // 这是MD5这个类的标准构造函数,JavaBean要求有一个public的并且没有参数的构造函数 + public MD5() { + md5Init(); + + return; + } + + /* md5Init是一个初始化函数,初始化核心变量,装入标准的幻数 */ + private void md5Init() { + count[0] = 0L; + count[1] = 0L; + /// * Load magic initialization constants. + + state[0] = 0x67452301L; + state[1] = 0xefcdab89L; + state[2] = 0x98badcfeL; + state[3] = 0x10325476L; + + return; + } + /* + * F, G, H ,I 是4个基本的MD5函数,在原始的MD5的C实现中,由于它们是 + * 简单的位运算,可能出于效率的考虑把它们实现成了宏,在java中,我们把它们 实现成了private方法,名字保持了原来C中的。 + */ + + private long F(long x, long y, long z) { + return (x & y) | ((~x) & z); + + } + + private long G(long x, long y, long z) { + return (x & z) | (y & (~z)); + + } + + private long H(long x, long y, long z) { + return x ^ y ^ z; + } + + private long I(long x, long y, long z) { + return y ^ (x | (~z)); + } + + /* + * FF,GG,HH和II将调用F,G,H,I进行近一步变换 FF, GG, HH, and II transformations for rounds 1, + * 2, 3, and 4. Rotation is separate from addition to prevent recomputation. + */ + + private long FF(long a, long b, long c, long d, long x, long s, long ac) { + a += F(b, c, d) + x + ac; + a = ((int) a << s) | ((int) a >>> (32 - s)); + a += b; + return a; + } + + private long GG(long a, long b, long c, long d, long x, long s, long ac) { + a += G(b, c, d) + x + ac; + a = ((int) a << s) | ((int) a >>> (32 - s)); + a += b; + return a; + } + + private long HH(long a, long b, long c, long d, long x, long s, long ac) { + a += H(b, c, d) + x + ac; + a = ((int) a << s) | ((int) a >>> (32 - s)); + a += b; + return a; + } + + private long II(long a, long b, long c, long d, long x, long s, long ac) { + a += I(b, c, d) + x + ac; + a = ((int) a << s) | ((int) a >>> (32 - s)); + a += b; + return a; + } + + /* + * md5Update是MD5的主计算过程,inbuf是要变换的字节串,inputlen是长度,这个 + * 函数由getMD5ofStr调用,调用之前需要调用md5init,因此把它设计成private的 + */ + private void md5Update(byte[] inbuf, int inputLen) { + + int i, index, partLen; + byte[] block = new byte[64]; + index = (int) (count[0] >>> 3) & 0x3F; + // /* Update number of bits */ + if ((count[0] += (inputLen << 3)) < (inputLen << 3)) + count[1]++; + count[1] += (inputLen >>> 29); + + partLen = 64 - index; + + // Transform as many times as possible. + if (inputLen >= partLen) { + md5Memcpy(buffer, inbuf, index, 0, partLen); + md5Transform(buffer); + + for (i = partLen; i + 63 < inputLen; i += 64) { + + md5Memcpy(block, inbuf, 0, i, 64); + md5Transform(block); + } + index = 0; + + } else + + i = 0; + + /// * Buffer remaining input */ + md5Memcpy(buffer, inbuf, index, i, inputLen - i); + + } + + /* + * md5Final整理和填写输出结果 + */ + private void md5Final() { + byte[] bits = new byte[8]; + int index, padLen; + + /// * Save number of bits */ + Encode(bits, count, 8); + + /// * Pad out to 56 mod 64. + index = (int) (count[0] >>> 3) & 0x3f; + padLen = (index < 56) ? (56 - index) : (120 - index); + md5Update(PADDING, padLen); + + /// * Append length (before padding) */ + md5Update(bits, 8); + + /// * Store state in digest */ + Encode(digest, state, 16); + + } + + /* + * md5Memcpy是一个内部使用的byte数组的块拷贝函数,从input的inpos开始把len长度的 字节拷贝到output的outpos位置开始 + */ + + private void md5Memcpy(byte[] output, byte[] input, int outpos, int inpos, int len) { + int i; + + for (i = 0; i < len; i++) + output[outpos + i] = input[inpos + i]; + } + + /* + * md5Transform是MD5核心变换程序,有md5Update调用,block是分块的原始字节 + */ + private void md5Transform(byte block[]) { + long a = state[0], b = state[1], c = state[2], d = state[3]; + long[] x = new long[16]; + + Decode(x, block, 64); + + /* Round 1 */ + a = FF(a, b, c, d, x[0], S11, 0xd76aa478L); /* 1 */ + d = FF(d, a, b, c, x[1], S12, 0xe8c7b756L); /* 2 */ + c = FF(c, d, a, b, x[2], S13, 0x242070dbL); /* 3 */ + b = FF(b, c, d, a, x[3], S14, 0xc1bdceeeL); /* 4 */ + a = FF(a, b, c, d, x[4], S11, 0xf57c0fafL); /* 5 */ + d = FF(d, a, b, c, x[5], S12, 0x4787c62aL); /* 6 */ + c = FF(c, d, a, b, x[6], S13, 0xa8304613L); /* 7 */ + b = FF(b, c, d, a, x[7], S14, 0xfd469501L); /* 8 */ + a = FF(a, b, c, d, x[8], S11, 0x698098d8L); /* 9 */ + d = FF(d, a, b, c, x[9], S12, 0x8b44f7afL); /* 10 */ + c = FF(c, d, a, b, x[10], S13, 0xffff5bb1L); /* 11 */ + b = FF(b, c, d, a, x[11], S14, 0x895cd7beL); /* 12 */ + a = FF(a, b, c, d, x[12], S11, 0x6b901122L); /* 13 */ + d = FF(d, a, b, c, x[13], S12, 0xfd987193L); /* 14 */ + c = FF(c, d, a, b, x[14], S13, 0xa679438eL); /* 15 */ + b = FF(b, c, d, a, x[15], S14, 0x49b40821L); /* 16 */ + + /* Round 2 */ + a = GG(a, b, c, d, x[1], S21, 0xf61e2562L); /* 17 */ + d = GG(d, a, b, c, x[6], S22, 0xc040b340L); /* 18 */ + c = GG(c, d, a, b, x[11], S23, 0x265e5a51L); /* 19 */ + b = GG(b, c, d, a, x[0], S24, 0xe9b6c7aaL); /* 20 */ + a = GG(a, b, c, d, x[5], S21, 0xd62f105dL); /* 21 */ + d = GG(d, a, b, c, x[10], S22, 0x2441453L); /* 22 */ + c = GG(c, d, a, b, x[15], S23, 0xd8a1e681L); /* 23 */ + b = GG(b, c, d, a, x[4], S24, 0xe7d3fbc8L); /* 24 */ + a = GG(a, b, c, d, x[9], S21, 0x21e1cde6L); /* 25 */ + d = GG(d, a, b, c, x[14], S22, 0xc33707d6L); /* 26 */ + c = GG(c, d, a, b, x[3], S23, 0xf4d50d87L); /* 27 */ + b = GG(b, c, d, a, x[8], S24, 0x455a14edL); /* 28 */ + a = GG(a, b, c, d, x[13], S21, 0xa9e3e905L); /* 29 */ + d = GG(d, a, b, c, x[2], S22, 0xfcefa3f8L); /* 30 */ + c = GG(c, d, a, b, x[7], S23, 0x676f02d9L); /* 31 */ + b = GG(b, c, d, a, x[12], S24, 0x8d2a4c8aL); /* 32 */ + + /* Round 3 */ + a = HH(a, b, c, d, x[5], S31, 0xfffa3942L); /* 33 */ + d = HH(d, a, b, c, x[8], S32, 0x8771f681L); /* 34 */ + c = HH(c, d, a, b, x[11], S33, 0x6d9d6122L); /* 35 */ + b = HH(b, c, d, a, x[14], S34, 0xfde5380cL); /* 36 */ + a = HH(a, b, c, d, x[1], S31, 0xa4beea44L); /* 37 */ + d = HH(d, a, b, c, x[4], S32, 0x4bdecfa9L); /* 38 */ + c = HH(c, d, a, b, x[7], S33, 0xf6bb4b60L); /* 39 */ + b = HH(b, c, d, a, x[10], S34, 0xbebfbc70L); /* 40 */ + a = HH(a, b, c, d, x[13], S31, 0x289b7ec6L); /* 41 */ + d = HH(d, a, b, c, x[0], S32, 0xeaa127faL); /* 42 */ + c = HH(c, d, a, b, x[3], S33, 0xd4ef3085L); /* 43 */ + b = HH(b, c, d, a, x[6], S34, 0x4881d05L); /* 44 */ + a = HH(a, b, c, d, x[9], S31, 0xd9d4d039L); /* 45 */ + d = HH(d, a, b, c, x[12], S32, 0xe6db99e5L); /* 46 */ + c = HH(c, d, a, b, x[15], S33, 0x1fa27cf8L); /* 47 */ + b = HH(b, c, d, a, x[2], S34, 0xc4ac5665L); /* 48 */ + + /* Round 4 */ + a = II(a, b, c, d, x[0], S41, 0xf4292244L); /* 49 */ + d = II(d, a, b, c, x[7], S42, 0x432aff97L); /* 50 */ + c = II(c, d, a, b, x[14], S43, 0xab9423a7L); /* 51 */ + b = II(b, c, d, a, x[5], S44, 0xfc93a039L); /* 52 */ + a = II(a, b, c, d, x[12], S41, 0x655b59c3L); /* 53 */ + d = II(d, a, b, c, x[3], S42, 0x8f0ccc92L); /* 54 */ + c = II(c, d, a, b, x[10], S43, 0xffeff47dL); /* 55 */ + b = II(b, c, d, a, x[1], S44, 0x85845dd1L); /* 56 */ + a = II(a, b, c, d, x[8], S41, 0x6fa87e4fL); /* 57 */ + d = II(d, a, b, c, x[15], S42, 0xfe2ce6e0L); /* 58 */ + c = II(c, d, a, b, x[6], S43, 0xa3014314L); /* 59 */ + b = II(b, c, d, a, x[13], S44, 0x4e0811a1L); /* 60 */ + a = II(a, b, c, d, x[4], S41, 0xf7537e82L); /* 61 */ + d = II(d, a, b, c, x[11], S42, 0xbd3af235L); /* 62 */ + c = II(c, d, a, b, x[2], S43, 0x2ad7d2bbL); /* 63 */ + b = II(b, c, d, a, x[9], S44, 0xeb86d391L); /* 64 */ + + state[0] += a; + state[1] += b; + state[2] += c; + state[3] += d; + + } + + /* + * Encode把long数组按顺序拆成byte数组,因为java的long类型是64bit的, 只拆低32bit,以适应原始C实现的用途 + */ + private void Encode(byte[] output, long[] input, int len) { + int i, j; + + for (i = 0, j = 0; j < len; i++, j += 4) { + output[j] = (byte) (input[i] & 0xffL); + output[j + 1] = (byte) ((input[i] >>> 8) & 0xffL); + output[j + 2] = (byte) ((input[i] >>> 16) & 0xffL); + output[j + 3] = (byte) ((input[i] >>> 24) & 0xffL); + } + } + + /* + * Decode把byte数组按顺序合成成long数组,因为java的long类型是64bit的, + * 只合成低32bit,高32bit清零,以适应原始C实现的用途 + */ + private void Decode(long[] output, byte[] input, int len) { + int i, j; + + for (i = 0, j = 0; j < len; i++, j += 4) + output[i] = b2iu(input[j]) | (b2iu(input[j + 1]) << 8) | (b2iu(input[j + 2]) << 16) + | (b2iu(input[j + 3]) << 24); + + return; + } + + /* + * b2iu是我写的一个把byte按照不考虑正负号的原则的"升位"程序,因为java没有unsigned运算 + */ + public static long b2iu(byte b) { + return b < 0 ? b & 0x7F + 128 : b; + } + + /* + * byteHEX(),用来把一个byte类型的数转换成十六进制的ASCII表示, + * 因为java中的byte的toString无法实现这一点,我们又没有C语言中的 sprintf(outbuf,"%02X",ib) + */ + public static String byteHEX(byte ib) { + char[] Digit = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; + char[] ob = new char[2]; + ob[0] = Digit[(ib >>> 4) & 0X0F]; + ob[1] = Digit[ib & 0X0F]; + String s = new String(ob); + return s; + } + + public static String getMD5(String str) { + MD5 md5 = new MD5(); + return md5.getMD5ofStr(str); + } + + public static void main(String args[]) { + MD5 md5 = new MD5(); // C0F098D04B5662BF202EA6F72D79F3BF + // E99A18C428CB38D5F260853678922E03 + System.out.println(md5.getMD5ofStr("abc123")); + } +} \ No newline at end of file diff --git a/platform-common/src/main/java/com/lyms/platform/common/utils/SignUtil.java b/platform-common/src/main/java/com/lyms/platform/common/utils/SignUtil.java new file mode 100644 index 0000000..e661a1b --- /dev/null +++ b/platform-common/src/main/java/com/lyms/platform/common/utils/SignUtil.java @@ -0,0 +1,88 @@ +package com.lyms.platform.common.utils; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.log4j.Logger; + + +public class SignUtil { + + private static final Logger logger = Logger.getLogger(SignUtil.class); + + private static SimpleDateFormat defaultDateFormat=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + /** + * 获取签名map + * @param syscode 系统编码 + * @param secret 系统秘钥 + * @return + */ + public static Map getSignParams(String syscode,String secret) { + Map signParams=new HashMap<>(); + signParams.put("syscode", syscode); + signParams.put("timestamp", defaultDateFormat.format(new Date())); + String unencryptedStr=getUnencryptedStr(signParams); + String sign=MD5.getMD5(secret+unencryptedStr+secret);//获取数字签名 + signParams.put("sign", sign); + return signParams; + } + + /** + * 校验签名是否正确 + * @param systemConfig + * @param timestamp + * @param sign + * @return + + public static Boolean validateSign(SystemConfig systemConfig,String timestamp,String sign) { + Map signParams=new HashMap<>(); + signParams.put("syscode", systemConfig.getSystemCode()); + signParams.put("timestamp",timestamp); + String unencryptedStr=getUnencryptedStr(signParams); + System.out.println("validateSign--未拼接密码前的字符串是:" + unencryptedStr); + logger.info("validateSign--未拼接密码前的字符串是:" + unencryptedStr); + String encryptedSign=MD5.getMD5(systemConfig.getSecret()+unencryptedStr+systemConfig.getSecret());//获取数字签名 + System.out.println("validateSign--加密后的字符串是:" + encryptedSign); + logger.info("validateSign--加密后的字符串是:" + encryptedSign); + if(encryptedSign.equals(sign)) { + return true; + } + return false; + } */ + /** + * 获取待加密字符串 + * @param signParams + * @return + */ + public static String getUnencryptedStr(Map signParams){ + List paramsList=new ArrayList<>(); + for(String key:signParams.keySet()){ + if("sign".equals(key)){ + continue; + } + String value=(String) signParams.get(key); + paramsList.add(key+value);//将参数转换成key+value格式 + } + Object[] paramsArray=(Object[]) paramsList.toArray(); + Arrays.sort(paramsArray);//ascii码排序 + String unencryptedStr="";//待加密字符串 + for(Object paramStr: paramsArray){ + unencryptedStr+=paramStr; + } + return unencryptedStr; + } + + public static void main(String[] args) { + Map params=new HashMap<>();//参数map + Map signParams=SignUtil.getSignParams("aaa", "bbb"); + params.putAll(signParams);//添加签名参数map + for(String key:signParams.keySet()) { + System.out.println("key=="+key+" value=="+signParams.get(key)); + } + } +} diff --git a/platform-dal/src/main/java/com/lyms/platform/pojo/SieveApplyOrderHuadaModel.java b/platform-dal/src/main/java/com/lyms/platform/pojo/SieveApplyOrderHuadaModel.java new file mode 100644 index 0000000..708b525 --- /dev/null +++ b/platform-dal/src/main/java/com/lyms/platform/pojo/SieveApplyOrderHuadaModel.java @@ -0,0 +1,345 @@ +package com.lyms.platform.pojo; + +import com.lyms.platform.beans.SerialIdEnum; +import com.lyms.platform.common.result.BaseModel; +import org.springframework.data.mongodb.core.mapping.Document; + +import java.util.Date; +import java.util.Map; + +/** + * 华大基因,产筛申请单 + *

+ * Created by Administrator on 2016/6/15 0015. + */ +@Document(collection = "lyms_sieveapplyorder_huada)") +public class SieveApplyOrderHuadaModel extends BaseModel { + + private static final long serialVersionUID = SerialIdEnum.SieveApplyOrderModel.getCid(); + + private String id; + // start 3.0原有的产筛申请字段 + private String parentId;//患者id + private Date created;//创建时间 + private String hospitalId;//医院id + private Integer status;//标识是否同步过数据 0 表示未同步 1表示已同步 + private Date modified;//修改的日期 + private Integer yn;//逻辑删除1正常 0删除 + private String checkDate; + //申请时间 + private Date applyTime; + // end + + + // start 一下字段是华大产筛申请需呀字段 + private String productCode;//产品编号 + private String customerCode;//客户编号 + private String sampleName;//孕妇姓名 + private String sampleNum;//样品编号(如果是正常双胎的情况:样本编号后要加+D;如果是减胎的情况:样本编号后要加+V;如果是重抽血的情况:样本编号后要加+R;) + private String bloodDate;//采样日期 + private String extBaseInfoId;//送检单唯一标识 + private String informedConsent;//是否签署知情同意书,默认02(01-同意捐献、02-不同意捐献、03-未签署知情同意书) + private String informedConsentVersion;//知情同意书版本,默认02(01:华大Logo或华大法人标准版本;02:医院或政府版本) + private String tubeType;//样品管类型 K牌采血管、G牌采血管 + private String gestationalWeeks;//孕周(格式:18w+1)注:“w”必须小写,“+”号后面的天数必须是0~6 + private String zidcardType;//证件类型(01:身份证、02:护照) + private String motherPhoneNum;//孕妇联系电话 + private String chargeType;//收费类型,后台固定传参:3 1:科研收费 2:科研免费 3:临床收费 4:临床免费 + private String isNeedOtherChromReport;//是否需要其他染色体附加正式报告 0-否、1-是 + private String isNeedReportOtherResult;//是否需要报告清单提示其它结果 (0-否、1-是) + private String age;//孕妇年龄 + private String lmp;//末次月经,如果有就诊末次月经,后台使用就诊末次月经 + private String adosculation;//是否是否体外受精-胚胎移植(IVF) 0:是否IVF-否 1:是否IVF-是 + private String allogeneticTransfusion;// 既往史: 一年内异体输血 0:既往史: 一年内异体输血-无 1:既往史: 一年内异体输血-有(不接受) + private String cellularImmunity;//四周内异体细胞免疫 0:四周内异体细胞免疫-无 1:四周内异体细胞免疫-有(不接受) + private String stemCell;//干细胞治疗 0:干细胞治疗-无 1:干细胞治疗-有(不接受) + private String sampleType;//样本类型 默认全血 S051:样本类型-全血 + /* + 0:辅助检查(重要)-正常(单胎活) + 1:辅助检查(重要)-正常(双胎活) + 2:辅助检查(重要)-正常(多胎活) + 3:辅助检查(重要)-异常(单胎) + 4:辅助检查(重要)-异常(双胎) + 5:辅助检查(重要)-异常(多胎) + 6:辅助检查(重要)-减胎 + */ + private String btypeUltrasonic;//辅助检查(B超结果) + /* + 0:筛查模式-未做 + 1:筛查模式-nt筛查 + 2:筛查模式-早孕期筛查 + 3:筛查模式-中孕期筛查 + 4:筛查模式-早中孕期联合筛查 + */ + private String screeningModel;//其他辅助筛查,页面传入什么输入 + // end + + + public Date getApplyTime() { + return applyTime; + } + + public void setApplyTime(Date applyTime) { + this.applyTime = applyTime; + } + + public String getCheckDate() { + return checkDate; + } + + public void setCheckDate(String checkDate) { + this.checkDate = checkDate; + } + + public Integer getYn() { + return yn; + } + + public void setYn(Integer yn) { + this.yn = yn; + } + + public Date getModified() { + return modified; + } + + public void setModified(Date modified) { + this.modified = modified; + } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } + + public Date getCreated() { + return created; + } + + public void setCreated(Date created) { + this.created = created; + } + + public String getHospitalId() { + return hospitalId; + } + + public void setHospitalId(String hospitalId) { + this.hospitalId = hospitalId; + } + + public static long getSerialVersionUID() { + return serialVersionUID; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getParentId() { + return parentId; + } + + public void setParentId(String parentId) { + this.parentId = parentId; + } + + public String getProductCode() { + return productCode; + } + + public void setProductCode(String productCode) { + this.productCode = productCode; + } + + public String getCustomerCode() { + return customerCode; + } + + public void setCustomerCode(String customerCode) { + this.customerCode = customerCode; + } + + public String getSampleName() { + return sampleName; + } + + public void setSampleName(String sampleName) { + this.sampleName = sampleName; + } + + public String getSampleNum() { + return sampleNum; + } + + public void setSampleNum(String sampleNum) { + this.sampleNum = sampleNum; + } + + public String getBloodDate() { + return bloodDate; + } + + public void setBloodDate(String bloodDate) { + this.bloodDate = bloodDate; + } + + public String getExtBaseInfoId() { + return extBaseInfoId; + } + + public void setExtBaseInfoId(String extBaseInfoId) { + this.extBaseInfoId = extBaseInfoId; + } + + public String getInformedConsent() { + return informedConsent; + } + + public void setInformedConsent(String informedConsent) { + this.informedConsent = informedConsent; + } + + public String getInformedConsentVersion() { + return informedConsentVersion; + } + + public void setInformedConsentVersion(String informedConsentVersion) { + this.informedConsentVersion = informedConsentVersion; + } + + public String getTubeType() { + return tubeType; + } + + public void setTubeType(String tubeType) { + this.tubeType = tubeType; + } + + public String getGestationalWeeks() { + return gestationalWeeks; + } + + public void setGestationalWeeks(String gestationalWeeks) { + this.gestationalWeeks = gestationalWeeks; + } + + public String getZidcardType() { + return zidcardType; + } + + public void setZidcardType(String zidcardType) { + this.zidcardType = zidcardType; + } + + public String getMotherPhoneNum() { + return motherPhoneNum; + } + + public void setMotherPhoneNum(String motherPhoneNum) { + this.motherPhoneNum = motherPhoneNum; + } + + public String getChargeType() { + return chargeType; + } + + public void setChargeType(String chargeType) { + this.chargeType = chargeType; + } + + public String getIsNeedOtherChromReport() { + return isNeedOtherChromReport; + } + + public void setIsNeedOtherChromReport(String isNeedOtherChromReport) { + this.isNeedOtherChromReport = isNeedOtherChromReport; + } + + public String getIsNeedReportOtherResult() { + return isNeedReportOtherResult; + } + + public void setIsNeedReportOtherResult(String isNeedReportOtherResult) { + this.isNeedReportOtherResult = isNeedReportOtherResult; + } + + public String getAge() { + return age; + } + + public void setAge(String age) { + this.age = age; + } + + public String getLmp() { + return lmp; + } + + public void setLmp(String lmp) { + this.lmp = lmp; + } + + public String getAdosculation() { + return adosculation; + } + + public void setAdosculation(String adosculation) { + this.adosculation = adosculation; + } + + public String getAllogeneticTransfusion() { + return allogeneticTransfusion; + } + + public void setAllogeneticTransfusion(String allogeneticTransfusion) { + this.allogeneticTransfusion = allogeneticTransfusion; + } + + public String getCellularImmunity() { + return cellularImmunity; + } + + public void setCellularImmunity(String cellularImmunity) { + this.cellularImmunity = cellularImmunity; + } + + public String getStemCell() { + return stemCell; + } + + public void setStemCell(String stemCell) { + this.stemCell = stemCell; + } + + public String getSampleType() { + return sampleType; + } + + public void setSampleType(String sampleType) { + this.sampleType = sampleType; + } + + public String getBtypeUltrasonic() { + return btypeUltrasonic; + } + + public void setBtypeUltrasonic(String btypeUltrasonic) { + this.btypeUltrasonic = btypeUltrasonic; + } + + public String getScreeningModel() { + return screeningModel; + } + + public void setScreeningModel(String screeningModel) { + this.screeningModel = screeningModel; + } +} diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/ApplyOrderController.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/ApplyOrderController.java index a3a6092..00bf547 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/ApplyOrderController.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/ApplyOrderController.java @@ -7,6 +7,7 @@ import com.lyms.platform.common.constants.ErrorCodeConstants; import com.lyms.platform.common.result.BaseResponse; import com.lyms.platform.operate.web.facade.ApplyOrderFacade; import com.lyms.platform.operate.web.request.*; +import net.sf.json.JSONObject; import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; @@ -75,6 +76,23 @@ public class ApplyOrderController extends BaseController { LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); return applyOrderFacade.addOneSieveApplyOrder(applyOrderAddRequest, loginState.getId()); } + + @RequestMapping(method = RequestMethod.POST,value = "/sieveapply_huada") + @ResponseBody + @TokenRequired + //增加产筛申请单_华大基因 + public BaseResponse addSieveApplyOrder_huada(@Valid @RequestBody SieveApplyOrderAddRequestHuada sieveApplyOrderAddRequestHuada,HttpServletRequest request) { + LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); + return applyOrderFacade.addOneSieveApplyOrder_huada(sieveApplyOrderAddRequestHuada, loginState.getId()); + } + + @RequestMapping(method = RequestMethod.POST,value = "/callbackLyms") + @ResponseBody + //华大基因回调接口 + public BaseResponse callbackLyms(@Valid @RequestBody JSONObject jsonObject) { + return applyOrderFacade.callbackLyms(jsonObject); + } + @RequestMapping(method = RequestMethod.GET,value = "/sieveapply") @ResponseBody @TokenRequired diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/ApplyOrderFacade.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/ApplyOrderFacade.java index 9ba06ca..cc9fe62 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/ApplyOrderFacade.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/ApplyOrderFacade.java @@ -1,16 +1,24 @@ package com.lyms.platform.operate.web.facade; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; import com.lyms.platform.biz.service.*; import com.lyms.platform.common.constants.ErrorCodeConstants; import com.lyms.platform.common.enums.*; import com.lyms.platform.common.exception.BusinessException; -import com.lyms.platform.common.result.*; +import com.lyms.platform.common.result.BaseListResponse; +import com.lyms.platform.common.result.BaseObjectResponse; +import com.lyms.platform.common.result.BaseResponse; import com.lyms.platform.common.utils.*; import com.lyms.platform.operate.web.request.*; import com.lyms.platform.operate.web.result.*; import com.lyms.platform.operate.web.utils.CommonsHelper; import com.lyms.platform.operate.web.utils.FunvCommonUtil; -import com.lyms.platform.permission.model.*; +import com.lyms.platform.permission.model.Organization; +import com.lyms.platform.permission.model.OrganizationQuery; +import com.lyms.platform.permission.model.PatientService; +import com.lyms.platform.permission.model.Users; import com.lyms.platform.permission.service.CouponService; import com.lyms.platform.permission.service.OrganizationService; import com.lyms.platform.permission.service.UsersService; @@ -21,10 +29,12 @@ import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.math.NumberUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import org.springframework.web.client.RestTemplate; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.OutputStream; +import java.text.SimpleDateFormat; import java.util.*; /** @@ -35,10 +45,15 @@ import java.util.*; @Component public class ApplyOrderFacade { + public static final String HUADA_URL = PropertiesUtils.getPropertyValue("huada_url"); + public static final String SYSCODE = PropertiesUtils.getPropertyValue("huada_syscode"); + public static final String SECRET = PropertiesUtils.getPropertyValue("huada_secret"); @Autowired private ApplyOrderService applyOrderService; @Autowired + private ApplyOrderHuadaService applyOrderHuadaService; + @Autowired private PatientsService patientsService; @Autowired private AutoMatchFacade autoMatchFacade; @@ -1253,4 +1268,211 @@ public class ApplyOrderFacade { } return ""; } + + public BaseResponse addOneSieveApplyOrder_huada(SieveApplyOrderAddRequestHuada sieveApplyOrderAddRequestHuada, Integer userId) { + SieveApplyOrderHuadaModel sieveApplyOrderHuadaModel = sieveApplyOrderAddRequestHuada.convertToDataModel(); + //修改这块占时不写 + + String hospitalId = autoMatchFacade.getHospitalId(userId); + //表示区域的_暂时不使用(sieveApplyOrderAddRequestHuada, userId, sieveApplyOrderHuadaModel, hospitalId); + + SieveApplyOrderQuery sieveApplyOrderQuery1 = new SieveApplyOrderQuery(); + sieveApplyOrderQuery1.setParentId(sieveApplyOrderAddRequestHuada.getParentId()); + sieveApplyOrderQuery1.setHospitalId(hospitalId); + sieveApplyOrderQuery1.setYn(YnEnums.YES.getId()); + //先查询本院是否已申请 + List list1 = applyOrderHuadaService.querySieveApplyOrderWithQuery(sieveApplyOrderQuery1); + if (CollectionUtils.isEmpty(list1)) { + //增加产筛 + sieveApplyOrderHuadaModel.setCreated(new Date()); + sieveApplyOrderHuadaModel.setHospitalId(hospitalId); + sieveApplyOrderHuadaModel.setInformedConsent("02"); + sieveApplyOrderHuadaModel.setInformedConsentVersion("02"); + sieveApplyOrderHuadaModel.setGestationalWeeks(getWeeks(sieveApplyOrderAddRequestHuada.getGestationalWeeks()));//孕周 + sieveApplyOrderHuadaModel.setChargeType("3"); + Patients patients = patientsService.findOnePatientById(sieveApplyOrderAddRequestHuada.getParentId()); + Date lmp = patients.getFuckLastMens() == null ? patients.getLastMenses() : patients.getFuckLastMens(); + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); + sieveApplyOrderHuadaModel.setLmp(formatter.format(lmp));//末次月经 + sieveApplyOrderHuadaModel.setAge(patients.getAge().toString()); + SieveApplyOrderHuadaModel sieveApplyOrderHuadaModel1 = applyOrderHuadaService.addOneSieveApplyOrder(sieveApplyOrderHuadaModel); + /*优惠卷改为已使用状态,等看看设计这块有没有这块需求 + if (StringUtils.isNotBlank(sieveApplyOrderAddRequestHuada.getCouponCode())) { + couponService.use(hospitalId, sieveApplyOrderAddRequestHuada.getCouponCode(), userId, sieveApplyOrderHuadaModel1.getId()); + }*/ + operateLogFacade.addAddOptLog(userId, Integer.parseInt(hospitalId), sieveApplyOrderHuadaModel, OptActionEnums.ADD.getId(), "增加产筛申请单"); + + //调用华大基因接口 + sieveApplyOrderHuadaModel.setExtBaseInfoId(sieveApplyOrderHuadaModel1.getId()); + boolean b = huadaSaveSampleInfo(sieveApplyOrderHuadaModel); + if(b){ + System.out.println("华大基因5.1.保存送检单成功"); + //华大基因产筛申请,保存成功后在改变产筛状态 + //产前产筛状态,等看看设计这块有没有这块需求 + // updateSieveStatus(sieveApplyOrderAddRequestHuada, userId, sieveApplyOrderHuadaModel, hospitalId); + + }else { + operateLogFacade.addAddOptLog(userId, Integer.parseInt(hospitalId), sieveApplyOrderHuadaModel, OptActionEnums.ADD.getId(), "华大基因5.1.保存送检单失败"); + } + }else { + return new BaseResponse().setErrorcode(ErrorCodeConstants.DATA_EXIST).setErrormsg("已申请过产筛"); + } + return new BaseResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功"); + + } + + private String getWeeks(String str) { + String s1=null; + s1 = str.replace("孕", ""); + s1 = s1.replace("周", "w"); + s1 = s1.replace("天", ""); + return s1; + } + + private void 表示区域的_暂时不使用(SieveApplyOrderAddRequestHuada sieveApplyOrderAddRequestHuada, Integer userId, SieveApplyOrderHuadaModel sieveApplyOrderHuadaModel, String hospitalId) { + if (StringUtils.isNotEmpty(groupsFacade.findByCurrentUserId(hospitalId))) { + String parentId = antenatalExaminationFacade.handHideBuild(sieveApplyOrderAddRequestHuada.getPid(), sieveApplyOrderAddRequestHuada.getParentId(), userId, -1); + if (StringUtils.isEmpty(parentId)) { + throw new BusinessException(); + //打印日志 + } else { + sieveApplyOrderHuadaModel.setParentId(parentId); + sieveApplyOrderAddRequestHuada.setParentId(parentId); + Patients p = patientsService.findOnePatientById(parentId); + //加入产筛 + patientsService.validata(p); + } + } + } + + private void updateSieveStatus(SieveApplyOrderAddRequestHuada sieveApplyOrderAddRequestHuada, Integer userId, SieveApplyOrderHuadaModel sieveApplyOrderHuadaModel, String hospitalId) { + SieveQuery sieveQuery = new SieveQuery(); + sieveQuery.setYn(YnEnums.YES.getId()); + sieveQuery.setParentId(sieveApplyOrderAddRequestHuada.getParentId()); + List sieveModels = sieveService.queryList(sieveQuery); + if (CollectionUtils.isNotEmpty(sieveModels)) + { + SieveModel sieveModel = sieveModels.get(0); + sieveModel.setReviceStatus(1); + sieveModel.setSieveHospitalId(sieveApplyOrderAddRequestHuada.getSieveHospitalId()); + sieveModel.setApplyHospitalId(hospitalId); + sieveModel.setApplyTime(sieveApplyOrderHuadaModel.getApplyTime()); + sieveModel.setStatus(2); + if (StringUtils.isNotEmpty(sieveApplyOrderHuadaModel.getCheckDate())) { + sieveModel.setApplyDate(DateUtil.parseYMD(sieveApplyOrderHuadaModel.getCheckDate())); + } + int days = DateUtil.daysBetween(sieveModel.getLastMenses(), sieveModel.getApplyDate()); + sieveModel.setDueWeek(days); + SieveService.handOrder(sieveModel); + sieveService.updateOneChanQianDiaSieve(sieveModel); + operateLogFacade.addModifyOptLog(userId, Integer.parseInt(hospitalId), sieveModels.get(0), sieveModel, OptActionEnums.UPDATE.getId(), "增加产前筛查"); + } + } + + + public boolean huadaSaveSampleInfo(Object o){ + try { + ArrayList paramsList = new ArrayList(); + AllParamsRequest paramsRequest = new AllParamsRequest(); + paramsRequest.setProductLine("3"); + paramsRequest.setSampleInfo(o); + paramsRequest.setIdentifying(""); + paramsList.add(paramsRequest); + String jsonString = JSON.toJSONString(paramsList.toArray()); + HashMap map = new HashMap<>(); + map.put("params", jsonString); + + Map signParams = getSignParams(SYSCODE, SECRET); + String timestamp = signParams.get("timestamp").toString(); + timestamp = timestamp.replaceAll(" ", "%20");//空格替换成 %20 + String syscode = signParams.get("syscode").toString(); + String sign = signParams.get("sign").toString(); + String s = HttpClientUtil.sendPost(HUADA_URL + "/intf?method=saveSampleInfo&"+ "timestamp=" + timestamp + "&syscode=" + syscode + "&sign=" + sign, map); + JSONObject jsonObject = JSONObject.parseObject(s); + JSONObject rows = JSONObject.parseObject(jsonObject.get("rows").toString()); + JSONArray jsonArray = JSONArray.parseArray(rows.get("successedList").toString()); + if (jsonArray.isEmpty()){ + return false; + } + return true; + } catch (Exception e) { + e.printStackTrace(); + } + return false; + } + + /** + * 获取签名map + * @param syscode 系统编码 + * @param secret 系统秘钥 + * @return + */ + public static Map getSignParams(String syscode,String secret) { + Map signParams=new HashMap<>(); + signParams.put("syscode", syscode); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + signParams.put("timestamp", sdf.format(new Date())); + String unencryptedStr=getUnencryptedStr(signParams); + String sign2=MD5.getMD5(secret+unencryptedStr+secret);//获取数字签名 + System.out.println("sign2 "+sign2); + signParams.put("sign", sign2); + return signParams; + } + /** + * 获取待加密字符串 + * @param signParams + * @return + */ + public static String getUnencryptedStr(Map signParams) { + List paramsList = new ArrayList<>(); + for (String key : signParams.keySet()) { + if ("sign".equals(key)) { + continue; + } + String value = (String) signParams.get(key); + paramsList.add(key + value);//将参数转换成key+value格式 + } + Object[] paramsArray = (Object[]) paramsList.toArray(); + Arrays.sort(paramsArray);//ascii码排序 + String unencryptedStr = "";//待加密字符串 + for (Object paramStr : paramsArray) { + unencryptedStr += paramStr; + } + return unencryptedStr; + } + + public BaseResponse callbackLyms(net.sf.json.JSONObject jsonObject) { + System.out.println(jsonObject); + return null; + } +/*拼json使用*/ + class AllParamsRequest{ + private String productLine; + private String identifying; + private Object sampleInfo; + + public String getIdentifying() { + return identifying; + } + + public void setIdentifying(String identifying) { + this.identifying = identifying; + } + + public String getProductLine() { + return productLine; + } + + public void setProductLine(String productLine) { + this.productLine = productLine; + } + + public Object getSampleInfo() { + return sampleInfo; + } + + public void setSampleInfo(Object sampleInfo) { + this.sampleInfo = sampleInfo; + } + } } \ No newline at end of file diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/SieveApplyOrderAddRequestHuada.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/SieveApplyOrderAddRequestHuada.java new file mode 100644 index 0000000..59d0e2b --- /dev/null +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/SieveApplyOrderAddRequestHuada.java @@ -0,0 +1,375 @@ +package com.lyms.platform.operate.web.request; + +import com.lyms.platform.common.base.IBasicRequestConvert; +import com.lyms.platform.common.core.annotation.form.Form; +import com.lyms.platform.common.core.annotation.form.FormParam; +import com.lyms.platform.common.enums.YnEnums; +import com.lyms.platform.pojo.SieveApplyOrderHuadaModel; + +import java.util.Date; + +/** + * 产筛申请华大基因vo + * + */ +@Form +public class SieveApplyOrderAddRequestHuada implements IBasicRequestConvert{ + + private String pid; + @FormParam + private String parentId; + @FormParam + private String checkDate;//检查时间 + private String sieveHospitalId;//产筛医院 + private String couponCode;//优惠劵码 + private Date created;//创建时间 + private String hospitalId;//医院id + private Integer status;//标识是否同步过数据 0 表示未同步 1表示已同步 + private Date modified;//修改的日期 + private Integer yn;//逻辑删除1正常 0删除 + private Date applyTime;//申请时间 + + private String productCode;//产品编号 + private String customerCode;//客户编号 + private String sampleName;//孕妇姓名 + private String sampleNum;//样品编号(如果是正常双胎的情况:样本编号后要加+D;如果是减胎的情况:样本编号后要加+V;如果是重抽血的情况:样本编号后要加+R;) + private String bloodDate;//采样日期 + private String extBaseInfoId;//送检单唯一标识 + private String informedConsent;//是否签署知情同意书,默认02(01-同意捐献、02-不同意捐献、03-未签署知情同意书) + private String informedConsentVersion;//知情同意书版本,默认02(01:华大Logo或华大法人标准版本;02:医院或政府版本) + private String tubeType;//样品管类型 K牌采血管、G牌采血管 + private String gestationalWeeks;//孕周(格式:18w+1)注:“w”必须小写,“+”号后面的天数必须是0~6 + private String zidcardType;//证件类型(01:身份证、02:护照) + private String motherPhoneNum;//孕妇联系电话 + private String chargeType;//收费类型,后台固定传参:3 1:科研收费 2:科研免费 3:临床收费 4:临床免费 + private String isNeedOtherChromReport;//是否需要其他染色体附加正式报告 0-否、1-是 + private String isNeedReportOtherResult;//是否需要报告清单提示其它结果 (0-否、1-是) + private String age;//孕妇年龄 + private String lmp;//末次月经,如果有就诊末次月经,后台使用就诊末次月经 + private String adosculation;//是否是否体外受精-胚胎移植(IVF) 0:是否IVF-否 1:是否IVF-是 + private String allogeneticTransfusion;// 既往史: 一年内异体输血 0:既往史: 一年内异体输血-无 1:既往史: 一年内异体输血-有(不接受) + private String cellularImmunity;//四周内异体细胞免疫 0:四周内异体细胞免疫-无 1:四周内异体细胞免疫-有(不接受) + private String stemCell;//干细胞治疗 0:干细胞治疗-无 1:干细胞治疗-有(不接受) + private String sampleType; + private String btypeUltrasonic;//辅助检查(B超结果) + private String screeningModel;//其他辅助筛查,页面传入什么输入 + + public String getBtypeUltrasonic() { + return btypeUltrasonic; + } + + public void setBtypeUltrasonic(String btypeUltrasonic) { + this.btypeUltrasonic = btypeUltrasonic; + } + + public String getScreeningModel() { + return screeningModel; + } + + public void setScreeningModel(String screeningModel) { + this.screeningModel = screeningModel; + } + + public Date getCreated() { + return created; + } + + public void setCreated(Date created) { + this.created = created; + } + + public String getHospitalId() { + return hospitalId; + } + + public void setHospitalId(String hospitalId) { + this.hospitalId = hospitalId; + } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } + + public Date getModified() { + return modified; + } + + public void setModified(Date modified) { + this.modified = modified; + } + + public Integer getYn() { + return yn; + } + + public void setYn(Integer yn) { + this.yn = yn; + } + + public Date getApplyTime() { + return applyTime; + } + + public void setApplyTime(Date applyTime) { + this.applyTime = applyTime; + } + + public String getProductCode() { + return productCode; + } + + public void setProductCode(String productCode) { + this.productCode = productCode; + } + + public String getCustomerCode() { + return customerCode; + } + + public void setCustomerCode(String customerCode) { + this.customerCode = customerCode; + } + + public String getSampleName() { + return sampleName; + } + + public void setSampleName(String sampleName) { + this.sampleName = sampleName; + } + + public String getSampleNum() { + return sampleNum; + } + + public void setSampleNum(String sampleNum) { + this.sampleNum = sampleNum; + } + + public String getBloodDate() { + return bloodDate; + } + + public void setBloodDate(String bloodDate) { + this.bloodDate = bloodDate; + } + + public String getExtBaseInfoId() { + return extBaseInfoId; + } + + public void setExtBaseInfoId(String extBaseInfoId) { + this.extBaseInfoId = extBaseInfoId; + } + + public String getInformedConsent() { + return informedConsent; + } + + public void setInformedConsent(String informedConsent) { + this.informedConsent = informedConsent; + } + + public String getInformedConsentVersion() { + return informedConsentVersion; + } + + public void setInformedConsentVersion(String informedConsentVersion) { + this.informedConsentVersion = informedConsentVersion; + } + + public String getTubeType() { + return tubeType; + } + + public void setTubeType(String tubeType) { + this.tubeType = tubeType; + } + + public String getGestationalWeeks() { + return gestationalWeeks; + } + + public void setGestationalWeeks(String gestationalWeeks) { + this.gestationalWeeks = gestationalWeeks; + } + + public String getZidcardType() { + return zidcardType; + } + + public void setZidcardType(String zidcardType) { + this.zidcardType = zidcardType; + } + + public String getMotherPhoneNum() { + return motherPhoneNum; + } + + public void setMotherPhoneNum(String motherPhoneNum) { + this.motherPhoneNum = motherPhoneNum; + } + + public String getChargeType() { + return chargeType; + } + + public void setChargeType(String chargeType) { + this.chargeType = chargeType; + } + + public String getIsNeedOtherChromReport() { + return isNeedOtherChromReport; + } + + public void setIsNeedOtherChromReport(String isNeedOtherChromReport) { + this.isNeedOtherChromReport = isNeedOtherChromReport; + } + + public String getIsNeedReportOtherResult() { + return isNeedReportOtherResult; + } + + public void setIsNeedReportOtherResult(String isNeedReportOtherResult) { + this.isNeedReportOtherResult = isNeedReportOtherResult; + } + + public String getAge() { + return age; + } + + public void setAge(String age) { + this.age = age; + } + + public String getLmp() { + return lmp; + } + + public void setLmp(String lmp) { + this.lmp = lmp; + } + + public String getAdosculation() { + return adosculation; + } + + public void setAdosculation(String adosculation) { + this.adosculation = adosculation; + } + + public String getAllogeneticTransfusion() { + return allogeneticTransfusion; + } + + public void setAllogeneticTransfusion(String allogeneticTransfusion) { + this.allogeneticTransfusion = allogeneticTransfusion; + } + + public String getCellularImmunity() { + return cellularImmunity; + } + + public void setCellularImmunity(String cellularImmunity) { + this.cellularImmunity = cellularImmunity; + } + + public String getStemCell() { + return stemCell; + } + + public void setStemCell(String stemCell) { + this.stemCell = stemCell; + } + + public String getSampleType() { + return sampleType; + } + + public void setSampleType(String sampleType) { + this.sampleType = sampleType; + } + + public String getCheckDate() { + return checkDate; + } + + public void setCheckDate(String checkDate) { + this.checkDate = checkDate; + } + + public String getSieveHospitalId() { + return sieveHospitalId; + } + + public void setSieveHospitalId(String sieveHospitalId) { + this.sieveHospitalId = sieveHospitalId; + } + + public String getCouponCode() { + return couponCode; + } + + public void setCouponCode(String couponCode) { + this.couponCode = couponCode; + } + + public String getPid() { + return pid; + } + + public void setPid(String pid) { + this.pid = pid; + } + + public String getParentId() { + return parentId; + } + + public void setParentId(String parentId) { + this.parentId = parentId; + } + + @Override + public SieveApplyOrderHuadaModel convertToDataModel() { + SieveApplyOrderHuadaModel sieveApplyOrderHuada = new SieveApplyOrderHuadaModel(); + sieveApplyOrderHuada.setParentId(parentId); + sieveApplyOrderHuada.setCreated(created); + sieveApplyOrderHuada.setHospitalId(hospitalId); + sieveApplyOrderHuada.setStatus(status); + sieveApplyOrderHuada.setModified(modified); + sieveApplyOrderHuada.setYn(YnEnums.YES.getId()); + sieveApplyOrderHuada.setCheckDate(checkDate); + sieveApplyOrderHuada.setApplyTime(applyTime); + + sieveApplyOrderHuada.setProductCode(productCode); + sieveApplyOrderHuada.setCustomerCode(customerCode); + sieveApplyOrderHuada.setSampleName(sampleName); + sieveApplyOrderHuada.setSampleNum(sampleNum); + sieveApplyOrderHuada.setBloodDate(bloodDate); + sieveApplyOrderHuada.setExtBaseInfoId(extBaseInfoId); + sieveApplyOrderHuada.setInformedConsent(informedConsent); + sieveApplyOrderHuada.setInformedConsentVersion(informedConsentVersion); + sieveApplyOrderHuada.setTubeType(tubeType); + sieveApplyOrderHuada.setGestationalWeeks(gestationalWeeks); + sieveApplyOrderHuada.setZidcardType(zidcardType); + sieveApplyOrderHuada.setMotherPhoneNum(motherPhoneNum); + sieveApplyOrderHuada.setChargeType(chargeType); + sieveApplyOrderHuada.setIsNeedOtherChromReport(isNeedOtherChromReport); + sieveApplyOrderHuada.setIsNeedReportOtherResult(isNeedReportOtherResult); + sieveApplyOrderHuada.setAge(age); + sieveApplyOrderHuada.setLmp(lmp); + sieveApplyOrderHuada.setAdosculation(adosculation); + sieveApplyOrderHuada.setAllogeneticTransfusion(allogeneticTransfusion); + sieveApplyOrderHuada.setCellularImmunity(cellularImmunity); + sieveApplyOrderHuada.setStemCell(stemCell); + sieveApplyOrderHuada.setSampleType(sampleType); + sieveApplyOrderHuada.setBtypeUltrasonic(btypeUltrasonic); + sieveApplyOrderHuada.setScreeningModel(screeningModel); + return sieveApplyOrderHuada; + } +} diff --git a/platform-operate-api/src/main/resources/config.properties b/platform-operate-api/src/main/resources/config.properties index a3b0882..945f1ef 100644 --- a/platform-operate-api/src/main/resources/config.properties +++ b/platform-operate-api/src/main/resources/config.properties @@ -34,3 +34,9 @@ ams_url=http://ams.api.stage.healthbaby.com.cn #同步数据到v2.0 sync_to_v2_url=http://hengshui.mamibeibi.com:8091 + +#华大基因url 测试 +huada_url=http://119.23.237.220/bisp-all +huada_syscode=bisp-tssfy +huada_secret=tssfy123456 +