Browse Source

20220313_后端更新代码_并增加红冲发票接口—msy

mashengyi 3 years ago
parent
commit
a4a98324fc

+ 4 - 3
src/main/java/com/jkcredit/invoice/controller/business/CustomerController.java

@@ -338,17 +338,18 @@ public class CustomerController {
             String [] res =customerRec.getServiceEndTime().split(",");
             customerRec.setServiceEndTimeStart(res[0]);
             customerRec.setServiceEndTimeEnd(res[1].replace("00:00:00","23:59:59"));
-            ipage = customerRecService.findAllCustomerRec(page, customerRec);
+            ipage = customerRecService.findAllCustomerRecWarning(page, customerRec);
         }else{
             Param param = paramService.getParamsByParamName("CUST_EARLY_WARNING");
-            ipage = customerRecService.findAllCustomerRec(page, customerRec);
+            ipage = customerRecService.findAllCustomerRecWarning(page, customerRec);
             List<CustomerRec> lists = ipage.getRecords();
             if(lists.size()>0){
                 //遍历删除
                 Iterator<CustomerRec> iterator = lists.iterator();
                 while (iterator.hasNext()) {
                     CustomerRec customerRec1 = iterator.next();
-                    if (Integer.valueOf(param.getParamValue()) <= (DateUtil.daysBetween(customerRec1.getServiceEndTime(),new Date()))) {
+                    if (((DateUtil.daysBetween(customerRec1.getServiceEndTime(),new Date()) < 0 ) )
+                            || (Integer.valueOf(param.getParamValue()) <= (DateUtil.daysBetween(customerRec1.getServiceEndTime(),new Date())))) {
                         iterator.remove();//使用迭代器的删除方法删除
                     }
                 }

+ 11 - 0
src/main/java/com/jkcredit/invoice/credit/InterfaceCheckServer.java

@@ -245,6 +245,17 @@ public class InterfaceCheckServer {
                     statisRequestIdTimeComp.removeReQuestIdAndTime(requestid);
                 }
                 break;
+
+            case "RED_INK_INVOICE_QUERY"://无车  红冲发票查询接口
+                if(StatisRequestIdTimeComp.isLimit){
+                    log.info("InterfaceCheckServer.doJumpHandler,appKey=" + appKey + " ,api="+api + " ,data=" + data + " ,requestid=" + requestid +"=被拒绝");
+                    result = resultTimeOut;
+                }else{
+                    statisRequestIdTimeComp.putReQuestIdAndTime(requestid);
+                    result = noCarInterService.redInkInvoiceQuery(appKey,api,data,requestid);
+                    statisRequestIdTimeComp.removeReQuestIdAndTime(requestid);
+                }
+                break;
             default:
                 result = null;
                 break;

+ 1 - 0
src/main/java/com/jkcredit/invoice/credit/SimpleCORSFilter.java

@@ -64,6 +64,7 @@ public class SimpleCORSFilter implements Filter {
             put( "WAY_BILL_NUM_FIND_INVOICE" ,  "1");// 运单号查询发票数据
             put( "FIND_NO_SEARCH_NUM" ,  "1");//获取未查询过发票的运单编号
             put( "BALANCE_QUERY" ,  "1");//账号余额查询
+            put( "RED_INK_INVOICE_QUERY" ,  "1");//红冲发票查询
 
 
             //自有车下游客户调用接口

+ 3 - 0
src/main/java/com/jkcredit/invoice/credit/interserver/NoCarInterService.java

@@ -30,4 +30,7 @@ public interface NoCarInterService {
 
     //无车 账户余额查询接口
     DataResult balanceQuery(String appKey, String api, String data, String requestid);
+
+    //无车红冲发票查询接口
+    DataResult redInkInvoiceQuery(String appKey, String api, String data, String requestid);
 }

+ 79 - 0
src/main/java/com/jkcredit/invoice/credit/interserver/NoCarInterServiceImpl.java

@@ -15,6 +15,7 @@ import com.jkcredit.invoice.model.entity.manager.Param;
 import com.jkcredit.invoice.model.entity.waybill.NoCarWayBill;
 import com.jkcredit.invoice.service.customer.CustomerRecService;
 import com.jkcredit.invoice.service.lowerservice.NoCarService;
+import com.jkcredit.invoice.service.lowerservice.vo.HCInvoiceQueryVo;
 import com.jkcredit.invoice.service.manager.ParamService;
 import com.jkcredit.invoice.service.nocar.NoCarBillWayImportService;
 import com.jkcredit.invoice.util.DateUtil;
@@ -823,6 +824,84 @@ public class NoCarInterServiceImpl implements NoCarInterService {
     }
 
 
+
+
+    /**
+     * 无车  红冲发票查询接口
+     * @param appKey
+     * @param api
+     * @param data
+     * @return
+     */
+    @Override
+    public DataResult redInkInvoiceQuery(String appKey, String api, String data,String requestid) {
+        long costtimestart = System.currentTimeMillis();
+
+        DataResult result = new DataResult();
+
+        result.setData(3);
+        result.setCode(200);
+        result.setRequestid(requestid);
+        result.setMsg("无法认证");
+
+        try {
+            log.info("[-NoCarInterServiceImpl.redInkInvoiceQuery-] request appKey=" + appKey + " ,api=" + api + " ,data=" +data+ " ,requestid=" +requestid);
+            JSONObject jsonObject = JSONObject.parseObject(data);
+            String companyNum =  jsonObject.getString("companyNum");//企业编号 必输
+            String month = jsonObject.getString("month");//开票月份 样例:yyyy-MM   必输
+            if(StringUtils.isEmpty(data)|| null == jsonObject){
+                return  result;
+            }
+            if( StringUtils.isEmpty(companyNum) || StringUtils.isEmpty(month)
+                    ){
+                return  result;
+            }
+
+
+            if (  null == DateUtil.parseDate(month)){
+                result.setMsg("日期格式不正确!");
+                return  result;
+            }
+            CustomerRec customerRec2 = new CustomerRec();
+            customerRec2.setCustomerName(appKey);
+            customerRec2.setCompanyNum(companyNum);
+            CustomerRec customerRec1 = customerRecMapper.selectByCustomerNameAndCompanyNum(customerRec2);
+            if (null == customerRec1 || customerRec1.getRecStatus() != 1){
+                result.setMsg("企业还未备案成功!");
+                return result;
+            }
+
+            HCInvoiceQueryVo hcInvoiceQueryVo = new HCInvoiceQueryVo();
+            hcInvoiceQueryVo.setCustomerName(appKey);
+            hcInvoiceQueryVo.setCompanyNum(companyNum);
+            hcInvoiceQueryVo.setCompanyName(customerRec1.getCompanyName());
+            hcInvoiceQueryVo.setMonth(month);
+            RespR rs = noCarService.hCInvoiceQuery(hcInvoiceQueryVo);
+
+            long costtimeend = System.currentTimeMillis();
+            log.info("[-NoCarInterServiceImpl.redInkInvoiceQuery-] result is "
+                    + rs.toString() + ", request is " + data + " ,costtime="
+                    + (costtimeend - costtimestart));
+            if(null != rs && rs.getCode() == 0){
+                result.setData(1);
+                result.setCode(200);
+                result.setMsg(rs.getData().toString());
+                return result;
+            } else {
+                result.setData(3);
+                result.setCode(200);
+                result.setMsg(rs.getMsg());
+                return result;
+            }
+        } catch (Exception e) {
+            log.error("[-NoCarInterServiceImpl.redInkInvoiceQuery-] get httpclient exception is "
+                    + e + ", request is " + data);
+        }
+
+        return result;
+    }
+
+
     public static void main(String[] args) {
             List<String> list1 = new ArrayList<String>();
             list1.add("1");

+ 4 - 0
src/main/java/com/jkcredit/invoice/mapper/customer/CustomerRecMapper.java

@@ -39,5 +39,9 @@ public interface CustomerRecMapper extends BaseMapper<CustomerRec> {
     int updateByPrimaryKey(CustomerRec record);
     IPage<List<CustomerRec>> selectAllByPage(Page page, @Param("customerRec") CustomerRec customerRec);
 
+
+    IPage<List<CustomerRec>> selectAllByPageWarning(Page page, @Param("customerRec") CustomerRec customerRec);
+
+
     List<CustomerRec> selectAllByPageExport( @Param("customerRec") CustomerRec customerRec);
 }

+ 10 - 0
src/main/java/com/jkcredit/invoice/service/customer/CustomerRecService.java

@@ -16,6 +16,16 @@ public interface CustomerRecService {
     IPage findAllCustomerRec(Page page, CustomerRec customerRec);
 
 
+
+    /**
+     * 查找所有备案信息(备案预警查询)
+     * @param page
+     * @param customerRec
+     * @return
+     */
+    IPage findAllCustomerRecWarning(Page page, CustomerRec customerRec);
+
+
     /**
      * 客户信息导出
      * @param customerRec

+ 13 - 0
src/main/java/com/jkcredit/invoice/service/customer/impl/CustomerRecServiceImpl.java

@@ -27,6 +27,19 @@ public class CustomerRecServiceImpl extends ServiceImpl<CustomerRecMapper,Custom
         return customerRecMapper.selectAllByPage(page,customerRec);
     }
 
+
+    /**
+     * 查找所有备案信息(备案预警查询)
+     * @param page
+     * @param customerRec
+     * @return
+     */
+    @Override
+    public IPage findAllCustomerRecWarning(Page page, CustomerRec customerRec) {
+        return customerRecMapper.selectAllByPageWarning(page,customerRec);
+    }
+
+
     /**
      * 客户信息导出
      * @param customerRec

+ 13 - 0
src/main/java/com/jkcredit/invoice/service/lowerservice/impl/CustomerLowerServiceImpl.java

@@ -89,10 +89,23 @@ public class CustomerLowerServiceImpl implements CustomeLowerService {
                 res.append("#"+customerRec.getCompanyName()+"业务类型有误;#");
                 return;
             }
+
+
             if(StringUtils.isEmpty(customerRec.getCompanyName()) || StringUtils.isEmpty(customerRec.getCompanyReferencenum())){
                 res.append("企业备案名称或税号为空");
                 return;
             }
+
+            if("2".equals(customerRec.getBussinessType()) && customerRec.getCompanyType() != 3){
+                res.append("#无车公司类型必须为合作商户#");
+                return;
+            }
+
+            if("0".equals(customerRec.getBussinessType()) && customerRec.getCompanyType() != 1){
+                res.append("#自有车公司类型必须为行业用户#");
+                return;
+            }
+
             //默认备案状态为备案中 2-失败 1-成功 3-等待协议上传 4-停用 0-备案中
             customerRec.setRecStatus(0);
             //主动查询上游接口,如果已经备案则更新

+ 3 - 8
src/main/java/com/jkcredit/invoice/service/lowerservice/impl/NoCarServiceImpl.java

@@ -692,8 +692,8 @@ public class NoCarServiceImpl implements NoCarService{
     public RespR hCInvoiceQuery(HCInvoiceQueryVo hcInvoiceQueryVo) {
         log.info("取红冲票啦:NoCarServiceImpl.hCInvoiceQuery{}",hcInvoiceQueryVo);
         WaybillInvoiceRedQueryRequest redQueryRequest = new WaybillInvoiceRedQueryRequest();
-        String companyNum = paramService.getParamsByParamName("REQUEST_COMPANY_NUM").getParamValue();
-        redQueryRequest.setCompanyNum(companyNum);
+        //String companyNum = paramService.getParamsByParamName("REQUEST_COMPANY_NUM").getParamValue();
+        redQueryRequest.setCompanyNum(hcInvoiceQueryVo.getCompanyNum());
         redQueryRequest.setMonth(hcInvoiceQueryVo.getMonth());
 
         RespR<WaybillInvoiceRedQueryResponse> respR = noCarInterface.waybillInvoiceRedQuery(redQueryRequest);
@@ -701,12 +701,7 @@ public class NoCarServiceImpl implements NoCarService{
             log.info("取红冲票失败啦:NoCarServiceImpl.hCInvoiceQuery{},msg{}",hcInvoiceQueryVo,respR.getMsg());
             return new RespR(false,respR.getMsg());
         }
-        if(StringUtils.isEmpty(hcInvoiceQueryVo.getCompanyName())){
-            return new RespR(respR.getData().getResult());
-        }else{
-            return new RespR(respR.getData().getResult().stream().filter(ele->ele.getBuyerName().equals(hcInvoiceQueryVo.getCompanyName())).collect(Collectors.toList()));
-        }
-
+            return respR;
     }
     @Override
     public RespR monthAccQuery(MonthAccountQueryVo monthAccountQueryVo) {

+ 1 - 1
src/main/java/com/jkcredit/invoice/service/nocar/impl/NoCarBillWayServiceImpl.java

@@ -272,7 +272,7 @@ public class NoCarBillWayServiceImpl extends ServiceImpl<NoCarWaybillMapper,NoCa
                             respR = noCarService.noCarHisWaybillEnd(noCarWayBillClo);
 
                             if(respR.getCode() == 1){
-                                noCarWaybillMapperImprt.updateBillway(1,respR.getMsg(),noCarWayBill);
+                                noCarWaybillMapperImprt.updateBillway(-3,respR.getMsg(),noCarWayBill);
                                 log.info(noCarWayBill.getBillNum()+"#结束指令失败"+respR.getMsg());
                                 stringBuffer.append("#").append(noCarWayBill.getBillNum()).append(":").append(respR.getMsg()).append("#");
                             }else{

+ 13 - 0
src/main/java/com/jkcredit/invoice/util/DateUtil.java

@@ -1,5 +1,6 @@
 package com.jkcredit.invoice.util;
 
+import org.apache.commons.lang3.time.DateUtils;
 import org.joda.time.DateTime;
 import org.joda.time.format.DateTimeFormat;
 import org.joda.time.format.DateTimeFormatter;
@@ -329,6 +330,18 @@ public class DateUtil {
 
 
 
+    private static String[] parsePatterns = {"yyyy-MM"};
+
+    public static Date parseDate(String str) {
+        if (str == null) {
+            return null;
+        }
+        try {
+            return DateUtils.parseDate(str, parsePatterns);
+        } catch (ParseException e) {
+            return null;
+        }
+    }
 
 
 }

+ 35 - 0
src/main/resources/mapper/customer/CustomerRecMapper.xml

@@ -63,6 +63,41 @@
     </where>
       order by id DESC
   </select>
+
+
+
+  <select id="selectAllByPageWarning" resultMap="BaseResultMap">
+    select
+    <include refid="Base_Column_List" />
+    from t_customer_rec
+    <where>
+      <if test="customerRec.customerName != null and customerRec.customerName != ''">
+        AND   customerName = BINARY #{customerRec.customerName}
+      </if>
+      <if test="customerRec.companyLeaderPhone != null and customerRec.companyLeaderPhone != ''">
+        and  company_leader_Phone = BINARY #{customerRec.companyLeaderPhone}
+      </if>
+      <if test="customerRec.companyReferencenum != null and customerRec.companyReferencenum != ''">
+        and  company_referenceNum = BINARY #{customerRec.companyReferencenum}
+      </if>
+      <if test="customerRec.companyName != null and customerRec.companyName != ''">
+        and  company_name  LIKE BINARY CONCAT('%',#{customerRec.companyName},'%')
+      </if>
+      <if test="customerRec.companyBelongName != null and customerRec.companyBelongName != ''">
+        and company_belong_name  LIKE CONCAT('%',#{customerRec.companyBelongName},'%')
+      </if>
+      <if test="customerRec.serviceEndTimeStart != null and customerRec.serviceEndTimeStart != ''">
+        and service_endTime BETWEEN #{customerRec.serviceEndTimeStart} and #{customerRec.serviceEndTimeEnd}
+      </if>
+        and  rec_status = 1
+        and service_endTime is not null
+
+    </where>
+    order by id DESC
+  </select>
+
+
+
   <select id="selectAllByPageExport" resultMap="BaseResultMap">
     select
     <include refid="Base_Column_List" />