Browse Source

Merge branch 'dev-1.0.4' into dev-1.0.5

hurugang 5 years ago
parent
commit
01d778c44a

+ 6 - 0
src/main/java/cn/hnthyy/thmz/controller/MzReceiptSerialController.java

@@ -4,6 +4,7 @@ import cn.hnthyy.thmz.Utils.NumberToCN;
 import cn.hnthyy.thmz.Utils.TokenUtil;
 import cn.hnthyy.thmz.comment.UserLoginToken;
 import cn.hnthyy.thmz.common.Constants;
+import cn.hnthyy.thmz.entity.MzException;
 import cn.hnthyy.thmz.entity.his.*;
 import cn.hnthyy.thmz.entity.thmz.User;
 import cn.hnthyy.thmz.enums.YesNoEnum;
@@ -187,6 +188,11 @@ public class MzReceiptSerialController {
             resultMap.put("mzPatientMi", mzPatientMi);
             log.info("病人id=" + patientId + ",times=" + times + "的发票已经预打印了");
             return resultMap;
+        } catch (MzException e) {
+            resultMap.put("code", -1);
+            resultMap.put("message", e.getMessage());
+            log.error("打印发票失败,系统异常,错误信息{}", e);
+            return resultMap;
         } catch (Exception e) {
             e.printStackTrace();
             resultMap.put("code", -1);

+ 2 - 0
src/main/java/cn/hnthyy/thmz/entity/his/MzReceiptSerial.java

@@ -107,6 +107,8 @@ public class MzReceiptSerial implements Serializable {
     private Integer totalCount;
     //病人姓名
     private String name;
+    //做版本控制,防止发票号被并发修改
+    private String bz;
     public void setCharge1(BigDecimal charge1) {
         this.charge1 = charge1;
         if(totalCharge==null){

+ 9 - 0
src/main/java/cn/hnthyy/thmz/mapper/his/MzReceiptSerialMapper.java

@@ -210,6 +210,15 @@ public interface MzReceiptSerialMapper {
     int updateMzReceiptSerial(MzReceiptSerial mzReceiptSerial);
 
 
+    /**
+     * 修改发票表备注字段 实际是为了防止已经打了发票继续打发票 根据收费次数
+     *
+     * @param mzReceiptSerial
+     * @return
+     */
+    @Update("update mz_receipt_serial set bz =1 where patient_id = #{patientId} and times=#{times} and receipt_no=#{receiptNo} and cheque_type=#{chequeType}  and bz is null")
+    int updateBzByReceiptNo(MzReceiptSerial mzReceiptSerial);
+
     /**
      * 修改发票表 根据收费次数
      *

+ 22 - 17
src/main/java/cn/hnthyy/thmz/service/impl/his/MzReceiptSerialServiceImpl.java

@@ -22,6 +22,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Isolation;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
+
 import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.Date;
@@ -88,23 +89,23 @@ public class MzReceiptSerialServiceImpl implements MzReceiptSerialService {
     }
 
     @Override
-    public MzReceiptSerial queryAllSerialForThisTime(String patientId, Integer times,Integer receiptNo) {
-        return mzReceiptSerialMapper.selectAllSerialForThisTime(patientId, times,receiptNo);
+    public MzReceiptSerial queryAllSerialForThisTime(String patientId, Integer times, Integer receiptNo) {
+        return mzReceiptSerialMapper.selectAllSerialForThisTime(patientId, times, receiptNo);
     }
 
     @Override
-    public List<MzReceiptSerial> queryPrintedSerialForThisTime(String patientId, Integer times,String receiptBill) {
-        return mzReceiptSerialMapper.selectPrintedSerialForThisTime(patientId, times,receiptBill);
+    public List<MzReceiptSerial> queryPrintedSerialForThisTime(String patientId, Integer times, String receiptBill) {
+        return mzReceiptSerialMapper.selectPrintedSerialForThisTime(patientId, times, receiptBill);
     }
 
     @Override
-    public List<MzReceiptSerial> queryTallyReceiptSerialByIdAndTimes(String patientId, Integer times,Integer receiptNo) {
-        return mzReceiptSerialMapper.selectTallyReceiptSerialByIdAndTimes(patientId, times,receiptNo);
+    public List<MzReceiptSerial> queryTallyReceiptSerialByIdAndTimes(String patientId, Integer times, Integer receiptNo) {
+        return mzReceiptSerialMapper.selectTallyReceiptSerialByIdAndTimes(patientId, times, receiptNo);
     }
 
     @Override
     @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, timeout = 36000, rollbackFor = Exception.class)
-    public String printReceiptSerial(MzReceiptSerial mzReceiptSerial,User user) throws MzException {
+    public String printReceiptSerial(MzReceiptSerial mzReceiptSerial, User user) throws MzException {
         Receipt receipt = receiptMapper.selectByUserIdCode(user.getUserIdCode());
         if (receipt == null || StringUtils.isBlank(receipt.getReceiptCurrent())) {
             throw new MzException("用户id=" + user.getUserName() + "没有可用的发票,请先维护发票。");
@@ -116,20 +117,24 @@ public class MzReceiptSerialServiceImpl implements MzReceiptSerialService {
         updateMzReceiptSerial.setReceiptBill(receipt.getReceiptCurrent());
         updateMzReceiptSerial.setOperatorId(user.getUserIdCode());
         updateMzReceiptSerial.setPayId(mzReceiptSerial.getOperatorId());
-        if(mzReceiptSerial.getDcountDate()!=null){
+        if (mzReceiptSerial.getDcountDate() != null) {
             //日结不为空,说明是手机自助缴费且已经日结过了,需要将原来日结时间设置到缴费日结字段,因为发票打印成功会重置原来的日结时间和日结状态
             updateMzReceiptSerial.setChargeDcountDate(mzReceiptSerial.getDcountDate());
             updateMzReceiptSerial.setChargeDcountNo(mzReceiptSerial.getDcountNo());
         }
         //如果是手机缴费,设置缴费方式为自助缴费
-        if(Constants.BRZZJF_CODE.equals(mzReceiptSerial.getOperatorId()) && Constants.BYJZ.equals(mzReceiptSerial.getChequeType())){
-            MzDepositFile mzDepositFile=mzDepositFileMapper.selectMzDepositFileBySerialNo(mzReceiptSerial.getSerialNo()).get(0);
-            if(Constants.WX.equals(mzDepositFile.getChequeType())){
+        if (Constants.BRZZJF_CODE.equals(mzReceiptSerial.getOperatorId()) && Constants.BYJZ.equals(mzReceiptSerial.getChequeType())) {
+            MzDepositFile mzDepositFile = mzDepositFileMapper.selectMzDepositFileBySerialNo(mzReceiptSerial.getSerialNo()).get(0);
+            if (Constants.WX.equals(mzDepositFile.getChequeType())) {
                 updateMzReceiptSerial.setNewChequeType(Constants.ZZWX);
-            }else if(Constants.ZFB.equals(mzDepositFile.getChequeType())){
+            } else if (Constants.ZFB.equals(mzDepositFile.getChequeType())) {
                 updateMzReceiptSerial.setNewChequeType(Constants.ZZZFB);
             }
-            mzDepositFileMapper.updateChequeType(updateMzReceiptSerial.getNewChequeType(),mzDepositFile.getReceiptSn());
+            mzDepositFileMapper.updateChequeType(updateMzReceiptSerial.getNewChequeType(), mzDepositFile.getReceiptSn());
+        }
+        int num = mzReceiptSerialMapper.updateBzByReceiptNo(updateMzReceiptSerial);
+        if (num == 0) {
+            throw new MzException("已经打印过发票,请勿重复打印,如果需要重新打印,请点击重新打印或者作废打印");
         }
         mzReceiptSerialMapper.updateMzReceiptSerialByReceiptNo(updateMzReceiptSerial);
         if (receipt.getReceiptCurrent() == receipt.getReceiptEnd()) {
@@ -168,7 +173,7 @@ public class MzReceiptSerialServiceImpl implements MzReceiptSerialService {
         if (receipt == null || StringUtils.isBlank(receipt.getReceiptCurrent())) {
             throw new MzException("用户id=" + user.getUserName() + "没有可用的发票,请先维护发票。");
         }
-        MzVisitTable mzVisitTable=mzVisitTableMapper.selectByPatientIdAndTimes(mzReceiptSerial.getPatientId(), mzReceiptSerial.getTimes());
+        MzVisitTable mzVisitTable = mzVisitTableMapper.selectByPatientIdAndTimes(mzReceiptSerial.getPatientId(), mzReceiptSerial.getTimes());
         if (mzVisitTable == null) {
             throw new MzException("当前病人就诊基础资料【MzVisitTable】不存在,请检查");
         }
@@ -194,10 +199,10 @@ public class MzReceiptSerialServiceImpl implements MzReceiptSerialService {
         //更新收费明细表发票流水号
         Date now = new Date();
         mzChargeDetailMapper.updateBySerialNo(receiptNo, mzReceiptSerial.getSerialNo(), oriSerialNo);
-        List<MzDepositFile> mzDepositFiles=mzDepositFileMapper.selectMzDepositFileBySerialNo(oriSerialNo);
+        List<MzDepositFile> mzDepositFiles = mzDepositFileMapper.selectMzDepositFileBySerialNo(oriSerialNo);
         //原收费方式记录设置为作废
-        mzDepositFileMapper.updatePayMark(PayMarkEnum.CANCELLATION.code,oriSerialNo);
-        for (MzDepositFile mzDepositFile:mzDepositFiles){
+        mzDepositFileMapper.updatePayMark(PayMarkEnum.CANCELLATION.code, oriSerialNo);
+        for (MzDepositFile mzDepositFile : mzDepositFiles) {
             //新增新的收费方式记录
             mzDepositFile.setReceiptNo(mzReceiptSerial.getReceiptNo());
             mzDepositFile.setReceiptSn(mzReceiptSerial.getSerialNo());

+ 1 - 1
src/main/resources/static/js/registration.js

@@ -1656,7 +1656,7 @@ function clearRegistration() {
  */
 function prn1Print(patientId, times) {
     setPrint();
-    var height ="93.18mm";
+    var height ="93.15mm";
     // if(countReceiot%2==0){
     //     height ="93.2mm";
     // }

+ 1 - 1
src/main/resources/static/js/registration_list.js

@@ -2019,7 +2019,7 @@ function clearRegistration() {
  */
 function prn1Print(patientId, times) {
     setPrint();
-    var height ="93.18mm";
+    var height ="93.15mm";
     // if(countReceiot%2==0){
     //     height ="93.2mm";
     // }

+ 1 - 1
src/main/resources/static/js/toll_administration.js

@@ -1377,7 +1377,7 @@ function obsoleteAndRepPrint(patientId, times, receiptNo) {
  */
 function printCommon(url, patientId, times, chargeFeeFlag) {
     setPrint();
-    var height = "93.18mm";
+    var height = "93.15mm";
     // if (countReceiot % 2 == 0) {
     //     height = "93.2mm";
     // }