Browse Source

修復+行信逻辑

fangq 4 năm trước cách đây
mục cha
commit
cc857d6d41

+ 63 - 0
src/main/java/org/springblade/common/utils/hangxin/HangxinUtil.java

@@ -0,0 +1,63 @@
+package org.springblade.common.utils.hangxin;
+
+import cn.hutool.json.JSONUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springblade.common.utils.hangxin.bean.HangxinResultBean;
+import org.springblade.common.utils.hangxin.conf.HangxinConfig;
+import org.springblade.common.utils.hangxin.contants.HangxinConstants;
+import org.springblade.core.tool.utils.StringUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.ParameterizedTypeReference;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Component;
+import org.springframework.web.client.RestTemplate;
+
+import java.net.URI;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Slf4j
+@Component
+public class HangxinUtil {
+
+	@Autowired
+	private HangxinConfig hangxinConfig;
+
+
+	public HangxinResultBean sendMsg (List<String> userIds, String title, String content){
+		RestTemplate restTemplate = new RestTemplate();
+		String url = hangxinConfig.getUrl() + HangxinConstants.SEND_MSG;
+		HttpHeaders headers = createHttpHeaders();
+
+		Map<String, Object> params = new HashMap<>();
+		params.put("touser", StringUtil.join(userIds, "|"));
+		params.put("sysId", hangxinConfig.getSysId());
+		params.put("title", title);
+		params.put("content", content);
+
+		HttpEntity<String> requestEntity = new HttpEntity<>(JSONUtil.toJsonStr(params), headers);
+		URI uri = URI.create(url);
+		ParameterizedTypeReference<HangxinResultBean> reference = new ParameterizedTypeReference<HangxinResultBean>() {};
+		ResponseEntity<HangxinResultBean> response = restTemplate.exchange(uri, HttpMethod.POST, requestEntity, reference);
+
+		return response.getBody();
+	}
+
+
+
+
+
+
+	private HttpHeaders createHttpHeaders(){
+		HttpHeaders httpHeaders = new HttpHeaders();
+		httpHeaders.add(HttpHeaders.CONTENT_TYPE, "application/json");
+//		httpHeaders.add("appKey", elevatorConfig.getAppKey());
+//		httpHeaders.add("appSecret", elevatorConfig.getAppSecret());
+		return httpHeaders;
+	}
+
+}

+ 23 - 0
src/main/java/org/springblade/common/utils/hangxin/bean/HangxinResultBean.java

@@ -0,0 +1,23 @@
+package org.springblade.common.utils.hangxin.bean;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.io.Serializable;
+
+/**
+ * @author fgh
+ * @create 2021/01/30 19:25
+ * 第三方接口的通用返回值
+ */
+
+@Setter
+@Getter
+public class HangxinResultBean<T> implements Serializable {
+
+	//0 成功
+    private Integer code;
+    private T data;
+    private String msg;
+
+}

+ 16 - 0
src/main/java/org/springblade/common/utils/hangxin/conf/HangxinConfig.java

@@ -0,0 +1,16 @@
+package org.springblade.common.utils.hangxin.conf;
+
+import lombok.Data;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Configuration;
+
+@Data
+@Configuration
+public class HangxinConfig {
+
+	@Value("${hangxin.url}")
+	private String url;
+	@Value("${hangxin.sysId}")
+	private String sysId;
+
+}

+ 8 - 0
src/main/java/org/springblade/common/utils/hangxin/contants/HangxinConstants.java

@@ -0,0 +1,8 @@
+package org.springblade.common.utils.hangxin.contants;
+
+public class HangxinConstants {
+
+	//redis中电梯token的key
+	public static String SEND_MSG = "/hxapi/hwp/sendmessage";
+
+}

+ 13 - 3
src/main/java/org/springblade/modules/desk/service/impl/NoticeServiceImpl.java

@@ -16,6 +16,7 @@
  */
 package org.springblade.modules.desk.service.impl;
 
