feat:证照同步

This commit is contained in:
苏竹红
2024-12-20 16:22:10 +08:00
parent c561029776
commit 67c6a72163
14 changed files with 277 additions and 2 deletions

View File

@@ -0,0 +1,29 @@
package com.cool.store.enums;
/**
* @Author suzhuhong
* @Date 2024/12/20 14:13
* @Version 1.0
*/
public enum ExpiryTypeEnum {
LONG("long","长期"),
TEMP("temp","临时"),;
private String expiryType;
private String desc;
private ExpiryTypeEnum(String expiryType, String desc) {
this.expiryType = expiryType;
this.desc = desc;
}
public String getExpiryType() {
return expiryType;
}
public String getDesc() {
return desc;
}
}

View File

@@ -15,6 +15,7 @@ public enum RocketMqTagEnum {
USER_EVENT("user_event","钉钉通讯录变更事件"), USER_EVENT("user_event","钉钉通讯录变更事件"),
DEPT_EVENT("dept_event","部门事件"), DEPT_EVENT("dept_event","部门事件"),
STORE_DING_QUEUE("store_ding_queue", "微应用钉钉消息发送"), STORE_DING_QUEUE("store_ding_queue", "微应用钉钉消息发送"),
PARTNER_LICENSE_SYNC_QUEUE("partner_license_sync_queue", "招商证照信息同步");
; ;

View File

@@ -1,6 +1,7 @@
package com.cool.store.dao; package com.cool.store.dao;
import com.cool.store.constants.CommonConstants; import com.cool.store.constants.CommonConstants;
import com.cool.store.dto.LicenseSyncDTO;
import com.cool.store.dto.Preparation.PreparationDTO; import com.cool.store.dto.Preparation.PreparationDTO;
import com.cool.store.dto.openPreparation.OpenPlanShopInfoDTO; import com.cool.store.dto.openPreparation.OpenPlanShopInfoDTO;
import com.cool.store.dto.point.LineCountDTO; import com.cool.store.dto.point.LineCountDTO;
@@ -172,4 +173,13 @@ public class ShopInfoDAO {
} }
return shopInfoMapper.platformBuildList(regionIds, request); return shopInfoMapper.platformBuildList(regionIds, request);
} }
public List<LicenseSyncDTO> getShopAndStoreList(String eid , List<Long> shopIds){
if(CollectionUtils.isEmpty(shopIds)){
return new ArrayList<>();
}
return shopInfoMapper.getShopAndStoreList(eid,shopIds);
}
} }

View File

@@ -18,4 +18,13 @@ public interface ApplyLicenseMapper extends Mapper<LicenseTransactDO> {
void updateByShopId(@Param("entity") LicenseTransactDO licenseTransactDO); void updateByShopId(@Param("entity") LicenseTransactDO licenseTransactDO);
LicenseTransactDO selectByShopId(@Param("shopId") Long shopId); LicenseTransactDO selectByShopId(@Param("shopId") Long shopId);
/**
* queryNotSyncList
* @return
*/
List<LicenseTransactDO> queryNotSyncList();
Boolean updateSyncFlagByIds(@Param("ids") List<Long> ids);
} }

View File

@@ -1,5 +1,6 @@
package com.cool.store.mapper; package com.cool.store.mapper;
import com.cool.store.dto.LicenseSyncDTO;
import com.cool.store.dto.Preparation.PreparationDTO; import com.cool.store.dto.Preparation.PreparationDTO;
import com.cool.store.dto.openPreparation.OpenPlanShopInfoDTO; import com.cool.store.dto.openPreparation.OpenPlanShopInfoDTO;
import com.cool.store.dto.point.LineCountDTO; import com.cool.store.dto.point.LineCountDTO;
@@ -94,4 +95,7 @@ public interface ShopInfoMapper extends Mapper<ShopInfoDO> {
List<ShopInfoDO> selectByIdOrSelectAll(@Param("shopId") Long shopId); List<ShopInfoDO> selectByIdOrSelectAll(@Param("shopId") Long shopId);
List<PlatformBuildListResponse> platformBuildList(@Param("list") List<Long> regionIds,@Param("request") platformBuildListRequest request); List<PlatformBuildListResponse> platformBuildList(@Param("list") List<Long> regionIds,@Param("request") platformBuildListRequest request);
List<LicenseSyncDTO> getShopAndStoreList(@Param("enterpriseId") String eid , @Param("shopIds") List<Long> shopIds);
} }

View File

