|
@@ -17,9 +17,7 @@ import org.jeecg.modules.quartz.utils.HolidayUtil;
|
|
|
import org.jeecg.modules.system.app.dto.TeachingDayDTO;
|
|
|
import org.jeecg.modules.system.app.entity.*;
|
|
|
import org.jeecg.modules.system.app.mapper.AppDeviceMapper;
|
|
|
-import org.jeecg.modules.system.app.mapper.AppIsinMapper;
|
|
|
-import org.jeecg.modules.system.app.mapper.AppOrderMapper;
|
|
|
-import org.jeecg.modules.system.app.mapper.AppOrderProInfoMapper;
|
|
|
+import org.jeecg.modules.system.app.mapper.AppGmtInfoMapper;
|
|
|
import org.jeecg.modules.system.app.service.IAppSitePlaceService;
|
|
|
import org.jeecg.modules.system.app.service.IAppSitePriceRulesService;
|
|
|
import org.jeecg.modules.system.app.service.IAppSiteService;
|
|
@@ -35,7 +33,6 @@ import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
import static com.alibaba.dashscope.utils.JsonUtils.gson;
|
|
|
import static org.jeecg.modules.hikiot.HikiotTool.deleteExpiredVisitors;
|
|
@@ -63,11 +60,7 @@ public class OrTeachingJobService {
|
|
|
private AppDeviceMapper appDeviceMapper;
|
|
|
|
|
|
@Resource
|
|
|
- private AppIsinMapper appIsinMapper;
|
|
|
- @Resource
|
|
|
- private AppOrderProInfoMapper appOrderProInfoMapper;
|
|
|
- @Resource
|
|
|
- private AppOrderMapper appOrderMapper;
|
|
|
+ private AppGmtInfoMapper appGmtInfoMapper;
|
|
|
|
|
|
@Scheduled(cron = "0 0 0 1 12 *")
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@@ -242,45 +235,26 @@ public class OrTeachingJobService {
|
|
|
* @Param
|
|
|
* @return
|
|
|
**/
|
|
|
-// @Scheduled(fixedDelay = 30000)
|
|
|
+ @Scheduled(fixedDelay = 300000)
|
|
|
public void synchronousDoorOpeningAndClosingRecords(){
|
|
|
try {
|
|
|
List<DoorRecordDTO> allRecords = fetchAllDoorRecords();
|
|
|
- List<ExtractedData> extractedData = extractRequiredData(allRecords);
|
|
|
-
|
|
|
- extractedData.forEach(data -> {
|
|
|
+ allRecords.forEach(data -> {
|
|
|
log.info("提取数据: {}", data);
|
|
|
- AppIsin appIsin = appIsinMapper.selectOne(Wrappers.<AppIsin>lambdaQuery().eq(AppIsin::getOrderProInfoId, data.getEmployeeNo()));
|
|
|
- if(null != appIsin){
|
|
|
- appIsin.setUseTime(DateUtils.str2Date(data.getGmtCreate(), new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")));
|
|
|
- appIsin.setUpdateTime(DateUtils.str2Date(data.getGmtCreate(), new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")));
|
|
|
- appIsin.setIsinStatus(1);
|
|
|
- appIsin.setUseImage(data.getPortraitUrl());
|
|
|
- appIsin.setOriginId(data.getOriginId());
|
|
|
- appIsinMapper.updateById(appIsin);
|
|
|
- AppOrderProInfo orderProInfo = appOrderProInfoMapper.selectById(appIsin.getOrderProInfoId());
|
|
|
- orderProInfo.setOrderStatus(2);
|
|
|
- appOrderProInfoMapper.updateById(orderProInfo);
|
|
|
- // 查询当前订单的所有 AppOrderProInfo 记录
|
|
|
- List<AppOrderProInfo> orderProInfoList = appOrderProInfoMapper.selectList(
|
|
|
- Wrappers.<AppOrderProInfo>lambdaQuery()
|
|
|
- .eq(AppOrderProInfo::getOrderCode, orderProInfo.getOrderCode())
|
|
|
- );
|
|
|
- // 判断所有子订单的 orderStatus 是否都为 2
|
|
|
- if (orderProInfoList != null && !orderProInfoList.isEmpty() &&
|
|
|
- orderProInfoList.stream().allMatch(opi -> opi.getOrderStatus() == 2)) {
|
|
|
- // 查询主订单
|
|
|
- AppOrder appOrder = appOrderMapper.selectOne(
|
|
|
- Wrappers.<AppOrder>lambdaQuery()
|
|
|
- .eq(AppOrder::getOrderCode, orderProInfo.getOrderCode())
|
|
|
- );
|
|
|
- if (appOrder != null) {
|
|
|
- // 更新主订单状态为 2
|
|
|
- appOrder.setOrderStatus(2);
|
|
|
- appOrderMapper.updateById(appOrder);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ appGmtInfoMapper.insert(new AppGmtInfo()
|
|
|
+ .setFamilyId(data.getEmployeeNo())
|
|
|
+ .setSiteId(appDeviceMapper.selectOne(Wrappers.<AppDevice>lambdaQuery()
|
|
|
+ .eq(AppDevice::getDeviceSerial, data.getDeviceSerial())).getSiteId())
|
|
|
+ .setAuthResultMsg(data.getAuthResultMsg())
|
|
|
+ .setGmtCreate(DateUtils.str2Date(data.getGmtCreate(), new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")))
|
|
|
+ .setPicUrl(data.getPicUrl())
|
|
|
+ .setSecMsgCode(data.getSecMsgCode())
|
|
|
+ .setOriginId(data.getOriginId())
|
|
|
+ .setDeviceSerial(data.getDeviceSerial().split("-")[0])
|
|
|
+ .setCreateTime(new Date())
|
|
|
+ .setUpdateTime(new Date())
|
|
|
+ .setDeviceSerialNo(data.getDeviceSerial()));
|
|
|
+
|
|
|
});
|
|
|
|
|
|
} catch (Exception e) {
|
|
@@ -295,16 +269,14 @@ public class OrTeachingJobService {
|
|
|
List<DoorRecordDTO> allRecords = new ArrayList<>();
|
|
|
int pageNum = 1;
|
|
|
int pageSize = 10000;
|
|
|
- AppIsin appIsin = appIsinMapper.selectOne(Wrappers.<AppIsin>lambdaQuery()
|
|
|
- .eq(AppIsin::getIsinStatus, 0)
|
|
|
- .eq(AppIsin::getOriginId, null)
|
|
|
- .orderByDesc(AppIsin::getUpdateTime)
|
|
|
+ AppGmtInfo appGmtInfo = appGmtInfoMapper.selectOne(Wrappers.<AppGmtInfo>lambdaQuery()
|
|
|
+ .orderByDesc(AppGmtInfo::getGmtCreate)
|
|
|
.last("limit 1"));
|
|
|
try {
|
|
|
while (true) {
|
|
|
JSONObject response;
|
|
|
- if(null != appIsin && null != appIsin.getUpdateTime()){
|
|
|
- response = gson.fromJson(queryOpenDoorRecord(pageNum, pageSize, appIsin.getUpdateTime()), JSONObject.class);
|
|
|
+ if(null != appGmtInfo && null != appGmtInfo.getGmtCreate()){
|
|
|
+ response = gson.fromJson(queryOpenDoorRecord(pageNum, pageSize, appGmtInfo.getGmtCreate()), JSONObject.class);
|
|
|
}else {
|
|
|
response = gson.fromJson(queryOpenDoorRecord(pageNum, pageSize,null), JSONObject.class);
|
|
|
}
|
|
@@ -337,29 +309,6 @@ public class OrTeachingJobService {
|
|
|
return allRecords;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 提取和过滤数据
|
|
|
- */
|
|
|
- private List<ExtractedData> extractRequiredData(List<DoorRecordDTO> records) {
|
|
|
- List<ExtractedData> result = new ArrayList<>();
|
|
|
- if (records != null && !records.isEmpty()) {
|
|
|
- result = records.stream()
|
|
|
- .filter(record -> "ACE-5-75".equals(record.getSecMsgCode()))
|
|
|
- .map(record -> new ExtractedData(
|
|
|
- record.getEmployeeNo(),
|
|
|
- record.getAuthResultMsg(),
|
|
|
- record.getGmtCreate(),
|
|
|
- record.getPortraitUrl(),
|
|
|
- record.getSecMsgCode(),
|
|
|
- record.getOriginId()
|
|
|
- ))
|
|
|
- .filter(data -> data.getEmployeeNo() != null) // 可选:排除无效数据
|
|
|
- .collect(Collectors.toList());
|
|
|
- }
|
|
|
-
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 验证响应是否有效
|
|
|
*/
|
|
@@ -377,22 +326,10 @@ public class OrTeachingJobService {
|
|
|
private String employeeNo;
|
|
|
private String authResultMsg;
|
|
|
private String gmtCreate;
|
|
|
- private String portraitUrl;
|
|
|
+ private String picUrl;
|
|
|
private String secMsgCode;
|
|
|
private String originId;
|
|
|
+ private String deviceSerial;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * DTO类 - 提取结果
|
|
|
- */
|
|
|
- @Data
|
|
|
- @AllArgsConstructor
|
|
|
- private static class ExtractedData {
|
|
|
- private String employeeNo;
|
|
|
- private String authResultMsg;
|
|
|
- private String gmtCreate;
|
|
|
- private String portraitUrl;
|
|
|
- private String secMsgCode;
|
|
|
- private String originId;
|
|
|
- }
|
|
|
}
|