+import cn.hutool.json.JSONUtil;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import lombok.AllArgsConstructor;
 import org.springblade.bank.cardswallow.entity.CardSwallow;
@@ -26,6 +27,8 @@ import org.springblade.bank.message.entity.Message;
 import org.springblade.bank.postchange.entity.PostChange;
 import org.springblade.bank.returns.entity.Returns;
 import org.springblade.bank.sealhandover.entity.SealHandover;
+import org.springblade.common.utils.hangxin.HangxinUtil;
+import org.springblade.common.utils.hangxin.bean.HangxinResultBean;
 import org.springblade.core.datascope.annotation.DataAuth;
 import org.springblade.core.datascope.enums.DataScopeEnum;
 import org.springblade.core.mp.base.BaseServiceImpl;
@@ -44,6 +47,7 @@ import org.springblade.modules.system.service.IDeptService;
 import org.springblade.modules.system.service.IDictService;
 import org.springblade.modules.system.service.IRoleService;
 import org.springblade.modules.system.service.IUserService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
@@ -64,6 +68,8 @@ public class NoticeServiceImpl extends BaseServiceImpl<NoticeMapper, Notice> imp
 	private final IDeptService deptService;
 	private final IRoleService roleService;
 
+	private HangxinUtil hangxinUtil;
+
 	@Override
 	public IPage<NoticeVO> selectNoticePage(IPage<NoticeVO> page, NoticeVO notice) {
 		// 若不使用mybatis-plus自带的分页方法,则不会自动带入tenantId,所以我们需要自行注入
@@ -262,14 +268,18 @@ public class NoticeServiceImpl extends BaseServiceImpl<NoticeMapper, Notice> imp
 		}
 
 		String title = dept.getDeptName() + "尚未完成" + checkType + "核對工作";
-		/*Notice notice = new Notice();
+		Notice notice = new Notice();
 		notice.setTitle(title);
 		notice.setBusinessType("checklist");
 		notice.setDeptId(dept.getId() + "");
 		notice.setRoleId(StringUtil.join(roleIds));
 		notice.setTargetIds(StringUtil.join(userIds));
-		sendNotice(notice);*/
-		return true;
+
+		// 發送行信通知
+		/*HangxinResultBean hangxinResultBean = hangxinUtil.sendMsg(userIds, "提示進度", title);
+		System.out.println(JSONUtil.toJsonStr(hangxinResultBean));*/
+		return sendNotice(notice);
+//		return true;
 	}
 
 	private String getCategoryName(KeyPwd keyPwd){

+ 1 - 1
src/main/java/org/springblade/modules/timer/TimeTask.java

@@ -30,7 +30,7 @@ public class TimeTask extends BladeController {
 	private final INoticeService noticeService;
 
 	//3.添加定时任务
-	@Scheduled(cron = "0 0 11 * * ?")
+	@Scheduled(cron = "0 0 22 * * ?")
 //	@Scheduled(cron = "0/10 * * * * ?")
 	//或直接指定时间间隔,例如:5秒
 	//@Scheduled(fixedRate=5000)

+ 3 - 0
src/main/resources/application-dev.yml

@@ -75,3 +75,6 @@ oss:
   access-key: D99KGE6ZTQXSATTJWU24
   secret-key: QyVqGnhIQQE734UYSUFlGOZViE6+ZlDEfUG3NjhJ
 
+hangxin:
+  url: http://22.237.189.107:9001
+  sysId: "000017"

+ 4 - 0
src/main/resources/application-prod.yml

@@ -53,3 +53,7 @@ oss:
   endpoint: http://192.168.2.9:90
   access-key: D99KGE6ZTQXSATTJWU24
   secret-key: QyVqGnhIQQE734UYSUFlGOZViE6+ZlDEfUG3NjhJ
+
+hangxin:
+  url: http://22.237.189.107:9001
+  sysId: "000017"