2026-01-07 10:36:02 +08:00
|
|
|
|
package com.guahao.h5.hsjc.service;
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
|
import cn.hutool.http.HttpUtil;
|
|
|
|
|
|
import cn.hutool.setting.Setting;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
|
import com.guahao.api.task.mapper.AdminSystemMapper;
|
|
|
|
|
|
import com.guahao.api.task.mapper.UserMzjfMapper;
|
|
|
|
|
|
import com.guahao.api.task.model.AdminSystem;
|
|
|
|
|
|
import com.guahao.api.task.model.UserMzjf;
|
|
|
|
|
|
import com.guahao.api.walkinto.model.JhClientInfo;
|
|
|
|
|
|
import com.guahao.common.Exception.LogicException;
|
|
|
|
|
|
import com.guahao.common.util.*;
|
|
|
|
|
|
import com.guahao.h5.hsjc.mapper.PhysicalMapper;
|
|
|
|
|
|
import com.guahao.h5.hsjc.vo.*;
|
|
|
|
|
|
import com.guahao.h5.hsjc.mapper.HsjcMapper;
|
|
|
|
|
|
import com.guahao.h5.reserve.service.Reserve8Service;
|
|
|
|
|
|
import com.guahao.h5.user.mapper.UserCardMapper;
|
|
|
|
|
|
import com.guahao.h5.user.model.UserCardVo;
|
|
|
|
|
|
import com.guahao.h5.user.model.UserVo;
|
|
|
|
|
|
import com.guahao.h5.user.service.UserService;
|
|
|
|
|
|
// sang:注释icbc部分
|
|
|
|
|
|
// import com.icbc.api.utils.IcbcSignature;
|
|
|
|
|
|
// import com.icbc.api.utils.WebUtils;
|
|
|
|
|
|
import com.itextpdf.text.DocumentException;
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
|
import org.apache.commons.net.ftp.FTPClient;
|
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import org.xml.sax.SAXException;
|
|
|
|
|
|
import tk.mybatis.mapper.entity.Example;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
import java.io.*;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
|
import java.net.HttpURLConnection;
|
|
|
|
|
|
import java.net.URL;
|
|
|
|
|
|
import java.text.DecimalFormat;
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
import org.w3c.dom.Document;
|
|
|
|
|
|
import org.w3c.dom.Element;
|
|
|
|
|
|
import org.w3c.dom.NodeList;
|
|
|
|
|
|
import javax.xml.parsers.DocumentBuilder;
|
|
|
|
|
|
import javax.xml.parsers.DocumentBuilderFactory;
|
|
|
|
|
|
import javax.xml.parsers.ParserConfigurationException;
|
|
|
|
|
|
import java.io.StringReader;
|
|
|
|
|
|
|
|
|
|
|
|
import org.xml.sax.InputSource;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
|
public class HsjcService {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// @Autowired
|
|
|
|
|
|
// private JhPayServiceImpl jhPayService;
|
|
|
|
|
|
private Logger log = LoggerFactory.getLogger(HsjcService.class);
|
|
|
|
|
|
|
|
|
|
|
|
//joju微信APPID
|
|
|
|
|
|
//public static final String WX_APP_ID="wx7a0981df44f66897";
|
|
|
|
|
|
|
|
|
|
|
|
public static final String WX_APP_ID = "wx45acd2b4907cb8f4";
|
|
|
|
|
|
|
|
|
|
|
|
//joju微信AppSecret
|
|
|
|
|
|
//public static final String WX_SECRET="4c329fa399103dd27edd84617c620e8e";
|
|
|
|
|
|
public static final String WX_SECRET = "895b90585c4698485c07e113711eac85";
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private UserMzjfMapper userMzjfMapper;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private AdminSystemMapper adminSystemMapper;
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private PhysicalMapper physicalMapper;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private HsjcMapper hsjcMapper;
|
|
|
|
|
|
// @Autowired
|
|
|
|
|
|
// private PayService payService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private Reserve8Service reserve8Service;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private UserService userService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private UserCardMapper userCardMapper;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private TXSendMsg txSendMsg;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private DateUtils dateUtils;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 查询PACS报告单
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
public JSONObject MOP_OutpLisReportQuery(String QueryCode, String StartTime, String EndTime) throws Exception {
|
|
|
|
|
|
JSONObject resSuc = new JSONObject();
|
|
|
|
|
|
|
|
|
|
|
|
String strPdfUrl = "";
|
|
|
|
|
|
StringBuffer str = new StringBuffer();
|
|
|
|
|
|
str.append("<QueryCode>");
|
|
|
|
|
|
str.append(QueryCode);
|
|
|
|
|
|
str.append("</QueryCode>");
|
|
|
|
|
|
str.append("<StartTime>");
|
|
|
|
|
|
str.append(StartTime);
|
|
|
|
|
|
str.append("</StartTime>");
|
|
|
|
|
|
str.append("<EndTime>");
|
|
|
|
|
|
str.append(EndTime);
|
|
|
|
|
|
str.append("</EndTime>");
|
|
|
|
|
|
|
|
|
|
|
|
String reqXml = requestXml("MOP_OutpPacsReptMasterQuery", str.toString());
|
|
|
|
|
|
String respXml = SoapUtil.soapMethod(reqXml);
|
|
|
|
|
|
log.debug("MOP_OutpPacsReptMasterQuery:" + reqXml);
|
|
|
|
|
|
log.debug("MOP_OutpPacsReptMasterQuery:" + respXml);
|
|
|
|
|
|
|
|
|
|
|
|
// 解析报文
|
|
|
|
|
|
List<Map<String, Object>> maplist = XmlUtil.getPacsRes(respXml, "MOP_OutpPacsReptMasterQuery");
|
|
|
|
|
|
|
|
|
|
|
|
if (maplist.get(0).get("returncode").toString().equals("1")) {
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < maplist.size(); i++) {
|
|
|
|
|
|
if (maplist.get(i).get("pdfurl") != null) {
|
|
|
|
|
|
//ftp 文件地址
|
|
|
|
|
|
String pdfname = FileUtil.getName(maplist.get(i).get("pdfurl").toString());
|
|
|
|
|
|
log.debug("pdfname:" + pdfname);
|
|
|
|
|
|
|
|
|
|
|
|
if (!pdfname.equals("")) {
|
|
|
|
|
|
PasDownloadPdf(pdfname);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
JSONArray allrate = JSONArray.parseArray(JSON.toJSONString(maplist));
|
|
|
|
|
|
resSuc.put("response", allrate);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return resSuc;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-14 17:15:54 +08:00
|
|
|
|
public Map<String, Object> opTiQuery(String hospitalZone, String startDate, String endDate,String type) {
|
2026-01-07 10:36:02 +08:00
|
|
|
|
Map<String, Object> result = new HashMap<>();
|
|
|
|
|
|
List<Map<String, Object>> dataList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
StringBuffer str = new StringBuffer();
|
|
|
|
|
|
str.append("<HospitalZone>");
|
|
|
|
|
|
str.append(hospitalZone);
|
|
|
|
|
|
str.append("</HospitalZone>");
|
|
|
|
|
|
str.append("<StartDate>");
|
|
|
|
|
|
str.append(startDate);
|
|
|
|
|
|
str.append("</StartDate>");
|
|
|
|
|
|
str.append("<EndDate>");
|
|
|
|
|
|
str.append(endDate);
|
|
|
|
|
|
str.append("</EndDate>");
|
2026-01-14 17:15:54 +08:00
|
|
|
|
str.append("<class>");
|
|
|
|
|
|
str.append(type);
|
|
|
|
|
|
str.append("</class>");
|
2026-01-07 10:36:02 +08:00
|
|
|
|
|
|
|
|
|
|
String respXml = SoapUtil.soapMethod4(str.toString(),"mop_canreservationphysicalprogram");
|
|
|
|
|
|
// log.debug("【原始SOAP响应】:\n{}", respXml);
|
|
|
|
|
|
|
|
|
|
|
|
// 解析SOAP响应
|
|
|
|
|
|
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
|
|
|
|
|
DocumentBuilder builder = factory.newDocumentBuilder();
|
|
|
|
|
|
|
|
|
|
|
|
// 解析外层SOAP响应
|
|
|
|
|
|
Document soapDoc = builder.parse(new InputSource(new StringReader(respXml)));
|
|
|
|
|
|
NodeList resultNodes = soapDoc.getElementsByTagName("mop_canreservationphysicalprogramResult");
|
|
|
|
|
|
|
|
|
|
|
|
if (resultNodes.getLength() > 0) {
|
|
|
|
|
|
String innerXml = resultNodes.item(0).getTextContent();
|
|
|
|
|
|
|
|
|
|
|
|
// 解析内层XML(CDATA内容)
|
|
|
|
|
|
Document innerDoc = builder.parse(new InputSource(new StringReader(innerXml)));
|
|
|
|
|
|
NodeList responseNodes = innerDoc.getElementsByTagName("response");
|
|
|
|
|
|
|
|
|
|
|
|
if (responseNodes.getLength() > 0) {
|
|
|
|
|
|
Element responseElement = (Element) responseNodes.item(0);
|
|
|
|
|
|
|
|
|
|
|
|
// 检查返回结果
|
|
|
|
|
|
NodeList returnResultNodes = responseElement.getElementsByTagName("returnresult");
|
|
|
|
|
|
if (returnResultNodes.getLength() > 0) {
|
|
|
|
|
|
Element returnResult = (Element) returnResultNodes.item(0);
|
|
|
|
|
|
String returnCode = getElementText(returnResult, "returncode");
|
|
|
|
|
|
String errorMsg = getElementText(returnResult, "errormsg");
|
|
|
|
|
|
|
|
|
|
|
|
result.put("returncode", returnCode);
|
|
|
|
|
|
result.put("errormsg", errorMsg);
|
|
|
|
|
|
|
|
|
|
|
|
// 如果返回成功,解析数据
|
|
|
|
|
|
if ("1".equals(returnCode)) {
|
|
|
|
|
|
NodeList dataRows = responseElement.getElementsByTagName("data_row");
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < dataRows.getLength(); i++) {
|
|
|
|
|
|
Element dataRow = (Element) dataRows.item(i);
|
|
|
|
|
|
Map<String, Object> item = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
|
|
item.put("program_id", getElementText(dataRow, "program_id"));
|
|
|
|
|
|
item.put("program_name", getElementText(dataRow, "program_name"));
|
|
|
|
|
|
item.put("booking_date", getElementText(dataRow, "booking_date"));
|
|
|
|
|
|
item.put("price", getElementText(dataRow, "price"));
|
|
|
|
|
|
item.put("category", getElementText(dataRow, "category"));
|
|
|
|
|
|
item.put("description", getElementText(dataRow, "description"));
|
|
|
|
|
|
|
|
|
|
|
|
dataList.add(item);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
result.put("data", dataList);
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
log.error("解析SOAP响应失败", e);
|
|
|
|
|
|
result.put("returncode", "0");
|
|
|
|
|
|
result.put("errormsg", "解析响应失败: " + e.getMessage());
|
|
|
|
|
|
result.put("data", Collections.emptyList());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private String getElementText(Element parent, String tagName) {
|
|
|
|
|
|
NodeList nodes = parent.getElementsByTagName(tagName);
|
|
|
|
|
|
if (nodes.getLength() > 0) {
|
|
|
|
|
|
return nodes.item(0).getTextContent();
|
|
|
|
|
|
}
|
|
|
|
|
|
return "";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-14 17:15:54 +08:00
|
|
|
|
public Map<String, Object> getDetail(String programId, String bookindDate,String Type) {
|
2026-01-07 10:36:02 +08:00
|
|
|
|
try {
|
|
|
|
|
|
StringBuffer str = new StringBuffer();
|
|
|
|
|
|
str.append("<program_id>");
|
|
|
|
|
|
str.append(programId);
|
|
|
|
|
|
str.append("</program_id>");
|
|
|
|
|
|
str.append("<booking_date>");
|
|
|
|
|
|
str.append(bookindDate);
|
|
|
|
|
|
str.append("</booking_date>");
|
2026-01-14 17:15:54 +08:00
|
|
|
|
str.append("<class>");
|
|
|
|
|
|
str.append(Type);
|
|
|
|
|
|
str.append("</class>");
|
2026-01-07 10:36:02 +08:00
|
|
|
|
|
|
|
|
|
|
String respXml = SoapUtil.soapMethod4(str.toString(),"mop_queryphysicalprogramdetail");
|
|
|
|
|
|
|
|
|
|
|
|
// log.debug("【原始SOAP响应】:\n{}", respXml);
|
|
|
|
|
|
Map<String, Object> map = XmlUtil.parse(respXml);
|
|
|
|
|
|
log.info("map:" + map);
|
|
|
|
|
|
// 解析SOAP响应
|
|
|
|
|
|
return map;
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Map<String, Object> opTjYy(AppointmentSubmitVO vo, Integer userId) {
|
|
|
|
|
|
log.info("收到预约请求: {}", vo);
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
String hisDate = DateUtils.getHisDate();
|
|
|
|
|
|
|
|
|
|
|
|
// 判断当天是否已预约(精确到天)
|
|
|
|
|
|
if (physicalMapper.IsselectByIdCard(vo.getIdCard(), vo.getBookingdate())) {
|
|
|
|
|
|
throw new RuntimeException("该就诊人 [" + vo.getUsername() + "] 已有该天的体检预约,不可重复预约!");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 判断是否有未过期的预约(防止跨天重复)
|
|
|
|
|
|
if (physicalMapper.existsValidAppointmentByIdCard(vo.getIdCard(), hisDate)) {
|
|
|
|
|
|
throw new RuntimeException("该就诊人 [" + vo.getUsername() + "] 已有未过期的预约,不可重复预约!");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 1. 拼接 SOAP 请求(略,保留你原有的 str 拼接逻辑)
|
|
|
|
|
|
|
|
|
|
|
|
StringBuffer str = new StringBuffer();
|
|
|
|
|
|
str.append("<booking_date>").append(vo.getBookingdate()).append("</booking_date>");
|
|
|
|
|
|
str.append("<programs>");
|
|
|
|
|
|
|
|
|
|
|
|
List<ProgramDetailVO> programDetails = vo.getProgramDetails();
|
|
|
|
|
|
StringBuilder programIdsBuilder = new StringBuilder(); // 用于拼接所有 programId
|
|
|
|
|
|
|
|
|
|
|
|
if (programDetails != null && !programDetails.isEmpty()) {
|
|
|
|
|
|
for (int i = 0; i < programDetails.size(); i++) {
|
|
|
|
|
|
ProgramDetailVO detail = programDetails.get(i);
|
|
|
|
|
|
String programId = detail.getProgramId();
|
|
|
|
|
|
|
|
|
|
|
|
// 拼接到 SOAP
|
|
|
|
|
|
str.append("<program>");
|
|
|
|
|
|
str.append("<program_id>").append(programId).append("</program_id>");
|
|
|
|
|
|
str.append("<time_period>").append(detail.getTimePeriod()).append("</time_period>");
|
|
|
|
|
|
str.append("<time>").append(detail.getTime()).append("</time>");
|
2026-01-14 17:15:54 +08:00
|
|
|
|
str.append("<class>").append(detail.getType()).append("</class>");
|
2026-01-07 10:36:02 +08:00
|
|
|
|
str.append("</program>");
|
|
|
|
|
|
|
|
|
|
|
|
// 拼接到本地存储的字符串:101,102,103
|
|
|
|
|
|
if (i > 0) programIdsBuilder.append(",");
|
|
|
|
|
|
programIdsBuilder.append(programId);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
str.append("</programs>");
|
|
|
|
|
|
// 继续拼接其他字段...
|
|
|
|
|
|
str.append("<booking_time>").append(vo.getBookingtime()).append("</booking_time>");
|
|
|
|
|
|
str.append("<name>").append(vo.getUsername()).append("</name>");
|
|
|
|
|
|
str.append("<gender>").append(vo.getGender()).append("</gender>");
|
|
|
|
|
|
str.append("<age>").append(vo.getAge()).append("</age>");
|
|
|
|
|
|
str.append("<phone>").append(vo.getPhone()).append("</phone>");
|
|
|
|
|
|
str.append("<idCard>").append(vo.getIdCard()).append("</idCard>");
|
|
|
|
|
|
str.append("<location>用户住址暂无</location>");
|
|
|
|
|
|
|
|
|
|
|
|
// 调用外部接口
|
|
|
|
|
|
String respXml = SoapUtil.soapMethod4(str.toString(), "mop_bookingphysical");
|
|
|
|
|
|
Map<String, Object> resultMap = XmlUtil.parse(respXml);
|
|
|
|
|
|
log.info("SOAP响应结果: {}", resultMap);
|
|
|
|
|
|
|
|
|
|
|
|
// 2. 获取拼接好的 programIds 字符串
|
|
|
|
|
|
String programIds = programIdsBuilder.toString(); // 如 "101,102,103"
|
|
|
|
|
|
|
|
|
|
|
|
// 3. 插入本地记录(假设 insertInfo 方法已扩展)
|
|
|
|
|
|
physicalMapper.insertInfo(
|
|
|
|
|
|
userId,
|
|
|
|
|
|
vo.getUsername(),
|
|
|
|
|
|
vo.getPhone(),
|
|
|
|
|
|
vo.getIdCard(),
|
|
|
|
|
|
vo.getBookingdate(),
|
|
|
|
|
|
(String) resultMap.get("program_id"), // 主套餐ID
|
|
|
|
|
|
programIds // 新增:子项目ID列表
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
// 4. 发送通知
|
|
|
|
|
|
UserVo userVo = userService.queryUserInfoDetails(userId);
|
|
|
|
|
|
txSendMsg.SendNotifyYY(
|
|
|
|
|
|
"预约体检成功",
|
|
|
|
|
|
userVo.getOpenid(),
|
|
|
|
|
|
vo.getUsername(),
|
|
|
|
|
|
vo.getPhone(),
|
|
|
|
|
|
vo.getBookingdate(),
|
|
|
|
|
|
"武警宁夏总队医院",
|
|
|
|
|
|
resultMap.get("program_id"),
|
|
|
|
|
|
"KASRtwl48DvmJS5It4y6dlzfDLOdX9rV8MRCkRMz6bQ"
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
return resultMap;
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
log.error("预约失败", e);
|
|
|
|
|
|
throw new RuntimeException("预约失败:" + e.getMessage(), e);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public String GetPdfReportsAddress(String patientsID, String studiesDateTime, String requestElectronic, String accessionNumber, String studiesModalities, String admissionSource) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
String requestXml = XmlUtil.getPdfReports(patientsID, studiesDateTime, requestElectronic, accessionNumber, studiesModalities, admissionSource);
|
|
|
|
|
|
log.info("PACS请求XML: {}", requestXml);
|
|
|
|
|
|
String responseXml = SoapUtil.soapMethod3(requestXml);
|
|
|
|
|
|
return responseXml;
|
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 从外部URL下载PDF文件到本地,并返回前端可访问的路径(按HIS系统时间创建多级目录)
|
|
|
|
|
|
* @param reportPdfFilePath 外部PDF文件URL(如:http://192.168.12.23:8080/PacsReportPDF/20250908000011.pdf)
|
|
|
|
|
|
* @return 转换后的Web路径(如:/LISPDF/2025/09/08/20250908000011.pdf)
|
|
|
|
|
|
*/
|
|
|
|
|
|
public String getPacsPdf(String reportPdfFilePath) {
|
|
|
|
|
|
// 1. 验证输入
|
|
|
|
|
|
if (StrUtil.isBlank(reportPdfFilePath)) {
|
|
|
|
|
|
throw new IllegalArgumentException("PDF文件路径不能为空");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
// 2. 解析原始URL
|
|
|
|
|
|
URL url = new URL(reportPdfFilePath);
|
|
|
|
|
|
String path = url.getPath();
|
|
|
|
|
|
|
|
|
|
|
|
// 3. 提取文件名(处理URL编码)
|
|
|
|
|
|
// 3. 手动提取文件名(无工具类)
|
|
|
|
|
|
String fileName;
|
|
|
|
|
|
int lastSlashIndex = path.lastIndexOf('/');
|
|
|
|
|
|
if (lastSlashIndex == -1) {
|
|
|
|
|
|
fileName = path; // 无斜杠路径(如根路径)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
fileName = path.substring(lastSlashIndex + 1);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 4. 移除查询参数(如 ?token=abc)
|
|
|
|
|
|
int queryIndex = fileName.indexOf('?');
|
|
|
|
|
|
if (queryIndex != -1) {
|
|
|
|
|
|
fileName = fileName.substring(0, queryIndex);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 5. 验证文件名
|
|
|
|
|
|
if (fileName == null || fileName.isEmpty()) {
|
|
|
|
|
|
throw new IllegalArgumentException("无法从URL提取文件名: " + reportPdfFilePath);
|
|
|
|
|
|
}
|
|
|
|
|
|
// 4. 获取HIS系统时间(格式:yyyy-MM-dd)
|
|
|
|
|
|
String hisDate = DateUtils.getHisDate();
|
|
|
|
|
|
if (StrUtil.isBlank(hisDate)) {
|
|
|
|
|
|
// 如果HIS时间获取失败,使用系统时间(东八区)
|
|
|
|
|
|
hisDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
|
|
|
|
|
|
log.warn("HIS时间获取失败,使用系统时间: {}", hisDate);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 5. 从HIS日期提取年月日(确保格式为YYYY-MM-DD)
|
|
|
|
|
|
String[] dateParts = hisDate.split("-");
|
|
|
|
|
|
if (dateParts.length != 3) {
|
|
|
|
|
|
throw new IllegalArgumentException("HIS日期格式错误: " + hisDate);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
String year = dateParts[0];
|
|
|
|
|
|
String month = String.format("%02d", Integer.parseInt(dateParts[1])); // 确保两位月份
|
|
|
|
|
|
String day = String.format("%02d", Integer.parseInt(dateParts[2])); // 确保两位日期
|
|
|
|
|
|
|
|
|
|
|
|
// 6. 构建本地目录路径(年月日)
|
|
|
|
|
|
String localDir = "/home/igzh/nxwj-gzhsvr/LISPDF/PACS" + File.separator + year + month + day;
|
|
|
|
|
|
File localDirFile = new File(localDir);
|
|
|
|
|
|
|
|
|
|
|
|
// 7. 确保本地目录存在(递归创建)
|
|
|
|
|
|
if (!localDirFile.exists()) {
|
|
|
|
|
|
if (!localDirFile.mkdirs()) {
|
|
|
|
|
|
throw new RuntimeException("无法创建目录: " + localDir);
|
|
|
|
|
|
}
|
|
|
|
|
|
log.info("创建目录成功: {}", localDir);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 8. 构建本地文件路径
|
|
|
|
|
|
String localFilePath = localDir + File.separator + fileName;
|
|
|
|
|
|
File localFile = new File(localFilePath);
|
|
|
|
|
|
// 仅改动这里:先检查文件是否存在,存在则直接返回路径
|
|
|
|
|
|
if (localFile.exists()) {
|
|
|
|
|
|
log.info("文件已存在,跳过下载: {}", localFilePath);
|
|
|
|
|
|
// 直接返回路径,不进行下载
|
|
|
|
|
|
String webPath = "/LISPDF/PACS/" + year + month + day + "/" + fileName;
|
|
|
|
|
|
log.info("返回Web路径: {}", webPath);
|
|
|
|
|
|
return webPath;
|
|
|
|
|
|
}
|
|
|
|
|
|
int maxRetries = 3;
|
|
|
|
|
|
for (int attempt = 1; attempt <= maxRetries; attempt++) {
|
|
|
|
|
|
// 9. 文件不存在才下载(保持原样)
|
|
|
|
|
|
log.info("开始下载PDF文件(第{}次尝试): {} -> {}", attempt, reportPdfFilePath, localFilePath);
|
|
|
|
|
|
HttpUtil.downloadFile(reportPdfFilePath, localFile);
|
|
|
|
|
|
if (localFile.exists()) {
|
|
|
|
|
|
log.info("PDF文件下载成功: {}", localFilePath);
|
|
|
|
|
|
break;
|
|
|
|
|
|
} else if (attempt == maxRetries) {
|
|
|
|
|
|
throw new RuntimeException("文件下载失败: " + reportPdfFilePath);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 11. 返回Web路径(保持原样)
|
|
|
|
|
|
String webPath = "/LISPDF/PACS/" + year + month + day + "/" + fileName;
|
|
|
|
|
|
log.info("返回Web路径: {}", webPath);
|
|
|
|
|
|
return webPath;
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
log.error("处理PDF文件失败: {}", reportPdfFilePath, e);
|
|
|
|
|
|
throw new RuntimeException("PDF处理失败: " + e.getMessage(), e);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static class ReportVo {
|
|
|
|
|
|
private String ReportName;
|
|
|
|
|
|
private String ReportId;
|
|
|
|
|
|
private String ReportPdfFilePath;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public String toString() {
|
|
|
|
|
|
return "ReportVo{" +
|
|
|
|
|
|
"ReportName='" + ReportName + '\'' +
|
|
|
|
|
|
", ReportId='" + ReportId + '\'' +
|
|
|
|
|
|
", ReportPdfFilePath='" + ReportPdfFilePath + '\'' +
|
|
|
|
|
|
'}';
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public ReportVo() {
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public ReportVo(String reportName, String reportId, String reportPdfFilePath) {
|
|
|
|
|
|
ReportName = reportName;
|
|
|
|
|
|
ReportId = reportId;
|
|
|
|
|
|
ReportPdfFilePath = reportPdfFilePath;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public String getReportName() {
|
|
|
|
|
|
return ReportName;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void setReportName(String reportName) {
|
|
|
|
|
|
ReportName = reportName;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public String getReportId() {
|
|
|
|
|
|
return ReportId;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void setReportId(String reportId) {
|
|
|
|
|
|
ReportId = reportId;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public String getReportPdfFilePath() {
|
|
|
|
|
|
return ReportPdfFilePath;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void setReportPdfFilePath(String reportPdfFilePath) {
|
|
|
|
|
|
ReportPdfFilePath = reportPdfFilePath;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 查询PACS报告单
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
public JSONObject MOP_OutpPacsReptMasterQuery(String QueryCode, Integer QueryType, String StartTime, String EndTime) throws Exception {
|
|
|
|
|
|
JSONObject resSuc = null;
|
|
|
|
|
|
// log.info("查询PACS报告单");
|
|
|
|
|
|
if (QueryType == 1){
|
|
|
|
|
|
resSuc = pacsQuery1(QueryCode, QueryType, StartTime, EndTime);
|
|
|
|
|
|
}else {
|
|
|
|
|
|
resSuc = pacsQuery2(QueryCode, QueryType, StartTime, EndTime);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return resSuc;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private JSONObject pacsQuery2(String queryCode, Integer queryType, String startTime, String endTime) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
PacsVo pacsVo = new PacsVo();
|
|
|
|
|
|
pacsVo.setPatientsID(queryCode);
|
|
|
|
|
|
String studyTime = DateUtils.formatRange(startTime, endTime);
|
|
|
|
|
|
pacsVo.setStudiesDateTime(studyTime);
|
|
|
|
|
|
|
|
|
|
|
|
log.info("PACS查询参数:病人ID={}, 时间范围={}", pacsVo.getPatientsID(), studyTime);
|
|
|
|
|
|
|
|
|
|
|
|
String requestXml = XmlUtil.getPacsQuery(pacsVo);
|
|
|
|
|
|
log.info("PACS请求XML: {}", requestXml);
|
|
|
|
|
|
|
|
|
|
|
|
String responseXml = SoapUtil.soapMethod3(requestXml);
|
|
|
|
|
|
// log.info("PACS响应XML: {}", responseXml);
|
|
|
|
|
|
JSONObject result = SoapPacsXmlParser.parseSoapResponseToJson(responseXml);
|
|
|
|
|
|
log.info("pacs解析出来的内容:{}", result.toJSONString());
|
|
|
|
|
|
return result;
|
|
|
|
|
|
// 解析响应(使用优化后的工具类)
|
|
|
|
|
|
// Map<String, Object> resultMap = XmlParserUtils.parseSoapXml(responseXml);
|
|
|
|
|
|
//
|
|
|
|
|
|
// if (resultMap == null) {
|
|
|
|
|
|
// log.warn("PACS XML解析结果为空,返回默认空JSON");
|
|
|
|
|
|
// return new JSONObject();
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// 安全转换为JSONObject(过滤null值)
|
|
|
|
|
|
// JSONObject jsonObject = new JSONObject();
|
|
|
|
|
|
// jsonObject.put("result",responseXml);
|
|
|
|
|
|
// for (Map.Entry<String, Object> entry : resultMap.entrySet()) {
|
|
|
|
|
|
// if (entry.getValue() != null) {
|
|
|
|
|
|
// jsonObject.put(entry.getKey(), entry.getValue());
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// return jsonObject;
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
log.error("PACS查询异常", e);
|
|
|
|
|
|
throw new RuntimeException("PACS查询失败", e);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public JSONObject pacsQuery1(String QueryCode, Integer QueryType, String StartTime, String EndTime) throws Exception{
|
|
|
|
|
|
JSONObject resSuc = new JSONObject();
|
|
|
|
|
|
// StringBuffer str = new StringBuffer();
|
|
|
|
|
|
String url = "http://localhost:8089/nxpdf/api/reports/search"; // 可配置为 wxPayConfig 属性
|
|
|
|
|
|
|
|
|
|
|
|
JSONObject objParams = new JSONObject();
|
|
|
|
|
|
objParams.put("patientId", QueryCode);
|
|
|
|
|
|
objParams.put("startDate", StartTime);
|
|
|
|
|
|
objParams.put("endDate", EndTime);
|
|
|
|
|
|
|
|
|
|
|
|
HttpURLConnection connection = null;
|
|
|
|
|
|
BufferedReader reader = null;
|
|
|
|
|
|
try {
|
|
|
|
|
|
// 1. 创建 URL 对象
|
|
|
|
|
|
URL requestUrl = new URL(url);
|
|
|
|
|
|
connection = (HttpURLConnection) requestUrl.openConnection();
|
|
|
|
|
|
|
|
|
|
|
|
// 2. 设置请求方式和参数
|
|
|
|
|
|
connection.setRequestMethod("POST");
|
|
|
|
|
|
connection.setRequestProperty("Content-Type", "application/json;charset=utf-8");
|
|
|
|
|
|
connection.setRequestProperty("Accept", "application/json");
|
|
|
|
|
|
connection.setDoOutput(true); // 允许写入请求体
|
|
|
|
|
|
connection.setDoInput(true); // 允许读取响应
|
|
|
|
|
|
connection.setConnectTimeout(10000);
|
|
|
|
|
|
connection.setReadTimeout(30000);
|
|
|
|
|
|
|
|
|
|
|
|
// 3. 写入请求体
|
|
|
|
|
|
try (OutputStream os = connection.getOutputStream()) {
|
|
|
|
|
|
byte[] input = objParams.toJSONString().getBytes("utf-8");
|
|
|
|
|
|
os.write(input, 0, input.length);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 4. 获取响应码
|
|
|
|
|
|
int code = connection.getResponseCode();
|
|
|
|
|
|
log.info("code:" + code);
|
|
|
|
|
|
|
|
|
|
|
|
if (code == 200) {
|
|
|
|
|
|
// 5. 读取响应内容
|
|
|
|
|
|
StringBuilder response = new StringBuilder();
|
|
|
|
|
|
try (InputStream is = connection.getInputStream();
|
|
|
|
|
|
BufferedReader br = new BufferedReader(new InputStreamReader(is, "UTF-8"))) {
|
|
|
|
|
|
String line;
|
|
|
|
|
|
while ((line = br.readLine()) != null) {
|
|
|
|
|
|
response.append(line);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
String a = response.toString();
|
|
|
|
|
|
log.info("a:" + a);
|
|
|
|
|
|
|
|
|
|
|
|
JSONObject jsonObject = JSON.parseObject(a);
|
|
|
|
|
|
log.info("jsonObject:" + jsonObject.toString());
|
|
|
|
|
|
String success = (String) jsonObject.get("success");
|
|
|
|
|
|
|
|
|
|
|
|
log.info("查询报告接口响应结果:" + success);
|
|
|
|
|
|
if (!StringUtils.isEmpty(success)) {//响应成功
|
|
|
|
|
|
String reportIdList = JSON.toJSONString(jsonObject.get("ReportIdList"));
|
|
|
|
|
|
log.info("reportIdList:" + reportIdList);
|
|
|
|
|
|
log.info("响应成功");
|
|
|
|
|
|
List<ReportVo> reportVos = JSONObject.parseArray(reportIdList, ReportVo.class);
|
|
|
|
|
|
log.info("reportVos:" + reportVos + ",size:" + reportVos.size());
|
|
|
|
|
|
|
|
|
|
|
|
List<ReportVo> resultList = new ArrayList<>();
|
|
|
|
|
|
if (reportVos.size() != 0) {
|
|
|
|
|
|
for (ReportVo re : reportVos) {
|
|
|
|
|
|
// log.info("re:" + re);
|
|
|
|
|
|
String pdfUrl = re.getReportPdfFilePath();
|
|
|
|
|
|
// log.debug("pdf url:" + pdfUrl);
|
|
|
|
|
|
|
|
|
|
|
|
// 转换为Web可访问路径
|
|
|
|
|
|
if (pdfUrl != null && !pdfUrl.isEmpty()) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
URL newurl = new URL(pdfUrl);
|
|
|
|
|
|
String path = newurl.getPath(); // 获取 /20250901/20250901-3-29.pdf
|
|
|
|
|
|
String newPath = "/LISPDF" + path; // 转换为 /LISPDF/20250901/20250901-3-29.pdf
|
|
|
|
|
|
re.setReportPdfFilePath(newPath);
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
log.error("URL解析失败: " + pdfUrl, e);
|
|
|
|
|
|
re.setReportPdfFilePath(pdfUrl); // 保持原URL
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
resultList.add(re);
|
|
|
|
|
|
|
|
|
|
|
|
// 下载文件到本地(可选)
|
|
|
|
|
|
if (pdfUrl != null && !pdfUrl.isEmpty()) {
|
|
|
|
|
|
// 检查本地文件是否存在
|
|
|
|
|
|
try {
|
|
|
|
|
|
URL newurl = new URL(pdfUrl);
|
|
|
|
|
|
String path = newurl.getPath();
|
|
|
|
|
|
String[] pathParts = path.split("/");
|
|
|
|
|
|
if (pathParts.length >= 3) {
|
|
|
|
|
|
String downUrl = pathParts[1]; // 20250901
|
|
|
|
|
|
String newFileName = pathParts[2]; // 20250901-3-29.pdf
|
|
|
|
|
|
File file = new File("/home/igzh/nxwj-gzhsvr/LISPDF/" + downUrl + "/" + newFileName);
|
|
|
|
|
|
// log.info("文件是否存在:" + file.exists());
|
|
|
|
|
|
if (!file.exists()) {
|
|
|
|
|
|
// 启动线程下载文件
|
|
|
|
|
|
String finalPdfUrl = pdfUrl;
|
|
|
|
|
|
new Thread(() -> new HsjcService().downloadHttpFile(finalPdfUrl, downUrl, newFileName)).start();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
log.error("文件检查失败: " + pdfUrl, e);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
JSONArray allrate = JSONArray.parseArray(JSON.toJSONString(resultList));
|
|
|
|
|
|
resSuc.put("response", allrate);
|
|
|
|
|
|
return resSuc;
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
throw new LogicException("获取pdf地址异常,请联系管理员。响应码: " + code);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
|
log.error("调用PACS查询接口失败", e);
|
|
|
|
|
|
throw new RuntimeException("网络请求失败: " + e.getMessage(), e);
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
if (connection != null) {
|
|
|
|
|
|
connection.disconnect();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return resSuc;
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 通过HTTP下载文件
|
|
|
|
|
|
* @param fileUrl 文件URL
|
|
|
|
|
|
* @param downUrl 日期目录
|
|
|
|
|
|
* @param fileName 文件名
|
|
|
|
|
|
*/
|
|
|
|
|
|
public void downloadHttpFile(String fileUrl, String downUrl, String fileName) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
// log.info("开始下载文件: " + fileUrl);
|
|
|
|
|
|
|
|
|
|
|
|
// 创建本地目录
|
|
|
|
|
|
String localDir = "/home/igzh/nxwj-gzhsvr/LISPDF/" + downUrl;
|
|
|
|
|
|
if (!FileUtil.exist(localDir)) {
|
|
|
|
|
|
FileUtil.mkdir(localDir);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 下载文件
|
|
|
|
|
|
URL url = new URL(fileUrl);
|
|
|
|
|
|
File localFile = new File(localDir + "/" + fileName);
|
|
|
|
|
|
|
|
|
|
|
|
// 使用Hutool工具类下载文件
|
|
|
|
|
|
FileUtil.writeFromStream(url.openStream(), localFile);
|
|
|
|
|
|
|
|
|
|
|
|
log.info("文件下载成功: " + fileUrl + " -> " + localFile.getAbsolutePath());
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
log.error("文件下载失败: " + fileUrl, e);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
public void PasDownloadPdf(String pdfname) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
// FtpWebUtil ftpWebUtil = new FtpWebUtil();
|
|
|
|
|
|
|
|
|
|
|
|
//读取classpath下的XXX.setting,不使用变量
|
|
|
|
|
|
Setting setting = new Setting("btby.setting");
|
|
|
|
|
|
|
|
|
|
|
|
//获取分组为group下key为name的值
|
|
|
|
|
|
String sftpname = setting.getByGroup("ftpname", "sys");
|
|
|
|
|
|
String sftppass = setting.getByGroup("ftppass", "sys");
|
|
|
|
|
|
String sftpip = setting.getByGroup("pacsftpip", "sys");
|
|
|
|
|
|
String sftpport = setting.getByGroup("ftpport", "sys");
|
|
|
|
|
|
|
|
|
|
|
|
//本地文件夹
|
|
|
|
|
|
String sftplocalpath = setting.getByGroup("localpath", "sys");
|
|
|
|
|
|
log.debug("pdf localpath:" + sftplocalpath);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FTPClient ftpClient = FtpWebUtil.ftpConnection(sftpip, sftpport, sftpname, sftppass);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String[] split = pdfname.split("/");
|
|
|
|
|
|
String downUrl = split[0];
|
|
|
|
|
|
String newFileName = split[1];
|
|
|
|
|
|
|
|
|
|
|
|
String fileName = split[1];
|
|
|
|
|
|
// log.info("newFileName" + newFileName);
|
|
|
|
|
|
// log.info("downUrl" + downUrl);
|
|
|
|
|
|
// log.info("fileName" + fileName);
|
|
|
|
|
|
//// String localpath = sftplocalpath;
|
|
|
|
|
|
// log.debug("download from ftp: " + downUrl);
|
|
|
|
|
|
String localDir = "/home/igzh/hnwj-pdf" + sftplocalpath + downUrl;
|
|
|
|
|
|
//检查文件夹,如果没有就新建
|
|
|
|
|
|
if (!cn.hutool.core.io.FileUtil.exist(localDir)) {
|
|
|
|
|
|
FileUtil.mkdir(localDir);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FtpWebUtil.downFile(ftpClient, newFileName, fileName, downUrl);
|
|
|
|
|
|
//// "ftp://reportpdf:123.com@192.168.150.3:20015/15100142_0219515.pdf"
|
|
|
|
|
|
// String urlname = "ftp://" + sftpname + ":" + sftppass + "@" + sftpip + ":" + sftpport + "/" + pdfname;
|
|
|
|
|
|
// ftpWebUtil.downloadpdf(urlname, localpath, pdfname);
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
}
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Map<String, Object> BillPay(Integer userId, String patientid, String jsonData) throws Exception {
|
|
|
|
|
|
int resultInt = 0;
|
|
|
|
|
|
Map<String, Object> mapRes = new HashMap<>();
|
|
|
|
|
|
BigDecimal bdBillAmount = BigDecimal.valueOf(0);
|
|
|
|
|
|
BigDecimal bdBillAmountMid;
|
|
|
|
|
|
DecimalFormat format = new DecimalFormat("###.00");
|
|
|
|
|
|
String payOrderNo = "";
|
|
|
|
|
|
String billMoney = "";
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
//如有多条单据,需要计算总金额
|
|
|
|
|
|
//把json字符串解析成json对象进行操作
|
|
|
|
|
|
String billString = "";
|
|
|
|
|
|
String hsjcname = "";
|
|
|
|
|
|
List<DjJson> lstDjJson;
|
|
|
|
|
|
JSONObject billData = new JSONObject();
|
|
|
|
|
|
|
|
|
|
|
|
JSONObject jb = JSONObject.parseObject(jsonData);
|
|
|
|
|
|
|
|
|
|
|
|
String data = jb.getString("data_row");
|
|
|
|
|
|
//这样判断的是否是JSONArray还是JSONObject
|
|
|
|
|
|
if (data.contains("[") && data.contains("]")) {
|
|
|
|
|
|
//这是jsonArray
|
|
|
|
|
|
log.debug("jsonArray");
|
|
|
|
|
|
|
|
|
|
|
|
//取“value”的键值,value里面是个json数组
|
|
|
|
|
|
List<Object> jsonArray = jb.getJSONArray("data_row");
|
|
|
|
|
|
|
|
|
|
|
|
//把json数组转为json字符串
|
|
|
|
|
|
billString = JSONObject.toJSONString(jsonArray);
|
|
|
|
|
|
|
|
|
|
|
|
//又把json字符串转为java集合得到我们需要的数据
|
|
|
|
|
|
lstDjJson = JSONObject.parseArray(billString, DjJson.class);
|
|
|
|
|
|
|
|
|
|
|
|
//插入mzjf表,查询如果有则不管
|
|
|
|
|
|
// 设置六位数支付订单号
|
|
|
|
|
|
payOrderNo = "MZ" + VeDate.getNo(6);
|
|
|
|
|
|
|
|
|
|
|
|
List<HsjcVo> lstJf = new ArrayList<>();
|
|
|
|
|
|
for (int i = 0; i < lstDjJson.size(); i++) {
|
|
|
|
|
|
HsjcVo jfvo = new HsjcVo();
|
|
|
|
|
|
|
|
|
|
|
|
//查询
|
|
|
|
|
|
jfvo.setUserId(userId);
|
|
|
|
|
|
jfvo.setPatientid(patientid);
|
|
|
|
|
|
|
|
|
|
|
|
jfvo.setFlowno(lstDjJson.get(i).getFlowno());
|
|
|
|
|
|
jfvo.setSetdepartcode(lstDjJson.get(i).getSetdepartcode());
|
|
|
|
|
|
jfvo.setSetdepartname(lstDjJson.get(i).getSetdepartname());
|
|
|
|
|
|
jfvo.setDodepartcode(lstDjJson.get(i).getDodepartcode());
|
|
|
|
|
|
jfvo.setDoctorname(lstDjJson.get(i).getDoctorname());
|
|
|
|
|
|
jfvo.setBilltype(lstDjJson.get(i).getBilltype());
|
|
|
|
|
|
jfvo.setBillname(lstDjJson.get(i).getBillname());
|
|
|
|
|
|
jfvo.setBilldes(lstDjJson.get(i).getBilldes());
|
|
|
|
|
|
jfvo.setBilltime(lstDjJson.get(i).getBilltime());
|
|
|
|
|
|
jfvo.setBillmoney(lstDjJson.get(i).getBillmoney());
|
|
|
|
|
|
bdBillAmountMid = new BigDecimal(lstDjJson.get(i).getBillmoney());
|
|
|
|
|
|
bdBillAmount = bdBillAmount.add(bdBillAmountMid);
|
|
|
|
|
|
|
|
|
|
|
|
jfvo.setDoctorcode(lstDjJson.get(i).getDoctorcode());
|
|
|
|
|
|
jfvo.setDoctorname(lstDjJson.get(i).getDoctorname());
|
|
|
|
|
|
jfvo.setSincemoney(lstDjJson.get(i).getSincemoney());
|
|
|
|
|
|
jfvo.setFairmoney(lstDjJson.get(i).getFairmoney());
|
|
|
|
|
|
jfvo.setSerialno(lstDjJson.get(i).getSerialno());
|
|
|
|
|
|
jfvo.setAppointno(lstDjJson.get(i).getAppointno());
|
|
|
|
|
|
jfvo.setSerialflowno(lstDjJson.get(i).getSerialflowno());
|
|
|
|
|
|
jfvo.setJzlb(lstDjJson.get(i).getJzlb());
|
|
|
|
|
|
jfvo.setBzdm(lstDjJson.get(i).getBzdm());
|
|
|
|
|
|
jfvo.setUpdatedate(lstDjJson.get(i).getUpdatedate());
|
|
|
|
|
|
|
|
|
|
|
|
//单据状态 0 正常 1 开具 2 已消号 3 挂号成功(待缴费) 4 已缴费 5 已退费
|
|
|
|
|
|
jfvo.setAppStatus(3);
|
|
|
|
|
|
|
|
|
|
|
|
jfvo.setOrderno(payOrderNo);
|
|
|
|
|
|
|
|
|
|
|
|
hsjcMapper.opHsjcAppoint(jfvo);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// lstJf = hsjcMapper.getMzjfListByFlow(jfvo);
|
|
|
|
|
|
// if (lstJf.size() == 0) {
|
|
|
|
|
|
// //插入 mzjf 表
|
|
|
|
|
|
// jfvo.setOrderno(payOrderNo);
|
|
|
|
|
|
//
|
|
|
|
|
|
// jfvo.setAppStatus(3);
|
|
|
|
|
|
// hsjcMapper.opHsjcAppoint(jfvo);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// else {
|
|
|
|
|
|
// //已经有记录,则取出payorderno
|
|
|
|
|
|
// //已经有记录,则需要更新orderno,工行订单号会过期
|
|
|
|
|
|
// String oldPayOrderNo = lstJf.get(0).getOrderno();
|
|
|
|
|
|
// String newUpdateTime = lstDjJson.get(i).getUpdatedate();
|
|
|
|
|
|
//
|
|
|
|
|
|
// //已经有记录 需要检查下是否已经付款
|
|
|
|
|
|
// log.debug("the use has the old orderno:" + oldPayOrderNo);
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
//下单!!!修改为建行支付
|
|
|
|
|
|
//这里修改为从建行下单,返回给公众号订单信息调出支付界面,完成支付后在回调接口里完成后续的订单处理
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// String ret = payService.inq(oldPayOrderNo);
|
|
|
|
|
|
// JSONObject resJb = JSON.parseObject(ret);
|
|
|
|
|
|
// if ((resJb.getInteger("returnCode") == 0) &&
|
|
|
|
|
|
// (resJb.getInteger("pay_status") == 0)) {
|
|
|
|
|
|
// //交易结果标志,0-成功;1-失败;2-未知
|
|
|
|
|
|
// //直接去做确认
|
|
|
|
|
|
// log.debug("the old orderno already pay: " + oldPayOrderNo);
|
|
|
|
|
|
//
|
|
|
|
|
|
// //更新时间
|
|
|
|
|
|
// hsjcMapper.opUpdateOrder(oldPayOrderNo, oldPayOrderNo, newUpdateTime);
|
|
|
|
|
|
//
|
|
|
|
|
|
// paybills(oldPayOrderNo, "", "");
|
|
|
|
|
|
//
|
|
|
|
|
|
// mapRes.put("code", "300");
|
|
|
|
|
|
// mapRes.put("result", "success");
|
|
|
|
|
|
// mapRes.put("id", 1);
|
|
|
|
|
|
// return mapRes;
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
// //已经有记录,先判断order时间是否过了5分钟
|
|
|
|
|
|
// String oldOrdernoTime = oldPayOrderNo.substring(10, 16);
|
|
|
|
|
|
// Date currentTime = new Date();
|
|
|
|
|
|
// SimpleDateFormat formatter = new SimpleDateFormat("HHmmss");
|
|
|
|
|
|
// String CurrentTime = formatter.format(currentTime);
|
|
|
|
|
|
// if (Integer.valueOf(CurrentTime) - Integer.parseInt(oldOrdernoTime) <= 600) {
|
|
|
|
|
|
// log.debug("the user old orderno create time less then 5 minutes");
|
|
|
|
|
|
//
|
|
|
|
|
|
// mapRes.put("code", "500");
|
|
|
|
|
|
// mapRes.put("result", "success");
|
|
|
|
|
|
// mapRes.put("id", 1);
|
|
|
|
|
|
// return mapRes;
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// log.debug("the old orderno not pay: " + oldPayOrderNo);
|
|
|
|
|
|
// hsjcMapper.opUpdateOrder(payOrderNo, oldPayOrderNo, newUpdateTime);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
}
|
|
|
|
|
|
//多单据的总金额
|
|
|
|
|
|
billMoney = bdBillAmount.toPlainString();
|
|
|
|
|
|
} else {
|
|
|
|
|
|
//这是jsonObject
|
|
|
|
|
|
log.debug("jsonObject");
|
|
|
|
|
|
billData = jb.getJSONObject("data_row");
|
|
|
|
|
|
|
|
|
|
|
|
//插入mzjf表,查询如果有则不管
|
|
|
|
|
|
// 设置六位数支付订单号
|
|
|
|
|
|
payOrderNo = "MZ" + VeDate.getNo(6);
|
|
|
|
|
|
|
|
|
|
|
|
HsjcVo jfvo = new HsjcVo();
|
|
|
|
|
|
|
|
|
|
|
|
//查询
|
|
|
|
|
|
jfvo.setUserId(userId);
|
|
|
|
|
|
jfvo.setPatientid(patientid);
|
|
|
|
|
|
|
|
|
|
|
|
jfvo.setFlowno(billData.getString("FlowNo"));
|
|
|
|
|
|
jfvo.setSetdepartcode(billData.getString("SetDepartCode"));
|
|
|
|
|
|
jfvo.setSetdepartname(billData.getString("SetDepartName"));
|
|
|
|
|
|
jfvo.setDodepartcode(billData.getString("DoDepartCode"));
|
|
|
|
|
|
jfvo.setDoctorname(billData.getString("DoDepartName"));
|
|
|
|
|
|
jfvo.setBilltype(billData.getString("BillType"));
|
|
|
|
|
|
jfvo.setBillname(billData.getString("BillName"));
|
|
|
|
|
|
jfvo.setBilldes(billData.getString("BillDes"));
|
|
|
|
|
|
jfvo.setBilltime(billData.getString("BillTime"));
|
|
|
|
|
|
jfvo.setBillmoney(billData.getString("BillMoney"));
|
|
|
|
|
|
|
|
|
|
|
|
jfvo.setDoctorcode(billData.getString("DoctorCode"));
|
|
|
|
|
|
jfvo.setDoctorname(billData.getString("DoctorName"));
|
|
|
|
|
|
jfvo.setSincemoney(billData.getString("SinceMoney"));
|
|
|
|
|
|
jfvo.setFairmoney(billData.getString("FairMoney"));
|
|
|
|
|
|
jfvo.setSerialno(billData.getString("SerialNo"));
|
|
|
|
|
|
jfvo.setAppointno(billData.getString("AppointNo"));
|
|
|
|
|
|
jfvo.setSerialflowno(billData.getString("SerialFlowNo"));
|
|
|
|
|
|
jfvo.setJzlb(billData.getString("JZLB"));
|
|
|
|
|
|
jfvo.setBzdm(billData.getString("BZDM"));
|
|
|
|
|
|
jfvo.setUpdatedate(billData.getString("Updatedate"));
|
|
|
|
|
|
|
|
|
|
|
|
//单据状态 0 正常 1 开具 2 已消号 3 挂号成功(待缴费) 4 已缴费 5 已退费
|
|
|
|
|
|
jfvo.setAppStatus(3);
|
|
|
|
|
|
jfvo.setOrderno(payOrderNo);
|
|
|
|
|
|
|
|
|
|
|
|
hsjcMapper.opHsjcAppoint(jfvo);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// List<HsjcVo> lstJf = new ArrayList<>();
|
|
|
|
|
|
// lstJf = hsjcMapper.getMzjfListByFlow(jfvo);
|
|
|
|
|
|
// if (lstJf.size() == 0) {
|
|
|
|
|
|
// //插入 mzjf 表
|
|
|
|
|
|
// jfvo.setOrderno(payOrderNo);
|
|
|
|
|
|
//
|
|
|
|
|
|
// jfvo.setAppStatus(3);
|
|
|
|
|
|
// hsjcMapper.opHsjcAppoint(jfvo);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// else {
|
|
|
|
|
|
// //已经有记录,则取出payorderno
|
|
|
|
|
|
// String oldPayOrderNo = lstJf.get(0).getOrderno();
|
|
|
|
|
|
// String newUpdateTime = billData.getString("Updatedate");
|
|
|
|
|
|
//
|
|
|
|
|
|
// //已经有记录 需要检查下是否已经付款
|
|
|
|
|
|
// log.debug("the use has the old orderno:" + oldPayOrderNo);
|
|
|
|
|
|
// String ret = payService.inq(oldPayOrderNo);
|
|
|
|
|
|
// JSONObject resJb = JSON.parseObject(ret);
|
|
|
|
|
|
// if ((resJb.getInteger("returnCode") == 0) &&
|
|
|
|
|
|
// (resJb.getInteger("pay_status") == 0)) {
|
|
|
|
|
|
// //交易结果标志,0-成功;1-失败;2-未知
|
|
|
|
|
|
// //直接去做确认
|
|
|
|
|
|
// log.debug("the old orderno already pay: " + oldPayOrderNo);
|
|
|
|
|
|
// //更新时间
|
|
|
|
|
|
// hsjcMapper.opUpdateOrder(oldPayOrderNo, oldPayOrderNo, newUpdateTime);
|
|
|
|
|
|
// paybills(oldPayOrderNo, "", "");
|
|
|
|
|
|
//
|
|
|
|
|
|
// mapRes.put("code", "300");
|
|
|
|
|
|
// mapRes.put("result", "success");
|
|
|
|
|
|
// mapRes.put("id", 1);
|
|
|
|
|
|
// return mapRes;
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
// //已经有记录,先判断order时间是否过了5分钟
|
|
|
|
|
|
// String oldOrdernoTime = oldPayOrderNo.substring(10, 16);
|
|
|
|
|
|
// Date currentTime = new Date();
|
|
|
|
|
|
// SimpleDateFormat formatter = new SimpleDateFormat("HHmmss");
|
|
|
|
|
|
// String CurrentTime = formatter.format(currentTime);
|
|
|
|
|
|
// if (Integer.valueOf(CurrentTime) - Integer.parseInt(oldOrdernoTime) <= 600) {
|
|
|
|
|
|
// log.debug("the user old orderno create time less then 5 minutes");
|
|
|
|
|
|
//
|
|
|
|
|
|
// mapRes.put("code", "500");
|
|
|
|
|
|
// mapRes.put("result", "success");
|
|
|
|
|
|
// mapRes.put("id", 1);
|
|
|
|
|
|
// return mapRes;
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// log.debug("the old orderno not pay: " + oldPayOrderNo);
|
|
|
|
|
|
// hsjcMapper.opUpdateOrder(payOrderNo, oldPayOrderNo, newUpdateTime);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
//单据的金额
|
|
|
|
|
|
billMoney = billData.getString("BillMoney");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//建行发起订单 缴费
|
|
|
|
|
|
// String result = "";
|
|
|
|
|
|
|
|
|
|
|
|
return httpHsjcAppAppoint(userId, payOrderNo, billMoney);
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
throw new LogicException("系统异常");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 建行订单 webService
|
|
|
|
|
|
*/
|
|
|
|
|
|
public Map<String, Object> httpHsjcAppAppoint(int userId, String payOrderNo, String billMoney) throws Exception {
|
|
|
|
|
|
// 设置六位数支付订单号
|
|
|
|
|
|
UserVo userVo = userService.queryUserInfoDetails(userId);
|
|
|
|
|
|
|
|
|
|
|
|
JhClientInfo jhClientInfo = new JhClientInfo(payOrderNo, userVo.getOpenid(), billMoney);
|
|
|
|
|
|
// Map<String, Object> stringObjectMap = jhPayService.unifiedPlaceOrder(jhClientInfo);
|
|
|
|
|
|
Map<String, Object> stringObjectMap =new HashMap<>();
|
|
|
|
|
|
// String str = payService.pay(money, payOrderNo, "/reserve/callback", "挂号费");
|
|
|
|
|
|
|
|
|
|
|
|
return stringObjectMap;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Map<String, Object> HsjcCreate(HsjcVo vo) throws Exception {
|
|
|
|
|
|
int resultInt = 0;
|
|
|
|
|
|
Integer iLimitCount = 0;
|
|
|
|
|
|
Map<String, Object> mapRes = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
|
|
//做限号处理 早上150 下午150
|
|
|
|
|
|
if (vo.getCreatitemname().equals("新型冠状病毒抗体检测")) {
|
|
|
|
|
|
Example exampleSys = new Example(AdminSystem.class);
|
|
|
|
|
|
Example.Criteria criteriaSys = exampleSys.createCriteria();
|
|
|
|
|
|
criteriaSys.andEqualTo("name", "hsjc");
|
|
|
|
|
|
List<AdminSystem> lstadminsystem = adminSystemMapper.selectByExample(exampleSys);
|
|
|
|
|
|
if (lstadminsystem.size() >= 1) {
|
|
|
|
|
|
iLimitCount = lstadminsystem.get(0).getLimitcount();
|
|
|
|
|
|
} else {
|
|
|
|
|
|
throw new LogicException("查询系统限额失败");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Example example = new Example(UserMzjf.class);
|
|
|
|
|
|
Example.Criteria criteria = example.createCriteria();
|
|
|
|
|
|
//单据状态 0 正常 1 开具 2 已消号 3 挂号成功(待缴费) 4 已缴费 5 已退费
|
|
|
|
|
|
criteria.andEqualTo("creatitemname", "新型冠状病毒抗体检测");
|
|
|
|
|
|
criteria.andEqualTo("appointmenttime", vo.getAppointmenttime());
|
|
|
|
|
|
List<UserMzjf> lstmzjf = userMzjfMapper.selectByExample(example);
|
|
|
|
|
|
log.debug("核酸检测已达:" + vo.getAppointmenttime() + " count:" + lstmzjf.size());
|
|
|
|
|
|
if (lstmzjf.size() >= iLimitCount) {
|
|
|
|
|
|
mapRes.put("result", "核酸预约已达限号");
|
|
|
|
|
|
mapRes.put("id", 888);
|
|
|
|
|
|
return mapRes;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//开单
|
|
|
|
|
|
String xml = MOP_OutpBillstoPayCreat(vo);
|
|
|
|
|
|
// 解析报文
|
|
|
|
|
|
Map<String, Object> mapCreate = XmlUtil.parse(xml);
|
|
|
|
|
|
if (mapCreate.get("returncode").toString().equals("1")) {
|
|
|
|
|
|
|
|
|
|
|
|
if (mapCreate.get("FlowNo") != null) {
|
|
|
|
|
|
vo.setFlowno(mapCreate.get("FlowNo").toString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//允许退号标志 N 不允许 Y 允许
|
|
|
|
|
|
vo.setAppFlag("Y");
|
|
|
|
|
|
//单据状态 0 正常 1 开具 2 已消号 3 挂号成功(待缴费) 4 已缴费 5 已退费
|
|
|
|
|
|
vo.setAppStatus(1);
|
|
|
|
|
|
|
|
|
|
|
|
// 设置六位数支付订单号
|
|
|
|
|
|
String payOrderNo = "MZ" + VeDate.getNo(6);
|
|
|
|
|
|
vo.setOrderno(payOrderNo);
|
|
|
|
|
|
|
|
|
|
|
|
resultInt = hsjcMapper.opHsjcAppoint(vo);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
throw new LogicException(mapCreate.get("errormsg").toString());
|
|
|
|
|
|
}
|
|
|
|
|
|
if (resultInt == 1) {
|
|
|
|
|
|
mapRes.put("result", "success");
|
|
|
|
|
|
mapRes.put("id", 1);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
mapRes.put("result", "fail");
|
|
|
|
|
|
mapRes.put("id", 1);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// if (resultInt == 1) {
|
|
|
|
|
|
// //查询单据
|
|
|
|
|
|
//// public String MOP_OutpBillstoPayQuery(String PatientId, Integer QueryType, String OrderNo)
|
|
|
|
|
|
// String resxml = MOP_OutpBillstoPayQuery(vo.getPatientid(), 2, vo.getFlowno());
|
|
|
|
|
|
// Map<String, Object> map = XmlUtil.parse(resxml);
|
|
|
|
|
|
// if (map.get("returncode").toString().equals("1")) {
|
|
|
|
|
|
//
|
|
|
|
|
|
// if (map.get("FlowNo") != null) {
|
|
|
|
|
|
// vo.setFlowno(map.get("FlowNo").toString());
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if (map.get("SetDepartCode") != null) {
|
|
|
|
|
|
// vo.setSetdepartcode(map.get("SetDepartCode").toString());
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if (map.get("SetDepartName") != null) {
|
|
|
|
|
|
// vo.setSetdepartname(map.get("SetDepartName").toString());
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if (map.get("DoDepartCode") != null) {
|
|
|
|
|
|
// vo.setDodepartcode(map.get("DoDepartCode").toString());
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if (map.get("DoDepartName") != null) {
|
|
|
|
|
|
// vo.setDoctorname(map.get("DoDepartName").toString());
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if (map.get("BillType") != null) {
|
|
|
|
|
|
// vo.setBilltype(map.get("BillType").toString());
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if (map.get("BillName") != null) {
|
|
|
|
|
|
// vo.setBillname(map.get("BillName").toString());
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if (map.get("BillDes") != null) {
|
|
|
|
|
|
// vo.setBilldes(map.get("BillDes").toString());
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if (map.get("BillTime") != null) {
|
|
|
|
|
|
// vo.setBilltime(map.get("BillTime").toString());
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if (map.get("BillMoney") != null) {
|
|
|
|
|
|
// vo.setBillmoney(map.get("BillMoney").toString());
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if (map.get("DoctorCode") != null) {
|
|
|
|
|
|
// vo.setDoctorcode(map.get("DoctorCode").toString());
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if (map.get("DoctorName") != null) {
|
|
|
|
|
|
// vo.setDoctorname(map.get("DoctorName").toString());
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if (map.get("SinceMoney") != null) {
|
|
|
|
|
|
// //vo.setSincemoney(map.get("SinceMoney").toString());
|
|
|
|
|
|
// vo.setSincemoney("");
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if (map.get("FairMoney") != null) {
|
|
|
|
|
|
// //vo.setFairmoney(map.get("FairMoney").toString());
|
|
|
|
|
|
// vo.setFairmoney("");
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if (map.get("SerialNo") != null) {
|
|
|
|
|
|
// vo.setSerialno(map.get("SerialNo").toString());
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if (map.get("AppointNo") != null) {
|
|
|
|
|
|
// vo.setAppointno(map.get("AppointNo").toString());
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if (map.get("SerialFlowNo") != null) {
|
|
|
|
|
|
// vo.setSerialflowno(map.get("SerialFlowNo").toString());
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if (map.get("JZLB") != null) {
|
|
|
|
|
|
// vo.setJzlb(map.get("JZLB").toString());
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if (map.get("BZDM") != null) {
|
|
|
|
|
|
// vo.setBzdm(map.get("BZDM").toString());
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if (map.get("Updatedate") != null) {
|
|
|
|
|
|
// vo.setUpdatedate(map.get("Updatedate").toString());
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// //允许退号标志 N 不允许 Y 允许
|
|
|
|
|
|
// vo.setAppFlag("Y");
|
|
|
|
|
|
// //单据状态 0 正常 1 开具 2 已消号 3 挂号成功(待缴费) 4 已缴费 5 已退费
|
|
|
|
|
|
// vo.setAppStatus(3);
|
|
|
|
|
|
//
|
|
|
|
|
|
// resultInt = hsjcMapper.opHsjcQueryAppoint(vo);
|
|
|
|
|
|
//
|
|
|
|
|
|
// //ICBC 缴费 如果缴费失败则做开单取消
|
|
|
|
|
|
// Map<String, Object> stringObjectMap = httpHsjcAppAppoint(vo.getUserId(), vo.getOrderno(), vo.getBillmoney());
|
|
|
|
|
|
//
|
|
|
|
|
|
//// mapRes.put("result", result);
|
|
|
|
|
|
//// mapRes.put("id", 1);
|
|
|
|
|
|
// return stringObjectMap;
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
// throw new LogicException(map.get("errormsg").toString());
|
|
|
|
|
|
// }
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
// mapRes.put("result", "");
|
|
|
|
|
|
// mapRes.put("id", 1);
|
|
|
|
|
|
// return mapRes;
|
|
|
|
|
|
// }
|
|
|
|
|
|
return mapRes;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 核酸自助开单
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
public String MOP_OutpBillstoPayCreat(HsjcVo vo) throws Exception {
|
|
|
|
|
|
StringBuffer str = new StringBuffer();
|
|
|
|
|
|
str.append("<PatientId>");
|
|
|
|
|
|
// str.append("00093777");
|
|
|
|
|
|
str.append(vo.getPatientid());
|
|
|
|
|
|
str.append("</PatientId>");
|
|
|
|
|
|
str.append("<IDType>");
|
|
|
|
|
|
// str.append("0");
|
|
|
|
|
|
str.append(vo.getIdtype());
|
|
|
|
|
|
str.append("</IDType>");
|
|
|
|
|
|
str.append("<LockType>");
|
|
|
|
|
|
// str.append("1");
|
|
|
|
|
|
str.append(vo.getLocktype());
|
|
|
|
|
|
str.append("</LockType>");
|
|
|
|
|
|
str.append("<CreatItemName>");
|
|
|
|
|
|
// str.append("新型冠状病毒抗体检测");
|
|
|
|
|
|
str.append(vo.getCreatitemname());
|
|
|
|
|
|
str.append("</CreatItemName>");
|
|
|
|
|
|
str.append("<CreatItemType>");
|
|
|
|
|
|
str.append("1");
|
|
|
|
|
|
str.append("</CreatItemType>");
|
|
|
|
|
|
str.append("<AppointmentTime>");
|
|
|
|
|
|
// str.append("2021-01-29 10:00:00");
|
|
|
|
|
|
str.append(vo.getAppointmenttime());
|
|
|
|
|
|
str.append("</AppointmentTime>");
|
|
|
|
|
|
str.append("<Creatdate>");
|
|
|
|
|
|
// str.append("2021-01-29 10:00:00");
|
|
|
|
|
|
str.append(vo.getCreatdate());
|
|
|
|
|
|
str.append("</Creatdate>");
|
|
|
|
|
|
|
|
|
|
|
|
String reqXml = requestXml("MOP_OutpBillstoPayCreat", str.toString());
|
|
|
|
|
|
String respXml = SoapUtil.soapMethod(reqXml);
|
|
|
|
|
|
log.debug("MOP_OutpBillstoPayCreat:" + reqXml);
|
|
|
|
|
|
log.debug("MOP_OutpBillstoPayCreat:" + respXml);
|
|
|
|
|
|
return respXml;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 核酸自助开单
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
public String MOP_OutpBillstoPayConfirm(HsjcVo vo) throws Exception {
|
|
|
|
|
|
StringBuffer str = new StringBuffer();
|
|
|
|
|
|
|
|
|
|
|
|
str.append("<PatientId>");
|
|
|
|
|
|
str.append(vo.getPatientid());
|
|
|
|
|
|
str.append("</PatientId>");
|
|
|
|
|
|
|
|
|
|
|
|
str.append("<BillsMsg>");
|
|
|
|
|
|
str.append(vo.getBillsmsg());
|
|
|
|
|
|
str.append("</BillsMsg>");
|
|
|
|
|
|
str.append("<CostAmount>");
|
|
|
|
|
|
str.append(vo.getZfamount());
|
|
|
|
|
|
str.append("</CostAmount>");
|
|
|
|
|
|
|
|
|
|
|
|
str.append("<ZFAmount>");
|
|
|
|
|
|
str.append(vo.getZfamount());
|
|
|
|
|
|
str.append("</ZFAmount>");
|
|
|
|
|
|
|
|
|
|
|
|
// str.append("<ChargAmount>");
|
|
|
|
|
|
// str.append(vo.getZfamount());
|
|
|
|
|
|
// str.append("</ChargAmount>");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
str.append("<PayNature>");
|
|
|
|
|
|
str.append(vo.getPaynature());
|
|
|
|
|
|
str.append("</PayNature>");
|
|
|
|
|
|
|
|
|
|
|
|
str.append("<PayType>");
|
|
|
|
|
|
str.append(vo.getPaytype());
|
|
|
|
|
|
str.append("</PayType>");
|
|
|
|
|
|
|
|
|
|
|
|
str.append("<PowerTranID>");
|
|
|
|
|
|
str.append(vo.getPowertranid());
|
|
|
|
|
|
str.append("</PowerTranID>");
|
|
|
|
|
|
|
|
|
|
|
|
str.append("<PayInfo>");
|
|
|
|
|
|
str.append(vo.getPowertranid());
|
|
|
|
|
|
str.append("</PayInfo>");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// str.append("<TerminalId>");
|
|
|
|
|
|
// str.append(vo.getTerminalid());
|
|
|
|
|
|
// str.append("</TerminalId>");
|
|
|
|
|
|
// str.append("<ReferNo>");
|
|
|
|
|
|
// str.append(vo.getReferno());
|
|
|
|
|
|
// str.append("</ReferNo>");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// str.append("<YBZHAmount>");
|
|
|
|
|
|
// //str.append(vo.getYbzhamount());
|
|
|
|
|
|
// str.append("0.00");
|
|
|
|
|
|
// str.append("</YBZHAmount>");
|
|
|
|
|
|
// str.append("<YBTCAmount>");
|
|
|
|
|
|
//// str.append(vo.getYbtcamount());
|
|
|
|
|
|
// str.append("0.00");
|
|
|
|
|
|
// str.append("</YBTCAmount>");
|
|
|
|
|
|
|
2026-01-26 17:57:47 +08:00
|
|
|
|
if (vo.getYboutmsg() != null && !vo.getYboutmsg().isEmpty()) {
|
|
|
|
|
|
str.append("<YBOutMsg>");
|
|
|
|
|
|
str.append(vo.getYboutmsg());
|
|
|
|
|
|
str.append("</YBOutMsg>");
|
|
|
|
|
|
}
|
2026-01-07 10:36:02 +08:00
|
|
|
|
str.append("<HisOperNum>");
|
|
|
|
|
|
str.append(vo.getHisopernum());
|
|
|
|
|
|
str.append("</HisOperNum>");
|
|
|
|
|
|
// str.append("<Updatedate>");
|
|
|
|
|
|
// str.append(vo.getUpdatedate());
|
|
|
|
|
|
// str.append("</Updatedate>");
|
|
|
|
|
|
|
|
|
|
|
|
String reqXml = requestXml("MOP_OutpBillsPayedConfirm", str.toString());
|
|
|
|
|
|
String respXml = SoapUtil.soapMethod(reqXml);
|
|
|
|
|
|
log.debug("MOP_OutpBillsPayedConfirm:" + reqXml);
|
|
|
|
|
|
log.debug("MOP_OutpBillsPayedConfirm:" + respXml);
|
|
|
|
|
|
return respXml;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 查询缴费状态
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
public String MOP_OutpBillsStateQuery(String PowerTranID) throws Exception {
|
|
|
|
|
|
StringBuffer str = new StringBuffer();
|
|
|
|
|
|
str.append("<PowerTranID>");
|
|
|
|
|
|
str.append(PowerTranID);
|
|
|
|
|
|
str.append("</PowerTranID>");
|
|
|
|
|
|
|
|
|
|
|
|
String reqXml = requestXml("MOP_OutpBillsStateQuery", str.toString());
|
|
|
|
|
|
String respXml = SoapUtil.soapMethod(reqXml);
|
|
|
|
|
|
log.debug("MOP_OutpBillsStateQuery:" + reqXml);
|
|
|
|
|
|
log.debug("MOP_OutpBillsStateQuery:" + respXml);
|
|
|
|
|
|
return respXml;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 查询检验报告单明细信息
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
public String MOP_OutpLisReptDetailQuery(String ReportId) throws Exception {
|
|
|
|
|
|
StringBuffer str = new StringBuffer();
|
|
|
|
|
|
str.append("<ReportId>");
|
|
|
|
|
|
str.append(ReportId);
|
|
|
|
|
|
str.append("</ReportId>");
|
|
|
|
|
|
|
|
|
|
|
|
String reqXml = requestXml("MOP_OutpLisReptDetailQuery", str.toString());
|
|
|
|
|
|
String respXml = SoapUtil.soapMethod(reqXml);
|
|
|
|
|
|
log.debug("MOP_OutpLisReptDetailQuery:" + reqXml);
|
|
|
|
|
|
log.debug("MOP_OutpLisReptDetailQuery:" + respXml);
|
|
|
|
|
|
return respXml;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String MOP_OutpBillsDetailQuery(String FlowNo, String PatientId, Integer InsuranceType) throws Exception {
|
|
|
|
|
|
StringBuffer str = new StringBuffer();
|
|
|
|
|
|
str.append("<FlowNo>");
|
|
|
|
|
|
str.append(FlowNo);
|
|
|
|
|
|
str.append("</FlowNo>");
|
|
|
|
|
|
str.append("<PatientId>");
|
|
|
|
|
|
str.append(PatientId);
|
|
|
|
|
|
str.append("</PatientId>");
|
|
|
|
|
|
str.append("<InsuranceType>");
|
|
|
|
|
|
str.append(InsuranceType);
|
|
|
|
|
|
str.append("</InsuranceType>");
|
|
|
|
|
|
String reqXml = requestXml("MOP_OutpBillsDetailQuery", str.toString());
|
|
|
|
|
|
String respXml = SoapUtil.soapMethod2(reqXml);
|
|
|
|
|
|
log.debug("MOP_OutpBillsDetailQuery:" + reqXml);
|
|
|
|
|
|
log.debug("MOP_OutpBillsDetailQuery:" + respXml);
|
|
|
|
|
|
return respXml;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 查询检验报告单主信息
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
public String MOP_OutpLisReptMasterQuery(String QueryCode, Integer QueryType, String StartTime, String EndTime) throws Exception {
|
|
|
|
|
|
StringBuffer str = new StringBuffer();
|
|
|
|
|
|
str.append("<QueryCode>");
|
|
|
|
|
|
str.append(QueryCode);
|
|
|
|
|
|
str.append("</QueryCode>");
|
|
|
|
|
|
str.append("<QueryType>");
|
|
|
|
|
|
str.append(QueryType);
|
|
|
|
|
|
str.append("</QueryType>");
|
|
|
|
|
|
str.append("<StartTime>");
|
|
|
|
|
|
str.append(StartTime);
|
|
|
|
|
|
str.append("</StartTime>");
|
|
|
|
|
|
str.append("<EndTime>");
|
|
|
|
|
|
str.append(EndTime);
|
|
|
|
|
|
str.append("</EndTime>");
|
|
|
|
|
|
|
|
|
|
|
|
String reqXml = requestXml("MOP_OutpLisReptMasterQuery", str.toString());
|
|
|
|
|
|
String respXml = SoapUtil.soapMethod(reqXml);
|
|
|
|
|
|
log.debug("MOP_OutpLisReptMasterQuery:" + reqXml);
|
|
|
|
|
|
log.debug("MOP_OutpLisReptMasterQuery:" + respXml);
|
|
|
|
|
|
return respXml;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 查询缴费单据
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
public String MOP_OutpBillstoPayQuery(String PatientId, Integer QueryType, String OrderNo) throws Exception {
|
|
|
|
|
|
StringBuffer str = new StringBuffer();
|
|
|
|
|
|
str.append("<PatientId>");
|
|
|
|
|
|
str.append(PatientId);
|
|
|
|
|
|
str.append("</PatientId>");
|
|
|
|
|
|
str.append("<QueryType>");
|
|
|
|
|
|
str.append(QueryType);
|
|
|
|
|
|
str.append("</QueryType>");
|
|
|
|
|
|
str.append("<OrderNo>");
|
|
|
|
|
|
str.append(OrderNo);
|
|
|
|
|
|
str.append("</OrderNo>");
|
|
|
|
|
|
|
|
|
|
|
|
String reqXml = requestXml("MOP_OutpBillstoPayQuery", str.toString());
|
|
|
|
|
|
String respXml = SoapUtil.soapMethod(reqXml);
|
|
|
|
|
|
log.debug("MOP_OutpBillstoPayQuery:" + reqXml);
|
|
|
|
|
|
log.debug("MOP_OutpBillstoPayQuery:" + respXml);
|
|
|
|
|
|
return respXml;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
public static String requestXml(String method, String xml) {
|
|
|
|
|
|
StringBuffer str = new StringBuffer();
|
|
|
|
|
|
str.append("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:tem=\"http://tempuri.org/\">");
|
|
|
|
|
|
str.append("<soapenv:Header/>");
|
|
|
|
|
|
str.append("<soapenv:Body>");
|
|
|
|
|
|
str.append("<tem:" + method);
|
|
|
|
|
|
str.append("><tem:InMsg>");
|
|
|
|
|
|
str.append("<![CDATA[");
|
|
|
|
|
|
str.append("<request>");
|
|
|
|
|
|
str.append(xml);
|
|
|
|
|
|
str.append("</request>");
|
|
|
|
|
|
str.append("]]>");
|
|
|
|
|
|
str.append("</tem:InMsg>");
|
|
|
|
|
|
str.append("</tem:" + method);
|
|
|
|
|
|
str.append("></soapenv:Body>");
|
|
|
|
|
|
str.append("</soapenv:Envelope>");
|
|
|
|
|
|
return str.toString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// @Async("asyncServiceExecutor")
|
|
|
|
|
|
public void callback(HttpServletRequest request, HttpServletResponse response) {
|
|
|
|
|
|
PrintWriter out = null;
|
|
|
|
|
|
try {
|
|
|
|
|
|
log.debug("enter the ICBC hsjc callback");
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, String> params = new HashMap<String, String>();
|
|
|
|
|
|
String from = request.getParameter("from");
|
|
|
|
|
|
String api = request.getParameter("api");
|
|
|
|
|
|
String app_id = request.getParameter("app_id");
|
|
|
|
|
|
String charset = request.getParameter("charset");
|
|
|
|
|
|
String format = request.getParameter("format");
|
|
|
|
|
|
String encrypt_type = request.getParameter("encrypt_type");
|
|
|
|
|
|
String timestamp = request.getParameter("timestamp");
|
|
|
|
|
|
String biz_content = request.getParameter("biz_content");
|
|
|
|
|
|
String sign_type = request.getParameter("sign_type");
|
|
|
|
|
|
String sign = request.getParameter("sign");
|
|
|
|
|
|
log.debug("from:" + from);
|
|
|
|
|
|
log.debug("api:" + api);
|
|
|
|
|
|
log.debug("app_id:" + app_id);
|
|
|
|
|
|
log.debug("charset:" + charset);
|
|
|
|
|
|
log.debug("format:" + format);
|
|
|
|
|
|
log.debug("encrypt_type:" + encrypt_type);
|
|
|
|
|
|
log.debug("timestamp:" + timestamp);
|
|
|
|
|
|
log.debug("biz_content:" + biz_content);
|
|
|
|
|
|
log.debug("sign_type:" + sign_type);
|
|
|
|
|
|
log.debug("sign:" + sign);
|
|
|
|
|
|
|
|
|
|
|
|
params.put("from", from);
|
|
|
|
|
|
params.put("api", api);
|
|
|
|
|
|
params.put("app_id", app_id);
|
|
|
|
|
|
params.put("charset", charset);
|
|
|
|
|
|
params.put("format", format);
|
|
|
|
|
|
params.put("encrypt_type", encrypt_type);
|
|
|
|
|
|
params.put("timestamp", timestamp);
|
|
|
|
|
|
params.put("biz_content", biz_content);
|
|
|
|
|
|
params.put("sign_type", sign_type);//目前上行网关签名暂时仅支持RSA
|
|
|
|
|
|
|
|
|
|
|
|
/**********验证工行上行网关RSA签名**********/
|
|
|
|
|
|
//回调接口
|
|
|
|
|
|
String path = "/assess/callback";
|
|
|
|
|
|
// WebUtils.buildOrderedSignStr(path, params);
|
|
|
|
|
|
String signStr;
|
|
|
|
|
|
String results = null;
|
|
|
|
|
|
String responseBizContent = null;
|
|
|
|
|
|
Map<String, Object> respMap = (Map<String, Object>) JSON.parse(biz_content);
|
|
|
|
|
|
|
|
|
|
|
|
responseBizContent = callbackHanldle(respMap);
|
|
|
|
|
|
|
|
|
|
|
|
//2、商户以RSA签名为例,如下:其中,priKey为商户私钥;
|
|
|
|
|
|
signStr = "\"response_biz_content\":" + responseBizContent + "," + "\"sign_type\":" + "\"RSA2\"";
|
|
|
|
|
|
// sang:注释icbc部分
|
|
|
|
|
|
// IcbcSignature.sign(signStr, "RSA2", PayService.MY_PRIVATE_KEY,
|
|
|
|
|
|
// charset);
|
|
|
|
|
|
sign = null;
|
|
|
|
|
|
results = "{" + signStr + ",\"sign\":\"" + sign + "\"}";
|
|
|
|
|
|
|
|
|
|
|
|
response.setContentType("application/json; charset=utf-8");
|
|
|
|
|
|
out = response.getWriter();
|
|
|
|
|
|
out.write(results);
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Throwable e) {
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
out.write(e.getMessage());
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
out.flush();
|
|
|
|
|
|
out.close();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public String callbackHanldle(Map<String, Object> respMap) {
|
|
|
|
|
|
String responseBizContent = "";
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
|
|
if (!respMap.get("return_code").toString().equals("0")) {
|
|
|
|
|
|
//支付失败
|
|
|
|
|
|
log.debug("-----------------支付失败-------------------");
|
|
|
|
|
|
|
|
|
|
|
|
//业务请求字段获取
|
|
|
|
|
|
String outTradeNo = (String) respMap.get("out_trade_no");
|
|
|
|
|
|
log.debug("outTradeNo" + outTradeNo);
|
|
|
|
|
|
|
|
|
|
|
|
//业务处理逻辑......
|
|
|
|
|
|
HsjcVo vo = new HsjcVo();
|
|
|
|
|
|
vo.setOrderno(outTradeNo);
|
|
|
|
|
|
|
|
|
|
|
|
//获取挂号信息
|
|
|
|
|
|
List<HsjcVo> list = hsjcMapper.getMzjfList(vo);
|
|
|
|
|
|
|
|
|
|
|
|
if (list.size() != 1) {
|
|
|
|
|
|
//没有查到
|
|
|
|
|
|
log.debug("没有对应订单号的记录");
|
|
|
|
|
|
} else {
|
|
|
|
|
|
//做消号操作
|
|
|
|
|
|
HsjcVo voCancel = new HsjcVo();
|
|
|
|
|
|
voCancel = list.get(0);
|
|
|
|
|
|
voCancel.setLocktype(-1);
|
|
|
|
|
|
// 封装xml
|
|
|
|
|
|
String strXML = MOP_OutpBillstoPayCreat(voCancel);
|
|
|
|
|
|
// // 发送soap请求
|
|
|
|
|
|
// String respXml = SoapUtil.soapMethod(strXML);
|
|
|
|
|
|
|
|
|
|
|
|
// 解析报文
|
|
|
|
|
|
Map<String, Object> map = XmlUtil.parse(strXML);
|
|
|
|
|
|
if (map.get("returncode").toString().equals("1")) {
|
|
|
|
|
|
|
|
|
|
|
|
//单据状态 0 正常 1 开具 2 已消号 3 挂号成功(待缴费) 4 已缴费 5 已退费
|
|
|
|
|
|
hsjcMapper.opUpdateOrderByHis(2, outTradeNo);
|
|
|
|
|
|
|
|
|
|
|
|
//推送消息给公众号
|
|
|
|
|
|
} else {
|
|
|
|
|
|
// throw new LogicException(map.get("errormsg").toString());
|
|
|
|
|
|
log.debug("消号返回 errormsg:" + map.get("errormsg").toString());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// responseBizContent = "{\"return_code\":-12345,\"return_msg\":\"" + respMap.get("return_msg") + "\"}";
|
|
|
|
|
|
//业务返回参数设置
|
|
|
|
|
|
int return_code = 0;
|
|
|
|
|
|
String return_msg = "success.";
|
|
|
|
|
|
String msg_id = respMap.get("msg_id").toString();
|
|
|
|
|
|
responseBizContent = "{\"return_code\":" + return_code + ",\"return_msg\":\"" + return_msg + "\",\"msg_id\":\"" + msg_id + "\","
|
|
|
|
|
|
+ "\"busi_param_rp\":\"thisisresponseparameter\"}";
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
log.debug("-----------------支付成功-------------------");
|
|
|
|
|
|
/**********合作方/分行 业务逻辑处理**********/
|
|
|
|
|
|
// @SuppressWarnings("unchecked")
|
|
|
|
|
|
|
|
|
|
|
|
String icbc_orderid = respMap.get("order_id").toString();
|
|
|
|
|
|
String icbc_paytime = respMap.get("pay_time").toString();
|
|
|
|
|
|
|
|
|
|
|
|
String msg_id = respMap.get("msg_id").toString();
|
|
|
|
|
|
//业务请求字段获取
|
|
|
|
|
|
String outTradeNo = (String) respMap.get("out_trade_no");
|
|
|
|
|
|
log.debug("outTradeNo:" + outTradeNo);
|
|
|
|
|
|
|
|
|
|
|
|
//业务处理逻辑......
|
|
|
|
|
|
HsjcVo vo = new HsjcVo();
|
|
|
|
|
|
vo.setOrderno(outTradeNo);
|
|
|
|
|
|
//获取挂号信息
|
|
|
|
|
|
List<HsjcVo> list = hsjcMapper.getMzjfList(vo);
|
|
|
|
|
|
if (list.size() == 1) {
|
|
|
|
|
|
vo = list.get(0);
|
|
|
|
|
|
log.debug("userid:" + vo.getUserId());
|
|
|
|
|
|
|
|
|
|
|
|
// 设置六位数支付订单号
|
|
|
|
|
|
String powerid = "HS" + VeDate.getNo(6);
|
|
|
|
|
|
|
|
|
|
|
|
// 封装xml
|
|
|
|
|
|
vo.setBillsmsg(vo.getFlowno());
|
|
|
|
|
|
vo.setPaynature("1");
|
|
|
|
|
|
vo.setPaytype("JHZF");
|
|
|
|
|
|
vo.setPowertranid(outTradeNo);
|
|
|
|
|
|
vo.setPowertrancard("");
|
|
|
|
|
|
vo.setTerminalid("0001");
|
|
|
|
|
|
vo.setReferno("");
|
|
|
|
|
|
vo.setZfamount(vo.getBillmoney());
|
|
|
|
|
|
// vo.setYbzhamount();
|
|
|
|
|
|
// vo.setYbtcamount();
|
|
|
|
|
|
vo.setYboutmsg("医保结算信息");
|
|
|
|
|
|
vo.setHisopernum("WX");
|
|
|
|
|
|
String respXml = MOP_OutpBillstoPayConfirm(vo);
|
|
|
|
|
|
// 解析报文
|
|
|
|
|
|
Map<String, Object> map = XmlUtil.parse(respXml);
|
|
|
|
|
|
|
|
|
|
|
|
if (map.get("returncode").toString().equals("1")) {
|
|
|
|
|
|
|
|
|
|
|
|
//允许退号标志 N 不允许 Y 允许
|
|
|
|
|
|
vo.setAppFlag("Y");
|
|
|
|
|
|
//单据状态 0 正常 1 开具 2 已消号 3 挂号成功(待缴费) 4 已缴费 5 已退费
|
|
|
|
|
|
vo.setAppStatus(4);
|
|
|
|
|
|
vo.setIcbcorderid(icbc_orderid);
|
|
|
|
|
|
vo.setIcbcpaytime(icbc_paytime);
|
|
|
|
|
|
|
|
|
|
|
|
hsjcMapper.opHsjcConfirmAppoint(vo);
|
|
|
|
|
|
|
|
|
|
|
|
UserVo voUser = userService.queryUserInfoDetails(vo.getUserId());
|
|
|
|
|
|
log.debug("get hsjc userid:" + voUser.getName());
|
|
|
|
|
|
|
|
|
|
|
|
String cardNo = vo.getPatientid();
|
|
|
|
|
|
List<UserCardVo> UCList = userCardMapper.queryUserCardListByCardno(cardNo);
|
|
|
|
|
|
log.debug("real name:" + UCList.get(0).getName());
|
|
|
|
|
|
|
|
|
|
|
|
//推送消息给公众号
|
|
|
|
|
|
log.debug("start push message");
|
|
|
|
|
|
txSendMsg.SendNotifyJF("缴费成功", voUser.getOpenid(), UCList.get(0).getName(), vo.getPatientid(),
|
|
|
|
|
|
vo.getBillmoney(), vo.getFlowno(), "u2MOIbFKkqSyhfZt2uZriiSRaIVMVhiu-Y4MzWS5p6Y");
|
|
|
|
|
|
log.debug("end push message");
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
//工行成功,HIS失败,需要原路返回退款
|
|
|
|
|
|
//查询his缴费状态,如果缴费正常,认为缴费是成功的
|
|
|
|
|
|
String inqResXml = MOP_OutpBillsStateQuery(outTradeNo);
|
|
|
|
|
|
// 解析报文
|
|
|
|
|
|
Map<String, Object> mapInq = XmlUtil.parse(inqResXml);
|
|
|
|
|
|
if (mapInq.get("returncode").toString().equals("1") &&
|
|
|
|
|
|
mapInq.get("FlowNo").toString().equals(vo.getFlowno())) {
|
|
|
|
|
|
log.debug("his confirm faile, but inq success");
|
|
|
|
|
|
//允许退号标志 N 不允许 Y 允许
|
|
|
|
|
|
vo.setAppFlag("Y");
|
|
|
|
|
|
//单据状态 0 正常 1 开具 2 已消号 3 挂号成功(待缴费) 4 已缴费 5 已退费
|
|
|
|
|
|
vo.setAppStatus(4);
|
|
|
|
|
|
vo.setIcbcorderid(icbc_orderid);
|
|
|
|
|
|
vo.setIcbcpaytime(icbc_paytime);
|
|
|
|
|
|
|
|
|
|
|
|
hsjcMapper.opHsjcConfirmAppoint(vo);
|
|
|
|
|
|
|
|
|
|
|
|
UserVo voUser = userService.queryUserInfoDetails(vo.getUserId());
|
|
|
|
|
|
log.debug("get hsjc userid:" + voUser.getName());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String cardNo = vo.getPatientid();
|
|
|
|
|
|
List<UserCardVo> UCList = userCardMapper.queryUserCardListByCardno(cardNo);
|
|
|
|
|
|
log.debug("real name:" + UCList.get(0).getName());
|
|
|
|
|
|
|
|
|
|
|
|
//推送消息给公众号
|
|
|
|
|
|
log.debug("start push message");
|
|
|
|
|
|
txSendMsg.SendNotifyJF("缴费成功", voUser.getOpenid(), UCList.get(0).getName(), vo.getPatientid(),
|
|
|
|
|
|
vo.getBillmoney(), vo.getFlowno(), "u2MOIbFKkqSyhfZt2uZriiSRaIVMVhiu-Y4MzWS5p6Y");
|
|
|
|
|
|
log.debug("end push message");
|
|
|
|
|
|
} else {
|
|
|
|
|
|
//做消号操作
|
|
|
|
|
|
HsjcVo voCancel = new HsjcVo();
|
|
|
|
|
|
voCancel = list.get(0);
|
|
|
|
|
|
voCancel.setLocktype(-1);
|
|
|
|
|
|
// 封装xml
|
|
|
|
|
|
String strXML = MOP_OutpBillstoPayCreat(voCancel);
|
|
|
|
|
|
// // 发送soap请求
|
|
|
|
|
|
// String resp1Xml = SoapUtil.soapMethod(strXML);
|
|
|
|
|
|
|
|
|
|
|
|
// 解析报文
|
|
|
|
|
|
Map<String, Object> mapCancel = XmlUtil.parse(strXML);
|
|
|
|
|
|
if (mapCancel.get("returncode").toString().equals("1")) {
|
|
|
|
|
|
|
|
|
|
|
|
//单据状态 0 正常 1 开具 2 已消号 3 挂号成功(待缴费) 4 已缴费 5 已退费
|
|
|
|
|
|
hsjcMapper.opUpdateOrderByHis(2, outTradeNo);
|
|
|
|
|
|
|
|
|
|
|
|
//自动退费
|
|
|
|
|
|
log.debug("his failed, auto-refund:" + vo.getBillmoney() + " orderno:" + outTradeNo);
|
|
|
|
|
|
// String ret = payService.refundHis(Double.valueOf(vo.getBillmoney()), outTradeNo);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
// throw new LogicException(mapCancel.get("errormsg").toString());
|
|
|
|
|
|
log.debug("消号返回 errormsg:" + map.get("errormsg").toString());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
log.debug("list size:" + list.size());
|
|
|
|
|
|
}
|
|
|
|
|
|
//业务返回参数设置
|
|
|
|
|
|
int return_code = 0;
|
|
|
|
|
|
String return_msg = "success.";
|
|
|
|
|
|
responseBizContent = "{\"return_code\":" + return_code + ",\"return_msg\":\"" + return_msg + "\",\"msg_id\":\"" + msg_id + "\","
|
|
|
|
|
|
+ "\"busi_param_rp\":\"thisisresponseparameter\"}";
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (Throwable e) {
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
}
|
|
|
|
|
|
return responseBizContent;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public int SendNotifyJF(String Title, String userOpenid, String username, String patienid, String amount, String kahao, String templateId) {
|
|
|
|
|
|
log.debug("in param:Title|" + Title + " userOpenid|" + userOpenid + " username|" + username + " patienid|" +
|
|
|
|
|
|
patienid + " amount|" + amount + " kahao|" + kahao + " templateId|" + templateId);
|
|
|
|
|
|
|
|
|
|
|
|
//第一步 获取token
|
|
|
|
|
|
String accessUrl = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&" +
|
|
|
|
|
|
"&appid=" + WX_APP_ID + "&secret=" + WX_SECRET;
|
|
|
|
|
|
String accessTokenStr = HttpClientUtil.doGet(accessUrl, null);
|
|
|
|
|
|
log.debug("step 1 get accesstoken:" + accessTokenStr);
|
|
|
|
|
|
|
|
|
|
|
|
JSONObject jsonObject = JSON.parseObject(accessTokenStr);
|
|
|
|
|
|
String accessToken = jsonObject.get("access_token").toString();
|
|
|
|
|
|
|
|
|
|
|
|
//第三步 发送模板消息
|
|
|
|
|
|
// 行业医疗护理
|
|
|
|
|
|
// 详细内容{{first.DATA}}
|
|
|
|
|
|
// 姓名:{{keyword1.DATA}}
|
|
|
|
|
|
// 卡号:{{keyword2.DATA}}
|
|
|
|
|
|
// 金额:{{keyword3.DATA}}
|
|
|
|
|
|
// 收费单:{{keyword4.DATA}}
|
|
|
|
|
|
// {{remark.DATA}}
|
|
|
|
|
|
|
|
|
|
|
|
String sendUrl = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + accessToken;
|
|
|
|
|
|
JSONObject sendPara = new JSONObject();
|
|
|
|
|
|
JSONObject dataPara = new JSONObject();
|
|
|
|
|
|
|
|
|
|
|
|
JSONObject first = new JSONObject();
|
|
|
|
|
|
first.put("value", Title);
|
|
|
|
|
|
first.put("color", "#173177");
|
|
|
|
|
|
|
|
|
|
|
|
JSONObject key1 = new JSONObject();
|
|
|
|
|
|
key1.put("value", username);
|
|
|
|
|
|
key1.put("color", "#173177");
|
|
|
|
|
|
|
|
|
|
|
|
JSONObject key2 = new JSONObject();
|
|
|
|
|
|
key2.put("value", patienid);
|
|
|
|
|
|
key2.put("color", "#173177");
|
|
|
|
|
|
|
|
|
|
|
|
JSONObject key3 = new JSONObject();
|
|
|
|
|
|
key3.put("value", amount);
|
|
|
|
|
|
key3.put("color", "#173177");
|
|
|
|
|
|
|
|
|
|
|
|
JSONObject key4 = new JSONObject();
|
|
|
|
|
|
key4.put("value", kahao);
|
|
|
|
|
|
key4.put("color", "#173177");
|
|
|
|
|
|
JSONObject remark = new JSONObject();
|
|
|
|
|
|
remark.put("value", "");
|
|
|
|
|
|
remark.put("color", "#173177");
|
|
|
|
|
|
|
|
|
|
|
|
dataPara.put("first", first);
|
|
|
|
|
|
dataPara.put("keyword1", key1);
|
|
|
|
|
|
dataPara.put("keyword2", key2);
|
|
|
|
|
|
dataPara.put("keyword3", key3);
|
|
|
|
|
|
dataPara.put("keyword4", key4);
|
|
|
|
|
|
dataPara.put("remark", remark);
|
|
|
|
|
|
|
|
|
|
|
|
sendPara.put("touser", userOpenid);
|
|
|
|
|
|
sendPara.put("template_id", templateId);
|
|
|
|
|
|
sendPara.put("url", "http://wx.btdbyy.cn:9081/jojugongzhonghao/#/Member_wdzd");
|
|
|
|
|
|
sendPara.put("data", dataPara);
|
|
|
|
|
|
String sendRes = HttpClientUtil.doPost(sendUrl, sendPara);
|
|
|
|
|
|
log.debug("step 2 send notify:" + sendRes);
|
|
|
|
|
|
|
|
|
|
|
|
JSONObject jsonSend = JSON.parseObject(sendRes);
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// @Async("asyncServiceExecutor")
|
|
|
|
|
|
public void zjcallback(HttpServletRequest request, HttpServletResponse response) {
|
|
|
|
|
|
PrintWriter out = null;
|
|
|
|
|
|
try {
|
|
|
|
|
|
log.debug("enter the ICBC hsjc zjcallback");
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, String> params = new HashMap<String, String>();
|
|
|
|
|
|
String from = request.getParameter("from");
|
|
|
|
|
|
String api = request.getParameter("api");
|
|
|
|
|
|
String app_id = request.getParameter("app_id");
|
|
|
|
|
|
String charset = request.getParameter("charset");
|
|
|
|
|
|
String format = request.getParameter("format");
|
|
|
|
|
|
String encrypt_type = request.getParameter("encrypt_type");
|
|
|
|
|
|
String timestamp = request.getParameter("timestamp");
|
|
|
|
|
|
String biz_content = request.getParameter("biz_content");
|
|
|
|
|
|
String sign_type = request.getParameter("sign_type");
|
|
|
|
|
|
String sign = request.getParameter("sign");
|
|
|
|
|
|
log.debug("from:" + from);
|
|
|
|
|
|
log.debug("api:" + api);
|
|
|
|
|
|
log.debug("app_id:" + app_id);
|
|
|
|
|
|
log.debug("charset:" + charset);
|
|
|
|
|
|
log.debug("format:" + format);
|
|
|
|
|
|
log.debug("encrypt_type:" + encrypt_type);
|
|
|
|
|
|
log.debug("timestamp:" + timestamp);
|
|
|
|
|
|
log.debug("biz_content:" + biz_content);
|
|
|
|
|
|
log.debug("sign_type:" + sign_type);
|
|
|
|
|
|
log.debug("sign:" + sign);
|
|
|
|
|
|
|
|
|
|
|
|
params.put("from", from);
|
|
|
|
|
|
params.put("api", api);
|
|
|
|
|
|
params.put("app_id", app_id);
|
|
|
|
|
|
params.put("charset", charset);
|
|
|
|
|
|
params.put("format", format);
|
|
|
|
|
|
params.put("encrypt_type", encrypt_type);
|
|
|
|
|
|
params.put("timestamp", timestamp);
|
|
|
|
|
|
params.put("biz_content", biz_content);
|
|
|
|
|
|
params.put("sign_type", sign_type);//目前上行网关签名暂时仅支持RSA
|
|
|
|
|
|
|
|
|
|
|
|
/**********验证工行上行网关RSA签名**********/
|
|
|
|
|
|
//回调接口
|
|
|
|
|
|
String path = "/assess/zjcallback";
|
|
|
|
|
|
// WebUtils.buildOrderedSignStr(path, params);
|
|
|
|
|
|
String signStr;
|
|
|
|
|
|
String results = null;
|
|
|
|
|
|
String responseBizContent = null;
|
|
|
|
|
|
Map<String, Object> respMap = (Map<String, Object>) JSON.parse(biz_content);
|
|
|
|
|
|
if (!respMap.get("return_code").toString().equals("0")) {
|
|
|
|
|
|
//支付失败
|
|
|
|
|
|
log.debug("-----------------支付失败-------------------");
|
|
|
|
|
|
|
|
|
|
|
|
//业务请求字段获取
|
|
|
|
|
|
String outTradeNo = (String) respMap.get("out_trade_no");
|
|
|
|
|
|
log.debug("outTradeNo" + outTradeNo + " payment failed");
|
|
|
|
|
|
|
|
|
|
|
|
//业务处理逻辑......
|
|
|
|
|
|
// responseBizContent = "{\"return_code\":-12345,\"return_msg\":\"" + respMap.get("return_msg") + "\"}";
|
|
|
|
|
|
|
|
|
|
|
|
//业务返回参数设置
|
|
|
|
|
|
int return_code = 0;
|
|
|
|
|
|
String return_msg = "success.";
|
|
|
|
|
|
String msg_id = respMap.get("msg_id").toString();
|
|
|
|
|
|
responseBizContent = "{\"return_code\":" + return_code + ",\"return_msg\":\"" + return_msg + "\",\"msg_id\":\"" + msg_id + "\","
|
|
|
|
|
|
+ "\"busi_param_rp\":\"thisisresponseparameter\"}";
|
|
|
|
|
|
} else {
|
|
|
|
|
|
log.debug("-----------------支付成功-------------------");
|
|
|
|
|
|
/**********合作方/分行 业务逻辑处理**********/
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
|
|
|
|
|
|
|
|
String icbc_orderid = respMap.get("order_id").toString();
|
|
|
|
|
|
String icbc_paytime = respMap.get("pay_time").toString();
|
|
|
|
|
|
String msg_id = respMap.get("msg_id").toString();
|
|
|
|
|
|
//业务请求字段获取
|
|
|
|
|
|
String outTradeNo = (String) respMap.get("out_trade_no");
|
|
|
|
|
|
log.debug("outTradeNo:" + outTradeNo + " start MOP_OutpBillstoPayConfirm");
|
|
|
|
|
|
|
|
|
|
|
|
paybills(outTradeNo, icbc_orderid, icbc_paytime);
|
|
|
|
|
|
|
|
|
|
|
|
//业务返回参数设置
|
|
|
|
|
|
int return_code = 0;
|
|
|
|
|
|
String return_msg = "success.";
|
|
|
|
|
|
responseBizContent = "{\"return_code\":" + return_code + ",\"return_msg\":\"" + return_msg + "\",\"msg_id\":\"" + msg_id + "\","
|
|
|
|
|
|
+ "\"busi_param_rp\":\"thisisresponseparameter\"}";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//2、商户以RSA签名为例,如下:其中,priKey为商户私钥;
|
|
|
|
|
|
signStr = "\"response_biz_content\":" + responseBizContent + "," + "\"sign_type\":" + "\"RSA2\"";
|
|
|
|
|
|
// sang:注释icbc部分
|
|
|
|
|
|
// IcbcSignature.sign(signStr, "RSA2", PayService.MY_PRIVATE_KEY,
|
|
|
|
|
|
// charset);
|
|
|
|
|
|
sign = null;
|
|
|
|
|
|
results = "{" + signStr + ",\"sign\":\"" + sign + "\"}";
|
|
|
|
|
|
|
|
|
|
|
|
response.setContentType("application/json; charset=utf-8");
|
|
|
|
|
|
out = response.getWriter();
|
|
|
|
|
|
out.write(results);
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Throwable e) {
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
out.write(e.getMessage());
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
out.flush();
|
|
|
|
|
|
out.close();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public String paybills(String outTradeNo, String icbc_orderid, String icbc_paytime) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
//业务处理逻辑......
|
|
|
|
|
|
HsjcVo vo = new HsjcVo();
|
|
|
|
|
|
vo.setOrderno(outTradeNo);
|
|
|
|
|
|
//通过orderno获取待缴费信息
|
|
|
|
|
|
List<HsjcVo> list = hsjcMapper.getMzjfListByFlow(vo);
|
|
|
|
|
|
BigDecimal bdBillAmount = BigDecimal.valueOf(0);
|
|
|
|
|
|
BigDecimal bdBillAmountMid = BigDecimal.valueOf(0);
|
|
|
|
|
|
DecimalFormat formatAmt = new DecimalFormat("###.00");
|
|
|
|
|
|
String billMsg = "";
|
|
|
|
|
|
String updateDate = "";
|
|
|
|
|
|
log.debug("unpay order: " + outTradeNo + " count:" + list.size());
|
|
|
|
|
|
|
|
|
|
|
|
for (int j = 0; j < list.size(); j++) {
|
|
|
|
|
|
|
|
|
|
|
|
if (j == (list.size() - 1)) {
|
|
|
|
|
|
billMsg += list.get(j).getFlowno();
|
|
|
|
|
|
|
|
|
|
|
|
if (list.get(j).getUpdatedate() == null || "".equals(list.get(j).getUpdatedate())) {
|
|
|
|
|
|
updateDate += list.get(j).getBilltime();
|
|
|
|
|
|
} else {
|
|
|
|
|
|
updateDate += list.get(j).getUpdatedate();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
billMsg += list.get(j).getFlowno() + ",";
|
|
|
|
|
|
|
|
|
|
|
|
if (list.get(j).getUpdatedate() == null || "".equals(list.get(j).getUpdatedate())) {
|
|
|
|
|
|
updateDate += list.get(j).getBilltime() + ",";
|
|
|
|
|
|
} else {
|
|
|
|
|
|
updateDate += list.get(j).getUpdatedate() + ",";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bdBillAmountMid = new BigDecimal(list.get(j).getBillmoney());
|
|
|
|
|
|
bdBillAmount = bdBillAmount.add(bdBillAmountMid);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 设置六位数支付订单号
|
|
|
|
|
|
String powerid = "HS" + VeDate.getNo(6);
|
|
|
|
|
|
String billMoney = bdBillAmount.toPlainString();
|
|
|
|
|
|
|
|
|
|
|
|
//单据集合用,分隔
|
|
|
|
|
|
vo.setBillsmsg(billMsg);
|
|
|
|
|
|
|
|
|
|
|
|
vo.setUserId(list.get(0).getUserId());
|
|
|
|
|
|
vo.setPatientid(list.get(0).getPatientid());
|
|
|
|
|
|
vo.setUpdatedate(updateDate);
|
|
|
|
|
|
|
|
|
|
|
|
vo.setPaynature("1");
|
|
|
|
|
|
vo.setPaytype("JHZF");
|
|
|
|
|
|
vo.setPowertranid(outTradeNo);
|
|
|
|
|
|
vo.setPowertrancard("");
|
|
|
|
|
|
vo.setTerminalid("0001");
|
|
|
|
|
|
vo.setReferno("");
|
|
|
|
|
|
//金额是总金额
|
|
|
|
|
|
vo.setZfamount(billMoney);
|
|
|
|
|
|
// vo.setYbzhamount();
|
|
|
|
|
|
// vo.setYbtcamount();
|
|
|
|
|
|
vo.setYboutmsg("医保结算信息");
|
|
|
|
|
|
vo.setHisopernum("WX");
|
|
|
|
|
|
String respXml = MOP_OutpBillstoPayConfirm(vo);
|
|
|
|
|
|
// 解析报文
|
|
|
|
|
|
Map<String, Object> map = XmlUtil.parse(respXml);
|
|
|
|
|
|
if (map.get("returncode").toString().equals("1")) {
|
|
|
|
|
|
|
|
|
|
|
|
//允许退号标志 N 不允许 Y 允许·
|
|
|
|
|
|
vo.setAppFlag("Y");
|
|
|
|
|
|
//单据状态 1 已退费 0 正常 2 已消号 3 挂号成功 4 已缴费
|
|
|
|
|
|
vo.setAppStatus(4);
|
|
|
|
|
|
vo.setIcbcorderid(icbc_orderid);
|
|
|
|
|
|
vo.setIcbcpaytime(icbc_paytime);
|
|
|
|
|
|
|
|
|
|
|
|
hsjcMapper.opHsjcConfirmAppoint(vo);
|
|
|
|
|
|
|
|
|
|
|
|
UserVo voUser = userService.queryUserInfoDetails(vo.getUserId());
|
|
|
|
|
|
log.debug("get hsjc userid:" + voUser.getName());
|
|
|
|
|
|
|
|
|
|
|
|
String cardNo = vo.getPatientid();
|
|
|
|
|
|
List<UserCardVo> UCList = userCardMapper.queryUserCardListByCardno(cardNo);
|
|
|
|
|
|
log.debug("real name:" + UCList.get(0).getName());
|
|
|
|
|
|
//推送消息给公众号
|
|
|
|
|
|
txSendMsg.SendNotifyJF("缴费成功", voUser.getOpenid(), UCList.get(0).getName(), vo.getPatientid(),
|
|
|
|
|
|
billMoney, billMsg, "u2MOIbFKkqSyhfZt2uZriiSRaIVMVhiu-Y4MzWS5p6Y");
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
//throw new LogicException(map.get("errormsg").toString());
|
|
|
|
|
|
log.debug("errormsg:" + map.get("errormsg").toString());
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (DocumentException e) {
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return "success";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|