Browse Source

医保日志入库

lighter 3 years ago
parent
commit
2158438e1e

+ 9 - 0
src/main/java/thyyxxk/simzfeeoprnsystm/dao/SiLogDao.java

@@ -0,0 +1,9 @@
+package thyyxxk.simzfeeoprnsystm.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+import thyyxxk.simzfeeoprnsystm.pojo.SiLog;
+
+@Mapper
+public interface SiLogDao extends BaseMapper<SiLog> {
+}

+ 84 - 0
src/main/java/thyyxxk/simzfeeoprnsystm/pojo/SiLog.java

@@ -0,0 +1,84 @@
+package thyyxxk.simzfeeoprnsystm.pojo;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+@TableName("t_si_log")
+public class SiLog implements Serializable {
+
+	private static final long serialVersionUID =  3109706338397960444L;
+
+	/**
+	 * 报文ID
+	 */
+	@TableId(type=IdType.ASSIGN_UUID)
+	private String msgid;
+
+	/**
+	 * 功能号
+	 */
+	private String infno;
+
+	/**
+	 * 参保地医保区划
+	 */
+	private String insuplcAdmdvs;
+
+	/**
+	 * 经办人
+	 */
+	private String opter;
+
+	/**
+	 * 交易输入
+	 */
+	private String body;
+
+	/**
+	 * 交易输出
+	 */
+	private String result;
+
+	/**
+	 * 住院号/门诊号
+	 */
+	private String patNo;
+
+	/**
+	 * 住院/门诊次数
+	 */
+	private Integer times;
+
+	/**
+	 * 账页号
+	 */
+	private Integer ledgerSn;
+
+	/**
+	 * 日志类别:1-住院;2-门诊
+	 * */
+	private Integer logType;
+
+	private Integer infcode;
+
+	public SiLog(JSONObject input, JSONObject result, String patNo, Integer times, Integer infcode) {
+		if (null != result) {
+			setResult(result.toJSONString());
+		}
+		setBody(input.toJSONString());
+		setInfno(input.getString("infno"));
+		setInsuplcAdmdvs(input.getString("insuplc_admdvs"));
+		setMsgid(input.getString("msgid"));
+		setOpter(input.getString("opter"));
+		setPatNo(patNo);
+		setTimes(times);
+		setLogType(2);
+		setInfcode(infcode);
+	}
+}

+ 35 - 16
src/main/java/thyyxxk/simzfeeoprnsystm/service/SiMzFeeService.java

@@ -3,6 +3,7 @@ package thyyxxk.simzfeeoprnsystm.service;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import thyyxxk.simzfeeoprnsystm.dao.SiLogDao;
 import thyyxxk.simzfeeoprnsystm.dao.SiMzDao;
 import thyyxxk.simzfeeoprnsystm.dao.SiSetldetailDao;
 import thyyxxk.simzfeeoprnsystm.dao.SiSetlinfoDao;
