NoCarInterServiceImpl.java 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143
  1. package com.jkcredit.invoice.credit.interserver;
  2. import cn.com.taiji.sdk.model.comm.protocol.tts.vehicle.VehicleQueryResponse;
  3. import com.alibaba.fastjson.JSON;
  4. import com.alibaba.fastjson.JSONObject;
  5. import com.jkcredit.invoice.common.DataResult;
  6. import com.jkcredit.invoice.mapper.binvoce.BillInvoiceMapper;
  7. import com.jkcredit.invoice.mapper.customer.CustomerCarRecMapper;
  8. import com.jkcredit.invoice.mapper.customer.CustomerMapper;
  9. import com.jkcredit.invoice.mapper.waybill.NoCarWaybillMapper;
  10. import com.jkcredit.invoice.model.entity.customer.Customer;
  11. import com.jkcredit.invoice.model.entity.customer.CustomerCarRec;
  12. import com.jkcredit.invoice.model.entity.customer.CustomerRec;
  13. import com.jkcredit.invoice.model.entity.invoice.BillInvoice;
  14. import com.jkcredit.invoice.model.entity.manager.Param;
  15. import com.jkcredit.invoice.model.entity.waybill.NoCarWayBill;
  16. import com.jkcredit.invoice.model.entity.waybill.NoCarWayBillFileInfo;
  17. import com.jkcredit.invoice.service.customer.CustomerRecService;
  18. import com.jkcredit.invoice.service.lowerservice.NoCarService;
  19. import com.jkcredit.invoice.service.lowerservice.vo.HcInvoiceQueryVo;
  20. import com.jkcredit.invoice.service.manager.ParamService;
  21. import com.jkcredit.invoice.service.nocar.NoCarBillWayImportService;
  22. import com.jkcredit.invoice.service.nocar.WayBillFileService;
  23. import com.jkcredit.invoice.util.DateUtil;
  24. import com.jkcredit.invoice.util.RespR;
  25. import com.jkcredit.invoice.util.StringUtil;
  26. import lombok.extern.slf4j.Slf4j;
  27. import net.sf.json.JSONArray;
  28. import org.apache.commons.lang3.StringUtils;
  29. import org.springframework.beans.factory.annotation.Autowired;
  30. import org.springframework.stereotype.Service;
  31. import java.util.ArrayList;
  32. import java.util.List;
  33. import static com.jkcredit.invoice.common.CommonConst.COMPUTE;
  34. import static com.jkcredit.invoice.common.CommonConst.NOT_FOUND;
  35. import static com.jkcredit.invoice.common.CommonConst.ONE;
  36. import static com.jkcredit.invoice.common.CommonConst.REC_STATUS_UN;
  37. import static com.jkcredit.invoice.common.CommonConst.REC_STATUS_WAIT;
  38. import static com.jkcredit.invoice.common.CommonConst.RESULT;
  39. import static com.jkcredit.invoice.common.CommonConst.SELF_CAR;
  40. import static com.jkcredit.invoice.common.CommonConst.XY_WAYBILL_HISTORY_END;
  41. import static java.util.stream.Collectors.toList;
  42. /**
  43. * 无车操作接口实现类
  44. * @author mumuxigua
  45. */
  46. @Service("noCarInterService")
  47. @Slf4j
  48. public class NoCarInterServiceImpl implements NoCarInterService {
  49. private static final String PDF = "pdf";
  50. @Autowired
  51. NoCarBillWayImportService noCarWaybillMapperImprt;
  52. @Autowired
  53. CustomerCarRecMapper customerCarRecMapper;
  54. @Autowired
  55. NoCarWaybillMapper noCarWaybillMapper;
  56. @Autowired
  57. CustomerRecService customerRecMapper;
  58. @Autowired
  59. BillInvoiceMapper billInvoiceMapper;
  60. @Autowired
  61. CustomerMapper customerMapper;
  62. @Autowired
  63. ParamService paramService;
  64. @Autowired
  65. private NoCarService noCarService;
  66. @Autowired
  67. private WayBillFileService wayBillFileService;
  68. public static void main(String[] args) {
  69. List<String> list1 = new ArrayList<String>();
  70. list1.add("1");
  71. list1.add("2");
  72. list1.add("3");
  73. list1.add("5");
  74. list1.add("6");
  75. List<String> list2 = new ArrayList<String>();
  76. list2.add("2");
  77. list2.add("3");
  78. list2.add("7");
  79. list2.add("8");
  80. // 交集
  81. List<String> intersection = list1.stream().filter(item -> list2.contains(item)).collect(toList());
  82. System.out.println("---交集 intersection---");
  83. intersection.parallelStream().forEach(System.out::println);
  84. // 差集 (list1 - list2)
  85. List<String> reduce1 = list1.stream().filter(item -> !list2.contains(item)).collect(toList());
  86. System.out.println("---差集 reduce1 (list1 - list2)---");
  87. // 并集
  88. reduce1.parallelStream().forEach(System.out::println);
  89. List<String> listAll = list1.parallelStream().collect(toList());
  90. List<String> listAll2 = list2.parallelStream().collect(toList());
  91. listAll.addAll(listAll2);
  92. System.out.println("---并集 listAll---");
  93. listAll.parallelStream().forEachOrdered(System.out::println);
  94. // 去重并集
  95. List<String> listAllDistinct = listAll.stream().distinct().collect(toList());
  96. System.out.println("---得到去重并集 listAllDistinct---");
  97. listAllDistinct.parallelStream().forEachOrdered(System.out::println);
  98. System.out.println("---原来的List1---");
  99. list1.parallelStream().forEachOrdered(System.out::println);
  100. System.out.println("---原来的List2---");
  101. list2.parallelStream().forEachOrdered(System.out::println);
  102. }
  103. /**
  104. * 无车 车辆备案接口
  105. *
  106. * @param appKey
  107. * @param api
  108. * @param data
  109. * @return
  110. */
  111. @Override
  112. public DataResult customerCarRec(String appKey, String api, String data, String requestid) {
  113. long costtimestart = System.currentTimeMillis();
  114. DataResult result = new DataResult();
  115. result.setData(3);
  116. result.setCode(200);
  117. result.setRequestid(requestid);
  118. result.setMsg("无法认证");
  119. try {
  120. log.info("[-NoCarInterServiceImpl.customerCarRec-] request appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid);
  121. JSONObject jsonObject = JSONObject.parseObject(data);
  122. //企业名称 选输
  123. String companyName = jsonObject.getString("companyName");
  124. //plateNumber 必输
  125. String plateNumber = jsonObject.getString("plateNumber");
  126. //plateColor 必输
  127. String plateColor = jsonObject.getString("plateColor");
  128. if (StringUtils.isEmpty(data) || null == jsonObject || StringUtils.isEmpty(plateNumber)
  129. || StringUtils.isEmpty(plateColor)
  130. ) {
  131. result.setMsg("必传参数有空值");
  132. return result;
  133. }
  134. List<CustomerCarRec> customerCarRecList = new ArrayList<CustomerCarRec>();
  135. CustomerCarRec customerCarRec = new CustomerCarRec();
  136. customerCarRec.setCustomerName(appKey);
  137. Customer cust = customerMapper.selectByCustomerName(appKey);
  138. CustomerRec customerRec = new CustomerRec();
  139. customerRec.setCustomerName(appKey);
  140. customerRec.setCompanyName(cust.getCompany());
  141. CustomerRec customerRec1 = customerRecMapper.selectByCustomerNameAndCompanyConcat(customerRec);
  142. if (null == customerRec1) {
  143. result.setMsg("该客户: " + appKey + " 未备案企业");
  144. return result;
  145. }
  146. customerCarRec.setCompanyName(customerRec1.getCompanyName());
  147. customerCarRec.setCustomerName(customerRec1.getCustomerName());
  148. //无车
  149. customerCarRec.setBusinessType("2");
  150. customerCarRec.setCarColor(plateColor);
  151. customerCarRec.setCarNum(plateNumber);
  152. customerCarRec.setInterType(0);
  153. if (SELF_CAR.equals(customerCarRec.getCarColor())) {
  154. //默认运营车辆
  155. customerCarRec.setServiceOperation(1);
  156. }
  157. customerCarRecList.add(customerCarRec);
  158. return getDataResultss(data, costtimestart, result, noCarService.customerCarRec(customerCarRecList), "[-NoCarInterServiceImpl.customerCarRec-] result is ");
  159. } catch (Exception e) {
  160. log.error("[-NoCarInterServiceImpl.customerCarRec-] get httpclient exception is "
  161. + e + ", request is " + data);
  162. }
  163. return result;
  164. }
  165. /**
  166. * 无车 车辆备案查询接口
  167. *
  168. * @param appKey
  169. * @param api
  170. * @param data
  171. * @return
  172. */
  173. @Override
  174. public DataResult customeRecUpperQuery(String appKey, String api, String data, String requestid) {
  175. long costtimestart = System.currentTimeMillis();
  176. DataResult result = new DataResult();
  177. result.setData(3);
  178. result.setCode(200);
  179. result.setRequestid(requestid);
  180. result.setMsg("无法认证");
  181. try {
  182. log.info("[-NoCarInterServiceImpl.customeRecUpperQuery-] request appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid);
  183. JSONObject jsonObject = JSONObject.parseObject(data);
  184. //备案来源 选输
  185. String waybillSource = jsonObject.getString("waybillSource");
  186. //plateNumber 必输
  187. String plateNumber = jsonObject.getString("plateNumber");
  188. //plateColor 必输
  189. String plateColor = jsonObject.getString("plateColor");
  190. if (StringUtils.isEmpty(data) || null == jsonObject || StringUtils.isEmpty(plateNumber)
  191. || StringUtils.isEmpty(plateColor)
  192. ) {
  193. result.setMsg("必传参数有空值");
  194. return result;
  195. }
  196. CustomerCarRec customerCarRec = new CustomerCarRec();
  197. Param param = paramService.getParamsByParamName("REQUEST_COMPANY_NUM");
  198. //无车,车辆备案,运单上传,运单查询都是统一用交科的企业编号;自有车用客户的企业编号
  199. customerCarRec.setCompanyNum(param.getParamValue());
  200. customerCarRec.setCarColor(plateColor);
  201. customerCarRec.setCarNum(plateNumber);
  202. customerCarRec.setCustomerName(appKey);
  203. //无车
  204. customerCarRec.setBusinessType("2");
  205. //此处代表仅查询上游接口,无任何处理逻辑
  206. customerCarRec.setInterType(8);
  207. RespR rs = noCarService.customerCarRecQueryUpper(customerCarRec);
  208. long costtimeend = System.currentTimeMillis();
  209. log.info("[-NoCarInterServiceImpl.customeRecUpperQuery-] result is "
  210. + rs.toString() + ", request is " + data + " ,costtime="
  211. + (costtimeend - costtimestart));
  212. if (null != rs && rs.getCode() == 0) {
  213. result.setData(1);
  214. result.setCode(200);
  215. result.setMsg(rs.getData().toString());
  216. JSONObject jb = JSONObject.parseObject(rs.getData().toString());
  217. result.setData(1);
  218. result.setMsg("车辆已备案");
  219. if (null == jb.getJSONArray(RESULT) || jb.getJSONArray(RESULT).size() == 0) {
  220. result.setData(2);
  221. result.setMsg("车辆未备案");
  222. }
  223. return result;
  224. } else {
  225. result.setData(3);
  226. result.setCode(200);
  227. result.setMsg("查询失败");
  228. return result;
  229. }
  230. } catch (Exception e) {
  231. log.error("[-NoCarInterServiceImpl.customeRecUpperQuery-] get httpclient exception is "
  232. + e + ", request is " + data);
  233. }
  234. return result;
  235. }
  236. /**
  237. * 无车 实时运单开始指令接口
  238. *
  239. * @param appKey
  240. * @param api
  241. * @param data
  242. * @return
  243. */
  244. @Override
  245. public DataResult noCarBillStart(String appKey, String api, String data, String requestid) {
  246. long costtimestart = System.currentTimeMillis();
  247. DataResult result = new DataResult();
  248. result.setData(3);
  249. result.setCode(200);
  250. result.setRequestid(requestid);
  251. result.setMsg("无法认证");
  252. try {
  253. log.info("[-NoCarInterServiceImpl.noCarBillStart-] request appKey=" + appKey + " ,api=" + api + " ,data=" + StringUtil.removeJSonField(data,"base64Str") + " ,requestid=" + requestid);
  254. JSONObject jsonObject = JSONObject.parseObject(data);
  255. //运单编号 必选
  256. String num = jsonObject.getString("num");
  257. //车牌号 必选
  258. String plateNumber = jsonObject.getString("plateNumber");
  259. //车牌颜色 必选
  260. String plateColor = jsonObject.getString("plateColor");
  261. //运单开始时间 必选
  262. String startTime = jsonObject.getString("startTime");
  263. //运单开始地址 必选
  264. String sourceAddr = jsonObject.getString("sourceAddr");
  265. //运单目的地址 必选
  266. String destAddr = jsonObject.getString("destAddr");
  267. //运单预计完成时间 必选
  268. String predictEndTime = jsonObject.getString("predictEndTime");
  269. //运单费用 必选
  270. Integer fee = jsonObject.getInteger("fee");
  271. //发票抬头类型 必选
  272. Integer titleType = jsonObject.getInteger("titleType");
  273. //税号 必选
  274. String taxplayerCode = jsonObject.getString("taxplayerCode");
  275. //base流文件 必选
  276. String base64Str = jsonObject.getString("base64Str");
  277. //运单协议名称 必选
  278. String waybillFileName = jsonObject.getString("waybillFileName");
  279. //运单类型 必选
  280. Integer contractType = jsonObject.getInteger("contractType");
  281. if (StringUtils.isEmpty(data) || null == jsonObject
  282. || StringUtils.isEmpty(num)
  283. || StringUtils.isEmpty(plateNumber)
  284. || StringUtils.isEmpty(plateColor)
  285. || StringUtils.isEmpty(startTime)
  286. || StringUtils.isEmpty(sourceAddr)
  287. || StringUtils.isEmpty(destAddr)
  288. || StringUtils.isEmpty(predictEndTime)
  289. || null == fee
  290. || null == titleType
  291. || StringUtils.isEmpty(taxplayerCode)
  292. /*|| StringUtils.isEmpty(base64Str)
  293. || StringUtils.isEmpty(waybillFileName)
  294. || null == contractType*/
  295. ) {
  296. result.setMsg("必传参数有空值");
  297. return result;
  298. }
  299. if (!DateUtil.isValidDate(startTime)) {
  300. result.setMsg("日期格式有误");
  301. return result;
  302. }
  303. if (!DateUtil.isValidDate(predictEndTime)) {
  304. result.setMsg("日期格式有误");
  305. return result;
  306. }
  307. if(StringUtils.isNotBlank(waybillFileName) && StringUtils.isNotBlank(base64Str) && null != contractType){
  308. String fileType = waybillFileName.substring(waybillFileName.lastIndexOf(".") + 1).toLowerCase();
  309. if (!PDF.equals(fileType)) {
  310. result.setMsg("必须是pdf文件!");
  311. return result;
  312. }
  313. int base64StrLength = base64Str.length();
  314. if (COMPUTE < base64StrLength) {
  315. result.setMsg("pdf不可超过10M!");
  316. return result;
  317. }
  318. base64Str = base64Str.replaceAll(" ", "+");
  319. }
  320. CustomerRec customerRec = new CustomerRec();
  321. customerRec.setCustomerName(appKey);
  322. customerRec.setCompanyReferencenum(taxplayerCode);
  323. customerRec = customerRecMapper.selectByCustomerNameAndCompanyReference(customerRec);
  324. if (customerRec == null || customerRec.getRecStatus() != 1) {
  325. result.setMsg("客户:" + appKey + ";税号" + taxplayerCode + "未在平台备案成功,请先做备案");
  326. return result;
  327. }
  328. NoCarWayBill noCarWayBill = getNoCarWayBill(appKey, num, plateNumber, plateColor, startTime, sourceAddr, destAddr, predictEndTime, fee, titleType, taxplayerCode, customerRec);
  329. noCarWayBill.setWaybillFileName(waybillFileName);
  330. noCarWayBill.setBase64Str(base64Str);
  331. noCarWayBill.setContractType(contractType);
  332. DataResult dataResult = getDataResult(appKey, data, costtimestart, result, customerRec, noCarWayBill);
  333. try {
  334. if(dataResult.getCode() == 0 && StringUtils.isNotBlank(waybillFileName) && StringUtils.isNotBlank(base64Str)){
  335. NoCarWayBillFileInfo noCarWayBillFileInfo = new NoCarWayBillFileInfo();
  336. noCarWayBillFileInfo.setBase64Str(base64Str);
  337. noCarWayBillFileInfo.setFileName(waybillFileName);
  338. noCarWayBillFileInfo.setBatchNum("接口运单");
  339. noCarWayBillFileInfo.setWayBillNum(num);
  340. noCarWayBillFileInfo.setCustomerId(appKey);
  341. noCarWayBillFileInfo.setCompanyName(noCarWayBill.getCompanyName());
  342. noCarWayBillFileInfo.setUpdateTime(DateUtil.getCurrentDateStr());
  343. wayBillFileService.insert(noCarWayBillFileInfo);
  344. }
  345. }catch (Exception e){
  346. e.printStackTrace();
  347. log.info("文件入表失败{}",noCarWayBill.getBillNum());
  348. }
  349. return dataResult;
  350. } catch (Exception e) {
  351. log.error("[-NoCarInterServiceImpl.noCarBillStart-] get httpclient exception is "
  352. + e + ", request is " + StringUtil.removeJSonField(data,"base64Str"));
  353. }
  354. return result;
  355. }
  356. private DataResult getDataResult(String appKey, String data, long costtimestart, DataResult result, CustomerRec customerRec, NoCarWayBill noCarWayBill) {
  357. List<CustomerCarRec> customerCarRecs = new ArrayList<>();
  358. CustomerCarRec customerCarRec = new CustomerCarRec();
  359. customerCarRec.setCompanyName(noCarWayBill.getCompanyName());
  360. customerCarRec.setCarNum(noCarWayBill.getPlateNum());
  361. customerCarRec.setCarColor(noCarWayBill.getPlateColor());
  362. customerCarRec.setCustomerName(appKey);
  363. //接口
  364. customerCarRec.setInterType(0);
  365. customerCarRec.setCompanyNum(customerRec.getCompanyNum());
  366. customerCarRec.setBusinessType("2");
  367. //默认运营车辆
  368. customerCarRec.setServiceOperation(1);
  369. noCarWayBill.setTitleType(2);
  370. //接口
  371. noCarWayBill.setInterType(0);
  372. return getDataResult(data, costtimestart, result, noCarWayBill, customerCarRecs, customerCarRec);
  373. }
  374. private NoCarWayBill getNoCarWayBill(String appKey, String num, String plateNumber, String plateColor, String startTime, String sourceAddr, String destAddr, String predictEndTime, Integer fee, Integer titleType, String taxplayerCode, CustomerRec customerRec) {
  375. NoCarWayBill noCarWayBill = new NoCarWayBill();
  376. noCarWayBill.setCustomerName(appKey);
  377. noCarWayBill.setCompanyName(customerRec.getCompanyName());
  378. noCarWayBill.setPlateNum(plateNumber);
  379. noCarWayBill.setBillNum(num);
  380. noCarWayBill.setPlateColor(plateColor);
  381. noCarWayBill.setStartTime(DateUtil.getDistanceHoursFormat(startTime));
  382. noCarWayBill.setSourceAddr(sourceAddr);
  383. noCarWayBill.setDestAddr(destAddr);
  384. noCarWayBill.setPredictEndTime(DateUtil.getDistanceHoursFormat(predictEndTime));
  385. noCarWayBill.setFee(fee.longValue());
  386. noCarWayBill.setTitleType(titleType);
  387. noCarWayBill.setTaxplayerCode(taxplayerCode);
  388. noCarWayBill.setHisFlag(0);
  389. noCarWayBill.setIntfaceStartTime(DateUtil.getCurrentDateStr());
  390. return noCarWayBill;
  391. }
  392. private DataResult getDataResult(String data, long costtimestart, DataResult result, NoCarWayBill noCarWayBill, List<CustomerCarRec> customerCarRecs, CustomerCarRec customerCarRec) {
  393. //先查询上游是否已经备案
  394. RespR<VehicleQueryResponse> respRquery = noCarService.customerCarRecQueryUpper(customerCarRec);
  395. if (respRquery.getCode() == 1 || respRquery.getData() == null || respRquery.getData().getResult() == null || respRquery.getData().getResult().size() <= 0) {
  396. customerCarRecs.add(customerCarRec);
  397. RespR respR = noCarService.customerCarRec(customerCarRecs);
  398. if (respR.getCode() == 1) {
  399. noCarWayBill.setFailReason(respR.getMsg());
  400. noCarWayBill.setBillwayStatus(-2);
  401. insertOrUpdateBillStart(noCarWayBill);
  402. result.setMsg("车牌号备案失败,失败原因:" + respR.getMsg());
  403. return result;
  404. }
  405. }
  406. return getDataResultss(data, costtimestart, result, noCarService.noCarWaybillStart(noCarWayBill), "[-NoCarInterServiceImpl.noCarBillStart-] result is ");
  407. }
  408. /**
  409. * 无车 实时运单结束指令接口
  410. *
  411. * @param appKey
  412. * @param api
  413. * @param data
  414. * @return
  415. */
  416. @Override
  417. public DataResult noCarBillEnd(String appKey, String api, String data, String requestid) {
  418. long costtimestart = System.currentTimeMillis();
  419. DataResult result = new DataResult();
  420. result.setData(3);
  421. result.setCode(200);
  422. result.setRequestid(requestid);
  423. result.setMsg("无法认证");
  424. try {
  425. log.info("[-NoCarInterServiceImpl.noCarBillEnd-] request appKey=" + appKey + " ,api=" + api + " ,data=" + StringUtil.removeJSonField(data,"base64Str") + " ,requestid=" + requestid);
  426. JSONObject jsonObject = JSONObject.parseObject(data);
  427. //运单号 必输
  428. String num = jsonObject.getString("num");
  429. //运单实际目的地址 必输
  430. String realDestAddr = jsonObject.getString("realDestAddr");
  431. //运单实际结束时间 必输
  432. String endTime = jsonObject.getString("endTime");
  433. if (StringUtils.isEmpty(data) || null == jsonObject || StringUtils.isEmpty(num)
  434. || StringUtils.isEmpty(realDestAddr)
  435. || StringUtils.isEmpty(endTime)
  436. ) {
  437. result.setMsg("必传参数有空值");
  438. return result;
  439. }
  440. if (!DateUtil.isValidDate(endTime)) {
  441. result.setMsg("日期格式有误");
  442. return result;
  443. }
  444. NoCarWayBill noCarWayBill = new NoCarWayBill();
  445. noCarWayBill.setCustomerName(appKey);
  446. noCarWayBill.setBillNum(num);
  447. noCarWayBill.setDestAddr(realDestAddr);
  448. noCarWayBill.setPredictEndTime(DateUtil.getDistanceHoursFormat(endTime));
  449. noCarWayBill.setHisFlag(0);
  450. //接口
  451. noCarWayBill.setInterType(0);
  452. return getDataResultss(data, costtimestart, result, noCarService.noCarWaybillEnd(noCarWayBill), "[-NoCarInterServiceImpl.noCarBillEnd-] result is ");
  453. } catch (Exception e) {
  454. log.error("[-NoCarInterServiceImpl.noCarBillEnd-] get httpclient exception is "
  455. + e + ", request is " + data);
  456. }
  457. return result;
  458. }
  459. /**
  460. * 无车 历史运单开始指令接口
  461. *
  462. * @param appKey
  463. * @param api
  464. * @param data
  465. * @return
  466. */
  467. @Override
  468. public DataResult noCarHisWaybillStart(String appKey, String api, String data, String requestid) {
  469. long costtimestart = System.currentTimeMillis();
  470. DataResult result = new DataResult();
  471. result.setData(3);
  472. result.setCode(200);
  473. result.setRequestid(requestid);
  474. result.setMsg("无法认证");
  475. try {
  476. log.info("[-NoCarInterServiceImpl.noCarHisWaybillStart-] request appKey=" + appKey + " ,api=" + api + " ,data=" + StringUtil.removeJSonField(data,"base64Str") + " ,requestid=" + requestid);
  477. JSONObject jsonObject = JSONObject.parseObject(data);
  478. //运单编号 必选
  479. String num = jsonObject.getString("num");
  480. //车牌号 必选
  481. String plateNumber = jsonObject.getString("plateNumber");
  482. //车牌颜色 必选
  483. String plateColor = jsonObject.getString("plateColor");
  484. //运单开始时间 必选
  485. String startTime = jsonObject.getString("startTime");
  486. //运单开始地址 必选
  487. String sourceAddr = jsonObject.getString("sourceAddr");
  488. //运单目的地址 必选
  489. String destAddr = jsonObject.getString("destAddr");
  490. //运单预计完成时间 必选
  491. String predictEndTime = jsonObject.getString("predictEndTime");
  492. //运单费用 必选
  493. Integer fee = jsonObject.getInteger("fee");
  494. //发票抬头类型 必选
  495. Integer titleType = jsonObject.getInteger("titleType");
  496. //税号 必选
  497. String taxplayerCode = jsonObject.getString("taxplayerCode");
  498. String base64Str = jsonObject.getString("base64Str");
  499. String waybillFileName = jsonObject.getString("waybillFileName");
  500. Integer contractType = jsonObject.getInteger("contractType");
  501. if (StringUtils.isEmpty(data) || null == jsonObject
  502. || StringUtils.isEmpty(num)
  503. || StringUtils.isEmpty(plateNumber)
  504. || StringUtils.isEmpty(plateColor)
  505. || StringUtils.isEmpty(startTime)
  506. || StringUtils.isEmpty(sourceAddr)
  507. || StringUtils.isEmpty(destAddr)
  508. || StringUtils.isEmpty(predictEndTime)
  509. || null == fee
  510. || null == titleType
  511. || StringUtils.isEmpty(taxplayerCode)
  512. /*|| StringUtils.isEmpty(base64Str)
  513. || StringUtils.isEmpty(waybillFileName)
  514. || null == contractType*/
  515. ) {
  516. result.setMsg("有空的必填运单要素,请检查");
  517. return result;
  518. }
  519. if (!DateUtil.isValidDate(startTime)) {
  520. result.setMsg("日期格式有误");
  521. return result;
  522. }
  523. if (!DateUtil.isValidDate(predictEndTime)) {
  524. result.setMsg("日期格式有误");
  525. return result;
  526. }
  527. CustomerRec customerRec = new CustomerRec();
  528. customerRec.setCustomerName(appKey);
  529. customerRec.setCompanyReferencenum(taxplayerCode);
  530. customerRec = customerRecMapper.selectByCustomerNameAndCompanyReference(customerRec);
  531. if (customerRec == null) {
  532. result.setMsg("客户:" + appKey + ";税号" + taxplayerCode + "未在平台备案成功,请先做备案");
  533. return result;
  534. }
  535. if(StringUtils.isNotBlank(waybillFileName) && StringUtils.isNotBlank(base64Str) && null != contractType){
  536. String fileType = waybillFileName.substring(waybillFileName.lastIndexOf(".") + 1).toLowerCase();
  537. if (!PDF.equals(fileType)) {
  538. result.setMsg("必须是pdf文件!");
  539. return result;
  540. }
  541. int base64StrLength = base64Str.length();
  542. if (COMPUTE < base64StrLength) {
  543. result.setMsg("pdf不可超过10M!");
  544. return result;
  545. }
  546. base64Str = base64Str.replaceAll(" ", "+");
  547. }
  548. NoCarWayBill noCarWayBill = getNoCarWayBills(appKey, num, plateNumber, plateColor, startTime, sourceAddr, destAddr, predictEndTime, fee, titleType, taxplayerCode, customerRec);
  549. noCarWayBill.setWaybillFileName(waybillFileName);
  550. noCarWayBill.setBase64Str(base64Str);
  551. noCarWayBill.setContractType(contractType);
  552. List<CustomerCarRec> customerCarRecs = new ArrayList<>();
  553. CustomerCarRec customerCarRec = new CustomerCarRec();
  554. customerCarRec.setCompanyName(noCarWayBill.getCompanyName());
  555. customerCarRec.setCarNum(noCarWayBill.getPlateNum());
  556. customerCarRec.setCarColor(noCarWayBill.getPlateColor());
  557. customerCarRec.setCustomerName(appKey);
  558. customerCarRec.setInterType(0);
  559. customerCarRec.setCompanyNum(customerRec.getCompanyNum());
  560. customerCarRec.setBusinessType("2");
  561. //默认运营车辆
  562. customerCarRec.setServiceOperation(1);
  563. noCarWayBill.setTitleType(2);
  564. if (checkCustomerCarRecQueryResult(result, noCarWayBill, customerCarRecs, customerCarRec)) {
  565. return result;
  566. }
  567. RespR respR = noCarService.noCarHisWaybillStart(noCarWayBill);
  568. try {
  569. if(respR.getCode() == 0 && StringUtils.isNotBlank(waybillFileName) && StringUtils.isNotBlank(base64Str) ){
  570. //上传成功后文件入库
  571. NoCarWayBillFileInfo noCarWayBillFileInfo = new NoCarWayBillFileInfo();
  572. noCarWayBillFileInfo.setBase64Str(base64Str);
  573. noCarWayBillFileInfo.setFileName(waybillFileName);
  574. noCarWayBillFileInfo.setBatchNum("接口运单");
  575. noCarWayBillFileInfo.setWayBillNum(num);
  576. noCarWayBillFileInfo.setUpdateTime(DateUtil.getCurrentDateStr());
  577. noCarWayBillFileInfo.setCustomerId(appKey);
  578. noCarWayBillFileInfo.setCompanyName(noCarWayBill.getCompanyName());
  579. wayBillFileService.insert(noCarWayBillFileInfo);
  580. }
  581. }catch (Exception e){
  582. e.printStackTrace();
  583. log.info("文件入表失败{}",noCarWayBill.getBillNum());
  584. }
  585. return getDataResultss(data, costtimestart, result, respR, "[-NoCarInterServiceImpl.noCarHisWaybillStart-] result is ");
  586. } catch (Exception e) {
  587. log.error("[-NoCarInterServiceImpl.noCarHisWaybillStart-] get httpclient exception is "
  588. + e + ", request is " + StringUtil.removeJSonField(data,"base64Str"));
  589. }
  590. return result;
  591. }
  592. private DataResult getDataResultss(String data, long costtimestart, DataResult result, RespR respR, String s) {
  593. RespR rs = respR;
  594. long costtimeend = System.currentTimeMillis();
  595. log.info(s
  596. + rs.toString() + ", request is " + StringUtil.removeJSonField(data,"base64Str") + " ,costtime="
  597. + (costtimeend - costtimestart));
  598. if (null != rs && rs.getCode() == 0) {
  599. result.setData(1);
  600. result.setCode(200);
  601. result.setMsg(rs.getData().toString());
  602. return result;
  603. } else {
  604. result.setData(3);
  605. result.setCode(200);
  606. result.setMsg(rs.getMsg());
  607. return result;
  608. }
  609. }
  610. private boolean checkCustomerCarRecQueryResult(DataResult result, NoCarWayBill noCarWayBill, List<CustomerCarRec> customerCarRecs, CustomerCarRec customerCarRec) {
  611. //先查询上游是否已经备案
  612. RespR<VehicleQueryResponse> respRquery = noCarService.customerCarRecQueryUpper(customerCarRec);
  613. if (respRquery.getCode() == 1 || respRquery.getData() == null || respRquery.getData().getResult() == null || respRquery.getData().getResult().size() <= 0) {
  614. customerCarRecs.add(customerCarRec);
  615. RespR respR = noCarService.customerCarRec(customerCarRecs);
  616. if (respR.getCode() == 1) {
  617. result.setMsg("车牌号备案失败,失败原因:" + respR.getMsg());
  618. noCarWayBill.setFailReason(respR.getMsg());
  619. noCarWayBill.setBillwayStatus(-2);
  620. insertOrUpdateBillStart(noCarWayBill);
  621. return true;
  622. }
  623. }
  624. return false;
  625. }
  626. private NoCarWayBill getNoCarWayBills(String appKey, String num, String plateNumber, String plateColor, String startTime, String sourceAddr, String destAddr, String predictEndTime, Integer fee, Integer titleType, String taxplayerCode, CustomerRec customerRec) {
  627. NoCarWayBill noCarWayBill = new NoCarWayBill();
  628. noCarWayBill.setCustomerName(appKey);
  629. noCarWayBill.setCompanyName(customerRec.getCompanyName());
  630. noCarWayBill.setPlateNum(plateNumber);
  631. noCarWayBill.setBillNum(num);
  632. noCarWayBill.setPlateColor(plateColor);
  633. noCarWayBill.setStartTime(DateUtil.getDistanceHoursFormat(startTime));
  634. noCarWayBill.setSourceAddr(sourceAddr);
  635. noCarWayBill.setDestAddr(destAddr);
  636. noCarWayBill.setPredictEndTime(DateUtil.getDistanceHoursFormat(predictEndTime));
  637. noCarWayBill.setFee(fee.longValue());
  638. noCarWayBill.setTitleType(titleType);
  639. noCarWayBill.setTaxplayerCode(taxplayerCode);
  640. noCarWayBill.setHisFlag(1);
  641. noCarWayBill.setUpdateTime(DateUtil.getCurrentDateStr());
  642. noCarWayBill.setIntfaceStartTime(DateUtil.getCurrentDateStr());
  643. //接口
  644. noCarWayBill.setInterType(0);
  645. return noCarWayBill;
  646. }
  647. /**
  648. * 插入或者更新运单
  649. * @param noCarWayBill
  650. */
  651. public void insertOrUpdateBillStart(NoCarWayBill noCarWayBill) {
  652. noCarWayBill.setIntfaceStartTime(DateUtil.getCurrentDateStr());
  653. noCarWayBill.setUpdateTime(DateUtil.getCurrentDateStr());
  654. NoCarWayBill curr = noCarWaybillMapper.selectByBillNum(noCarWayBill.getBillNum());
  655. if (null == curr) {
  656. noCarWaybillMapper.insert(noCarWayBill);
  657. } else {
  658. if (curr.getBillwayStatus() < 1) {
  659. noCarWaybillMapper.updateByBillNum(noCarWayBill);
  660. }
  661. }
  662. }
  663. /**
  664. * 无车 历史运单结束指令接口
  665. *
  666. * @param appKey
  667. * @param api
  668. * @param data
  669. * @return
  670. */
  671. @Override
  672. public DataResult noCarHisWaybillEnd(String appKey, String api, String data, String requestid) {
  673. long costtimestart = System.currentTimeMillis();
  674. DataResult result = new DataResult();
  675. result.setData(3);
  676. result.setCode(200);
  677. result.setRequestid(requestid);
  678. result.setMsg("无法认证");
  679. try {
  680. log.info("[-NoCarInterServiceImpl.noCarHisWaybillEnd-] request appKey=" + appKey + " ,api=" + api + " ,data=" + StringUtil.removeJSonField(data,"base64Str") + " ,requestid=" + requestid);
  681. JSONObject jsonObject = JSONObject.parseObject(data);
  682. //运单号 必输
  683. String num = jsonObject.getString("num");
  684. //运单实际目的地址 必输
  685. String realDestAddr = jsonObject.getString("realDestAddr");
  686. //运单实际结束时间 必输
  687. String endTime = jsonObject.getString("endTime");
  688. if (StringUtils.isEmpty(data) || null == jsonObject || StringUtils.isEmpty(num)
  689. || StringUtils.isEmpty(realDestAddr)
  690. || StringUtils.isEmpty(endTime)
  691. ) {
  692. result.setMsg("有空的必填运单要素,请检查");
  693. return result;
  694. }
  695. if (!DateUtil.isValidDate(endTime)) {
  696. result.setMsg("日期格式有误");
  697. return result;
  698. }
  699. NoCarWayBill noCarWayBill = new NoCarWayBill();
  700. noCarWayBill.setBillNum(num);
  701. noCarWayBill.setDestAddr(realDestAddr);
  702. noCarWayBill.setPredictEndTime(DateUtil.getDistanceHoursFormat(endTime));
  703. noCarWayBill.setHisFlag(1);
  704. noCarWayBill.setCustomerName(appKey);
  705. //接口
  706. noCarWayBill.setInterType(0);
  707. return getDataResultss(data, costtimestart, result, noCarService.noCarHisWaybillEnd(noCarWayBill), "[-NoCarInterServiceImpl.noCarHisWaybillEnd-] result is ");
  708. } catch (Exception e) {
  709. log.error("[-NoCarInterServiceImpl.noCarHisWaybillEnd-] get httpclient exception is "
  710. + e + ", request is " + data);
  711. }
  712. return result;
  713. }
  714. /**
  715. * 无车 运单号查询发票数据
  716. *
  717. * @param appKey
  718. * @param api
  719. * @param data
  720. * @return
  721. */
  722. @Override
  723. public DataResult noCarVoiceQuery(String appKey, String api, String data, String requestid) {
  724. long costtimestart = System.currentTimeMillis();
  725. DataResult result = new DataResult();
  726. result.setData(3);
  727. result.setCode(200);
  728. result.setRequestid(requestid);
  729. result.setMsg("无法认证");
  730. try {
  731. log.info("[-NoCarInterServiceImpl.noCarVoiceQuery-] request appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid);
  732. JSONObject jsonObject = JSONObject.parseObject(data);
  733. //运单号 必输
  734. String num = jsonObject.getString("num");
  735. if (StringUtils.isEmpty(data) || null == jsonObject || StringUtils.isEmpty(num)
  736. ) {
  737. result.setMsg("有空的必填运单要素,请检查");
  738. return result;
  739. }
  740. NoCarWayBill noCarWayBill1 = null;
  741. try {
  742. noCarWayBill1 = noCarWaybillMapper.selectByBillNum(num);
  743. } catch (Exception e) {
  744. log.info("xuyaoshanchuyundan:" + num);
  745. result.setMsg("平台运单号存在多条,请联系管理员删除无效运单");
  746. return result;
  747. }
  748. if (null == noCarWayBill1) {
  749. noCarWayBill1 = new NoCarWayBill();
  750. noCarWayBill1.setBillNum(num);
  751. noCarWayBill1.setInterType(0);
  752. noCarWayBill1.setBillwayStatus(-5);
  753. }
  754. if (isaBoolean(noCarWayBill1)) {
  755. noCarWayBill1.setBillwayStatus(-5);
  756. }
  757. noCarWayBill1.setCustomerName(appKey);
  758. noCarWayBill1.setCompanyName(noCarWayBill1.getCompanyName());
  759. RespR rs = noCarService.getInvoiceByWayBillNumReal(noCarWayBill1, true);
  760. long costtimeend = System.currentTimeMillis();
  761. log.info("[-NoCarInterServiceImpl.noCarVoiceQuery-] result is "
  762. + rs.toString() + ", request is " + data + " ,costtime="
  763. + (costtimeend - costtimestart));
  764. if (null != rs && rs.getCode() == 0) {
  765. result.setData(1);
  766. result.setCode(200);
  767. result.setMsg(rs.getData().toString());
  768. return result;
  769. } else {
  770. result.setData(3);
  771. if (NOT_FOUND.equals(rs.getMsg())) {
  772. result.setData(2);
  773. }
  774. result.setCode(200);
  775. result.setMsg(rs.getMsg());
  776. return result;
  777. }
  778. } catch (Exception e) {
  779. log.error("[-NoCarInterServiceImpl.noCarVoiceQuery-] get httpclient exception is "
  780. + e + ", request is " + data);
  781. }
  782. return result;
  783. }
  784. private boolean isaBoolean(NoCarWayBill noCarWayBill1) {
  785. return noCarWayBill1.getInterType() == REC_STATUS_WAIT ||
  786. (noCarWayBill1.getBillwayStatus() < REC_STATUS_UN &&
  787. noCarWayBill1.getFailReason() != null &&
  788. noCarWayBill1.getFailReason().contains(XY_WAYBILL_HISTORY_END));
  789. }
  790. /**
  791. * 无车 获取未查询过发票的运单编号
  792. *
  793. * @param appKey
  794. * @param api
  795. * @param data
  796. * @return
  797. */
  798. @Override
  799. public DataResult noCarNoVoiceQuery(String appKey, String api, String data, String requestid) {
  800. long costtimestart = System.currentTimeMillis();
  801. DataResult result = new DataResult();
  802. result.setData(3);
  803. result.setCode(200);
  804. result.setRequestid(requestid);
  805. result.setMsg("无法认证");
  806. try {
  807. log.info("[-NoCarInterServiceImpl.noCarNoVoiceQuery-] request appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid);
  808. String param = paramService.getParamsByParamName("FIND_NO_SEARCH_NUM_ON_OFF").getParamValue();
  809. if (!StringUtils.equals(ONE, param)) {
  810. result.setMsg("获取未查询过发票的运单编号接口已关闭");
  811. return result;
  812. }
  813. List<NoCarWayBill> noCarWayBills = noCarWaybillMapper.getNoCarNoVoiceQuery(appKey);
  814. List<String> list1 = new ArrayList<String>();
  815. for (NoCarWayBill noCarWayBill : noCarWayBills
  816. ) {
  817. list1.add(noCarWayBill.getBillNum());
  818. }
  819. List<BillInvoice> billInvoices = billInvoiceMapper.selectNoCarNoVoiceQuery(appKey);
  820. List<String> list2 = new ArrayList<String>();
  821. for (BillInvoice billInvoice : billInvoices
  822. ) {
  823. list2.add(billInvoice.getWaybillNum());
  824. }
  825. List<String> reduce1 = list1.stream().filter(item -> !list2.contains(item)).collect(toList());
  826. long costtimeend = System.currentTimeMillis();
  827. log.info("[-NoCarInterServiceImpl.noCarNoVoiceQuery-] result is "
  828. + reduce1.toString() + ", request is " + data + " ,costtime="
  829. + (costtimeend - costtimestart));
  830. if (null != reduce1 && reduce1.size() > 0) {
  831. result.setData(1);
  832. result.setCode(200);
  833. result.setMsg(JSONArray.fromObject(reduce1).toString());
  834. return result;
  835. } else {
  836. result.setData(2);
  837. result.setCode(200);
  838. result.setMsg("未查得");
  839. return result;
  840. }
  841. } catch (Exception e) {
  842. log.error("[-NoCarInterServiceImpl.noCarNoVoiceQuery-] get httpclient exception is "
  843. + e + ", request is " + data);
  844. }
  845. return result;
  846. }
  847. /**
  848. * 无车 账户余额查询接口
  849. *
  850. * @param appKey
  851. * @param api
  852. * @param data
  853. * @return
  854. */
  855. @Override
  856. public DataResult balanceQuery(String appKey, String api, String data, String requestid) {
  857. long costtimestart = System.currentTimeMillis();
  858. DataResult result = new DataResult();
  859. result.setData(3);
  860. result.setCode(200);
  861. result.setRequestid(requestid);
  862. result.setMsg("无法认证");
  863. try {
  864. log.info("[-NoCarInterServiceImpl.balanceQuery-] request appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid);
  865. Customer customer = customerMapper.selectByCustomerName(appKey);
  866. long costtimeend = System.currentTimeMillis();
  867. log.info("[-NoCarInterServiceImpl.balanceQuery-] result is "
  868. + customer.toString() + ", request is " + data + " ,costtime="
  869. + (costtimeend - costtimestart));
  870. if (null != customer) {
  871. result.setData(1);
  872. result.setCode(200);
  873. JSONObject jb = new JSONObject();
  874. jb.put("balance", customer.getAccountBalance());
  875. jb.put("lastDeductionTime", customer.getInvoiceTime());
  876. result.setMsg(jb.toString());
  877. return result;
  878. } else {
  879. result.setData(3);
  880. result.setCode(200);
  881. result.setMsg("无法认证");
  882. return result;
  883. }
  884. } catch (Exception e) {
  885. log.error("[-NoCarInterServiceImpl.balanceQuery-] get httpclient exception is "
  886. + e + ", request is " + data);
  887. }
  888. return result;
  889. }
  890. /**
  891. * 无车 红冲发票查询接口
  892. *
  893. * @param appKey
  894. * @param api
  895. * @param data
  896. * @return
  897. */
  898. @Override
  899. public DataResult redInkInvoiceQuery(String appKey, String api, String data, String requestid) {
  900. long costtimestart = System.currentTimeMillis();
  901. DataResult result = new DataResult();
  902. result.setData(3);
  903. result.setCode(200);
  904. result.setRequestid(requestid);
  905. result.setMsg("无法认证");
  906. try {
  907. log.info("[-NoCarInterServiceImpl.redInkInvoiceQuery-] request appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid);
  908. JSONObject jsonObject = JSONObject.parseObject(data);
  909. //企业税号 必输
  910. String taxplayerCode = jsonObject.getString("taxplayerCode");
  911. //开票月份 样例:yyyy-MM 必输
  912. String month = jsonObject.getString("month");
  913. //查询第几页 示例1,2,3,4…
  914. Long pageNo = jsonObject.getLong("pageNo");
  915. //查询第几页 示例1,2,3,4… 没有就默认1000
  916. Long pageSize = jsonObject.getLong("pageSize");
  917. if (StringUtils.isEmpty(data) || null == jsonObject) {
  918. return result;
  919. }
  920. if (StringUtils.isEmpty(taxplayerCode) || StringUtils.isEmpty(month) || null == pageNo || pageNo < 1) {
  921. return result;
  922. }
  923. if (null == DateUtil.parseDate(month)) {
  924. result.setMsg("日期格式不正确!");
  925. return result;
  926. }
  927. HcInvoiceQueryVo hcInvoiceQueryVo = new HcInvoiceQueryVo();
  928. hcInvoiceQueryVo.setBuyerTaxpayerCode(taxplayerCode);
  929. hcInvoiceQueryVo.setMonth(month);
  930. hcInvoiceQueryVo.setPageSize(pageSize);
  931. hcInvoiceQueryVo.setPageNo(pageNo);
  932. RespR rs = noCarService.hcinvoicequeryinter(hcInvoiceQueryVo);
  933. long costtimeend = System.currentTimeMillis();
  934. log.info("[-NoCarInterServiceImpl.redInkInvoiceQuery-] result is "
  935. + rs.toString() + ", request is " + data + " ,costtime="
  936. + (costtimeend - costtimestart));
  937. if (null != rs && rs.getCode() == 0) {
  938. result.setData(1);
  939. result.setCode(200);
  940. result.setMsg(JSON.toJSONString(rs.getData()));
  941. return result;
  942. } else {
  943. result.setData(3);
  944. result.setCode(200);
  945. result.setMsg("查询失败");
  946. return result;
  947. }
  948. } catch (Exception e) {
  949. log.error("[-NoCarInterServiceImpl.redInkInvoiceQuery-] get httpclient exception is "
  950. + e + ", request is " + data);
  951. }
  952. return result;
  953. }
  954. /**
  955. * 无车 运单号查询发票数据
  956. *
  957. * @param appKey
  958. * @param api
  959. * @param data
  960. * @return
  961. */
  962. @Override
  963. public DataResult noCarVoiceOwnerQuery(String appKey, String api, String data, String requestid) {
  964. long costtimestart = System.currentTimeMillis();
  965. DataResult result = new DataResult();
  966. result.setData(3);
  967. result.setCode(200);
  968. result.setRequestid(requestid);
  969. result.setMsg("无法认证");
  970. try {
  971. log.info("[-NoCarInterServiceImpl.noCarVoiceOwnerQuery-] request appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid);
  972. JSONObject jsonObject = JSONObject.parseObject(data);
  973. //运单号 必输
  974. String num = jsonObject.getString("num");
  975. if (StringUtils.isEmpty(data) || null == jsonObject || StringUtils.isEmpty(num)
  976. ) {
  977. result.setMsg("有空的必填运单要素,请检查");
  978. return result;
  979. }
  980. NoCarWayBill noCarWayBill1 = null;
  981. try {
  982. noCarWayBill1 = noCarWaybillMapper.selectByBillNum(num);
  983. } catch (Exception e) {
  984. log.info("xuyaoshanchuyundannoCarVoiceOwnerQuery:" + num);
  985. result.setMsg("平台运单号存在多条,请联系管理员删除无效运单");
  986. return result;
  987. }
  988. if (null == noCarWayBill1) {
  989. noCarWayBill1 = new NoCarWayBill();
  990. noCarWayBill1.setBillNum(num);
  991. }
  992. noCarWayBill1.setInterType(3);
  993. RespR rs = noCarService.getInvoiceByWayBillOwnerNumReal(noCarWayBill1, false);
  994. long costtimeend = System.currentTimeMillis();
  995. log.info("[-NoCarInterServiceImpl.noCarVoiceOwnerQuery-] result is "
  996. + rs.toString() + ", request is " + data + " ,costtime="
  997. + (costtimeend - costtimestart));
  998. if (null != rs && rs.getCode() == 0) {
  999. result.setData(1);
  1000. result.setCode(200);
  1001. result.setMsg(rs.getData().toString());
  1002. return result;
  1003. } else {
  1004. result.setData(3);
  1005. if (NOT_FOUND.equals(rs.getMsg())) {
  1006. result.setData(2);
  1007. }
  1008. result.setCode(200);
  1009. result.setMsg(rs.getMsg());
  1010. return result;
  1011. }
  1012. } catch (Exception e) {
  1013. log.error("[-NoCarInterServiceImpl.noCarVoiceOwnerQuery-] get httpclient exception is "
  1014. + e + ", request is " + data);
  1015. }
  1016. return result;
  1017. }
  1018. }