11 changed files with 309 additions and 14 deletions
@ -0,0 +1,31 @@ |
|||
package com.epmet.commons.tools.constant; |
|||
|
|||
|
|||
/** |
|||
* 需要特殊处理的客户id |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since 1.0.0 |
|||
*/ |
|||
public interface SpecialCustomerOrgConstant { |
|||
/** |
|||
* 榆山街道组织id |
|||
*/ |
|||
String YUSHAN_AGENCY_ID_PROD="1258587398679126017"; |
|||
|
|||
/** |
|||
* 南宁社区-开发测试用的 |
|||
*/ |
|||
String test="6e511da6816e53af4cda952365a26eb9"; |
|||
|
|||
// /**
|
|||
// * 榆山生产客户id
|
|||
// */
|
|||
// String YUSHAN_PROD_CUSTOMER_ID = "46c55cb862d6d5e6d05d2ab61a1cc07e";
|
|||
//
|
|||
// /**
|
|||
// * 榆山测试客户id
|
|||
// */
|
|||
// String YUSHAN_TEST_CUSTOMER_ID = "a4bbf298d8e427844038cee466f022ef";
|
|||
|
|||
} |
@ -0,0 +1,29 @@ |
|||
package com.epmet.commons.tools.dto.form; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
@Data |
|||
public class UpdateUserPointsFormDTO implements Serializable { |
|||
|
|||
/** |
|||
* 行为类型: |
|||
* 双十信息更新-double_info_update |
|||
* 网格巡查-grid_patrol |
|||
* 网格上报事件-grid_report_event |
|||
* 网格工作上传-grid_work_upload |
|||
*/ |
|||
private String behaviorType; |
|||
|
|||
/** |
|||
* 手机号 |
|||
*/ |
|||
private String mobile; |
|||
|
|||
/** |
|||
* 工作端用户id |
|||
*/ |
|||
private String staffId; |
|||
private String customerId; |
|||
} |
@ -0,0 +1,43 @@ |
|||
package com.epmet.commons.tools.enums; |
|||
|
|||
|
|||
/** |
|||
* 更新用户积分(双实信息更新 网格巡查) |
|||
* 行为类型枚举类 |
|||
*/ |
|||
public enum BehaviorTypeYuShanEnum { |
|||
|
|||
DOUBLE_INFO_UPDATE("double_info_update", "双十信息更新"), |
|||
GRID_PATROL("grid_patrol", "网格巡查"), |
|||
GRID_REPORT_EVENT("grid_report_event", "网格上报事件"), |
|||
GRID_WORK_UPLOAD("grid_work_upload", "网格工作上传"), |
|||
; |
|||
|
|||
private String code; |
|||
private String name; |
|||
|
|||
|
|||
BehaviorTypeYuShanEnum(String code, String name) { |
|||
this.code = code; |
|||
this.name = name; |
|||
} |
|||
|
|||
public static BehaviorTypeYuShanEnum getEnum(String code) { |
|||
BehaviorTypeYuShanEnum[] values = BehaviorTypeYuShanEnum.values(); |
|||
for (BehaviorTypeYuShanEnum value : values) { |
|||
if (value.getCode().equals(code)) { |
|||
return value; |
|||
} |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
|
|||
public String getCode() { |
|||
return code; |
|||
} |
|||
|
|||
public String getName() { |
|||
return name; |
|||
} |
|||
} |
@ -0,0 +1,35 @@ |
|||
package com.epmet.commons.tools.enums; |
|||
|
|||
/** |
|||
* 外部api |
|||
*/ |
|||
public enum ExternalApiEnum { |
|||
|
|||
/** |
|||
* 榆山-测试服务器地址 |
|||
*/ |
|||
UPDATE_USER_POINTS("/api/points/behavior/updateUserPoints","更新用户积分(双实信息更新 网格巡查)","http://yapi.elinkservice.cn/project/57/interface/api/7466"); |
|||
|
|||
private String apiPath; |
|||
private String desc; |
|||
private String descUrl; |
|||
|
|||
|
|||
ExternalApiEnum(String apiPath, String desc,String descUrl) { |
|||
this.apiPath = apiPath; |
|||
this.desc = desc; |
|||
this.descUrl=descUrl; |
|||
} |
|||
|
|||
public String getApiPath() { |
|||
return apiPath; |
|||
} |
|||
|
|||
public String getDesc() { |
|||
return desc; |
|||
} |
|||
|
|||
public String getDescUrl() { |
|||
return descUrl; |
|||
} |
|||
} |
@ -0,0 +1,55 @@ |
|||
package com.epmet.commons.tools.enums; |
|||
|
|||
import com.epmet.commons.tools.constant.StrConstant; |
|||
|
|||
|
|||
/** |
|||
* 外部客户的服务器地址 |
|||
*/ |
|||
public enum ExternalServerEnum { |
|||
DEV_TEST("45687aa479955f9d06204d415238f7cc", "https://epdc-api-test.elinkservice.cn/epdc-api"), |
|||
/** |
|||
* 榆山-测试服务器地址 |
|||
*/ |
|||
YUSHAN_TEST("a4bbf298d8e427844038cee466f022ef", "https://epdc-api-test.elinkservice.cn/epdc-api"), |
|||
/** |
|||
* 榆山-生产服务器地址 |
|||
*/ |
|||
YUSHAN_PROD("46c55cb862d6d5e6d05d2ab61a1cc07e", "https://epdc-yushan.elinkservice.cn/epdc-api"); |
|||
|
|||
|
|||
private String customerId; |
|||
private String url; |
|||
|
|||
|
|||
ExternalServerEnum(String customerId, String url) { |
|||
this.customerId = customerId; |
|||
this.url = url; |
|||
} |
|||
|
|||
public static String getUrl(String customerId) { |
|||
ExternalServerEnum[] array = values(); |
|||
for (ExternalServerEnum enumValue : array) { |
|||
if (enumValue.getCustomerId().equals(customerId)) { |
|||
return enumValue.getUrl(); |
|||
} |
|||
} |
|||
return StrConstant.EPMETY_STR; |
|||
} |
|||
|
|||
public String getCustomerId() { |
|||
return customerId; |
|||
} |
|||
|
|||
public void setCustomerId(String customerId) { |
|||
this.customerId = customerId; |
|||
} |
|||
|
|||
public String getUrl() { |
|||
return url; |
|||
} |
|||
|
|||
public void setUrl(String url) { |
|||
this.url = url; |
|||
} |
|||
} |
@ -0,0 +1,70 @@ |
|||
package com.epmet.commons.tools.utils; |
|||
|
|||
|
|||
import com.alibaba.fastjson.JSON; |
|||
import com.epmet.commons.tools.constant.SpecialCustomerOrgConstant; |
|||
import com.epmet.commons.tools.dto.form.UpdateUserPointsFormDTO; |
|||
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; |
|||
import com.epmet.commons.tools.enums.ExternalApiEnum; |
|||
import com.epmet.commons.tools.enums.ExternalServerEnum; |
|||
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|||
import com.epmet.commons.tools.exception.RenException; |
|||
import com.epmet.commons.tools.redis.common.CustomerStaffRedis; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.scheduling.annotation.Async; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.util.CollectionUtils; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* e事通调用榆山api |
|||
* |
|||
* @author yinzuomei |
|||
* @date 2022-02-16 |
|||
**/ |
|||
@Service |
|||
@Slf4j |
|||
public class YuShanSysApiService { |
|||
|
|||
|
|||
/** |
|||
* 更新用户积分(双实信息更新 网格巡查) |
|||
* |
|||
* @return |
|||
*/ |
|||
@Async |
|||
public void updateUserPoints(String customerId, List<UpdateUserPointsFormDTO> paramList) { |
|||
if (StringUtils.isBlank(customerId) || CollectionUtils.isEmpty(paramList)) { |
|||
throw new RenException("参数错误"); |
|||
} |
|||
String serverUrl = ExternalServerEnum.getUrl(customerId); |
|||
if (StringUtils.isBlank(serverUrl)) { |
|||
log.warn(String.format("当前客户:%s,未配置服务器地址", customerId)); |
|||
return; |
|||
} |
|||
String apiPath = serverUrl.concat(ExternalApiEnum.UPDATE_USER_POINTS.getApiPath()); |
|||
log.info(String.format("updateUserPoints 接口路径:%s", apiPath)); |
|||
for (UpdateUserPointsFormDTO formDTO : paramList) { |
|||
try { |
|||
CustomerStaffInfoCacheResult staff = CustomerStaffRedis.getStaffInfo(customerId, formDTO.getStaffId()); |
|||
//只有榆山街道的工作人员才调用
|
|||
if (null != staff && (staff.getAgencyId().equals(SpecialCustomerOrgConstant.YUSHAN_AGENCY_ID_PROD) || staff.getAgencyPIds().contains(SpecialCustomerOrgConstant.YUSHAN_AGENCY_ID_PROD))) { |
|||
formDTO.setMobile(staff.getMobile()); |
|||
Result<String> res = HttpClientManager.getInstance().sendPostByJSON(apiPath, JSON.toJSONString(formDTO)); |
|||
Result result = JSON.parseObject(res.getData(), Result.class); |
|||
log.info(String.format("updateUserPoints 入参:%s", JSON.toJSONString(formDTO))); |
|||
if (!result.success()) { |
|||
log.warn("updateUserPoints failed:{}", JSON.toJSONString(result)); |
|||
} |
|||
} |
|||
} catch (Exception e) { |
|||
log.warn("updateUserPoints exception 入参:{}", JSON.toJSONString(formDTO)); |
|||
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), e.getMessage()); |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|||
} |
Loading…
Reference in new issue