@@ -29,13 +30,16 @@ public class SiMzFeeService {
     private static final String RESULT_CODE = "infcode";
     private static final String ERROR_MESSAGE = "err_msg";
     private static final String OUTPUT = "output";
+    private final SiLogDao logDao;
 
     @Autowired
-    public SiMzFeeService(SiMzDao mzDao, SiSetlinfoDao setlinfoDao, SiSetldetailDao setldetailDao, ExecService exec) {
+    public SiMzFeeService(SiMzDao mzDao, SiSetlinfoDao setlinfoDao,
+                          SiSetldetailDao setldetailDao, ExecService exec, SiLogDao logDao) {
         this.mzDao = mzDao;
         this.setlinfoDao = setlinfoDao;
         this.setldetailDao = setldetailDao;
         this.exec = exec;
+        this.logDao = logDao;
     }
 
     public ResultVo<String> outpatientRegistration(MzPatientInfo p) {
@@ -56,10 +60,12 @@ public class SiMzFeeService {
         if (null == result) {
             return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
         }
-        if (null == result.getInteger(RESULT_CODE)) {
+        Integer infcode = result.getInteger(RESULT_CODE);
+        logDao.insert(new SiLog(input, result, p.getPatNo(), p.getTimes(), infcode));
+        if (null == infcode) {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
         }
-        if (result.getIntValue(RESULT_CODE) == 0) {
+        if (infcode == 0) {
             JSONObject output = result.getJSONObject(OUTPUT).getJSONObject("data");
             p.setMdtrtId(output.getString("mdtrt_id"));
             p.setVisitDate(regstrtn.getBegntime());
@@ -89,10 +95,12 @@ public class SiMzFeeService {
         if (null == result) {
             return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
         }
-        if (null == result.getInteger(RESULT_CODE)) {
+        Integer infcode = result.getInteger(RESULT_CODE);
+        logDao.insert(new SiLog(input, result, p.getPatNo(), p.getTimes(), infcode));
+        if (null == infcode) {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
         }
-        if (result.getIntValue(RESULT_CODE) == 0) {
+        if (infcode == 0) {
             mzDao.clearMdtrtIdForMz(p.getPatNo(), p.getTimes(), null);
             return ResultVoUtil.success("取消门诊挂号成功。");
         }
@@ -132,6 +140,8 @@ public class SiMzFeeService {
         input.getJSONObject("input").put("diseinfo", JSONArray.parse(ref));
         JSONObject result = exec.executeTrade(input, SiFunction.UPLOAD_OUTPATIENT_INFO);
         log.info("【操作员:{}】门诊就诊信息上传:\n参数:{},\n结果:{}", staffId, input, result);
+        Integer infcode = result.getInteger(RESULT_CODE);
+        logDao.insert(new SiLog(input, result, p.getPatNo(), p.getTimes(), infcode));
         return SiUtil.makeReturnWithoutOutput(result, "门诊就诊信息上传成功。");
     }
 
@@ -174,10 +184,12 @@ public class SiMzFeeService {
         if (null == result) {
             return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
         }
-        if (null == result.getInteger(RESULT_CODE)) {
+        Integer infcode = result.getInteger(RESULT_CODE);
+        logDao.insert(new SiLog(input, result, p.getPatNo(), p.getTimes(), infcode));
+        if (null == infcode) {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
         }
-        if (result.getIntValue(RESULT_CODE) == 0) {
+        if (infcode == 0) {
             JSONArray feeRes = result.getJSONObject(OUTPUT).getJSONArray("result");
             double fulamtOwnpayAmt = 0d;
             double overlmtAmt = 0d;
@@ -215,7 +227,6 @@ public class SiMzFeeService {
             p.setTimes(mzDao.selectMaxTimes(p.getPatNo()));
         }
         SiPatInfo siPatInfo = mzDao.selectSiPatInfoForMz(p.getPatNo(), p.getTimes());
-        log.info("patNo: {}, times: {}, sipatinfo: {}", p.getPatNo(), p.getTimes(), siPatInfo);
         if (null == siPatInfo || StringUtil.isBlank(siPatInfo.getMdtrtId())) {
             return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "没有此患者的医保挂号信息!");
         }
@@ -231,10 +242,12 @@ public class SiMzFeeService {
         if (null == result) {
             return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
         }
-        if (null == result.getInteger(RESULT_CODE)) {
+        Integer infcode = result.getInteger(RESULT_CODE);
+        logDao.insert(new SiLog(input, result, p.getPatNo(), p.getTimes(), infcode));
+        if (null == infcode) {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
         }
-        if (result.getIntValue(RESULT_CODE) == 0) {
+        if (infcode == 0) {
             mzDao.afterRevokeFees(p.getPatNo(), p.getTimes());
             return ResultVoUtil.success("门诊费用明细信息撤销成功。");
         }
@@ -262,10 +275,12 @@ public class SiMzFeeService {
         if (null == result) {
             return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
         }
-        if (null == result.getInteger(RESULT_CODE)) {
+        Integer infcode = result.getInteger(RESULT_CODE);
+        logDao.insert(new SiLog(input, result, p.getPatNo(), p.getTimes(), infcode));
+        if (null == infcode) {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
         }
-        if (result.getIntValue(RESULT_CODE) == 0) {
+        if (infcode == 0) {
             int mtPartCount = mzDao.selectMtPartCount(p.getPatNo(), p.getTimes());
             if (mtPartCount == 0) {
                 MtPartInfo mtinfo = new MtPartInfo();
@@ -327,10 +342,12 @@ public class SiMzFeeService {
         if (null == result) {
             return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR, "与医保中心的连接出现网络异常!");
         }
-        if (null == result.getInteger(RESULT_CODE)) {
+        Integer infcode = result.getInteger(RESULT_CODE);
+        logDao.insert(new SiLog(input, result, p.getPatNo(), p.getTimes(), infcode));
+        if (null == infcode) {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
         }
-        if (result.getIntValue(RESULT_CODE) == 0) {
+        if (infcode == 0) {
             JSONObject setlinfo = result.getJSONObject(OUTPUT).getJSONObject("setlinfo");
             SiSetlinfo setlEntity = JSONObject.parseObject(setlinfo.toJSONString(), SiSetlinfo.class);
             setlEntity.setPatNo(p.getPatNo());
@@ -380,10 +397,12 @@ public class SiMzFeeService {
         if (null == result) {
             return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
         }
-        if (null == result.getInteger(RESULT_CODE)) {
+        Integer infcode = result.getInteger(RESULT_CODE);
+        logDao.insert(new SiLog(input, result, p.getPatNo(), p.getTimes(), infcode));
+        if (null == infcode) {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
         }
-        if (result.getIntValue(RESULT_CODE) == 0) {
+        if (infcode == 0) {
             mzDao.deleteSetlInfo(p.getPatNo(), p.getTimes());
             mzDao.deleteSetlDetail(p.getPatNo(), p.getTimes());
             mzDao.updateRvkSetlMsgid(p.getPatNo(), p.getTimes(), input.getString("msgid"));