|  | @@ -2,6 +2,7 @@ package cn.hnthyy.thmz.controller.api;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import cn.hnthyy.thmz.Utils.DateUtil;
 | 
	
		
			
				|  |  | +import cn.hnthyy.thmz.Utils.NumberToCN;
 | 
	
		
			
				|  |  |  import cn.hnthyy.thmz.Utils.TokenUtil;
 | 
	
		
			
				|  |  |  import cn.hnthyy.thmz.common.Constants;
 | 
	
		
			
				|  |  |  import cn.hnthyy.thmz.entity.MzException;
 | 
	
	
		
			
				|  | @@ -79,7 +80,8 @@ public class MedicalViewApiController {
 | 
	
		
			
				|  |  |      private ZyActpatientService zyActpatientService;
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private ZyDepositFileService zyDepositFileService;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private MzReceiptSerialService mzReceiptSerialService;
 | 
	
		
			
				|  |  |      //海慈身份证类型
 | 
	
		
			
				|  |  |      private static final String ID_CARD_TYPE = "11";
 | 
	
		
			
				|  |  |      //诊疗卡类型
 | 
	
	
		
			
				|  | @@ -1025,14 +1027,14 @@ public class MedicalViewApiController {
 | 
	
		
			
				|  |  |          try {
 | 
	
		
			
				|  |  |              mzPrescriptionVo.setJzFlag(YesNoEnum.NO.code);
 | 
	
		
			
				|  |  |              mzPrescriptionVo.setFirstOrNot(YesNoEnum.NO.code);
 | 
	
		
			
				|  |  | -            if(StringUtils.isBlank(mzPrescriptionVo.getDoctorCode())){
 | 
	
		
			
				|  |  | +            if (StringUtils.isBlank(mzPrescriptionVo.getDoctorCode())) {
 | 
	
		
			
				|  |  |                  mzPrescriptionVo.setDoctorCode(Constants.BRZZJF_CODE);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -            if(StringUtils.isBlank(mzPrescriptionVo.getVisitDeptCode())){
 | 
	
		
			
				|  |  | +            if (StringUtils.isBlank(mzPrescriptionVo.getVisitDeptCode())) {
 | 
	
		
			
				|  |  |                  mzPrescriptionVo.setVisitDeptCode(Constants.ZZBM);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -            Clinic clinic = mzChargeDetailService.savePrescription(mzPrescriptionVo,null);
 | 
	
		
			
				|  |  | -            if (clinic != null && clinic.getId()!=null) {
 | 
	
		
			
				|  |  | +            Clinic clinic = mzChargeDetailService.savePrescription(mzPrescriptionVo, null);
 | 
	
		
			
				|  |  | +            if (clinic != null && clinic.getId() != null) {
 | 
	
		
			
				|  |  |                  results.put("resultCode", 0);
 | 
	
		
			
				|  |  |                  results.put("resultMessage", "门诊处方保存成功");
 | 
	
		
			
				|  |  |                  return results;
 | 
	
	
		
			
				|  | @@ -1071,7 +1073,7 @@ public class MedicalViewApiController {
 | 
	
		
			
				|  |  |                  return results;
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              Clinic clinic = mzChargeDetailService.nucleicAcidApplication(patientId);
 | 
	
		
			
				|  |  | -            if (clinic != null && clinic.getId()!=null) {
 | 
	
		
			
				|  |  | +            if (clinic != null && clinic.getId() != null) {
 | 
	
		
			
				|  |  |                  results.put("resultCode", 0);
 | 
	
		
			
				|  |  |                  results.put("resultMessage", "核酸申请保存成功");
 | 
	
		
			
				|  |  |                  return results;
 | 
	
	
		
			
				|  | @@ -1094,7 +1096,6 @@ public class MedicalViewApiController {
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 根据病人住院号查询住院病人信息
 | 
	
		
			
				|  |  |       *
 | 
	
	
		
			
				|  | @@ -1124,7 +1125,6 @@ public class MedicalViewApiController {
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 根据住院号查询院记录的
 | 
	
		
			
				|  |  |       *
 | 
	
	
		
			
				|  | @@ -1142,9 +1142,9 @@ public class MedicalViewApiController {
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              resultMap.put("resultCode", 0);
 | 
	
		
			
				|  |  |              resultMap.put("resultMessage", "根据住院号查询在院记录成功");
 | 
	
		
			
				|  |  | -            ZyActpatient zyActpatient=zyActpatientService.queryByInpatientNo("zy_actpatient",inpatientNo,null);
 | 
	
		
			
				|  |  | -            GenderEnum genderEnum= GenderEnum.getGenderByCode(Integer.valueOf(zyActpatient.getSex()));
 | 
	
		
			
				|  |  | -            zyActpatient.setGender(genderEnum==null?GenderEnum.UNKNOWN.name:genderEnum.name);
 | 
	
		
			
				|  |  | +            ZyActpatient zyActpatient = zyActpatientService.queryByInpatientNo("zy_actpatient", inpatientNo, null);
 | 
	
		
			
				|  |  | +            GenderEnum genderEnum = GenderEnum.getGenderByCode(Integer.valueOf(zyActpatient.getSex()));
 | 
	
		
			
				|  |  | +            zyActpatient.setGender(genderEnum == null ? GenderEnum.UNKNOWN.name : genderEnum.name);
 | 
	
		
			
				|  |  |              zyActpatient.setDeptName(zdUnitCodeService.queryDeptNameByIdInCache(zyActpatient.getDept()));
 | 
	
		
			
				|  |  |              zyActpatient.setResponceTypeName(ResponceTypeEnum.getReportTypeByCode(zyActpatient.getResponceType()).name);
 | 
	
		
			
				|  |  |              resultMap.put("data", zyActpatient);
 | 
	
	
		
			
				|  | @@ -1159,7 +1159,6 @@ public class MedicalViewApiController {
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 保存住院收费
 | 
	
		
			
				|  |  |       *
 | 
	
	
		
			
				|  | @@ -1214,7 +1213,6 @@ public class MedicalViewApiController {
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 查询挂号科室分类
 | 
	
		
			
				|  |  |       *
 | 
	
	
		
			
				|  | @@ -1260,7 +1258,7 @@ public class MedicalViewApiController {
 | 
	
		
			
				|  |  |              return resultMap;
 | 
	
		
			
				|  |  |          } catch (MzException e) {
 | 
	
		
			
				|  |  |              e.printStackTrace();
 | 
	
		
			
				|  |  | -            log.error("系统异常,请联系管理员,{}",e);
 | 
	
		
			
				|  |  | +            log.error("系统异常,请联系管理员,{}", e);
 | 
	
		
			
				|  |  |              resultMap.put("code", e.getValue());
 | 
	
		
			
				|  |  |              resultMap.put("message", e.getMessage());
 | 
	
		
			
				|  |  |              return resultMap;
 | 
	
	
		
			
				|  | @@ -1313,7 +1311,7 @@ public class MedicalViewApiController {
 | 
	
		
			
				|  |  |              resultMap.put("data", zdUnitCodeList);
 | 
	
		
			
				|  |  |              return resultMap;
 | 
	
		
			
				|  |  |          } catch (Exception e) {
 | 
	
		
			
				|  |  | -            log.error("系统异常,请联系管理员,{}",e);
 | 
	
		
			
				|  |  | +            log.error("系统异常,请联系管理员,{}", e);
 | 
	
		
			
				|  |  |              resultMap.put("code", -1);
 | 
	
		
			
				|  |  |              resultMap.put("message", "没有查询到符合条件的科室列表");
 | 
	
		
			
				|  |  |              return resultMap;
 | 
	
	
		
			
				|  | @@ -1415,7 +1413,7 @@ public class MedicalViewApiController {
 | 
	
		
			
				|  |  |              Map<String, String> zdUnitCodeMap = list.stream().collect(Collectors.toMap(ZdUnitCode::getCode, ZdUnitCode::getName));
 | 
	
		
			
				|  |  |              if (zdEmpTitles != null && zdEmpTitles.size() > 0) {
 | 
	
		
			
				|  |  |                  titleMap = zdEmpTitles.stream().collect(Collectors.toMap(ZdEmpTitle::getCode, ZdEmpTitle::getName));
 | 
	
		
			
				|  |  | -                titGradeMap = zdEmpTitles.stream().collect(Collectors.toMap(ZdEmpTitle::getCode, zdEmpTitle-> zdEmpTitle.getTitGrade()==null?3:zdEmpTitle.getTitGrade()));
 | 
	
		
			
				|  |  | +                titGradeMap = zdEmpTitles.stream().collect(Collectors.toMap(ZdEmpTitle::getCode, zdEmpTitle -> zdEmpTitle.getTitGrade() == null ? 3 : zdEmpTitle.getTitGrade()));
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              List<Employee> notDoctors = new ArrayList<>();
 | 
	
		
			
				|  |  |              for (Employee employee : employees) {
 | 
	
	
		
			
				|  | @@ -1658,7 +1656,7 @@ public class MedicalViewApiController {
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |                  WorkTimeEnum workTimeEnum = WorkTimeEnum.geteBedStatusByCode(ampm);
 | 
	
		
			
				|  |  | -                map.put("ampm", workTimeEnum==null?"":workTimeEnum.name);
 | 
	
		
			
				|  |  | +                map.put("ampm", workTimeEnum == null ? "" : workTimeEnum.name);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              results.put("resultCode", 0);
 | 
	
		
			
				|  |  |              results.put("resultMessage", "查询可以挂号的医生号源信息成功");
 | 
	
	
		
			
				|  | @@ -2155,4 +2153,264 @@ public class MedicalViewApiController {
 | 
	
		
			
				|  |  |              return results;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 根据病人id查询所有未打印的发票
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  | +     * @return
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    @RequestMapping(value = "/getUnPrintReceiptSerial", method = {RequestMethod.GET})
 | 
	
		
			
				|  |  | +    public Map<String, Object> getUnPrintReceiptSerial(@RequestParam("patientId") String patientId) {
 | 
	
		
			
				|  |  | +        Map<String, Object> resultMap = new HashMap<>();
 | 
	
		
			
				|  |  | +        try {
 | 
	
		
			
				|  |  | +            if (StringUtils.isBlank(patientId)) {
 | 
	
		
			
				|  |  | +                resultMap.put("code", -1);
 | 
	
		
			
				|  |  | +                resultMap.put("message", "病人门诊ID不能为空");
 | 
	
		
			
				|  |  | +                return resultMap;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            List<Map<String, Object>> resultList = mzyReqrecService.queryUnPrintReceiptSerial(patientId);
 | 
	
		
			
				|  |  | +            if (resultList == null) {
 | 
	
		
			
				|  |  | +                resultList = mzReceiptSerialService.queryUnPrintReceiptSerial(patientId);
 | 
	
		
			
				|  |  | +            } else {
 | 
	
		
			
				|  |  | +                resultList.addAll(mzReceiptSerialService.queryUnPrintReceiptSerial(patientId));
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            if (resultList == null) {
 | 
	
		
			
				|  |  | +                resultMap.put("code", -1);
 | 
	
		
			
				|  |  | +                resultMap.put("message", "很抱歉,未查询到您有未打印的发票信息");
 | 
	
		
			
				|  |  | +                return resultMap;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            resultMap.put("code", 0);
 | 
	
		
			
				|  |  | +            resultMap.put("message", "未打印的发票信息查询成功");
 | 
	
		
			
				|  |  | +            resultMap.put("data", resultList);
 | 
	
		
			
				|  |  | +            return resultMap;
 | 
	
		
			
				|  |  | +        } catch (Exception e) {
 | 
	
		
			
				|  |  | +            log.error("未打印的发票信息查询失败,错误信息{}", e);
 | 
	
		
			
				|  |  | +            resultMap.put("code", -1);
 | 
	
		
			
				|  |  | +            resultMap.put("message", "未打印的发票信息查询失败");
 | 
	
		
			
				|  |  | +            return resultMap;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 获取发票内容发票
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  | +     * @return
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    @RequestMapping(value = "/getReceiptSerialDetail", method = {RequestMethod.POST})
 | 
	
		
			
				|  |  | +    public Map<String, Object> getReceiptSerialDetail(@RequestBody Map<String, Object> params) {
 | 
	
		
			
				|  |  | +        Map<String, Object> resultMap = new HashMap<>();
 | 
	
		
			
				|  |  | +        try {
 | 
	
		
			
				|  |  | +            if (params == null) {
 | 
	
		
			
				|  |  | +                resultMap.put("code", -1);
 | 
	
		
			
				|  |  | +                resultMap.put("message", "发票详情查询参数不能为空");
 | 
	
		
			
				|  |  | +                return resultMap;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            String patientId = (String) params.get("patientId");
 | 
	
		
			
				|  |  | +            Integer times = (Integer) params.get("times");
 | 
	
		
			
				|  |  | +            Integer type = (Integer) params.get("type");
 | 
	
		
			
				|  |  | +            Integer receiptNo = (Integer) params.get("receiptNo");
 | 
	
		
			
				|  |  | +            String chequeType = (String) params.get("chequeType");
 | 
	
		
			
				|  |  | +            String receiptBill = (String) params.get("receiptBill");
 | 
	
		
			
				|  |  | +            if (StringUtils.isBlank(patientId)) {
 | 
	
		
			
				|  |  | +                resultMap.put("code", -1);
 | 
	
		
			
				|  |  | +                resultMap.put("message", "病人门诊ID不能为空");
 | 
	
		
			
				|  |  | +                return resultMap;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            if (StringUtils.isBlank(receiptBill)) {
 | 
	
		
			
				|  |  | +                resultMap.put("code", -1);
 | 
	
		
			
				|  |  | +                resultMap.put("message", "发票号不能为空");
 | 
	
		
			
				|  |  | +                return resultMap;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            if (times == null) {
 | 
	
		
			
				|  |  | +                resultMap.put("code", -1);
 | 
	
		
			
				|  |  | +                resultMap.put("message", "病人就诊次数不能为空");
 | 
	
		
			
				|  |  | +                return resultMap;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            if (type == null) {
 | 
	
		
			
				|  |  | +                resultMap.put("code", -1);
 | 
	
		
			
				|  |  | +                resultMap.put("message", "发票类型不能为空");
 | 
	
		
			
				|  |  | +                return resultMap;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            if (type == 2) {
 | 
	
		
			
				|  |  | +                if (receiptNo == null) {
 | 
	
		
			
				|  |  | +                    resultMap.put("code", -1);
 | 
	
		
			
				|  |  | +                    resultMap.put("message", "病人缴费次数不能为空");
 | 
	
		
			
				|  |  | +                    return resultMap;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                if (StringUtils.isBlank(chequeType)) {
 | 
	
		
			
				|  |  | +                    resultMap.put("code", -1);
 | 
	
		
			
				|  |  | +                    resultMap.put("message", "病人缴费方式不能为空");
 | 
	
		
			
				|  |  | +                    return resultMap;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                MzReceiptSerial mzReceiptSerial = mzReceiptSerialService.queryAllSerialForThisTime(patientId, times, receiptNo);
 | 
	
		
			
				|  |  | +                if (mzReceiptSerial == null) {
 | 
	
		
			
				|  |  | +                    mzReceiptSerialService.repairDataFromBack(patientId, times, receiptNo);
 | 
	
		
			
				|  |  | +                    mzReceiptSerial = mzReceiptSerialService.queryAllSerialForThisTime(patientId, times, receiptNo);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                if (StringUtils.isBlank(mzReceiptSerial.getChequeType())) {
 | 
	
		
			
				|  |  | +                    resultMap.put("code", -1);
 | 
	
		
			
				|  |  | +                    resultMap.put("message", "当前病人发票表中的收费类型为空,无法打印发票,请及时联系管理员");
 | 
	
		
			
				|  |  | +                    log.info("当前病人发票表中的收费类型为空,无法打印发票,请及时联系管理员,patientId={},time={},receiptNo={}", patientId, times, receiptNo);
 | 
	
		
			
				|  |  | +                    return resultMap;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                List<Integer> timesList = new ArrayList<>();
 | 
	
		
			
				|  |  | +                List<MzReceiptSerialVo> mzReceiptSerialVos = mzReceiptSerialService.getMzReceiptSerialVos(mzReceiptSerial, timesList, receiptBill);
 | 
	
		
			
				|  |  | +                resultMap.put("data", mzReceiptSerialVos);
 | 
	
		
			
				|  |  | +                resultMap.put("printerId", Constants.BRZZJF_NAME);
 | 
	
		
			
				|  |  | +                resultMap.put("message", "发票详情查询成功");
 | 
	
		
			
				|  |  | +                return resultMap;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            MzyReqrec mzyReqrec = mzyReqrecService.queryMzyReqrecByPatientIdAndTimes(patientId, times);
 | 
	
		
			
				|  |  | +            if (mzyReqrec == null) {
 | 
	
		
			
				|  |  | +                resultMap.put("code", -1);
 | 
	
		
			
				|  |  | +                resultMap.put("message", "当前病人不存在挂号信息");
 | 
	
		
			
				|  |  | +                return resultMap;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            if (StringUtils.isNotBlank(mzyReqrec.getPrinterId())) {
 | 
	
		
			
				|  |  | +                resultMap.put("code", -1);
 | 
	
		
			
				|  |  | +                resultMap.put("message", "当前挂号信息已经打印过发票,请勿重复操作");
 | 
	
		
			
				|  |  | +                return resultMap;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            ZdUnitCode zdUnitCode = zdUnitCodeService.queryByCode(mzyReqrec.getUnitCode());
 | 
	
		
			
				|  |  | +            if (zdUnitCode != null) {
 | 
	
		
			
				|  |  | +                mzyReqrec.setUnitCode(zdUnitCode.getName());
 | 
	
		
			
				|  |  | +                resultMap.put("officePos", zdUnitCode.getOfficePos());
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            Employee employee = employeeService.queryByUserCode(mzyReqrec.getDoctorCode());
 | 
	
		
			
				|  |  | +            if (employee != null) {
 | 
	
		
			
				|  |  | +                mzyReqrec.setDoctorCode(employee.getEmployeeName());
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            MzyZdChargeType mzyZdChargeType = mzyZdChargeTypeService.queryByCode(mzyReqrec.getChargeType());
 | 
	
		
			
				|  |  | +            if (mzyZdChargeType != null) {
 | 
	
		
			
				|  |  | +                mzyReqrec.setChargeType(mzyZdChargeType.getName());
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            if ("a".equals(mzyReqrec.getAmpm())) {
 | 
	
		
			
				|  |  | +                mzyReqrec.setAmpm("上午");
 | 
	
		
			
				|  |  | +            } else if ("p".equals(mzyReqrec.getAmpm())) {
 | 
	
		
			
				|  |  | +                mzyReqrec.setAmpm("下午");
 | 
	
		
			
				|  |  | +            } else if ("n".equals(mzyReqrec.getAmpm())) {
 | 
	
		
			
				|  |  | +                mzyReqrec.setAmpm("中午");
 | 
	
		
			
				|  |  | +            } else if ("d".equals(mzyReqrec.getAmpm())) {
 | 
	
		
			
				|  |  | +                mzyReqrec.setAmpm("全天");
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            BigDecimal totalFee = mzyReqrec.getReqFee().add(mzyReqrec.getClinicFee()).add(mzyReqrec.getOthFee()).add(mzyReqrec.getBrochureFee());
 | 
	
		
			
				|  |  | +            if (totalFee.compareTo(BigDecimal.ZERO) == 0) {
 | 
	
		
			
				|  |  | +                resultMap.put("code", -1);
 | 
	
		
			
				|  |  | +                resultMap.put("message", "当前病人无费用信息,无需开具发票");
 | 
	
		
			
				|  |  | +                return resultMap;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            resultMap.put("totalFee", totalFee);
 | 
	
		
			
				|  |  | +            resultMap.put("totalFeeStr", NumberToCN.number2CNMontrayUnit(totalFee));
 | 
	
		
			
				|  |  | +            Date chargeDate = mzyReqrec.getRequestDay();
 | 
	
		
			
				|  |  | +            if (chargeDate == null) {
 | 
	
		
			
				|  |  | +                chargeDate = new Date();
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            Calendar calendar = Calendar.getInstance();
 | 
	
		
			
				|  |  | +            calendar.setTime(chargeDate);
 | 
	
		
			
				|  |  | +            resultMap.put("year", calendar.get(Calendar.YEAR));
 | 
	
		
			
				|  |  | +            Integer month = calendar.get(Calendar.MONTH) + 1;
 | 
	
		
			
				|  |  | +            if (month < 10) {
 | 
	
		
			
				|  |  | +                resultMap.put("month", "0" + month);
 | 
	
		
			
				|  |  | +            } else {
 | 
	
		
			
				|  |  | +                resultMap.put("month", month.toString());
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            Integer day = calendar.get(Calendar.DAY_OF_MONTH);
 | 
	
		
			
				|  |  | +            if (day < 10) {
 | 
	
		
			
				|  |  | +                resultMap.put("day", "0" + day);
 | 
	
		
			
				|  |  | +            } else {
 | 
	
		
			
				|  |  | +                resultMap.put("day", day.toString());
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            resultMap.put("printerId", Constants.BRZZJF_NAME);
 | 
	
		
			
				|  |  | +            resultMap.put("code", 0);
 | 
	
		
			
				|  |  | +            resultMap.put("data", mzyReqrec);
 | 
	
		
			
				|  |  | +            resultMap.put("message", "发票详情查询成功");
 | 
	
		
			
				|  |  | +            return resultMap;
 | 
	
		
			
				|  |  | +        } catch (Exception e) {
 | 
	
		
			
				|  |  | +            log.error("发票详情查询失败,错误信息{}", e);
 | 
	
		
			
				|  |  | +            resultMap.put("code", -1);
 | 
	
		
			
				|  |  | +            resultMap.put("message", "发票详情查询失败");
 | 
	
		
			
				|  |  | +            return resultMap;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 打印发票
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  | +     * @return
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    @RequestMapping(value = "/printReceiptSerial", method = {RequestMethod.POST})
 | 
	
		
			
				|  |  | +    public Map<String, Object> printReceiptSerial(@RequestBody Map<String, Object> params) {
 | 
	
		
			
				|  |  | +        Map<String, Object> resultMap = new HashMap<>();
 | 
	
		
			
				|  |  | +        try {
 | 
	
		
			
				|  |  | +            if (params == null) {
 | 
	
		
			
				|  |  | +                resultMap.put("code", -1);
 | 
	
		
			
				|  |  | +                resultMap.put("message", "打印发票参数不能为空");
 | 
	
		
			
				|  |  | +                return resultMap;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            String patientId = (String) params.get("patientId");
 | 
	
		
			
				|  |  | +            Integer times = (Integer) params.get("times");
 | 
	
		
			
				|  |  | +            Integer type = (Integer) params.get("type");
 | 
	
		
			
				|  |  | +            Integer receiptNo = (Integer) params.get("receiptNo");
 | 
	
		
			
				|  |  | +            String chequeType = (String) params.get("chequeType");
 | 
	
		
			
				|  |  | +            String receiptBill = (String) params.get("receiptBill");
 | 
	
		
			
				|  |  | +            if (StringUtils.isBlank(patientId)) {
 | 
	
		
			
				|  |  | +                resultMap.put("code", -1);
 | 
	
		
			
				|  |  | +                resultMap.put("message", "病人门诊ID不能为空");
 | 
	
		
			
				|  |  | +                return resultMap;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            if (StringUtils.isBlank(receiptBill)) {
 | 
	
		
			
				|  |  | +                resultMap.put("code", -1);
 | 
	
		
			
				|  |  | +                resultMap.put("message", "发票号不能为空");
 | 
	
		
			
				|  |  | +                return resultMap;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            if (times == null) {
 | 
	
		
			
				|  |  | +                resultMap.put("code", -1);
 | 
	
		
			
				|  |  | +                resultMap.put("message", "病人就诊次数不能为空");
 | 
	
		
			
				|  |  | +                return resultMap;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            if (type == null) {
 | 
	
		
			
				|  |  | +                resultMap.put("code", -1);
 | 
	
		
			
				|  |  | +                resultMap.put("message", "发票类型不能为空");
 | 
	
		
			
				|  |  | +                return resultMap;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            int num = 0;
 | 
	
		
			
				|  |  | +            if (type == 2) {
 | 
	
		
			
				|  |  | +                if (receiptNo == null) {
 | 
	
		
			
				|  |  | +                    resultMap.put("code", -1);
 | 
	
		
			
				|  |  | +                    resultMap.put("message", "病人缴费次数不能为空");
 | 
	
		
			
				|  |  | +                    return resultMap;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                if (StringUtils.isBlank(chequeType)) {
 | 
	
		
			
				|  |  | +                    resultMap.put("code", -1);
 | 
	
		
			
				|  |  | +                    resultMap.put("message", "病人缴费方式不能为空");
 | 
	
		
			
				|  |  | +                    return resultMap;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                num = mzReceiptSerialService.printReceiptSerial(patientId, times, receiptNo, chequeType, receiptBill);
 | 
	
		
			
				|  |  | +            } else {
 | 
	
		
			
				|  |  | +                num = mzyReqrecService.printMzyReqrecRecept(patientId, times, receiptBill);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            if (num == 0) {
 | 
	
		
			
				|  |  | +                resultMap.put("code", -1);
 | 
	
		
			
				|  |  | +                resultMap.put("message", "打印发票失败,请重试");
 | 
	
		
			
				|  |  | +                return resultMap;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            resultMap.put("code", 0);
 | 
	
		
			
				|  |  | +            resultMap.put("message", "发票打印成功");
 | 
	
		
			
				|  |  | +            return resultMap;
 | 
	
		
			
				|  |  | +        } catch (MzException e) {
 | 
	
		
			
				|  |  | +            log.error("发票打印失败,错误信息{}", e);
 | 
	
		
			
				|  |  | +            resultMap.put("code", -1);
 | 
	
		
			
				|  |  | +            resultMap.put("message", e.getMessage());
 | 
	
		
			
				|  |  | +            return resultMap;
 | 
	
		
			
				|  |  | +        } catch (Exception e) {
 | 
	
		
			
				|  |  | +            log.error("发票打印失败,错误信息{}", e);
 | 
	
		
			
				|  |  | +            resultMap.put("code", -1);
 | 
	
		
			
				|  |  | +            resultMap.put("message", "发票打印失败失败");
 | 
	
		
			
				|  |  | +            return resultMap;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  }
 |