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 8777143097..0c6c4cb9ae 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 @@ -240,6 +240,34 @@ public class HttpClientManager { return new Result().error(); } + /** + * @Desc 发送钉钉消息 content需为 OapiRobotSendRequest 设定msgType格式,根据相应的格式填写 标题 内容 + * @param content OapiRobotSendRequest转换为String + * @param url webhook地址 + * @param secret 加签串 + * @author zxc + */ + public Result sendDingMsg(String content,String url,String secret) { + Long timestamp = System.currentTimeMillis(); + try { + String stringToSign = timestamp + "\n" + secret; + Mac mac = Mac.getInstance("HmacSHA256"); + mac.init(new SecretKeySpec(secret.getBytes("UTF-8"), "HmacSHA256")); + byte[] signData = mac.doFinal(stringToSign.getBytes("UTF-8")); + String sign = URLEncoder.encode(new String(Base64.encodeBase64(signData)), "UTF-8"); + log.info("sign为:"+sign); + url = url.concat("×tamp=" + timestamp + "&sign=" + sign); + log.info("发送url:"+url); + Result stringResult = HttpClientManager.getInstance().sendPostByJSON(url, content); + log.info("robot发送消息结果为:"+stringResult.getData()); + return stringResult; + } catch (Exception e) { + e.printStackTrace(); + } + return new Result().error(); + } + + /** * desc: 发送get请求 * param:url, params diff --git a/epmet-module/epmet-heart/epmet-heart-server/deploy/docker-compose-test.yml b/epmet-module/epmet-heart/epmet-heart-server/deploy/docker-compose-test.yml index bd1df2562d..c37ef4ba9f 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/deploy/docker-compose-test.yml +++ b/epmet-module/epmet-heart/epmet-heart-server/deploy/docker-compose-test.yml @@ -2,7 +2,7 @@ version: "3.7" services: epmet-heart-server: container_name: epmet-heart-server-test - image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-release/epmet-heart-server:0.0.45 + image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-release/epmet-heart-server:0.0.46 ports: - "8111:8111" network_mode: host # 使用现有网络 diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/LatestActInfoServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/LatestActInfoServiceImpl.java index 069c4f91c7..3ff7ce31bf 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/LatestActInfoServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/LatestActInfoServiceImpl.java @@ -39,6 +39,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.Arrays; +import java.util.Date; import java.util.List; import java.util.Map; @@ -105,6 +106,10 @@ public class LatestActInfoServiceImpl extends BaseServiceImpl 4.0.0 - 0.0.117 + 0.0.119 com.epmet 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 17bb891ece..de55530200 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 @@ -94,6 +94,7 @@ public interface ModuleConstant { String WE_APP_AUDIT = "weapp_audit"; String TO_USER_NAME = "ToUserName"; String FROM_USER_NAME = "FromUserName"; + String RESI = "resi"; /** * 微信模推送给第三方平台方 Content固定格式 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 b7b7ca6ed6..b03a808edf 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 @@ -214,5 +214,17 @@ public class CodeController { return new Result().ok(pageData); } + @PostMapping("version") + public Result version(@RequestBody CustomerClientFormDTO formDTO) { + CodeVersionInfoResultDTO result = codeService.version(formDTO); + return new Result().ok(result); + } + + @PostMapping("speedupaudit") + public Result speedUpAudit(@RequestBody CodeCommonFormDTO formDTO) { + codeService.speedUpAudit(formDTO); + return new Result<>(); + } + } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CodeCustomerDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CodeCustomerDao.java index 0b1916a56a..7ff7c5114e 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CodeCustomerDao.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CodeCustomerDao.java @@ -73,6 +73,8 @@ public interface CodeCustomerDao extends BaseDao { */ void deleteCode(@Param("customerId") String customerId, @Param("clientType") String clientType); + void deleteCommitCode(@Param("customerId") String customerId, @Param("clientType") String clientType); + /** * 获取审核中代码列表 * @@ -92,7 +94,8 @@ public interface CodeCustomerDao extends BaseDao { * @author zhaoqifeng * @date 2020/7/31 15:54 */ - CodeCustomerDTO selectUploadCodeByCustomer(@Param("customerId") String customerId, @Param("clientType") String clientType); + CodeCustomerDTO selectUploadCodeByCustomer(@Param("codeId") String codeId, @Param("customerId") String customerId, + @Param("clientType") String clientType); /** diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeCustomerService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeCustomerService.java index fcbddcd665..f115eabba7 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeCustomerService.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeCustomerService.java @@ -120,7 +120,7 @@ public interface CodeCustomerService extends BaseService { * @param clientType * @return com.epmet.dto.CodeCustomerDTO */ - CodeCustomerDTO getUploadCodeByCustomer(String customerId, String clientType); + CodeCustomerDTO getUploadCodeByCustomer(String codeId, String customerId, String clientType); /** * 删除旧代码记录 @@ -132,6 +132,16 @@ public interface CodeCustomerService extends BaseService { */ void deleteCode(String customerId, String clientType); + /** + * 删除旧上传记录 + * @author zhaoqifeng + * @date 2020/8/10 11:09 + * @param customerId + * @param clientType + * @return void + */ + void deleteCommitCode(String customerId, String clientType); + /** * 开发版 * @author zhaoqifeng @@ -161,4 +171,14 @@ public interface CodeCustomerService extends BaseService { * @return com.epmet.dto.CodeCustomerDTO */ CodeCustomerDTO getReleaseInfo(String customerId, String clientType); + + /** + * 版本回退 + * @author zhaoqifeng + * @date 2020/8/10 15:50 + * @param customerId + * @param clientType + * @return void + */ + void revertCodeRelease(String customerId, String clientType); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeService.java index a2fb76a0d7..ae2240010c 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeService.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeService.java @@ -163,4 +163,40 @@ public interface CodeService { */ PageData getCustomerList(UploadListFormDTO formDTO); + /** + * 加急审核 + * @author zhaoqifeng + * @date 2020/8/10 14:57 + * @param formDTO + * @return void + */ + void speedUpAudit(CodeCommonFormDTO formDTO); + + /** + * 分阶段发布 + * @author zhaoqifeng + * @date 2020/8/10 15:29 + * @param formDTO + * @return void + */ + void grayRelease(CodeCommonFormDTO formDTO); + + /** + * 取消分阶段发布 + * @author zhaoqifeng + * @date 2020/8/10 15:29 + * @param formDTO + * @return void + */ + void revertGrayRelease(CodeCommonFormDTO formDTO); + + /** + * 版本退回 + * @author zhaoqifeng + * @date 2020/8/10 15:31 + * @param formDTO + * @return void + */ + void revertCodeRelease(CodeCommonFormDTO formDTO); + } 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 cc3b41531d..02de9c657a 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 @@ -120,8 +120,8 @@ public class CodeCustomerServiceImpl extends BaseServiceImpl wxAuditResult = wxMaCodeService.getAuditStatus(authInfo.getAuthorizerAccessToken(), request); - if (wxAuditResult.success()) { - WxMaAuditStatusResult result = wxAuditResult.getData(); - if (result.getStatus() == NumConstant.ZERO) { - audit.setStatus(CodeConstant.AUDIT_SUCCESS); - auditResult.setResult(CodeConstant.AUDIT_SUCCESS); - saveOperation(formDTO.getCustomerId(), formDTO.getClientType(), audit.getId(), audit.getUserVersion(), CodeConstant.OPER_SUCCESS - , "审核成功"); - } else if (result.getStatus() == NumConstant.ONE) { - audit.setStatus(CodeConstant.AUDIT_FAILED); - auditResult.setResult(CodeConstant.AUDIT_FAILED); - auditResult.setReason(result.getReason()); - auditResult.setScreenShot(result.getScreenshot()); - saveOperation(formDTO.getCustomerId(), formDTO.getClientType(), audit.getId(), audit.getUserVersion(), CodeConstant.OPER_FAILED, - result.getReason()); - } else if (result.getStatus() == NumConstant.FOUR) { - audit.setStatus(CodeConstant.DELAY); - auditResult.setResult(CodeConstant.DELAY); - auditResult.setReason(result.getReason()); - saveOperation(formDTO.getCustomerId(), formDTO.getClientType(), audit.getId(), audit.getUserVersion(), CodeConstant.OPER_DELAY, - result.getReason()); + if(null != audit) { + CodeVersionInfoResultDTO.AuditBean auditBean = new CodeVersionInfoResultDTO.AuditBean(); + auditBean.setCodeId(audit.getId()); + auditBean.setVersion(audit.getUserVersion()); + auditBean.setCodeInfo(audit.getUserDesc()); + if (CodeConstant.AUDITING.equals(audit.getStatus())) { + //获取小程序调用令牌 + AuthorizationInfoDTO authInfo = authorizationInfoDao.getAuthInfoByCustomer(formDTO.getCustomerId(), formDTO.getClientType()); + //获取审核结果信息 + CodeAuditResultDTO auditResult = codeAuditResultService.getAuditResultByCodeId(audit.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) { + audit.setStatus(CodeConstant.AUDIT_SUCCESS); + auditResult.setResult(CodeConstant.AUDIT_SUCCESS); + saveOperation(formDTO.getCustomerId(), formDTO.getClientType(), audit.getId(), audit.getUserVersion(), CodeConstant.OPER_SUCCESS + , "审核成功"); + } else if (result.getStatus() == NumConstant.ONE) { + audit.setStatus(CodeConstant.AUDIT_FAILED); + auditResult.setResult(CodeConstant.AUDIT_FAILED); + auditResult.setReason(result.getReason()); + auditResult.setScreenShot(result.getScreenshot()); + saveOperation(formDTO.getCustomerId(), formDTO.getClientType(), audit.getId(), audit.getUserVersion(), CodeConstant.OPER_FAILED, + result.getReason()); + } else if (result.getStatus() == NumConstant.FOUR) { + audit.setStatus(CodeConstant.DELAY); + auditResult.setResult(CodeConstant.DELAY); + auditResult.setReason(result.getReason()); + saveOperation(formDTO.getCustomerId(), formDTO.getClientType(), audit.getId(), audit.getUserVersion(), CodeConstant.OPER_DELAY, + result.getReason()); + } + codeCustomerService.update(audit); + codeAuditResultService.update(auditResult); } - codeCustomerService.update(audit); - codeAuditResultService.update(auditResult); } + auditBean.setStatus(audit.getStatus()); + auditBean.setCommitTime(DateUtils.format(audit.getCommitTime(), DateUtils.DATE_TIME_PATTERN)); + auditBean.setAuditTime(DateUtils.format(audit.getAuditTime(), DateUtils.DATE_TIME_PATTERN)); + resultDTO.setAudit(auditBean); } - resultDTO.getAudit().setStatus(audit.getStatus()); - resultDTO.getAudit().setCommitTime(DateUtils.format(audit.getCommitTime(), DateUtils.DATE_TIME_PATTERN)); - resultDTO.getAudit().setAuditTime(DateUtils.format(audit.getAuditTime(), DateUtils.DATE_TIME_PATTERN)); //线上版本 CodeCustomerDTO release = codeCustomerService.getReleaseInfo(formDTO.getCustomerId(), formDTO.getClientType()); - resultDTO.getRelease().setCodeId(release.getId()); - resultDTO.getRelease().setCodeInfo(release.getUserDesc()); - resultDTO.getRelease().setCommitTime(DateUtils.format(release.getCommitTime(), DateUtils.DATE_TIME_PATTERN)); - resultDTO.getRelease().setAuditTime(DateUtils.format(release.getAuditTime(), DateUtils.DATE_TIME_PATTERN)); - resultDTO.getRelease().setReleaseTime(DateUtils.format(release.getReleaseTime(), DateUtils.DATE_TIME_PATTERN)); - resultDTO.getRelease().setReleaseType(release.getReleaseType()); - resultDTO.getRelease().setGrayPercentage(release.getGaryPercentage()); - resultDTO.getRelease().setVersion(release.getUserVersion()); + if(null != release) { + CodeVersionInfoResultDTO.ReleaseBean releaseBean = new CodeVersionInfoResultDTO.ReleaseBean(); + releaseBean.setCodeId(release.getId()); + releaseBean.setCodeInfo(release.getUserDesc()); + releaseBean.setCommitTime(DateUtils.format(release.getCommitTime(), DateUtils.DATE_TIME_PATTERN)); + releaseBean.setAuditTime(DateUtils.format(release.getAuditTime(), DateUtils.DATE_TIME_PATTERN)); + releaseBean.setReleaseTime(DateUtils.format(release.getReleaseTime(), DateUtils.DATE_TIME_PATTERN)); + releaseBean.setReleaseType(release.getReleaseType()); + releaseBean.setGrayPercentage(release.getGaryPercentage()); + releaseBean.setVersion(release.getUserVersion()); + resultDTO.setRelease(releaseBean); + } + return resultDTO; } @@ -245,7 +257,16 @@ public class CodeServiceImpl implements CodeService { if (null == authInfo) { throw new RenException("未授权"); } - + //获取上传代码信息 + CodeCustomerDTO uploadCode = codeCustomerService.getUploadCodeByCustomer(formDTO.getCodeId(), codeCustomerDTO.getCustomerId(), + codeCustomerDTO.getClientType()); + if (null != uploadCode) { + if (CodeConstant.AUDITING.equals(uploadCode.getStatus())) { + throw new RenException("已经有正在审核的版本"); + } else { + codeCustomerService.deleteById(uploadCode.getId()); + } + } //调用微信API上提交审核 WxMaCodeSubmitAuditRequest request = new WxMaCodeSubmitAuditRequest(); request.setVersionDesc(formDTO.getVersionDesc()); @@ -292,6 +313,7 @@ public class CodeServiceImpl implements CodeService { } //更新代码表状态 codeCustomerDTO.setStatus(CodeConstant.AUDITING); + codeCustomerDTO.setAuditTime(new Date()); codeCustomerService.update(codeCustomerDTO); saveOperation(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType(), codeCustomerDTO.getId(), codeCustomerDTO.getUserVersion(), CodeConstant.OPER_SUBMIT, "审核中"); @@ -370,6 +392,9 @@ public class CodeServiceImpl implements CodeService { //更新代码表状态 codeCustomerDTO.setStatus(CodeConstant.RELEASE_SUCCESS); + codeCustomerDTO.setReleaseTime(new Date()); + codeCustomerDTO.setReleaseType("total"); + codeCustomerDTO.setGaryPercentage(NumConstant.ZERO); codeCustomerService.update(codeCustomerDTO); saveOperation(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType(), codeCustomerDTO.getId(), codeCustomerDTO.getUserVersion(), CodeConstant.OPER_RELEASE, "发布成功"); @@ -467,7 +492,6 @@ public class CodeServiceImpl implements CodeService { public PageData history(CodeCommonFormDTO formDTO) { PageHelper.startPage(formDTO.getPage(), formDTO.getLimit()); //获取上传代码信息 -// CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId()); List list = codeOperationHistoryService.getHistoryList(formDTO.getCodeId()); PageInfo pageInfo = new PageInfo<>(list); return new PageData<>(list, pageInfo.getTotal()); @@ -553,6 +577,57 @@ public class CodeServiceImpl implements CodeService { return paCustomerService.getCustomerList(formDTO); } + @Override + public void speedUpAudit(CodeCommonFormDTO formDTO) { + //获取上传代码信息 + CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId()); + //获取小程序调用令牌 + AuthorizationInfoDTO authInfo = authorizationInfoDao.getAuthInfoByCustomer(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType()); + if (null == authInfo) { + throw new RenException("未授权"); + } + //获取审核结果信息 + CodeAuditResultDTO codeAuditResultDTO = codeAuditResultService.getAuditResultByCodeId(formDTO.getCodeId()); + //调用微信API 加急审核 + WxMaSpeedUpAuditReq speedRequest = new WxMaSpeedUpAuditReq(); + speedRequest.setAuditId(codeAuditResultDTO.getAuditId()); + WxResult wxSpeedResult = wxMaCodeService.speedUpAudit(authInfo.getAuthorizerAccessToken(), speedRequest); + if (!wxSpeedResult.success()) { + saveOperation(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType(), codeCustomerDTO.getId(), + codeCustomerDTO.getUserVersion(), CodeConstant.OPER_SUBMIT, wxSpeedResult.getErrorMsg()); + throw new RenException(wxSpeedResult.getErrorCode(), wxSpeedResult.getErrorMsg()); + } + } + + @Override + public void grayRelease(CodeCommonFormDTO formDTO) { + + } + + @Override + public void revertGrayRelease(CodeCommonFormDTO formDTO) { + + } + + @Override + public void revertCodeRelease(CodeCommonFormDTO formDTO) { + //获取上传代码信息 + CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId()); + //获取小程序调用令牌 + AuthorizationInfoDTO authInfo = authorizationInfoDao.getAuthInfoByCustomer(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType()); + if (null == authInfo) { + throw new RenException("未授权"); + } + WxResult wxSpeedResult = wxMaCodeService.revertCodeRelease(authInfo.getAuthorizerAccessToken()); + if (!wxSpeedResult.success()) { + saveOperation(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType(), codeCustomerDTO.getId(), + codeCustomerDTO.getUserVersion(), CodeConstant.OPER_SUBMIT, wxSpeedResult.getErrorMsg()); + throw new RenException(wxSpeedResult.getErrorCode(), wxSpeedResult.getErrorMsg()); + } + codeCustomerService.revertCodeRelease(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType()); + codeCustomerService.deleteById(codeCustomerDTO.getId()); + } + private void saveOperation(String customerId, String clientType, String codeId, String version, String operation, String describe) { CodeOperationHistoryDTO operationDTO = new CodeOperationHistoryDTO(); operationDTO.setCustomerId(customerId); diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/WarrantServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/WarrantServiceImpl.java index 3e8994ae50..85b15f296d 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/WarrantServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/WarrantServiceImpl.java @@ -3,12 +3,8 @@ package com.epmet.service.impl; import cn.hutool.json.JSONObject; import com.alibaba.fastjson.JSON; import com.alibaba.nacos.client.config.utils.IOUtils; -import com.dingtalk.api.DefaultDingTalkClient; -import com.dingtalk.api.DingTalkClient; import com.dingtalk.api.request.OapiRobotSendRequest; -import com.dingtalk.api.response.OapiRobotSendResponse; import com.epmet.commons.tools.constant.NumConstant; -import com.epmet.commons.tools.dto.form.DingTalkTextMsg; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.HttpClientManager; @@ -28,10 +24,6 @@ import com.epmet.mpaes.WXXmlToMapUtil; import com.epmet.redis.RedisThird; import com.epmet.service.WarrantService; import com.epmet.wxapi.constant.WxMaCodeConstant; -import com.fasterxml.jackson.core.JsonEncoding; -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.taobao.api.ApiException; import lombok.extern.slf4j.Slf4j; import org.apache.commons.codec.binary.Base64; import org.apache.commons.lang3.StringUtils; @@ -152,7 +144,7 @@ public class WarrantServiceImpl implements WarrantService { codeAuditRecord.setAuthAppId(authAppId); codeAuditRecord.setTemplateId(templateId); String customerName = paCustomerDao.selectCustomerName(customerId); - String client = this.getClient(clientType); + String client = clientType.equals(ModuleConstant.RESI) ? "居民端" : "工作端"; //插入 代码审核 记录 log.info(String.format(ThirdRunTimeInfoConstant.CODE_AUDIT_RESULT, xml)); codeAuditRecordDao.insertCodeAuditRecord(codeAuditRecord); @@ -171,7 +163,7 @@ public class WarrantServiceImpl implements WarrantService { break; } log.info("开始寻找机器人发送消息"); - this.dingDingRobot(reason,codeResult,customerName,client); + this.dingDingRobot(reason,event,customerName,client); log.info("已找到robot,并发送消息......"); String codeCustomerId = codeCustomerDao.selectCodeCustomerId(codeAuditRecord); codeAuditResultDao.updateAuditResult(customerId, codeCustomerId, codeResult); @@ -201,7 +193,6 @@ public class WarrantServiceImpl implements WarrantService { PrintWriter pw = response.getWriter();//需在5秒内返回空串表明暂时不回复,然后再立即使用客服消息接口发送消息回复粉丝 pw.write(""); pw.flush(); - log.info(String.format(ThirdRunTimeInfoConstant.TEXT_MESSAGE_LOG_INFO,content,content.split(ThirdRedisKeyConstant.COLON)[NumConstant.ONE],fromUserName,toUserName)); //接下来客服API再回复一次消息 String[] split = content.split(ThirdRedisKeyConstant.COLON); @@ -247,39 +238,9 @@ public class WarrantServiceImpl implements WarrantService { log.info("robot需要发送的内容为:"+markdown.getText()); String url = "https://oapi.dingtalk.com/robot/send?access_token=2438902efbcc15909deb7076963c5cbe2d6fdbfdb9d66750faab2f2cce6eb09f"; String secret = "SECe3c785dd254659608667a4a623acc5a0395636143411617f6e36838b48941e74"; - this.sendCodeMsg(request,url,secret); + HttpClientManager.getInstance().sendDingMsg(JSON.toJSONString(request),url,secret); } -// public static void main(String[] args) { -// WarrantServiceImpl w = new WarrantServiceImpl(); -// w.dingDingRobot("审核失败","weapp_audit_fail","机器人测试","居民端"); -// } - public Result sendCodeMsg(OapiRobotSendRequest request,String url,String secret) { - Long timestamp = System.currentTimeMillis(); - try { - String stringToSign = timestamp + "\n" + secret; - Mac mac = Mac.getInstance("HmacSHA256"); - mac.init(new SecretKeySpec(secret.getBytes("UTF-8"), "HmacSHA256")); - byte[] signData = mac.doFinal(stringToSign.getBytes("UTF-8")); - String sign = URLEncoder.encode(new String(Base64.encodeBase64(signData)), "UTF-8"); - log.info("sign为:"+sign); - url = url.concat("×tamp=" + timestamp + "&sign=" + sign); - log.info("发送url:"+url); - String requestString = JSON.toJSONString(request); - log.info("发送内容:"+requestString); - Result stringResult = HttpClientManager.getInstance().sendPostByJSON(url, requestString); - log.info("robot发送消息结果为:"+stringResult.getData()); - return stringResult; - } catch (Exception e) { - e.printStackTrace(); - } - return new Result().error(); - } - - public String getClient(String clientType){ - String result = clientType == "resi" ? "居民端" : "工作端"; - return result; - } /** * 方法描述: 类型为event的时候,拼接 diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/WxMaCodeService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/WxMaCodeService.java index 28212e5674..df405b12e9 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/WxMaCodeService.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/WxMaCodeService.java @@ -191,4 +191,13 @@ public interface WxMaCodeService { * @date 2020/8/6 14:07 */ WxResult getAccountBasicInfo(String accessToken); + + /** + * 版本退回 + * @author zhaoqifeng + * @date 2020/8/10 15:41 + * @param accessToken + * @return com.epmet.wxapi.result.WxResult + */ + WxResult revertCodeRelease(String accessToken); } 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 e91b31cee6..4711ac11b7 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 @@ -293,7 +293,7 @@ public class WxMaCodeServiceImpl implements WxMaCodeService { public WxResult getWeAppSupportVersion(String accessToken) { WxResult result = new WxResult<>(); String url = WxMaCodeConstant.GET_SUPPORT_VERSION_URL + "?" + "access_token=" + accessToken; - Result statusResult = HttpClientManager.getInstance().sendPostByJSON(url, null); + Result statusResult = HttpClientManager.getInstance().sendPostByJSON(url, "{}"); if (!statusResult.success()) { result.setErrorCode(statusResult.getCode()); result.setErrorMsg(statusResult.getMsg()); @@ -367,6 +367,22 @@ public class WxMaCodeServiceImpl implements WxMaCodeService { return result; } + @Override + public WxResult revertCodeRelease(String accessToken) { + WxResult result = new WxResult(); + String url = WxMaCodeConstant.REVERT_CODE_RELEASE_URL + "?" + "access_token=" + accessToken; + Result setVersionResult = HttpClientManager.getInstance().sendPostByJSON(url, null); + if (!setVersionResult.success()) { + result.setErrorCode(setVersionResult.getCode()); + result.setErrorMsg(setVersionResult.getMsg()); + return result; + } + JSONObject jsonObject = JSONObject.parseObject(setVersionResult.getData()); + result.setErrorCode(jsonObject.getInteger(ERR_CODE)); + result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(jsonObject.getInteger(ERR_CODE))); + return result; + } + private String toJson(Object object) { GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.setPrettyPrinting(); 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 4ef32234ef..366e15e889 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 @@ -21,6 +21,15 @@ + + UPDATE code_customer + SET + DEL_FLAG = '1' + WHERE CUSTOMER_ID = #{customerId} + AND CLIENT_TYPE = #{clientType} + AND STATUS = 'unaudited' + AND DEL_FLAG = '0' + @@ -116,8 +128,9 @@ FROM code_customer WHERE CUSTOMER_ID = #{customerId} AND CLIENT_TYPE = #{clientType} - AND STATUS = 'unaudited' AND DEL_FLAG = '0' + ORDER BY COMMIT_TIME DESC + LIMIT 1