Your Name пре 3 година
родитељ
комит
7013acb37e

+ 2 - 0
java110-bean/src/main/java/com/java110/dto/printerRule/PrinterRuleDto.java

@@ -14,6 +14,8 @@ import java.util.Date;
  **/
 public class PrinterRuleDto extends PageDto implements Serializable {
 
+    public static final String STATE_NORMAL = "1001";//有效
+
     private String ruleName;
 private String remark;
 private String state;

+ 1 - 1
java110-db/src/main/resources/mapper/fee/FeeDetailServiceDaoImplMapper.xml

@@ -121,7 +121,7 @@
         t.state,d.name stateName,t.start_time,t.end_time,t.start_time startTime,t.end_time endTime,pfa.`value`
         importFeeName,pfc.fee_name feeName,t.payable_amount,t.payable_amount payableAmount,
         mw.cur_degrees curDegrees,mw.pre_degrees preDegrees, mw.pre_reading_time preReadingTime,mw.cur_reading_time
-        curReadingTime,t.pay_order_id payOrderId
+        curReadingTime,t.pay_order_id payOrderId,pfc.config_id configId
         from pay_fee_detail t
         left join pay_fee_attrs pfa on t.fee_id = pfa.fee_id and pfa.spec_cd = '390002'
         left join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'

+ 101 - 6
service-job/src/main/java/com/java110/job/adapt/payment/receipt/PayFeeReceiptAdapt.java

@@ -8,8 +8,16 @@ import com.java110.core.smo.IComputeFeeSMO;
 import com.java110.dto.fee.FeeDetailDto;
 import com.java110.dto.fee.FeeDto;
 import com.java110.dto.logSystemError.LogSystemErrorDto;
+import com.java110.dto.machinePrinter.MachinePrinterDto;
 import com.java110.dto.owner.OwnerDto;
+import com.java110.dto.printerRule.PrinterRuleDto;
+import com.java110.dto.printerRuleFee.PrinterRuleFeeDto;
+import com.java110.dto.printerRuleMachine.PrinterRuleMachineDto;
 import com.java110.entity.order.Business;
+import com.java110.intf.common.IMachinePrinterV1InnerServiceSMO;
+import com.java110.intf.common.IPrinterRuleFeeV1InnerServiceSMO;
+import com.java110.intf.common.IPrinterRuleMachineV1InnerServiceSMO;
+import com.java110.intf.common.IPrinterRuleV1InnerServiceSMO;
 import com.java110.intf.community.ICommunityInnerServiceSMO;
 import com.java110.intf.fee.IFeeDetailInnerServiceSMO;
 import com.java110.intf.fee.IFeeInnerServiceSMO;
@@ -20,15 +28,19 @@ import com.java110.intf.user.IOwnerCarInnerServiceSMO;
 import com.java110.intf.user.IOwnerInnerServiceSMO;
 import com.java110.intf.user.IOwnerRoomRelInnerServiceSMO;
 import com.java110.job.adapt.DatabusAdaptImpl;
+import com.java110.job.printer.IPrinter;
 import com.java110.po.fee.PayFeeDetailPo;
 import com.java110.po.feeReceipt.FeeReceiptPo;
 import com.java110.po.feeReceiptDetail.FeeReceiptDetailPo;
 import com.java110.po.logSystemError.LogSystemErrorPo;
 import com.java110.service.smo.ISaveSystemErrorSMO;
+import com.java110.utils.exception.CmdException;
+import com.java110.utils.factory.ApplicationContextFactory;
 import com.java110.utils.util.Assert;
 import com.java110.utils.util.BeanConvertUtil;
 import com.java110.utils.util.ExceptionUtil;
 import com.java110.utils.util.StringUtil;
+import com.java110.vo.ResultVo;
 import org.slf4j.Logger;
 import com.java110.core.log.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -81,6 +93,18 @@ public class PayFeeReceiptAdapt extends DatabusAdaptImpl {
     @Autowired
     private IOwnerAppUserInnerServiceSMO ownerAppUserInnerServiceSMO;
 
+    @Autowired
+    private IPrinterRuleFeeV1InnerServiceSMO printerRuleFeeV1InnerServiceSMOImpl;
+
+    @Autowired
+    private IPrinterRuleV1InnerServiceSMO printerRuleV1InnerServiceSMOImpl;
+
+    @Autowired
+    private IPrinterRuleMachineV1InnerServiceSMO printerRuleMachineV1InnerServiceSMOImpl;
+
+    @Autowired
+    private IMachinePrinterV1InnerServiceSMO machinePrinterV1InnerServiceSMOImpl;
+
     //模板信息推送地址
     private static String sendMsgUrl = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=";
 
@@ -90,8 +114,8 @@ public class PayFeeReceiptAdapt extends DatabusAdaptImpl {
     public void execute(Business business, List<Business> businesses) {
         JSONObject data = business.getData();
 
-        if(data != null){
-            logger.debug("请求日志:{}",data);
+        if (data != null) {
+            logger.debug("请求日志:{}", data);
         }
         JSONArray businessPayFeeDetails = null;
         if (data == null) {
@@ -147,9 +171,9 @@ public class PayFeeReceiptAdapt extends DatabusAdaptImpl {
 
             // if received amount lt zero
 
-            if(businessPayFeeDetail.containsKey("receivedAmount")
-                    && businessPayFeeDetail.getDoubleValue("receivedAmount")<0){
-                return ;
+            if (businessPayFeeDetail.containsKey("receivedAmount")
+                    && businessPayFeeDetail.getDoubleValue("receivedAmount") < 0) {
+                return;
             }
 
             //添加单元信息
@@ -185,7 +209,10 @@ public class PayFeeReceiptAdapt extends DatabusAdaptImpl {
             //这里只是写入 收据表,暂不考虑 事务一致性问题,就算写入失败 也只是影响 收据打印,如果 贵公司对 收据要求 比较高,不能有失败的情况 请加入事务管理
             feeReceiptDetailInnerServiceSMOImpl.saveFeeReceiptDetail(feeReceiptDetailPo);
             feeReceiptInnerServiceSMOImpl.saveFeeReceipt(feeReceiptPo);
-        }catch (Exception e){
+
+            // 是否配置了自动打印功能 如果配置了自动打印功能 自动打印
+            autoPrintReceipt(businessPayFeeDetail.getString("detailId"), feeDto.getCommunityId());
+        } catch (Exception e) {
             LogSystemErrorPo logSystemErrorPo = new LogSystemErrorPo();
             logSystemErrorPo.setErrId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_errId));
             logSystemErrorPo.setErrType(LogSystemErrorDto.ERR_TYPE_NOTICE);
@@ -196,4 +223,72 @@ public class PayFeeReceiptAdapt extends DatabusAdaptImpl {
     }
 
 
+    private void autoPrintReceipt(String detailId, String communityId) {
+
+        FeeDetailDto feeDetailDto = new FeeDetailDto();
+        feeDetailDto.setDetailId(detailId);
+        feeDetailDto.setCommunityId(communityId);
+        List<FeeDetailDto> feeDetailDtos = feeDetailInnerServiceSMOImpl.queryFeeDetails(feeDetailDto);
+
+        if (feeDetailDtos == null || feeDetailDtos.size() < 1) {
+            return;
+        }
+
+        PrinterRuleFeeDto printerRuleFeeDto = new PrinterRuleFeeDto();
+        printerRuleFeeDto.setCommunityId(communityId);
+        printerRuleFeeDto.setFeeId(feeDetailDtos.get(0).getConfigId());
+        List<PrinterRuleFeeDto> printerRuleFeeDtos = printerRuleFeeV1InnerServiceSMOImpl.queryPrinterRuleFees(printerRuleFeeDto);
+
+        if (printerRuleFeeDtos == null || printerRuleFeeDtos.size() < 1) {
+            return;
+        }
+
+        PrinterRuleDto printerRuleDto = new PrinterRuleDto();
+        printerRuleDto.setRuleId(printerRuleFeeDtos.get(0).getRuleId());
+        printerRuleDto.setCommunityId(communityId);
+        printerRuleDto.setState(PrinterRuleDto.STATE_NORMAL);
+        int count = printerRuleV1InnerServiceSMOImpl.queryPrinterRulesCount(printerRuleDto);
+
+        if (count < 1) {
+            return;
+        }
+
+        PrinterRuleMachineDto printerRuleMachineDto = new PrinterRuleMachineDto();
+        printerRuleMachineDto.setCommunityId(communityId);
+        printerRuleMachineDto.setRuleId(printerRuleFeeDtos.get(0).getRuleId());
+        List<PrinterRuleMachineDto> printerRuleMachineDtos = printerRuleMachineV1InnerServiceSMOImpl.queryPrinterRuleMachines(printerRuleMachineDto);
+        if (printerRuleMachineDtos == null || printerRuleMachineDtos.size() < 1) {
+            return;
+        }
+
+        for (PrinterRuleMachineDto tmpPrinterRuleMachineDto : printerRuleMachineDtos) {
+            try {
+                doPrint(tmpPrinterRuleMachineDto, detailId);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+
+
+    }
+
+    private void doPrint(PrinterRuleMachineDto tmpPrinterRuleMachineDto, String detailId) {
+        MachinePrinterDto machinePrinterDto = new MachinePrinterDto();
+        machinePrinterDto.setCommunityId(tmpPrinterRuleMachineDto.getCommunityId());
+        machinePrinterDto.setMachineId(tmpPrinterRuleMachineDto.getMachineId());
+        List<MachinePrinterDto> machinePrinterDtos = machinePrinterV1InnerServiceSMOImpl.queryMachinePrinters(machinePrinterDto);
+
+        Assert.listOnlyOne(machinePrinterDtos, "云打印机不存在");
+
+        IPrinter printer = ApplicationContextFactory.getBean(machinePrinterDtos.get(0).getImplBean(), IPrinter.class);
+
+        if (printer == null) {
+            throw new CmdException("打印机异常,未包含适配器");
+        }
+
+        printer.printPayFeeDetail(new String[]{detailId}, tmpPrinterRuleMachineDto.getCommunityId(), Integer.parseInt(tmpPrinterRuleMachineDto.getQuantity()), machinePrinterDtos.get(0));
+
+    }
+
+
 }

+ 23 - 12
service-job/src/main/java/com/java110/job/printer/manufactor/FeieManufactor.java

@@ -7,9 +7,12 @@ import com.java110.dto.fee.FeeDto;
 import com.java110.dto.feeReceipt.FeeReceiptDetailDto;
 import com.java110.dto.feeReceipt.FeeReceiptDto;
 import com.java110.dto.machinePrinter.MachinePrinterDto;
+import com.java110.dto.smallWeChat.SmallWeChatDto;
 import com.java110.intf.fee.*;
+import com.java110.intf.store.ISmallWeChatInnerServiceSMO;
 import com.java110.job.printer.IPrinter;
 import com.java110.utils.cache.MappingCache;
+import com.java110.utils.cache.UrlCache;
 import com.java110.utils.constant.MappingConstant;
 import com.java110.utils.exception.CmdException;
 import com.java110.utils.util.Assert;
@@ -28,17 +31,10 @@ import org.apache.http.message.BasicNameValuePair;
 import org.apache.http.util.EntityUtils;
 import org.slf4j.Logger;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpMethod;
-import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Service;
-import org.springframework.util.LinkedMultiValueMap;
-import org.springframework.util.MultiValueMap;
 
 import java.io.IOException;
-import java.io.UnsupportedEncodingException;
 import java.math.BigDecimal;
-import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Date;
@@ -75,6 +71,9 @@ public class FeieManufactor implements IPrinter {
     @Autowired
     private IFeeReceiptInnerServiceSMO feeReceiptInnerServiceSMOImpl;
 
+    @Autowired
+    private ISmallWeChatInnerServiceSMO smallWeChatInnerServiceSMOImpl;
+
     /**
      * **************************
      * 单号:832023020800440026
@@ -163,7 +162,7 @@ public class FeieManufactor implements IPrinter {
             totalDecimal = totalDecimal.add(new BigDecimal(Double.parseDouble(tmpFeeReceiptDetailDto.getAmount())));
 
         }
-        printStr += getPrintPayFeeDetailFloorContent(totalDecimal.doubleValue());
+        printStr += getPrintPayFeeDetailFloorContent(communityId, totalDecimal.doubleValue());
 
         String stime = String.valueOf(System.currentTimeMillis() / 1000);
         String user = MappingCache.getValue(MappingConstant.FEIE_DOMAIN, "user");
@@ -200,7 +199,7 @@ public class FeieManufactor implements IPrinter {
         nvps.add(new BasicNameValuePair("apiname", "Open_printMsg"));// 固定值,不需要修改
         nvps.add(new BasicNameValuePair("sn", machinePrinterDto.getMachineCode()));
         nvps.add(new BasicNameValuePair("content", printStr));
-        nvps.add(new BasicNameValuePair("times", quantity+""));// 打印联数
+        nvps.add(new BasicNameValuePair("times", quantity + ""));// 打印联数
 
         CloseableHttpResponse response = null;
         String result = null;
@@ -269,11 +268,23 @@ public class FeieManufactor implements IPrinter {
         return orderInfo;
     }
 
-    public static String getPrintPayFeeDetailFloorContent(double totals) {
+    public String getPrintPayFeeDetailFloorContent(String communityId, double totals) {
         String orderInfo = "";
-        orderInfo += "********************************<BR>";
+        //orderInfo += "********************************<BR>";
         orderInfo += "合计:" + totals + "元<BR>";
-        orderInfo += "<QR>http://www.feieyun.com</QR>";
+
+        //查询公众号配置
+        SmallWeChatDto smallWeChatDto = new SmallWeChatDto();
+        smallWeChatDto.setWeChatType("1100");
+        smallWeChatDto.setObjType(SmallWeChatDto.OBJ_TYPE_COMMUNITY);
+        smallWeChatDto.setObjId(communityId);
+        List<SmallWeChatDto> smallWeChatDtos = smallWeChatInnerServiceSMOImpl.querySmallWeChats(smallWeChatDto);
+
+
+        if (smallWeChatDto != null && smallWeChatDtos.size() > 0) {
+            orderInfo += "<QR>" + UrlCache.getOwnerUrl() + "/#/?wAppId=" + smallWeChatDtos.get(0).getAppId() + "</QR>";
+        }
+
         return orderInfo;
     }