Commit df7adda4 by HlQ

[add] 添加同步销帮帮合同文件定时任务和接口

1 parent 6976245f
......@@ -8,7 +8,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.3</version>
<version>3.3.0</version>
</parent>
<artifactId>Vion-DevOps</artifactId>
......@@ -17,7 +17,7 @@
<pg.version>42.7.0</pg.version>
<sqlserver.version>12.2.0.jre8</sqlserver.version>
<lombok.version>1.18.30</lombok.version>
<hutool.version>6.0.0-M11</hutool.version>
<hutool.version>6.0.0-M13</hutool.version>
<redisson.verion>3.27.1</redisson.verion>
<mapstruct-plus.version>1.3.5</mapstruct-plus.version>
<mp.version>3.5.5</mp.version>
......
......@@ -13,7 +13,7 @@ import org.aspectj.lang.annotation.Pointcut;
import org.dromara.hutool.core.lang.Opt;
import org.dromara.hutool.core.text.StrUtil;
import org.dromara.hutool.core.util.ObjUtil;
import org.dromara.hutool.http.server.servlet.JakartaServletUtil;
import org.dromara.hutool.http.server.servlet.ServletUtil;
import org.slf4j.MDC;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
......@@ -56,10 +56,10 @@ public class LogAspect {
log.info("Request URL:{}, Method:{}, IP:{}, Operator:{}, Args:{}, Body:{}",
request.getRequestURI(),
request.getMethod(),
JakartaServletUtil.getClientIP(request),
ServletUtil.getClientIP(request),
username,
objectMapper.writeValueAsString(request.getParameterMap()),
StrUtil.replaceChars(JakartaServletUtil.getBody(request), " \r\n", "")
StrUtil.replaceChars(ServletUtil.getBody(request), " \r\n", "")
);
}
......
......@@ -2,10 +2,10 @@ package vion.advice;
import cn.dev33.satoken.exception.NotLoginException;
import cn.dev33.satoken.exception.NotPermissionException;
import cn.hutool.core.util.ObjUtil;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.dromara.hutool.core.util.ObjUtil;
import org.springframework.core.MethodParameter;
import org.springframework.core.io.Resource;
import org.springframework.http.MediaType;
......
......@@ -73,7 +73,7 @@ public class ContractController {
@PostMapping("/contract/{id}")
@SaCheckPermission(value = "contract:edit", orRole = "admin")
public String updateById(@PathVariable Long id, ContractDTO dto) {
public String updateById(@PathVariable Long id, @RequestBody ContractDTO dto) {
return contractService.updateById(id, null, dto);
}
......@@ -198,4 +198,10 @@ public class ContractController {
throw new RuntimeException(e);
}
}
@GetMapping("/contract/fileSync")
@SaCheckPermission(value = "contract:fileSync", orRole = "admin")
public String fileSync(String[] contractNoList) {
return contractService.syncContractFile(contractNoList);
}
}
......@@ -54,7 +54,7 @@ public class ContractRunner {
@Value("${xbongbong.token}")
private String token;
@Value("${xbongbong.corpid}")
private String corpid;
private String corpId;
// @Scheduled(cron = "0 0 * * * *")
@Transactional(rollbackFor = Exception.class)
......@@ -302,7 +302,7 @@ public class ContractRunner {
public void contractSync1() {
Long modifyTime = Opt.ofNullable((Long) redissonClient.getBucket(RedisKeyEnum.CONTRACT_SYNC_NEW_TIME.getVal()).get()).orElse(0L);
// 只同步2024-05-07号(含)之后的合同
// 只同步申请日期(原CRM中的签订日期)2024-05-07号(含)之后的合同
var json = JSONUtil.ofObj()
.set("sortMap", JSONUtil.ofObj()
.set("field", "updateTime")
......@@ -317,7 +317,7 @@ public class ContractRunner {
.set("symbol", "greatethan")
.set("value", new String[]{String.valueOf(modifyTime / 1000)}))
)
.set("corpid", corpid)
.set("corpid", corpId)
.set("formId", 8429903)
.set("pageSize", 100);
var res = Request.of("https://proapi.xbongbong.com/pro/v2/api/contract/list")
......@@ -347,18 +347,22 @@ public class ContractRunner {
.set("order", "desc"))
.set("conditions", JSONUtil.ofArray()
.put(JSONUtil.ofObj()
.set("attr", "date_3")
.set("symbol", "greaterequal")
.set("value", new String[]{"1715356800"}))
.put(JSONUtil.ofObj()
.set("attr", "updateTime")
.set("fieldType", "10015")
.set("symbol", "greatethan")
.set("value", new String[]{String.valueOf(modifyTime)}))
)
.set("corpid", corpid)
.set("corpid", corpId)
.set("formId", 8429903)
.set("page", i)
.set("pageSize", 100);
var resR = Request.of("https://proapi.xbongbong.com/pro/v2/api/contract/list")
.header("sign", SecureUtil.sha256(jsonR.toString() + token))
.body(json.toString())
.body(jsonR.toString())
.method(Method.POST)
.send();
var jobR = JSONUtil.parseObj(resR.bodyStr());
......@@ -378,7 +382,7 @@ public class ContractRunner {
}
dataIdSet.forEach(dataId -> {
var json1 = JSONUtil.ofObj()
.set("corpid", corpid)
.set("corpid", corpId)
.set("dataId", dataId);
var res1 = Request.of("https://proapi.xbongbong.com/pro/v2/api/contract/detail")
.header("sign", SecureUtil.sha256(json1.toString() + token))
......@@ -633,7 +637,7 @@ public class ContractRunner {
public List<JSONObject> getProductList() {
List<JSONObject> resList = new ArrayList<>();
var json = JSONUtil.ofObj()
.set("corpid", corpid)
.set("corpid", corpId)
.set("page", 1)
.set("pageSize", 100);
......@@ -654,7 +658,7 @@ public class ContractRunner {
for (int i = 2; i <= totalPage; i++) {
var json1 = JSONUtil.ofObj()
.set("corpid", corpid)
.set("corpid", corpId)
.set("page", i)
.set("pageSize", 100);
var res1 = Request.of("https://proapi.xbongbong.com/pro/v2/api/product/list")
......@@ -680,4 +684,9 @@ public class ContractRunner {
storeService.calMaintainStatus(ListUtil.empty());
log.info("【结束】计算门店维保状态");
}
@Scheduled(cron = "0 10 * ? * *")
public void syncContractFile() {
contractService.syncContractFile(null);
}
}
package vion.cron;
import cn.hutool.core.lang.Opt;
import cn.hutool.core.util.ObjUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.dromara.hutool.core.date.DateUtil;
import org.dromara.hutool.core.lang.Opt;
import org.dromara.hutool.core.text.StrUtil;
import org.dromara.hutool.core.util.ObjUtil;
import org.dromara.hutool.cron.CronUtil;
import org.dromara.hutool.cron.task.Task;
import org.dromara.hutool.json.JSONObject;
......
......@@ -67,6 +67,8 @@ public class Contract {
/**
* 合同总金额
* <p>
* 更新合同时,合同相关金额计算是由合同收款记录计算的,不能通过更新接口自己修改
*/
@TableField(value = "total_amount")
@ReverseAutoMapping(targetClass = ContractDTO.class, ignore = true)
......
......@@ -49,4 +49,5 @@ public interface IContractService extends MPJBaseService<Contract> {
JSONObject getCRMProduct(String name, String code, Integer page, Integer pageSize);
String syncContractFile(String[] contractNoList);
}
\ No newline at end of file
package vion.service.impl;
import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.util.DesensitizedUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.base.MPJBaseServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
......@@ -12,6 +11,7 @@ import org.dromara.hutool.core.array.ArrayUtil;
import org.dromara.hutool.core.collection.CollUtil;
import org.dromara.hutool.core.collection.ListUtil;
import org.dromara.hutool.core.collection.set.SetUtil;
import org.dromara.hutool.core.data.MaskingUtil;
import org.dromara.hutool.core.data.id.IdUtil;
import org.dromara.hutool.core.date.DateUtil;
import org.dromara.hutool.core.io.file.FileNameUtil;
......@@ -325,7 +325,7 @@ public class TaskServiceImpl extends MPJBaseServiceImpl<TaskMapper, Task> implem
.build();
List<WxMpTemplateData> wxMpTemplateDataList = ListUtil.of(
new WxMpTemplateData("character_string21", existTask.getUuid()),
new WxMpTemplateData("thing12", DesensitizedUtil.chineseName(user.getUsername())),
new WxMpTemplateData("thing12", MaskingUtil.chineseName(user.getUsername())),
new WxMpTemplateData("time11", DateUtil.formatDateTime(new Date())),
new WxMpTemplateData("thing20", existTask.getFaultDescription().length() > 20 ? StrUtil.sub(existTask.getFaultDescription(), 0, 17) + "..." : existTask.getFaultDescription()),
new WxMpTemplateData("phrase25", statusMap.get(existTask.getStatus())));
......
package vion.service.impl;
import cn.hutool.core.util.ObjUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.base.MPJBaseServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
......@@ -12,6 +11,7 @@ import org.dromara.hutool.core.lang.Opt;
import org.dromara.hutool.core.tree.MapTree;
import org.dromara.hutool.core.tree.TreeNode;
import org.dromara.hutool.core.tree.TreeUtil;
import org.dromara.hutool.core.util.ObjUtil;
import org.springframework.stereotype.Service;
import vion.dto.UserDTO;
import vion.mapper.UserMapper;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!