@@ -95,4 +95,23 @@
where shop_id = #{shopId} where shop_id = #{shopId}
and deleted = 0 and deleted = 0
</select> </select>
<select id="queryNotSyncList" resultType="com.cool.store.entity.LicenseTransactDO">
select <include refid="baseColumn"/>
from xfsg_license_transact
where sync_flag = 0
and deleted = 0
</select>
<update id="updateSyncFlagByIds">
update xfsg_license_transact
set sync_flag = 1
where deleted = 0
<if test="ids != null and ids.size > 0">
<foreach item="item" collection="ids" open="and id in (" separator="," close=")">
#{item}
</foreach>
</if>
</update>
</mapper> </mapper>

View File

@@ -225,5 +225,19 @@
</where> </where>
</select> </select>
<select id="getShopAndStoreList" resultType="com.cool.store.dto.LicenseSyncDTO">
select
a.id as shopId,
a.shop_code as shopCode,
b.store_id as storeId
from
xfsg_shop_info a
left join store_${enterpriseId} b on a.shop_code = b.store_num
where b.store_id is not null and a.id in
<foreach collection="shopIds" item="shopId" separator="," open="(" close=")">
#{shopId}
</foreach>
</select>
</mapper> </mapper>

View File

@@ -0,0 +1,21 @@
package com.cool.store.dto;
import lombok.Data;
import java.util.List;
/**
* @Author suzhuhong
* @Date 2024/12/20 15:16
* @Version 1.0
*/
@Data
public class LicenseDTO {
private String enterpriseId;
List<LicenseSyncInfoDTO> requests;
}

View File

@@ -0,0 +1,20 @@
package com.cool.store.dto;
import lombok.Data;
/**
* @Author suzhuhong
* @Date 2024/12/20 10:52
* @Version 1.0
*/
@Data
public class LicenseSyncDTO {
private Long shopId;
private String shopCode;
private String storeId;
}

View File

@@ -0,0 +1,25 @@
package com.cool.store.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @Author suzhuhong
* @Date 2024/12/20 10:52
* @Version 1.0
*/
@Data
public class LicenseSyncInfoDTO {
private String storeId;
private Integer licenseType;
private String picture;
private String expiryType;
private Long expiryBeginDate;
private Long expiryEndDate;
}

View File

@@ -73,5 +73,7 @@ public class LicenseTransactDO {
private Integer deleted; private Integer deleted;
@Column(name = "two_certificates_one") @Column(name = "two_certificates_one")
private Integer twoCertificatesOne; private Integer twoCertificatesOne;
@Column(name = "sync_flag")
private Integer syncFlag;
} }

View File

@@ -116,6 +116,9 @@ public class ApplyLicenseServiceImpl implements ApplyLicenseService {
if (licenseTransactDO.getId() == null) { if (licenseTransactDO.getId() == null) {
applyLicenseMapper.insertSelective(licenseTransactDO); applyLicenseMapper.insertSelective(licenseTransactDO);
} else { } else {
//如果更新了数据 同步标识置为0
licenseTransactDO.setUpdateTime(new Date());
licenseTransactDO.setSyncFlag(CommonConstants.ZERO);
applyLicenseMapper.updateByPrimaryKey(licenseTransactDO); applyLicenseMapper.updateByPrimaryKey(licenseTransactDO);
} }
ShopStageInfoDO shopSubStageInfo = shopStageInfoDAO.getShopSubStageInfo(request.getShopId(), ShopSubStageEnum.SHOP_STAGE_3); ShopStageInfoDO shopSubStageInfo = shopStageInfoDAO.getShopSubStageInfo(request.getShopId(), ShopSubStageEnum.SHOP_STAGE_3);
@@ -145,6 +148,9 @@ public class ApplyLicenseServiceImpl implements ApplyLicenseService {
if (licenseTransactDO.getId() == null) { if (licenseTransactDO.getId() == null) {
applyLicenseMapper.insertSelective(licenseTransactDO); applyLicenseMapper.insertSelective(licenseTransactDO);
} else { } else {
//如果更新了数据 同步标识置为0
licenseTransactDO.setUpdateTime(new Date());
licenseTransactDO.setSyncFlag(CommonConstants.ZERO);
applyLicenseMapper.updateByPrimaryKey(licenseTransactDO); applyLicenseMapper.updateByPrimaryKey(licenseTransactDO);
} }
ShopStageInfoDO shopSubStageInfo = shopStageInfoDAO.getShopSubStageInfo(request.getShopId(), ShopSubStageEnum.SHOP_STAGE_4); ShopStageInfoDO shopSubStageInfo = shopStageInfoDAO.getShopSubStageInfo(request.getShopId(), ShopSubStageEnum.SHOP_STAGE_4);

View File

@@ -5,6 +5,7 @@ import com.cool.store.dao.*;
import com.cool.store.entity.*; import com.cool.store.entity.*;
import com.cool.store.enums.MessageEnum; import com.cool.store.enums.MessageEnum;
import com.cool.store.enums.SMSMsgEnum; import com.cool.store.enums.SMSMsgEnum;
import com.cool.store.job.XxlJobHandler;
import com.cool.store.mq.util.HttpRestTemplateService; import com.cool.store.mq.util.HttpRestTemplateService;
import com.cool.store.request.xfsgFirstOrderListRequest; import com.cool.store.request.xfsgFirstOrderListRequest;
import com.cool.store.response.ResponseResult; import com.cool.store.response.ResponseResult;
@@ -34,6 +35,8 @@ public class PCTestController {
@Resource @Resource
private LineInterviewDAO lineInterviewDAO; private LineInterviewDAO lineInterviewDAO;
@Resource @Resource
private XxlJobHandler xxlJobHandler;
@Resource
DataHandleService dataHandleService; DataHandleService dataHandleService;
static String url = "https://hzly.cloudcubic.net/ajaxHandle/synchronization/JCallBackSynchronizationHandler.ashx?action=app&controller=GetProjectDetails&projectid="; static String url = "https://hzly.cloudcubic.net/ajaxHandle/synchronization/JCallBackSynchronizationHandler.ashx?action=app&controller=GetProjectDetails&projectid=";
@@ -92,4 +95,10 @@ public class PCTestController {
return ResponseResult.success(dataHandleService.dataHandleService(shopId)); return ResponseResult.success(dataHandleService.dataHandleService(shopId));
} }
@GetMapping("/licenseSync")
public ResponseResult<Boolean> licenseSync(){
xxlJobHandler.partnerSyncLicense();
return ResponseResult.success(Boolean.TRUE);
}
} }

