Commit 339a3f60 by 杨林龙

Merge branch 'develop' of http://192.168.3.233:8090/eshiled-new/ne-shield-standard-interfaces

 Conflicts:
	.gitignore
	src/test/java/cn/com/glsx/stdinterface/modules/service/WorkOrderServiceTest.java
2 parents 87ffa3cf 3172b305
# Created by .ignore support plugin (hsz.mobi) /.idea
/.vscode
/target
/*.iml
...@@ -14,6 +14,7 @@ import cn.com.glsx.stdinterface.modules.service.WorkOrderDocsService; ...@@ -14,6 +14,7 @@ import cn.com.glsx.stdinterface.modules.service.WorkOrderDocsService;
import cn.com.glsx.stdinterface.modules.service.WorkOrderService; import cn.com.glsx.stdinterface.modules.service.WorkOrderService;
import cn.com.glsx.stdinterface.modules.service.ZhongliVehicleService; import cn.com.glsx.stdinterface.modules.service.ZhongliVehicleService;
import cn.com.glsx.stdinterface.modules.util.Sm4DecryptUtils; import cn.com.glsx.stdinterface.modules.util.Sm4DecryptUtils;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.glsx.plat.common.annotation.SysLog; import com.glsx.plat.common.annotation.SysLog;
import com.glsx.plat.common.enums.OperateType; import com.glsx.plat.common.enums.OperateType;
...@@ -295,4 +296,22 @@ public class WorkOrderApiController extends CommonController { ...@@ -295,4 +296,22 @@ public class WorkOrderApiController extends CommonController {
} }
return R.ok(); return R.ok();
} }
/**
* 获取工单照片
*
* @param request
* @return
*/
@PostMapping(value = "/getImages")
@SysLog(module = "工单API", value = "获取工单照片", action = OperateType.QUERY)
public R getImages(@RequestBody CommonApiRequest request) {
String decryptData = decryptRequestData(request.getOrganization(), request.getData());
GetImagesBO imagesBO = JSON.parseObject(decryptData, GetImagesBO.class);
imagesBO.setOrderSource(request.getOrganization());
log.info("imagesBO===" + JSONUtil.toJsonStr(imagesBO));
GetImagesDTO imagesDTO = workOrderService.getImages(imagesBO, true);
log.info("imagesDTO===" + JSONUtil.toJsonStr(imagesDTO));
return R.ok().data(imagesDTO);
}
} }
package cn.com.glsx.stdinterface.modules.component;
import cn.com.glsx.stdinterface.enums.WorkOrderSourceEnum;
import cn.com.glsx.stdinterface.modules.entity.WorkOrder;
import cn.com.glsx.stdinterface.modules.model.SyncInstallDataRequest;
import cn.com.glsx.stdinterface.modules.util.zlgj.ZLUtils;
import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.glsx.plat.common.utils.HttpUtils;
import com.glsx.plat.context.utils.PropertiesUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
/**
* 同步仲利数据
*
* @author Yanglinlong
* @date 2023/6/1 16:14
*/
@Slf4j
@Component
public class SyncZhongLiDataComponent {
/**
* 同步激活时间给仲利 异步发送不影响主流程
*
* @param workOrder 工单数据
*/
@Async
public void syncZhongLiInstallTime(WorkOrder workOrder) {
log.info("syncZhongLiInstallTime start===" + workOrder.getPartnerOrderNo());
if (Boolean.FALSE.equals(Boolean.valueOf(PropertiesUtils.getProperty("sync.zl.active.data.flag")))) {
log.info("开关关闭,不推送给仲利" + workOrder.getPartnerOrderNo());
return;
}
// 仲利国际的工单才会推送
if (!WorkOrderSourceEnum.ZLGJ.getCode().equals(workOrder.getOrderSource())) {
log.info("不是仲利国际的单===" + workOrder.getPartnerOrderNo());
return;
}
SyncInstallDataRequest syncInstallDataRequest = new SyncInstallDataRequest();
syncInstallDataRequest.setAppcode(workOrder.getPartnerOrderNo());
syncInstallDataRequest.setInstallationEndTime(DateUtil.formatDateTime(workOrder.getFinishedTime()));
log.info("syncInstallDataRequest:" + JSONUtil.toJsonStr(syncInstallDataRequest));
// 2023/6/1 请求仲利的接口
JSONObject headJson = new JSONObject();
headJson.put(ZLUtils.ZL_DEVICEID_KEY, ZLUtils.ZL_DEVICEID_VAL);
JSONObject bodyJson = new JSONObject();
String syncInstallDataJsonStr = JSON.toJSONString(syncInstallDataRequest);
long currentTime = System.currentTimeMillis();
bodyJson.put("data", ZLUtils.parseDataByRSA(syncInstallDataJsonStr));
bodyJson.put("time", currentTime);
bodyJson.put("sign", ZLUtils.getSign(syncInstallDataJsonStr, currentTime));
JSONObject paramBaseJson = new JSONObject();
paramBaseJson.put(ZLUtils.ZL_CN_KEY, ZLUtils.ZL_CN_VAL);
paramBaseJson.put(ZLUtils.ZL_SI_KEY, ZLUtils.ZL_SI_VAL);
paramBaseJson.put(ZLUtils.ZL_TN_KEY, ZLUtils.ZL_TN_VAL);
paramBaseJson.put("head", headJson);
paramBaseJson.put("body", bodyJson);
log.info("调用仲利上传激活时间接口 params:" + paramBaseJson.toJSONString());
String saveGpsEndDateUrl = PropertiesUtils.getProperty("zlgj.active.saveGpsEndDate.url");
String result = HttpUtils.post(saveGpsEndDateUrl, paramBaseJson.toJSONString());
log.info("调用仲利上传激活时间接口 返回的结果为:" + result);
log.info("syncZhongLiInstallTime end===" + workOrder.getPartnerOrderNo());
}
}
...@@ -83,4 +83,10 @@ public class WorkOrderController implements WorkOrderClient { ...@@ -83,4 +83,10 @@ public class WorkOrderController implements WorkOrderClient {
workOrderService.updateImage(updateImageBO.getWorkOrderDocs(), updateImageBO.getWorkOrderId()); workOrderService.updateImage(updateImageBO.getWorkOrderDocs(), updateImageBO.getWorkOrderId());
return R.ok(); return R.ok();
} }
@Override
public R syncZhongLiData(WorkOrderDetailDTO workOrdeDetailrDTO) {
workOrderService.syncZhongLiData(workOrdeDetailrDTO);
return R.ok();
}
} }
...@@ -23,6 +23,8 @@ public interface WorkOrderConverter { ...@@ -23,6 +23,8 @@ public interface WorkOrderConverter {
WorkOrder bo2do(RemoveWorkOrderBO item); WorkOrder bo2do(RemoveWorkOrderBO item);
WorkOrder bo2do(WorkOrderDetailDTO item);
@Mappings({ @Mappings({
@Mapping(source = "id", target = "workOrderId"), @Mapping(source = "id", target = "workOrderId"),
@Mapping(source = "orderNo", target = "workOrderNo"), @Mapping(source = "orderNo", target = "workOrderNo"),
......
...@@ -104,4 +104,17 @@ public interface WorkOrderMapper extends CommonBaseMapper<WorkOrder> { ...@@ -104,4 +104,17 @@ public interface WorkOrderMapper extends CommonBaseMapper<WorkOrder> {
* @return * @return
*/ */
List<CompletedWorkOrderModel> selectAllCompletedWorkOrders(); List<CompletedWorkOrderModel> selectAllCompletedWorkOrders();
/**
* 通过服务类型 工单号 车架号查询工单信息
*
* @param serviceType 服务类型
* @param partnerOrderNo 业务工单号
* @param vin 车架号
* @return
*/
WorkOrder selectWorkOrderByBizWorkOrderNoAndVin(@Param("orderSource") String orderSource,
@Param("serviceType") String serviceType,
@Param("partnerOrderNo") String partnerOrderNo,
@Param("vin") String vin);
} }
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.stdinterface.modules.model;
import lombok.Data;
/**
* @author Yanglinlong
* @date 2023/6/1 16:19
*/
@Data
public class SyncInstallDataRequest {
/**
* 工单号
*/
private String appcode;
/**
* 完成安装时间 激活时间
*/
private String installationEndTime;
}
package cn.com.glsx.stdinterface.modules.model;
import lombok.Data;
/**
* 同步仲利数据返回实体类
*
* @author Yanglinlong
* @date 2023/6/1 16:19
*/
@Data
public class SyncInstallDataResponse {
/**
* 成功状态码 0000为成功,其他都为失败
*/
private String code;
/**
* 成功信息
*/
private String message;
}
package cn.com.glsx.stdinterface.modules.remote;
import cn.com.glsx.usercenter.api.dto.response.TenantDto;
import cn.com.glsx.usercenter.api.feign.ApiUserService;
import cn.hutool.json.JSONUtil;
import com.glsx.plat.core.web.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* 调用usercenter 用户服务
*
* @author Yanglinlong
* @date 2023/6/19 16:29
*/
@Slf4j
@Service
public class RemoteApiUserService {
@Autowired
private ApiUserService apiUserService;
/**
* 通过 userId 获取租户数据
*
* @param userId 用户ID
* @return
*/
public TenantDto getTenantByUserId(Long userId) {
R<TenantDto> tenantR = apiUserService.getTenantByUserId(userId);
TenantDto tenantDto = tenantR.getData(TenantDto.class);
log.info("tenantDto==" + JSONUtil.toJsonStr(tenantDto));
return tenantDto;
}
}
...@@ -13,7 +13,6 @@ import cn.com.glsx.devicemonitor.api.feign.GpsBsFeignService; ...@@ -13,7 +13,6 @@ import cn.com.glsx.devicemonitor.api.feign.GpsBsFeignService;
import cn.com.glsx.notify.dto.request.MailMessageRequest; import cn.com.glsx.notify.dto.request.MailMessageRequest;
import cn.com.glsx.notify.dto.request.SmsMessageRequest; import cn.com.glsx.notify.dto.request.SmsMessageRequest;
import cn.com.glsx.stdinterface.common.constants.Constants; import cn.com.glsx.stdinterface.common.constants.Constants;
import cn.com.glsx.stdinterface.common.enums.ResultEnum;
import cn.com.glsx.stdinterface.common.enums.TypeConverseEunm; import cn.com.glsx.stdinterface.common.enums.TypeConverseEunm;
import cn.com.glsx.stdinterface.common.exception.StdInterfaceException; import cn.com.glsx.stdinterface.common.exception.StdInterfaceException;
import cn.com.glsx.stdinterface.dto.*; import cn.com.glsx.stdinterface.dto.*;
...@@ -21,13 +20,17 @@ import cn.com.glsx.stdinterface.enums.BizServiceTypeEnum; ...@@ -21,13 +20,17 @@ import cn.com.glsx.stdinterface.enums.BizServiceTypeEnum;
import cn.com.glsx.stdinterface.enums.DeviceComposeEnum; import cn.com.glsx.stdinterface.enums.DeviceComposeEnum;
import cn.com.glsx.stdinterface.enums.WorkOrderSourceEnum; import cn.com.glsx.stdinterface.enums.WorkOrderSourceEnum;
import cn.com.glsx.stdinterface.enums.WorkOrderStatusEnum; import cn.com.glsx.stdinterface.enums.WorkOrderStatusEnum;
import cn.com.glsx.stdinterface.modules.component.SyncZhongLiDataComponent;
import cn.com.glsx.stdinterface.modules.converter.*; import cn.com.glsx.stdinterface.modules.converter.*;
import cn.com.glsx.stdinterface.modules.entity.*; import cn.com.glsx.stdinterface.modules.entity.*;
import cn.com.glsx.stdinterface.modules.mapper.*; import cn.com.glsx.stdinterface.modules.mapper.*;
import cn.com.glsx.stdinterface.modules.model.*; import cn.com.glsx.stdinterface.modules.model.*;
import cn.com.glsx.stdinterface.modules.model.datasync.DeviceActiveSync; import cn.com.glsx.stdinterface.modules.model.datasync.DeviceActiveSync;
import cn.com.glsx.stdinterface.modules.remote.NotifyCenterService; import cn.com.glsx.stdinterface.modules.remote.NotifyCenterService;
import cn.com.glsx.stdinterface.modules.remote.RemoteApiUserService;
import cn.com.glsx.stdinterface.modules.util.DeviceLocationUtil; import cn.com.glsx.stdinterface.modules.util.DeviceLocationUtil;
import cn.com.glsx.stdinterface.modules.util.Pinyin;
import cn.com.glsx.usercenter.api.dto.response.TenantDto;
import cn.com.glsx.usercenter.api.dto.response.User; import cn.com.glsx.usercenter.api.dto.response.User;
import cn.com.glsx.usercenter.api.feign.ApiUserService; import cn.com.glsx.usercenter.api.feign.ApiUserService;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
...@@ -128,6 +131,12 @@ public class WorkOrderService { ...@@ -128,6 +131,12 @@ public class WorkOrderService {
@Autowired @Autowired
private ApplicationEventPublisher applicationEventPublisher; private ApplicationEventPublisher applicationEventPublisher;
@Autowired
private SyncZhongLiDataComponent syncZhongLiDataComponent;
@Autowired
private RemoteApiUserService remoteApiUserService;
/** /**
* 新增工单 * 新增工单
* *
...@@ -1106,6 +1115,10 @@ public class WorkOrderService { ...@@ -1106,6 +1115,10 @@ public class WorkOrderService {
activatedVehicleInfoDTO.setBindingDevices(bindingDevices); activatedVehicleInfoDTO.setBindingDevices(bindingDevices);
log.info("激活工单概要信息:{}", JSONUtil.toJsonStr(activatedVehicleInfoDTO)); log.info("激活工单概要信息:{}", JSONUtil.toJsonStr(activatedVehicleInfoDTO));
if (!isApiCall) {
// 非接口调用 前端调用的时候(调用激活接口) 异步同步仲利激活时间给仲利
syncZhongLiDataComponent.syncZhongLiInstallTime(workOrder);
}
return activatedVehicleInfoDTO; return activatedVehicleInfoDTO;
} }
...@@ -1185,6 +1198,8 @@ public class WorkOrderService { ...@@ -1185,6 +1198,8 @@ public class WorkOrderService {
//操作日志 //操作日志
recordLogs(workOrder, workOrder.getUpdatedBy(), "审核激活工单"); recordLogs(workOrder, workOrder.getUpdatedBy(), "审核激活工单");
//异步同步仲利激活时间给仲利
syncZhongLiDataComponent.syncZhongLiInstallTime(workOrder);
} }
/** /**
...@@ -1744,4 +1759,66 @@ public class WorkOrderService { ...@@ -1744,4 +1759,66 @@ public class WorkOrderService {
DeviceLocation location = DeviceLocationConverter.INSTANCE.bo2do(locationBO); DeviceLocation location = DeviceLocationConverter.INSTANCE.bo2do(locationBO);
return deviceLocationMapper.insertOrUpdate(location); return deviceLocationMapper.insertOrUpdate(location);
} }
public GetImagesDTO getImages(GetImagesBO imagesBO, boolean isApiCall) {
WorkOrder workOrder = null;
if (isApiCall) {
workOrder = workOrderMapper.selectWorkOrderByBizWorkOrderNoAndVin(imagesBO.getOrderSource(), BizServiceTypeEnum.INSTALL.getType(), imagesBO.getBizWorkOrderNo(), imagesBO.getVin());
} else {
workOrder = workOrderMapper.selectById(imagesBO.getWorkOrderId());
}
if (workOrder == null) {
log.info(imagesBO.getBizWorkOrderNo() + "工单不存在");
throw new StdInterfaceException("656565", String.format("工单%s不存在", imagesBO.getBizWorkOrderNo()));
}
if (WorkOrderStatusEnum.CANCELED.getStatus().equals(workOrder.getStatus())) {
log.info("工单{}已经被取消", imagesBO.getBizWorkOrderNo());
throw new StdInterfaceException("656565", String.format("工单%s已经被取消", workOrder.getOrderNo()));
}
if (!WorkOrderStatusEnum.COMPLETED.getStatus().equals(workOrder.getStatus())) {
log.info("工单{}未完成", imagesBO.getBizWorkOrderNo());
throw new StdInterfaceException("656565", String.format("工单%s未完成", workOrder.getOrderNo()));
}
GetImagesDTO imagesDTO = new GetImagesDTO();
imagesDTO.setShopName(workOrder.getShopName());
imagesDTO.setShopTelephone(workOrder.getShopTelephone());
imagesDTO.setServiceTime(workOrder.getServiceTime());
imagesDTO.setServiceAddress(workOrder.getServiceAddress());
//查车辆
Vehicle vehicle = vehicleMapper.selectByWorkOrderId(workOrder.getId());
if (vehicle == null) {
log.info("工单{}未完成车辆激活", imagesBO.getBizWorkOrderNo());
throw new StdInterfaceException("656565", String.format("工单%s未完成车辆激活", imagesBO.getBizWorkOrderNo()));
}
// 根据车辆查询所在组织层级
TenantDto tenantDto = remoteApiUserService.getTenantByUserId(vehicle.getCreatedBy());
if (Objects.isNull(tenantDto) || !Objects.equals(imagesBO.getOrderSource(), Pinyin.getPinYinHeadChar(tenantDto.getTenantName()))) {
log.info("工单{}对应的车辆不是{}的车辆", imagesBO.getBizWorkOrderNo(), imagesBO.getOrderSource());
throw new StdInterfaceException("656565", String.format("工单%s不存在", imagesBO.getBizWorkOrderNo()));
}
imagesDTO.setLesseeName(vehicle.getOwnerName());
imagesDTO.setVin(vehicle.getVin());
List<WorkOrderDocs> workOrderDocs = workOrderDocsMapper.selectByOrderId(workOrder.getId());
List<ImageItem> imageItemList = workOrderDocs.stream().map(workOrderDoc -> {
ImageItem imageItem = new ImageItem();
imageItem.setId(workOrderDoc.getId());
imageItem.setName(workOrderDoc.getName());
imageItem.setPath(workOrderDoc.getPath());
imageItem.setCompressUrl(workOrderDoc.getCompressUrl());
return imageItem;
}).collect(Collectors.toList());
imagesDTO.setList(imageItemList);
return imagesDTO;
}
public void syncZhongLiData(WorkOrderDetailDTO workOrderDetailDTO) {
WorkOrder workOrder = WorkOrderConverter.INSTANCE.bo2do(workOrderDetailDTO);
syncZhongLiDataComponent.syncZhongLiInstallTime(workOrder);
}
} }
package cn.com.glsx.stdinterface.modules.util.zlgj;
/**
* 该类由仲利提供 用于base64编码
*/
public final class ZLBase64 {
static private final int BASELENGTH = 128;
static private final int LOOKUPLENGTH = 64;
static private final int TWENTYFOURBITGROUP = 24;
static private final int EIGHTBIT = 8;
static private final int SIXTEENBIT = 16;
static private final int FOURBYTE = 4;
static private final int SIGN = -128;
static private final char PAD = '=';
static private final boolean fDebug = false;
static final private byte[] base64Alphabet = new byte[BASELENGTH];
static final private char[] lookUpBase64Alphabet = new char[LOOKUPLENGTH];
static {
for (int i = 0; i < BASELENGTH; ++i) {
base64Alphabet[i] = -1;
}
for (int i = 'Z'; i >= 'A'; i--) {
base64Alphabet[i] = (byte) (i - 'A');
}
for (int i = 'z'; i >= 'a'; i--) {
base64Alphabet[i] = (byte) (i - 'a' + 26);
}
for (int i = '9'; i >= '0'; i--) {
base64Alphabet[i] = (byte) (i - '0' + 52);
}
base64Alphabet['+'] = 62;
base64Alphabet['/'] = 63;
for (int i = 0; i <= 25; i++) {
lookUpBase64Alphabet[i] = (char) ('A' + i);
}
for (int i = 26, j = 0; i <= 51; i++, j++) {
lookUpBase64Alphabet[i] = (char) ('a' + j);
}
for (int i = 52, j = 0; i <= 61; i++, j++) {
lookUpBase64Alphabet[i] = (char) ('0' + j);
}
lookUpBase64Alphabet[62] = (char) '+';
lookUpBase64Alphabet[63] = (char) '/';
}
private static boolean isWhiteSpace(char octect) {
return (octect == 0x20 || octect == 0xd || octect == 0xa || octect == 0x9);
}
private static boolean isPad(char octect) {
return (octect == PAD);
}
private static boolean isData(char octect) {
return (octect < BASELENGTH && base64Alphabet[octect] != -1);
}
/**
* Encodes hex octects into ZLBase64
*
* @param binaryData Array containing binaryData
* @return Encoded ZLBase64 array
*/
public static String encode(byte[] binaryData) {
if (binaryData == null) {
return null;
}
int lengthDataBits = binaryData.length * EIGHTBIT;
if (lengthDataBits == 0) {
return "";
}
int fewerThan24bits = lengthDataBits % TWENTYFOURBITGROUP;
int numberTriplets = lengthDataBits / TWENTYFOURBITGROUP;
int numberQuartet = fewerThan24bits != 0 ? numberTriplets + 1 : numberTriplets;
char encodedData[] = null;
encodedData = new char[numberQuartet * 4];
byte k = 0, l = 0, b1 = 0, b2 = 0, b3 = 0;
int encodedIndex = 0;
int dataIndex = 0;
if (fDebug) {
System.out.println("number of triplets = " + numberTriplets);
}
for (int i = 0; i < numberTriplets; i++) {
b1 = binaryData[dataIndex++];
b2 = binaryData[dataIndex++];
b3 = binaryData[dataIndex++];
if (fDebug) {
System.out.println("b1= " + b1 + ", b2= " + b2 + ", b3= " + b3);
}
l = (byte) (b2 & 0x0f);
k = (byte) (b1 & 0x03);
byte val1 = ((b1 & SIGN) == 0) ? (byte) (b1 >> 2) : (byte) ((b1) >> 2 ^ 0xc0);
byte val2 = ((b2 & SIGN) == 0) ? (byte) (b2 >> 4) : (byte) ((b2) >> 4 ^ 0xf0);
byte val3 = ((b3 & SIGN) == 0) ? (byte) (b3 >> 6) : (byte) ((b3) >> 6 ^ 0xfc);
if (fDebug) {
System.out.println("val2 = " + val2);
System.out.println("k4 = " + (k << 4));
System.out.println("vak = " + (val2 | (k << 4)));
}
encodedData[encodedIndex++] = lookUpBase64Alphabet[val1];
encodedData[encodedIndex++] = lookUpBase64Alphabet[val2 | (k << 4)];
encodedData[encodedIndex++] = lookUpBase64Alphabet[(l << 2) | val3];
encodedData[encodedIndex++] = lookUpBase64Alphabet[b3 & 0x3f];
}
// form integral number of 6-bit groups
if (fewerThan24bits == EIGHTBIT) {
b1 = binaryData[dataIndex];
k = (byte) (b1 & 0x03);
if (fDebug) {
System.out.println("b1=" + b1);
System.out.println("b1<<2 = " + (b1 >> 2));
}
byte val1 = ((b1 & SIGN) == 0) ? (byte) (b1 >> 2) : (byte) ((b1) >> 2 ^ 0xc0);
encodedData[encodedIndex++] = lookUpBase64Alphabet[val1];
encodedData[encodedIndex++] = lookUpBase64Alphabet[k << 4];
encodedData[encodedIndex++] = PAD;
encodedData[encodedIndex++] = PAD;
} else if (fewerThan24bits == SIXTEENBIT) {
b1 = binaryData[dataIndex];
b2 = binaryData[dataIndex + 1];
l = (byte) (b2 & 0x0f);
k = (byte) (b1 & 0x03);
byte val1 = ((b1 & SIGN) == 0) ? (byte) (b1 >> 2) : (byte) ((b1) >> 2 ^ 0xc0);
byte val2 = ((b2 & SIGN) == 0) ? (byte) (b2 >> 4) : (byte) ((b2) >> 4 ^ 0xf0);
encodedData[encodedIndex++] = lookUpBase64Alphabet[val1];
encodedData[encodedIndex++] = lookUpBase64Alphabet[val2 | (k << 4)];
encodedData[encodedIndex++] = lookUpBase64Alphabet[l << 2];
encodedData[encodedIndex++] = PAD;
}
return new String(encodedData);
}
/**
* Decodes ZLBase64 data into octects
*
* @param encoded string containing ZLBase64 data
* @return Array containind decoded data.
*/
public static byte[] decode(String encoded) {
if (encoded == null) {
return null;
}
char[] base64Data = encoded.toCharArray();
// remove white spaces
int len = removeWhiteSpace(base64Data);
if (len % FOURBYTE != 0) {
return null;//should be divisible by four
}
int numberQuadruple = (len / FOURBYTE);
if (numberQuadruple == 0) {
return new byte[0];
}
byte decodedData[] = null;
byte b1 = 0, b2 = 0, b3 = 0, b4 = 0;
char d1 = 0, d2 = 0, d3 = 0, d4 = 0;
int i = 0;
int encodedIndex = 0;
int dataIndex = 0;
decodedData = new byte[(numberQuadruple) * 3];
for (; i < numberQuadruple - 1; i++) {
if (!isData((d1 = base64Data[dataIndex++])) || !isData((d2 = base64Data[dataIndex++]))
|| !isData((d3 = base64Data[dataIndex++]))
|| !isData((d4 = base64Data[dataIndex++]))) {
return null;
}//if found "no data" just return null
b1 = base64Alphabet[d1];
b2 = base64Alphabet[d2];
b3 = base64Alphabet[d3];
b4 = base64Alphabet[d4];
decodedData[encodedIndex++] = (byte) (b1 << 2 | b2 >> 4);
decodedData[encodedIndex++] = (byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf));
decodedData[encodedIndex++] = (byte) (b3 << 6 | b4);
}
if (!isData((d1 = base64Data[dataIndex++])) || !isData((d2 = base64Data[dataIndex++]))) {
return null;//if found "no data" just return null
}
b1 = base64Alphabet[d1];
b2 = base64Alphabet[d2];
d3 = base64Data[dataIndex++];
d4 = base64Data[dataIndex++];
if (!isData((d3)) || !isData((d4))) {//Check if they are PAD characters
if (isPad(d3) && isPad(d4)) {
if ((b2 & 0xf) != 0)//last 4 bits should be zero
{
return null;
}
byte[] tmp = new byte[i * 3 + 1];
System.arraycopy(decodedData, 0, tmp, 0, i * 3);
tmp[encodedIndex] = (byte) (b1 << 2 | b2 >> 4);
return tmp;
} else if (!isPad(d3) && isPad(d4)) {
b3 = base64Alphabet[d3];
if ((b3 & 0x3) != 0)//last 2 bits should be zero
{
return null;
}
byte[] tmp = new byte[i * 3 + 2];
System.arraycopy(decodedData, 0, tmp, 0, i * 3);
tmp[encodedIndex++] = (byte) (b1 << 2 | b2 >> 4);
tmp[encodedIndex] = (byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf));
return tmp;
} else {
return null;
}
} else { //No PAD e.g 3cQl
b3 = base64Alphabet[d3];
b4 = base64Alphabet[d4];
decodedData[encodedIndex++] = (byte) (b1 << 2 | b2 >> 4);
decodedData[encodedIndex++] = (byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf));
decodedData[encodedIndex++] = (byte) (b3 << 6 | b4);
}
return decodedData;
}
/**
* remove WhiteSpace from MIME containing encoded ZLBase64 data.
*
* @param data the byte array of base64 data (with WS)
* @return the new length
*/
private static int removeWhiteSpace(char[] data) {
if (data == null) {
return 0;
}
// count characters that's not whitespace
int newSize = 0;
int len = data.length;
for (int i = 0; i < len; i++) {
if (!isWhiteSpace(data[i])) {
data[newSize++] = data[i];
}
}
return newSize;
}
}
package cn.com.glsx.stdinterface.modules.util.zlgj;
import java.security.MessageDigest;
/**
* 该类由仲利提供 用于ZLMD5 算法
*/
public class ZLMD5 {
// 全局数组
private final static String[] strDigits = {"0", "1", "2", "3", "4", "5",
"6", "7", "8", "9", "a", "b", "c", "d", "e", "f"};
public ZLMD5() {
}
// 返回形式为数字跟字符串
private static String byteToArrayString(byte bByte) {
int iRet = bByte;
// System.out.println("iRet="+iRet);
if (iRet < 0) {
iRet += 256;
}
int iD1 = iRet / 16;
int iD2 = iRet % 16;
return strDigits[iD1] + strDigits[iD2];
}
// 返回形式只为数字
private static String byteToNum(byte bByte) {
int iRet = bByte;
System.out.println("iRet1=" + iRet);
if (iRet < 0) {
iRet += 256;
}
return String.valueOf(iRet);
}
// 转换字节数组为16进制字串
private static String byteToString(byte[] bByte) {
StringBuffer sBuffer = new StringBuffer();
for (int i = 0; i < bByte.length; i++) {
sBuffer.append(byteToArrayString(bByte[i]));
}
return sBuffer.toString();
}
public static String GetMD5Code(String strObj) {
String resultString = null;
try {
resultString = new String(strObj);
MessageDigest md = MessageDigest.getInstance("MD5");
// md.digest() 该函数返回值为存放哈希值结果的byte数组
resultString = byteToString(md.digest(strObj.getBytes("UTF-8")));
} catch (Exception ex) {
ex.printStackTrace();
}
return resultString;
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.stdinterface.modules.util.zlgj;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.glsx.plat.context.utils.PropertiesUtils;
/**
* @Desc:仲利的相关业务工具类
* @Author huangxc
* @Date 2020/9/18
*/
public class ZLUtils {
public static final String ZL_CN_KEY = "_cn";
public static final String ZL_CN_VAL = "IFSP01";
public static final String ZL_TN_KEY = "_tn";
public static final String ZL_TN_VAL = "1EE5C59F0A1700100057306C855BFBB0S";
public static final String ZL_SI_KEY = "_si";
public static final String ZL_SI_VAL = "TRA003010104";
public static final String ZL_DEVICEID_KEY = "deviceId";
public static final String ZL_DEVICEID_VAL = "bMFnyF6zNashglsx";
//测试环境
// public static final String publicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCz3GrqjbXScSZTGx7e/XGgPo2IUFrK1L2JwQduO0i74plQy5pgkNovjlvUTt50kbnURsm9lnrQ1/jkxbx2T9CpONMSxhEavg+FvH9cqBKHCymgtMoPd9WL53ySiCIAgrpDf3JlHx2eC6Dyd/HG/1VLxWVhF2XlBHKfE3h1T+xRsQIDAQAB";
//生产环境
//public static final String publicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCAeM809K/0O6YOTbHg1UVuKRGpHSZfd8q/J81Gmb3z895PfU6Jzdd3XFu+K+1VRt8WUgc71S+ZTFD3KkqSpmmutYAo0ODi2lPWlMN2f1MuySvP3T9UGsKyG8/ucdSrwfiESuJXgcvkl7YwbZby7cQ+kdS8hkVzqM5R5tFfVH2QMwIDAQAB";
public static final String SUCCESS_CODE = "0000";
/**
* 解析数据集合 数据用RSA进行加密
*
* @param objData 数据集合
* @return
*/
public static String parseDataListByRSA(Object objData) {
String publicKey = PropertiesUtils.getProperty("zl.zlrsa.public.key");
return ZLRSA.encryptPublickey(JSONArray.toJSONString(objData), publicKey);
}
/**
* 解析数据 数据用RSA进行加密
*
* @param objData 数据
* @return
*/
public static String parseDataByRSA(Object objData) {
String publicKey = PropertiesUtils.getProperty("zl.zlrsa.public.key");
return ZLRSA.encryptPublickey(JSON.toJSONString(objData), publicKey);
}
/**
* 获得数据的签名
*
* @param dataJsonStr
* @param currentTime
* @param publicKey
* @return
*/
public static String getSign(String dataJsonStr, long currentTime, String publicKey) {
String param = dataJsonStr + currentTime + publicKey;
return ZLMD5.GetMD5Code(param).toUpperCase();
}
public static String getSign(String dateJsonStr, long currentTime) {
String publicKey = PropertiesUtils.getProperty("zl.zlrsa.public.key");
return getSign(dateJsonStr, currentTime, publicKey);
}
}
...@@ -27,3 +27,4 @@ spring.cloud.nacos.config.shared-configs[1].data-id=glsx-ne-shield-share-dev.pro ...@@ -27,3 +27,4 @@ spring.cloud.nacos.config.shared-configs[1].data-id=glsx-ne-shield-share-dev.pro
spring.cloud.nacos.config.shared-configs[1].refresh=true spring.cloud.nacos.config.shared-configs[1].refresh=true
spring.main.allow-bean-definition-overriding=true spring.main.allow-bean-definition-overriding=true
#mybatis.configuration.log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
\ No newline at end of file \ No newline at end of file
...@@ -162,4 +162,24 @@ ...@@ -162,4 +162,24 @@
where tw.del_flag = 0 where tw.del_flag = 0
order by tw.id desc order by tw.id desc
</select> </select>
<select id="selectWorkOrderByBizWorkOrderNoAndVin" resultMap="BaseResultMap">
select tw.*
from t_workorder tw
left join t_workorder_vehicle twv on twv.workorder_id = tw.id
where tw.del_flag = 0
and tw.status = 2
<choose>
<when test="orderSource != null and orderSource != ''">
and tw.order_source in (#{orderSource},'glsx_nes')
</when>
<otherwise>
and tw.order_source = 'glsx_nes'
</otherwise>
</choose>
and tw.service_type = #{serviceType}
and tw.partner_order_no = #{partnerOrderNo}
and twv.vin = #{vin}
order by tw.id desc limit 1
</select>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
...@@ -14,21 +14,21 @@ public class MainTest03 { ...@@ -14,21 +14,21 @@ public class MainTest03 {
public static void main(String[] args) { public static void main(String[] args) {
XBAddrVerifyBo infoBO = new XBAddrVerifyBo(); XBAddrVerifyBo infoBO = new XBAddrVerifyBo();
infoBO.setOrderSource("湖北襄本网络"); infoBO.setOrderSource("湖北襄本网络");
infoBO.setSn("1700112234"); infoBO.setSn("15211150569");
System.out.println("infoBO = " + JSONUtil.toJsonPrettyStr(infoBO)); System.out.println("infoBO = " + JSONUtil.toJsonPrettyStr(infoBO));
CommonApiRequest request = new CommonApiRequest(); CommonApiRequest request = new CommonApiRequest();
request.setOrganization("湖北襄本网络"); request.setOrganization("湖北襄本网络");
request.setTimestamp(System.currentTimeMillis()); request.setTimestamp(System.currentTimeMillis());
request.setDataType(1); request.setDataType(1);
System.out.println("request = " + JSONUtil.toJsonPrettyStr(request)); System.out.println("request beforre= " + JSONUtil.toJsonPrettyStr(request));
String encryptData = Sm4EncryptUtils.encryptCbc("E76F7D9A27F63E6BA5F4282D81BA9E50", JSONUtil.toJsonStr(infoBO)); String encryptData = Sm4EncryptUtils.encryptCbc("E76F7D9A27F63E6BA5F4282D81BA9E50", JSONUtil.toJsonStr(infoBO));
request.setData(encryptData); request.setData(encryptData);
System.out.println(JSONUtil.toJsonPrettyStr(request)); System.out.println("request after===" + JSONUtil.toJsonPrettyStr(request));
String encryptDataTest = Sm4EncryptUtils.encryptCbc("E76F7D9A27F63E6BA5F4282D81BA9E50", "123456"); // String encryptDataTest = Sm4EncryptUtils.encryptCbc("E76F7D9A27F63E6BA5F4282D81BA9E50", "123456");
System.out.println("encryptDataTest===" + encryptDataTest); // System.out.println("encryptDataTest===" + encryptDataTest);
} }
} }
package cn.com.glsx.stdinterface.modules.component;
import cn.com.glsx.Application;
import cn.com.glsx.stdinterface.modules.entity.WorkOrder;
import cn.com.glsx.stdinterface.modules.mapper.WorkOrderMapper;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@Slf4j
@RunWith(SpringRunner.class)
@SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class SyncZhongLiDataComponentTest {
@Autowired
private SyncZhongLiDataComponent syncZhongLiDataComponent;
@Autowired
private WorkOrderMapper workOrderMapper;
@Test
public void syncZhongLiInstallTime() {
WorkOrder workOrder = workOrderMapper.selectByOrderNo("2022121516000001");
syncZhongLiDataComponent.syncZhongLiInstallTime(workOrder);
}
}
\ No newline at end of file \ No newline at end of file
...@@ -6,9 +6,7 @@ import cn.com.glsx.notify.dto.request.MailMessageRequest; ...@@ -6,9 +6,7 @@ import cn.com.glsx.notify.dto.request.MailMessageRequest;
import cn.com.glsx.notify.dto.request.SmsMessageRequest; import cn.com.glsx.notify.dto.request.SmsMessageRequest;
import cn.com.glsx.stdinterface.common.exception.StdInterfaceException; import cn.com.glsx.stdinterface.common.exception.StdInterfaceException;
import cn.com.glsx.stdinterface.dto.SimpleDeviceItem; import cn.com.glsx.stdinterface.dto.SimpleDeviceItem;
import cn.com.glsx.stdinterface.dto.WorkOrderActivateBO; import cn.com.glsx.stdinterface.dto.*;
import cn.com.glsx.stdinterface.dto.WorkOrderAddrVerifyBO;
import cn.com.glsx.stdinterface.dto.WorkOrderAddrVerifyDTO;
import cn.com.glsx.stdinterface.modules.entity.Vehicle; import cn.com.glsx.stdinterface.modules.entity.Vehicle;
import cn.com.glsx.stdinterface.modules.entity.WorkOrder; import cn.com.glsx.stdinterface.modules.entity.WorkOrder;
import cn.com.glsx.stdinterface.modules.entity.WorkOrderDocs; import cn.com.glsx.stdinterface.modules.entity.WorkOrderDocs;
...@@ -252,4 +250,15 @@ public class WorkOrderServiceTest { ...@@ -252,4 +250,15 @@ public class WorkOrderServiceTest {
System.out.println("end=== "); System.out.println("end=== ");
} }
@Test
public void testGetImages() {
GetImagesBO imagesBO = new GetImagesBO();
imagesBO.setOrderSource("glsx_nes");
imagesBO.setBizWorkOrderNo("AP2021083194981");
imagesBO.setVin("LHGFS165XK2114307");
GetImagesDTO images = workOrderService.getImages(imagesBO, Boolean.TRUE);
System.out.println("images = " + JSONUtil.toJsonPrettyStr(images));
}
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!