parent
1940dfe6a8
commit
247bc426e5
@ -1,61 +0,0 @@ |
||||
package com.cjy.happyToEnjoy.util; |
||||
|
||||
import java.security.MessageDigest; |
||||
import java.util.Arrays; |
||||
import java.util.Map; |
||||
import java.util.Set; |
||||
import java.util.UUID; |
||||
|
||||
/** |
||||
* @author liangjiawei |
||||
* @createDate 2023/8/21 |
||||
*/ |
||||
public class SignUtil { |
||||
|
||||
public static String getSign(Map<String, Object> data) { |
||||
Set<String> keySet = data.keySet(); |
||||
String[] keyArr = keySet.toArray(new String[keySet.size()]); |
||||
Arrays.sort(keyArr); |
||||
StringBuilder sb = new StringBuilder(); |
||||
for (int i = 0; i < keyArr.length; i++) { |
||||
String key = keyArr[i]; |
||||
sb.append(key + "=" + data.get(key)); |
||||
if (i != keyArr.length - 1) { |
||||
sb.append('&'); |
||||
} |
||||
} |
||||
try { |
||||
return string2MD5(sb.toString()).toLowerCase(); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
return ""; |
||||
} |
||||
|
||||
|
||||
|
||||
public static String string2MD5(String inStr) { |
||||
MessageDigest md5 = null; |
||||
try { |
||||
md5 = MessageDigest.getInstance("MD5"); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
return ""; |
||||
} |
||||
char[] charArray = inStr.toCharArray(); |
||||
byte[] byteArray = new byte[charArray.length]; |
||||
|
||||
for (int i = 0; i < charArray.length; i++) |
||||
byteArray[i] = (byte) charArray[i]; |
||||
byte[] md5Bytes = md5.digest(byteArray); |
||||
StringBuffer hexValue = new StringBuffer(); |
||||
for (int i = 0; i < md5Bytes.length; i++) { |
||||
int val = ((int) md5Bytes[i]) & 0xff; |
||||
if (val < 16) |
||||
hexValue.append("0"); |
||||
hexValue.append(Integer.toHexString(val)); |
||||
} |
||||
return hexValue.toString(); |
||||
|
||||
} |
||||
} |
@ -0,0 +1,143 @@ |
||||
package com.cjy.happytoenjoy.domain; |
||||
|
||||
/** |
||||
* @author liangjiawei |
||||
* @createDate 2023/8/22 |
||||
*/ |
||||
public class HappyToEnjoyEntity { |
||||
private String id; |
||||
private String scenicName; |
||||
private String name; |
||||
private String certificateType; |
||||
private String certificateCode; |
||||
private String phone; |
||||
private String carryFlag; |
||||
private String status; |
||||
private String reservationDate; |
||||
private String beginTime; |
||||
private String endingTime; |
||||
private String scanTime; |
||||
private String reservationNum; |
||||
private String exitStatus; |
||||
private String exitTime; |
||||
|
||||
public String getId() { |
||||
return id; |
||||
} |
||||
|
||||
public void setId(String id) { |
||||
this.id = id; |
||||
} |
||||
|
||||
public String getScenicName() { |
||||
return scenicName; |
||||
} |
||||
|
||||
public void setScenicName(String scenicName) { |
||||
this.scenicName = scenicName; |
||||
} |
||||
|
||||
public String getName() { |
||||
return name; |
||||
} |
||||
|
||||
public void setName(String name) { |
||||
this.name = name; |
||||
} |
||||
|
||||
public String getCertificateType() { |
||||
return certificateType; |
||||
} |
||||
|
||||
public void setCertificateType(String certificateType) { |
||||
this.certificateType = certificateType; |
||||
} |
||||
|
||||
public String getCertificateCode() { |
||||
return certificateCode; |
||||
} |
||||
|
||||
public void setCertificateCode(String certificateCode) { |
||||
this.certificateCode = certificateCode; |
||||
} |
||||
|
||||
public String getPhone() { |
||||
return phone; |
||||
} |
||||
|
||||
public void setPhone(String phone) { |
||||
this.phone = phone; |
||||
} |
||||
|
||||
public String getCarryFlag() { |
||||
return carryFlag; |
||||
} |
||||
|
||||
public void setCarryFlag(String carryFlag) { |
||||
this.carryFlag = carryFlag; |
||||
} |
||||
|
||||
public String getStatus() { |
||||
return status; |
||||
} |
||||
|
||||
public void setStatus(String status) { |
||||
this.status = status; |
||||
} |
||||
|
||||
public String getReservationDate() { |
||||
return reservationDate; |
||||
} |
||||
|
||||
public void setReservationDate(String reservationDate) { |
||||
this.reservationDate = reservationDate; |
||||
} |
||||
|
||||
public String getBeginTime() { |
||||
return beginTime; |
||||
} |
||||
|
||||
public void setBeginTime(String beginTime) { |
||||
this.beginTime = beginTime; |
||||
} |
||||
|
||||
public String getEndingTime() { |
||||
return endingTime; |
||||
} |
||||
|
||||
public void setEndingTime(String endingTime) { |
||||
this.endingTime = endingTime; |
||||
} |
||||
|
||||
public String getScanTime() { |
||||
return scanTime; |
||||
} |
||||
|
||||
public void setScanTime(String scanTime) { |
||||
this.scanTime = scanTime; |
||||
} |
||||
|
||||
public String getReservationNum() { |
||||
return reservationNum; |
||||
} |
||||
|
||||
public void setReservationNum(String reservationNum) { |
||||
this.reservationNum = reservationNum; |
||||
} |
||||
|
||||
public String getExitStatus() { |
||||
return exitStatus; |
||||
} |
||||
|
||||
public void setExitStatus(String exitStatus) { |
||||
this.exitStatus = exitStatus; |
||||
} |
||||
|
||||
public String getExitTime() { |
||||
return exitTime; |
||||
} |
||||
|
||||
public void setExitTime(String exitTime) { |
||||
this.exitTime = exitTime; |
||||
} |
||||
} |
@ -0,0 +1,130 @@ |
||||
package com.cjy.happytoenjoy.task; |
||||
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject; |
||||
import com.cjy.happytoenjoy.domain.HappyToEnjoyEntity; |
||||
import com.cjy.happytoenjoy.util.SignUtil; |
||||
import com.cjy.media.util.WeiBoEncryption; |
||||
import com.cjy.reservationdata.domain.AppointmentCenterData; |
||||
import com.cjy.reservationdata.service.IAppointmentCenterDataService; |
||||
import com.ruoyi.common.utils.DateUtils; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.beans.factory.annotation.Value; |
||||
import org.springframework.scheduling.annotation.Scheduled; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
import java.text.ParseException; |
||||
import java.text.SimpleDateFormat; |
||||
import java.util.*; |
||||
|
||||
/** |
||||
* @author liangjiawei |
||||
* @createDate 2023/8/21 |
||||
*/ |
||||
|
||||
@Component("GetHappyToEnjoyTask") |
||||
public class GetHappyToEnjoyTask { |
||||
@Value("${lxj.scenicId}") |
||||
private String scenicId; |
||||
|
||||
@Value("${lxj.appId}") |
||||
private String appId; |
||||
|
||||
@Value("${lxj.appSecret}") |
||||
private String appSecret; |
||||
|
||||
@Value("${lxj.numberOfDaysAvailable}") |
||||
private Integer numberOfDaysAvailable; |
||||
@Value("${weibo.encryptionRule}") |
||||
private String rule; |
||||
@Autowired |
||||
IAppointmentCenterDataService iAppointmentCenterDataService; |
||||
|
||||
//这里身份证、手机号继续加密 避免查询的时候无法解密
|
||||
// @Scheduled(cron = "0 0/1 * * * ?")
|
||||
public void getEnjoymentAppointmentRecord() { |
||||
String timestamp = SignUtil.create_timestamp(); |
||||
String nonceStr = SignUtil.create_nonce_str(); |
||||
Map<String, Object> signDatgaMap = new HashMap<>(); |
||||
signDatgaMap.put("appId", appId); |
||||
signDatgaMap.put("timestamp", timestamp); |
||||
signDatgaMap.put("nonceStr", nonceStr); |
||||
signDatgaMap.put("appSecret", appSecret); |
||||
String sign = SignUtil.getSign(signDatgaMap); |
||||
signDatgaMap.put("sign", sign); |
||||
|
||||
String startDate = DateUtils.getDaysTimeToString(0); |
||||
String endDate = DateUtils.getDaysTimeToString(numberOfDaysAvailable); |
||||
JSONObject jo = new JSONObject(); |
||||
jo.put("scenicId", scenicId); |
||||
jo.put("startDate", startDate); |
||||
jo.put("endDate", endDate); |
||||
String responseSting = SignUtil.post("https://traveline.hebeitour.com.cn/api/reservation/getReservationRecordT", jo.toString(), signDatgaMap); |
||||
JSONObject jsonData = JSONObject.parseObject(responseSting); |
||||
List<HappyToEnjoyEntity> list = jsonData.getJSONArray("data").toList(HappyToEnjoyEntity.class); |
||||
List<AppointmentCenterData> saveList =new ArrayList<>(); |
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
||||
SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd"); |
||||
list.stream().forEach(item->{ |
||||
AppointmentCenterData appointmentCenterData= new AppointmentCenterData(); |
||||
//预约日期
|
||||
try { |
||||
appointmentCenterData.setAppointmentDate(sdfDate.parse(item.getReservationDate())); |
||||
} catch (ParseException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
//预约人姓名
|
||||
appointmentCenterData.setAppointmentPeopleName(item.getName()); |
||||
//预约人手机号
|
||||
appointmentCenterData.setAppointmentPeoplePhone(WeiBoEncryption.encrypt(item.getPhone(), rule)); |
||||
//预约时间段
|
||||
appointmentCenterData.setAppointmentSlot(item.getBeginTime()+"~"+item.getEndingTime()); |
||||
//证件类型
|
||||
if(item.getCertificateType().equals("身份证")){ |
||||
appointmentCenterData.setCertificateType("5501"); |
||||
//身份证号码
|
||||
appointmentCenterData.setDocumentsNumber(WeiBoEncryption.encrypt(item.getCertificateCode(), rule)); |
||||
}else { |
||||
appointmentCenterData.setCertificateType("5502"); |
||||
appointmentCenterData.setDocumentsNumber(item.getCertificateCode()); |
||||
} |
||||
|
||||
//状态
|
||||
if(item.getStatus().equals("2")){ |
||||
appointmentCenterData.setState("3"); |
||||
}else { |
||||
appointmentCenterData.setState(item.getStatus()); |
||||
} |
||||
|
||||
//核销时间
|
||||
try { |
||||
if(item.getScanTime() !=null){ |
||||
appointmentCenterData.setWriteOffTime( sdf.parse(item.getScanTime())); |
||||
} |
||||
|
||||
} catch (ParseException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
//
|
||||
appointmentCenterData.setSourceDataId(item.getId()); |
||||
appointmentCenterData.setSourceType(1); |
||||
appointmentCenterData.setExternalId("783232818342789120"); |
||||
appointmentCenterData.setDataSources("2"); |
||||
appointmentCenterData.setCreateTime(new Date()); |
||||
appointmentCenterData.setOrganCode(123L); |
||||
if(saveList.size()<1000){ |
||||
saveList.add(appointmentCenterData); |
||||
}else { |
||||
iAppointmentCenterDataService.synchronousData(saveList); |
||||
saveList.clear(); |
||||
saveList.add(appointmentCenterData); |
||||
} |
||||
|
||||
}); |
||||
if(!saveList.isEmpty()){ |
||||
iAppointmentCenterDataService.synchronousData(saveList); |
||||
} |
||||
|
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue