钉钉版本调整

This commit is contained in:
andy 2026-04-24 16:39:25 +08:00
parent a055d211ff
commit 098ab28150
9 changed files with 143 additions and 4 deletions

View File

@ -26,12 +26,16 @@ import com.evo.wechat.dto.MessageTemplate;
import com.evo.wechat.service.GZHAccessTokenService;
import org.apache.ibatis.annotations.Param;
import org.jasypt.encryption.StringEncryptor;
import org.springframework.core.io.FileSystemResource;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
@ -191,9 +195,50 @@ public class TestController {
*/
@GetMapping("/testAdapterSend")
public AjaxResult testSend() throws ParseException {
String data = "{\"FormId\":\"BD_Empinfo\",\"FieldKeys\":\"FID\",\"FilterString\":[{\"Left\":\"\",\"FieldName\":\"FStaffNumber\",\"Compare\":\"17\",\"Value\":\"00046\",\"Right\":\"\",\"Logic\":0}],\"OrderString\":\"\",\"TopRowCount\":0,\"StartRow\":0,\"Limit\":2000,\"SubSystemId\":\"\"}";
return AjaxResult.success(HttpUtils.sendPost("http://localhost:8089/distribution/kingdee/send", JSONObject.toJSONString(
Collections.asMap("fromId","BD_Empinfo", "month","executeBillQuery", "parameterTypes",Collections.asList(String.class),"data",Collections.asMap("data",data)))));
RestTemplate restTemplate = new RestTemplate();
MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
// 文件
// File file = new File("D:\\andy\\ideaWorker\\shangban12.png");
// FileSystemResource resource = new FileSystemResource(file);
// params.add("file", resource);
StringBuilder markdownMsg = new StringBuilder();
markdownMsg.append("### 🚀 安全库存提醒\n\n")
.append("今日暂无安全库存预警数据。\n\n");
// 只显示前三个安全库存数据
markdownMsg.append("**物料编号: ").append("123321").append("**\n")
.append("- 物料名称: ").append("测试测试567").append("\n")
.append("- 预计可用量: ").append("200").append("\n")
.append("- 即时库存: ").append("100").append("\n")
.append("- 最大库存: ").append("50").append("\n")
.append("- 创建时间: ").append(DateUtil.formatDateTime(new Date())).append("\n")
.append("---\n"); // 添加分隔线
// 添加总数汇总
markdownMsg.append("**总数汇总**\n")
.append("- 今日安全库存预警数据总数: **").append(50).append("**\n");
Map<String,String> dataMap = Collections.emptyMap();
dataMap.put("month", "sendMarkdownToUser");
dataMap.put("robotCode", "dingwoaeaozawfochwoo");
dataMap.put("clientId", "dingwoaeaozawfochwoo");
dataMap.put("clientSecret", "rGrAQ7cReWeYzIK5j71l8d2qOLgUTyc-qnlacQcl3n0dKG3M8bgbbaSoc9AbKeUy");
dataMap.put("users", JSON.toJSONString(Collections.asList("史国臣","田志阳")));
dataMap.put("parameterTypes", JSON.toJSONString(Collections.asList("java.lang.String","java.lang.String")));
dataMap.put("parameters", JSON.toJSONString(Collections.asList("test测试",markdownMsg.toString())));
params.add("data", JSON.toJSONString(dataMap));
String url = "http://localhost:8089/ding/send";
return AjaxResult.success(restTemplate.postForObject(url, params, String.class));
// String data = "{\"FormId\":\"BD_Empinfo\",\"FieldKeys\":\"FID\",\"FilterString\":[{\"Left\":\"\",\"FieldName\":\"FStaffNumber\",\"Compare\":\"17\",\"Value\":\"00046\",\"Right\":\"\",\"Logic\":0}],\"OrderString\":\"\",\"TopRowCount\":0,\"StartRow\":0,\"Limit\":2000,\"SubSystemId\":\"\"}";
// return AjaxResult.success(HttpUtils.sendPost("http://localhost:8089/distribution/kingdee/send", JSONObject.toJSONString(
// Collections.asMap("fromId","BD_Empinfo", "month","executeBillQuery", "parameterTypes",Collections.asList(String.class),"data",Collections.asMap("data",data)))));
}

View File

@ -191,6 +191,71 @@ public class HttpUtils
return result.toString();
}
public static String sendPost(String url, String param, String contentType) {
PrintWriter out = null;
BufferedReader in = null;
StringBuilder result = new StringBuilder();
try
{
log.info("sendPost - {}", url);
URL realUrl = new URL(url);
URLConnection conn = realUrl.openConnection();
conn.setRequestProperty("accept", "*/*");
conn.setRequestProperty("connection", "Keep-Alive");
conn.setRequestProperty("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64)");
conn.setRequestProperty("Accept-Charset", "UTF-8");
conn.setRequestProperty("Content-Type", contentType);
conn.setDoOutput(true);
conn.setDoInput(true);
out = new PrintWriter(conn.getOutputStream());
out.print(param);
out.flush();
in = new BufferedReader(new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8));
String line;
while ((line = in.readLine()) != null)
{
result.append(line);
}
log.info("recv - {}", result);
}
catch (ConnectException e)
{
log.error("调用HttpUtils.sendPost ConnectException, url=" + url + ",param=" + param, e);
}
catch (SocketTimeoutException e)
{
log.error("调用HttpUtils.sendPost SocketTimeoutException, url=" + url + ",param=" + param, e);
}
catch (IOException e)
{
log.error("调用HttpUtils.sendPost IOException, url=" + url + ",param=" + param, e);
}
catch (Exception e)
{
log.error("调用HttpsUtil.sendPost Exception, url=" + url + ",param=" + param, e);
}
finally
{
try
{
if (out != null)
{
out.close();
}
if (in != null)
{
in.close();
}
}
catch (IOException ex)
{
log.error("调用in.close Exception, url=" + url + ",param=" + param, ex);
}
}
return result.toString();
}
public static String sendSSLPost(String url, String param)
{
StringBuilder result = new StringBuilder();

View File

@ -119,6 +119,7 @@ public class SecurityConfig
.antMatchers("/wechat/**").permitAll()
.antMatchers("/websocket/**").permitAll()
.antMatchers("/test/**").permitAll()
.antMatchers("/system/staff/tree/getDingUserId").permitAll()
.antMatchers("/callback/**/**").permitAll()
.antMatchers("/api/v1/verify_user").permitAll()
.antMatchers("/api/v1/record/face").permitAll()

View File

@ -11,6 +11,7 @@ import com.evo.common.utils.poi.ExcelUtil;
import com.evo.system.domain.SysStaff;
import com.evo.system.domain.vo.SysStaffVo;
import com.evo.system.service.ISysStaffService;
import org.apache.ibatis.annotations.Param;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@ -184,4 +185,12 @@ public class SysStaffController extends BaseController
{
return sysStaffService.reEmployment(userId);
}
// @Log(title = "员工管理-离职员工重新入职", businessType = BusinessType.OTHER)
@GetMapping("/tree/getDingUserId")
public AjaxResult getDingUserId(@RequestParam("userName") String userName) throws Exception
{
return sysStaffService.getDingUserId(userName);
}
}

