Commit d1913b17805b2196b3a6f06258e6762489e535c7
1 parent
ec48b61c22
Exists in
master
and in
6 other branches
华大基因产筛申请冲突修改
Showing 2 changed files with 224 additions and 2 deletions
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/ApplyOrderController.java
View file @
d1913b1
| ... | ... | @@ -73,6 +73,14 @@ |
| 73 | 73 | LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); |
| 74 | 74 | return applyOrderFacade.addOneSieveApplyOrder(applyOrderAddRequest, loginState.getId()); |
| 75 | 75 | } |
| 76 | + @RequestMapping(method = RequestMethod.POST,value = "/sieveapply_huada") | |
| 77 | + @ResponseBody | |
| 78 | + @TokenRequired | |
| 79 | + //增加产筛申请单_华大基因 | |
| 80 | + public BaseResponse addSieveApplyOrder_huada(@Valid @RequestBody SieveApplyOrderAddRequestHuada sieveApplyOrderAddRequestHuada,HttpServletRequest request) { | |
| 81 | + LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); | |
| 82 | + return applyOrderFacade.addOneSieveApplyOrder_huada(sieveApplyOrderAddRequestHuada, loginState.getId()); | |
| 83 | + } | |
| 76 | 84 | |
| 77 | 85 | @RequestMapping(method = RequestMethod.GET, value = "/sieveapply") |
| 78 | 86 | @ResponseBody |
| ... | ... | @@ -91,7 +99,7 @@ |
| 91 | 99 | * @param orderQueryRequest |
| 92 | 100 | * @return |
| 93 | 101 | */ |
| 94 | - @RequestMapping(method = RequestMethod.GET, value = "/applyorder") | |
| 102 | + @RequestMapping(method = RequestMethod.GET, value = "/sieveapply_huada") | |
| 95 | 103 | @ResponseBody |
| 96 | 104 | @TokenRequired |
| 97 | 105 | public BaseResponse queryApplyOrder(@Valid ApplyOrderQueryRequest orderQueryRequest, HttpServletRequest request) { |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/ApplyOrderFacade.java
View file @
d1913b1
| 1 | 1 | package com.lyms.platform.operate.web.facade; |
| 2 | 2 | |
| 3 | +import com.alibaba.fastjson.JSON; | |
| 4 | +import com.alibaba.fastjson.JSONArray; | |
| 5 | +import com.alibaba.fastjson.JSONObject; | |
| 3 | 6 | import com.lyms.platform.biz.service.*; |
| 4 | 7 | import com.lyms.platform.common.constants.ErrorCodeConstants; |
| 5 | 8 | import com.lyms.platform.common.enums.*; |
| ... | ... | @@ -26,6 +29,7 @@ |
| 26 | 29 | import javax.servlet.http.HttpServletResponse; |
| 27 | 30 | import java.io.IOException; |
| 28 | 31 | import java.io.OutputStream; |
| 32 | +import java.text.SimpleDateFormat; | |
| 29 | 33 | import java.util.*; |
| 30 | 34 | |
| 31 | 35 | /** |
| 32 | 36 | |
| 33 | 37 | |
| ... | ... | @@ -35,11 +39,15 @@ |
| 35 | 39 | */ |
| 36 | 40 | @Component |
| 37 | 41 | public class ApplyOrderFacade { |
| 42 | + public static final String HUADA_URL = PropertiesUtils.getPropertyValue("huada_url"); | |
| 43 | + public static final String SYSCODE = PropertiesUtils.getPropertyValue("huada_syscode"); | |
| 44 | + public static final String SECRET = PropertiesUtils.getPropertyValue("huada_secret"); | |
| 38 | 45 | |
| 39 | - | |
| 40 | 46 | @Autowired |
| 41 | 47 | private ApplyOrderService applyOrderService; |
| 42 | 48 | @Autowired |
| 49 | + private ApplyOrderHuadaService applyOrderHuadaService; | |
| 50 | + @Autowired | |
| 43 | 51 | private PatientsService patientsService; |
| 44 | 52 | @Autowired |
| 45 | 53 | private AutoMatchFacade autoMatchFacade; |
| 46 | 54 | |
| ... | ... | @@ -1358,6 +1366,212 @@ |
| 1358 | 1366 | } |
| 1359 | 1367 | return new BaseObjectResponse().setData("").setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功"); |
| 1360 | 1368 | } |
| 1369 | + public BaseResponse addOneSieveApplyOrder_huada(SieveApplyOrderAddRequestHuada sieveApplyOrderAddRequestHuada, Integer userId) { | |
| 1370 | + SieveApplyOrderHuadaModel sieveApplyOrderHuadaModel = sieveApplyOrderAddRequestHuada.convertToDataModel(); | |
| 1371 | + //修改这块占时不写 | |
| 1361 | 1372 | |
| 1373 | + String hospitalId = autoMatchFacade.getHospitalId(userId); | |
| 1374 | + //表示区域的_暂时不使用(sieveApplyOrderAddRequestHuada, userId, sieveApplyOrderHuadaModel, hospitalId); | |
| 1375 | + | |
| 1376 | + SieveApplyOrderQuery sieveApplyOrderQuery1 = new SieveApplyOrderQuery(); | |
| 1377 | + sieveApplyOrderQuery1.setParentId(sieveApplyOrderAddRequestHuada.getParentId()); | |
| 1378 | + sieveApplyOrderQuery1.setHospitalId(hospitalId); | |
| 1379 | + sieveApplyOrderQuery1.setYn(YnEnums.YES.getId()); | |
| 1380 | + //先查询本院是否已申请 | |
| 1381 | + List<SieveApplyOrderHuadaModel> list1 = applyOrderHuadaService.querySieveApplyOrderWithQuery(sieveApplyOrderQuery1); | |
| 1382 | + if (CollectionUtils.isEmpty(list1)) { | |
| 1383 | + //增加产筛 | |
| 1384 | + sieveApplyOrderHuadaModel.setCreated(new Date()); | |
| 1385 | + sieveApplyOrderHuadaModel.setHospitalId(hospitalId); | |
| 1386 | + sieveApplyOrderHuadaModel.setInformedConsent("02"); | |
| 1387 | + sieveApplyOrderHuadaModel.setInformedConsentVersion("02"); | |
| 1388 | + sieveApplyOrderHuadaModel.setGestationalWeeks(getWeeks(sieveApplyOrderAddRequestHuada.getGestationalWeeks()));//孕周 | |
| 1389 | + sieveApplyOrderHuadaModel.setChargeType("3"); | |
| 1390 | + Patients patients = patientsService.findOnePatientById(sieveApplyOrderAddRequestHuada.getParentId()); | |
| 1391 | + Date lmp = patients.getFuckLastMens() == null ? patients.getLastMenses() : patients.getFuckLastMens(); | |
| 1392 | + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); | |
| 1393 | + sieveApplyOrderHuadaModel.setLmp(formatter.format(lmp));//末次月经 | |
| 1394 | + sieveApplyOrderHuadaModel.setAge(patients.getAge().toString()); | |
| 1395 | + SieveApplyOrderHuadaModel sieveApplyOrderHuadaModel1 = applyOrderHuadaService.addOneSieveApplyOrder(sieveApplyOrderHuadaModel); | |
| 1396 | + /*优惠卷改为已使用状态,等看看设计这块有没有这块需求 | |
| 1397 | + if (StringUtils.isNotBlank(sieveApplyOrderAddRequestHuada.getCouponCode())) { | |
| 1398 | + couponService.use(hospitalId, sieveApplyOrderAddRequestHuada.getCouponCode(), userId, sieveApplyOrderHuadaModel1.getId()); | |
| 1399 | + }*/ | |
| 1400 | + operateLogFacade.addAddOptLog(userId, Integer.parseInt(hospitalId), sieveApplyOrderHuadaModel, OptActionEnums.ADD.getId(), "增加产筛申请单"); | |
| 1401 | + | |
| 1402 | + //调用华大基因接口 | |
| 1403 | + sieveApplyOrderHuadaModel.setExtBaseInfoId(sieveApplyOrderHuadaModel1.getId()); | |
| 1404 | + boolean b = huadaSaveSampleInfo(sieveApplyOrderHuadaModel); | |
| 1405 | + if(b){ | |
| 1406 | + System.out.println("华大基因5.1.保存送检单成功"); | |
| 1407 | + //华大基因产筛申请,保存成功后在改变产筛状态 | |
| 1408 | + //产前产筛状态,等看看设计这块有没有这块需求 | |
| 1409 | + // updateSieveStatus(sieveApplyOrderAddRequestHuada, userId, sieveApplyOrderHuadaModel, hospitalId); | |
| 1410 | + | |
| 1411 | + }else { | |
| 1412 | + operateLogFacade.addAddOptLog(userId, Integer.parseInt(hospitalId), sieveApplyOrderHuadaModel, OptActionEnums.ADD.getId(), "华大基因5.1.保存送检单失败"); | |
| 1413 | + } | |
| 1414 | + }else { | |
| 1415 | + return new BaseResponse().setErrorcode(ErrorCodeConstants.DATA_EXIST).setErrormsg("已申请过产筛"); | |
| 1416 | + } | |
| 1417 | + return new BaseResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功"); | |
| 1418 | + | |
| 1419 | + } | |
| 1420 | + | |
| 1421 | + private String getWeeks(String str) { | |
| 1422 | + String s1=null; | |
| 1423 | + s1 = str.replace("孕", ""); | |
| 1424 | + s1 = s1.replace("周", "w"); | |
| 1425 | + s1 = s1.replace("天", ""); | |
| 1426 | + return s1; | |
| 1427 | + } | |
| 1428 | + | |
| 1429 | + private void 表示区域的_暂时不使用(SieveApplyOrderAddRequestHuada sieveApplyOrderAddRequestHuada, Integer userId, SieveApplyOrderHuadaModel sieveApplyOrderHuadaModel, String hospitalId) { | |
| 1430 | + if (StringUtils.isNotEmpty(groupsFacade.findByCurrentUserId(hospitalId))) { | |
| 1431 | + String parentId = antenatalExaminationFacade.handHideBuild(sieveApplyOrderAddRequestHuada.getPid(), sieveApplyOrderAddRequestHuada.getParentId(), userId, -1); | |
| 1432 | + if (StringUtils.isEmpty(parentId)) { | |
| 1433 | + throw new BusinessException(); | |
| 1434 | + //打印日志 | |
| 1435 | + } else { | |
| 1436 | + sieveApplyOrderHuadaModel.setParentId(parentId); | |
| 1437 | + sieveApplyOrderAddRequestHuada.setParentId(parentId); | |
| 1438 | + Patients p = patientsService.findOnePatientById(parentId); | |
| 1439 | + //加入产筛 | |
| 1440 | + patientsService.validata(p); | |
| 1441 | + } | |
| 1442 | + } | |
| 1443 | + } | |
| 1444 | + | |
| 1445 | + private void updateSieveStatus(SieveApplyOrderAddRequestHuada sieveApplyOrderAddRequestHuada, Integer userId, SieveApplyOrderHuadaModel sieveApplyOrderHuadaModel, String hospitalId) { | |
| 1446 | + SieveQuery sieveQuery = new SieveQuery(); | |
| 1447 | + sieveQuery.setYn(YnEnums.YES.getId()); | |
| 1448 | + sieveQuery.setParentId(sieveApplyOrderAddRequestHuada.getParentId()); | |
| 1449 | + List<SieveModel> sieveModels = sieveService.queryList(sieveQuery); | |
| 1450 | + if (CollectionUtils.isNotEmpty(sieveModels)) | |
| 1451 | + { | |
| 1452 | + SieveModel sieveModel = sieveModels.get(0); | |
| 1453 | + sieveModel.setReviceStatus(1); | |
| 1454 | + sieveModel.setSieveHospitalId(sieveApplyOrderAddRequestHuada.getSieveHospitalId()); | |
| 1455 | + sieveModel.setApplyHospitalId(hospitalId); | |
| 1456 | + sieveModel.setApplyTime(sieveApplyOrderHuadaModel.getApplyTime()); | |
| 1457 | + sieveModel.setStatus(2); | |
| 1458 | + if (StringUtils.isNotEmpty(sieveApplyOrderHuadaModel.getCheckDate())) { | |
| 1459 | + sieveModel.setApplyDate(DateUtil.parseYMD(sieveApplyOrderHuadaModel.getCheckDate())); | |
| 1460 | + } | |
| 1461 | + int days = DateUtil.daysBetween(sieveModel.getLastMenses(), sieveModel.getApplyDate()); | |
| 1462 | + sieveModel.setDueWeek(days); | |
| 1463 | + SieveService.handOrder(sieveModel); | |
| 1464 | + sieveService.updateOneChanQianDiaSieve(sieveModel); | |
| 1465 | + operateLogFacade.addModifyOptLog(userId, Integer.parseInt(hospitalId), sieveModels.get(0), sieveModel, OptActionEnums.UPDATE.getId(), "增加产前筛查"); | |
| 1466 | + } | |
| 1467 | + } | |
| 1468 | + | |
| 1469 | + | |
| 1470 | + public boolean huadaSaveSampleInfo(Object o){ | |
| 1471 | + try { | |
| 1472 | + ArrayList<AllParamsRequest> paramsList = new ArrayList(); | |
| 1473 | + AllParamsRequest paramsRequest = new AllParamsRequest(); | |
| 1474 | + paramsRequest.setProductLine("3"); | |
| 1475 | + paramsRequest.setSampleInfo(o); | |
| 1476 | + paramsRequest.setIdentifying(""); | |
| 1477 | + paramsList.add(paramsRequest); | |
| 1478 | + String jsonString = JSON.toJSONString(paramsList.toArray()); | |
| 1479 | + HashMap<String, String> map = new HashMap<>(); | |
| 1480 | + map.put("params", jsonString); | |
| 1481 | + | |
| 1482 | + Map<String, Object> signParams = getSignParams(SYSCODE, SECRET); | |
| 1483 | + String timestamp = signParams.get("timestamp").toString(); | |
| 1484 | + timestamp = timestamp.replaceAll(" ", "%20");//空格替换成 %20 | |
| 1485 | + String syscode = signParams.get("syscode").toString(); | |
| 1486 | + String sign = signParams.get("sign").toString(); | |
| 1487 | + String s = HttpClientUtil.sendPost(HUADA_URL + "/intf?method=saveSampleInfo&"+ "timestamp=" + timestamp + "&syscode=" + syscode + "&sign=" + sign, map); | |
| 1488 | + System.out.println(s); | |
| 1489 | + JSONObject jsonObject = JSONObject.parseObject(s); | |
| 1490 | + JSONObject rows = JSONObject.parseObject(jsonObject.get("rows").toString()); | |
| 1491 | + JSONArray jsonArray = JSONArray.parseArray(rows.get("successedList").toString()); | |
| 1492 | + if (jsonArray.isEmpty()){ | |
| 1493 | + return false; | |
| 1494 | + } | |
| 1495 | + return true; | |
| 1496 | + } catch (Exception e) { | |
| 1497 | + e.printStackTrace(); | |
| 1498 | + } | |
| 1499 | + return false; | |
| 1500 | + } | |
| 1501 | + | |
| 1502 | + /** | |
| 1503 | + * 获取签名map | |
| 1504 | + * @param syscode 系统编码 | |
| 1505 | + * @param secret 系统秘钥 | |
| 1506 | + * @return | |
| 1507 | + */ | |
| 1508 | + public static Map<String, Object> getSignParams(String syscode,String secret) { | |
| 1509 | + Map<String, Object> signParams=new HashMap<>(); | |
| 1510 | + signParams.put("syscode", syscode); | |
| 1511 | + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
| 1512 | + signParams.put("timestamp", sdf.format(new Date())); | |
| 1513 | + String unencryptedStr=getUnencryptedStr(signParams); | |
| 1514 | + String sign2=MD5.getMD5(secret+unencryptedStr+secret);//获取数字签名 | |
| 1515 | + System.out.println("sign2 "+sign2); | |
| 1516 | + signParams.put("sign", sign2); | |
| 1517 | + return signParams; | |
| 1518 | + } | |
| 1519 | + /** | |
| 1520 | + * 获取待加密字符串 | |
| 1521 | + * @param signParams | |
| 1522 | + * @return | |
| 1523 | + */ | |
| 1524 | + public static String getUnencryptedStr(Map<String, Object> signParams) { | |
| 1525 | + List<String> paramsList = new ArrayList<>(); | |
| 1526 | + for (String key : signParams.keySet()) { | |
| 1527 | + if ("sign".equals(key)) { | |
| 1528 | + continue; | |
| 1529 | + } | |
| 1530 | + String value = (String) signParams.get(key); | |
| 1531 | + paramsList.add(key + value);//将参数转换成key+value格式 | |
| 1532 | + } | |
| 1533 | + Object[] paramsArray = (Object[]) paramsList.toArray(); | |
| 1534 | + Arrays.sort(paramsArray);//ascii码排序 | |
| 1535 | + String unencryptedStr = "";//待加密字符串 | |
| 1536 | + for (Object paramStr : paramsArray) { | |
| 1537 | + unencryptedStr += paramStr; | |
| 1538 | + } | |
| 1539 | + return unencryptedStr; | |
| 1540 | + } | |
| 1541 | + | |
| 1542 | + public BaseResponse callbackLyms(net.sf.json.JSONObject jsonObject) { | |
| 1543 | + System.out.println(jsonObject); | |
| 1544 | + return null; | |
| 1545 | + } | |
| 1546 | + /*拼json使用*/ | |
| 1547 | + class AllParamsRequest{ | |
| 1548 | + private String productLine; | |
| 1549 | + private String identifying; | |
| 1550 | + private Object sampleInfo; | |
| 1551 | + | |
| 1552 | + public String getIdentifying() { | |
| 1553 | + return identifying; | |
| 1554 | + } | |
| 1555 | + | |
| 1556 | + public void setIdentifying(String identifying) { | |
| 1557 | + this.identifying = identifying; | |
| 1558 | + } | |
| 1559 | + | |
| 1560 | + public String getProductLine() { | |
| 1561 | + return productLine; | |
| 1562 | + } | |
| 1563 | + | |
| 1564 | + public void setProductLine(String productLine) { | |
| 1565 | + this.productLine = productLine; | |
| 1566 | + } | |
| 1567 | + | |
| 1568 | + public Object getSampleInfo() { | |
| 1569 | + return sampleInfo; | |
| 1570 | + } | |
| 1571 | + | |
| 1572 | + public void setSampleInfo(Object sampleInfo) { | |
| 1573 | + this.sampleInfo = sampleInfo; | |
| 1574 | + } | |
| 1575 | + } | |
| 1362 | 1576 | } |