Commit a79955b8 by HlQ

[add]

1.添加手动同步钉钉组织关系接口
2.项目交付日志添加钉钉提醒
3.新增字典项
[fix]
1.修复合同定时同步合同关联产品信息重复的 bug
2.修复新员工入职,系统未同步时,获取不到用户信息的 bug
1 parent a421dc8c
......@@ -41,6 +41,8 @@ public enum RedisKeyEnum {
OFFSET_ITEM("offset_item"),
POINT_STATUS("pointStatus"),
REPAIR_STATUS("repairStatus"),
PROJECT_SIZE("projectSize"),
SERVICE_METHOD("serviceMethod"),
/**
* 钉钉 key
......
......@@ -52,4 +52,10 @@ public class DeliverLogController {
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 {
/**
* 同步字典到 Redis
* 目前字典接口未使用,添加字典和字典项是直接在数据库中添加的,所以需要手动同步到 Redis
*
* @return java.lang.String
*/
......
......@@ -57,7 +57,7 @@ public class UserController {
@SaCheckPermission(value = "user:listName", orRole = "admin")
public List<UserVO> getNameList(UserDTO dto) {
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)
.list(), UserVO.class);
}
......@@ -98,6 +98,13 @@ public class UserController {
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}")
public Object dingCallback(@PathVariable String target, DingDTO dto, HttpServletResponse res) {
return dingMod.dingCallback(target, dto, res);
......
......@@ -337,6 +337,7 @@ public class ContractRunner {
return;
}
var jsonArray = jobO.getJSONObject("result").getJSONArray("list");
// 合同记录唯一 dataId
var dataIdSet = jsonArray.stream().map(v -> JSONUtil.parseObj(v).getInt("dataId")).collect(Collectors.toSet());
for (int i = 2; i <= page; i++) {
......@@ -409,43 +410,45 @@ public class ContractRunner {
contract.setReceivableAmount(BigDecimal.ZERO);
contract.setOutstandingAmount(jsonObj1.getBigDecimal("num_1"));
var paymentForm = jsonObj1.getJSONArray("subForm_1");
paymentForm.forEach(pf -> {
var pfObj = JSONUtil.parseObj(pf);
var ratio = NumberUtil.div(BigDecimal.valueOf(Double.parseDouble(pfObj.getStr("text_1"))), 100);
var date = DateUtil.date(pfObj.getLong("date_1") * 1000);
var stage = pfObj.getJSONObject("text_2").getStr("text");
if (StrUtil.equals(stage, "预付款")) {
contract.setSignRatio(ratio);
contract.setSignDate1(date);
} else if (StrUtil.equals(stage, "到货款")) {
contract.setArriveRatio(ratio);
contract.setArriveDate(date);
} else if (StrUtil.equals(stage, "系统验收款")) {
contract.setSystemCheckRatio(ratio);
contract.setSystemCheckDate(date);
} else if (StrUtil.equals(stage, "项目终验款")) {
contract.setProjectCheckRatio(ratio);
contract.setProjectCheckDate(date);
} else if (StrUtil.equals(stage, "质保款")) {
contract.setWarrantyRatio(ratio);
contract.setWarrantyDate(date);
} else if (StrUtil.equals(stage, "维保第一笔款")) {
contract.setMaintainRatio1(ratio);
contract.setMaintainDate1(date);
} else if (StrUtil.equals(stage, "维保第二笔款")) {
contract.setMaintainRatio2(ratio);
contract.setMaintainDate2(date);
} else if (StrUtil.equals(stage, "维保第三笔款")) {
contract.setMaintainRatio3(ratio);
contract.setMaintainDate3(date);
} else if (StrUtil.equals(stage, "维保进度款")) {
contract.setMaintainProgressRatio(ratio);
contract.setMaintainProgressDate(date);
} else if (StrUtil.equals(stage, "维保验收款")) {
contract.setMaintainAcceptanceRatio(ratio);
contract.setMaintainAcceptanceDate(date);
}
});
if (!paymentForm.isEmpty()) {
paymentForm.forEach(pf -> {
var pfObj = JSONUtil.parseObj(pf);
var ratio = NumberUtil.div(BigDecimal.valueOf(Double.parseDouble(pfObj.getStr("text_1"))), 100);
var date = DateUtil.date(pfObj.getLong("date_1") * 1000);
var stage = pfObj.getJSONObject("text_2").getStr("text");
if (StrUtil.equals(stage, "预付款")) {
contract.setSignRatio(ratio);
contract.setSignDate1(date);
} else if (StrUtil.equals(stage, "到货款")) {
contract.setArriveRatio(ratio);
contract.setArriveDate(date);
} else if (StrUtil.equals(stage, "系统验收款")) {
contract.setSystemCheckRatio(ratio);
contract.setSystemCheckDate(date);
} else if (StrUtil.equals(stage, "项目终验款")) {
contract.setProjectCheckRatio(ratio);
contract.setProjectCheckDate(date);
} else if (StrUtil.equals(stage, "质保款")) {
contract.setWarrantyRatio(ratio);
contract.setWarrantyDate(date);
} else if (StrUtil.equals(stage, "维保第一笔款")) {
contract.setMaintainRatio1(ratio);
contract.setMaintainDate1(date);
} else if (StrUtil.equals(stage, "维保第二笔款")) {
contract.setMaintainRatio2(ratio);
contract.setMaintainDate2(date);
} else if (StrUtil.equals(stage, "维保第三笔款")) {
contract.setMaintainRatio3(ratio);
contract.setMaintainDate3(date);
} else if (StrUtil.equals(stage, "维保进度款")) {
contract.setMaintainProgressRatio(ratio);
contract.setMaintainProgressDate(date);
} else if (StrUtil.equals(stage, "维保验收款")) {
contract.setMaintainAcceptanceRatio(ratio);
contract.setMaintainAcceptanceDate(date);
}
});
}
contract.setSubject("北京文安智能技术股份有限公司");
contract.setCustomerName(jsonObj1.getJSONObject("text_2").getStr("name"));
contract.setSaleName(jsonObj1.getJSONObject("text_8").getStr("name"));
......@@ -456,29 +459,33 @@ public class ContractRunner {
insOrUpdContractList.add(contract);
var productArr = jsonObj1.getJSONArray("array_4");
productArr.forEach(pro -> {
var product = JSONUtil.parseObj(pro);
var crmProJson = crmProList.stream().filter(p -> p.getInt("dataId").equals(product.getInt("text_1"))).toList().get(0);
var crmPro = crmProJson.getJSONObject("data");
var contractProduct = new RContractProduct();
contractProduct.setContractNo(contract.getContractNo());
contractProduct.setProductName(crmPro.getStr("text_1"));
contractProduct.setProductCode(crmPro.getStr("serialNo"));
contractProduct.setProductModel(crmPro.getStr("text_4"));
contractProduct.setNum(product.getInt("num_3"));
contractProduct.setTaxPrice(product.getBigDecimal("num_1"));
contractProduct.setTaxRate(BigDecimal.valueOf(Integer.parseInt(crmPro.getStr("text_12").replace("%", "")) / 100));
// contractProduct.setNoTaxPrice(product.getBigDecimal("num_6"));
contractProduct.setDiscountRate(NumberUtil.div(product.getBigDecimal("num_4"), 100));
contractProduct.setActualPrice(product.getBigDecimal("num_6"));
// contractProduct.setErase(product);
contractProduct.setTotalPrice(product.getBigDecimal("num_5"));
productList.add(contractProduct);
});
if (!productArr.isEmpty()) {
productArr.forEach(pro -> {
var product = JSONUtil.parseObj(pro);
var crmProJson = crmProList.stream().filter(p -> p.getInt("dataId").equals(product.getInt("text_1"))).toList().get(0);
var crmPro = crmProJson.getJSONObject("data");
var contractProduct = new RContractProduct();
contractProduct.setContractNo(contract.getContractNo());
contractProduct.setProductName(crmPro.getStr("text_1"));
contractProduct.setProductCode(crmPro.getStr("serialNo"));
contractProduct.setProductModel(crmPro.getStr("text_4"));
contractProduct.setNum(product.getInt("num_3"));
contractProduct.setTaxPrice(product.getBigDecimal("num_1"));
contractProduct.setTaxRate(BigDecimal.valueOf(Integer.parseInt(crmPro.getStr("text_12").replace("%", "")) / 100));
// contractProduct.setNoTaxPrice(product.getBigDecimal("num_6"));
contractProduct.setDiscountRate(NumberUtil.div(product.getBigDecimal("num_4"), 100));
contractProduct.setActualPrice(product.getBigDecimal("num_6"));
// contractProduct.setErase(product);
contractProduct.setTotalPrice(product.getBigDecimal("num_5"));
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()));
List<Long> updContractIdList = new ArrayList<>();
......@@ -489,8 +496,12 @@ public class ContractRunner {
// 已有合同不更新状态
v.setStatus(null);
updContractIdList.add(contractId);
// 移除已存在合同的关联产品信息,防止重复插入
no2ProductMap.remove(v.getContractNo());
}
});
contractProductService.saveBatch(no2ProductMap.values().stream().flatMap(Collection::stream).toList());
// 合同更新,同步调用一下更新项目的维保状态
Opt.ofEmptyAble(updContractIdList)
.map(contractIdList -> contractStoreService.lambdaQuery().in(RContractStore::getContractId, contractIdList).list())
......
......@@ -19,4 +19,6 @@ public interface IDeliverLogService extends MPJBaseService<DeliverLog> {
String update(DeliverLogDTO dto);
Boolean logNotify(String[] userIdStr);
}
......@@ -113,6 +113,12 @@ public class DeliverLogServiceImpl extends MPJBaseServiceImpl<DeliverLogMapper,
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) {
var jsonObj = JSONUtil.ofObj()
.set("agent_id", 2358374016L)
......@@ -140,4 +146,21 @@ public class DeliverLogServiceImpl extends MPJBaseServiceImpl<DeliverLogMapper,
jsonObj.set("msg", msg);
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
});
userList.forEach(v -> {
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);
});
var wholeTree = TreeUtil.build(nodeList, "1");
......
......@@ -332,6 +332,9 @@ public class DingMod {
User user = userService.lambdaQuery()
.select(User::getId, User::getUserid, User::getUsername, User::getPhone, User::getStatus, User::getEmployeeStatus)
.eq(User::getUserid, userid).one();
if (ObjUtil.isNull(user)) {
return "该用户不存在,请联系管理员!";
}
UserVO userVO = converter.convert(user, UserVO.class);
// 禁用用户或离职用户禁止登录系统
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!