View File

@ -102,4 +102,6 @@ s * @return
*/
public SysStaff selectSysStaffByDingUserId(String dingUserId);
String getDingUserId(@Param("userName") String userName);
}

View File

@ -135,4 +135,6 @@ public interface ISysStaffService extends IService<SysStaff>
* @param dingUserId
*/
public void sysStaffLeaveByDingUserId(String dingUserId);
AjaxResult getDingUserId(String userName);
}

View File

@ -1017,6 +1017,15 @@ public class SysStaffServiceImpl extends ServiceImpl<SysStaffMapper, SysStaff> i
updateSysStaff(sysStaff);
}
@Override
public AjaxResult getDingUserId(String userName) {
Object dingUserId = baseMapper.getDingUserId(userName);
if(ObjectUtils.isEmpty(dingUserId)){
return AjaxResult.error("钉钉UserId不存在");
}
return AjaxResult.success(dingUserId);
}
public String getAllParentName(List<SysDept> sysDepts, Long parentId, List<String> allParentNames){
for (SysDept sysDept : sysDepts){

View File

@ -7,7 +7,7 @@ spring:
# 热部署开关
redis:
# 地址
host: 192.168.5.232
host: localhost
# 端口默认为6379
port: 6379
# 数据库索引

View File

@ -313,4 +313,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectSysStaffVo"/>
where del_flag = '0' and status != '-1' and dept_id = #{deptId} and is_leader='是' limit 1
</select>
<select id="getDingUserId" resultType="java.lang.String">
select ding_user_id from sys_staff where name=#{userName}
</select>
</mapper>