完成部分定时任务
This commit is contained in:
@@ -18,11 +18,9 @@ import com.cool.store.mapper.TrainingExperienceMapper;
|
||||
import com.cool.store.mq.util.HttpRestTemplateService;
|
||||
import com.cool.store.request.xfsgFirstOrderListRequest;
|
||||
import com.cool.store.response.xfsgFirstOderListResponse;
|
||||
import com.cool.store.service.CoolStoreStartFlowService;
|
||||
import com.cool.store.service.DecorationService;
|
||||
import com.cool.store.service.PreparationService;
|
||||
import com.cool.store.service.XfsgEhrService;
|
||||
import com.cool.store.service.*;
|
||||
import com.cool.store.service.impl.CommonService;
|
||||
import com.cool.store.utils.CoolDateUtils;
|
||||
import com.cool.store.utils.poi.DateUtils;
|
||||
import com.cool.store.utils.poi.StringUtils;
|
||||
import com.cool.store.utils.poi.constant.Constants;
|
||||
@@ -34,6 +32,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.text.ParseException;
|
||||
@@ -42,6 +41,7 @@ import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@@ -83,6 +83,8 @@ public class XxlJobHandler {
|
||||
private TempUserDetailDAO tempUserDetailDAO;
|
||||
@Resource
|
||||
private EnterpriseUserDAO enterpriseUserDAO;
|
||||
@Resource
|
||||
private UserAuthMappingService userAuthMappingService;
|
||||
|
||||
/**
|
||||
* 每天都将待体验门店信息变更到体验中
|
||||
@@ -128,38 +130,43 @@ public class XxlJobHandler {
|
||||
*/
|
||||
@XxlJob("updateFirstOrder")
|
||||
public void updateFirstOrder() {
|
||||
log.info("----定时任务查询更新订货金----");
|
||||
boolean hasNext = true;
|
||||
int PageNum = 1;
|
||||
int PageSize = 50;
|
||||
|
||||
int pageNum = 1;
|
||||
int pageSize = 50;
|
||||
while (hasNext) {
|
||||
log.info("----查询更新订货金----");
|
||||
//sql 判定传入
|
||||
Page<Long> shopIdListByStageStatus = shopStageInfoDAO.getShopIdListByStageStatus(PageNum, PageSize);
|
||||
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
List<ShopStageInfoDO> shopIdListByStageStatus = shopStageInfoDAO.getShopIdListByStageStatus(ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_152.getShopSubStageStatus());
|
||||
if (CollectionUtils.isEmpty(shopIdListByStageStatus)) {
|
||||
log.info("------今日没有待更新数据------");
|
||||
log.info("------定时任务结束调用鲜丰更新订货金结束------");
|
||||
return;
|
||||
}
|
||||
List<OpenPlanShopInfoDTO> openPlanShopInfoDTOS = shopInfoDAO.queryStoreNumeListByid(shopIdListByStageStatus);
|
||||
Map<String, Long> map = openPlanShopInfoDTOS.stream().filter(OpenPlanShopInfoDTO -> OpenPlanShopInfoDTO.getStoreNum() != null).
|
||||
collect(Collectors.toMap(OpenPlanShopInfoDTO::getStoreNum, OpenPlanShopInfoDTO::getShopId));
|
||||
List<String> storeCodes = new ArrayList<>(map.keySet());
|
||||
xfsgFirstOrderListRequest request = new xfsgFirstOrderListRequest();
|
||||
request.setStoreCodeList(storeCodes);
|
||||
xfsgFirstOderListResponse firstOrderList = coolStoreStartFlowService.getFirstOrderList(request);
|
||||
if (Objects.nonNull(firstOrderList) && CollectionUtils.isNotEmpty(firstOrderList.getData())) {
|
||||
for (xfsgFirstOderDTO o : firstOrderList.getData()) {
|
||||
if (o.getBalance()) {
|
||||
shopStageInfoDAO.updateShopStageAndAuditInfo(map.get(o.getStoreCode()), ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_151, null);
|
||||
preparationService.whetherToOpenForAcceptance(map.get(o.getStoreCode()));
|
||||
List<Long> shopIds = shopIdListByStageStatus.stream().filter(o -> o.getShopId() != null).map(ShopStageInfoDO::getShopId).collect(Collectors.toList());
|
||||
try {
|
||||
List<OpenPlanShopInfoDTO> openPlanShopInfoDTOS = shopInfoDAO.queryStoreNumeListByid(shopIds);
|
||||
Map<String, Long> map = openPlanShopInfoDTOS.stream().filter(OpenPlanShopInfoDTO -> StringUtils.isNoneBlank(OpenPlanShopInfoDTO.getStoreNum())).
|
||||
collect(Collectors.toMap(OpenPlanShopInfoDTO::getStoreNum, OpenPlanShopInfoDTO::getShopId));
|
||||
List<String> storeCodes = new ArrayList<>(map.keySet());
|
||||
xfsgFirstOrderListRequest request = new xfsgFirstOrderListRequest();
|
||||
request.setStoreCodeList(storeCodes);
|
||||
xfsgFirstOderListResponse firstOrderList = coolStoreStartFlowService.getFirstOrderList(request);
|
||||
if (Objects.nonNull(firstOrderList) && CollectionUtils.isNotEmpty(firstOrderList.getData())) {
|
||||
for (xfsgFirstOderDTO o : firstOrderList.getData()) {
|
||||
if (o.getBalance()) {
|
||||
shopStageInfoDAO.updateShopStageAndAuditInfo(map.get(o.getStoreCode()), ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_151, null);
|
||||
preparationService.whetherToOpenForAcceptance(map.get(o.getStoreCode()));
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("定时任务更新订货金失败 shopIds:{}", shopIds);
|
||||
}
|
||||
hasNext = shopIdListByStageStatus.size() >= PageSize;
|
||||
PageNum++;
|
||||
|
||||
hasNext = shopIdListByStageStatus.size() >= pageSize;
|
||||
pageNum++;
|
||||
}
|
||||
|
||||
log.info("------定时任务结束调用鲜丰更新订货金结束------");
|
||||
XxlJobHelper.handleSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -168,67 +175,107 @@ public class XxlJobHandler {
|
||||
* @description: 每天更新装修阶段进场时间等,至预约状态
|
||||
*/
|
||||
@XxlJob("fitmentAcceptanceHandler")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void fitmentAcceptanceHandler() {
|
||||
log.info("----定时任务每天更新装修阶段进场时间,施工完成时间等,至预约状态----");
|
||||
boolean hasNext = true;
|
||||
int PageNum = 1;
|
||||
int PageSize = 50;
|
||||
|
||||
int pageNum = 1;
|
||||
int pageSize = 50;
|
||||
while (hasNext) {
|
||||
log.info("----每天更新装修阶段进场时间,施工完成时间等,至预约状态----");
|
||||
PageHelper.startPage(PageNum, PageSize);
|
||||
//获取施工阶段未完成shopID
|
||||
List<Long> shops = shopStageInfoDAO.getShopContractIncompletion();
|
||||
if (CollectionUtils.isEmpty(shops)) {
|
||||
log.info("------今日没有待更新数据------");
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
//获取表中进场时间为空的店铺
|
||||
List<AcceptanceInfoDO> acceptanceList = acceptanceInfoDAO.selectByEntryTimeNull();
|
||||
if (CollectionUtils.isEmpty(acceptanceList)) {
|
||||
log.info("------定时任务结束调用鲜丰获取进场时间结束------");
|
||||
return;
|
||||
}
|
||||
List<AcceptanceInfoDO> acceptanceInfoDOS = new ArrayList<>();
|
||||
acceptanceInfoDOS.addAll(acceptanceInfoDAO.selectByShopIds(shops));
|
||||
for (AcceptanceInfoDO acceptanceInfoDO : acceptanceInfoDOS) {
|
||||
Long shopId = acceptanceInfoDO.getShopId();
|
||||
acceptanceInfoDO.setUpdateTime(new Date());
|
||||
ConstructionScheduleDTO constructionInfo = decorationService.getConstructionInfo(shopId);
|
||||
List<ConstructionScheduleDTO> construction = decorationService.getConstruction(shopId);
|
||||
//施工完成时间,装修计划开始和完成时间
|
||||
if (Objects.nonNull(constructionInfo) && !StringUtils.isNull(constructionInfo.getPlanEndDate())
|
||||
&& Objects.isNull(acceptanceInfoDO.getConstructionCompletionTime())) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
int flag = CommonConstants.ZERO;
|
||||
for (AcceptanceInfoDO acceptanceInfoDO : acceptanceList) {
|
||||
while (flag < CommonConstants.TWO) {
|
||||
try {
|
||||
Date constructionEndTime = sdf.parse(constructionInfo.getActualEndDate());
|
||||
acceptanceInfoDO.setConstructionCompletionTime(constructionEndTime);
|
||||
Date PlanBegin = sdf.parse(constructionInfo.getPlanBeginDate());
|
||||
Date PlanEnd = sdf.parse(constructionInfo.getPlanEndDate());
|
||||
acceptanceInfoDO.setDecorationPlannedStartTime(PlanBegin);
|
||||
acceptanceInfoDO.setDecorationPlannedCompletionTime(PlanEnd);
|
||||
acceptanceInfoDAO.updateAcceptanceInfo(acceptanceInfoDO);
|
||||
} catch (ParseException e) {
|
||||
log.error("初始化acceptanceInfo,鲜丰服务施工完成时间日期转化异常");
|
||||
Long shopId = acceptanceInfoDO.getShopId();
|
||||
//施工子阶段
|
||||
List<ConstructionScheduleDTO> construction = decorationService.getConstruction(shopId);
|
||||
Map<String, ConstructionScheduleDTO> constructionMap = construction.stream().
|
||||
collect(Collectors.toMap(ConstructionScheduleDTO::getName, dto -> dto));
|
||||
//进场时间
|
||||
ConstructionScheduleDTO approach = constructionMap.get(CommonConstants.APPROACH);
|
||||
if (Objects.nonNull(approach)) {
|
||||
Date date = CoolDateUtils.parseDate(approach.getActualBeginDate(), CoolDateUtils.DATE_FORMAT_DAY);
|
||||
if (Objects.nonNull(date)) {
|
||||
Instant instant = date.toInstant();
|
||||
ZoneId zone = ZoneId.systemDefault();
|
||||
LocalDate localDate = instant.atZone(zone).toLocalDate();
|
||||
LocalDate datePlusFiveDays = localDate.plusDays(CommonConstants.FOUR); // 5天
|
||||
LocalDate now = LocalDate.now();
|
||||
if (datePlusFiveDays.equals(now)) {
|
||||
//三方验收带预约
|
||||
shopStageInfoDAO.updateShopStageInfo(shopId, ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_120);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
} catch (Exception e) {
|
||||
log.error("定时任务设置进场时间失败,shopId:{}", acceptanceInfoDO.getShopId());
|
||||
flag++;
|
||||
}
|
||||
}
|
||||
flag = CommonConstants.ZERO;
|
||||
}
|
||||
hasNext = acceptanceList.size() >= pageSize;
|
||||
pageNum++;
|
||||
}
|
||||
log.info("------定时任务结束调用鲜丰获取进场时间结束------");
|
||||
XxlJobHelper.handleSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* @Auther: wangshuo
|
||||
* @Date: 2024/5/10
|
||||
* @description:实际进场时间+5天,发送钉钉通知到工程监理
|
||||
*/
|
||||
@XxlJob("threeAcceptanceBookingMessage")
|
||||
public void threeAcceptanceBookingMessage() {
|
||||
log.info("------定时任务三方验收待预约钉钉通知-----");
|
||||
boolean hasNext = true;
|
||||
int pageNum = 1;
|
||||
int pageSize = 50;
|
||||
while (hasNext) {
|
||||
//TODO
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
//获取为带预约状态的
|
||||
List<ShopStageInfoDO> shopIdListByStageStatus = shopStageInfoDAO.
|
||||
getShopIdListByStageStatus(ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_120.getShopSubStageStatus());
|
||||
if (CollectionUtils.isEmpty(shopIdListByStageStatus)) {
|
||||
log.info("------定时任务结束三方验收待预约钉钉通知------");
|
||||
return;
|
||||
}
|
||||
List<Long> shopIds = shopIdListByStageStatus.stream().filter(o -> o.getShopId() != null).map(o -> o.getShopId()).collect(Collectors.toList());
|
||||
List<AcceptanceInfoDO> acceptanceInfoDOS = acceptanceInfoDAO.selectByShopIds(shopIds);
|
||||
for (AcceptanceInfoDO acceptanceInfoDO : acceptanceInfoDOS) {
|
||||
//进场时间
|
||||
if (Objects.nonNull(construction) && !StringUtils.isNull(construction.get(CommonConstants.ZERO).getActualBeginDate())
|
||||
&& Objects.isNull(acceptanceInfoDO.getActualEntryTime())) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
try {
|
||||
Date constructionBeginTime = sdf.parse(construction.get(CommonConstants.ZERO).getActualBeginDate());
|
||||
acceptanceInfoDO.setActualEntryTime(constructionBeginTime);
|
||||
acceptanceInfoDAO.updateAcceptanceInfo(acceptanceInfoDO);
|
||||
//+5tian
|
||||
Instant instant = acceptanceInfoDO.getActualEntryTime().toInstant();
|
||||
ZoneId zone = ZoneId.systemDefault();
|
||||
LocalDate localDate = instant.atZone(zone).toLocalDate();
|
||||
LocalDate datePlusFiveDays = localDate.plusDays(CommonConstants.FOUR); // 添加5天
|
||||
LocalDate now = LocalDate.now();
|
||||
if (datePlusFiveDays.equals(now)) {
|
||||
shopStageInfoDAO.updateShopStageInfo(shopId, ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_120);
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
log.error("初始化acceptanceInfo,鲜丰服务进场时间日期转化异常");
|
||||
Date approach = acceptanceInfoDO.getActualEntryTime();
|
||||
if (Objects.nonNull(approach)) {
|
||||
Instant instant = approach.toInstant();
|
||||
ZoneId zone = ZoneId.systemDefault();
|
||||
LocalDate localDate = instant.atZone(zone).toLocalDate();
|
||||
LocalDate datePlusFiveDays = localDate.plusDays(CommonConstants.FOUR); // 5天
|
||||
if (datePlusFiveDays.equals(localDate)) {
|
||||
//三方验收带预约
|
||||
ShopInfoDO shopInfo = shopInfoDAO.getShopInfo(acceptanceInfoDO.getShopId());
|
||||
EnterpriseUserDO userByRoleEnumAndRegionId = userAuthMappingService
|
||||
.getUserByRoleEnumAndRegionId(UserRoleEnum.ENGINEER_DEP_SUPERVISOR, shopInfo.getRegionId());
|
||||
LineInfoDO lineInfo = lineInfoDAO.getLineInfo(shopInfo.getLineId());
|
||||
Map<String, String> messageMap = new HashMap<>();
|
||||
messageMap.put("storeName", shopInfo.getShopName());
|
||||
messageMap.put("partnerUsername", lineInfo.getUsername());
|
||||
messageMap.put("partnerMobile", lineInfo.getMobile());
|
||||
commonService.sendMessage(Arrays.asList(userByRoleEnumAndRegionId.getUserId()), MessageEnum.MESSAGE_24, messageMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
hasNext = acceptanceInfoDOS.size() >= PageSize;
|
||||
PageNum++;
|
||||
hasNext = shopIdListByStageStatus.size() >= pageSize;
|
||||
pageNum++;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -236,20 +283,100 @@ public class XxlJobHandler {
|
||||
/**
|
||||
* @Auther: wangshuo
|
||||
* @Date: 2024/5/7
|
||||
* @description:三方验收预约短信通知
|
||||
* @description:三方验收预约短信通知+7day
|
||||
*/
|
||||
@XxlJob("ThreeAcceptanceMessage")
|
||||
public void ThreeAcceptanceMessage() {
|
||||
log.info("------三方验收预约短信通知-----");
|
||||
@XxlJob("threeAcceptanceMessage")
|
||||
public void threeAcceptanceMessage() {
|
||||
log.info("------定时任务三方验收预约短信通知-----");
|
||||
boolean hasNext = true;
|
||||
int PageNum = 1;
|
||||
int PageSize = 50;
|
||||
int pageNum = 1;
|
||||
int pageSize = 50;
|
||||
while (hasNext) {
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
//获取待验收的
|
||||
List<ShopStageInfoDO> ShopStageInfoList = shopStageInfoDAO.
|
||||
getShopIdListByStageStatus(ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_121.getShopSubStageStatus());
|
||||
if (CollectionUtils.isEmpty(ShopStageInfoList)) {
|
||||
log.info("------定时任务结束三方验收预约短信通知------");
|
||||
return;
|
||||
}
|
||||
List<Long> shopIds = ShopStageInfoList.stream().filter(o -> o.getShopId() != null)
|
||||
.map(ShopStageInfoDO::getShopId).collect(Collectors.toList());
|
||||
Map<Long, ShopStageInfoDO> lineIdMap = ShopStageInfoList.stream().filter(o -> o.getLineId() != null)
|
||||
.collect(Collectors.toMap(ShopStageInfoDO::getLineId, Function.identity()));
|
||||
List<AcceptanceInfoDO> acceptanceList = acceptanceInfoDAO.selectByShopIds(shopIds);
|
||||
|
||||
// hasNext = ;
|
||||
PageNum++;
|
||||
for (AcceptanceInfoDO acceptance : acceptanceList) {
|
||||
Date approach = acceptance.getActualEntryTime();
|
||||
if (Objects.nonNull(approach)) {
|
||||
Instant instant = approach.toInstant();
|
||||
ZoneId zone = ZoneId.systemDefault();
|
||||
LocalDate localDate = instant.atZone(zone).toLocalDate();
|
||||
LocalDate datePlusFiveDays = localDate.plusDays(CommonConstants.SIX); // 7天
|
||||
if (datePlusFiveDays.equals(localDate)) {
|
||||
ShopStageInfoDO stageInfoDO = lineIdMap.get(acceptance.getShopId());
|
||||
if (Objects.nonNull(stageInfoDO)) {
|
||||
Long lineId = stageInfoDO.getLineId();
|
||||
LineInfoDO lineInfo = lineInfoDAO.getLineInfo(lineId);
|
||||
|
||||
Map<String, String> templateParam = new HashMap<>();
|
||||
commonService.sendSms(lineInfo.getMobile(), SMSMsgEnum.THREE_ACCEPTANCE_WAIT, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
hasNext = ShopStageInfoList.size() >= pageSize;
|
||||
pageNum++;
|
||||
}
|
||||
XxlJobHelper.handleSuccess();
|
||||
}
|
||||
/**
|
||||
* @Auther: wangshuo
|
||||
* @Date: 2024/5/7
|
||||
* @description:实际进场时间+7天,发送钉钉通知到督导
|
||||
*/
|
||||
@XxlJob("waitThreeAcceptanceMessage")
|
||||
public void waitThreeAcceptanceMessage() {
|
||||
log.info("------定时任务三方待验收通知-----");
|
||||
boolean hasNext = true;
|
||||
int pageNum = 1;
|
||||
int pageSize = 50;
|
||||
while (hasNext) {
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
//获取待验收的
|
||||
List<ShopStageInfoDO> ShopStageInfoList = shopStageInfoDAO.
|
||||
getShopIdListByStageStatus(ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_121.getShopSubStageStatus());
|
||||
if (CollectionUtils.isEmpty(ShopStageInfoList)) {
|
||||
log.info("------定时任务结束三方验收预约短信通知------");
|
||||
return;
|
||||
}
|
||||
List<Long> shopIds = ShopStageInfoList.stream().filter(o -> o.getShopId() != null)
|
||||
.map(ShopStageInfoDO::getShopId).collect(Collectors.toList());
|
||||
Map<Long, ShopStageInfoDO> lineIdMap = ShopStageInfoList.stream().filter(o -> o.getLineId() != null)
|
||||
.collect(Collectors.toMap(ShopStageInfoDO::getLineId, Function.identity()));
|
||||
List<AcceptanceInfoDO> acceptanceList = acceptanceInfoDAO.selectByShopIds(shopIds);
|
||||
|
||||
for (AcceptanceInfoDO acceptance : acceptanceList) {
|
||||
Date approach = acceptance.getActualEntryTime();
|
||||
if (Objects.nonNull(approach)) {
|
||||
Instant instant = approach.toInstant();
|
||||
ZoneId zone = ZoneId.systemDefault();
|
||||
LocalDate localDate = instant.atZone(zone).toLocalDate();
|
||||
LocalDate datePlusFiveDays = localDate.plusDays(CommonConstants.SIX); // 7天
|
||||
if (datePlusFiveDays.equals(localDate)) {
|
||||
ShopStageInfoDO stageInfoDO = lineIdMap.get(acceptance.getShopId());
|
||||
if (Objects.nonNull(stageInfoDO)) {
|
||||
Long lineId = stageInfoDO.getLineId();
|
||||
LineInfoDO lineInfo = lineInfoDAO.getLineInfo(lineId);
|
||||
commonService.sendSms(lineInfo.getMobile(), SMSMsgEnum.THREE_ACCEPTANCE_WAIT, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
hasNext = ShopStageInfoList.size() >= pageSize;
|
||||
pageNum++;
|
||||
}
|
||||
XxlJobHelper.handleSuccess();
|
||||
}
|
||||
|
||||
@XxlJob("interviewRemind")
|
||||
|
||||
Reference in New Issue
Block a user