View File

@@ -4,17 +4,18 @@ import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.cool.store.constants.CommonConstants; import com.cool.store.constants.CommonConstants;
import com.cool.store.dao.*; import com.cool.store.dao.*;
import com.cool.store.dto.StaffExamInfoDTO; import com.cool.store.dto.*;
import com.cool.store.dto.decoration.ConstructionScheduleDTO; import com.cool.store.dto.decoration.ConstructionScheduleDTO;
import com.cool.store.dto.openPreparation.OpenPlanShopInfoDTO; import com.cool.store.dto.openPreparation.OpenPlanShopInfoDTO;
import com.cool.store.dto.xfsgFirstOderDTO;
import com.cool.store.entity.*; import com.cool.store.entity.*;
import com.cool.store.enums.*; import com.cool.store.enums.*;
import com.cool.store.enums.point.ShopSubStageEnum; import com.cool.store.enums.point.ShopSubStageEnum;
import com.cool.store.enums.point.ShopSubStageStatusEnum; import com.cool.store.enums.point.ShopSubStageStatusEnum;
import com.cool.store.exception.ServiceException; import com.cool.store.exception.ServiceException;
import com.cool.store.mapper.ApplyLicenseMapper;
import com.cool.store.mapper.LineInfoMapper; import com.cool.store.mapper.LineInfoMapper;
import com.cool.store.mapper.TrainingExperienceMapper; import com.cool.store.mapper.TrainingExperienceMapper;
import com.cool.store.mq.producer.SimpleMessageService;
import com.cool.store.mq.util.HttpRestTemplateService; import com.cool.store.mq.util.HttpRestTemplateService;
import com.cool.store.request.xfsgFirstOrderListRequest; import com.cool.store.request.xfsgFirstOrderListRequest;
import com.cool.store.response.xfsgFirstOderListResponse; import com.cool.store.response.xfsgFirstOderListResponse;
@@ -53,6 +54,8 @@ import java.util.stream.Collectors;
public class XxlJobHandler { public class XxlJobHandler {
@Value("${mybatis.configuration.variables.enterpriseId}")
private String eid;
@Resource @Resource
TrainingExperienceMapper trainingExperienceMapper; TrainingExperienceMapper trainingExperienceMapper;
@Value("${xfsg.url}") @Value("${xfsg.url}")
@@ -91,6 +94,10 @@ public class XxlJobHandler {
private UserAuthMappingService userAuthMappingService; private UserAuthMappingService userAuthMappingService;
@Resource @Resource
private OpenAcceptanceInfoDAO openAcceptanceInfoDAO; private OpenAcceptanceInfoDAO openAcceptanceInfoDAO;
@Resource
private SimpleMessageService simpleMessageService;
@Resource
ApplyLicenseMapper applyLicenseMapper;
@@ -199,4 +206,103 @@ public class XxlJobHandler {
XxlJobHelper.handleSuccess(); XxlJobHelper.handleSuccess();
} }
@XxlJob("partnerSyncLicense")
public void partnerSyncLicense() {
log.info("------start sync license------");
boolean hasNext = true;
int pageNum = 1;
int pageSize = 9;
List<Long> updateSyncList = new ArrayList<>();
while (hasNext) {
PageHelper.startPage(pageNum, pageSize);
List<LicenseTransactDO> licenseTransactDOS = applyLicenseMapper.queryNotSyncList();
if (CollectionUtils.isEmpty(licenseTransactDOS)) {
log.info("------sync license is empty------");
break;
}
List<Long> shopIds = licenseTransactDOS.stream().map(LicenseTransactDO::getShopId).collect(Collectors.toList());
List<LicenseSyncDTO> infoDOS = shopInfoDAO.getShopAndStoreList(eid, shopIds);
if (CollectionUtils.isEmpty(infoDOS)) {
log.info("------sync store is empty------");
}
Map<Long, LicenseTransactDO> transactDOMap = licenseTransactDOS.stream().collect(Collectors.toMap(LicenseTransactDO::getShopId, x -> x));
List<LicenseSyncInfoDTO> pushList = new ArrayList<>();
infoDOS.forEach(x -> {
LicenseTransactDO licenseTransactDO = transactDOMap.get(x.getShopId());
Integer currentStoreSyncCount = 0;
if (licenseTransactDO != null) {
// 同步营业执照
if (StringUtils.isNotEmpty(licenseTransactDO.getCreditUrl())) {
pushList.add(createLicenseSyncInfoDTO(x.getStoreId(), CommonConstants.ONE,
licenseTransactDO.getCreditUrl(), licenseTransactDO.getIssueTime(), licenseTransactDO.getValidity()));
currentStoreSyncCount++;
}
// 同步食品经营许可证
if (StringUtils.isNotEmpty(licenseTransactDO.getFoodBusinessLicenseUrl())) {
pushList.add(createLicenseSyncInfoDTO(x.getStoreId(), CommonConstants.THREE,
licenseTransactDO.getFoodBusinessLicenseUrl(), licenseTransactDO.getFoodBusinessStartTime(), licenseTransactDO.getFoodBusinessEndTime()));
currentStoreSyncCount++;
}
// 如果食品证为空且为二证合一,使用营业执照的图片
if (StringUtils.isEmpty(licenseTransactDO.getFoodBusinessLicenseUrl()) &&
Integer.valueOf(CommonConstants.ONE).equals(licenseTransactDO.getTwoCertificatesOne())) {
pushList.add(createLicenseSyncInfoDTO(x.getStoreId(), CommonConstants.THREE,
licenseTransactDO.getCreditUrl(), licenseTransactDO.getIssueTime(), licenseTransactDO.getValidity()));
currentStoreSyncCount++;
}
// 发送消息
if (!pushList.isEmpty()) {
LicenseDTO licenseDTO = new LicenseDTO();
licenseDTO.setEnterpriseId(eid);
licenseDTO.setRequests(pushList);
log.info("licenseDTO:{}",JSONObject.toJSONString(licenseDTO));
//simpleMessageService.send(JSONObject.toJSONString(licenseDTO), RocketMqTagEnum.PARTNER_LICENSE_SYNC_QUEUE);
}
if (currentStoreSyncCount == CommonConstants.TWO) {
updateSyncList.add(licenseTransactDO.getId());
}
}
});
hasNext = licenseTransactDOS.size() >= pageSize;
pageNum++;
}
log.info("licenseDTO:{}",JSONObject.toJSONString(updateSyncList));
if (CollectionUtils.isNotEmpty(updateSyncList)) {
applyLicenseMapper.updateSyncFlagByIds(updateSyncList);
}
log.info("------sync complete-------");
XxlJobHelper.handleSuccess();
}
private LicenseSyncInfoDTO createLicenseSyncInfoDTO(String storeId, Integer licenseType, String pictureUrl,
Date startTime, Date endTime) {
LicenseSyncInfoDTO licenseSyncInfoDTO = new LicenseSyncInfoDTO();
licenseSyncInfoDTO.setStoreId(storeId);
licenseSyncInfoDTO.setLicenseType(licenseType);
licenseSyncInfoDTO.setPicture(pictureUrl);
licenseSyncInfoDTO.setExpiryType(ExpiryTypeEnum.TEMP.getExpiryType());
licenseSyncInfoDTO.setExpiryBeginDate(startTime.getTime());
if (endTime != null) {
licenseSyncInfoDTO.setExpiryEndDate(endTime.getTime());
} else {
// 如果没有有效期,则设置为长期有效
licenseSyncInfoDTO.setExpiryType(ExpiryTypeEnum.LONG.getExpiryType());
}
return licenseSyncInfoDTO;
}
} }