|
|
@ -7,8 +7,8 @@ import com.dingtalk.api.request.OapiRobotSendRequest; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.DateUtils; |
|
|
|
import com.epmet.commons.tools.utils.HttpClientManager; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.constant.ModuleConstant; |
|
|
|
import com.epmet.constant.ThirdRedisKeyConstant; |
|
|
|
import com.epmet.constant.ThirdRunTimeInfoConstant; |
|
|
@ -17,6 +17,7 @@ import com.epmet.dto.form.CodeAuditRecordFormDTO; |
|
|
|
import com.epmet.dto.form.MessagePushTextFormDTO; |
|
|
|
import com.epmet.dto.result.AuthorizationInfoResultDTO; |
|
|
|
import com.epmet.dto.result.CustomerIdAndClientResultDTO; |
|
|
|
import com.epmet.dto.result.DingResultDTO; |
|
|
|
import com.epmet.dto.result.TemplateAndAppIdResultDTO; |
|
|
|
import com.epmet.mpaes.AesException; |
|
|
|
import com.epmet.mpaes.WXBizMsgCrypt; |
|
|
@ -25,7 +26,6 @@ import com.epmet.redis.RedisThird; |
|
|
|
import com.epmet.service.WarrantService; |
|
|
|
import com.epmet.wxapi.constant.WxMaCodeConstant; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.codec.binary.Base64; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.dom4j.DocumentException; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
@ -33,14 +33,11 @@ import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import javax.crypto.Mac; |
|
|
|
import javax.crypto.spec.SecretKeySpec; |
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.InputStream; |
|
|
|
import java.io.PrintWriter; |
|
|
|
import java.net.URLEncoder; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.Map; |
|
|
@ -55,8 +52,6 @@ public class WarrantServiceImpl implements WarrantService { |
|
|
|
|
|
|
|
@Value("${third.platform.appId}") |
|
|
|
private String componentAppId; |
|
|
|
@Value("${third.platform.appSecret}") |
|
|
|
private String appSecret; |
|
|
|
@Value("${third.platform.aesKey}") |
|
|
|
private String aesKey; |
|
|
|
@Value("${third.platform.token}") |
|
|
@ -72,11 +67,7 @@ public class WarrantServiceImpl implements WarrantService { |
|
|
|
@Autowired |
|
|
|
private ComponentVerifyTicketServiceImpl componentVerifyTicketServiceImpl; |
|
|
|
@Autowired |
|
|
|
private MessagePushTextDao messagePushTextDao; |
|
|
|
@Autowired |
|
|
|
private RedisThird redisThird; |
|
|
|
@Autowired |
|
|
|
private PaCustomerDao paCustomerDao; |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 1.保存代码审核结果 2.更新代码上传结果 |
|
|
@ -143,27 +134,35 @@ public class WarrantServiceImpl implements WarrantService { |
|
|
|
codeAuditRecord.setCustomerId(customerId); |
|
|
|
codeAuditRecord.setAuthAppId(authAppId); |
|
|
|
codeAuditRecord.setTemplateId(templateId); |
|
|
|
String customerName = paCustomerDao.selectCustomerName(customerId); |
|
|
|
String client = clientType.equals(ModuleConstant.RESI) ? "居民端" : "工作端"; |
|
|
|
//插入 代码审核 记录
|
|
|
|
log.info(String.format(ThirdRunTimeInfoConstant.CODE_AUDIT_RESULT, xml)); |
|
|
|
codeAuditRecordDao.insertCodeAuditRecord(codeAuditRecord); |
|
|
|
// 修改 code_audit_result 中的代码审核结果
|
|
|
|
String reason = codeAuditRecord.getReason(); |
|
|
|
String codeResult = null; |
|
|
|
switch (event) { |
|
|
|
case ModuleConstant.WEAPP_AUDIT_SUCCESS: |
|
|
|
codeResult = ModuleConstant.AUDIT_SUCCESS; |
|
|
|
Long successTime = Long.valueOf(xml.get(ModuleConstant.SUCC_TIME).toString()); |
|
|
|
codeAuditRecord.setSuccTime(componentVerifyTicketServiceImpl.sToDate(successTime.toString())); |
|
|
|
break; |
|
|
|
case ModuleConstant.WEAPP_AUDIT_FAIL: |
|
|
|
codeResult = ModuleConstant.AUDIT_FAILED; |
|
|
|
Long failTime = Long.valueOf(xml.get(ModuleConstant.FAIL_TIME).toString()); |
|
|
|
codeAuditRecord.setFailTime(componentVerifyTicketServiceImpl.sToDate(failTime.toString())); |
|
|
|
break; |
|
|
|
case ModuleConstant.WEAPP_AUDIT_DELAY: |
|
|
|
codeResult = ModuleConstant.DELAY; |
|
|
|
Long delayTime = Long.valueOf(xml.get(ModuleConstant.DELAY_TIME).toString()); |
|
|
|
codeAuditRecord.setDelayTime(componentVerifyTicketServiceImpl.sToDate(delayTime.toString())); |
|
|
|
break; |
|
|
|
default: |
|
|
|
codeResult = ModuleConstant.AUDIT_FAILED; |
|
|
|
} |
|
|
|
//插入 代码审核 记录
|
|
|
|
log.info(String.format(ThirdRunTimeInfoConstant.CODE_AUDIT_RESULT, xml)); |
|
|
|
codeAuditRecordDao.insertCodeAuditRecord(codeAuditRecord); |
|
|
|
// 修改 code_audit_result 中的代码审核结果
|
|
|
|
String reason = codeAuditRecord.getReason(); |
|
|
|
log.info("开始寻找机器人发送消息"); |
|
|
|
this.dingDingRobot(reason,event,customerName,client); |
|
|
|
DingResultDTO dingResultDTO = codeCustomerDao.selectCustomerNameAndVersion(customerId, clientType); |
|
|
|
this.dingDingRobot(reason,event,dingResultDTO,client,codeAuditRecord); |
|
|
|
log.info("已找到robot,并发送消息......"); |
|
|
|
String codeCustomerId = codeCustomerDao.selectCodeCustomerId(codeAuditRecord); |
|
|
|
codeAuditResultDao.updateAuditResult(customerId, codeCustomerId, codeResult); |
|
|
@ -201,38 +200,57 @@ public class WarrantServiceImpl implements WarrantService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/*public static void main(String[] args) { |
|
|
|
WarrantServiceImpl w = new WarrantServiceImpl(); |
|
|
|
DingResultDTO ding = new DingResultDTO(); |
|
|
|
ding.setUserVersion("1.1.1"); |
|
|
|
ding.setCustomerName("阿里巴巴"); |
|
|
|
CodeAuditRecordFormDTO dto = new CodeAuditRecordFormDTO(); |
|
|
|
String format = DateUtils.format(new Date(),ModuleConstant.DATE_FORMAT); |
|
|
|
System.out.println(format); |
|
|
|
dto.setFailTime(new Date()); |
|
|
|
w.dingDingRobot("再次失败","weapp_audit_fail",ding,"支付宝",dto); |
|
|
|
}*/ |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 钉钉机器人报警 |
|
|
|
* @author zxc |
|
|
|
* @date 2020/8/5 4:33 下午 |
|
|
|
*/ |
|
|
|
public void dingDingRobot(String result,String event,String customerName,String clientType){ |
|
|
|
public void dingDingRobot(String result,String event,DingResultDTO dingResultDTO,String clientType,CodeAuditRecordFormDTO codeAuditRecord){ |
|
|
|
OapiRobotSendRequest request = new OapiRobotSendRequest(); |
|
|
|
request.setMsgtype("markdown"); |
|
|
|
OapiRobotSendRequest.Markdown markdown = new OapiRobotSendRequest.Markdown(); |
|
|
|
markdown.setTitle("代码审核结果"); |
|
|
|
String customerName = dingResultDTO.getCustomerName(); |
|
|
|
String userVersion = dingResultDTO.getUserVersion(); |
|
|
|
switch (event){ |
|
|
|
case ModuleConstant.WEAPP_AUDIT_SUCCESS: |
|
|
|
markdown.setText("代码审核结果: 审核成功\n"+ |
|
|
|
"> 客户名称:" + customerName +"\n\n"+ |
|
|
|
"> 客户端:"+clientType+"\n"); |
|
|
|
"> 客户端:"+clientType+"\n\n"+ |
|
|
|
"> 审核成功时间:"+DateUtils.format(codeAuditRecord.getSuccTime(),ModuleConstant.DATE_FORMAT)+"\n\n"+ |
|
|
|
"> 版本号:"+userVersion); |
|
|
|
break; |
|
|
|
case ModuleConstant.WEAPP_AUDIT_FAIL: |
|
|
|
markdown.setText("代码审核结果: 审核不通过\n"+ |
|
|
|
"> 客户名称:" + customerName +"\n\n"+ |
|
|
|
"> 客户端:"+clientType+"\n\n"+ |
|
|
|
"> 审核失败时间:"+DateUtils.format(codeAuditRecord.getFailTime(),ModuleConstant.DATE_FORMAT)+"\n\n"+ |
|
|
|
"> 版本号:"+userVersion+"\n\n"+ |
|
|
|
"> 不通过原因:"+result); |
|
|
|
break; |
|
|
|
case ModuleConstant.WEAPP_AUDIT_DELAY: |
|
|
|
markdown.setText("代码审核结果: 审核延时\n"+ |
|
|
|
"> 客户名称:" + customerName +"\n\n"+ |
|
|
|
"> 客户端:"+clientType+"\n\n"+ |
|
|
|
"> 审核延时时间:"+DateUtils.format(codeAuditRecord.getDelayTime(),ModuleConstant.DATE_FORMAT)+"\n\n"+ |
|
|
|
"> 版本号:"+userVersion+"\n\n"+ |
|
|
|
"> 延时原因:"+result); |
|
|
|
break; |
|
|
|
default: |
|
|
|
markdown.setText("机器人生病了......"); |
|
|
|
log.info("event为:"+event); |
|
|
|
break; |
|
|
|
} |
|
|
|
request.setMarkdown(markdown); |
|
|
|
log.info("robot需要发送的内容为:"+markdown.getText()); |
|
|
|