| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -3,6 +3,10 @@ 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.utils.ConvertUtils; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.tools.utils.HttpClientManager; | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -24,6 +28,7 @@ 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.lang3.StringUtils; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import org.dom4j.DocumentException; | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -70,6 +75,8 @@ public class WarrantServiceImpl implements WarrantService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    private MessagePushTextDao messagePushTextDao; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    @Autowired | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    private RedisThird redisThird; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    @Autowired | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    private PaCustomerDao paCustomerDao; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    /** | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @Description  1.保存代码审核结果 2.更新代码上传结果 | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -134,21 +141,27 @@ public class WarrantServiceImpl implements WarrantService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                codeAuditRecord.setCustomerId(customerId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                codeAuditRecord.setAuthAppId(authAppId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                codeAuditRecord.setTemplateId(templateId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                String customerName = paCustomerDao.selectCustomerName(customerId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                String client = this.getClient(clientType); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                //插入 代码审核 记录
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                log.info(String.format(ThirdRunTimeInfoConstant.CODE_AUDIT_RESULT, xml)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                codeAuditRecordDao.insertCodeAuditRecord(codeAuditRecord); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                // 修改 code_audit_result 中的代码审核结果
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//                String event = codeAuditRecord.getEvent();
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                String reason = codeAuditRecord.getReason(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                String codeResult = null; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                switch (event) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    case ModuleConstant.WEAPP_AUDIT_SUCCESS: | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        codeResult = ModuleConstant.AUDIT_SUCCESS; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        this.dingDingRobot(reason,null,customerName,client); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        break; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    case ModuleConstant.WEAPP_AUDIT_FAIL: | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        codeResult = ModuleConstant.AUDIT_FAILED; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        this.dingDingRobot(reason,codeResult,customerName,client); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        break; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    case ModuleConstant.WEAPP_AUDIT_DELAY: | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        codeResult = ModuleConstant.DELAY; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        this.dingDingRobot(reason,codeResult,customerName,client); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        break; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                String codeCustomerId = codeCustomerDao.selectCodeCustomerId(codeAuditRecord); | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -190,6 +203,44 @@ public class WarrantServiceImpl implements WarrantService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        return ModuleConstant.SUCCESS; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    public void dingDingRobot(String result,String event,String customerName,String clientType){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/robot/send?access_token=5b48fcbc3fde24b8ba4696aa062b7f8146479a9d3467dbb1f9cf132ec36b955a"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        OapiRobotSendRequest request = new OapiRobotSendRequest(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        request.setMsgtype("text"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        OapiRobotSendRequest.Text text = new OapiRobotSendRequest.Text(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        switch (event){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            case ModuleConstant.WEAPP_AUDIT_SUCCESS: | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                text.setContent("代码审核结果: 审核成功\n"+ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        "客户名称:" + customerName +"\n"+ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        "客户端:"+clientType+"\n"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                break; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            case ModuleConstant.WEAPP_AUDIT_FAIL: | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                text.setContent("代码审核结果: 审核不通过\n"+ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        "客户名称:" + customerName +"\n"+ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        "客户端:"+clientType+"\n"+ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        "不通过原因:"+result); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                break; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            case ModuleConstant.WEAPP_AUDIT_DELAY: | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                text.setContent("代码审核结果: 审核延时\n"+ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        "客户名称:" + customerName +"\n"+ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        "客户端:"+clientType+"\n"+ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        "延时原因:"+result); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                break; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        request.setText(text); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        try { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            OapiRobotSendResponse response = client.execute(request); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } catch (ApiException e) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            log.error("机器人生病了......"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            e.printStackTrace(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    public String getClient(String clientType){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        String result = clientType == "resi" ? "居民端" : "工作端"; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        return result; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    /** | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * 方法描述: 类型为enevt的时候,拼接 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @param request | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -242,7 +293,7 @@ public class WarrantServiceImpl implements WarrantService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    public void replyTextMessage(HttpServletRequest request, HttpServletResponse response, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                                 String content,String toUserName, String fromUserName) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            throws DocumentException, IOException { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        Long createTime = System.currentTimeMillis() / 1000; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        Long createTime = System.currentTimeMillis() / NumConstant.ONE_THOUSAND; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        StringBuffer sb = new StringBuffer(512); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        sb.append("<xml>"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        sb.append("<ToUserName><![CDATA["+toUserName+"]]></ToUserName>"); | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -269,7 +320,7 @@ public class WarrantServiceImpl implements WarrantService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        // 得到微信授权成功的消息后,应该立刻进行处理!!相关信息只会在首次授权的时候推送过来
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        //第三方平台【component_access_token】
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        String componentAccessToken = redisThird.getComponentAccessToken(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        com.alibaba.fastjson.JSONObject jsonObject = new com.alibaba.fastjson.JSONObject(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        JSONObject jsonObject = new JSONObject(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        jsonObject.put(ModuleConstant.COMPONENT_APPID, componentAppId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        jsonObject.put(ModuleConstant.AUTHORIZATION_CODE, auth_code); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        String authInfo = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_QUERY_AUTH_URL + componentAccessToken, JSON.toJSONString(jsonObject)).getData(); | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				
					
  |