12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532 |
- package com.jkcredit.invoice.credit.interserver;
- import cn.com.taiji.sdk.model.comm.protocol.tts.vehicle.VehicleQueryResponse;
- import com.alibaba.fastjson.JSON;
- import com.alibaba.fastjson.JSONObject;
- import com.jkcredit.invoice.common.DataResult;
- import com.jkcredit.invoice.mapper.binvoce.BillInvoiceMapper;
- import com.jkcredit.invoice.mapper.customer.CustomerCarRecMapper;
- import com.jkcredit.invoice.mapper.customer.CustomerMapper;
- import com.jkcredit.invoice.mapper.waybill.NoCarWaybillMapper;
- import com.jkcredit.invoice.model.entity.customer.Customer;
- import com.jkcredit.invoice.model.entity.customer.CustomerCarRec;
- import com.jkcredit.invoice.model.entity.customer.CustomerRec;
- import com.jkcredit.invoice.model.entity.invoice.BillInvoice;
- import com.jkcredit.invoice.model.entity.manager.Param;
- import com.jkcredit.invoice.model.entity.waybill.NoCarCompanyManger;
- import com.jkcredit.invoice.model.entity.waybill.NoCarWayBill;
- import com.jkcredit.invoice.model.entity.waybill.NoCarWayBillFileInfo;
- import com.jkcredit.invoice.model.vo.OperatorEditConfirmVo;
- import com.jkcredit.invoice.model.vo.OperatorEditVo;
- import com.jkcredit.invoice.model.vo.OperatorEvidenceVo;
- import com.jkcredit.invoice.model.vo.OperatorSendCodeVo;
- 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.service.nocar.NoCarCompanyMangerOper;
- import com.jkcredit.invoice.service.nocar.WayBillFileService;
- import com.jkcredit.invoice.util.DateUtil;
- import com.jkcredit.invoice.util.RespR;
- import com.jkcredit.invoice.util.StringUtil;
- import lombok.extern.slf4j.Slf4j;
- import net.sf.json.JSONArray;
- import org.apache.commons.lang3.StringUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import java.util.ArrayList;
- import java.util.List;
- import static com.jkcredit.invoice.common.CommonConst.COMPUTE;
- import static com.jkcredit.invoice.common.CommonConst.NOT_FOUND;
- import static com.jkcredit.invoice.common.CommonConst.ONE;
- import static com.jkcredit.invoice.common.CommonConst.REC_STATUS_UN;
- import static com.jkcredit.invoice.common.CommonConst.REC_STATUS_WAIT;
- import static com.jkcredit.invoice.common.CommonConst.RESULT;
- import static com.jkcredit.invoice.common.CommonConst.SELF_CAR;
- import static com.jkcredit.invoice.common.CommonConst.XY_WAYBILL_HISTORY_END;
- import static java.util.stream.Collectors.toList;
- /**
- * 无车操作接口实现类
- * @author mumuxigua
- */
- @Service("noCarInterService")
- @Slf4j
- public class NoCarInterServiceImpl implements NoCarInterService {
- private static final String PDF = "pdf";
- @Autowired
- NoCarBillWayImportService noCarWaybillMapperImprt;
- @Autowired
- CustomerCarRecMapper customerCarRecMapper;
- @Autowired
- NoCarWaybillMapper noCarWaybillMapper;
- @Autowired
- CustomerRecService customerRecMapper;
- @Autowired
- BillInvoiceMapper billInvoiceMapper;
- @Autowired
- CustomerMapper customerMapper;
- @Autowired
- ParamService paramService;
- @Autowired
- private NoCarService noCarService;
- @Autowired
- private WayBillFileService wayBillFileService;
- public static void main(String[] args) {
- List<String> list1 = new ArrayList<String>();
- list1.add("1");
- list1.add("2");
- list1.add("3");
- list1.add("5");
- list1.add("6");
- List<String> list2 = new ArrayList<String>();
- list2.add("2");
- list2.add("3");
- list2.add("7");
- list2.add("8");
- // 交集
- List<String> intersection = list1.stream().filter(item -> list2.contains(item)).collect(toList());
- System.out.println("---交集 intersection---");
- intersection.parallelStream().forEach(System.out::println);
- // 差集 (list1 - list2)
- List<String> reduce1 = list1.stream().filter(item -> !list2.contains(item)).collect(toList());
- System.out.println("---差集 reduce1 (list1 - list2)---");
- // 并集
- reduce1.parallelStream().forEach(System.out::println);
- List<String> listAll = list1.parallelStream().collect(toList());
- List<String> listAll2 = list2.parallelStream().collect(toList());
- listAll.addAll(listAll2);
- System.out.println("---并集 listAll---");
- listAll.parallelStream().forEachOrdered(System.out::println);
- // 去重并集
- List<String> listAllDistinct = listAll.stream().distinct().collect(toList());
- System.out.println("---得到去重并集 listAllDistinct---");
- listAllDistinct.parallelStream().forEachOrdered(System.out::println);
- System.out.println("---原来的List1---");
- list1.parallelStream().forEachOrdered(System.out::println);
- System.out.println("---原来的List2---");
- list2.parallelStream().forEachOrdered(System.out::println);
- }
- /**
- * 无车 车辆备案接口
- *
- * @param appKey
- * @param api
- * @param data
- * @return
- */
- @Override
- public DataResult customerCarRec(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.customerCarRec-] request appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid);
- JSONObject jsonObject = JSONObject.parseObject(data);
- //企业名称 选输
- String companyName = jsonObject.getString("companyName");
- //plateNumber 必输
- String plateNumber = jsonObject.getString("plateNumber");
- //plateColor 必输
- String plateColor = jsonObject.getString("plateColor");
- if (StringUtils.isEmpty(data) || null == jsonObject || StringUtils.isEmpty(plateNumber)
- || StringUtils.isEmpty(plateColor)
- ) {
- result.setMsg("必传参数有空值");
- return result;
- }
- List<CustomerCarRec> customerCarRecList = new ArrayList<CustomerCarRec>();
- CustomerCarRec customerCarRec = new CustomerCarRec();
- customerCarRec.setCustomerName(appKey);
- Customer cust = customerMapper.selectByCustomerName(appKey);
- CustomerRec customerRec = new CustomerRec();
- customerRec.setCustomerName(appKey);
- customerRec.setCompanyName(cust.getCompany());
- CustomerRec customerRec1 = customerRecMapper.selectByCustomerNameAndCompany(customerRec);
- if (null == customerRec1) {
- result.setMsg("该客户: " + appKey + " 未备案企业");
- return result;
- }
- customerCarRec.setCompanyName(customerRec1.getCompanyName());
- customerCarRec.setCustomerName(customerRec1.getCustomerName());
- //无车
- customerCarRec.setBusinessType("2");
- customerCarRec.setCarColor(plateColor);
- customerCarRec.setCarNum(plateNumber);
- customerCarRec.setInterType(0);
- if (SELF_CAR.equals(customerCarRec.getCarColor())) {
- //默认运营车辆
- customerCarRec.setServiceOperation(1);
- }
- customerCarRecList.add(customerCarRec);
- return getDataResultss(data, costtimestart, result, noCarService.customerCarRec(customerCarRecList), "[-NoCarInterServiceImpl.customerCarRec-] result is ");
- } catch (Exception e) {
- log.error("[-NoCarInterServiceImpl.customerCarRec-] get httpclient exception is "
- + e + ", request is " + data);
- }
- return result;
- }
- /**
- * 无车 车辆备案查询接口
- *
- * @param appKey
- * @param api
- * @param data
- * @return
- */
- @Override
- public DataResult customeRecUpperQuery(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.customeRecUpperQuery-] request appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid);
- JSONObject jsonObject = JSONObject.parseObject(data);
- //备案来源 选输
- String waybillSource = jsonObject.getString("waybillSource");
- //plateNumber 必输
- String plateNumber = jsonObject.getString("plateNumber");
- //plateColor 必输
- String plateColor = jsonObject.getString("plateColor");
- if (StringUtils.isEmpty(data) || null == jsonObject || StringUtils.isEmpty(plateNumber)
- || StringUtils.isEmpty(plateColor)
- ) {
- result.setMsg("必传参数有空值");
- return result;
- }
- CustomerCarRec customerCarRec = new CustomerCarRec();
- Param param = paramService.getParamsByParamName("REQUEST_COMPANY_NUM");
- //无车,车辆备案,运单上传,运单查询都是统一用交科的企业编号;自有车用客户的企业编号
- customerCarRec.setCompanyNum(param.getParamValue());
- customerCarRec.setCarColor(plateColor);
- customerCarRec.setCarNum(plateNumber);
- customerCarRec.setCustomerName(appKey);
- //无车
- customerCarRec.setBusinessType("2");
- //此处代表仅查询上游接口,无任何处理逻辑
- customerCarRec.setInterType(8);
- RespR rs = noCarService.customerCarRecQueryUpper(customerCarRec);
- long costtimeend = System.currentTimeMillis();
- log.info("[-NoCarInterServiceImpl.customeRecUpperQuery-] 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());
- JSONObject jb = JSONObject.parseObject(rs.getData().toString());
- result.setData(1);
- result.setMsg("车辆已备案");
- if (null == jb.getJSONArray(RESULT) || jb.getJSONArray(RESULT).size() == 0) {
- result.setData(2);
- result.setMsg("车辆未备案");
- }
- return result;
- } else {
- result.setData(3);
- result.setCode(200);
- result.setMsg("查询失败");
- return result;
- }
- } catch (Exception e) {
- log.error("[-NoCarInterServiceImpl.customeRecUpperQuery-] get httpclient exception is "
- + e + ", request is " + data);
- }
- return result;
- }
- /**
- * 无车 实时运单开始指令接口
- *
- * @param appKey
- * @param api
- * @param data
- * @return
- */
- @Override
- public DataResult noCarBillStart(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.noCarBillStart-] request appKey=" + appKey + " ,api=" + api + " ,data=" + StringUtil.removeJSonField(data,"base64Str") + " ,requestid=" + requestid);
- JSONObject jsonObject = JSONObject.parseObject(data);
- //运单编号 必选
- String num = jsonObject.getString("num");
- //车牌号 必选
- String plateNumber = jsonObject.getString("plateNumber");
- //车牌颜色 必选
- String plateColor = jsonObject.getString("plateColor");
- //运单开始时间 必选
- String startTime = jsonObject.getString("startTime");
- //运单开始地址 必选
- String sourceAddr = jsonObject.getString("sourceAddr");
- //运单目的地址 必选
- String destAddr = jsonObject.getString("destAddr");
- //运单预计完成时间 必选
- String predictEndTime = jsonObject.getString("predictEndTime");
- //运单费用 必选
- Integer fee = jsonObject.getInteger("fee");
- //发票抬头类型 必选
- Integer titleType = jsonObject.getInteger("titleType");
- //税号 必选
- String taxplayerCode = jsonObject.getString("taxplayerCode");
- //base流文件 必选
- String base64Str = jsonObject.getString("base64Str");
- //运单协议名称 必选
- String waybillFileName = jsonObject.getString("waybillFileName");
- //运单类型 必选
- Integer contractType = jsonObject.getInteger("contractType");
- if (StringUtils.isEmpty(data) || null == jsonObject
- || StringUtils.isEmpty(num)
- || StringUtils.isEmpty(plateNumber)
- || StringUtils.isEmpty(plateColor)
- || StringUtils.isEmpty(startTime)
- || StringUtils.isEmpty(sourceAddr)
- || StringUtils.isEmpty(destAddr)
- || StringUtils.isEmpty(predictEndTime)
- || null == fee
- || null == titleType
- || StringUtils.isEmpty(taxplayerCode)
- || StringUtils.isEmpty(base64Str)
- || StringUtils.isEmpty(waybillFileName)
- || null == contractType
- ) {
- result.setMsg("必传参数有空值");
- return result;
- }
- if (!DateUtil.isValidDate(startTime)) {
- result.setMsg("日期格式有误");
- return result;
- }
- if (!DateUtil.isValidDate(predictEndTime)) {
- result.setMsg("日期格式有误");
- return result;
- }
- if(StringUtils.isNotBlank(waybillFileName) && StringUtils.isNotBlank(base64Str) && null != contractType){
- String fileType = waybillFileName.substring(waybillFileName.lastIndexOf(".") + 1).toLowerCase();
- if (!PDF.equals(fileType)) {
- result.setMsg("必须是pdf文件!");
- return result;
- }
- int base64StrLength = base64Str.length();
- if (COMPUTE < base64StrLength) {
- result.setMsg("pdf不可超过10M!");
- return result;
- }
- base64Str = base64Str.replaceAll(" ", "+");
- }
- CustomerRec customerRec = new CustomerRec();
- customerRec.setCustomerName(appKey);
- customerRec.setCompanyReferencenum(taxplayerCode);
- customerRec = customerRecMapper.selectByCustomerNameAndCompanyReference(customerRec);
- if (customerRec == null || customerRec.getRecStatus() != 1) {
- result.setMsg("客户:" + appKey + ";税号" + taxplayerCode + "未在平台备案成功,请先做备案");
- return result;
- }
- NoCarWayBill noCarWayBill = getNoCarWayBill(appKey, num, plateNumber, plateColor, startTime, sourceAddr, destAddr, predictEndTime, fee, titleType, taxplayerCode, customerRec);
- noCarWayBill.setWaybillFileName(waybillFileName);
- noCarWayBill.setBase64Str(base64Str);
- noCarWayBill.setContractType(contractType);
- DataResult dataResult = getDataResult(appKey, data, costtimestart, result, customerRec, noCarWayBill);
- try {
- if(dataResult.getData() == 1 && dataResult.getCode()==200 && StringUtils.isNotBlank(waybillFileName) && StringUtils.isNotBlank(base64Str)){
- NoCarWayBillFileInfo noCarWayBillFileInfo = new NoCarWayBillFileInfo();
- noCarWayBillFileInfo.setBase64Str(base64Str);
- noCarWayBillFileInfo.setFileName(waybillFileName);
- noCarWayBillFileInfo.setBatchNum("接口运单");
- noCarWayBillFileInfo.setWayBillNum(num);
- noCarWayBillFileInfo.setCustomerId(appKey);
- noCarWayBillFileInfo.setCompanyName(noCarWayBill.getCompanyName());
- noCarWayBillFileInfo.setUpdateTime(DateUtil.getCurrentDateStr());
- wayBillFileService.insert(noCarWayBillFileInfo);
- }
- }catch (Exception e){
- e.printStackTrace();
- log.info("文件入表失败{}",noCarWayBill.getBillNum());
- }
- return dataResult;
- } catch (Exception e) {
- log.error("[-NoCarInterServiceImpl.noCarBillStart-] get httpclient exception is "
- + e + ", request is " + StringUtil.removeJSonField(data,"base64Str"));
- }
- return result;
- }
- private DataResult getDataResult(String appKey, String data, long costtimestart, DataResult result, CustomerRec customerRec, NoCarWayBill noCarWayBill) {
- List<CustomerCarRec> customerCarRecs = new ArrayList<>();
- CustomerCarRec customerCarRec = new CustomerCarRec();
- customerCarRec.setCompanyName(noCarWayBill.getCompanyName());
- customerCarRec.setCarNum(noCarWayBill.getPlateNum());
- customerCarRec.setCarColor(noCarWayBill.getPlateColor());
- customerCarRec.setCustomerName(appKey);
- //接口
- customerCarRec.setInterType(0);
- customerCarRec.setCompanyNum(customerRec.getCompanyNum());
- customerCarRec.setBusinessType("2");
- //默认运营车辆
- customerCarRec.setServiceOperation(1);
- noCarWayBill.setTitleType(2);
- //接口
- noCarWayBill.setInterType(0);
- return getDataResult(data, costtimestart, result, noCarWayBill, customerCarRecs, customerCarRec);
- }
- 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) {
- NoCarWayBill noCarWayBill = new NoCarWayBill();
- noCarWayBill.setCustomerName(appKey);
- noCarWayBill.setCompanyName(customerRec.getCompanyName());
- noCarWayBill.setPlateNum(plateNumber);
- noCarWayBill.setBillNum(num);
- noCarWayBill.setPlateColor(plateColor);
- noCarWayBill.setStartTime(DateUtil.getDistanceHoursFormat(startTime));
- noCarWayBill.setSourceAddr(sourceAddr);
- noCarWayBill.setDestAddr(destAddr);
- noCarWayBill.setPredictEndTime(DateUtil.getDistanceHoursFormat(predictEndTime));
- noCarWayBill.setFee(fee.longValue());
- noCarWayBill.setTitleType(titleType);
- noCarWayBill.setTaxplayerCode(taxplayerCode);
- noCarWayBill.setHisFlag(0);
- noCarWayBill.setIntfaceStartTime(DateUtil.getCurrentDateStr());
- return noCarWayBill;
- }
- private DataResult getDataResult(String data, long costtimestart, DataResult result, NoCarWayBill noCarWayBill, List<CustomerCarRec> customerCarRecs, CustomerCarRec customerCarRec) {
- //先查询上游是否已经备案
- RespR<VehicleQueryResponse> respRquery = noCarService.customerCarRecQueryUpper(customerCarRec);
- if (respRquery.getCode() == 1 || respRquery.getData() == null || respRquery.getData().getResult() == null || respRquery.getData().getResult().size() <= 0) {
- customerCarRecs.add(customerCarRec);
- RespR respR = noCarService.customerCarRec(customerCarRecs);
- if (respR.getCode() == 1) {
- noCarWayBill.setFailReason(respR.getMsg());
- noCarWayBill.setBillwayStatus(-2);
- insertOrUpdateBillStart(noCarWayBill);
- result.setMsg("车牌号备案失败,失败原因:" + respR.getMsg());
- return result;
- }
- }
- return getDataResultss(data, costtimestart, result, noCarService.noCarWaybillStart(noCarWayBill), "[-NoCarInterServiceImpl.noCarBillStart-] result is ");
- }
- /**
- * 无车 实时运单结束指令接口
- *
- * @param appKey
- * @param api
- * @param data
- * @return
- */
- @Override
- public DataResult noCarBillEnd(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.noCarBillEnd-] request appKey=" + appKey + " ,api=" + api + " ,data=" + StringUtil.removeJSonField(data,"base64Str") + " ,requestid=" + requestid);
- JSONObject jsonObject = JSONObject.parseObject(data);
- //运单号 必输
- String num = jsonObject.getString("num");
- //运单实际目的地址 必输
- String realDestAddr = jsonObject.getString("realDestAddr");
- //运单实际结束时间 必输
- String endTime = jsonObject.getString("endTime");
- if (StringUtils.isEmpty(data) || null == jsonObject || StringUtils.isEmpty(num)
- || StringUtils.isEmpty(realDestAddr)
- || StringUtils.isEmpty(endTime)
- ) {
- result.setMsg("必传参数有空值");
- return result;
- }
- if (!DateUtil.isValidDate(endTime)) {
- result.setMsg("日期格式有误");
- return result;
- }
- NoCarWayBill noCarWayBill = new NoCarWayBill();
- noCarWayBill.setCustomerName(appKey);
- noCarWayBill.setBillNum(num);
- noCarWayBill.setDestAddr(realDestAddr);
- noCarWayBill.setPredictEndTime(DateUtil.getDistanceHoursFormat(endTime));
- noCarWayBill.setHisFlag(0);
- //接口
- noCarWayBill.setInterType(0);
- return getDataResultss(data, costtimestart, result, noCarService.noCarWaybillEnd(noCarWayBill), "[-NoCarInterServiceImpl.noCarBillEnd-] result is ");
- } catch (Exception e) {
- log.error("[-NoCarInterServiceImpl.noCarBillEnd-] get httpclient exception is "
- + e + ", request is " + data);
- }
- return result;
- }
- /**
- * 无车 历史运单开始指令接口
- *
- * @param appKey
- * @param api
- * @param data
- * @return
- */
- @Override
- public DataResult noCarHisWaybillStart(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.noCarHisWaybillStart-] request appKey=" + appKey + " ,api=" + api + " ,data=" + StringUtil.removeJSonField(data,"base64Str") + " ,requestid=" + requestid);
- String param = paramService.getParamsByParamName("NO_CAR_HISWAY_BILL_ON_OFF").getParamValue();
- if (StringUtils.isBlank(param) || !StringUtils.equals(ONE, param)) {
- result.setMsg("历史运单开始指令接口已关闭");
- return result;
- }
- JSONObject jsonObject = JSONObject.parseObject(data);
- //运单编号 必选
- String num = jsonObject.getString("num");
- //车牌号 必选
- String plateNumber = jsonObject.getString("plateNumber");
- //车牌颜色 必选
- String plateColor = jsonObject.getString("plateColor");
- //运单开始时间 必选
- String startTime = jsonObject.getString("startTime");
- //运单开始地址 必选
- String sourceAddr = jsonObject.getString("sourceAddr");
- //运单目的地址 必选
- String destAddr = jsonObject.getString("destAddr");
- //运单预计完成时间 必选
- String predictEndTime = jsonObject.getString("predictEndTime");
- //运单费用 必选
- Integer fee = jsonObject.getInteger("fee");
- //发票抬头类型 必选
- Integer titleType = jsonObject.getInteger("titleType");
- //税号 必选
- String taxplayerCode = jsonObject.getString("taxplayerCode");
- String base64Str = jsonObject.getString("base64Str");
- String waybillFileName = jsonObject.getString("waybillFileName");
- Integer contractType = jsonObject.getInteger("contractType");
- if (StringUtils.isEmpty(data) || null == jsonObject
- || StringUtils.isEmpty(num)
- || StringUtils.isEmpty(plateNumber)
- || StringUtils.isEmpty(plateColor)
- || StringUtils.isEmpty(startTime)
- || StringUtils.isEmpty(sourceAddr)
- || StringUtils.isEmpty(destAddr)
- || StringUtils.isEmpty(predictEndTime)
- || null == fee
- || null == titleType
- || StringUtils.isEmpty(taxplayerCode)
- || StringUtils.isEmpty(base64Str)
- || StringUtils.isEmpty(waybillFileName)
- || null == contractType
- ) {
- result.setMsg("有空的必填运单要素,请检查");
- return result;
- }
- if (!DateUtil.isValidDate(startTime)) {
- result.setMsg("日期格式有误");
- return result;
- }
- if (!DateUtil.isValidDate(predictEndTime)) {
- result.setMsg("日期格式有误");
- return result;
- }
- CustomerRec customerRec = new CustomerRec();
- customerRec.setCustomerName(appKey);
- customerRec.setCompanyReferencenum(taxplayerCode);
- customerRec = customerRecMapper.selectByCustomerNameAndCompanyReference(customerRec);
- if (customerRec == null) {
- result.setMsg("客户:" + appKey + ";税号" + taxplayerCode + "未在平台备案成功,请先做备案");
- return result;
- }
- if(StringUtils.isNotBlank(waybillFileName) && StringUtils.isNotBlank(base64Str) && null != contractType){
- String fileType = waybillFileName.substring(waybillFileName.lastIndexOf(".") + 1).toLowerCase();
- if (!PDF.equals(fileType)) {
- result.setMsg("必须是pdf文件!");
- return result;
- }
- int base64StrLength = base64Str.length();
- if (COMPUTE < base64StrLength) {
- result.setMsg("pdf不可超过10M!");
- return result;
- }
- base64Str = base64Str.replaceAll(" ", "+");
- }
- NoCarWayBill noCarWayBill = getNoCarWayBills(appKey, num, plateNumber, plateColor, startTime, sourceAddr, destAddr, predictEndTime, fee, titleType, taxplayerCode, customerRec);
- noCarWayBill.setWaybillFileName(waybillFileName);
- noCarWayBill.setBase64Str(base64Str);
- noCarWayBill.setContractType(contractType);
- List<CustomerCarRec> customerCarRecs = new ArrayList<>();
- CustomerCarRec customerCarRec = new CustomerCarRec();
- customerCarRec.setCompanyName(noCarWayBill.getCompanyName());
- customerCarRec.setCarNum(noCarWayBill.getPlateNum());
- customerCarRec.setCarColor(noCarWayBill.getPlateColor());
- customerCarRec.setCustomerName(appKey);
- customerCarRec.setInterType(0);
- customerCarRec.setCompanyNum(customerRec.getCompanyNum());
- customerCarRec.setBusinessType("2");
- //默认运营车辆
- customerCarRec.setServiceOperation(1);
- noCarWayBill.setTitleType(2);
- if (checkCustomerCarRecQueryResult(result, noCarWayBill, customerCarRecs, customerCarRec)) {
- return result;
- }
- RespR respR = noCarService.noCarHisWaybillStart(noCarWayBill);
- try {
- if(respR.getCode() == 0 && StringUtils.isNotBlank(waybillFileName) && StringUtils.isNotBlank(base64Str) ){
- //上传成功后文件入库
- NoCarWayBillFileInfo noCarWayBillFileInfo = new NoCarWayBillFileInfo();
- noCarWayBillFileInfo.setBase64Str(base64Str);
- noCarWayBillFileInfo.setFileName(waybillFileName);
- noCarWayBillFileInfo.setBatchNum("接口运单");
- noCarWayBillFileInfo.setWayBillNum(num);
- noCarWayBillFileInfo.setUpdateTime(DateUtil.getCurrentDateStr());
- noCarWayBillFileInfo.setCustomerId(appKey);
- noCarWayBillFileInfo.setCompanyName(noCarWayBill.getCompanyName());
- wayBillFileService.insert(noCarWayBillFileInfo);
- }
- }catch (Exception e){
- e.printStackTrace();
- log.info("文件入表失败{}",noCarWayBill.getBillNum());
- }
- return getDataResultss(data, costtimestart, result, respR, "[-NoCarInterServiceImpl.noCarHisWaybillStart-] result is ");
- } catch (Exception e) {
- log.error("[-NoCarInterServiceImpl.noCarHisWaybillStart-] get httpclient exception is "
- + e + ", request is " + StringUtil.removeJSonField(data,"base64Str"));
- }
- return result;
- }
- private DataResult getDataResultss(String data, long costtimestart, DataResult result, RespR respR, String s) {
- RespR rs = respR;
- long costtimeend = System.currentTimeMillis();
- log.info(s
- + rs.toString() + ", request is " + StringUtil.removeJSonField(data,"base64Str") + " ,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;
- }
- }
- private boolean checkCustomerCarRecQueryResult(DataResult result, NoCarWayBill noCarWayBill, List<CustomerCarRec> customerCarRecs, CustomerCarRec customerCarRec) {
- //先查询上游是否已经备案
- RespR<VehicleQueryResponse> respRquery = noCarService.customerCarRecQueryUpper(customerCarRec);
- if (respRquery.getCode() == 1 || respRquery.getData() == null || respRquery.getData().getResult() == null || respRquery.getData().getResult().size() <= 0) {
- customerCarRecs.add(customerCarRec);
- RespR respR = noCarService.customerCarRec(customerCarRecs);
- if (respR.getCode() == 1) {
- result.setMsg("车牌号备案失败,失败原因:" + respR.getMsg());
- noCarWayBill.setFailReason(respR.getMsg());
- noCarWayBill.setBillwayStatus(-2);
- insertOrUpdateBillStart(noCarWayBill);
- return true;
- }
- }
- return false;
- }
- 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) {
- NoCarWayBill noCarWayBill = new NoCarWayBill();
- noCarWayBill.setCustomerName(appKey);
- noCarWayBill.setCompanyName(customerRec.getCompanyName());
- noCarWayBill.setPlateNum(plateNumber);
- noCarWayBill.setBillNum(num);
- noCarWayBill.setPlateColor(plateColor);
- noCarWayBill.setStartTime(DateUtil.getDistanceHoursFormat(startTime));
- noCarWayBill.setSourceAddr(sourceAddr);
- noCarWayBill.setDestAddr(destAddr);
- noCarWayBill.setPredictEndTime(DateUtil.getDistanceHoursFormat(predictEndTime));
- noCarWayBill.setFee(fee.longValue());
- noCarWayBill.setTitleType(titleType);
- noCarWayBill.setTaxplayerCode(taxplayerCode);
- noCarWayBill.setHisFlag(1);
- noCarWayBill.setUpdateTime(DateUtil.getCurrentDateStr());
- noCarWayBill.setIntfaceStartTime(DateUtil.getCurrentDateStr());
- //接口
- noCarWayBill.setInterType(0);
- return noCarWayBill;
- }
- /**
- * 插入或者更新运单
- * @param noCarWayBill
- */
- public void insertOrUpdateBillStart(NoCarWayBill noCarWayBill) {
- noCarWayBill.setIntfaceStartTime(DateUtil.getCurrentDateStr());
- noCarWayBill.setUpdateTime(DateUtil.getCurrentDateStr());
- NoCarWayBill curr = noCarWaybillMapper.selectByBillNum(noCarWayBill.getBillNum());
- if (null == curr) {
- noCarWaybillMapper.insert(noCarWayBill);
- } else {
- if (curr.getBillwayStatus() < 1) {
- noCarWaybillMapper.updateByBillNum(noCarWayBill);
- }
- }
- }
- /**
- * 无车 历史运单结束指令接口
- *
- * @param appKey
- * @param api
- * @param data
- * @return
- */
- @Override
- public DataResult noCarHisWaybillEnd(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.noCarHisWaybillEnd-] request appKey=" + appKey + " ,api=" + api + " ,data=" + StringUtil.removeJSonField(data,"base64Str") + " ,requestid=" + requestid);
- String param = paramService.getParamsByParamName("NO_CAR_HISWAY_BILL_ON_OFF").getParamValue();
- if (StringUtils.isBlank(param) || !StringUtils.equals(ONE, param)) {
- result.setMsg("历史运单结束指令接口已关闭");
- return result;
- }
- JSONObject jsonObject = JSONObject.parseObject(data);
- //运单号 必输
- String num = jsonObject.getString("num");
- //运单实际目的地址 必输
- String realDestAddr = jsonObject.getString("realDestAddr");
- //运单实际结束时间 必输
- String endTime = jsonObject.getString("endTime");
- if (StringUtils.isEmpty(data) || null == jsonObject || StringUtils.isEmpty(num)
- || StringUtils.isEmpty(realDestAddr)
- || StringUtils.isEmpty(endTime)
- ) {
- result.setMsg("有空的必填运单要素,请检查");
- return result;
- }
- if (!DateUtil.isValidDate(endTime)) {
- result.setMsg("日期格式有误");
- return result;
- }
- NoCarWayBill noCarWayBill = new NoCarWayBill();
- noCarWayBill.setBillNum(num);
- noCarWayBill.setDestAddr(realDestAddr);
- noCarWayBill.setPredictEndTime(DateUtil.getDistanceHoursFormat(endTime));
- noCarWayBill.setHisFlag(1);
- noCarWayBill.setCustomerName(appKey);
- //接口
- noCarWayBill.setInterType(0);
- return getDataResultss(data, costtimestart, result, noCarService.noCarHisWaybillEnd(noCarWayBill), "[-NoCarInterServiceImpl.noCarHisWaybillEnd-] result is ");
- } catch (Exception e) {
- log.error("[-NoCarInterServiceImpl.noCarHisWaybillEnd-] get httpclient exception is "
- + e + ", request is " + data);
- }
- return result;
- }
- /**
- * 无车 运单号查询发票数据
- *
- * @param appKey
- * @param api
- * @param data
- * @return
- */
- @Override
- public DataResult noCarVoiceQuery(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.noCarVoiceQuery-] request appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid);
- JSONObject jsonObject = JSONObject.parseObject(data);
- //运单号 必输
- String num = jsonObject.getString("num");
- if (StringUtils.isEmpty(data) || null == jsonObject || StringUtils.isEmpty(num)
- ) {
- result.setMsg("有空的必填运单要素,请检查");
- return result;
- }
- NoCarWayBill noCarWayBill1 = null;
- try {
- noCarWayBill1 = noCarWaybillMapper.selectByBillNum(num);
- } catch (Exception e) {
- log.info("xuyaoshanchuyundan:" + num);
- result.setMsg("平台运单号存在多条,请联系管理员删除无效运单");
- return result;
- }
- if (null == noCarWayBill1) {
- noCarWayBill1 = new NoCarWayBill();
- noCarWayBill1.setBillNum(num);
- noCarWayBill1.setInterType(0);
- noCarWayBill1.setBillwayStatus(-5);
- }
- if (isaBoolean(noCarWayBill1)) {
- noCarWayBill1.setBillwayStatus(-5);
- }
- noCarWayBill1.setCustomerName(appKey);
- noCarWayBill1.setCompanyName(noCarWayBill1.getCompanyName());
- RespR rs = noCarService.getInvoiceByWayBillNumReal(noCarWayBill1, true);
- long costtimeend = System.currentTimeMillis();
- log.info("[-NoCarInterServiceImpl.noCarVoiceQuery-] 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);
- if (NOT_FOUND.equals(rs.getMsg())) {
- result.setData(2);
- }
- result.setCode(200);
- result.setMsg(noCarWayBill1.getBillwayStatus()+","+rs.getMsg());
- return result;
- }
- } catch (Exception e) {
- log.error("[-NoCarInterServiceImpl.noCarVoiceQuery-] get httpclient exception is "
- + e + ", request is " + data);
- }
- return result;
- }
- private boolean isaBoolean(NoCarWayBill noCarWayBill1) {
- return noCarWayBill1.getInterType() == REC_STATUS_WAIT ||
- (noCarWayBill1.getBillwayStatus() < REC_STATUS_UN &&
- noCarWayBill1.getFailReason() != null &&
- noCarWayBill1.getFailReason().contains(XY_WAYBILL_HISTORY_END));
- }
- /**
- * 无车 获取未查询过发票的运单编号
- *
- * @param appKey
- * @param api
- * @param data
- * @return
- */
- @Override
- public DataResult noCarNoVoiceQuery(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.noCarNoVoiceQuery-] request appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid);
- String param = paramService.getParamsByParamName("FIND_NO_SEARCH_NUM_ON_OFF").getParamValue();
- if (!StringUtils.equals(ONE, param)) {
- result.setMsg("获取未查询过发票的运单编号接口已关闭");
- return result;
- }
- List<NoCarWayBill> noCarWayBills = noCarWaybillMapper.getNoCarNoVoiceQuery(appKey);
- List<String> list1 = new ArrayList<String>();
- for (NoCarWayBill noCarWayBill : noCarWayBills
- ) {
- list1.add(noCarWayBill.getBillNum());
- }
- List<BillInvoice> billInvoices = billInvoiceMapper.selectNoCarNoVoiceQuery(appKey);
- List<String> list2 = new ArrayList<String>();
- for (BillInvoice billInvoice : billInvoices
- ) {
- list2.add(billInvoice.getWaybillNum());
- }
- List<String> reduce1 = list1.stream().filter(item -> !list2.contains(item)).collect(toList());
- long costtimeend = System.currentTimeMillis();
- log.info("[-NoCarInterServiceImpl.noCarNoVoiceQuery-] result is "
- + reduce1.toString() + ", request is " + data + " ,costtime="
- + (costtimeend - costtimestart));
- if (null != reduce1 && reduce1.size() > 0) {
- result.setData(1);
- result.setCode(200);
- result.setMsg(JSONArray.fromObject(reduce1).toString());
- return result;
- } else {
- result.setData(2);
- result.setCode(200);
- result.setMsg("未查得");
- return result;
- }
- } catch (Exception e) {
- log.error("[-NoCarInterServiceImpl.noCarNoVoiceQuery-] get httpclient exception is "
- + e + ", request is " + data);
- }
- return result;
- }
- /**
- * 无车 账户余额查询接口
- *
- * @param appKey
- * @param api
- * @param data
- * @return
- */
- @Override
- public DataResult balanceQuery(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.balanceQuery-] request appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid);
- Customer customer = customerMapper.selectByCustomerName(appKey);
- long costtimeend = System.currentTimeMillis();
- log.info("[-NoCarInterServiceImpl.balanceQuery-] result is "
- + customer.toString() + ", request is " + data + " ,costtime="
- + (costtimeend - costtimestart));
- if (null != customer) {
- result.setData(1);
- result.setCode(200);
- JSONObject jb = new JSONObject();
- jb.put("balance", customer.getAccountBalance());
- jb.put("lastDeductionTime", customer.getInvoiceTime());
- result.setMsg(jb.toString());
- return result;
- } else {
- result.setData(3);
- result.setCode(200);
- result.setMsg("无法认证");
- return result;
- }
- } catch (Exception e) {
- log.error("[-NoCarInterServiceImpl.balanceQuery-] get httpclient exception is "
- + e + ", request is " + data);
- }
- return result;
- }
- /**
- * 无车 红冲发票查询接口
- *
- * @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 taxplayerCode = jsonObject.getString("taxplayerCode");
- //开票月份 样例:yyyy-MM 必输
- String month = jsonObject.getString("month");
- //查询第几页 示例1,2,3,4…
- Long pageNo = jsonObject.getLong("pageNo");
- //查询第几页 示例1,2,3,4… 没有就默认1000
- Long pageSize = jsonObject.getLong("pageSize");
- if (StringUtils.isEmpty(data) || null == jsonObject) {
- return result;
- }
- if (StringUtils.isEmpty(taxplayerCode) || StringUtils.isEmpty(month) || null == pageNo || pageNo < 1) {
- return result;
- }
- if (null == DateUtil.parseDate(month)) {
- result.setMsg("日期格式不正确!");
- return result;
- }
- HcInvoiceQueryVo hcInvoiceQueryVo = new HcInvoiceQueryVo();
- hcInvoiceQueryVo.setBuyerTaxpayerCode(taxplayerCode);
- hcInvoiceQueryVo.setMonth(month);
- hcInvoiceQueryVo.setPageSize(pageSize);
- hcInvoiceQueryVo.setPageNo(pageNo);
- RespR rs = noCarService.hcinvoicequeryinter(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(JSON.toJSONString(rs.getData()));
- return result;
- } else {
- result.setData(3);
- result.setCode(200);
- result.setMsg("查询失败");
- return result;
- }
- } catch (Exception e) {
- log.error("[-NoCarInterServiceImpl.redInkInvoiceQuery-] get httpclient exception is "
- + e + ", request is " + data);
- }
- return result;
- }
- /**
- * 无车 运单号查询发票数据
- *
- * @param appKey
- * @param api
- * @param data
- * @return
- */
- @Override
- public DataResult noCarVoiceOwnerQuery(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.noCarVoiceOwnerQuery-] request appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid);
- JSONObject jsonObject = JSONObject.parseObject(data);
- //运单号 必输
- String num = jsonObject.getString("num");
- if (StringUtils.isEmpty(data) || null == jsonObject || StringUtils.isEmpty(num)
- ) {
- result.setMsg("有空的必填运单要素,请检查");
- return result;
- }
- NoCarWayBill noCarWayBill1 = null;
- try {
- noCarWayBill1 = noCarWaybillMapper.selectByBillNum(num);
- } catch (Exception e) {
- log.info("xuyaoshanchuyundannoCarVoiceOwnerQuery:" + num);
- result.setMsg("平台运单号存在多条,请联系管理员删除无效运单");
- return result;
- }
- if (null == noCarWayBill1) {
- noCarWayBill1 = new NoCarWayBill();
- noCarWayBill1.setBillNum(num);
- }
- noCarWayBill1.setInterType(0);
- RespR rs = noCarService.getInvoiceByWayBillOwnerNumReal(noCarWayBill1, false);
- long costtimeend = System.currentTimeMillis();
- log.info("[-NoCarInterServiceImpl.noCarVoiceOwnerQuery-] 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);
- if (NOT_FOUND.equals(rs.getMsg())) {
- result.setData(2);
- }
- result.setCode(200);
- result.setMsg(rs.getMsg());
- return result;
- }
- } catch (Exception e) {
- log.error("[-NoCarInterServiceImpl.noCarVoiceOwnerQuery-] get httpclient exception is "
- + e + ", request is " + data);
- }
- return result;
- }
- @Autowired
- NoCarCompanyMangerOper noCarCompanyMangerOper;
- @Override
- public DataResult companyDetailAdd(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("无法认证");
- JSONObject jsonObject = JSONObject.parseObject(data);
- if (StringUtils.isEmpty(data) || null == jsonObject) {
- result.setMsg("有空的必填运单要素,请检查");
- return result;
- }
- //税号 必输
- String taxplayerCode = jsonObject.getString("taxplayerCode");
- String operatorName = jsonObject.getString("operatorName");
- String operatorMobile = jsonObject.getString("operatorMobile");
- String identificationId = jsonObject.getString("identificationId");
- String contractFileName = jsonObject.getString("contractFileName");
- String base64Str = jsonObject.getString("base64Str");
- if(StringUtils.isEmpty(taxplayerCode) || StringUtils.isEmpty(operatorName)
- ||StringUtils.isEmpty(operatorMobile) ||StringUtils.isEmpty(contractFileName)
- ||StringUtils.isEmpty(base64Str) ){
- result.setMsg("有空的必填运单要素,请检查");
- }
- CustomerRec customerRec = new CustomerRec();
- customerRec.setCustomerName(appKey);
- customerRec.setCompanyReferencenum(taxplayerCode);
- customerRec = customerRecMapper.selectByCustomerNameAndCompanyReference(customerRec);
- if (customerRec == null) {
- result.setMsg("客户:" + appKey + ";税号" + taxplayerCode + "未在平台备案成功,请先做备案");
- return result;
- }
- try {
- log.info("[-NoCarInterServiceImpl.companyDetailAdd-] request appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid);
- NoCarCompanyManger noCarCompanyManger = new NoCarCompanyManger();
- noCarCompanyManger.setCompanyNum(customerRec.getCompanyNum());
- noCarCompanyManger.setOperatorName(operatorName);
- noCarCompanyManger.setOperatorMobile(operatorMobile);
- noCarCompanyManger.setIdentificationId(identificationId);
- noCarCompanyManger.setContractFileName(contractFileName);
- noCarCompanyManger.setBase64Str(base64Str);
- noCarCompanyManger.setCustId(customerRec.getCustomerName());
- noCarCompanyManger.setCompanyName(customerRec.getCompanyName());
- RespR re = noCarCompanyMangerOper.companyDetailAdd(noCarCompanyManger);
- long costtimeend = System.currentTimeMillis();
- log.info("[-NoCarInterServiceImpl.companyDetailAdd-] result is "
- + re.toString() + ", request is " + data + " ,costtime="
- + (costtimeend - costtimestart));
- if (null != re && re.getCode()==0) {
- result.setData(1);
- result.setCode(200);
- result.setMsg("success");
- return result;
- } else {
- result.setData(3);
- result.setCode(200);
- result.setMsg(re.getMsg());
- return result;
- }
- } catch (Exception e) {
- log.error("[-NoCarInterServiceImpl.companyDetailAdd-] get httpclient exception is "
- + e + ", request is " + data);
- }
- return result;
- }
- @Override
- public DataResult operatorEdit(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("无法认证");
- JSONObject jsonObject = JSONObject.parseObject(data);
- if (StringUtils.isEmpty(data) || null == jsonObject) {
- result.setMsg("有空的必填运单要素,请检查");
- return result;
- }
- //税号 必输
- String taxplayerCode = jsonObject.getString("taxplayerCode");
- String sourceOperatorMobile = jsonObject.getString("sourceOperatorMobile");
- String targetOperatorName = jsonObject.getString("targetOperatorName");
- String targetOperatorMobile = jsonObject.getString("targetOperatorMobile");
- String targetIdentificationId = jsonObject.getString("targetIdentificationId");
- if(StringUtils.isEmpty(taxplayerCode) || StringUtils.isEmpty(targetOperatorName)
- ||StringUtils.isEmpty(targetOperatorMobile) ||StringUtils.isEmpty(sourceOperatorMobile)){
- result.setMsg("有空的必填运单要素,请检查");
- }
- CustomerRec customerRec = new CustomerRec();
- customerRec.setCustomerName(appKey);
- customerRec.setCompanyReferencenum(taxplayerCode);
- customerRec = customerRecMapper.selectByCustomerNameAndCompanyReference(customerRec);
- if (customerRec == null) {
- result.setMsg("客户:" + appKey + ";税号" + taxplayerCode + "未在平台备案成功,请先做备案");
- return result;
- }
- try {
- log.info("[-NoCarInterServiceImpl.operatorEdit-] request appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid);
- OperatorEditVo operatorEditVo = new OperatorEditVo();
- operatorEditVo.setCompanyNum(customerRec.getCompanyNum());
- operatorEditVo.setSourceOperatorMobile(sourceOperatorMobile);
- operatorEditVo.setTargetOperatorName(targetOperatorName);
- operatorEditVo.setTargetOperatorMobile(targetOperatorMobile);
- operatorEditVo.setTargetIdentificationId(targetIdentificationId);
- RespR re = noCarCompanyMangerOper.operatorEdit(operatorEditVo);
- long costtimeend = System.currentTimeMillis();
- log.info("[-NoCarInterServiceImpl.operatorEdit-] result is "
- + re.toString() + ", request is " + data + " ,costtime="
- + (costtimeend - costtimestart));
- if (null != re && re.getCode()==0) {
- result.setData(1);
- result.setCode(200);
- result.setMsg("success");
- return result;
- } else {
- result.setData(3);
- result.setCode(200);
- result.setMsg(re.getMsg());
- return result;
- }
- } catch (Exception e) {
- log.error("[-NoCarInterServiceImpl.operatorEdit-] get httpclient exception is "
- + e + ", request is " + data);
- }
- return result;
- }
- @Override
- public DataResult operatorEditConfirm(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("无法认证");
- JSONObject jsonObject = JSONObject.parseObject(data);
- if (StringUtils.isEmpty(data) || null == jsonObject) {
- result.setMsg("有空的必填运单要素,请检查");
- return result;
- }
- //税号 必输
- String taxplayerCode = jsonObject.getString("taxplayerCode");
- String targetOperatorMobile = jsonObject.getString("targetOperatorMobile");
- String validCode = jsonObject.getString("validCode");
- if(StringUtils.isEmpty(taxplayerCode) || StringUtils.isEmpty(targetOperatorMobile)
- ||StringUtils.isEmpty(validCode)){
- result.setMsg("有空的必填运单要素,请检查");
- }
- CustomerRec customerRec = new CustomerRec();
- customerRec.setCustomerName(appKey);
- customerRec.setCompanyReferencenum(taxplayerCode);
- customerRec = customerRecMapper.selectByCustomerNameAndCompanyReference(customerRec);
- if (customerRec == null) {
- result.setMsg("客户:" + appKey + ";税号" + taxplayerCode + "未在平台备案成功,请先做备案");
- return result;
- }
- try {
- log.info("[-NoCarInterServiceImpl.operatorEditConfirm-] request appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid);
- OperatorEditConfirmVo operatorEditConfirmVo = new OperatorEditConfirmVo();
- operatorEditConfirmVo.setCompanyNum(customerRec.getCompanyNum());
- operatorEditConfirmVo.setTargetOperatorMobile(targetOperatorMobile);
- operatorEditConfirmVo.setValidCode(validCode);
- RespR re = noCarCompanyMangerOper.operatorEditConfirm(operatorEditConfirmVo);
- long costtimeend = System.currentTimeMillis();
- log.info("[-NoCarInterServiceImpl.operatorEditConfirm-] result is "
- + re.toString() + ", request is " + data + " ,costtime="
- + (costtimeend - costtimestart));
- if (null != re && re.getCode()==0) {
- result.setData(1);
- result.setCode(200);
- result.setMsg("success");
- return result;
- } else {
- result.setData(3);
- result.setCode(200);
- result.setMsg(re.getMsg());
- return result;
- }
- } catch (Exception e) {
- log.error("[-NoCarInterServiceImpl.operatorEditConfirm-] get httpclient exception is "
- + e + ", request is " + data);
- }
- return result;
- }
- @Override
- public DataResult operatorEvidence(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("无法认证");
- JSONObject jsonObject = JSONObject.parseObject(data);
- if (StringUtils.isEmpty(data) || null == jsonObject) {
- result.setMsg("有空的必填运单要素,请检查");
- return result;
- }
- //税号 必输
- String taxplayerCode = jsonObject.getString("taxplayerCode");
- String operatorMobile = jsonObject.getString("operatorMobile");
- String contractFileName = jsonObject.getString("contractFileName");
- String base64Str = jsonObject.getString("base64Str");
- if(StringUtils.isEmpty(taxplayerCode)
- ||StringUtils.isEmpty(operatorMobile) ||StringUtils.isEmpty(contractFileName)
- ||StringUtils.isEmpty(base64Str) ){
- result.setMsg("有空的必填运单要素,请检查");
- }
- CustomerRec customerRec = new CustomerRec();
- customerRec.setCustomerName(appKey);
- customerRec.setCompanyReferencenum(taxplayerCode);
- customerRec = customerRecMapper.selectByCustomerNameAndCompanyReference(customerRec);
- if (customerRec == null) {
- result.setMsg("客户:" + appKey + ";税号" + taxplayerCode + "未在平台备案成功,请先做备案");
- return result;
- }
- try {
- log.info("[-NoCarInterServiceImpl.operatorEvidence-] request appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid);
- OperatorEvidenceVo operatorEvidenceVo = new OperatorEvidenceVo();
- operatorEvidenceVo.setCompanyNum(customerRec.getCompanyNum());
- operatorEvidenceVo.setOperatorMobile(operatorMobile);
- operatorEvidenceVo.setContractFileName(contractFileName);
- operatorEvidenceVo.setBase64Str(base64Str);
- RespR re = noCarCompanyMangerOper.operatorEvidence(operatorEvidenceVo);
- long costtimeend = System.currentTimeMillis();
- log.info("[-NoCarInterServiceImpl.operatorEvidence-] result is "
- + re.toString() + ", request is " + data + " ,costtime="
- + (costtimeend - costtimestart));
- if (null != re && re.getCode()==0) {
- result.setData(1);
- result.setCode(200);
- result.setMsg("success");
- return result;
- } else {
- result.setData(3);
- result.setCode(200);
- result.setMsg(re.getMsg());
- return result;
- }
- } catch (Exception e) {
- log.error("[-NoCarInterServiceImpl.operatorEvidence-] get httpclient exception is "
- + e + ", request is " + data);
- }
- return result;
- }
- @Override
- public DataResult operatorSendCode(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("无法认证");
- JSONObject jsonObject = JSONObject.parseObject(data);
- if (StringUtils.isEmpty(data) || null == jsonObject) {
- result.setMsg("有空的必填运单要素,请检查");
- return result;
- }
- //税号 必输
- String taxplayerCode = jsonObject.getString("taxplayerCode");
- if(StringUtils.isEmpty(taxplayerCode)){
- result.setMsg("有空的必填运单要素,请检查");
- }
- CustomerRec customerRec = new CustomerRec();
- customerRec.setCustomerName(appKey);
- customerRec.setCompanyReferencenum(taxplayerCode);
- customerRec = customerRecMapper.selectByCustomerNameAndCompanyReference(customerRec);
- if (customerRec == null) {
- result.setMsg("客户:" + appKey + ";税号" + taxplayerCode + "未在平台备案成功,请先做备案");
- return result;
- }
- try {
- log.info("[-NoCarInterServiceImpl.operatorSendCode-] request appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid);
- OperatorSendCodeVo operatorSendCodeVo = new OperatorSendCodeVo();
- operatorSendCodeVo.setBuyerCode(taxplayerCode);
- RespR re = noCarCompanyMangerOper.operatorSendCode(operatorSendCodeVo, customerRec);
- long costtimeend = System.currentTimeMillis();
- log.info("[-NoCarInterServiceImpl.operatorSendCode-] result is "
- + re.toString() + ", request is " + data + " ,costtime="
- + (costtimeend - costtimestart));
- if (null != re && re.getCode()==0) {
- result.setData(1);
- result.setCode(200);
- result.setMsg("success");
- return result;
- } else {
- result.setData(3);
- result.setCode(200);
- result.setMsg(re.getMsg());
- return result;
- }
- } catch (Exception e) {
- log.error("[-NoCarInterServiceImpl.operatorSendCode-] get httpclient exception is "
- + e + ", request is " + data);
- }
- return result;
- }
- @Override
- public DataResult operatorValidCode(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("无法认证");
- JSONObject jsonObject = JSONObject.parseObject(data);
- if (StringUtils.isEmpty(data) || null == jsonObject) {
- result.setMsg("有空的必填运单要素,请检查");
- return result;
- }
- //税号 必输
- String taxplayerCode = jsonObject.getString("taxplayerCode");
- String validCode = jsonObject.getString("validCode");
- if(StringUtils.isEmpty(taxplayerCode)||StringUtils.isEmpty(validCode)){
- result.setMsg("有空的必填运单要素,请检查");
- }
- CustomerRec customerRec = new CustomerRec();
- customerRec.setCustomerName(appKey);
- customerRec.setCompanyReferencenum(taxplayerCode);
- customerRec = customerRecMapper.selectByCustomerNameAndCompanyReference(customerRec);
- if (customerRec == null) {
- result.setMsg("客户:" + appKey + ";税号" + taxplayerCode + "未在平台备案成功,请先做备案");
- return result;
- }
- try {
- log.info("[-NoCarInterServiceImpl.operatorValidCode-] request appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid);
- OperatorSendCodeVo operatorSendCodeVo = new OperatorSendCodeVo();
- operatorSendCodeVo.setBuyerCode(taxplayerCode);
- operatorSendCodeVo.setValidCode(validCode);
- RespR re = noCarCompanyMangerOper.operatorValidCode(operatorSendCodeVo, customerRec);
- long costtimeend = System.currentTimeMillis();
- log.info("[-NoCarInterServiceImpl.operatorValidCode-] result is "
- + re.toString() + ", request is " + data + " ,costtime="
- + (costtimeend - costtimestart));
- if (null != re && re.getCode()==0) {
- result.setData(1);
- result.setCode(200);
- result.setMsg("success");
- return result;
- } else {
- result.setData(3);
- result.setCode(200);
- result.setMsg(re.getMsg());
- return result;
- }
- } catch (Exception e) {
- log.error("[-NoCarInterServiceImpl.operatorValidCode-] get httpclient exception is "
- + e + ", request is " + data);
- }
- return result;
- }
- }
|