Commit a79955b8 by HlQ

[add]

1.添加手动同步钉钉组织关系接口
2.项目交付日志添加钉钉提醒
3.新增字典项
[fix]
1.修复合同定时同步合同关联产品信息重复的 bug
2.修复新员工入职,系统未同步时,获取不到用户信息的 bug
1 parent a421dc8c
...@@ -41,6 +41,8 @@ public enum RedisKeyEnum { ...@@ -41,6 +41,8 @@ public enum RedisKeyEnum {
OFFSET_ITEM("offset_item"), OFFSET_ITEM("offset_item"),
POINT_STATUS("pointStatus"), POINT_STATUS("pointStatus"),
REPAIR_STATUS("repairStatus"), REPAIR_STATUS("repairStatus"),
PROJECT_SIZE("projectSize"),
SERVICE_METHOD("serviceMethod"),
/** /**
* 钉钉 key * 钉钉 key
......
...@@ -52,4 +52,10 @@ public class DeliverLogController { ...@@ -52,4 +52,10 @@ public class DeliverLogController {
return deliverLogService.removeById(id) ? "删除成功" : "删除失败"; return deliverLogService.removeById(id) ? "删除成功" : "删除失败";
} }
@GetMapping("/notify")
@SaCheckPermission(value = "deliverLog:notify", orRole = "admin")
public String logNotify(String[] userIdStr) {
return deliverLogService.logNotify(userIdStr) ? "钉钉提醒成功" : "钉钉提醒失败";
}
} }
...@@ -66,6 +66,7 @@ public class DictionaryController { ...@@ -66,6 +66,7 @@ public class DictionaryController {
/** /**
* 同步字典到 Redis * 同步字典到 Redis
* 目前字典接口未使用,添加字典和字典项是直接在数据库中添加的,所以需要手动同步到 Redis
* *
* @return java.lang.String * @return java.lang.String
*/ */
......
...@@ -57,7 +57,7 @@ public class UserController { ...@@ -57,7 +57,7 @@ public class UserController {
@SaCheckPermission(value = "user:listName", orRole = "admin") @SaCheckPermission(value = "user:listName", orRole = "admin")
public List<UserVO> getNameList(UserDTO dto) { public List<UserVO> getNameList(UserDTO dto) {
return converter.convert(userService.lambdaQuery(converter.convert(dto, new User())) return converter.convert(userService.lambdaQuery(converter.convert(dto, new User()))
.select(User::getId, User::getUserid, User::getUsername, User::getPreWorkOrder) .select(User::getId, User::getUserid, User::getUsername, User::getPreWorkOrder, User::getEmployeeStatus)
.ne(User::getStatus, 5) .ne(User::getStatus, 5)
.list(), UserVO.class); .list(), UserVO.class);
} }
...@@ -98,6 +98,13 @@ public class UserController { ...@@ -98,6 +98,13 @@ public class UserController {
return converter.convert(roleList, RoleVO.class); return converter.convert(roleList, RoleVO.class);
} }
@GetMapping("/user/manual")
@SaCheckPermission(value = "user:manual", orRole = "admin")
public String manualUser() {
dingMod.getDingUserList();
return "成功";
}
@GetMapping("/ding/callback/{target}") @GetMapping("/ding/callback/{target}")
public Object dingCallback(@PathVariable String target, DingDTO dto, HttpServletResponse res) { public Object dingCallback(@PathVariable String target, DingDTO dto, HttpServletResponse res) {
return dingMod.dingCallback(target, dto, res); return dingMod.dingCallback(target, dto, res);
......
...@@ -337,6 +337,7 @@ public class ContractRunner { ...@@ -337,6 +337,7 @@ public class ContractRunner {
return; return;
} }
var jsonArray = jobO.getJSONObject("result").getJSONArray("list"); var jsonArray = jobO.getJSONObject("result").getJSONArray("list");
// 合同记录唯一 dataId
var dataIdSet = jsonArray.stream().map(v -> JSONUtil.parseObj(v).getInt("dataId")).collect(Collectors.toSet()); var dataIdSet = jsonArray.stream().map(v -> JSONUtil.parseObj(v).getInt("dataId")).collect(Collectors.toSet());
for (int i = 2; i <= page; i++) { for (int i = 2; i <= page; i++) {
...@@ -409,6 +410,7 @@ public class ContractRunner { ...@@ -409,6 +410,7 @@ public class ContractRunner {
contract.setReceivableAmount(BigDecimal.ZERO); contract.setReceivableAmount(BigDecimal.ZERO);
contract.setOutstandingAmount(jsonObj1.getBigDecimal("num_1")); contract.setOutstandingAmount(jsonObj1.getBigDecimal("num_1"));
var paymentForm = jsonObj1.getJSONArray("subForm_1"); var paymentForm = jsonObj1.getJSONArray("subForm_1");
if (!paymentForm.isEmpty()) {
paymentForm.forEach(pf -> { paymentForm.forEach(pf -> {
var pfObj = JSONUtil.parseObj(pf); var pfObj = JSONUtil.parseObj(pf);
var ratio = NumberUtil.div(BigDecimal.valueOf(Double.parseDouble(pfObj.getStr("text_1"))), 100); var ratio = NumberUtil.div(BigDecimal.valueOf(Double.parseDouble(pfObj.getStr("text_1"))), 100);
...@@ -446,6 +448,7 @@ public class ContractRunner { ...@@ -446,6 +448,7 @@ public class ContractRunner {
contract.setMaintainAcceptanceDate(date); contract.setMaintainAcceptanceDate(date);
} }
}); });
}
contract.setSubject("北京文安智能技术股份有限公司"); contract.setSubject("北京文安智能技术股份有限公司");
contract.setCustomerName(jsonObj1.getJSONObject("text_2").getStr("name")); contract.setCustomerName(jsonObj1.getJSONObject("text_2").getStr("name"));
contract.setSaleName(jsonObj1.getJSONObject("text_8").getStr("name")); contract.setSaleName(jsonObj1.getJSONObject("text_8").getStr("name"));
...@@ -456,6 +459,7 @@ public class ContractRunner { ...@@ -456,6 +459,7 @@ public class ContractRunner {
insOrUpdContractList.add(contract); insOrUpdContractList.add(contract);
var productArr = jsonObj1.getJSONArray("array_4"); var productArr = jsonObj1.getJSONArray("array_4");
if (!productArr.isEmpty()) {
productArr.forEach(pro -> { productArr.forEach(pro -> {
var product = JSONUtil.parseObj(pro); var product = JSONUtil.parseObj(pro);
var crmProJson = crmProList.stream().filter(p -> p.getInt("dataId").equals(product.getInt("text_1"))).toList().get(0); var crmProJson = crmProList.stream().filter(p -> p.getInt("dataId").equals(product.getInt("text_1"))).toList().get(0);
...@@ -476,9 +480,12 @@ public class ContractRunner { ...@@ -476,9 +480,12 @@ public class ContractRunner {
contractProduct.setTotalPrice(product.getBigDecimal("num_5")); contractProduct.setTotalPrice(product.getBigDecimal("num_5"));
productList.add(contractProduct); productList.add(contractProduct);
}); });
}
}); });
contractProductService.saveBatch(productList); insOrUpdContractList.sort(Comparator.comparing(Contract::getOriginalModTime).reversed());
var no2ProductMap = productList.stream().collect(Collectors.groupingBy(RContractProduct::getContractNo));
// 已存在的合同列表
Map<String, Contract> no2ContactMap = contractService.list().stream().collect(Collectors.toMap(Contract::getContractNo, Function.identity())); Map<String, Contract> no2ContactMap = contractService.list().stream().collect(Collectors.toMap(Contract::getContractNo, Function.identity()));
List<Long> updContractIdList = new ArrayList<>(); List<Long> updContractIdList = new ArrayList<>();
...@@ -489,8 +496,12 @@ public class ContractRunner { ...@@ -489,8 +496,12 @@ public class ContractRunner {
// 已有合同不更新状态 // 已有合同不更新状态
v.setStatus(null); v.setStatus(null);
updContractIdList.add(contractId); updContractIdList.add(contractId);
// 移除已存在合同的关联产品信息,防止重复插入
no2ProductMap.remove(v.getContractNo());
} }
}); });
contractProductService.saveBatch(no2ProductMap.values().stream().flatMap(Collection::stream).toList());
// 合同更新,同步调用一下更新项目的维保状态 // 合同更新,同步调用一下更新项目的维保状态
Opt.ofEmptyAble(updContractIdList) Opt.ofEmptyAble(updContractIdList)
.map(contractIdList -> contractStoreService.lambdaQuery().in(RContractStore::getContractId, contractIdList).list()) .map(contractIdList -> contractStoreService.lambdaQuery().in(RContractStore::getContractId, contractIdList).list())
......
...@@ -19,4 +19,6 @@ public interface IDeliverLogService extends MPJBaseService<DeliverLog> { ...@@ -19,4 +19,6 @@ public interface IDeliverLogService extends MPJBaseService<DeliverLog> {
String update(DeliverLogDTO dto); String update(DeliverLogDTO dto);
Boolean logNotify(String[] userIdStr);
} }
...@@ -113,6 +113,12 @@ public class DeliverLogServiceImpl extends MPJBaseServiceImpl<DeliverLogMapper, ...@@ -113,6 +113,12 @@ public class DeliverLogServiceImpl extends MPJBaseServiceImpl<DeliverLogMapper,
return this.updateById(deliverLog) ? "修改成功" : "修改失败"; return this.updateById(deliverLog) ? "修改成功" : "修改失败";
} }
@Override
public Boolean logNotify(String[] userIdStr) {
var pushRes = dingMod.workMsg(buildMsg1(userIdStr));
return StrUtil.containsIgnoreCase(pushRes, "ok");
}
JSONObject buildMsg(String userid, String storeName, String confederateName, DeliverLog deliverLog) { JSONObject buildMsg(String userid, String storeName, String confederateName, DeliverLog deliverLog) {
var jsonObj = JSONUtil.ofObj() var jsonObj = JSONUtil.ofObj()
.set("agent_id", 2358374016L) .set("agent_id", 2358374016L)
...@@ -140,4 +146,21 @@ public class DeliverLogServiceImpl extends MPJBaseServiceImpl<DeliverLogMapper, ...@@ -140,4 +146,21 @@ public class DeliverLogServiceImpl extends MPJBaseServiceImpl<DeliverLogMapper,
jsonObj.set("msg", msg); jsonObj.set("msg", msg);
return jsonObj; return jsonObj;
} }
JSONObject buildMsg1(String[] userIdStr) {
var jsonObj = JSONUtil.ofObj()
.set("agent_id", 2358374016L)
.set("userid_list", String.join(",", userIdStr));
var msg = new JSONObject();
var content = new JSONObject();
content.set("title", "项目交付日志提醒")
.set("text", StrUtil.format("""
#### 您的日志还未提交,请尽快提交!
#### 发送时间:{}""", DateUtil.now()));
msg.set("msgtype", "markdown").set("markdown", content);
jsonObj.set("msg", msg);
return jsonObj;
}
} }
...@@ -82,7 +82,7 @@ public class UserServiceImpl extends MPJBaseServiceImpl<UserMapper, User> implem ...@@ -82,7 +82,7 @@ public class UserServiceImpl extends MPJBaseServiceImpl<UserMapper, User> implem
}); });
userList.forEach(v -> { userList.forEach(v -> {
TreeNode<String> node = new TreeNode<>(v.getUserid(), v.getDeptId().toString(), v.getUsername(), 2); TreeNode<String> node = new TreeNode<>(v.getUserid(), v.getDeptId().toString(), v.getUsername(), 2);
node.setExtra(Map.of("type", "user", "pkId", v.getId())); node.setExtra(Map.of("type", "user", "pkId", v.getId(), "employeeStatus", v.getEmployeeStatus()));
nodeList.add(node); nodeList.add(node);
}); });
var wholeTree = TreeUtil.build(nodeList, "1"); var wholeTree = TreeUtil.build(nodeList, "1");
......
...@@ -332,6 +332,9 @@ public class DingMod { ...@@ -332,6 +332,9 @@ public class DingMod {
User user = userService.lambdaQuery() User user = userService.lambdaQuery()
.select(User::getId, User::getUserid, User::getUsername, User::getPhone, User::getStatus, User::getEmployeeStatus) .select(User::getId, User::getUserid, User::getUsername, User::getPhone, User::getStatus, User::getEmployeeStatus)
.eq(User::getUserid, userid).one(); .eq(User::getUserid, userid).one();
if (ObjUtil.isNull(user)) {
return "该用户不存在,请联系管理员!";
}
UserVO userVO = converter.convert(user, UserVO.class); UserVO userVO = converter.convert(user, UserVO.class);
// 禁用用户或离职用户禁止登录系统 // 禁用用户或离职用户禁止登录系统
if (userVO.getStatus() == 1 || userVO.getEmployeeStatus() == 5) { if (userVO.getStatus() == 1 || userVO.getEmployeeStatus() == 5) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!