diff --git a/epmet-auth/deploy/docker-compose-dev.yml b/epmet-auth/deploy/docker-compose-dev.yml index b2609df0b1..03a7a57ee3 100644 --- a/epmet-auth/deploy/docker-compose-dev.yml +++ b/epmet-auth/deploy/docker-compose-dev.yml @@ -2,7 +2,7 @@ version: "3.7" services: epmet-auth-server: container_name: epmet-auth-server-dev - image: 192.168.1.130:10080/epmet-cloud-dev/epmet-auth:0.3.43 + image: 192.168.1.130:10080/epmet-cloud-dev/epmet-auth:0.3.44 ports: - "8081:8081" network_mode: host # 使用现有网络 diff --git a/epmet-auth/pom.xml b/epmet-auth/pom.xml index ab11a183fc..7c5f5d6a62 100644 --- a/epmet-auth/pom.xml +++ b/epmet-auth/pom.xml @@ -2,7 +2,7 @@ 4.0.0 - 0.3.43 + 0.3.44 com.epmet epmet-cloud diff --git a/epmet-auth/src/main/java/com/epmet/controller/PublicUserLoginController.java b/epmet-auth/src/main/java/com/epmet/controller/PublicUserLoginController.java index d083b2a26b..85163f625c 100644 --- a/epmet-auth/src/main/java/com/epmet/controller/PublicUserLoginController.java +++ b/epmet-auth/src/main/java/com/epmet/controller/PublicUserLoginController.java @@ -9,6 +9,7 @@ import com.epmet.constant.PublicUserLoginConstant; import com.epmet.dto.form.LoginByPhoneFormDTO; import com.epmet.dto.form.PaWxCodeFormDTO; import com.epmet.dto.form.PublicSendSmsCodeFormDTO; +import com.epmet.dto.form.RegisterFormDTO; import com.epmet.dto.result.UserTokenResultDTO; import com.epmet.service.PublicUserLoginService; import org.springframework.beans.factory.annotation.Autowired; @@ -70,5 +71,18 @@ public class PublicUserLoginController { return new Result().ok(publicUserLoginService.loginByPhone(tokenDTO, formDTO)); } + /** + * @param formDTO + * @return + * @Author sun + * @Description 公众号-手机号注册 + **/ + @PostMapping(value = "/register") + public Result register(@LoginUser TokenDto tokenDTO, @RequestBody RegisterFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, RegisterFormDTO.AddUserInternalGroup.class, RegisterFormDTO.AddUserShowGroup.class); + formDTO.setUserId(tokenDTO.getUserId()); + return new Result().ok(publicUserLoginService.register(formDTO)); + } + } diff --git a/epmet-auth/src/main/java/com/epmet/service/PublicUserLoginService.java b/epmet-auth/src/main/java/com/epmet/service/PublicUserLoginService.java index 0ee6449c90..80fd7ea305 100644 --- a/epmet-auth/src/main/java/com/epmet/service/PublicUserLoginService.java +++ b/epmet-auth/src/main/java/com/epmet/service/PublicUserLoginService.java @@ -4,6 +4,7 @@ import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.dto.form.LoginByPhoneFormDTO; import com.epmet.dto.form.PaWxCodeFormDTO; import com.epmet.dto.form.PublicSendSmsCodeFormDTO; +import com.epmet.dto.form.RegisterFormDTO; import com.epmet.dto.result.UserTokenResultDTO; /** @@ -38,4 +39,12 @@ public interface PublicUserLoginService { **/ UserTokenResultDTO loginByPhone(TokenDto tokenDTO, LoginByPhoneFormDTO formDTO); + /** + * @param formDTO + * @return + * @Author sun + * @Description 公众号-手机号注册 + **/ + UserTokenResultDTO register(RegisterFormDTO formDTO); + } diff --git a/epmet-auth/src/main/java/com/epmet/service/impl/LoginServiceImpl.java b/epmet-auth/src/main/java/com/epmet/service/impl/LoginServiceImpl.java index 695c187105..5221a30b33 100644 --- a/epmet-auth/src/main/java/com/epmet/service/impl/LoginServiceImpl.java +++ b/epmet-auth/src/main/java/com/epmet/service/impl/LoginServiceImpl.java @@ -4,6 +4,7 @@ import cn.binarywang.wx.miniapp.api.WxMaService; import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo; import cn.binarywang.wx.miniapp.bean.WxMaUserInfo; +import com.alibaba.fastjson.JSON; import com.epmet.common.token.constant.LoginConstant; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.RenException; @@ -120,10 +121,10 @@ public class LoginServiceImpl implements LoginService { wxMaJscode2SessionResult = wxMaServiceUtils.resiWxMaService().jsCode2SessionInfo(wxCode); } } catch (WxErrorException e) { - log.error("->[getMaOpenId]::error[{}]", "解析微信code失败"); + log.error("->[getMaOpenId]::error[{}]", "解析微信code失败",e); } if (null == wxMaJscode2SessionResult) { - log.error(String.format("解析微信用户信息失败,app[%s],wxCode[%s]",app,wxCode)); + log.error(String.format("解析微信用户信息失败,app[%s],wxCode[%s],result:[%S]",app,wxCode, JSON.toJSONString(wxMaJscode2SessionResult))); throw new RenException("解析微信用户信息失败"); } else if (StringUtils.isBlank(wxMaJscode2SessionResult.getOpenid())) { log.error(String.format("获取微信openid失败,app[%s],wxCode[%s]",app,wxCode)); diff --git a/epmet-auth/src/main/java/com/epmet/service/impl/PublicUserLoginServiceImpl.java b/epmet-auth/src/main/java/com/epmet/service/impl/PublicUserLoginServiceImpl.java index 6d0e615944..f626ec6814 100644 --- a/epmet-auth/src/main/java/com/epmet/service/impl/PublicUserLoginServiceImpl.java +++ b/epmet-auth/src/main/java/com/epmet/service/impl/PublicUserLoginServiceImpl.java @@ -1,8 +1,10 @@ package com.epmet.service.impl; import com.epmet.common.token.constant.LoginConstant; +import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.redis.RedisKeys; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.CpUserDetailRedis; import com.epmet.commons.tools.utils.DateUtils; @@ -14,10 +16,7 @@ import com.epmet.dto.PaCustomerDTO; import com.epmet.dto.PaUserDTO; import com.epmet.dto.PaUserWechatDTO; import com.epmet.dto.form.*; -import com.epmet.dto.result.CustomerUserResultDTO; -import com.epmet.dto.result.SaveUserResultDTO; -import com.epmet.dto.result.SendVerificationCodeResultDTO; -import com.epmet.dto.result.UserTokenResultDTO; +import com.epmet.dto.result.*; import com.epmet.feign.EpmetMessageOpenFeignClient; import com.epmet.feign.EpmetThirdFeignClient; import com.epmet.jwt.JwtTokenProperties; @@ -33,8 +32,10 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -242,4 +243,35 @@ public class PublicUserLoginServiceImpl implements PublicUserLoginService { return userTokenResultDTO; } + /** + * @param formDTO + * @return + * @Author sun + * @Description 公众号-手机号注册 + **/ + @Override + public UserTokenResultDTO register(RegisterFormDTO formDTO) { + //1.调用epmet-third服务,完成信息注册 + Result result = epmetThirdFeignClient.register(formDTO); + if (!result.success()) { + logger.error("调用epmet_third服务初始化用户信息失败"); + throw new RenException(result.getCode()); + } + RegisterResultDTO resultDTO = result.getData(); + + //2.直接生成一个新的token放入缓存中(不管缓存中是否存在旧的token,都重新生成) + //2-1.生成token + String token = this.generateGovWxmpToken(resultDTO.getUserId()); + //2-2.token存入redis + String openid = resultDTO.getOpenId(); + String unionId = (null == resultDTO.getUnionId() ? "" : resultDTO.getUnionId()); + this.saveLatestGovTokenDto("", resultDTO.getUserId(), openid, unionId, token); + + //3.返回token + UserTokenResultDTO userTokenResultDTO = new UserTokenResultDTO(); + userTokenResultDTO.setToken(token); + return userTokenResultDTO; + } + + } diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/mq/EventClassDto.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/mq/EventClassDto.java new file mode 100644 index 0000000000..fb82587822 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/mq/EventClassDto.java @@ -0,0 +1,41 @@ +package com.epmet.commons.tools.dto.form.mq; + +import lombok.Data; + +import java.io.Serializable; + +/** + * desc:消息网关事件类型dto + * + * @author lyn + * @date 2020/7/24 18:30 + */ +@Data +public class EventClassDto implements Serializable { + private static final long serialVersionUID = 6923860669547819790L; + /** + * appId + */ + private String appId; + /** + * 事件类型Id + */ + private Integer id; + /** + * 事件标识 + */ + private String eventClass; + /** + * 事件名称 + */ + private String eventClassName; + /** + * 0''未删''1''已删 + */ + private Integer delFlag; + /** + * 事件计数 + */ + private Integer eventCount; + +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/mq/MqBaseMsgDTO.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/mq/MqBaseMsgDTO.java index 812d2e5baa..6e9318549e 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/mq/MqBaseMsgDTO.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/mq/MqBaseMsgDTO.java @@ -3,6 +3,8 @@ package com.epmet.commons.tools.dto.form.mq; import lombok.Data; import org.springframework.stereotype.Component; +import javax.validation.constraints.NotBlank; + /** * 消息网关基础信息 * @@ -11,20 +13,23 @@ import org.springframework.stereotype.Component; **/ @Data @Component -public class MqBaseMsgDTO extends MqConfigDTO { +public class MqBaseMsgDTO extends MqBaseParamDTO { private static final long serialVersionUID = 8176470786428432009L; /** * mq的事件类型 */ + @NotBlank(message = "事件类型不能为空") private String eventClass; /** * 事件code */ + @NotBlank(message = "事件标识不能为空") private String eventTag; /** * 消息体 */ + @NotBlank(message = "消息体不能为空") private String msg; } diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/mq/MqConfigDTO.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/mq/MqBaseParamDTO.java similarity index 83% rename from epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/mq/MqConfigDTO.java rename to epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/mq/MqBaseParamDTO.java index 24a388f8ae..9ad8df6cf4 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/mq/MqConfigDTO.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/mq/MqBaseParamDTO.java @@ -11,7 +11,7 @@ import java.io.Serializable; * @date 2020-07-21 14:33 **/ @Data -public class MqConfigDTO implements Serializable { +public class MqBaseParamDTO implements Serializable { private String appId; private String token; private String requestUrl; diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/MqMethodPathEnum.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/MqMethodPathEnum.java index 014722de84..866229d1d9 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/MqMethodPathEnum.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/MqMethodPathEnum.java @@ -9,6 +9,7 @@ package com.epmet.commons.tools.enums; **/ public enum MqMethodPathEnum { SEND_MSG("producerService/producer/sendMsg", "发送消息"), + GET_EVENT_LIST("eventClass/getList", "获取事件类型列表"), ; diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpClientManager.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpClientManager.java index 5061222074..6d91832472 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpClientManager.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpClientManager.java @@ -23,9 +23,10 @@ import org.apache.http.config.RegistryBuilder; import org.apache.http.conn.socket.ConnectionSocketFactory; import org.apache.http.conn.socket.PlainConnectionSocketFactory; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; +import org.apache.http.entity.ContentType; import org.apache.http.entity.StringEntity; +import org.apache.http.entity.mime.HttpMultipartMode; import org.apache.http.entity.mime.MultipartEntityBuilder; -import org.apache.http.entity.mime.content.FileBody; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; @@ -43,6 +44,7 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; import java.security.KeyManagementException; import java.security.NoSuchAlgorithmException; import java.security.cert.CertificateException; @@ -170,11 +172,20 @@ public class HttpClientManager { try { HttpPost httppost = new HttpPost(url); httppost.setConfig(requestConfig); - httppost.addHeader("Content-Type", "application/json; charset=utf-8"); - FileBody fileBody = new FileBody(file); - HttpEntity reqEntity = MultipartEntityBuilder.create() - .addPart("media", fileBody).build(); - httppost.setEntity(reqEntity); + String boundaryStr = "------------" + System.currentTimeMillis(); + httppost.addHeader("Connection", "keep-alive"); + httppost.addHeader("Accept", "*/*"); + httppost.addHeader("Content-Type", "multipart/form-data;boundary=" + boundaryStr); + httppost.addHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0) "); + MultipartEntityBuilder meb = MultipartEntityBuilder.create(); + meb.setBoundary(boundaryStr).setCharset(StandardCharsets.UTF_8).setMode(HttpMultipartMode.BROWSER_COMPATIBLE); + meb.addBinaryBody("media", file, ContentType.APPLICATION_OCTET_STREAM, file.getName()); + HttpEntity entity = meb.build(); + httppost.setEntity(entity); +// FileBody fileBody = new FileBody(file); +// HttpEntity reqEntity = MultipartEntityBuilder.create() +// .addPart("media", fileBody).build(); +// httppost.setEntity(reqEntity); return execute(httppost,false); } catch (Exception e) { log.error("send exception", e); diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/SendMqMsgUtils.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/SendMqMsgUtils.java index 65fb179ca3..dede8d5706 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/SendMqMsgUtils.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/SendMqMsgUtils.java @@ -4,14 +4,21 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.epmet.commons.tools.config.MqConfig; import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.dto.form.mq.EventClassDto; import com.epmet.commons.tools.dto.form.mq.MqBaseMsgDTO; import com.epmet.commons.tools.dto.form.mq.MqReturnBaseResult; import com.epmet.commons.tools.enums.MqMethodPathEnum; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.ValidateException; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.commons.tools.validator.group.DefaultGroup; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + /** * 发送亿联云消息工具类 * @@ -21,7 +28,7 @@ import org.springframework.stereotype.Component; @Slf4j @Component public class SendMqMsgUtils { - private static MqConfig mqStaticConfig; + private static MqConfig mqConfig; /** * desc:发送mq消息 @@ -29,19 +36,19 @@ public class SendMqMsgUtils { * @return */ public static Result sendMsg(MqBaseMsgDTO msg) { - if (mqStaticConfig == null) { - mqStaticConfig = SpringContextUtils.getBean(MqConfig.class); + if (mqConfig == null) { + mqConfig = SpringContextUtils.getBean(MqConfig.class); } log.debug("sendMsg param:{}", JSON.toJSONString(msg)); try { // TODO - //ValidatorUtils.validateEntity(msg, null); + ValidatorUtils.validateEntity(msg, DefaultGroup.class); } catch (ValidateException e) { return new Result().error(e.getMsg()); } - msg.setAppId(mqStaticConfig.getAppId()); - msg.setRequestUrl(mqStaticConfig.getHost().concat(MqMethodPathEnum.SEND_MSG.getCode())); - msg.setToken(mqStaticConfig.getToken()); + msg.setAppId(mqConfig.getAppId()); + msg.setRequestUrl(mqConfig.getHost().concat(MqMethodPathEnum.SEND_MSG.getCode())); + msg.setToken(mqConfig.getToken()); try { Result result = HttpClientManager.getInstance().sendPostByHttps(msg.getRequestUrl(), JSON.toJSONString(msg)); log.debug("sendMsg result:{}", JSON.toJSONString(result)); @@ -66,4 +73,42 @@ public class SendMqMsgUtils { } + /** + * desc:发送mq消息 + * + * @return + */ + public static Result> getEventClassList() { + if (mqConfig == null) { + mqConfig = SpringContextUtils.getBean(MqConfig.class); + } + Map param = new HashMap<>(); + param.put("appId", mqConfig.getAppId()); + param.put("token", mqConfig.getToken()); + String requestUrl = mqConfig.getHost().concat(MqMethodPathEnum.GET_EVENT_LIST.getCode()); + + try { + Result result = HttpClientManager.getInstance().sendPostByHttps(requestUrl, JSON.toJSONString(param)); + log.debug("getEventClassList result:{}", JSON.toJSONString(result)); + if (result.success()) { + MqReturnBaseResult resultResult = JSON.parseObject(result.getData(), MqReturnBaseResult.class); + if (resultResult.getErrCode().equals(NumConstant.ZERO)) { + List eventClassDto = JSON.parseArray(resultResult.getData(), EventClassDto.class); + return new Result>().ok(eventClassDto); + } else { + log.error("sendMsg fail,resultData:{}", JSON.toJSONString(resultResult)); + return new Result>().error(EpmetErrorCode.SERVER_ERROR.getCode(), resultResult.getErrMsg()); + } + } + Result> resultResult = new Result<>(); + resultResult.error(result.getCode(), result.getMsg()); + resultResult.setInternalMsg(result.getInternalMsg()); + return resultResult; + } catch (Exception e) { + log.debug("sendMsg exception", e); + return new Result>().error(EpmetErrorCode.SERVER_ERROR.getCode(), EpmetErrorCode.SERVER_ERROR.getMsg()); + } + } + + } diff --git a/epmet-gateway/deploy/docker-compose-prod.yml b/epmet-gateway/deploy/docker-compose-prod.yml index 35a4e7e1e2..cec8fb60da 100644 --- a/epmet-gateway/deploy/docker-compose-prod.yml +++ b/epmet-gateway/deploy/docker-compose-prod.yml @@ -2,7 +2,7 @@ version: "3.7" services: epmet-gateway-server: container_name: epmet-gateway-server-prod - image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-master/epmet-gateway:0.3.25 + image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-master/epmet-gateway:0.3.26 ports: - "8080:8080" network_mode: host # 使用现有网络 diff --git a/epmet-module/data-statistical/data-statistical-server/deploy/docker-compose-dev.yml b/epmet-module/data-statistical/data-statistical-server/deploy/docker-compose-dev.yml index 811a2df85c..e86909b2c8 100644 --- a/epmet-module/data-statistical/data-statistical-server/deploy/docker-compose-dev.yml +++ b/epmet-module/data-statistical/data-statistical-server/deploy/docker-compose-dev.yml @@ -2,7 +2,7 @@ version: "3.7" services: data-statistical-server: container_name: data-statistical-server-dev - image: 192.168.1.130:10080/epmet-cloud-dev/data-statistical-server:0.3.39 + image: 192.168.1.130:10080/epmet-cloud-dev/data-statistical-server:0.3.41 ports: - "8108:8108" network_mode: host # 使用现有网络 diff --git a/epmet-module/data-statistical/data-statistical-server/deploy/docker-compose-test.yml b/epmet-module/data-statistical/data-statistical-server/deploy/docker-compose-test.yml index 3b3123c312..4d3be03e5d 100644 --- a/epmet-module/data-statistical/data-statistical-server/deploy/docker-compose-test.yml +++ b/epmet-module/data-statistical/data-statistical-server/deploy/docker-compose-test.yml @@ -2,7 +2,7 @@ version: "3.7" services: data-statistical-server: container_name: data-statistical-server-test - image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-release/data-statistical-server:0.3.39 + image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-release/data-statistical-server:0.3.41 ports: - "8108:8108" network_mode: host # 使用现有网络 diff --git a/epmet-module/data-statistical/data-statistical-server/pom.xml b/epmet-module/data-statistical/data-statistical-server/pom.xml index 971d0c956a..1709484e94 100644 --- a/epmet-module/data-statistical/data-statistical-server/pom.xml +++ b/epmet-module/data-statistical/data-statistical-server/pom.xml @@ -2,7 +2,7 @@ - 0.3.39 + 0.3.41 data-statistical com.epmet diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/crm/CustomerDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/crm/CustomerDao.java index bfe699c25e..f3618f4e06 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/crm/CustomerDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/crm/CustomerDao.java @@ -43,4 +43,6 @@ public interface CustomerDao extends BaseDao { List listValidCustomersByCreateTime( @Param("createTimeFrom") Date createTimeFrom, @Param("createTimeTo") Date createTimeTo); + + List listValidCustomersByUpdateTime(@Param("startTime") Date startTime, @Param("endTime") Date endTime); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/CustomerDepartmentDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/CustomerDepartmentDao.java index 2b9b4705ab..8db5a46efb 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/CustomerDepartmentDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/CustomerDepartmentDao.java @@ -38,4 +38,5 @@ public interface CustomerDepartmentDao extends BaseDao @Param("createdTimeFrom") Date createdTimeFrom, @Param("createdTimeTo") Date createdTimeTo); + List listDepartmentsByUpdatedTime(@Param("startTime") Date startTime, @Param("endTime") Date endTime); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/CustomerGridDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/CustomerGridDao.java index faccf553a2..9f26b8b98d 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/CustomerGridDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/CustomerGridDao.java @@ -59,4 +59,12 @@ public interface CustomerGridDao extends BaseDao { * @author zxc */ List getCustomerGridIdList(@Param("customerId") String customerId, @Param("dateId") String dateId); + + /** + * 根据更新时间查询列表 + * @param startTime + * @param endTime + * @return + */ + List listUpdatedGridsByUpdateTime(@Param("startTime") Date startTime, @Param("endTime") Date endTime); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/StatsCustomerAgencyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/StatsCustomerAgencyDao.java index b3de9cfd02..eb02051e91 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/StatsCustomerAgencyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/StatsCustomerAgencyDao.java @@ -20,4 +20,6 @@ public interface StatsCustomerAgencyDao extends BaseDao { List selectAllAgency(); List selectSubAgencyByPid(@Param("pid")String pid); + + List listAgenciesByUpdatedTime(@Param("startTime") Date startTime, @Param("endTime") Date endTime); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimAgencyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimAgencyDao.java index 419a54ef2c..8788232a7b 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimAgencyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimAgencyDao.java @@ -124,4 +124,6 @@ public interface DimAgencyDao extends BaseDao { String getPidByAgencyId(@Param("agencyId") String agencyId); DimAgencyEntity getLatestCreatedAgencyDimEntity(); + + DimAgencyEntity getLatestUpdatedAgencyDimEntity(); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimCustomerDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimCustomerDao.java index 1834b73ffc..8bd2c3cf8d 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimCustomerDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimCustomerDao.java @@ -47,4 +47,6 @@ public interface DimCustomerDao extends BaseDao { void insertOne(DimCustomerEntity dim); DimCustomerEntity getLatestCreatedDimEntity(); + + DimCustomerEntity getLatestUpdatedDimEntity(); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimDepartmentDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimDepartmentDao.java index 5098869983..0b58bc2220 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimDepartmentDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimDepartmentDao.java @@ -42,4 +42,6 @@ public interface DimDepartmentDao extends BaseDao { List getDepartmentListByCustomerId(@Param("customerId") String customerId); DimDepartmentEntity getLatestCreatedDimEntity(); + + DimDepartmentEntity getLatestUpdatedDimEntity(); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimGridDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimGridDao.java index 669e8a08a0..c1671131b1 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimGridDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimGridDao.java @@ -58,4 +58,6 @@ public interface DimGridDao extends BaseDao { * @author zxc */ List selectSubAgencyId(@Param("formDTO")List formDTO); + + DimGridEntity getLastUpdatedGridDim(); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/CustomerService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/CustomerService.java index e562a08365..dbc2cc03f9 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/CustomerService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/CustomerService.java @@ -9,4 +9,5 @@ public interface CustomerService { List listValidCustomersByCreateTime(Date createTimeFrom, Date createTimeTo); + List listValidCustomersByUpdatedTime(Date updatedTime, Date initTime); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/impl/CustomerServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/impl/CustomerServiceImpl.java index 3db2f197bd..056df4e50e 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/impl/CustomerServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/impl/CustomerServiceImpl.java @@ -22,4 +22,9 @@ public class CustomerServiceImpl implements CustomerService { public List listValidCustomersByCreateTime(Date createTimeFrom, Date createTimeTo) { return customerDao.listValidCustomersByCreateTime(createTimeFrom, createTimeTo); } + + @Override + public List listValidCustomersByUpdatedTime(Date startTime, Date endTime) { + return customerDao.listValidCustomersByUpdateTime(startTime, endTime); + } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsDimServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsDimServiceImpl.java index dde7d9f14e..5c09458416 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsDimServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsDimServiceImpl.java @@ -1,8 +1,6 @@ package com.epmet.service.impl; -import com.epmet.commons.tools.utils.DateUtils; import com.epmet.constant.RobotConstant; -import com.epmet.constant.StatsSubject; import com.epmet.entity.crm.CustomerEntity; import com.epmet.entity.org.CustomerAgencyEntity; import com.epmet.entity.org.CustomerDepartmentEntity; @@ -18,6 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; +import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.stream.Collectors; @@ -54,6 +53,17 @@ public class StatsDimServiceImpl implements StatsDimService { @Override public void initGridDim() { + List newDimGrids = getNewDimGrids(); + List changedGrids = getChangedGrids(); + + dimGridService.initGridDims(newDimGrids, changedGrids); + } + + /** + * 初始化新建网格 + * @return + */ + public List getNewDimGrids() { DimGridEntity lastDimEntity = dimGridService.getLastCreatedGridDim(); List grids; Date now = new Date(); @@ -65,10 +75,36 @@ public class StatsDimServiceImpl implements StatsDimService { grids = customerGridService.listGridsByCreateTime(lastInitTime, now); } - List gridDims = convertCustomerGrid2GridDim(grids, now); - if (!CollectionUtils.isEmpty(gridDims)) { - dimGridService.initGridDims(gridDims); + return convertCustomerGrid2GridDim(grids, now); + } + + /** + * 初始化变更的网格 + * @return + */ + public List getChangedGrids() { + DimGridEntity lastUpdatedGridDim = dimGridService.getLastUpdatedGridDim(); + + List updatedGrids; + Date now = new Date(); + if (lastUpdatedGridDim != null) { + Date lastInitTime = lastUpdatedGridDim.getUpdatedTime(); + updatedGrids = customerGridService.listUpdatedGridsByUpdateTime(lastInitTime, now); + ArrayList dimGrids = new ArrayList<>(); + for (CustomerGridEntity updatedGrid : updatedGrids) { + DimGridEntity dimGrid = dimGridService.selectById(updatedGrid.getId()); + if (dimGrid != null) { + dimGrid.setGridName(updatedGrid.getGridName()); + dimGrid.setUpdatedTime(now); + dimGrid.setUpdatedBy(RobotConstant.DIMENSION_ROBOT); + dimGrids.add(dimGrid); + } + } + + return dimGrids; } + + return new ArrayList<>(); } /** @@ -98,19 +134,41 @@ public class StatsDimServiceImpl implements StatsDimService { */ @Override public void initAgencyDim() { + Date now = new Date(); + List agencies2Add = listAgencies2Add(now); + List agencies2Update = listAgencies2Update(now); + dimAgencyService.initAgencyDims(agencies2Add, agencies2Update, now); + } + + /** + * 查询需要添加的机关ç + * @return + */ + public List listAgencies2Add(Date endDate) { DimAgencyEntity latestCreatedAgencyDim = dimAgencyService.getLatestCreatedAgencyDimEntity(); - Date now = new Date(); Date lastInitTime = null; if (latestCreatedAgencyDim != null) { lastInitTime = latestCreatedAgencyDim.getCreatedTime(); } - List agencies = customerAgencyService.listAgenciesByCreateTime(lastInitTime, now); - if (!CollectionUtils.isEmpty(agencies)) { - dimAgencyService.initAgencyDims(agencies, now); + return customerAgencyService.listAgenciesByCreateTime(lastInitTime, endDate); + } + + /** + * 查询需要更新的机关 + * @return + */ + public List listAgencies2Update(Date endDate) { + DimAgencyEntity latestUpdatedAgencyDim = dimAgencyService.getLatestUpdatedAgencyDimEntity(); + + if (latestUpdatedAgencyDim != null) { + // 不是首次初始化,可以更新 + Date updatedTime = latestUpdatedAgencyDim.getUpdatedTime(); + return customerAgencyService.listAgenciesByUpdatedTime(updatedTime, endDate); } + return new ArrayList<>(); } /** @@ -118,24 +176,59 @@ public class StatsDimServiceImpl implements StatsDimService { */ @Override public void initCustomerDim() { + Date now = new Date(); + List newCustomers = listNewCustomers(now); + List updatedCustomers = listUpdatedCustomers(now); +// System.out.println(666); + dimCustomerService.initCustomerDims(newCustomers, updatedCustomers, now); + } + + /** + * 查询新增的客户列表 + * @param initTime + * @return + */ + public List listNewCustomers(Date initTime) { DimCustomerEntity lastCreateDim = dimCustomerService.getLatestCreatedDimEntity(); - Date now = new Date(); Date lastInitTime = null; if (lastCreateDim != null) { lastInitTime = lastCreateDim.getCreatedTime(); } - List customers = customerService.listValidCustomersByCreateTime(lastInitTime, now); - if (!CollectionUtils.isEmpty(customers)) { - dimCustomerService.initCustomerDims(customers, now); + List customers = customerService.listValidCustomersByCreateTime(lastInitTime, initTime); + + return customers; + } + + /** + * 查询更新的客户列表 + * @param initTime + * @return + */ + public List listUpdatedCustomers(Date initTime) { + DimCustomerEntity lastCreatedDim = dimCustomerService.getLatestUpdatedDimEntity(); + if (lastCreatedDim != null) { + // 说明不是首次初始化 + List customers = customerService.listValidCustomersByUpdatedTime(lastCreatedDim.getUpdatedTime(), initTime); + return customers; } + return new ArrayList<>(); } + /** + * 初始化部门维度 + */ @Override public void initDepartmentDim() { + Date now = new Date(); + List newDepartments = listNewDepartments(now); + List updatedDepartments = listUpdatedDepartments(now); + dimDepartmentService.initDepartmentDims(newDepartments, updatedDepartments, now); + } + public List listNewDepartments(Date initTime) { DimDepartmentEntity lastCreatedDeptDim = dimDepartmentService.getLatestCreatedDimEntity(); Date now = new Date(); @@ -144,10 +237,14 @@ public class StatsDimServiceImpl implements StatsDimService { if (lastCreatedDeptDim != null) { lastInitTime = lastCreatedDeptDim.getCreatedTime(); } + return departmentService.listDepartmentsByCreatedTime(lastInitTime, now); + } - List departments = departmentService.listDepartmentsByCreatedTime(lastInitTime, now); - if (!CollectionUtils.isEmpty(departments)) { - dimDepartmentService.initDepartmentDims(departments, now); + public List listUpdatedDepartments(Date initTime) { + DimDepartmentEntity lastUpdatedDeptDim = dimDepartmentService.getLatestUpdatedDimEntity(); + if (lastUpdatedDeptDim != null) { + return departmentService.listDepartmentsByUpdatedTime(lastUpdatedDeptDim.getCreatedTime(), initTime); } + return new ArrayList<>(); } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerAgencyService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerAgencyService.java index 034499e955..96669f2ae9 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerAgencyService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerAgencyService.java @@ -7,4 +7,6 @@ import java.util.List; public interface CustomerAgencyService { List listAgenciesByCreateTime(Date statsStartTime, Date statsEndTime); + + List listAgenciesByUpdatedTime(Date updatedTime, Date now); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerDepartmentService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerDepartmentService.java index 1aa2c2f7db..15178715ed 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerDepartmentService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerDepartmentService.java @@ -8,4 +8,6 @@ import java.util.List; public interface CustomerDepartmentService { List listDepartmentsByCreatedTime(Date createdTimeFrom, Date createdTimeTo); + + List listDepartmentsByUpdatedTime(Date createdTime, Date initTime); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerGridService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerGridService.java index 00b46e8b75..b2b7a5b129 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerGridService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerGridService.java @@ -32,4 +32,12 @@ public interface CustomerGridService { * @author zxc */ List getCustomerGridIdList(String customerId, String dateId); + + /** + * 根据更新时间查询变更过的网格列表 + * @param lastInitTime + * @param now + * @return + */ + List listUpdatedGridsByUpdateTime(Date lastInitTime, Date now); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerAgencyServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerAgencyServiceImpl.java index 2912ca0cca..4813309176 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerAgencyServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerAgencyServiceImpl.java @@ -22,4 +22,9 @@ public class CustomerAgencyServiceImpl implements CustomerAgencyService { public List listAgenciesByCreateTime(Date statsStartTime, Date statsEndTime) { return customerAgencyDao.listAgenciesByCreateTime(statsStartTime, statsEndTime); } + + @Override + public List listAgenciesByUpdatedTime(Date startTime, Date endTime) { + return customerAgencyDao.listAgenciesByUpdatedTime(startTime, endTime); + } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerDepartmentServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerDepartmentServiceImpl.java index ac430a3abd..0a7a4e380a 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerDepartmentServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerDepartmentServiceImpl.java @@ -28,4 +28,9 @@ public class CustomerDepartmentServiceImpl implements CustomerDepartmentService public List listDepartmentsByCreatedTime(Date createdTimeFrom, Date createdTimeTo) { return departmentDao.listDepartmentsByCreatedTime(createdTimeFrom, createdTimeTo); } + + @Override + public List listDepartmentsByUpdatedTime(Date startTime, Date endTime) { + return departmentDao.listDepartmentsByUpdatedTime(startTime, endTime); + } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerGridServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerGridServiceImpl.java index fc95a3de29..5bab5596a7 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerGridServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerGridServiceImpl.java @@ -46,4 +46,9 @@ public class CustomerGridServiceImpl implements CustomerGridService { public List getCustomerGridIdList(String customerId, String dateId) { return customerGridDao.getCustomerGridIdList(customerId, dateId); } + + @Override + public List listUpdatedGridsByUpdateTime(Date lastInitTime, Date now) { + return customerGridDao.listUpdatedGridsByUpdateTime(lastInitTime, now); + } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimAgencyService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimAgencyService.java index df58489fd0..aad2cae314 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimAgencyService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimAgencyService.java @@ -107,9 +107,8 @@ public interface DimAgencyService extends BaseService { /** * 初始化机关维度 - * @param agencies */ - void initAgencyDims(List agencies, Date initTime); + void initAgencyDims(List agencies2Add, List agencies2Update, Date initTime); /** * @Description 查询所有机关以及它下级机关的信息 @@ -175,4 +174,6 @@ public interface DimAgencyService extends BaseService { String getPidByAgencyId(String agencyId); DimAgencyEntity getLatestCreatedAgencyDimEntity(); + + DimAgencyEntity getLatestUpdatedAgencyDimEntity(); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimCustomerService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimCustomerService.java index d3562d01db..9d53593957 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimCustomerService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimCustomerService.java @@ -110,9 +110,10 @@ public interface DimCustomerService extends BaseService { /** * 添加客户维度 - * @param customers */ - void initCustomerDims(List customers, Date initTime); + void initCustomerDims(List newCustomers, List updatedCustomers, Date initTime); DimCustomerEntity getLatestCreatedDimEntity(); + + DimCustomerEntity getLatestUpdatedDimEntity(); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimDepartmentService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimDepartmentService.java index fe839ac0c9..767d5b8ffe 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimDepartmentService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimDepartmentService.java @@ -95,7 +95,7 @@ public interface DimDepartmentService extends BaseService { */ void delete(String[] ids); - void initDepartmentDims(List departments, Date initTime); + void initDepartmentDims(List newDepartments, List updatedDepartments, Date initTime); /** * desc: 根据客户Id获取 部门数据 @@ -108,4 +108,6 @@ public interface DimDepartmentService extends BaseService { List getDepartmentListByCustomerId(String customerId); DimDepartmentEntity getLatestCreatedDimEntity(); + + DimDepartmentEntity getLatestUpdatedDimEntity(); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimGridService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimGridService.java index 312659eb96..b937efdf9e 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimGridService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimGridService.java @@ -101,9 +101,8 @@ public interface DimGridService extends BaseService { /** * 初始化网格维度 - * @param gridDims */ - void initGridDims(List gridDims); + void initGridDims(List newDimGrids, List changedGrids); /** * desc: 根据客户Id获取 该客户下所有的网格数据 @@ -128,4 +127,6 @@ public interface DimGridService extends BaseService { * @author zxc */ List selectSubAgencyId(List formDTO); + + DimGridEntity getLastUpdatedGridDim(); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimAgencyServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimAgencyServiceImpl.java index 0d21b5525f..d40987c1bc 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimAgencyServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimAgencyServiceImpl.java @@ -123,12 +123,25 @@ public class DimAgencyServiceImpl extends BaseServiceImpl agencies, Date initTime) { - for (CustomerAgencyEntity agency : agencies) { + public void initAgencyDims(List agencies2Add, List agencies2Update, Date initTime) { + // 添加新增的机关维度 + for (CustomerAgencyEntity agency : agencies2Add) { initAgencyAllDim(agency, initTime); initAgencySelfDim(agency, initTime); } + // 更新变更过的机关维度 + for (CustomerAgencyEntity agency : agencies2Update) { + DimAgencyEntity existsDimAgency = baseDao.selectById(agency.getId()); + if (existsDimAgency != null) { + //说明是已存在的,不是新增的 + existsDimAgency.setAgencyName(agency.getOrganizationName()); + existsDimAgency.setUpdatedTime(initTime); + existsDimAgency.setUpdatedBy(RobotConstant.DIMENSION_ROBOT); + baseDao.updateById(existsDimAgency); + } + } + lastExecRecordDao.updateExecTimeBySubject(new Date(), StatsSubject.DIM_AGENCY); } @@ -255,4 +268,9 @@ public class DimAgencyServiceImpl extends BaseServiceImpl customers, Date initTime) { - for (CustomerEntity customer : customers) { + public void initCustomerDims(List newCustomers, List updatedCustomers, Date initTime) { + // 添加新增的客户维度 + for (CustomerEntity customer : newCustomers) { DimCustomerEntity dim = new DimCustomerEntity(); dim.setCustomerName(customer.getCustomerName()); dim.setCreatedBy(RobotConstant.DIMENSION_ROBOT); @@ -131,6 +132,18 @@ public class DimCustomerServiceImpl extends BaseServiceImpl departments, Date initTime) { - for (CustomerDepartmentEntity department : departments) { + public void initDepartmentDims(List newDepartments, List updatedDepartments, Date initTime) { + // 新增科室初始化 + for (CustomerDepartmentEntity department : newDepartments) { DimDepartmentEntity dim = new DimDepartmentEntity(); dim.setAgencyId(department.getAgencyId()); dim.setCustomerId(department.getCustomerId()); @@ -122,6 +123,18 @@ public class DimDepartmentServiceImpl extends BaseServiceImpl gridDims) { - for (DimGridEntity gridDim : gridDims) { - baseDao.insert(gridDim); + public void initGridDims(List newDimGrids, List changedGrids) { + for (DimGridEntity newGridDim : newDimGrids) { + baseDao.insert(newGridDim); + } + + for (DimGridEntity updatedGridDim : changedGrids) { + baseDao.updateById(updatedGridDim); } lastExecRecordDao.updateExecTimeBySubject(new Date(), StatsSubject.DIM_GRID); @@ -156,4 +159,9 @@ public class DimGridServiceImpl extends BaseServiceImpl selectSubAgencyId(List formDTO) { return baseDao.selectSubAgencyId(formDTO); } + + @Override + public DimGridEntity getLastUpdatedGridDim() { + return baseDao.getLastUpdatedGridDim(); + } } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/crm/CustomerDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/crm/CustomerDao.xml index 0aac258069..382edefac3 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/crm/CustomerDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/crm/CustomerDao.xml @@ -41,4 +41,27 @@ CONVERT ( c.CUSTOMER_NAME USING gbk ) ASC + + diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerDepartmentDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerDepartmentDao.xml index 6d3bc43ce3..365ae56b8a 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerDepartmentDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerDepartmentDao.xml @@ -16,4 +16,24 @@ + + + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerGridDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerGridDao.xml index 6a5253e473..48c5176a78 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerGridDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerGridDao.xml @@ -47,4 +47,25 @@ AND customer_id = #{customerId} AND DATE_FORMAT( created_time, '%Y%m%d' ) #{dateId} + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/StatsCustomerAgencyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/StatsCustomerAgencyDao.xml index 3e22e1b5c3..268782eb3d 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/StatsCustomerAgencyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/StatsCustomerAgencyDao.xml @@ -75,4 +75,29 @@ grid.ID + + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimAgencyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimAgencyDao.xml index 74c52efaa6..dedf82d8fe 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimAgencyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimAgencyDao.xml @@ -277,4 +277,25 @@ LIMIT 1 + + + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimCustomerDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimCustomerDao.xml index 7b8ad49e3c..13bc6a3e01 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimCustomerDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimCustomerDao.xml @@ -25,4 +25,19 @@ ORDER BY CREATED_TIME DESC LIMIT 1 + + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimDepartmentDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimDepartmentDao.xml index 68de10bef6..4f0a68ed28 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimDepartmentDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimDepartmentDao.xml @@ -35,4 +35,21 @@ ORDER BY CREATED_TIME DESC LIMIT 1 + + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimGridDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimGridDao.xml index 783230dc55..eef43456f7 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimGridDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimGridDao.xml @@ -52,4 +52,21 @@ + + \ No newline at end of file diff --git a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/result/EventDTO.java b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/result/EventDTO.java new file mode 100644 index 0000000000..e95e09002a --- /dev/null +++ b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/result/EventDTO.java @@ -0,0 +1,112 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + + +/** + * 事件表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-07-16 + */ +@Data +public class EventDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private String id; + + /** + * 消息网关事件类别ID 从消息网关获取事件类型Id + */ + private String classId; + + /** + * 消息网关APP_ID + */ + private String appId; + + /** + * 消息网关APP_NAME + */ + private String appName; + + /** + * 事件标识 与消息网关事件tag一致 + */ + private String eventCode; + + /** + * 事件名称 + */ + private String eventName; + + /** + * 事件说明 + */ + private String eventDesc; + + /** + * 事件功能分组ID 来自oper_customize.customer_function表 + */ + private String functionId; + + /** + * 是否是通用事件 0-否,1-是;消息体内需要体现该字段,通用则说明由业务系统自己计算分值 + */ + private String isCommon; + + /** + * 删除标识 0-否,1-是 + */ + private String delFlag; + + /** + * 乐观锁 查询时添加版本号,新加的事件需要更新版本号 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/epmet-module/epmet-common-service/common-service-server/pom.xml b/epmet-module/epmet-common-service/common-service-server/pom.xml index 2c694bbd67..69b16c5a01 100644 --- a/epmet-module/epmet-common-service/common-service-server/pom.xml +++ b/epmet-module/epmet-common-service/common-service-server/pom.xml @@ -116,6 +116,11 @@ false + + https://epmet-dev.elinkservice.cn/estos/ + producerService/producer/sendMsg + 202007161443499985fa2d397436d10356542134c8f008c48 + 52d9d9b0e7d0eb5b8b81c205b579e07c @@ -177,6 +182,11 @@ true + + https://epmet-dev.elinkservice.cn/estos/ + producerService/producer/sendMsg + 202007161443499985fa2d397436d10356542134c8f008c48 + 52d9d9b0e7d0eb5b8b81c205b579e07c diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/EventController.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/EventController.java index a9a8108669..4c3212b878 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/EventController.java +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/EventController.java @@ -17,15 +17,22 @@ package com.epmet.controller; +import com.epmet.commons.tools.config.MqConfig; +import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.utils.SendMqMsgUtils; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.group.AddGroup; import com.epmet.commons.tools.validator.group.UpdateGroup; import com.epmet.dto.form.EventFormDTO; +import com.epmet.dto.result.EventDTO; import com.epmet.service.EventService; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import java.util.Map; + /** * 事件表 @@ -33,12 +40,25 @@ import org.springframework.web.bind.annotation.*; * @author generator generator@elink-cn.com * @since v1.0.0 2020-07-16 */ +@Slf4j @RestController @RequestMapping("event") public class EventController { @Autowired private EventService eventService; + @Autowired + private MqConfig mqConfig; + + @GetMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = eventService.page(params); + return new Result>().ok(page); + } + @GetMapping("geteventclass") + public Result getEventClass(){ + return SendMqMsgUtils.getEventClassList(); + } /** * desc:添加事件,如果已存在则不作任何改动,直接返回成功 diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/EventService.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/EventService.java index fc60058fc2..8e2c4cb635 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/EventService.java +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/EventService.java @@ -18,9 +18,13 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; import com.epmet.dto.form.EventFormDTO; +import com.epmet.dto.result.EventDTO; import com.epmet.entity.EventEntity; +import java.util.Map; + /** * 事件表 * @@ -32,4 +36,6 @@ public interface EventService extends BaseService { void addEvent(EventFormDTO formDTO); void updateEvent(EventFormDTO formDTO); + + PageData page(Map params); } \ No newline at end of file diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/EventServiceImpl.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/EventServiceImpl.java index 53f892b9a5..5fe736adb3 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/EventServiceImpl.java +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/EventServiceImpl.java @@ -17,15 +17,23 @@ package com.epmet.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.dao.EventDao; import com.epmet.dto.form.EventFormDTO; +import com.epmet.dto.result.EventDTO; import com.epmet.entity.EventEntity; import com.epmet.service.EventService; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; +import java.util.Map; + /** * 事件表 * @@ -35,7 +43,14 @@ import org.springframework.stereotype.Service; @Slf4j @Service public class EventServiceImpl extends BaseServiceImpl implements EventService { - + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, EventDTO.class); + } @Override public void addEvent(EventFormDTO formDTO) { EventEntity eventEntity = ConvertUtils.sourceToTarget(formDTO, EventEntity.class); @@ -46,4 +61,12 @@ public class EventServiceImpl extends BaseServiceImpl imp public void updateEvent(EventFormDTO formDTO) { //baseDao.update(eventEntity); } + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } } \ No newline at end of file diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/resources/bootstrap.yml b/epmet-module/epmet-common-service/common-service-server/src/main/resources/bootstrap.yml index 146d5758dd..ec2f2c7a2b 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/resources/bootstrap.yml +++ b/epmet-module/epmet-common-service/common-service-server/src/main/resources/bootstrap.yml @@ -117,4 +117,12 @@ ribbon: #pageHelper分页插件 pagehelper: helper-dialect: mysql - reasonable: false #分页合理化配置,例如输入页码为-1,则自动转化为最小页码1 \ No newline at end of file + reasonable: false #分页合理化配置,例如输入页码为-1,则自动转化为最小页码1 + +#亿联云消息网关 +elink: + mq: + appId: @elink.mq.appId@ #项目接入亿联云的应用Id + token: @elink.mq.token@ #项目接入亿联云的应用token 相当于secret + host: @elink.mq.host@ #亿联云消息网关服务地址 + sendMsgPath: @elink.mq.sendMsgPath@ #发送消息路径 \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResiActInsertLiveFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResiActInsertLiveFormDTO.java index d84b3b4698..42ee3576fe 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResiActInsertLiveFormDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResiActInsertLiveFormDTO.java @@ -90,4 +90,9 @@ public class ResiActInsertLiveFormDTO implements Serializable { * 用户id */ private String userId; + + /** + * id + */ + private String id; } diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/EpmetUserFeignClient.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/EpmetUserFeignClient.java deleted file mode 100644 index c8e1660cd3..0000000000 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/EpmetUserFeignClient.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.epmet.feign; - -import com.epmet.commons.tools.constant.ServiceConstant; -import com.epmet.commons.tools.security.dto.TokenDto; -import com.epmet.commons.tools.utils.Result; -import com.epmet.dto.form.UserRoleFormDTO; -import com.epmet.dto.form.WxUserInfoFormDTO; -import com.epmet.dto.result.UserBaseInfoResultDTO; -import com.epmet.dto.result.UserRoleResultDTO; -import com.epmet.feign.fallback.EpmetUserFeignClientFallBack; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; - -import java.util.List; - - -/** - * 用户模块 - * - * @author zhangyong - * @date 2020/7/22 14:51 - */ -@FeignClient(name = ServiceConstant.EPMET_USER_SERVER, fallback = EpmetUserFeignClientFallBack.class) -public interface EpmetUserFeignClient { - - /** - * @param userIds - * @return com.epmet.commons.tools.utils.Result> - * @author zhangyong - * @description 传入用户id集合,返回用户的基本信息(包含微信基本信息) - * @Date 2020/7/22 9:30 - **/ - @PostMapping("epmetuser/userbaseinfo/queryuserbaseinfo") - Result> heartQueryUserBaseInfo(@RequestBody List userIds); - - /** - * 根据用户ID,查询用户所属角色: 多种身份 - * - * @param userId - * @return com.epmet.commons.tools.utils.Result> - * @Author zhangyong - * @Date 14:13 2020-07-23 - **/ - @PostMapping(value = "epmetuser/userrole/getuserroleinfobyuserid/{userId}", consumes = MediaType.APPLICATION_JSON_VALUE) - Result> getUserRoleInfoByUserId(@PathVariable("userId") String userId); - - /** - * 同步-居民基础信息、用户微信信息 - * - * @param formDTO - * @return com.epmet.commons.tools.utils.Result - * @Author zhangyong - * @Date 14:37 2020-07-23 - **/ - @PostMapping("epmetuser/user/updateUserBaseAndWxUserInfo") - Result updateUserBaseAndWxUserInfo(@RequestBody WxUserInfoFormDTO formDTO); -} diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java deleted file mode 100644 index 1238fceed5..0000000000 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.epmet.feign.fallback; - -import com.epmet.commons.tools.constant.ServiceConstant; -import com.epmet.commons.tools.security.dto.TokenDto; -import com.epmet.commons.tools.utils.ModuleUtils; -import com.epmet.commons.tools.utils.Result; -import com.epmet.dto.form.WxUserInfoFormDTO; -import com.epmet.dto.result.UserBaseInfoResultDTO; -import com.epmet.dto.result.UserRoleResultDTO; -import com.epmet.feign.EpmetUserFeignClient; -import org.springframework.stereotype.Component; - -import java.util.List; - - -/** - * @author zhangyong - * @date 2020/7/22 14:51 - */ -@Component -public class EpmetUserFeignClientFallBack implements EpmetUserFeignClient { - - @Override - public Result> heartQueryUserBaseInfo(List userIds) { - return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "heartQueryUserBaseInfo", userIds); - } - - @Override - public Result> getUserRoleInfoByUserId(String userId) { - return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getUserRoleInfoByUserId", userId); - } - - @Override - public Result updateUserBaseAndWxUserInfo(WxUserInfoFormDTO formDTO) { - return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "updateUserBaseAndWxUserInfo", formDTO); - } -} diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/ActLiveRecDao.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/ActLiveRecDao.java index 61d04aa888..ce9999af87 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/ActLiveRecDao.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/ActLiveRecDao.java @@ -20,7 +20,7 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.dto.ActLivePicDTO; import com.epmet.dto.ActLiveRecDTO; -import com.epmet.dto.form.resi.ResiActContentFormDTO; +import com.epmet.dto.form.resi.ResiActInsertLiveFormDTO; import com.epmet.entity.ActLiveRecEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -55,4 +55,14 @@ public interface ActLiveRecDao extends BaseDao { * @Date 17:04 2020-07-22 **/ List selectListActLiveImg(@Param("liveId") List liveIds); + + /** + * 插入活动实况表 + * + * @param formDTO + * @return void + * @Author zhangyong + * @Date 18:05 2020-07-24 + **/ + void insertActLiveRec(ResiActInsertLiveFormDTO formDTO); } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/ActSignInRecDao.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/ActSignInRecDao.java index 04c13f13cd..ca383df81f 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/ActSignInRecDao.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/ActSignInRecDao.java @@ -18,6 +18,8 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.ActSignInRecDTO; +import com.epmet.dto.form.resi.ResiActSignInFormDTO; import com.epmet.entity.ActSignInRecEntity; import org.apache.ibatis.annotations.Mapper; @@ -29,5 +31,14 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface ActSignInRecDao extends BaseDao { - -} \ No newline at end of file + + /** + * 插入活动签到记录表 + * + * @param dto + * @return void + * @Author zhangyong + * @Date 18:05 2020-07-24 + **/ + void insertActSignInRec(ActSignInRecDTO dto); +} diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/ActLiveRecService.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/ActLiveRecService.java index 4185eedf75..79d95ce9e7 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/ActLiveRecService.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/ActLiveRecService.java @@ -18,19 +18,12 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; -import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; -import com.epmet.dto.ActLiveRecDTO; -import com.epmet.dto.form.resi.ResiActContentFormDTO; import com.epmet.dto.form.resi.ResiActInsertLiveFormDTO; -import com.epmet.dto.form.resi.ResiActSignInFormDTO; import com.epmet.dto.result.resi.ResiActLiveRecResultDTO; import com.epmet.entity.ActLiveRecEntity; -import java.util.List; -import java.util.Map; - /** * 活动实况记录 * diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/ActSignInRecService.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/ActSignInRecService.java index 84aec10141..c2ba4124ce 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/ActSignInRecService.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/ActSignInRecService.java @@ -18,16 +18,11 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; -import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; -import com.epmet.dto.ActSignInRecDTO; import com.epmet.dto.form.resi.ResiActSignInFormDTO; import com.epmet.entity.ActSignInRecEntity; -import java.util.List; -import java.util.Map; - /** * 活动签到记录 * diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActLiveRecServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActLiveRecServiceImpl.java index b5038ce2ab..45e15e53e6 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActLiveRecServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActLiveRecServiceImpl.java @@ -23,8 +23,6 @@ import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.dao.ActLivePicDao; import com.epmet.dao.ActLiveRecDao; -import com.epmet.dao.ActUserLogDao; -import com.epmet.dao.ActUserRelationDao; import com.epmet.dto.ActLivePicDTO; import com.epmet.dto.ActLiveRecDTO; import com.epmet.dto.form.resi.ResiActInsertLiveFormDTO; @@ -32,9 +30,10 @@ import com.epmet.dto.result.UserBaseInfoResultDTO; import com.epmet.dto.result.resi.ResiActLiveRecResultDTO; import com.epmet.entity.ActLivePicEntity; import com.epmet.entity.ActLiveRecEntity; -import com.epmet.feign.EpmetUserFeignClient; +import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.redis.ActLiveRecRedis; import com.epmet.service.ActLiveRecService; +import com.epmet.utils.ValidityVerification; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -54,7 +53,7 @@ public class ActLiveRecServiceImpl extends BaseServiceImpl> userWxInfos = epmetUserFeignClient.heartQueryUserBaseInfo(userIds); + Result> userWxInfos = epmetUserOpenFeignClient.queryUserBaseInfo(userIds); // 根据活动实况id,查询对应实况的图片集合 List actLiveImg = baseDao.selectListActLiveImg(liveIds); // 数据汇总 @@ -99,26 +98,29 @@ public class ActLiveRecServiceImpl extends BaseServiceImpl inSertlive(TokenDto tokenDto, ResiActInsertLiveFormDTO formDTO) { formDTO.setUserId(tokenDto.getUserId()); + // 文本校验 + ValidityVerification verification = new ValidityVerification(); + verification.textScanVerification(formDTO.getDesc(),"添加实况-文本内容审核失败"); + // 图片校验 + verification.imgScanVerification(formDTO.getImages(),"添加实况-图片审核失败"); + // 存储活动实况记录表 - ActLiveRecEntity actLiveRecEntity = new ActLiveRecEntity(); - actLiveRecEntity.setActId(formDTO.getActId()); - actLiveRecEntity.setUserId(formDTO.getUserId()); - actLiveRecEntity.setLongitude(formDTO.getLongitude()); - actLiveRecEntity.setLatitude(formDTO.getLatitude()); - actLiveRecEntity.setAddress(formDTO.getAddress()); - actLiveRecEntity.setDesc(formDTO.getDesc()); - baseDao.insert(actLiveRecEntity); + String uuid = UUID.randomUUID().toString().replaceAll("-",""); + formDTO.setId(uuid); + baseDao.insertActLiveRec(formDTO); //存储活动实况图片 List imgList = formDTO.getImages(); - for (int i = 0; i < imgList.size(); i++) { - String imgUrl = imgList.get(i); - ActLivePicEntity actLivePicEntity = new ActLivePicEntity(); - actLivePicEntity.setLiveId(actLiveRecEntity.getId()); - actLivePicEntity.setPicUrl(imgUrl); - actLivePicEntity.setSort(i + NumConstant.ONE); - actLivePicDao.insert(actLivePicEntity); + if (null != imgList){ + for (int i = 0; i < imgList.size(); i++) { + String imgUrl = imgList.get(i); + ActLivePicEntity actLivePicEntity = new ActLivePicEntity(); + actLivePicEntity.setLiveId(uuid); + actLivePicEntity.setPicUrl(imgUrl); + actLivePicEntity.setSort(i + NumConstant.ONE); + actLivePicDao.insert(actLivePicEntity); + } } - return new Result().ok(actLiveRecEntity.getId()); + return new Result().ok(uuid); } } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActSignInRecServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActSignInRecServiceImpl.java index 5cc716d8b4..4bd516e4f9 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActSignInRecServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActSignInRecServiceImpl.java @@ -25,22 +25,23 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.constant.ActConstant; import com.epmet.dao.ActSignInPicDao; import com.epmet.dao.ActSignInRecDao; -import com.epmet.dao.ActUserLogDao; import com.epmet.dao.ActUserRelationDao; +import com.epmet.dto.ActSignInRecDTO; import com.epmet.dto.ActUserRelationDTO; import com.epmet.dto.form.resi.ResiActInsertLiveFormDTO; import com.epmet.dto.form.resi.ResiActSignInFormDTO; import com.epmet.entity.ActSignInPicEntity; import com.epmet.entity.ActSignInRecEntity; -import com.epmet.entity.ActUserLogEntity; import com.epmet.redis.ActSignInRecRedis; import com.epmet.service.ActLiveRecService; import com.epmet.service.ActSignInRecService; +import com.epmet.utils.ValidityVerification; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.List; +import java.util.UUID; /** * 活动签到记录 @@ -57,9 +58,6 @@ public class ActSignInRecServiceImpl extends BaseServiceImpl inSertlive = actLiveRecService.inSertlive(tokenDto, liveFormDTO); - liveId = inSertlive.getData(); + //实况id, 当sync_live=1时此列有值 + dto.setLiveId(inSertlive.getData()); } - // 存储活动签到记录表 - ActSignInRecEntity actSignInRecEntity = new ActSignInRecEntity(); - actSignInRecEntity.setActId(formDTO.getActId()); - actSignInRecEntity.setUserId(formDTO.getUserId()); - actSignInRecEntity.setLongitude(formDTO.getLongitude()); - actSignInRecEntity.setLatitude(formDTO.getLatitude()); - actSignInRecEntity.setAddress(formDTO.getAddress()); - actSignInRecEntity.setDesc(formDTO.getDesc()); - actSignInRecEntity.setSyncLive(formDTO.getSyncLive()); - actSignInRecEntity.setLiveId(liveId); - baseDao.insert(actSignInRecEntity); + String uuid = UUID.randomUUID().toString().replaceAll("-",""); + dto.setId(uuid); + baseDao.insertActSignInRec(dto); //存储活动签到图片 List imgList = formDTO.getImages(); - for (int i = 0; i < imgList.size(); i++) { - String imgUrl = imgList.get(i); - ActSignInPicEntity actLivePicEntity = new ActSignInPicEntity(); - actLivePicEntity.setSignInId(actSignInRecEntity.getId()); - actLivePicEntity.setPicUrl(imgUrl); - actLivePicEntity.setSort(i + NumConstant.ONE); - actSignInPicDao.insert(actLivePicEntity); + if (null != imgList){ + for (int i = 0; i < imgList.size(); i++) { + String imgUrl = imgList.get(i); + ActSignInPicEntity actLivePicEntity = new ActSignInPicEntity(); + actLivePicEntity.setSignInId(uuid); + actLivePicEntity.setPicUrl(imgUrl); + actLivePicEntity.setSort(i + NumConstant.ONE); + actSignInPicDao.insert(actLivePicEntity); + } } return new Result(); } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActUserRelationServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActUserRelationServiceImpl.java index d1782fc0f8..53bc8a11f0 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActUserRelationServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActUserRelationServiceImpl.java @@ -42,7 +42,7 @@ import com.epmet.dto.result.UserRoleResultDTO; import com.epmet.entity.ActUserLogEntity; import com.epmet.entity.ActUserRelationEntity; import com.epmet.entity.HeartUserInfoEntity; -import com.epmet.feign.EpmetUserFeignClient; +import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.redis.ActUserRelationRedis; import com.epmet.service.ActInfoService; import com.epmet.service.ActUserLogService; @@ -76,7 +76,7 @@ public class ActUserRelationServiceImpl extends BaseServiceImpl0 当前用户是志愿者 + Integer volunteerFlag = volunteerInfoDao.queryVolunteerFlagByUserId(formDTO.getActId()); if (actInfoDTO.getVolunteerLimit()){ - // 活动只能志愿者参加 - Integer volunteerFlag = volunteerInfoDao.queryVolunteerFlagByUserId(formDTO.getUserId()); - if (volunteerFlag > NumConstant.ZERO){ - satisfy = true; - } else { - logger.info("活动报名失败,请先认证志愿者"); - throw new RenException(EpmetErrorCode.NON_CERTIFIED_VOLUNTEER.getCode()); - } + // 活动只能志愿者参加, 当前用户是否满足条件 + satisfy = this.volunteerParticipationAct(volunteerFlag); } else { - // 活动不限制志愿者身份,但要求是 居民身份 - Result> userRoleInfo = epmetUserFeignClient.getUserRoleInfoByUserId(formDTO.getUserId()); - for (UserRoleResultDTO roleResultDTO :userRoleInfo.getData()){ - if (EpmetRoleKeyConstant.REGISTERED_RESI.equals(roleResultDTO.getRoleKey())){ - satisfy = true; - } - } - if (!satisfy){ - logger.info("活动报名失败,请完善居民信息"); - throw new RenException(EpmetErrorCode.CANNOT_AUDIT_WARM.getCode()); - } + // 活动不限制志愿者身份,但要求是 居民身份, 当前用户是否满足条件 + satisfy = this.resiParticipationAct(formDTO.getUserId()); } if (satisfy){ - this.actStartSignUp(actInfoDTO, formDTO); + // 开始报名 + this.actStartSignUp(actInfoDTO, formDTO, volunteerFlag); } return new Result(); } - private void actStartSignUp(ActInfoDTO actInfoDTO, ResiActRegistrationFormDTO formDTO){ + /** + * 开始报名活动 + * + * @param actInfoDTO 活动详情 + * @param formDTO 接口请求入参 + * @param volunteerFlag >0 当前用户是志愿者 + * @return void + * @Author zhangyong + * @Date 15:31 2020-07-24 + **/ + private void actStartSignUp(ActInfoDTO actInfoDTO, ResiActRegistrationFormDTO formDTO, Integer volunteerFlag){ boolean signUp = true; Integer auditingNum = actUserLogService.countActTimesOfParticipation(formDTO.getUserId()); if (auditingNum > NumConstant.ZERO){ @@ -246,7 +244,7 @@ public class ActUserRelationServiceImpl extends BaseServiceImpl NumConstant.ZERO); entity.setKindnessTime(NumConstant.ZERO); entity.setParticipationNum(NumConstant.ZERO); entity.setObtainPointNum(NumConstant.ZERO); @@ -264,8 +262,53 @@ public class ActUserRelationServiceImpl extends BaseServiceImpl NumConstant.ZERO){ + satisfy = true; + return satisfy; + } else { + logger.info("活动报名失败,请先认证志愿者"); + throw new RenException(EpmetErrorCode.NON_CERTIFIED_VOLUNTEER.getCode()); + } + } + + /** + * 活动报名,不限制志愿者身份,但要求是 居民身份。当前用户是否符合 + * @param userId + * @return boolean + * @Author zhangyong + * @Date 15:04 2020-07-24 + **/ + private boolean resiParticipationAct(String userId){ + boolean satisfy = false; + // 活动不限制志愿者身份,但要求是 居民身份 + Result> userRoleInfo = epmetUserOpenFeignClient.getUserRoleInfoByUserId(userId); + if (userRoleInfo.success()){ + for (UserRoleResultDTO roleResultDTO :userRoleInfo.getData()){ + if (EpmetRoleKeyConstant.REGISTERED_RESI.equals(roleResultDTO.getRoleKey())){ + satisfy = true; + } + } + } + if (!satisfy){ + logger.info("活动报名失败,请完善居民信息"); + throw new RenException(EpmetErrorCode.CANNOT_AUDIT_WARM.getCode()); + } else { + return satisfy; + } + } } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/HeartUserInfoServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/HeartUserInfoServiceImpl.java index fead42e055..a8d0dfacfe 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/HeartUserInfoServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/HeartUserInfoServiceImpl.java @@ -20,21 +20,24 @@ package com.epmet.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; -import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.utils.Result; import com.epmet.dao.HeartUserInfoDao; import com.epmet.dto.HeartUserInfoDTO; -import com.epmet.dto.UserWechatDTO; import com.epmet.dto.form.resi.ResiActBaseFormDTO; import com.epmet.dto.result.UserBaseInfoResultDTO; import com.epmet.dto.result.resi.ResiLeaderboardResultDTO; import com.epmet.entity.HeartUserInfoEntity; -import com.epmet.feign.EpmetUserFeignClient; +import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.redis.HeartUserInfoRedis; import com.epmet.service.HeartUserInfoService; import org.apache.commons.lang3.StringUtils; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -52,11 +55,11 @@ import java.util.Map; */ @Service public class HeartUserInfoServiceImpl extends BaseServiceImpl implements HeartUserInfoService { - + private Logger logger = LogManager.getLogger(HeartUserInfoServiceImpl.class); @Autowired private HeartUserInfoRedis heartUserInfoRedis; @Autowired - private EpmetUserFeignClient epmetUserFeignClient; + private EpmetUserOpenFeignClient epmetUserOpenFeignClient; @Override public PageData page(Map params) { @@ -124,28 +127,35 @@ public class HeartUserInfoServiceImpl extends BaseServiceImpl> leaderboard(ResiActBaseFormDTO formDTO) { + List resultDTOS = new ArrayList<>(); // 获取排好序的 排行榜 List leaderboardList = baseDao.selectListLeaderboard(formDTO); - // 根据用户ID获取微信昵称、头像 - List userIds = new ArrayList<>(); - for (HeartUserInfoDTO list : leaderboardList){ - userIds.add(list.getUserId()); - } - // 查询用户微信基础信息 - Result> userWxInfos = epmetUserFeignClient.heartQueryUserBaseInfo(userIds); - - List resultDTOS = new ArrayList<>(); - for (HeartUserInfoDTO list : leaderboardList){ - ResiLeaderboardResultDTO dto = new ResiLeaderboardResultDTO(); - dto.setKindnessTime(list.getKindnessTime()); - dto.setVolunteerFlag(list.getVolunteerFlag()); - dto.setParticipationNum(list.getParticipationNum()); - List wxInfo = userWxInfos.getData(); - for (UserBaseInfoResultDTO wx : wxInfo){ - if (list.getUserId().equals(wx.getUserId())){ - dto.setHeadImg(wx.getHeadImgUrl()); - dto.setNickname(wx.getNickname()); + if (leaderboardList.size() > NumConstant.ZERO){ + // 根据用户ID获取微信昵称、头像 + List userIds = new ArrayList<>(); + for (HeartUserInfoDTO list : leaderboardList){ + userIds.add(list.getUserId()); + } + // 查询用户微信基础信息 + Result> userWxInfos = epmetUserOpenFeignClient.queryUserBaseInfo(userIds); + if (userWxInfos.success() && userWxInfos.getData().size() > NumConstant.ZERO){ + for (HeartUserInfoDTO list : leaderboardList){ + ResiLeaderboardResultDTO dto = new ResiLeaderboardResultDTO(); + dto.setKindnessTime(list.getKindnessTime()); + dto.setVolunteerFlag(list.getVolunteerFlag()); + dto.setParticipationNum(list.getParticipationNum()); + List wxInfo = userWxInfos.getData(); + for (UserBaseInfoResultDTO wx : wxInfo){ + if (list.getUserId().equals(wx.getUserId())){ + dto.setHeadImg(wx.getHeadImgUrl()); + dto.setNickname(wx.getNickname()); + } + } + resultDTOS.add(dto); } + } else { + logger.info("查询用户基本信息接口返回失败"); + throw new RenException("查询用户基本信息失败"); } } return new Result>().ok(resultDTOS); diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/VolunteerInfoServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/VolunteerInfoServiceImpl.java index 84e78622c8..3429acbb2f 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/VolunteerInfoServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/VolunteerInfoServiceImpl.java @@ -17,34 +17,24 @@ package com.epmet.service.impl; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.constant.NumConstant; -import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.ConvertUtils; -import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.utils.Result; import com.epmet.dao.VolunteerInfoDao; import com.epmet.dto.HeartUserInfoDTO; -import com.epmet.dto.VolunteerInfoDTO; import com.epmet.dto.form.WxUserInfoFormDTO; import com.epmet.dto.form.resi.ResiVolunteerAuthenticateFormDTO; import com.epmet.entity.VolunteerInfoEntity; -import com.epmet.feign.EpmetUserFeignClient; +import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.redis.VolunteerInfoRedis; import com.epmet.service.HeartUserInfoService; import com.epmet.service.VolunteerInfoService; -import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.Arrays; -import java.util.List; -import java.util.Map; - /** * 志愿者信息 * @@ -58,7 +48,7 @@ public class VolunteerInfoServiceImpl extends BaseServiceImpl imgList){ + public void imgScanVerification(List imgList, String businessEnum){ if (NumConstant.ZERO != imgList.size()){ ImgScanParamDTO imgScanParamDTO = new ImgScanParamDTO(); imgList.forEach(url -> { @@ -82,6 +84,8 @@ public class ValidityVerification { throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); } else { if (!imgScanResult.getData().isAllPass()) { + // 业务枚举:例如:评论话题失败,评论内容为:%s" + log.error(String.format(businessEnum)); throw new RenException(EpmetErrorCode.IMG_SCAN_FAILED.getCode()); } } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/bootstrap.yml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/bootstrap.yml index 8571a47da1..72477fb20d 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/bootstrap.yml +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/bootstrap.yml @@ -118,17 +118,19 @@ pagehelper: helper-dialect: mysql reasonable: false #分页合理化配置,例如输入页码为-1,则自动转化为最小页码1 -#亿联云消息网关 -elink: - mq: - appId: @elink.mq.appId@ #项目接入亿联云的应用Id - token: @elink.mq.token@ #项目接入亿联云的应用token 相当于secret - host: @elink.mq.host@ #亿联云消息网关服务地址 - sendMsgPath: @elink.mq.sendMsgPath@ #发送消息路径 + openapi: scan: server: url: @openapi.scan.server.url@ method: imgSyncScan: /imgSyncScan - textSyncScan: /textSyncScan \ No newline at end of file + textSyncScan: /textSyncScan + +#亿联云消息网关 +elink: + mq: + appId: @elink.mq.appId@ #项目接入亿联云的应用Id + token: @elink.mq.token@ #项目接入亿联云的应用token 相当于secret + host: @elink.mq.host@ #亿联云消息网关服务地址 + sendMsgPath: @elink.mq.sendMsgPath@ #发送消息路径 \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActInfoDao.xml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActInfoDao.xml index 368115e3e2..4686b14efc 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActInfoDao.xml +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActInfoDao.xml @@ -450,12 +450,12 @@ resultType="java.lang.Integer"> SELECT COUNT(1) - FROM act_info - WHERE DEL_FLAG = '0' - AND USER_ID = #{userId} - AND ACT_STATUS = 'published' - AND ((#{actStartTime} BETWEEN ACT_START_TIME AND ACT_END_TIME OR #{actEndTime} BETWEEN ACT_START_TIME AND ACT_END_TIME) - or (ACT_START_TIME BETWEEN #{actStartTime} AND #{actEndTime} OR ACT_END_TIME BETWEEN #{actStartTime} AND #{actEndTime})); + FROM act_info i LEFT JOIN act_user_relation r ON i.ID = r.ACT_ID + WHERE i.DEL_FLAG = '0' + AND r.USER_ID = #{userId} + AND i.ACT_STATUS = 'published' + AND ((#{actStartTime} BETWEEN i.ACT_START_TIME AND i.ACT_END_TIME OR #{actEndTime} BETWEEN i.ACT_START_TIME AND i.ACT_END_TIME) + or (i.ACT_START_TIME BETWEEN #{actStartTime} AND #{actEndTime} OR i.ACT_END_TIME BETWEEN #{actStartTime} AND #{actEndTime})); diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActLiveRecDao.xml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActLiveRecDao.xml index 6e0281baf5..6b3c8d92ea 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActLiveRecDao.xml +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActLiveRecDao.xml @@ -48,4 +48,35 @@ order by SORT asc + + + INSERT INTO act_live_rec ( + ID, + ACT_ID, + USER_ID, + LONGITUDE, + LATITUDE, + ADDRESS, + `DESC`, + DEL_FLAG, + REVISION, + CREATED_BY, + CREATED_TIME, + UPDATED_BY, + UPDATED_TIME) + VALUES + ( #{id}, + #{actId}, + #{userId}, + #{longitude}, + #{latitude}, + #{address}, + #{desc}, + 0, + 0, + #{userId}, + now(), + #{userId}, + now()) + diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActSignInRecDao.xml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActSignInRecDao.xml index 6ac88d72a1..c1e6956935 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActSignInRecDao.xml +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActSignInRecDao.xml @@ -21,5 +21,38 @@ - - \ No newline at end of file + + INSERT INTO act_sign_in_rec ( + ID, + ACT_ID, + USER_ID, + LONGITUDE, + LATITUDE, + ADDRESS, + `DESC`, + SYNC_LIVE, + LIVE_ID, + DEL_FLAG, + REVISION, + CREATED_BY, + CREATED_TIME, + UPDATED_BY, + UPDATED_TIME) + VALUES + ( #{id}, + #{actId}, + #{userId}, + #{longitude}, + #{latitude}, + #{address}, + #{desc}, + #{syncLive}, + #{liveId}, + 0, + 0, + #{userId}, + now(), + #{userId}, + now()) + + diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/HeartUserInfoDao.xml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/HeartUserInfoDao.xml index 107007c2dc..3a9473fa15 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/HeartUserInfoDao.xml +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/HeartUserInfoDao.xml @@ -45,8 +45,7 @@ resultType="com.epmet.dto.HeartUserInfoDTO"> SELECT ui.USER_ID userId, - volunteerFlag, - IF(ui.VOLUNTEER_FLAG = 1, true , false ) + ui.VOLUNTEER_FLAG volunteerFlag, ui.KINDNESS_TIME kindnessTime, ui.PARTICIPATION_NUM participationNum FROM heart_user_info ui diff --git a/epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/feign/OssFeignClient.java b/epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/feign/OssFeignClient.java index 1a64ebab62..a22f95bf71 100644 --- a/epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/feign/OssFeignClient.java +++ b/epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/feign/OssFeignClient.java @@ -8,6 +8,7 @@ package com.epmet.feign; +import com.epmet.commons.tools.constant.ServiceConstant; import feign.codec.Encoder; import feign.form.spring.SpringFormEncoder; import com.epmet.commons.tools.utils.Result; @@ -25,7 +26,7 @@ import org.springframework.web.multipart.MultipartFile; * @author Mark sunlightcs@gmail.c om * @since 1.1.0 */ -@FeignClient(name = "renren-oss-server", configuration = OssFeignClient.MultipartSupportConfig.class) +@FeignClient(name = ServiceConstant.EPMET_OSS_SERVER, configuration = OssFeignClient.MultipartSupportConfig.class) public interface OssFeignClient { /** * 文件上传 diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/CodeOperationHistoryDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/CodeOperationHistoryDTO.java index c668daeaea..65fa58f1cd 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/CodeOperationHistoryDTO.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/CodeOperationHistoryDTO.java @@ -61,7 +61,7 @@ public class CodeOperationHistoryDTO implements Serializable { /** * 描述 */ - private String describe; + private String description; /** * 乐观锁 diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/AuthResultRecordFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/AuthResultRecordFormDTO.java new file mode 100644 index 0000000000..6223eafc66 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/AuthResultRecordFormDTO.java @@ -0,0 +1,86 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * @Author zxc + * @CreateTime 2020/7/24 9:22 + */ +@Data +public class AuthResultRecordFormDTO implements Serializable { + + private static final long serialVersionUID = -5359209459022630868L; + + /** + * ID + */ + private String id; + + /** + * 客户ID + */ + private String customerId; + + /** + * resi:居民端,work:工作端 + */ + private String clientType; + + /** + * 第三方平台AppId 第三方平台AppId + */ + private String componentAppId; + + /** + * 微信返回创建时间 微信返回创建时间 + */ + private Date wechatCreateTime; + + /** + * 通知类型 + */ + private String InfoType; + + /** + * 授权方AppId + */ + private String AuthorizerAppid; + + /** + * 授权码(auth_code) + */ + private String AuthorizationCode; + + /** + * 授权码过期时间 + */ + private Date ExpiredTime; + + /** + * 预授权码 + */ + private String PreAuthCode; + + /** + * 删除状态 + */ + private Integer delFlag = 0; + + /** + * 乐观锁 + */ + private Integer revision = 0; + + /** + * 创建人 + */ + private String createdBy = "APP_USER"; + + /** + * 更新人 + */ + private String updatedBy = "APP_USER"; +} diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/AuthorizationInfoFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/AuthorizationInfoFormDTO.java index 2004536f1c..1340896baf 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/AuthorizationInfoFormDTO.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/AuthorizationInfoFormDTO.java @@ -44,6 +44,11 @@ public class AuthorizationInfoFormDTO implements Serializable { */ private String clientType; + /** + * 权限列表 + */ + private String funcInfo; + private Integer delFlag = 0; private String createdBy = "APP_USER"; diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/AuthorizerAccessTokenFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/AuthorizerAccessTokenFormDTO.java index 2e5528ea64..08f038f317 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/AuthorizerAccessTokenFormDTO.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/AuthorizerAccessTokenFormDTO.java @@ -34,6 +34,11 @@ public class AuthorizerAccessTokenFormDTO implements Serializable { */ private String authAppid; + /** + * 客户端类型:resi居民端,work:工作端 + */ + private String clientType; + /** * 客户ID */ diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/SubmitAuditFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/SubmitAuditFormDTO.java index e88d58e3f9..82867159cf 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/SubmitAuditFormDTO.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/SubmitAuditFormDTO.java @@ -43,84 +43,100 @@ public class SubmitAuditFormDTO implements Serializable { /** * 用户生成内容场景(UGC)信息安全声明 */ - private List ugcDeclare; + private UgcDeclareBean ugcDeclare; @NoArgsConstructor @Data - private static class ItemListBean { + public static class ItemListBean { /** * 小程序的页面,可通过获取小程序的页面列表接口获得 */ + @SerializedName("address") private String address; /** * 小程序的标签,用空格分隔,标签至多 10 个,标签长度至多 20 */ + @SerializedName("tag") private String tag; /** * 一级类目名称 */ + @SerializedName("first_class") private String firstClass; /** * 二级类目名称 */ + @SerializedName("second_class") private String secondClass; /** * 三级类目名称 */ + @SerializedName("third_class") private String thirdClass; /** * 一级类目的 ID */ + @SerializedName("first_id") private String firstId; /** * 二级类目的 ID */ + @SerializedName("second_id") private String secondId; /** * 三级类目的 ID */ + @SerializedName("third_id") private String thirdId; /** * 小程序页面的标题,标题长度至多 32 */ + @SerializedName("title") private String title; } @NoArgsConstructor @Data - private static class PreviewInfoBean { + public static class PreviewInfoBean { /** * 录屏mediaid列表,可以通过提审素材上传接口获得 */ + @SerializedName("Video_id_list") private List videoIdList; /** * 截屏mediaid列表,可以通过提审素材上传接口获得 */ + @SerializedName("pic_id_list") private List picIdList; } @NoArgsConstructor @Data - private static class UgcDeclareBean { + public static class UgcDeclareBean { /** * UGC场景 0,不涉及用户生成内容, 1.用户资料,2.图片,3.视频,4.文本,5其他, 可多选,当scene填0时无需填写下列字段 */ + @SerializedName("scene") private List scene; /** * 当scene选其他时的说明,不超时256字 */ + @SerializedName("other_scene_desc") private String otherSceneDesc; /** * 内容安全机制 1.使用平台建议的内容安全API,2.使用其他的内容审核产品,3.通过人工审核把关,4.未做内容审核把关 */ + @SerializedName("method") private List method; /** * 是否有审核团队, 0.无,1.有,默认0 */ + @SerializedName("has_audit_team") private Integer hasAuditTeam; /** * 说明当前对UGC内容的审核机制,不超过256字 */ + @SerializedName("audit_desc") private String auditDesc; } } diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/UploadListFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/UploadListFormDTO.java index 64f3483f55..64a2b42e87 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/UploadListFormDTO.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/UploadListFormDTO.java @@ -38,9 +38,9 @@ public class UploadListFormDTO implements Serializable { /** * 页数 */ - private Integer page; + private Integer pageNo; /** * 页面条数 */ - private Integer limit; + private Integer pageSize; } diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/RegisterResultDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/RegisterResultDTO.java new file mode 100644 index 0000000000..2198a52459 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/RegisterResultDTO.java @@ -0,0 +1,31 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author sun + * @Description 公众号-手机号注册-接口返参 + */ +@Data +public class RegisterResultDTO implements Serializable { + + private static final long serialVersionUID = 3253989119352850315L; + + /** + * userId + */ + private String userId; + + /** + * 用户微信openid + */ + private String openId; + + /** + * 用户微信unionId + */ + private String unionId; + +} diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/EpmetThirdFeignClient.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/EpmetThirdFeignClient.java index 5a91825392..ff62e37885 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/EpmetThirdFeignClient.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/EpmetThirdFeignClient.java @@ -3,12 +3,10 @@ package com.epmet.feign; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.UserWechatDTO; +import com.epmet.dto.form.RegisterFormDTO; import com.epmet.dto.form.SaveUserVisitedFormDTO; import com.epmet.dto.form.WxLoginFormDTO; -import com.epmet.dto.result.CustomerUserResultDTO; -import com.epmet.dto.result.InitCustomerResultDTO; -import com.epmet.dto.result.PublicCustomerResultDTO; -import com.epmet.dto.result.SaveUserResultDTO; +import com.epmet.dto.result.*; import com.epmet.feign.fallback.EpmetThirdFeignClientFallback; import me.chanjar.weixin.mp.bean.result.WxMpUser; import org.springframework.cloud.openfeign.FeignClient; @@ -106,4 +104,13 @@ public interface EpmetThirdFeignClient { **/ @PostMapping(value = "third/customermp/getcustomermsg/{appId}") Result getCustomerMsg(@PathVariable("appId") String appId); + + /** + * @param formDTO + * @return + * @Author sun + * @Description 用户登陆,新增访问记录数据 + **/ + @PostMapping(value = "third/pacustomer/register") + Result register(@RequestBody RegisterFormDTO formDTO); } diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/fallback/EpmetThirdFeignClientFallback.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/fallback/EpmetThirdFeignClientFallback.java index fda713210f..d3d97faa1a 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/fallback/EpmetThirdFeignClientFallback.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/fallback/EpmetThirdFeignClientFallback.java @@ -4,12 +4,10 @@ import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.ModuleUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.UserWechatDTO; +import com.epmet.dto.form.RegisterFormDTO; import com.epmet.dto.form.SaveUserVisitedFormDTO; import com.epmet.dto.form.WxLoginFormDTO; -import com.epmet.dto.result.CustomerUserResultDTO; -import com.epmet.dto.result.InitCustomerResultDTO; -import com.epmet.dto.result.PublicCustomerResultDTO; -import com.epmet.dto.result.SaveUserResultDTO; +import com.epmet.dto.result.*; import com.epmet.feign.EpmetThirdFeignClient; import me.chanjar.weixin.mp.bean.result.WxMpUser; import org.springframework.stereotype.Component; @@ -65,4 +63,9 @@ public class EpmetThirdFeignClientFallback implements EpmetThirdFeignClient { public Result getCustomerMsg(String appId) { return ModuleUtils.feignConError(ServiceConstant.EPMET_THIRD_SERVER, "getCustomerMsg", appId); } + + @Override + public Result register(RegisterFormDTO formDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_THIRD_SERVER, "register", formDTO); + } } diff --git a/epmet-module/epmet-third/epmet-third-server/deploy/docker-compose-dev.yml b/epmet-module/epmet-third/epmet-third-server/deploy/docker-compose-dev.yml index 494df190a6..de278b5785 100644 --- a/epmet-module/epmet-third/epmet-third-server/deploy/docker-compose-dev.yml +++ b/epmet-module/epmet-third/epmet-third-server/deploy/docker-compose-dev.yml @@ -2,7 +2,7 @@ version: "3.7" services: epmet-third-server: container_name: epmet-third-server-dev - image: 192.168.1.130:10080/epmet-cloud-dev/epmet-third-server:0.0.39 + image: 192.168.1.130:10080/epmet-cloud-dev/epmet-third-server:0.0.48 ports: - "8110:8110" network_mode: host # 使用现有网络 diff --git a/epmet-module/epmet-third/epmet-third-server/pom.xml b/epmet-module/epmet-third/epmet-third-server/pom.xml index 6c831bfb2f..2efc3df332 100644 --- a/epmet-module/epmet-third/epmet-third-server/pom.xml +++ b/epmet-module/epmet-third/epmet-third-server/pom.xml @@ -2,7 +2,7 @@ 4.0.0 - 0.0.39 + 0.0.48 com.epmet @@ -135,6 +135,12 @@ 2.0.0 compile + + com.epmet + epmet-oss-client + 2.0.0 + compile + diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ModuleConstant.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ModuleConstant.java index 5e72094a57..d787e30ed1 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ModuleConstant.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ModuleConstant.java @@ -22,9 +22,12 @@ public interface ModuleConstant { String AUTHORIZATION_CODE_HUMP = "AuthorizationCode"; String UNAUTHORIZED = "unauthorized"; String AUTHORIZED = "authorized"; + String UPDATE_AUTHORIZED = "updateauthorized"; String NULL_CHAR = ""; String SUCCESS = "success"; String AUTHORIZER_APP_ID_HUMP = "AuthorizerAppid"; + String PRE_AUTH_CODE_HUMP = "PreAuthCode"; + String AUTHORIZATION_CODE_EXPIRED_TIME = "AuthorizationCodeExpiredTime"; // 获取 component_access_token 如下 String COMPONENT_APPID = "component_appid"; @@ -65,7 +68,7 @@ public interface ModuleConstant { String COMPONENT_APP_ID = "component_appid"; String AUTHORIZER_APP_ID = "authorizer_appid"; String AUTHORIZER_INFO = "authorizer_info"; - String MINI_PROGRAM_INFO = "miniprograminfo"; + String MINI_PROGRAM_INFO = "MiniProgramInfo"; String BUSINESS_INFO = "business_info"; String CATEGORIES = "categories"; String NETWORK = "network"; diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/PaConstant.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/PaConstant.java index cbed19f1c2..4651738fd4 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/PaConstant.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/PaConstant.java @@ -22,6 +22,14 @@ public interface PaConstant { * 保存用户访问记录数据失败 */ String SAVE_VISITED_EXCEPTION = "保存用户访问记录数据失败"; + /** + * 保存用户数据失败 + */ + String SAVE_USER_EXCEPTION = "保存用户数据失败"; + /** + * 保存用户微信基本数据失败 + */ + String SAVE_WECHAT_EXCEPTION = "保存用户微信信息失败"; /** * 组织级别对应的key、name diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ThirdRedisKeyConstant.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ThirdRedisKeyConstant.java index 13fa20c226..c6cbaa6894 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ThirdRedisKeyConstant.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ThirdRedisKeyConstant.java @@ -44,7 +44,7 @@ public interface ThirdRedisKeyConstant { /** * authorization_info 授权信息 */ - String AUTH_INFO_REDIS_KEY = "epmet:wechartthird:authinfo"; + String AUTH_INFO_REDIS_KEY = "epmet:wechartthird:authinfo:"; } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ThirdRunTimeInfoConstant.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ThirdRunTimeInfoConstant.java index 2e4e5e7083..b7dc98d4b4 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ThirdRunTimeInfoConstant.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ThirdRunTimeInfoConstant.java @@ -46,7 +46,7 @@ public interface ThirdRunTimeInfoConstant { String END_GET_AUTH_INFO = "=====================结束获取【authorization_info】====================="; - String CREATE_AND_BIND_SUCCESS = "创建开放平台帐号并绑定公众号/小程序"; + String CREATE_AND_BIND_SUCCESS = "开始创建开放平台帐号并绑定公众号/小程序"; String BIND_SUCCESS = "绑定公众号/小程序到开放平台"; @@ -82,4 +82,6 @@ public interface ThirdRunTimeInfoConstant { String VERIFY_TICKET = "msgSignature = %s, timeStamp = %s, nonce = %s, encryptType = %s, signature = %s"; + String REFRESH_AUTH_ACCESS_TOKEN = "查询到新的 授权方【access_token】"; + } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CodeController.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CodeController.java index c24e502e47..e2b7901ed6 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CodeController.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CodeController.java @@ -49,7 +49,7 @@ public class CodeController { * @date 2020/7/17 16:22 */ @PostMapping("getextjson") - public Result getExtJson(CodeUploadFormDTO formDTO) { + public Result getExtJson(@RequestBody CodeUploadFormDTO formDTO) { String extJson = codeService.getExtJson(formDTO); return new Result().ok(extJson); } @@ -175,7 +175,7 @@ public class CodeController { * @date 2020/7/17 11:20 */ @PostMapping("mediaupload") - public Result mediaUpload(@RequestBody MediaUploadFormDTO formDTO) { + public Result mediaUpload(MediaUploadFormDTO formDTO) { String result = codeService.mediaUpload(formDTO); return new Result().ok(result); } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PaCustomerController.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PaCustomerController.java index 519a1a4cc4..8ed2ff7fd9 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PaCustomerController.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PaCustomerController.java @@ -45,11 +45,8 @@ public class PaCustomerController { * @Description 公众号-手机号注册 **/ @PostMapping("register") - public Result register(@LoginUser TokenDto tokenDTO, @RequestBody RegisterFormDTO formDTO) { - ValidatorUtils.validateEntity(formDTO, RegisterFormDTO.AddUserInternalGroup.class, RegisterFormDTO.AddUserShowGroup.class); - formDTO.setUserId(tokenDTO.getUserId()); - paCustomerService.register(formDTO); - return new Result(); + public Result register(@RequestBody RegisterFormDTO formDTO) { + return new Result().ok(paCustomerService.register(formDTO)); } /** diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/AuthResultRecordDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/AuthResultRecordDao.java index ca98874003..42bb397220 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/AuthResultRecordDao.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/AuthResultRecordDao.java @@ -18,6 +18,7 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.form.AuthResultRecordFormDTO; import com.epmet.entity.AuthResultRecordEntity; import org.apache.ibatis.annotations.Mapper; @@ -29,5 +30,12 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface AuthResultRecordDao extends BaseDao { + + /** + * @Description 插入授权结果记录 + * @param formDTO + * @author zxc + */ + void insertAuthResultRecord(AuthResultRecordFormDTO formDTO); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/AuthorizationInfoDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/AuthorizationInfoDao.java index 3e98b5a623..f4fde172f6 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/AuthorizationInfoDao.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/AuthorizationInfoDao.java @@ -21,6 +21,7 @@ import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.dto.AuthorizationInfoDTO; import com.epmet.dto.form.AuthorizationInfoFormDTO; import com.epmet.dto.form.AuthorizerAccessTokenFormDTO; +import com.epmet.dto.result.AuthCodeResultDTO; import com.epmet.dto.result.WillOverDueResultDTO; import com.epmet.entity.AuthorizationInfoEntity; import org.apache.ibatis.annotations.Mapper; @@ -44,13 +45,6 @@ public interface AuthorizationInfoDao extends BaseDao { */ void insertAuthorizationInfo(AuthorizationInfoFormDTO formDTO); - /** - * @Description 逻辑删除授权信息 - * @param customerId - * @author zxc - */ - void updateOldAuthorizationInfo(@Param("customerId")String customerId); - /** * 根据客户ID,客户端类型获取授权信息 * @author zhaoqifeng @@ -60,7 +54,13 @@ public interface AuthorizationInfoDao extends BaseDao { * @return com.epmet.dto.AuthorizationInfoDTO */ AuthorizationInfoDTO getAuthInfoByCustomer(@Param("customerId") String customerId, @Param("clientType") String clientType); - void updateOldAuthorizationInfo(@Param("customerId")String customerId,@Param("clientType")String clientType); + + /** + * @Description 逻辑删除授权信息 + * @param authAppId + * @author zxc + */ + void updateOldAuthorizationInfo(@Param("authAppId")String authAppId); /** * @Description 查询即将过期的 authorizer_access_token @@ -83,4 +83,11 @@ public interface AuthorizationInfoDao extends BaseDao { */ void updateOldAuthorizerAccessToken(@Param("customerId")String customerId,@Param("clientType")String clientType); + /** + * @Description 根据 authAppId 查询客户ID和客户端类型 + * @param authAppId + * @author zxc + */ + AuthCodeResultDTO selectCustomerIdByAuthAppId(@Param("authAppId")String authAppId); + } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ComponentVerifyTicketDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ComponentVerifyTicketDao.java index 9c29569f0e..87cb38b046 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ComponentVerifyTicketDao.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ComponentVerifyTicketDao.java @@ -39,10 +39,10 @@ public interface ComponentVerifyTicketDao extends BaseDao { * @param customerId * @author zxc */ - Integer selectAuthCount(@Param("customerId")String customerId); + List selectAuthCount(@Param("customerId")String customerId); /** * @Description 回填customer_mp的appId @@ -107,4 +107,12 @@ public interface CustomerMpDao extends BaseDao { * @Description 根据appId查询客户信息 **/ PaCustomerDTO selectCustomerByAppId(@Param("appId") String appId); + + /** + * @Description 校验此小程序是不是绑定别的客户端 + * @param authAppId + * @param clientType + * @author zxc + */ + Integer checkBind(String authAppId,String clientType); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/OpenPlatformAccountDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/OpenPlatformAccountDao.java index 2ec5ef1588..00913eac71 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/OpenPlatformAccountDao.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/OpenPlatformAccountDao.java @@ -41,6 +41,13 @@ public interface OpenPlatformAccountDao extends BaseDao { - + + /** + * @param openId + * @return + * @Author sun + * @Description 根据openId查询登陆访问记录数据,按时间倒序 + **/ + PaUserVisitedDTO selectByOpenId(@Param("openId") String openId); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaUserWechatDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaUserWechatDao.java index 8d3f6a6351..78d08c42dc 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaUserWechatDao.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaUserWechatDao.java @@ -23,6 +23,8 @@ import com.epmet.entity.PaUserWechatEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; +import java.util.List; + /** * 公众号用户信息 * @@ -38,7 +40,7 @@ public interface PaUserWechatDao extends BaseDao { * @Author sun * @Description 根据openId查询user_wechat表信息 **/ - PaUserWechatDTO selectWechatByOpenId(@Param("openId") String openId); + List selectWechatByOpenId(@Param("openId") String openId); /** * @param dto diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/CodeOperationHistoryEntity.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/CodeOperationHistoryEntity.java index fe56ddd312..706351f4f7 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/CodeOperationHistoryEntity.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/CodeOperationHistoryEntity.java @@ -61,6 +61,6 @@ public class CodeOperationHistoryEntity extends BaseEpmetEntity { /** * 描述 */ - private String describe; + private String description; } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/RedisThird.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/RedisThird.java index 9317ce418e..e367e13227 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/RedisThird.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/RedisThird.java @@ -121,8 +121,9 @@ public class RedisThird { * @author zxc */ public void setAuthInfo(AuthorizationInfoResultDTO authInfo,String customerId,String clientType){ - String key = ThirdRedisKeyConstant.AUTH_INFO_REDIS_KEY+ThirdRedisKeyConstant.COLON+customerId+ThirdRedisKeyConstant.COLON+clientType; - redisUtils.set(key,authInfo,-1); + Map map = BeanUtil.beanToMap(authInfo, false, true); + String key = ThirdRedisKeyConstant.AUTH_INFO_REDIS_KEY + customerId+ThirdRedisKeyConstant.COLON + clientType; + redisUtils.hMSet(key, map,NOT_EXPIRE); } } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaCustomerService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaCustomerService.java index 87bd164d01..addf9d6d53 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaCustomerService.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaCustomerService.java @@ -105,7 +105,7 @@ public interface PaCustomerService extends BaseService { * @Author sun * @Description 公众号-手机号注册 **/ - void register(RegisterFormDTO formDTO); + RegisterResultDTO register(RegisterFormDTO formDTO); /** * @return diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaUserWechatService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaUserWechatService.java index 31c520d793..bc873038ac 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaUserWechatService.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaUserWechatService.java @@ -99,5 +99,5 @@ public interface PaUserWechatService extends BaseService { * @Author sun * @Description 根据openId查询user_wechat表信息 **/ - PaUserWechatDTO getWechatByOpenId(String openId); + List getWechatByOpenId(String openId); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeCustomerServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeCustomerServiceImpl.java index f2e9d5fd4c..1962b917a9 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeCustomerServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeCustomerServiceImpl.java @@ -107,7 +107,7 @@ public class CodeCustomerServiceImpl extends BaseServiceImpl list = baseDao.selectCodeList(formDTO); PageInfo pageInfo = new PageInfo<>(list); return new PageData<>(list, pageInfo.getTotal()); diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeServiceImpl.java index 4b9bfe1757..8e18dadcbf 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeServiceImpl.java @@ -13,8 +13,12 @@ import com.epmet.dao.AuthorizationInfoDao; import com.epmet.dao.ComponentAccessTokenDao; import com.epmet.dto.*; import com.epmet.dto.form.*; -import com.epmet.dto.result.*; +import com.epmet.dto.result.CodeHistoryResultDTO; +import com.epmet.dto.result.QrCodeResultDTO; +import com.epmet.dto.result.ReasonResultDTO; +import com.epmet.dto.result.TemplateListResultDTO; import com.epmet.feign.OperCrmOpenFeignClient; +import com.epmet.feign.OssFeignClient; import com.epmet.service.*; import com.epmet.wxapi.param.WxMaCodeAuditStatusReq; import com.epmet.wxapi.param.WxMaCodeCommitReq; @@ -24,8 +28,6 @@ import com.epmet.wxapi.result.*; import com.epmet.wxapi.service.WxMaCodeService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; -import com.google.gson.JsonElement; -import com.google.gson.JsonParser; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -63,6 +65,8 @@ public class CodeServiceImpl implements CodeService { private CodeMediaService codeMediaService; @Autowired private CodeExtService codeExtService; + @Autowired + private OssFeignClient ossFeignClient; @Override public List templateList() { @@ -101,7 +105,7 @@ public class CodeServiceImpl implements CodeService { @Transactional(rollbackFor = Exception.class) public void upload(CodeUploadFormDTO formDTO) { //是否授权 - if (customerMpService.getAuthFlag(formDTO.getCustomerId(), formDTO.getClientType())) { + if (!customerMpService.getAuthFlag(formDTO.getCustomerId(), formDTO.getClientType())) { throw new RenException("未授权"); } //获取小程序调用令牌 @@ -148,6 +152,7 @@ public class CodeServiceImpl implements CodeService { CodeCustomerDTO codeCustomerDTO = ConvertUtils.sourceToTarget(formDTO, CodeCustomerDTO.class); codeCustomerDTO.setCustomerName(customerInfo.getData().getCustomerName()); codeCustomerDTO.setExtJson(formDTO.getExtJson()); + codeCustomerDTO.setAppId(authInfo.getAuthorizerAppid()); codeCustomerDTO.setStatus(CodeConstant.UNAUDITED); codeCustomerService.save(codeCustomerDTO); @@ -156,39 +161,40 @@ public class CodeServiceImpl implements CodeService { @Override public PageData uploadList(UploadListFormDTO formDTO) { - //获取小程序调用令牌 - AuthorizationInfoDTO authInfo = authorizationInfoDao.getAuthInfoByCustomer(formDTO.getCustomerId(), formDTO.getClientType()); - if (null == authInfo) { - throw new RenException("未授权"); - } List auditingList = codeCustomerService.getAuditingCodeList(); - auditingList.forEach(code -> { - //获取审核结果信息 - CodeAuditResultDTO auditResult = codeAuditResultService.getAuditResultByCodeId(code.getId()); - //调用微信API获取最新审核状态 - WxMaCodeAuditStatusReq request = new WxMaCodeAuditStatusReq(); - request.setAuditId(auditResult.getAuditId()); - WxResult wxAuditResult = wxMaCodeService.getAuditStatus(authInfo.getAuthorizerAccessToken(), request); - if (wxAuditResult.success()) { - WxMaAuditStatusResult result = wxAuditResult.getData(); - if (result.getStatus() == NumConstant.ZERO) { - code.setStatus(CodeConstant.AUDIT_SUCCESS); - auditResult.setResult(CodeConstant.AUDIT_SUCCESS); - codeOperationHistoryService.updateDescribe(code.getId(), "审核成功"); - } else if (result.getStatus() == NumConstant.ONE) { - code.setStatus(CodeConstant.AUDIT_FAILED); - auditResult.setResult(CodeConstant.AUDIT_FAILED); - auditResult.setReason(result.getReason()); - codeOperationHistoryService.updateDescribe(code.getId(), result.getReason()); - } else if (result.getStatus() == NumConstant.FOUR) { - code.setStatus(CodeConstant.DELAY); - auditResult.setResult(CodeConstant.DELAY); - codeOperationHistoryService.updateDescribe(code.getId(), "审核延后"); + if (null != auditingList && auditingList.size() > NumConstant.ZERO) { + auditingList.forEach(code -> { + //获取小程序调用令牌 + AuthorizationInfoDTO authInfo = authorizationInfoDao.getAuthInfoByCustomer(code.getCustomerId(), code.getClientType()); + //获取审核结果信息 + CodeAuditResultDTO auditResult = codeAuditResultService.getAuditResultByCodeId(code.getId()); + //调用微信API获取最新审核状态 + WxMaCodeAuditStatusReq request = new WxMaCodeAuditStatusReq(); + request.setAuditId(auditResult.getAuditId()); + WxResult wxAuditResult = wxMaCodeService.getAuditStatus(authInfo.getAuthorizerAccessToken(), request); + if (wxAuditResult.success()) { + WxMaAuditStatusResult result = wxAuditResult.getData(); + if (result.getStatus() == NumConstant.ZERO) { + code.setStatus(CodeConstant.AUDIT_SUCCESS); + auditResult.setResult(CodeConstant.AUDIT_SUCCESS); + codeOperationHistoryService.updateDescribe(code.getId(), "审核成功"); + } else if (result.getStatus() == NumConstant.ONE) { + code.setStatus(CodeConstant.AUDIT_FAILED); + auditResult.setResult(CodeConstant.AUDIT_FAILED); + auditResult.setReason(result.getReason()); + auditResult.setScreenShot(result.getScreenshot()); + codeOperationHistoryService.updateDescribe(code.getId(), result.getReason()); + } else if (result.getStatus() == NumConstant.FOUR) { + code.setStatus(CodeConstant.DELAY); + auditResult.setResult(CodeConstant.DELAY); + auditResult.setReason(result.getReason()); + codeOperationHistoryService.updateDescribe(code.getId(), "审核延后"); + } + codeCustomerService.update(code); + codeAuditResultService.update(auditResult); } - codeCustomerService.update(code); - codeAuditResultService.update(auditResult); - } - }); + }); + } return codeCustomerService.getCodeList(formDTO); } @@ -197,7 +203,7 @@ public class CodeServiceImpl implements CodeService { //获取上传代码信息 CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId()); //是否授权 - if (customerMpService.getAuthFlag(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType())) { + if (!customerMpService.getAuthFlag(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType())) { throw new RenException("未授权"); } //获取小程序调用令牌 @@ -206,7 +212,13 @@ public class CodeServiceImpl implements CodeService { throw new RenException("未授权"); } //调用微信API上提交审核 - WxMaCodeSubmitAuditRequest request = ConvertUtils.sourceToTarget(formDTO, WxMaCodeSubmitAuditRequest.class); + WxMaCodeSubmitAuditRequest request = new WxMaCodeSubmitAuditRequest(); + request.setVersionDesc(formDTO.getVersionDesc()); + request.setFeedbackInfo(formDTO.getFeedbackInfo()); + request.setFeedbackStuff(formDTO.getFeedbackStuff()); + request.setItemList(formDTO.getItemList()); + request.setPreviewInfo(formDTO.getPreviewInfo()); + request.setUgcDeclare(formDTO.getUgcDeclare()); WxResult wxResult = wxMaCodeService.submitAudit(authInfo.getAuthorizerAccessToken(), request); if (!wxResult.success()) { saveOperation(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getId(), codeCustomerDTO.getUserVersion(), CodeConstant.OPER_SUBMIT, @@ -232,7 +244,7 @@ public class CodeServiceImpl implements CodeService { //获取上传代码信息 CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId()); //是否授权 - if (customerMpService.getAuthFlag(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType())) { + if (!customerMpService.getAuthFlag(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType())) { throw new RenException("未授权"); } //获取审核结果信息 @@ -277,7 +289,7 @@ public class CodeServiceImpl implements CodeService { //获取上传代码信息 CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId()); //是否授权 - if (customerMpService.getAuthFlag(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType())) { + if (!customerMpService.getAuthFlag(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType())) { throw new RenException("未授权"); } //获取小程序调用令牌 @@ -308,7 +320,7 @@ public class CodeServiceImpl implements CodeService { //获取上传代码信息 CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId()); //是否授权 - if (customerMpService.getAuthFlag(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType())) { + if (!customerMpService.getAuthFlag(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType())) { throw new RenException("未授权"); } AuthorizationInfoDTO authInfo = authorizationInfoDao.getAuthInfoByCustomer(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType()); @@ -343,7 +355,7 @@ public class CodeServiceImpl implements CodeService { //获取上传代码信息 CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId()); //是否授权 - if (customerMpService.getAuthFlag(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType())) { + if (!customerMpService.getAuthFlag(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType())) { throw new RenException("未授权"); } //获取小程序调用令牌 @@ -370,6 +382,7 @@ public class CodeServiceImpl implements CodeService { @Override public String mediaUpload(MediaUploadFormDTO formDTO) { try { +// Result uploadDTOResult = ossFeignClient.upload(formDTO.getMedia()); File file = MultipartFileToFileUtils.multipartFileToFile(formDTO.getMedia()); //获取上传代码信息 CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId()); @@ -383,7 +396,7 @@ public class CodeServiceImpl implements CodeService { CodeMediaDTO codeMediaDTO = new CodeMediaDTO(); codeMediaDTO.setCodeId(formDTO.getCodeId()); codeMediaDTO.setMediaId(wxResult.getData().getMediaId()); - codeMediaDTO.setMediaName(formDTO.getMedia().getName()); + codeMediaDTO.setMediaName(formDTO.getMedia().getOriginalFilename()); codeMediaDTO.setMediaType(wxResult.getData().getType()); codeMediaService.save(codeMediaDTO); return wxResult.getData().getMediaId(); @@ -399,7 +412,7 @@ public class CodeServiceImpl implements CodeService { operationDTO.setCodeId(codeId); operationDTO.setVersion(version); operationDTO.setOperation(operation); - operationDTO.setDescribe(describe); + operationDTO.setDescription(describe); codeOperationHistoryService.save(operationDTO); } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java index 30517d5cb7..69302821e7 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java @@ -1,7 +1,9 @@ package com.epmet.service.impl; +import cn.hutool.core.convert.Convert; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.TypeReference; import com.alibaba.nacos.client.config.utils.IOUtils; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.exception.RenException; @@ -12,10 +14,8 @@ import com.epmet.constant.ThirdRedisKeyConstant; import com.epmet.constant.ThirdRunTimeInfoConstant; import com.epmet.dao.*; import com.epmet.dto.form.*; -import com.epmet.dto.result.AuthCodeResultDTO; -import com.epmet.dto.result.AuthorizationInfoResultDTO; -import com.epmet.dto.result.CreateOpenResultDTO; -import com.epmet.dto.result.WillOverDueResultDTO; +import com.epmet.dto.result.*; +import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.mpaes.WXBizMsgCrypt; import com.epmet.mpaes.WXXmlToMapUtil; import com.epmet.redis.RedisThird; @@ -32,9 +32,7 @@ import org.springframework.web.bind.annotation.RequestBody; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import java.io.IOException; import java.io.InputStream; -import java.io.UnsupportedEncodingException; import java.lang.reflect.Field; import java.util.*; @@ -79,6 +77,10 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe private MiniCategoryInfoDao miniCategoryInfoDao; @Autowired private BusinessInfoDao businessInfoDao; + @Autowired + private EpmetUserOpenFeignClient epmetUserOpenFeignClient; + @Autowired + private AuthResultRecordDao authResultRecordDao; @Value("${third.platform.appId}") private String componentAppId; @@ -109,20 +111,17 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe String nonce = request.getParameter(ModuleConstant.NONCE); String encryptType = request.getParameter(ModuleConstant.ENCRYPT_TYPE); String signature = request.getParameter(ModuleConstant.SIGNATURE); - log.info(String.format(ThirdRunTimeInfoConstant.VERIFY_TICKET,msgSignature,timeStamp,nonce,encryptType,signature)); // 从请求中读取整个post数据 InputStream inputStream; String postData = null; inputStream = request.getInputStream(); postData= IOUtils.toString(inputStream,ModuleConstant.UTF8); - log.info("postData = "+postData); WXBizMsgCrypt wxBizMsgCrypt = new WXBizMsgCrypt(token,aesKey,componentAppId); String msg = wxBizMsgCrypt.decryptMsg(msgSignature, timeStamp, nonce, postData); log.info(String.format(ThirdRunTimeInfoConstant.MSG,msg)); // 将xml转为map Map result = WXXmlToMapUtil.xmlToMap(msg); - String infotype = result.get(ModuleConstant.INFO_TYPE); //获取infotype,注:微信开放平台文档中标明固定为:"component_verify_ticket",但参考其他代码,还包含authorized??? - log.info(infotype); + String infotype = result.get(ModuleConstant.INFO_TYPE); switch (infotype){ case ModuleConstant.TICKET_UNDERLINE_KEY: //接收票据 【component_verify_ticket】 String ComponentVerifyTicket = result.get(ModuleConstant.TICKET_KEY); @@ -133,29 +132,22 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe ticketFormDTO.setComponentAppId(componentAppId); ticketFormDTO.setComponentVerifyTicket(ComponentVerifyTicket); //先逻辑删 - ticketDao.updateOldComponentVerifyTicket(); + ticketDao.deleteOldComponentVerifyTicket(); ticketDao.insertComponentVerifyTicket(ticketFormDTO); log.info(ModuleConstant.TICKET_UNDERLINE_KEY+":"+ComponentVerifyTicket); break; case ModuleConstant.AUTHORIZED: //授权成功 - // 更改customer_mp 授权信息,appId,并绑定 -// String authAppId = result.get(ModuleConstant.APP_ID); - String authCode = result.get(ModuleConstant.AUTHORIZATION_CODE_HUMP); - log.info("=============================="+authCode); - AuthCodeResultDTO authCodeResultDTO = authCodeDao.selectCustomerIdByAuthCode(authCode); - String clientType = authCodeResultDTO.getClientType(); - String customerId = authCodeResultDTO.getCustomerId(); - Map authorizerRefreshToken = redisThird.getAuthorizerRefreshToken(customerId + ThirdRedisKeyConstant.COLON + clientType); - String authAppId = authorizerRefreshToken.get("authorizerAppid").toString(); - this.updateCustomerMpAppIdAndCreateOpenPlatform(customerId,authAppId,clientType); -// this.authInfoByAuthCode(authCode, customerId,clientType); - authCodeDao.updateAppId(customerId,clientType,authAppId); - this.saveAuthAccountInfo(customerId,authAppId,clientType); -// customerMpDao.updateAuthorizationFlag(authAppId); + this.disposeAuthResult(result); + break; case ModuleConstant.UNAUTHORIZED://用户取消授权 //todo 取消授权 String authorizerAppId = result.get(ModuleConstant.AUTHORIZER_APP_ID_HUMP); customerMpDao.updateAuthorizationFlag(authorizerAppId); + this.disposeAuthResult(result); + break; + case ModuleConstant.UPDATE_AUTHORIZED://授权变更 + this.disposeAuthResult(result); + break; } } catch (Exception e) { log.error(e.getMessage()); @@ -170,6 +162,24 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe return ModuleConstant.SUCCESS; } + /** + * @Description 授权结果插入 + * @param result + * @author zxc + */ + @Transactional(rollbackFor = Exception.class) + public void disposeAuthResult(Map result){ + Map tempMap = result; + Map data = tempMap; + AuthResultRecordFormDTO authResultRecord = mapToEntity(data, AuthResultRecordFormDTO.class); + authResultRecord.setWechatCreateTime(this.sToDate(result.get(ModuleConstant.CREATE_TIME))); + if (result.containsKey(ModuleConstant.AUTHORIZATION_CODE_EXPIRED_TIME)) { + authResultRecord.setExpiredTime(this.sToDate(result.get(ModuleConstant.AUTHORIZATION_CODE_EXPIRED_TIME))); + } + authResultRecord.setComponentAppId(componentAppId); + authResultRecordDao.insertAuthResultRecord(authResultRecord); + } + /** * @Description 定时获取 (令牌,component_access_token) 第三方与微信交互使用的component_access_token * 每十分钟执行一次,判断是否有马上超时的(15分钟以内算马上超时) @@ -283,28 +293,13 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe authInfoDTO.setExpiresInTime(expiresInTime); authInfoDTO.setCustomerId(customerId); authInfoDTO.setClientType(clientType); - //先逻辑删除,在插入 - authorizationInfoDao.updateOldAuthorizationInfo(customerId,clientType); - authorizationInfoDao.insertAuthorizationInfo(authInfoDTO); - // 2. 权限列表 - log.info(START_INSERT_FUNC_INFO); - List funcInfos = new ArrayList<>(); List func_info = authorizationInfoResultDTO.getFunc_info(); log.info("权限列表信息:"+func_info); - /*func_info.forEach(func -> { - func.forEach((key,value) -> { - FuncInfoFormDTO fu = new FuncInfoFormDTO(); - fu.setFuncscopeCategory((String) key); - Map funcScope = (Map) value; - fu.setFuncscopeId(funcScope.get(ModuleConstant.ID).toString()); - fu.setAuthorizationInfoAppid(authAppId); - fu.setCustomerId(customerId); - funcInfos.add(fu); - }); - });*/ - // todo 先逻辑删除,在插入 - /*funcInfoDao.updateOldFuncInfo(customerId,authAppId); - funcInfoDao.insertFuncInfo(funcInfos);*/ + String funcInfo = JSON.toJSONString(func_info); + authInfoDTO.setFuncInfo(funcInfo); + //先逻辑删除,在插入 + authorizationInfoDao.updateOldAuthorizationInfo(authAppId); + authorizationInfoDao.insertAuthorizationInfo(authInfoDTO); // 授权信息放入缓存 redisThird.setAuthInfo(authorizationInfoResultDTO,customerId,clientType); //authorizer_refresh_token 放入缓存 @@ -338,27 +333,29 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe String componentAccessToken = redisThird.getComponentAccessToken(); String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_AUTHORIZER_TOKEN_URL + componentAccessToken, JSON.toJSONString(jsonObject)).getData(); Map map = JSON.parseObject(data, HashMap.class); - //authorizer_access_token - String authorizerAccessToken = map.get(ModuleConstant.AUTHORIZER_ACCESS_TOKEN).toString(); - String expiresIn = map.get(ModuleConstant.EXPIRES_IN).toString(); - String authorizerRefreshToken = map.get(ModuleConstant.AUTHORIZER_REFRESH_TOKEN).toString(); - Date expiresInTime = this.countExpirationTime(expiresIn); - //更新DB - AuthorizerAccessTokenFormDTO formDTO = new AuthorizerAccessTokenFormDTO(); - AuthorizationInfoFormDTO authorizationInfo = new AuthorizationInfoFormDTO(); - BeanUtils.copyProperties(formDTO,authorizationInfo); - authorizationInfo.setAuthorizerAppid(authAppId); - formDTO.setAuthorizerAccessToken(authorizerAccessToken); - formDTO.setAuthorizerRefreshToken(authorizerRefreshToken); - formDTO.setExpiresInTime(expiresInTime); - formDTO.setCustomerId(customerId); - formDTO.setAuthAppid(authAppId); - //先逻辑删除,在插入 - authorizationInfoDao.updateOldAuthorizerAccessToken(willOverDueDTO.getCustomerId(),clientType); - authorizationInfoDao.insertAuthorizerAccessToken(formDTO); - - //缓存 refreshAuthorizerAccessToken - redisThird.setAuthorizerRefreshToken(authorizationInfo); + if (!map.containsKey(ModuleConstant.ERR_CODE)) { + log.info(REFRESH_AUTH_ACCESS_TOKEN); + String authorizerAccessToken = map.get(ModuleConstant.AUTHORIZER_ACCESS_TOKEN).toString(); + String expiresIn = map.get(ModuleConstant.EXPIRES_IN).toString(); + String authorizerRefreshToken = map.get(ModuleConstant.AUTHORIZER_REFRESH_TOKEN).toString(); + Date expiresInTime = this.countExpirationTime(expiresIn); + //更新DB + AuthorizerAccessTokenFormDTO formDTO = new AuthorizerAccessTokenFormDTO(); + AuthorizationInfoFormDTO authorizationInfo = new AuthorizationInfoFormDTO(); + BeanUtils.copyProperties(formDTO, authorizationInfo); + authorizationInfo.setAuthorizerAppid(authAppId); + formDTO.setAuthorizerAccessToken(authorizerAccessToken); + formDTO.setAuthorizerRefreshToken(authorizerRefreshToken); + formDTO.setExpiresInTime(expiresInTime); + formDTO.setCustomerId(customerId); + formDTO.setAuthAppid(authAppId); + formDTO.setClientType(clientType); + //先逻辑删除,在插入 + authorizationInfoDao.updateOldAuthorizerAccessToken(customerId, clientType); + authorizationInfoDao.insertAuthorizerAccessToken(formDTO); + //缓存 refreshAuthorizerAccessToken + redisThird.setAuthorizerRefreshToken(authorizationInfo); + } }); log.info("更新authorizer_access_token成功"); } @@ -375,27 +372,31 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe public void redirectUri(TokenDto tokenDto, @RequestBody AuthCodeAndTimeFromDTO authCodeAndTime){ log.info("开始执行回调URL"); String authCode = authCodeAndTime.getAuthCode(); - String client = authCodeAndTime.getClientType(); + String clientType = authCodeAndTime.getClientType(); String expiresIn = authCodeAndTime.getExpiresIn(); - String customerId = tokenDto.getCustomerId(); - customerId = "f530774b31e0609a3c7f0f83794cda0c"; + String customerId = this.getLoginUserCustomerId(tokenDto); Date expiresInTime = this.countExpirationTime(expiresIn); - if (StringUtils.isBlank(customerId)||StringUtils.isBlank(client)||StringUtils.isBlank(authCode)||StringUtils.isBlank(expiresIn)){ - log.info("客户ID = "+customerId+", 客户端类型为 = "+client+", 授权码为 = "+authCode+", 有效期 = "+expiresIn); - } //authCode存数据库 AuthCodeFormDTO formDTO = new AuthCodeFormDTO(); formDTO.setAuthCode(authCode); formDTO.setExpiresInTime(expiresInTime); - formDTO.setClientType(client); - //授权方AppId + formDTO.setClientType(clientType); formDTO.setCustomerId(customerId); log.info(formDTO.toString()); - authCodeDao.deleteCustomerAuthCode(customerId,client); + authCodeDao.deleteCustomerAuthCode(customerId,clientType); authCodeDao.insertRedirectAuthCode(formDTO); //authCode存缓存 redisThird.setAuthCode(formDTO); - this.authInfoByAuthCode(authCode, customerId,client); + // 1. 开始获取授权信息(使用授权码) + AuthorizationInfoResultDTO authorizationInfoResultDTO = this.authInfoByAuthCode(authCode, customerId, clientType); + String authAppId = authorizationInfoResultDTO.getAuthorizer_appid(); + // 2. 创建开放平台账号并绑定 或者 直接绑定开放平台 + this.createAndBindOpenAccount(customerId,authAppId,clientType); + // 3. 更新 customer_mp 表授权状态和AuthAppId + this.updateCustomerMpAppId(customerId,authAppId,clientType); + authCodeDao.updateAppId(customerId,clientType,authAppId); + // 4. 保存授权方账户信息 + this.saveAuthAccountInfo(customerId,authAppId,clientType); log.info("回调结束"); } @@ -456,18 +457,20 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe //todo 小程序配置的类目信息插入 List categoryInfoList = new ArrayList<>(); List categories = (List) miniProgramInfo.get(ModuleConstant.CATEGORIES); - categories.forEach(category -> { - category.forEach((key,value) -> { - MiniCategoryInfoFormDTO categoryInfo = new MiniCategoryInfoFormDTO(); - categoryInfo.setCustomerId(customerId); - categoryInfo.setClientType(clientType); - categoryInfo.setCategorySort(key.toString()); - categoryInfo.setCategoryName(value.toString()); - categoryInfo.setPrimaryId(primaryId); - categoryInfoList.add(categoryInfo); + if (categories.size() != NumConstant.ZERO) { + categories.forEach(category -> { + category.forEach((key, value) -> { + MiniCategoryInfoFormDTO categoryInfo = new MiniCategoryInfoFormDTO(); + categoryInfo.setCustomerId(customerId); + categoryInfo.setClientType(clientType); + categoryInfo.setCategorySort(key.toString()); + categoryInfo.setCategoryName(value.toString()); + categoryInfo.setPrimaryId(primaryId); + categoryInfoList.add(categoryInfo); + }); }); - }); - miniCategoryInfoDao.insertCategoryInfo(categoryInfoList); + miniCategoryInfoDao.insertCategoryInfo(categoryInfoList); + } }else { log.info("授权方为公众号 并 开始插入信息"); PaInfoFormDTO paInfoFormDTO = this.mapToEntity(authorizerInfo, PaInfoFormDTO.class); @@ -493,89 +496,107 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe } /** - * @Description 1.创建开放平台账号并绑定 2.回填 customer_mp appId + * @Description 回填 customer_mp appId , 更改授权状态 * @param * @author zxc */ @Transactional(rollbackFor = Exception.class) - public void updateCustomerMpAppIdAndCreateOpenPlatform(String customerId,String authAppId,String clientType){ - log.info("开始创建开放平台账号并绑定"); - Integer authCount = customerMpDao.selectAuthCount(customerId); - String openPlatformId = null; + public void updateCustomerMpAppId(String customerId,String authAppId,String clientType){ + log.info("==========回填customer_mp开始=========="); + Integer checkBindCount = customerMpDao.checkBind(authAppId, clientType); + if (checkBindCount == NumConstant.ZERO) { + AuthCodeFormDTO formDTO = new AuthCodeFormDTO(); + formDTO.setClientType(clientType); + formDTO.setAuthAppId(authAppId); + formDTO.setCustomerId(customerId); + //回填customer_mp的appId 只需以上三个字段 + customerMpDao.updateAppIDByCustomerIdAndClient(formDTO); + } + log.info("==========回填customer_mp结束=========="); + } + + public void createAndBindOpenAccount(String customerId,String authAppId,String clientType){ Map authorizerRefreshToken = redisThird.getAuthorizerRefreshToken(customerId + ThirdRedisKeyConstant.COLON + clientType); String authorizerAccessToken = authorizerRefreshToken.get("authorizerAccessToken").toString(); - if (authCount==NumConstant.ZERO){ - log.info("未查询到该客户授权信息,先创建开放平台账号,再绑定"); - //没有任何一个小程序/公众号授权,【先创建,再绑定】 - JSONObject jsonObject = new JSONObject(); - jsonObject.put(ModuleConstant.LOW_APP_ID,authAppId); - // 此处的 access_token 为 【authorizer_access_token】 - String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_CREATE_OPEN + authorizerAccessToken, JSON.toJSONString(jsonObject)).getData(); - Map map = JSON.parseObject(data, Map.class); - CreateOpenResultDTO createOpen = new CreateOpenResultDTO(); - createOpen.setErrCode(Integer.valueOf(map.get(ModuleConstant.ERR_CODE))); - createOpen.setErrMsg(map.get(ModuleConstant.ERR_MSG)); - createOpen.setOpenAppId(map.get(ModuleConstant.OPEN_APP_ID)); - switch (createOpen.getErrCode()){ - case NumConstant.ONE: - log.info(CREATE_AND_BIND_SUCCESS); - break; - case NumConstant.ONE_NEG: - throw new RenException(SYSTEM_ERROR); - case ModuleConstant.FORTY_THOUSAND_AND_THIRTEEN: - throw new RenException(INVALID_APP_ID); - case ModuleConstant.EIGHTY_NINE_THOUSAND: - throw new RenException(ACCOUNT_HAS_BOUND_OPEN); + JSONObject bindInfoForm = new JSONObject(); + bindInfoForm.put(ModuleConstant.LOW_APP_ID,authAppId); + String bindResult = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_OPEN_GET + authorizerAccessToken, JSON.toJSONString(bindInfoForm)).getData(); + Map bindInfo = JSON.parseObject(bindResult, Map.class); + boolean bindStatus = bindInfo.containsKey(ModuleConstant.OPEN_APP_ID); + if (bindStatus != true) { + log.info(CREATE_AND_BIND_SUCCESS); + List authCount = customerMpDao.selectAuthCount(customerId); + String openPlatformId = null; + if (authCount.size() > 0) { + openPlatformId = openPlatformAccountDao.selectOpenAppIdByCustomerId(customerId); } - CreateOpenFormDTO coForm = new CreateOpenFormDTO(); - coForm.setOpenid(map.get(ModuleConstant.OPEN_APP_ID)); - coForm.setCustomerId(customerId); - //插入 open_platform_account 表 - openPlatformAccountDao.insertOpenPlatFormAccount(coForm); - openPlatformId = coForm.getId(); - }else if (authCount>NumConstant.ZERO){ - log.info("该客户已创建过开放平台账号,直接绑定"); - String openAppId = openPlatformAccountDao.selectOpenAppIdByCustomerId(customerId); - JSONObject jsonObject = new JSONObject(); - jsonObject.put(ModuleConstant.LOW_APP_ID,componentAppId); - jsonObject.put(ModuleConstant.OPEN_APP_ID,openAppId); - String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_BIND_OPEN + authorizerRefreshToken, JSON.toJSONString(jsonObject)).getData(); - Map map = JSON.parseObject(data, Map.class); - CreateOpenResultDTO createOpen = new CreateOpenResultDTO(); - createOpen.setErrCode(Integer.valueOf(map.get(ModuleConstant.ERR_CODE))); - createOpen.setErrMsg(map.get(ModuleConstant.ERR_MSG)); - switch (createOpen.getErrCode()){ - case NumConstant.ONE: - log.info(BIND_SUCCESS); - break; - case NumConstant.ONE_NEG: - throw new RenException(SYSTEM_ERROR); - case ModuleConstant.FORTY_THOUSAND_AND_THIRTEEN: - throw new RenException(INVALID_APP_ID); - case ModuleConstant.EIGHTY_NINE_THOUSAND: - throw new RenException(ACCOUNT_HAS_BOUND_OPEN); - case ModuleConstant.EIGHTY_NINE_THOUSAND_AND_ONE: - throw new RenException(NOT_SAME_CONTRACTOR); - case ModuleConstant.EIGHTY_NINE_THOUSAND_AND_THREE: - throw new RenException(NOT_ALLOWED_OPERATE); - case ModuleConstant.EIGHTY_NINE_THOUSAND_AND_FOUR: - throw new RenException(TO_LIMIT); + if (authCount.size() == NumConstant.ZERO) { + log.info("未查询到该客户授权信息,先创建开放平台账号,再绑定"); + //没有任何一个小程序/公众号授权,【先创建,再绑定】 + JSONObject jsonObject = new JSONObject(); + jsonObject.put(ModuleConstant.LOW_APP_ID, authAppId); + // 此处的 access_token 为 【authorizer_access_token】 + String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_CREATE_OPEN + authorizerAccessToken, JSON.toJSONString(jsonObject)).getData(); + Map map = JSON.parseObject(data, Map.class); + openPlatformId = map.get(ModuleConstant.OPEN_APP_ID).toString(); + CreateOpenResultDTO createOpen = new CreateOpenResultDTO(); + createOpen.setErrCode((Integer) map.get(ModuleConstant.ERR_CODE)); + createOpen.setErrMsg(map.get(ModuleConstant.ERR_MSG).toString()); + createOpen.setOpenAppId(map.get(ModuleConstant.OPEN_APP_ID).toString()); + switch (createOpen.getErrCode()) { + case NumConstant.ZERO: + log.info(CREATE_AND_BIND_SUCCESS); + CreateOpenFormDTO coForm = new CreateOpenFormDTO(); + coForm.setOpenid(map.get(ModuleConstant.OPEN_APP_ID).toString()); + coForm.setCustomerId(customerId); + //插入 open_platform_account 表 + openPlatformAccountDao.deleteOldOpenPlatFprmAccount(customerId); + openPlatformAccountDao.insertOpenPlatFormAccount(coForm); + break; + case NumConstant.ONE_NEG: + throw new RenException(SYSTEM_ERROR); + case ModuleConstant.FORTY_THOUSAND_AND_THIRTEEN: + throw new RenException(INVALID_APP_ID); + case ModuleConstant.EIGHTY_NINE_THOUSAND: + throw new RenException(ACCOUNT_HAS_BOUND_OPEN); + } + } else if (authCount.size() > NumConstant.ZERO && !authCount.contains(authAppId)) { + log.info("该客户已创建过开放平台账号,直接绑定"); + JSONObject jsonObject = new JSONObject(); + jsonObject.put(ModuleConstant.LOW_APP_ID, authAppId); + jsonObject.put(ModuleConstant.OPEN_APP_ID, openPlatformId); + String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_BIND_OPEN + authorizerAccessToken, JSON.toJSONString(jsonObject)).getData(); + Map map = JSON.parseObject(data, Map.class); + CreateOpenResultDTO createOpen = new CreateOpenResultDTO(); + createOpen.setErrCode((Integer) map.get(ModuleConstant.ERR_CODE)); + createOpen.setErrMsg(map.get(ModuleConstant.ERR_MSG).toString()); + switch (createOpen.getErrCode()) { + case NumConstant.ZERO: + log.info(BIND_SUCCESS); + break; + case NumConstant.ONE_NEG: + throw new RenException(SYSTEM_ERROR); + case ModuleConstant.FORTY_THOUSAND_AND_THIRTEEN: + throw new RenException(INVALID_APP_ID); + case ModuleConstant.EIGHTY_NINE_THOUSAND: + throw new RenException(ACCOUNT_HAS_BOUND_OPEN); + case ModuleConstant.EIGHTY_NINE_THOUSAND_AND_ONE: + throw new RenException(NOT_SAME_CONTRACTOR); + case ModuleConstant.EIGHTY_NINE_THOUSAND_AND_THREE: + throw new RenException(NOT_ALLOWED_OPERATE); + case ModuleConstant.EIGHTY_NINE_THOUSAND_AND_FOUR: + throw new RenException(TO_LIMIT); + } } + //插入 binding_account + BindingAccountFormDTO bindingAccount = new BindingAccountFormDTO(); + bindingAccount.setOpenPlatformAccountId(openPlatformId); + bindingAccount.setAuthAppId(authAppId); + bindingAccount.setClientType(clientType); + bindingAccount.setCustomerId(customerId); + bindingAccountDao.insertBindingAccount(bindingAccount); + log.info("创建绑定账号结束"); } - AuthCodeFormDTO formDTO = new AuthCodeFormDTO(); - formDTO.setClientType(clientType); - formDTO.setAuthAppId(authAppId); - formDTO.setCustomerId(customerId); - //回填customer_mp的appId 只需以上三个字段 - customerMpDao.updateAppIDByCustomerIdAndClient(formDTO); - //插入 binding_account - BindingAccountFormDTO bindingAccount = new BindingAccountFormDTO(); - bindingAccount.setOpenPlatformAccountId(openPlatformId); - bindingAccount.setAuthAppId(authAppId); - bindingAccount.setClientType(clientType); - bindingAccount.setCustomerId(customerId); - bindingAccountDao.insertBindingAccount(bindingAccount); - log.info("创建绑定账号结束"); } /** @@ -620,4 +641,28 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe date.setTime(l); return date; } + + /** + * @Description 查询客户Id + * @param tokenDto + * @author zxc + */ + public String getLoginUserCustomerId(TokenDto tokenDto){ + LoginUserDetailsFormDTO dto = new LoginUserDetailsFormDTO(); + BeanUtils.copyProperties(tokenDto,dto); + LoginUserDetailsResultDTO data = epmetUserOpenFeignClient.getLoginUserDetails(dto).getData(); + return data.getCustomerId(); + } + + /** + * @Description 时间戳(秒级)转换 Date + * @param t + * @author zxc + */ + public Date sToDate(String t){ + Long aLong = Long.valueOf(t + "000"); + Date date = new Date(); + date.setTime(aLong); + return date; + } } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaCustomerServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaCustomerServiceImpl.java index 63290cfb9f..62fdde3a8c 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaCustomerServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaCustomerServiceImpl.java @@ -154,14 +154,9 @@ public class PaCustomerServiceImpl extends BaseServiceImpl userList = paUserDao.selectUserByPhone(formDTO.getPhone()); - if (null != userList && userList.size() > NumConstant.ZERO) { - throw new RenException(PaConstant.PHONE_EXCEPTION); - } - - //2.校验验证码是否正确 + public RegisterResultDTO register(RegisterFormDTO formDTO) { + RegisterResultDTO resultDTO = new RegisterResultDTO(); + //0.校验验证码是否正确 String smsCodeKey = RedisKeys.getLoginSmsCodeKey(LoginConstant.APP_PUBLIC, LoginConstant.CLIENT_MP, formDTO.getPhone()); String rightSmsCode = (String) redisUtils.get(smsCodeKey); if (!formDTO.getSmsCode().equals(rightSmsCode)) { @@ -169,31 +164,87 @@ public class PaCustomerServiceImpl extends BaseServiceImpl userList = paUserDao.selectUserByPhone(formDTO.getPhone()); + if (null != userList && userList.size() > NumConstant.ZERO) { + throw new RenException(PaConstant.PHONE_EXCEPTION); } - //2.访问记录表新增数据 - PaUserWechatDTO dto = new PaUserWechatDTO(); - dto.setUserId(formDTO.getUserId()); - PaUserWechatEntity wechatEntity = paUserWechatDao.selectWechatByUserId(dto); - if (null == wechatEntity) { - throw new RenException(PaConstant.SELECT_WECHAT_EXCEPTION); - } - PaUserVisitedEntity visitedEntity = new PaUserVisitedEntity(); - visitedEntity.setUserId(formDTO.getUserId()); - visitedEntity.setWxOpenId(wechatEntity.getWxOpenId()); - visitedEntity.setOpenId(wechatEntity.getWxOpenId()); - visitedEntity.setPhone(formDTO.getPhone()); - if (paUserVisitedDao.insert(visitedEntity) < NumConstant.ONE) { - throw new RenException(PaConstant.SAVE_VISITED_EXCEPTION); + //2.根据token中的userId查询pa_user表数据,根据手机号是否为空判断后续是新增还是更新user数据 + PaUserEntity paUserEntity = paUserDao.selectById(formDTO.getUserId()); + + //3.手机号不为空说明是同一个微信用户用第二个手机号注册,手机为空说明当前微信用户用第一个手机号注册 + if(null != paUserEntity.getPhone() && StringUtils.isNotBlank(paUserEntity.getPhone())){ + //手机号不为空说明是同一个微信用户用第二个手机号注册,新增user和user_wechat表数据 + //3-1.user表新增数据 + PaUserEntity userEntity = new PaUserEntity(); + userEntity.setPhone(formDTO.getPhone()); + userEntity.setRealName(formDTO.getSurName()); + userEntity.setGender(formDTO.getGender().toString()); + if (paUserDao.insert(userEntity) < NumConstant.ONE) { + throw new RenException(PaConstant.SAVE_USER_EXCEPTION); + } + + //3-2.根据token中的userId查询用户的微信信息 + PaUserWechatDTO dto = new PaUserWechatDTO(); + dto.setUserId(formDTO.getUserId()); + PaUserWechatEntity wechatEntity = paUserWechatDao.selectWechatByUserId(dto); + if (null == wechatEntity) { + throw new RenException(PaConstant.SELECT_WECHAT_EXCEPTION); + } + + //3-3.新增用户微信信息 + wechatEntity.setId(null); + wechatEntity.setUserId(userEntity.getId()); + if (paUserWechatDao.insert(wechatEntity) < NumConstant.ONE) { + throw new RenException(PaConstant.SAVE_WECHAT_EXCEPTION); + } + + //3-4.访问记录表新增数据 + PaUserVisitedEntity visitedEntity = new PaUserVisitedEntity(); + visitedEntity.setUserId(userEntity.getId()); + visitedEntity.setWxOpenId(wechatEntity.getWxOpenId()); + visitedEntity.setOpenId(wechatEntity.getWxOpenId()); + visitedEntity.setPhone(formDTO.getPhone()); + if (paUserVisitedDao.insert(visitedEntity) < NumConstant.ONE) { + throw new RenException(PaConstant.SAVE_VISITED_EXCEPTION); + } + resultDTO.setUserId(userEntity.getId()); + resultDTO.setOpenId(wechatEntity.getWxOpenId()); + resultDTO.setUnionId(null == wechatEntity.getUnionId() ? "" : wechatEntity.getUnionId()); + }else { + //手机为空说明当前微信用户用第一个手机号注册,更新user表数据 + //3-1.pa_user表更新数据 + PaUserEntity userEntity = new PaUserEntity(); + userEntity.setId(formDTO.getUserId()); + userEntity.setPhone(formDTO.getPhone()); + userEntity.setRealName(formDTO.getSurName()); + userEntity.setGender(formDTO.getGender().toString()); + if (paUserDao.updateById(userEntity) < NumConstant.ONE) { + throw new RenException(PaConstant.UPDATE_USER_EXCEPTION); + } + + //3-2.访问记录表新增数据 + PaUserWechatDTO dto = new PaUserWechatDTO(); + dto.setUserId(formDTO.getUserId()); + PaUserWechatEntity wechatEntity = paUserWechatDao.selectWechatByUserId(dto); + if (null == wechatEntity) { + throw new RenException(PaConstant.SELECT_WECHAT_EXCEPTION); + } + PaUserVisitedEntity visitedEntity = new PaUserVisitedEntity(); + visitedEntity.setUserId(formDTO.getUserId()); + visitedEntity.setWxOpenId(wechatEntity.getWxOpenId()); + visitedEntity.setOpenId(wechatEntity.getWxOpenId()); + visitedEntity.setPhone(formDTO.getPhone()); + if (paUserVisitedDao.insert(visitedEntity) < NumConstant.ONE) { + throw new RenException(PaConstant.SAVE_VISITED_EXCEPTION); + } + resultDTO.setUserId(userEntity.getId()); + resultDTO.setOpenId(wechatEntity.getWxOpenId()); + resultDTO.setUnionId(null == wechatEntity.getUnionId() ? "" : wechatEntity.getUnionId()); } + + return resultDTO; } /** diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaUserServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaUserServiceImpl.java index dfdb56af5f..680bf4fec4 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaUserServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaUserServiceImpl.java @@ -26,9 +26,11 @@ import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.dao.PaCustomerDao; import com.epmet.dao.PaUserDao; +import com.epmet.dao.PaUserVisitedDao; import com.epmet.dao.PaUserWechatDao; import com.epmet.dto.PaCustomerDTO; import com.epmet.dto.PaUserDTO; +import com.epmet.dto.PaUserVisitedDTO; import com.epmet.dto.PaUserWechatDTO; import com.epmet.dto.result.CustomerUserResultDTO; import com.epmet.dto.result.SaveUserResultDTO; @@ -64,6 +66,8 @@ public class PaUserServiceImpl extends BaseServiceImpl private PaCustomerDao paCustomerDao; @Autowired private PaUserWechatDao paUserWechatDao; + @Autowired + private PaUserVisitedDao paUserVisitedDao; @Override public PageData page(Map params) { @@ -127,11 +131,11 @@ public class PaUserServiceImpl extends BaseServiceImpl @Transactional(rollbackFor = Exception.class) public SaveUserResultDTO saveUser(WxMpUser wxMpUser) { SaveUserResultDTO resultDTO = new SaveUserResultDTO(); - //1.根据openId查询user_wechat表是否存在用户信息 - PaUserWechatDTO wechatDTO = paUserWechatService.getWechatByOpenId(wxMpUser.getOpenId()); + //1.根据openId查询user_wechat表是否存在用户信息(user表和user_wechat表数据时多对多关系) + List wechatDTO = paUserWechatService.getWechatByOpenId(wxMpUser.getOpenId()); //2.不存在则新增用户信息,存在则更新user_wechat表信息 - if (null == wechatDTO || null == wechatDTO.getId()) { + if (null == wechatDTO || wechatDTO.size() < NumConstant.ONE) { //2.1、user表新增数据 PaUserEntity userEntity = new PaUserEntity(); baseDao.insert(userEntity); @@ -151,18 +155,23 @@ public class PaUserServiceImpl extends BaseServiceImpl resultDTO.setUserId(userEntity.getId()); } else { - //2.3、更新user_wechat表数据 - PaUserWechatEntity wechatEntity = ConvertUtils.sourceToTarget(wechatDTO, PaUserWechatEntity.class); - wechatEntity.setGender(wxMpUser.getSex().toString()); - wechatEntity.setNickname(wxMpUser.getNickname()); - wechatEntity.setHeadImgUrl(null == wxMpUser.getHeadImgUrl() ? "" : wxMpUser.getHeadImgUrl()); - wechatEntity.setCountry(null == wxMpUser.getCountry() ? "" : wxMpUser.getCountry()); - wechatEntity.setProvince(null == wxMpUser.getProvince() ? "" : wxMpUser.getProvince()); - wechatEntity.setCity(null == wxMpUser.getCity() ? "" : wxMpUser.getCity()); - wechatEntity.setLanguage(null == wxMpUser.getLanguage() ? "" : wxMpUser.getLanguage()); - paUserWechatService.updateById(wechatEntity); - - resultDTO.setUserId(wechatDTO.getUserId()); + //2.3、批量更新user_wechat表数据 + List wechatEntity = ConvertUtils.sourceToTarget(wechatDTO, PaUserWechatEntity.class); + for(PaUserWechatEntity entity : wechatEntity){ + entity.setGender(wxMpUser.getSex().toString()); + entity.setNickname(wxMpUser.getNickname()); + entity.setHeadImgUrl(null == wxMpUser.getHeadImgUrl() ? "" : wxMpUser.getHeadImgUrl()); + entity.setCountry(null == wxMpUser.getCountry() ? "" : wxMpUser.getCountry()); + entity.setProvince(null == wxMpUser.getProvince() ? "" : wxMpUser.getProvince()); + entity.setCity(null == wxMpUser.getCity() ? "" : wxMpUser.getCity()); + entity.setLanguage(null == wxMpUser.getLanguage() ? "" : wxMpUser.getLanguage()); + } + paUserWechatService.updateBatchById(wechatEntity); + + //2.4、根据openid查询用户登陆访问记录表数据,按登陆时间倒序 + PaUserVisitedDTO visitedDTO = paUserVisitedDao.selectByOpenId(wxMpUser.getOpenId()); + + resultDTO.setUserId(visitedDTO.getUserId()); } //3.返回userId diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaUserWechatServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaUserWechatServiceImpl.java index 9fb9089c5e..46726a9823 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaUserWechatServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaUserWechatServiceImpl.java @@ -108,7 +108,7 @@ public class PaUserWechatServiceImpl extends BaseServiceImpl getWechatByOpenId(String openId) { return baseDao.selectWechatByOpenId(openId); } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxMaCodeConstant.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxMaCodeConstant.java index e98f7a4701..8ec83ac350 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxMaCodeConstant.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxMaCodeConstant.java @@ -33,16 +33,18 @@ public interface WxMaCodeConstant { /** * 前端地址 【授权之后的跳转的地址】 */ - String WEB_URL = "https://epmet-cloud.elinkservice.cn/third/mpweb/page/#/info?clientType="; + String WEB_URL = "https://epmet-cloud.elinkservice.cn/third/mpweb/page/#/info?clientType="; /** * 授权注册页面扫码授权 * component_appid:第三方AppId * pre_auth_code:预授权码 * redirect_uri:回调url(获取授权码) + * 上面url为扫码形式 + * 下面注释url为按钮形式 */ -// String API_AUTH_REGISTER_URL = "https://mp.weixin.qq.com/cgi-bin/componentloginpage?component_appid=%s&pre_auth_code=%s&redirect_uri=%s"; - String API_AUTH_REGISTER_URL = "https://mp.weixin.qq.com/safe/bindcomponent?action=bindcomponent&auth_type=3&no_scan=1&component_appid=%s&pre_auth_code=%s&redirect_uri=%s#wechat_redirect"; + String API_AUTH_REGISTER_URL = "https://mp.weixin.qq.com/cgi-bin/componentloginpage?component_appid=%s&pre_auth_code=%s&redirect_uri=%s"; +// String API_AUTH_REGISTER_URL = "https://mp.weixin.qq.com/safe/bindcomponent?action=bindcomponent&auth_type=3&no_scan=1&component_appid=%s&pre_auth_code=%s&redirect_uri=%s#wechat_redirect"; /** * 创建开放平台帐号并绑定公众号/小程序 @@ -59,6 +61,11 @@ public interface WxMaCodeConstant { */ String API_GET_AUTHORIZER_INFO = "https://api.weixin.qq.com/cgi-bin/component/api_get_authorizer_info?component_access_token="; + /** + * 获取公众号/小程序所绑定的开放平台帐号 + */ + String API_OPEN_GET = "https://api.weixin.qq.com/cgi-bin/open/get?access_token="; + /** * 为授权的小程序帐号上传小程序代码. */ @@ -143,4 +150,11 @@ public interface WxMaCodeConstant { * 新增临时素材 */ String MEDIA_UPLOAD_URL = "https://api.weixin.qq.com/wxa/setwebviewdomain"; + + /** + * 新增临时素材 + */ + String GET_TEMPLATE_URL = "https://api.weixin.qq.com/wxa/gettemplatelist"; + + } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaCodeSubmitAuditRequest.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaCodeSubmitAuditRequest.java index c9fa07b8e4..1c63b9ed3a 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaCodeSubmitAuditRequest.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaCodeSubmitAuditRequest.java @@ -1,5 +1,6 @@ package com.epmet.wxapi.param; +import com.epmet.dto.form.SubmitAuditFormDTO; import com.google.gson.annotations.SerializedName; import lombok.Data; import lombok.NoArgsConstructor; @@ -36,110 +37,16 @@ public class WxMaCodeSubmitAuditRequest implements Serializable { * 审核项列表(选填,至多填写 5 项) */ @SerializedName("item_list") - private List itemList; + private List itemList; /** * 预览信息(小程序页面截图和操作录屏) */ @SerializedName("preview_info") - private List previewInfo; + private List previewInfo; /** * 用户生成内容场景(UGC)信息安全声明 */ @SerializedName("ugc_declare") - private List ugcDeclare; + private SubmitAuditFormDTO.UgcDeclareBean ugcDeclare; - @NoArgsConstructor - @Data - private static class ItemListBean { - /** - * 小程序的页面,可通过获取小程序的页面列表接口获得 - */ - @SerializedName("address") - private String address; - /** - * 小程序的标签,用空格分隔,标签至多 10 个,标签长度至多 20 - */ - @SerializedName("tag") - private String tag; - /** - * 一级类目名称 - */ - @SerializedName("first_class") - private String firstClass; - /** - * 二级类目名称 - */ - @SerializedName("second_class") - private String secondClass; - /** - * 三级类目名称 - */ - @SerializedName("third_class") - private String thirdClass; - /** - * 一级类目的 ID - */ - @SerializedName("first_id") - private String firstId; - /** - * 二级类目的 ID - */ - @SerializedName("second_id") - private String secondId; - /** - * 三级类目的 ID - */ - @SerializedName("third_id") - private String thirdId; - /** - * 小程序页面的标题,标题长度至多 32 - */ - @SerializedName("title") - private String title; - } - - @NoArgsConstructor - @Data - private static class PreviewInfoBean { - /** - * 录屏mediaid列表,可以通过提审素材上传接口获得 - */ - @SerializedName("Video_id_list") - private List videoIdList; - /** - * 截屏mediaid列表,可以通过提审素材上传接口获得 - */ - @SerializedName("pic_id_list") - private List picIdList; - } - - @NoArgsConstructor - @Data - private static class UgcDeclareBean { - /** - * UGC场景 0,不涉及用户生成内容, 1.用户资料,2.图片,3.视频,4.文本,5其他, 可多选,当scene填0时无需填写下列字段 - */ - @SerializedName("scene") - private List scene; - /** - * 当scene选其他时的说明,不超时256字 - */ - @SerializedName("other_scene_desc") - private String otherSceneDesc; - /** - * 内容安全机制 1.使用平台建议的内容安全API,2.使用其他的内容审核产品,3.通过人工审核把关,4.未做内容审核把关 - */ - @SerializedName("method") - private List method; - /** - * 是否有审核团队, 0.无,1.有,默认0 - */ - @SerializedName("has_audit_team") - private Integer hasAuditTeam; - /** - * 说明当前对UGC内容的审核机制,不超过256字 - */ - @SerializedName("audit_desc") - private String auditDesc; - } } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaDomainDTO.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaDomainDTO.java new file mode 100644 index 0000000000..694dd0f262 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaDomainDTO.java @@ -0,0 +1,23 @@ +package com.epmet.wxapi.param; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +import java.util.List; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/7/17 17:44 + */ +@Data +@Component +@ConfigurationProperties(prefix = "third.domain") +public class WxMaDomainDTO { + private List requestDomain; + private List wsRequestDomain; + private List uploadDomain; + private List downloadDomain; + private List webviewDomain; +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/impl/WxLoginServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/impl/WxLoginServiceImpl.java index 8ae28634de..6edf2fbbd0 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/impl/WxLoginServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/impl/WxLoginServiceImpl.java @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.redis.RedisUtils; import com.epmet.commons.tools.utils.HttpClientManager; +import com.epmet.constant.ThirdRedisKeyConstant; import com.epmet.dto.UserWechatDTO; import com.epmet.wxapi.constant.WxLoginConstant; import com.epmet.wxapi.service.WxLoginService; @@ -45,29 +46,33 @@ public class WxLoginServiceImpl implements WxLoginService { map.put("js_code", wxCode); map.put("grant_type", "authorization_code"); map.put("component_appid", componentAppId); - String componentAccessToken = (String) redisUtils.get("epmet:wechartthird:componentaccesstoken"); + String componentAccessToken = (String) redisUtils.get(ThirdRedisKeyConstant.ACCESS_TOKEN_REDIS_KEY); map.put("component_access_token", componentAccessToken); String resultStr = HttpClientManager.getInstance().sendGet(WxLoginConstant.WXCODE_BY_OPENID, map).getData(); HashMap hashMap = JSON.parseObject(resultStr, HashMap.class); - if (null != hashMap.get("errorCode")) { + if (null != hashMap.get("errcode")) { logger.error("wxcode换取openid接口调用失败"); - throw new RenException(hashMap.get("errorMsg")); + throw new RenException(hashMap.get("errmsg")); } String openid = hashMap.get("openid"); String sessionKey = hashMap.get("session_key"); //2.换取用户基本信息 //小程序access_token - String access_token = (String) redisUtils.get("epmet:wechartthird:authinfo" + ":" + customerId + ":" + clientType); + Map accessMap = redisUtils.hGetAll(ThirdRedisKeyConstant.AUTH_INFO_REDIS_KEY + ":" + customerId + ":" + clientType); + if(null==accessMap.get("authorizer_access_token")){ + logger.error("获取缓存中小程序access_token失败"); + throw new RenException("access_token获取失败"); + } Map hash = new HashMap<>(); - hash.put("access_token", access_token); + hash.put("access_token", accessMap.get("authorizer_access_token")); hash.put("openid", openid); hash.put("lang", "zh_CN"); String getStr = HttpClientManager.getInstance().sendGet(WxLoginConstant.OPENID_TO_INFORMATION, map).getData(); HashMap resultMap = JSON.parseObject(getStr, HashMap.class); - if (null != resultMap.get("errorCode")) { + if (null != resultMap.get("errcode")) { logger.error("openid和access_token换取微信用户基本信息接口调用失败"); - throw new RenException(resultMap.get("errorMsg")); + throw new RenException(resultMap.get("errormsg")); } //3.返回结果 diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/impl/WxMaCodeServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/impl/WxMaCodeServiceImpl.java index dfc9bb5cc9..e0ae3823e5 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/impl/WxMaCodeServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/impl/WxMaCodeServiceImpl.java @@ -10,14 +10,19 @@ import com.epmet.wxapi.result.*; import com.epmet.wxapi.service.WxMaCodeService; import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonObject; import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import java.io.File; +import java.io.InputStream; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Arrays; import java.util.List; /** @@ -30,21 +35,14 @@ import java.util.List; public class WxMaCodeServiceImpl implements WxMaCodeService { private static final String ERR_CODE = "errcode"; private static final String ERR_MSG = "errmsg"; - @Value("${third.domain.requestdomain}") - private List requestDomain; - @Value("${third.domain.wsrequestdomain}") - private List wsRequestDomain; - @Value("${third.domain.uploaddomain}") - private List uploadDomain; - @Value("${third.domain.downloaddomain}") - private List downloadDomain; - @Value("${third.domain.webviewdomain}") - private List webviewDomain; + + @Autowired + private WxMaDomainDTO wxMaDomainDTO; @Override public WxResult> getTemplateList(String accessToken) { WxResult> result = new WxResult<>(); - String url = WxMaCodeConstant.COMMIT_URL + "?" + "access_token=" + accessToken; + String url = WxMaCodeConstant.GET_TEMPLATE_URL + "?" + "access_token=" + accessToken; Result templateListResult = HttpClientManager.getInstance().sendGet(url, null); if (!templateListResult.success()) { result.setErrorCode(templateListResult.getCode()); @@ -54,7 +52,7 @@ public class WxMaCodeServiceImpl implements WxMaCodeService { Gson gson = new Gson(); WxMaTemplateListResult templateList = gson.fromJson(templateListResult.getData(), WxMaTemplateListResult.class); result.setErrorCode(templateList.getErrCode()); - result.setErrorMsg(templateList.getErrMsg()); + result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(templateList.getErrCode())); result.setData(templateList.getTemplateList()); return result; } @@ -153,7 +151,7 @@ public class WxMaCodeServiceImpl implements WxMaCodeService { @Override public WxResult getAuditStatus(String accessToken, WxMaCodeAuditStatusReq request) { WxResult result = new WxResult<>(); - String url = WxMaCodeConstant.COMMIT_URL + "?" + "access_token=" + accessToken; + String url = WxMaCodeConstant.GET_AUDIT_STATUS_URL + "?" + "access_token=" + accessToken; Result statusResult = HttpClientManager.getInstance().sendPostByJSON(url, toJson(request)); if (!statusResult.success()) { result.setErrorCode(statusResult.getCode()); @@ -213,6 +211,7 @@ public class WxMaCodeServiceImpl implements WxMaCodeService { return result; } Gson gson = new Gson(); + InputStream inputStream = gson.fromJson(statusResult.getData(), InputStream.class); WxMaNewsResult newsResult = gson.fromJson(statusResult.getData(), WxMaNewsResult.class); result.ok(newsResult); return result; @@ -224,10 +223,10 @@ public class WxMaCodeServiceImpl implements WxMaCodeService { String url = WxMaCodeConstant.MODIFY_DOMAIN_URL + "?" + "access_token=" + accessToken; WxMaModifyDomainReq request = new WxMaModifyDomainReq(); request.setAction("set"); - request.setRequestDomain(requestDomain); - request.setUploadDomain(uploadDomain); - request.setWsRequestDomain(wsRequestDomain); - request.setDownloadDomain(downloadDomain); + request.setRequestDomain(wxMaDomainDTO.getRequestDomain()); + request.setUploadDomain(wxMaDomainDTO.getUploadDomain()); + request.setWsRequestDomain(wxMaDomainDTO.getWsRequestDomain()); + request.setDownloadDomain(wxMaDomainDTO.getDownloadDomain()); Result modifyResult = HttpClientManager.getInstance().sendPostByJSON(url, toJson(request)); if (!modifyResult.success()) { result.setErrorCode(modifyResult.getCode()); @@ -246,7 +245,7 @@ public class WxMaCodeServiceImpl implements WxMaCodeService { String url = WxMaCodeConstant.SET_WEBVIEW_DOMAIN_URL + "?" + "access_token=" + accessToken; WxMaSetWebviewDomainReq request = new WxMaSetWebviewDomainReq(); request.setAction("set"); - request.setWebViewDomain(webviewDomain); + request.setWebViewDomain(wxMaDomainDTO.getWebviewDomain()); Result modifyResult = HttpClientManager.getInstance().sendPostByJSON(url, toJson(request)); if (!modifyResult.success()) { result.setErrorCode(modifyResult.getCode()); diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/bootstrap.yml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/bootstrap.yml index 34cba72036..82188b3697 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/bootstrap.yml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/bootstrap.yml @@ -105,8 +105,13 @@ third: aesKey: d6dbde92c67e11eabac1c03fd56f7847qazxswedcvg token: 1ae5f230c67f11eabac1c03fd56f7847 domain: - requestdomain: "https://epmet-cloud.elinkservice.cn" - wsrequestdomain: "https://epmet-cloud.elinkservice.cn" - uploaddomain: "https://epmet-cloud.elinkservice.cn" - downloaddomain: "https://epmet-cloud.elinkservice.cn" - webviewdomain: "https://epmet-cloud.elinkservice.cn" \ No newline at end of file + requestDomain: + - https://epmet-cloud.elinkservice.cn + wsRequestDomain: + - https://epmet-cloud.elinkservice.cn + uploadDomain: + - https://epmet-cloud.elinkservice.cn + downloadDomain: + - https://epmet-cloud.elinkservice.cn + webviewDomain: + - https://epmet-cloud.elinkservice.cn \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/AuthResultRecordDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/AuthResultRecordDao.xml index d0c2ba2654..9cc47df530 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/AuthResultRecordDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/AuthResultRecordDao.xml @@ -3,4 +3,25 @@ + + + INSERT INTO auth_result_record ( ID, COMPONENT_APP_ID, WECHAT_CREATE_TIME, INFO_TYPE, AUTHORIZER_APP_ID, AUTHORIZATION_CODE, EXPIRES_IN_TIME, PRE_AUTH_CODE, DEL_FLAG, REVISION, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME ) + VALUES + ( + REPLACE(UUID(),'-',''), + #{componentAppId}, + #{wechatCreateTime}, + #{InfoType}, + #{AuthorizerAppid}, + #{AuthorizationCode}, + #{ExpiredTime}, + #{PreAuthCode}, + #{delFlag}, + #{revision}, + #{createdBy}, + NOW(), + #{updatedBy}, + NOW() + ) + \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/AuthorizationInfoDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/AuthorizationInfoDao.xml index 406a9fd06c..d8ab9821eb 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/AuthorizationInfoDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/AuthorizationInfoDao.xml @@ -5,7 +5,7 @@ - INSERT INTO authorization_info ( ID, CUSTOMER_ID, AUTHORIZER_APPID, AUTHORIZER_ACCESS_TOKEN, EXPIRES_IN_TIME, AUTHORIZER_REFRESH_TOKEN, CLIENT_TYPE, DEL_FLAG, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME ) + INSERT INTO authorization_info ( ID, CUSTOMER_ID, AUTHORIZER_APPID, AUTHORIZER_ACCESS_TOKEN, EXPIRES_IN_TIME, AUTHORIZER_REFRESH_TOKEN, FUNC_INFO, CLIENT_TYPE, DEL_FLAG, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME ) VALUES ( REPLACE ( UUID(), '-', '' ), @@ -14,6 +14,7 @@ #{authorizerAccessToken}, #{expiresInTime}, #{authorizerRefreshToken}, + #{funcInfo}, #{clientType}, #{delFlag}, #{createdBy}, @@ -25,7 +26,7 @@ - update authorization_info set del_flag = 1 where customer_id = #{customerId} AND client_type = #{clientType} + update authorization_info set del_flag = 1 where authorizer_appid = #{authAppId} @@ -41,7 +42,6 @@ WHERE del_flag = 0 AND (UNIX_TIMESTAMP(expires_in_time) - UNIX_TIMESTAMP(NOW())) 900 - AND (UNIX_TIMESTAMP(expires_in_time) - UNIX_TIMESTAMP(NOW())) > 0 @@ -68,6 +68,7 @@ update authorization_info set del_flag = 1 where customer_id = #{customerId} AND client_type = #{clientType} + + + + \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/BindingAccountDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/BindingAccountDao.xml index 8547b41dcf..d0d3d49815 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/BindingAccountDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/BindingAccountDao.xml @@ -15,7 +15,7 @@ #{clientType}, #{delFlag}, #{revision}, - #{createDBy}, + #{createdBy}, NOW(), #{updatedBy}, NOW() diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeCustomerDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeCustomerDao.xml index 22d77316e6..dbfe38c5e7 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeCustomerDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeCustomerDao.xml @@ -31,8 +31,8 @@ cc.USER_VERSION AS "version", cc.USER_DESC AS "codeInfo", cc.STATUS, - DATE_FORMAT(cc.CREATED_TIME,'%Y-%m-%d') AS "uploadTime", - IFNULL(DATE_FORMAT(car.CREATED_TIME,'%Y-%m-%d'),'') AS "auditTime", + DATE_FORMAT(cc.CREATED_TIME,'%Y-%m-%d %T') AS "uploadTime", + IFNULL(DATE_FORMAT(car.CREATED_TIME,'%Y-%m-%d %T'),'') AS "auditTime", car.AUDIT_ID FROM code_customer cc LEFT JOIN code_audit_result car ON cc.ID = car.CODE_ID AND car.DEL_FLAG = '0' diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeOperationHistoryDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeOperationHistoryDao.xml index 277beabe35..66041c4ea0 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeOperationHistoryDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeOperationHistoryDao.xml @@ -9,7 +9,7 @@ - + @@ -19,7 +19,7 @@ UPDATE code_operation_history SET - `DESCRIBE` = #{describe} + `DESCRIPTION` = #{describe} WHERE CODE_ID = #{codeId} AND OPERATION = 'audit' @@ -28,7 +28,7 @@ DATE_FORMAT(coh.CREATED_TIME, '%Y-%m-%d') AS "operationTime", coh.VERSION, coh.OPERATION, - coh.`DESCRIBE` + coh.`DESCRIPTION` FROM code_operation_history coh INNER JOIN code_customer cc ON coh.CODE_ID = cc.ID WHERE diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ComponentAccessTokenDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ComponentAccessTokenDao.xml index 53e1820b8a..c48019c3a3 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ComponentAccessTokenDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ComponentAccessTokenDao.xml @@ -28,7 +28,7 @@ COMPONENT_ACCESS_TOKEN FROM component_access_token - WHERE delFlag = '0' + WHERE DEL_FLAG = '0' diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ComponentVerifyTicketDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ComponentVerifyTicketDao.xml index ba33593a48..c875223478 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ComponentVerifyTicketDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ComponentVerifyTicketDao.xml @@ -21,9 +21,9 @@ - - update component_verify_ticket set del_flag = 1 - + + DELETE FROM component_verify_ticket WHERE del_flag = 0 + \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CustomerMpDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CustomerMpDao.xml index 4612ca8c88..f4e6b6403a 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CustomerMpDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CustomerMpDao.xml @@ -19,9 +19,9 @@ client ASC - SELECT - COUNT(*) AS notAuthCount + app_id AS authAppId FROM customer_mp WHERE @@ -37,7 +37,7 @@ WHERE customer_id = #{customerId} AND del_flag = '0' - AND client = #{client} + AND client = #{clientType} @@ -51,7 +51,7 @@ + + + \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/OpenFlatformAccountDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/OpenFlatformAccountDao.xml index efaa55adad..4b4842e478 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/OpenFlatformAccountDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/OpenFlatformAccountDao.xml @@ -12,7 +12,7 @@ VALUES ( REPLACE ( UUID(), '-', '' ), - #{openAppId}, + #{openid}, #{customerId}, #{delFlag}, #{revision}, @@ -23,12 +23,17 @@ ) + + + UPDATE open_platform_account set del_flag = 1 where customer_id = #{customerId} + + + SELECT + id, + user_id, + wx_open_id, + open_id, + phone + FROM + pa_user_visited + WHERE + del_flag = '0' + AND wx_open_id = #{openId} + ORDER BY + created_time DESC + LIMIT 1 + \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/deploy/docker-compose-dev.yml b/epmet-module/gov-org/gov-org-server/deploy/docker-compose-dev.yml index d1c7b78043..0b247eae18 100644 --- a/epmet-module/gov-org/gov-org-server/deploy/docker-compose-dev.yml +++ b/epmet-module/gov-org/gov-org-server/deploy/docker-compose-dev.yml @@ -2,7 +2,7 @@ version: "3.7" services: gov-org-server: container_name: gov-org-server-dev - image: 192.168.1.130:10080/epmet-cloud-dev/gov-org-server:0.3.75 + image: 192.168.1.130:10080/epmet-cloud-dev/gov-org-server:0.3.76 ports: - "8092:8092" network_mode: host # 使用现有网络 diff --git a/epmet-module/gov-org/gov-org-server/pom.xml b/epmet-module/gov-org/gov-org-server/pom.xml index 191856ef70..3d9f8fd97c 100644 --- a/epmet-module/gov-org/gov-org-server/pom.xml +++ b/epmet-module/gov-org/gov-org-server/pom.xml @@ -2,7 +2,7 @@ 4.0.0 - 0.3.75 + 0.3.76 com.epmet gov-org diff --git a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java index b14ab6036d..5b220aa698 100644 --- a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java +++ b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java @@ -21,6 +21,6 @@ public interface OperCrmOpenFeignClient { * @param dto * @return */ - @PostMapping("/oper/crm/getcostomerInfo") + @PostMapping("/oper/crm/customer/getcostomerInfo") Result getCustomerInfo(CustomerDTO dto); } diff --git a/epmet-module/resi-guide/resi-guide-server/deploy/docker-compose-dev.yml b/epmet-module/resi-guide/resi-guide-server/deploy/docker-compose-dev.yml index a8b5a7a663..20aac7e3ec 100644 --- a/epmet-module/resi-guide/resi-guide-server/deploy/docker-compose-dev.yml +++ b/epmet-module/resi-guide/resi-guide-server/deploy/docker-compose-dev.yml @@ -2,7 +2,7 @@ version: "3.7" services: resi-guide-server: container_name: resi-guide-server-dev - image: 192.168.1.130:10080/epmet-cloud-dev/resi-guide-server:0.3.17 + image: 192.168.1.130:10080/epmet-cloud-dev/resi-guide-server:0.3.18 ports: - "8091:8091" network_mode: host # 使用现有网络 diff --git a/epmet-module/resi-guide/resi-guide-server/pom.xml b/epmet-module/resi-guide/resi-guide-server/pom.xml index d93427f6b0..48851b561e 100644 --- a/epmet-module/resi-guide/resi-guide-server/pom.xml +++ b/epmet-module/resi-guide/resi-guide-server/pom.xml @@ -2,7 +2,7 @@ 4.0.0 - 0.3.17 + 0.3.18 com.epmet resi-guide diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java index 8a4de9898e..1e1fa0e9e8 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java @@ -148,4 +148,26 @@ public interface EpmetUserOpenFeignClient { **/ @PostMapping("/epmetuser/userbaseinfo/queryuserbaseinfo") Result> queryUserBaseInfo(@RequestBody List userIdList); + + /** + * 根据用户ID,查询用户所属角色: 多种身份 + * + * @param userId + * @return com.epmet.commons.tools.utils.Result> + * @Author zhangyong + * @Date 14:13 2020-07-23 + **/ + @GetMapping(value = "epmetuser/userrole/getuserroleinfobyuserid/{userId}") + Result> getUserRoleInfoByUserId(@PathVariable("userId") String userId); + + /** + * 同步-居民基础信息、用户微信信息 + * + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @Author zhangyong + * @Date 14:37 2020-07-23 + **/ + @PostMapping("epmetuser/user/updateUserBaseAndWxUserInfo") + Result updateUserBaseAndWxUserInfo(@RequestBody WxUserInfoFormDTO formDTO); } diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java index bb2cbe9d77..4bf31e518b 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java @@ -98,4 +98,14 @@ public class EpmetUserOpenFeignClientFallback implements EpmetUserOpenFeignClien public Result> queryUserBaseInfo(List userIdList) { return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "queryUserBaseInfo", userIdList); } + + @Override + public Result> getUserRoleInfoByUserId(String userId) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getUserRoleInfoByUserId", userId); + } + + @Override + public Result updateUserBaseAndWxUserInfo(WxUserInfoFormDTO formDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "updateUserBaseAndWxUserInfo", formDTO); + } } diff --git a/epmet-user/epmet-user-server/deploy/docker-compose-dev.yml b/epmet-user/epmet-user-server/deploy/docker-compose-dev.yml index 88d224e76e..a16884cdcd 100644 --- a/epmet-user/epmet-user-server/deploy/docker-compose-dev.yml +++ b/epmet-user/epmet-user-server/deploy/docker-compose-dev.yml @@ -2,7 +2,7 @@ version: "3.7" services: epmet-user-server: container_name: epmet-user-server-dev - image: 192.168.1.130:10080/epmet-cloud-dev/epmet-user-server:0.3.76 + image: 192.168.1.130:10080/epmet-cloud-dev/epmet-user-server:0.3.77 ports: - "8087:8087" network_mode: host # 不会创建新的网络 diff --git a/epmet-user/epmet-user-server/pom.xml b/epmet-user/epmet-user-server/pom.xml index 2c3f938f56..9ec79e461e 100644 --- a/epmet-user/epmet-user-server/pom.xml +++ b/epmet-user/epmet-user-server/pom.xml @@ -2,7 +2,7 @@ 4.0.0 - 0.3.76 + 0.3.77 com.epmet epmet-user diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserRoleController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserRoleController.java index f73fc1b52f..7a1bbbe99d 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserRoleController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserRoleController.java @@ -128,8 +128,8 @@ public class UserRoleController { * @Author zhangyong * @Date 14:24 2020-07-23 **/ - @PostMapping("getuserroleinfobyuserid/{userId}") - public Result> getUserRoleInfoByUserId(@PathVariable String userId) { + @GetMapping("getuserroleinfobyuserid/{userId}") + public Result> getUserRoleInfoByUserId(@PathVariable("userId") String userId) { return userRoleService.getUserRoleInfoByUserId(userId); } }