From abefef70ee144169527e878513636578742f40bc Mon Sep 17 00:00:00 2001
From: chengf <cgf12138@163.com>
Date: 星期四, 29 一月 2026 09:34:51 +0800
Subject: [PATCH] 上词掉词逻辑更新-cgf
---
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/demo/contract/controller/ContractController.java | 501 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 484 insertions(+), 17 deletions(-)
diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/demo/contract/controller/ContractController.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/demo/contract/controller/ContractController.java
index 4c5cc6f..0a7b7c7 100644
--- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/demo/contract/controller/ContractController.java
+++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/demo/contract/controller/ContractController.java
@@ -3,18 +3,27 @@
import java.io.UnsupportedEncodingException;
import java.io.IOException;
import java.net.URLDecoder;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import java.util.stream.Collectors;
-import java.util.HashMap;
+import cn.hutool.extra.pinyin.PinyinUtil;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
+import jakarta.websocket.server.PathParam;
+import net.sourceforge.pinyin4j.PinyinHelper;
+import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
+import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
+import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
+import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;
+import org.jeecg.common.aspect.DictAspect;
import org.jeecg.modules.demo.customer.entity.Customer;
import org.jeecg.modules.demo.customer.service.ICustomerService;
+import org.jeecg.modules.system.controller.SysUserController;
+import org.jeecg.modules.system.entity.SysUser;
+import org.jeecg.modules.system.service.ISysUserService;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
@@ -35,6 +44,8 @@
import org.jeecg.modules.demo.contract.service.ISemanticWordService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.multipart.MultipartFile;
@@ -69,7 +80,9 @@
private ISemanticWordService semanticWordService;
@Autowired
private ICustomerService customerService;
-
+
+ @Autowired
+ private ISysUserService sysUserService;
/**
* 鍒嗛〉鍒楄〃鏌ヨ
*
@@ -84,19 +97,83 @@
@GetMapping(value = "/list")
public Result<IPage<Contract>> queryPageList(Contract contract,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
- @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
+ @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
+ @RequestParam(name="role", defaultValue="鏃�") String role,
+ @RequestParam(name="user", defaultValue="鏃�") String user,
HttpServletRequest req) {
// 鑷畾涔夋煡璇㈣鍒�
Map<String, QueryRuleEnum> customeRuleMap = new HashMap<>();
+ if (contract.getCreateBy() != null) {
+ user = contract.getCreateBy();
+ }
// 鑷畾涔夊閫夌殑鏌ヨ瑙勫垯涓猴細LIKE_WITH_OR
customeRuleMap.put("reviewStatus", QueryRuleEnum.LIKE_WITH_OR);
- QueryWrapper<Contract> queryWrapper = QueryGenerator.initQueryWrapper(contract, req.getParameterMap(),customeRuleMap);
+ QueryWrapper<Contract> queryWrapper = QueryGenerator.initQueryWrapper(contract, req.getParameterMap(),customeRuleMap,true);
+ if (contract.getAgentAuditorIsNull() != null) {
+ if (contract.getAgentAuditorIsNull().equals("false")) {
+ queryWrapper.isNotNull("agents_name");
+ } else{
+ queryWrapper.and(wrapper -> wrapper.isNull("agents_name").or().eq("agents_name", ""));
+
+ }
+ }
+ if (user.equals("鏃�"));
+ else if (role.equals("1972228581703651330")){//閿�鍞�
+// else{
+// if (user.equals("鏃�")){
+// return Result.error("璇疯緭鍏ラ攢鍞悕绉�");//閿�鍞牴鎹敤鎴风瓫閫�
+// }
+ QueryWrapper<SysUser> sysUserQueryWrapper = new QueryWrapper<>();
+ sysUserQueryWrapper.eq("agent_sales", user);
+ Result<IPage<SysUser>> iPageResult = sysUserService.queryPageList(req, sysUserQueryWrapper, pageSize, pageNo);
+ List<String> name = new ArrayList<>();
+ for (SysUser sysUser : iPageResult.getResult().getRecords()){
+ name.add(sysUser.getUsername());
+ }
+ name.add(user);
+ queryWrapper.nested(wrapper -> {
+ // 鍐呭眰绗竴涓潯浠讹細(create_by IN (name) AND review_status != 2)
+ wrapper.nested(w1 -> w1.in("create_by", name).ne("review_status", 2));
+ // 鍐呭眰 OR 鏉′欢锛�(create_by = 鏈�鍚庝竴涓猲ame AND review_status = 2)
+ wrapper.or(w2 -> w2.eq("create_by", name.get(name.size()-1)).eq("review_status", 2));
+ });
+ }
+ if (role.equals("1972228688033452034")){//璐㈠姟
+ queryWrapper.ne("review_status", "8");
+ }
Page<Contract> page = new Page<Contract>(pageNo, pageSize);
- IPage<Contract> pageList = contractService.page(page, queryWrapper);
+ queryWrapper.orderBy(
+ true, // condition锛氭槸鍚﹀惎鐢ㄨ鎺掑簭锛坱rue=鍚敤锛�
+ false, // isAsc锛氭槸鍚﹀崌搴忥紙false=闄嶅簭锛岃 1 鍦ㄥ墠銆�0 鍦ㄥ悗锛�
+ "CASE WHEN review_status = 1 THEN 1 ELSE 0 END" // R column锛氳櫄鎷熸帓搴忓垪锛堢洿鎺ヤ紶 SQL 鐗囨锛�
+ );
+
+ queryWrapper.orderBy(
+ true, // condition锛氭槸鍚﹀惎鐢ㄨ鎺掑簭锛坱rue=鍚敤锛�
+ false, // isAsc锛氭槸鍚﹀崌搴忥紙false=闄嶅簭锛岃 1 鍦ㄥ墠銆�0 鍦ㄥ悗锛�
+ "CASE WHEN review_status = 2 THEN 1 ELSE 0 END" // R column锛氳櫄鎷熸帓搴忓垪锛堢洿鎺ヤ紶 SQL 鐗囨锛�
+ );
+
+ queryWrapper.orderBy(
+ true, // condition锛氭槸鍚﹀惎鐢ㄨ鎺掑簭锛坱rue=鍚敤锛�
+ true, // isAsc锛氭槸鍚﹀崌搴忥紙false=闄嶅簭锛岃 1 鍦ㄥ墠銆�0 鍦ㄥ悗锛�
+ "emergency_status" // R column锛氳櫄鎷熸帓搴忓垪锛堢洿鎺ヤ紶 SQL 鐗囨锛�
+ );
+
+ queryWrapper.orderBy(
+ true, // condition锛氭槸鍚﹀惎鐢ㄨ鎺掑簭锛坱rue=鍚敤锛�
+ false, // isAsc锛氭槸鍚﹀崌搴忥紙false=闄嶅簭锛岃 1 鍦ㄥ墠銆�0 鍦ㄥ悗锛�
+ "create_time" // R column锛氳櫄鎷熸帓搴忓垪锛堢洿鎺ヤ紶 SQL 鐗囨锛�
+ );
+
+ IPage<Contract> pageList = contractService.page(page, queryWrapper);
List<SemanticWord> semanticWordList = null;
for (Contract contract1 : pageList.getRecords()){
semanticWordList = semanticWordService.selectByMainId(contract1.getId());
for (SemanticWord semanticWord : semanticWordList){
+ if (semanticWord.getPrice() != null){
+ contract1.setCountSum(contract1.getCountSum() + semanticWord.getPrice());
+ }
contract1.setSemanticWordList(contract1.getSemanticWordList() == null ? semanticWord.getWord() : contract1.getSemanticWordList() + ", " + semanticWord.getWord());
}
QueryWrapper<Customer> qw = new QueryWrapper<>();
@@ -105,8 +182,83 @@
}
return Result.OK(pageList);
}
-
- /**
+
+
+ @Operation(summary="鍚堝悓-鏌ヨ璇ヨ鑹插悎鍚屼釜鏁�")
+ @GetMapping(value = "/count")
+ public Result<IPage<Contract>> queryPageList(Contract contract,
+ @RequestParam(name="role", defaultValue="鏃�") String role,
+ @RequestParam(name="user", defaultValue="鏃�") String user,
+ HttpServletRequest req) {
+ // 鑷畾涔夋煡璇㈣鍒�
+ Map<String, QueryRuleEnum> customeRuleMap = new HashMap<>();
+ if (contract.getCreateBy() != null) {
+ user = contract.getCreateBy();
+ }
+ // 鑷畾涔夊閫夌殑鏌ヨ瑙勫垯涓猴細LIKE_WITH_OR
+ customeRuleMap.put("reviewStatus", QueryRuleEnum.LIKE_WITH_OR);
+ QueryWrapper<Contract> queryWrapper = QueryGenerator.initQueryWrapper(contract, req.getParameterMap(),customeRuleMap,true);
+ if (contract.getAgentAuditorIsNull() != null) {
+ if (contract.getAgentAuditorIsNull().equals("false")) {
+ queryWrapper.isNotNull("agents_name");
+ } else{
+ queryWrapper.and(wrapper -> wrapper.isNull("agents_name").or().eq("agents_name", ""));
+
+ }
+ }
+ if (user.equals("鏃�"));
+ else if (role.equals("1972228581703651330")){//閿�鍞�
+// else{
+// if (user.equals("鏃�")){
+// return Result.error("璇疯緭鍏ラ攢鍞悕绉�");//閿�鍞牴鎹敤鎴风瓫閫�
+// }
+ QueryWrapper<SysUser> sysUserQueryWrapper = new QueryWrapper<>();
+ sysUserQueryWrapper.eq("agent_sales", user);
+ Result<IPage<SysUser>> iPageResult = sysUserService.queryPageList(req, sysUserQueryWrapper, 100, 1);
+ List<String> name = new ArrayList<>();
+ for (SysUser sysUser : iPageResult.getResult().getRecords()){
+ name.add(sysUser.getUsername());
+ }
+ name.add(user);
+ queryWrapper.nested(wrapper -> {
+ // 鍐呭眰绗竴涓潯浠讹細(create_by IN (name) AND review_status != 2)
+ wrapper.nested(w1 -> w1.in("create_by", name).ne("review_status", 2));
+ // 鍐呭眰 OR 鏉′欢锛�(create_by = 鏈�鍚庝竴涓猲ame AND review_status = 2)
+ wrapper.or(w2 -> w2.eq("create_by", name.get(name.size()-1)).eq("review_status", 2));
+ });
+ }
+ if (role.equals("1972228688033452034")){//璐㈠姟
+ queryWrapper.ne("review_status", "8");
+ }
+ queryWrapper.orderBy(
+ true, // condition锛氭槸鍚﹀惎鐢ㄨ鎺掑簭锛坱rue=鍚敤锛�
+ false, // isAsc锛氭槸鍚﹀崌搴忥紙false=闄嶅簭锛岃 1 鍦ㄥ墠銆�0 鍦ㄥ悗锛�
+ "CASE WHEN review_status = 1 THEN 1 ELSE 0 END" // R column锛氳櫄鎷熸帓搴忓垪锛堢洿鎺ヤ紶 SQL 鐗囨锛�
+ );
+
+ queryWrapper.orderBy(
+ true, // condition锛氭槸鍚﹀惎鐢ㄨ鎺掑簭锛坱rue=鍚敤锛�
+ false, // isAsc锛氭槸鍚﹀崌搴忥紙false=闄嶅簭锛岃 1 鍦ㄥ墠銆�0 鍦ㄥ悗锛�
+ "CASE WHEN review_status = 2 THEN 1 ELSE 0 END" // R column锛氳櫄鎷熸帓搴忓垪锛堢洿鎺ヤ紶 SQL 鐗囨锛�
+ );
+
+ queryWrapper.orderBy(
+ true, // condition锛氭槸鍚﹀惎鐢ㄨ鎺掑簭锛坱rue=鍚敤锛�
+ true, // isAsc锛氭槸鍚﹀崌搴忥紙false=闄嶅簭锛岃 1 鍦ㄥ墠銆�0 鍦ㄥ悗锛�
+ "emergency_status" // R column锛氳櫄鎷熸帓搴忓垪锛堢洿鎺ヤ紶 SQL 鐗囨锛�
+ );
+
+ queryWrapper.orderBy(
+ true, // condition锛氭槸鍚﹀惎鐢ㄨ鎺掑簭锛坱rue=鍚敤锛�
+ false, // isAsc锛氭槸鍚﹀崌搴忥紙false=闄嶅簭锛岃 1 鍦ㄥ墠銆�0 鍦ㄥ悗锛�
+ "create_time" // R column锛氳櫄鎷熸帓搴忓垪锛堢洿鎺ヤ紶 SQL 鐗囨锛�
+ );
+
+ long count = contractService.count(queryWrapper);
+ return Result.OK(count+"");
+ }
+
+ /**
* 娣诲姞
*
* @param contractPage
@@ -119,10 +271,47 @@
public Result<String> add(@RequestBody ContractPage contractPage) {
Contract contract = new Contract();
BeanUtils.copyProperties(contractPage, contract);
+ contract.setContractCode(getFirstLetter(contract.getContractName()));
contractService.saveMain(contract, contractPage.getContractFileList(),contractPage.getSemanticWordList());
- return Result.OK("娣诲姞鎴愬姛锛�");
+ addContract(contract,contractPage.getSemanticWordList());
+
+
+
+ return Result.OK("娣诲姞鎴愬姛锛�");
}
-
+
+ public static String getFirstLetter(String chinese) {
+ if (chinese == null || chinese.isEmpty()) {
+ return "";
+ }
+
+ HanyuPinyinOutputFormat format = new HanyuPinyinOutputFormat();
+ format.setCaseType(HanyuPinyinCaseType.UPPERCASE); // 澶у啓
+ format.setToneType(HanyuPinyinToneType.WITHOUT_TONE); // 蹇界暐澹拌皟
+
+ StringBuilder firstLetters = new StringBuilder();
+ char[] chars = chinese.toCharArray();
+
+ for (char c : chars) {
+ // 濡傛灉鏄腑鏂囷紝鎻愬彇棣栧瓧姣�
+ if (Character.toString(c).matches("[\\u4E00-\\u9FA5]+")) {
+ try {
+ String[] pinyinArray = PinyinHelper.toHanyuPinyinStringArray(c, format);
+ if (pinyinArray != null && pinyinArray.length > 0) {
+ firstLetters.append(pinyinArray[0].charAt(0)); // 鍙栫涓�涓嫾闊崇殑棣栧瓧姣�
+ }
+ } catch (BadHanyuPinyinOutputFormatCombination e) {
+ e.printStackTrace();
+ }
+ } else {
+ // 闈炰腑鏂囦笉澶勭悊锛堟垨鏍规嵁闇�姹備繚鐣�/杩囨护锛�
+ // firstLetters.append(c); // 濡傞渶淇濈暀闈炰腑鏂囧瓧绗︼紝瑙e紑姝ゆ敞閲�
+ }
+ }
+
+ return firstLetters.toString();
+ }
+
/**
* 缂栬緫
*
@@ -138,6 +327,10 @@
if (contract.getCustomer() == null ||contract.getCustomer().getEnterpriseName() == null || !contract.getCustomer().getEnterpriseName().equals("")) {
BeanUtils.copyProperties(contractPage, contract);
Contract contractEntity = contractService.getById(contract.getId());
+ if (contractEntity.getReviewStatus() != null && contract.getReviewStatus() != null && !contractEntity.getReviewStatus().equals(contract.getReviewStatus())) {
+ contractEntity.setChangerTime(new Date());
+ contract.setChangerTime(new Date());
+ }
if(contractEntity==null) {
return Result.error("鏈壘鍒板搴旀暟鎹�");
}
@@ -146,6 +339,12 @@
}
BeanUtils.copyProperties(contractPage, contract);
Contract contractEntity = contractService.getById(contract.getId());
+
+ if (contractEntity.getReviewStatus() != null && contract.getReviewStatus() != null && !contractEntity.getReviewStatus().equals(contract.getReviewStatus())) {
+ contractEntity.setChangerTime(new Date());
+ contract.setChangerTime(new Date());
+ }
+
contractEntity.setCustomer(contract.getCustomer());
contract.setCustomerName(contract.getCustomer().getEnterpriseName());
contractEntity.setCustomerName(contract.getCustomer().getEnterpriseName());
@@ -159,6 +358,13 @@
}
contractService.updateMain(contract, contractPage.getContractFileList(),contractPage.getSemanticWordList());
customerService.updateById(contractEntity.getCustomer());
+
+ if (contractPage.getStatus() != null) {
+ UpdateWrapper<SemanticWord> updateWrapper = new UpdateWrapper<>();
+ updateWrapper.set("status", contractPage.getStatus()); // 鏇挎崲涓哄疄闄呰淇敼鐨勫瓧娈靛悕锛堝semantic_id锛�
+ updateWrapper.eq("contract_id", contract.getId()); // 澶嶇敤鏌ヨ鏉′欢
+ boolean update = semanticWordService.update(updateWrapper);
+ }
return Result.OK("缂栬緫鎴愬姛!");
}
@@ -173,7 +379,28 @@
@RequiresPermissions("contract:contract:delete")
@DeleteMapping(value = "/delete")
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
- contractService.delMain(id);
+ QueryWrapper<Contract> objectQueryWrapper = new QueryWrapper<>();
+ objectQueryWrapper.eq("id",id);
+
+ List<Contract> list = contractService.list(objectQueryWrapper);
+ String customerName = list.get(0).getCustomerName();
+ contractService.delMain(id);
+
+ objectQueryWrapper = new QueryWrapper<>();
+ objectQueryWrapper.eq("customer_name",customerName);
+
+ if (contractService.count(objectQueryWrapper) == 0) {
+ QueryWrapper<Customer> customerQueryWrapper = new QueryWrapper<>();
+ customerQueryWrapper.eq("enterprise_name",customerName);
+ Customer one = customerService.getOne(customerQueryWrapper);
+ customerService.removeById(one);
+
+ QueryWrapper<SysUser> qw = new QueryWrapper<>();
+ qw.eq("username", customerName);
+ qw.eq("realname", customerName);
+
+ sysUserService.remove(qw);
+ }
return Result.OK("鍒犻櫎鎴愬姛!");
}
@@ -191,7 +418,9 @@
this.contractService.delBatchMain(Arrays.asList(ids.split(",")));
return Result.OK("鎵归噺鍒犻櫎鎴愬姛锛�");
}
-
+
+ @Autowired
+ DictAspect dictAspect;
/**
* 閫氳繃id鏌ヨ
*
@@ -202,13 +431,26 @@
@Operation(summary="鍚堝悓-閫氳繃id鏌ヨ")
@GetMapping(value = "/queryById")
public Result<Contract> queryById(@RequestParam(name="id",required=true) String id) {
- Contract contract = contractService.getById(id);
- if(contract==null) {
+ Page<Contract> page = new Page<Contract>(1, 1);
+ QueryWrapper<Contract> contractQueryWrapper = new QueryWrapper<>();
+ contractQueryWrapper.eq("id", id);
+ IPage<Contract> pageList = contractService.page(page, contractQueryWrapper);
+ Result result = (Result) dictAspect.parseDictText(Result.ok(pageList));
+ Contract contract = ((JSONObject)(((IPage)(result.getResult())).getRecords().get(0))).toJavaObject(Contract.class);
+ if(contract==null) {
return Result.error("鏈壘鍒板搴旀暟鎹�");
}
QueryWrapper<Customer> qw = new QueryWrapper<>();
qw.eq("enterprise_name",contract.getCustomerName());
contract.setCustomer(customerService.getOne(qw));
+ List<SemanticWord> semanticWordList = null;
+ semanticWordList = semanticWordService.selectByMainId(contract.getId());
+ for (SemanticWord semanticWord : semanticWordList){
+ if (semanticWord.getPrice() != null){
+ contract.setCountSum(contract.getCountSum() + semanticWord.getPrice());
+ }
+ contract.setSemanticWordList(contract.getSemanticWordList() == null ? semanticWord.getWord() : contract.getSemanticWordList() + ", " + semanticWord.getWord());
+ }
return Result.OK(contract);
}
@@ -324,6 +566,231 @@
}
return Result.OK("鏂囦欢瀵煎叆澶辫触锛�");
}
+ /**
+ * 鏌ヨ蹇繃鏈熺殑鍚堝悓
+ *
+ * @param days 杩囨湡澶╂暟闃堝�硷紙榛樿30澶╋級
+ * @return
+ */
+ @AutoLog(value = "鍚堝悓-鏌ヨ蹇繃鏈熷悎鍚�")
+ @Operation(summary = "鍚堝悓-鏌ヨ蹇繃鏈熷悎鍚�")
+ @GetMapping(value = "/expiring")
+ public Result<List<Map<String, Object>>> queryExpiringContracts(
+ @RequestParam(name = "days", defaultValue = "30") Integer days) {
+ try {
+ // 璁$畻鏃ユ湡鑼冨洿
+ java.time.LocalDate today = java.time.LocalDate.now();
+ java.util.Date startDate = java.sql.Date.valueOf(today);
+ java.util.Date endDateLimit = java.sql.Date.valueOf(today.minusDays(days));
+ // 鏋勫缓鏌ヨ鏉′欢
+ QueryWrapper<Contract> queryWrapper = new QueryWrapper<>();
+ queryWrapper.isNotNull("month")
+ // 鏇挎崲涓� MySQL 姝g‘鐨� DATE_ADD 璇硶锛欴ATE_ADD(鏃ユ湡, INTERVAL 鏁板�� 鍗曚綅)
+ .apply("DATE_ADD(create_time, INTERVAL month MONTH) >= {0}", endDateLimit)
+ .apply("DATE_ADD(create_time, INTERVAL month MONTH) <= {0}", startDate)
+ // 鎺掑簭涔熷悓姝ユ浛鎹负 MySQL 璇硶
+ .orderByAsc("DATE_ADD(create_time, INTERVAL month MONTH)");
+ // 鎵ц鏌ヨ
+ List<Contract> contractList = contractService.list(queryWrapper);
+
+ // 鏋勫缓杩斿洖缁撴灉锛屽寘鍚繃鏈熷ぉ鏁颁俊鎭�
+ List<Map<String, Object>> resultList = new ArrayList<>();
+
+ for (Contract contract : contractList) {
+ Map<String, Object> contractMap = new HashMap<>();
+
+ // 澶嶅埗鍚堝悓鍩烘湰淇℃伅
+ contractMap.put("id", contract.getId());
+ contractMap.put("contractName", contract.getContractName());
+ contractMap.put("customerName", contract.getCustomerName());
+ contractMap.put("endDate", contract.getEndDate());
+ contractMap.put("reviewStatus", contract.getReviewStatus());
+
+ // 璁$畻璺濈杩囨湡鐨勫ぉ鏁�
+ if (contract.getEndDate() != null) {
+ // 灏唈ava.util.Date杞崲涓篖ocalDate
+ java.time.LocalDate endDate = contract.getEndDate().toInstant()
+ .atZone(java.time.ZoneId.systemDefault())
+ .toLocalDate();
+ long daysRemaining = java.time.temporal.ChronoUnit.DAYS.between(today, endDate);
+ contractMap.put("daysRemaining", daysRemaining);
+ } else {
+ contractMap.put("daysRemaining", null);
+ }
+
+ // 璁剧疆瀹㈡埛淇℃伅
+ if (contract.getCustomerName() != null) {
+ QueryWrapper<Customer> customerQueryWrapper = new QueryWrapper<>();
+ customerQueryWrapper.eq("enterprise_name", contract.getCustomerName());
+ Customer customer = customerService.getOne(customerQueryWrapper);
+ contractMap.put("customer", customer);
+ }
+
+ // 璁剧疆璇箟璇嶅垪琛�
+ List<SemanticWord> semanticWordList = semanticWordService.selectByMainId(contract.getId());
+ if (semanticWordList != null && !semanticWordList.isEmpty()) {
+ String semanticWords = semanticWordList.stream()
+ .map(SemanticWord::getWord)
+ .collect(Collectors.joining(", "));
+ contractMap.put("semanticWordList", semanticWords);
+ }
+
+ resultList.add(contractMap);
+ }
+
+ return Result.OK(resultList);
+ } catch (Exception e) {
+ log.error("鏌ヨ蹇繃鏈熷悎鍚屽け璐�", e);
+ return Result.error("鏌ヨ澶辫触: " + e.getMessage());
+ }
+ }
+
+ @Autowired
+ @Qualifier("robinJdbcTemplate") // 鎸囧畾鐗瑰畾鐨凧dbcTemplate
+ private JdbcTemplate jdbcTemplate;
+
+ public void addContract(Contract contract, List<SemanticWord> semanticWordList) {
+ for (SemanticWord semanticWord : semanticWordList){
+ String uuid = UUID.randomUUID().toString().replaceAll("-", "");
+ String sBookMarkName = PinyinUtil.getPinyin(contract.getContractName(), "") + "_" + PinyinUtil.getPinyin(semanticWord.getOutWord());
+ String sCreator = contract.getCreateBy();
+ String sType = contract.getAgentsName() == null || contract.getAgentsName().equals("") ? "瀹㈡埛" : "浠g悊鍟�";
+ String sTarget = semanticWord.getOutWord();
+ String checkSql = "SELECT COUNT(1) FROM d_Contract WHERE sBookMarkName = ?";
+ String contractId = PinyinUtil.getPinyin(contract.getContractName(), "");
+ Integer count = jdbcTemplate.queryForObject(
+ checkSql,
+ new Object[]{sBookMarkName}, // 浼犲叆鏌ヨ鍙傛暟锛堝悎鍚屽悕绉帮級
+ Integer.class
+ );
+ if (count > 0) {
+ return;
+ }
+ String[] arr = new String[]{"鍝濂�", "鍝闈犺氨", "鎺掕姒�", "閫夊摢瀹�", "鎺掑悕"};
+ for (int i = 0; i < 5; i++) {
+ uuid = UUID.randomUUID().toString().replaceAll("-", "");
+ sBookMarkName = semanticWord.getWord() + arr[i];
+ String semantic_word = semanticWord.getOutWord();
+// 鎻掑叆SQL锛屽浐瀹氬�肩洿鎺ュ啓鍦⊿QL涓紝鍔ㄦ�佸�肩敤?鍗犱綅
+ String insertSql = "INSERT INTO d_keyword_list (" + // 琛ㄥ悕淇涓� d_keyword_list
+ "UUID, sBookMarkName, ContractId, semantic_word, sCreator, sType, sDomain, " +
+ "apply_name, is_active, priority_num, interval_minute, is_proxy, proxy_mode, scan_min" + // 琛ュ厖琛ㄤ腑瀛樺湪鐨� is_proxy 瀛楁
+ ") VALUES (" +
+ "?, ?, ?, ?, 'admin', 'manual', '瀹㈡埛', " +
+ "'deepseek', 1, 8, 240, 0, 'random', 5" + // 琛ュ厖 is_proxy 鐨勯粯璁ゅ�硷紙int绫诲瀷锛岃繖閲岀敤0锛�
+ ")";
+
+ // 鎵ц鎻掑叆锛屼粎浼犲叆鍔ㄦ�佸弬鏁�
+// jdbcTemplate.update(
+// insertSql,
+// uuid, // 鍔ㄦ�乁UID
+// sBookMarkName, // 鍔ㄦ�乻BookMarkName
+// contractId,
+// semanticWord.getWord() // 鍔ㄦ�乻emantic_word
+// );
+
+ }
+ }
+ }
+
+ @RequiresPermissions("contract:contract:importAgentContractWord")
+ @RequestMapping(value = "/importAgentContractWord", method = RequestMethod.POST)
+ public Result<String> importAgentContractWord(@RequestBody Contract contract) {
+ if (contract.getReviewStatus() == null) {
+ contract.setReviewStatus("8");
+ }
+
+ QueryWrapper queryWrapper = new QueryWrapper();
+
+ queryWrapper.eq("contract_name",contract.getContractName());
+
+ long count = contractService.count(queryWrapper);
+
+ if (count > 0) {
+ return Result.error("鍚堝悓鍚嶇О宸插瓨鍦�");
+ }
+
+ contractService.save(contract);
+
+ QueryWrapper<Contract> queryWrapper1 = new QueryWrapper<>();
+ queryWrapper1.eq("contract_name",contract.getContractName());
+
+
+ Contract one1 = contractService.getOne(queryWrapper1);
+ for (SemanticWord semanticWord : contract.getSemanticWordObjs()){
+ semanticWord.setContractId(one1.getId());
+ }
+ semanticWordService.saveBatch(contract.getSemanticWordObjs());
+
+ for (ContractFile contractFile : contract.getContractFileList()){
+ contractFile.setContractId(one1.getId());
+ contractFileService.save(contractFile);
+ }
+ addContract(contract,contract.getSemanticWordObjs());
+
+ return Result.OK("娣诲姞鎴愬姛锛�");
+ }
+
+ @Autowired
+ private SysUserController sysUserController;
+
+ @RequiresPermissions("contract:contract:assignCustomers")
+ @RequestMapping(value = "/assignCustomers/{contractId}", method = RequestMethod.POST)
+ public Result<String> assignCustomers(@RequestBody Customer customer, @PathVariable("contractId") String contractId) {
+ QueryWrapper<Customer> queryWrapper = new QueryWrapper<>();
+ queryWrapper.eq("enterprise_name",customer.getEnterpriseName());
+ QueryWrapper<SysUser> querySysUser = new QueryWrapper<>();
+ querySysUser.eq("username",customer.getEnterpriseName());
+
+ if (customerService.count(queryWrapper) == 0) {
+ customerService.save(customer);
+ }
+
+ if (sysUserController.getSysUserService().count(querySysUser) == 0) {
+ JSONObject jsonObject = new JSONObject();
+ String filteredName = customer.getEnterpriseName().replaceAll("[\u4e00-\u9fa5]", "").replaceAll("\\s+", "");
+ jsonObject.put("workNo", "KH" + filteredName + customer.getCustomerPhone());
+ jsonObject.put("password", "123456");
+ jsonObject.put("confirmPassword", "123456");
+ jsonObject.put("selectedroles", "1972228625018228737");
+ jsonObject.put("activitiSync", "1");
+ jsonObject.put("departIds", "");
+ jsonObject.put("userIdentity", "1");
+ String phone = customer.getCustomerPhone(); ;
+
+// 鏍¢獙鐢佃瘽鍙风爜锛氶潪绌轰笖涓烘暟瀛楋紝涓旈暱搴︹墹20
+ if (phone != null && phone.matches("\\d{1,20}")) {
+ // 鏍¢獙閫氳繃锛屾斁鍏SONObject
+ jsonObject.put("phone", phone);
+ } else if(phone == null) {
+
+ }else {
+ return Result.error("璇疯緭鍏ユ纭殑鐢佃瘽鍙风爜");
+ }
+ jsonObject.put("email" , customer.getCustomerEmail());
+ jsonObject.put("username" , customer.getEnterpriseName());
+ jsonObject.put("realname" , customer.getEnterpriseName());
+ try {
+ Result<SysUser> add = sysUserController.add(jsonObject);
+ if (add.getCode() != 200) {
+ return Result.error("鐢佃瘽鍙风爜鎴栭偖绠遍噸澶�");
+ }
+ }catch (Exception e) {
+ if (e.getMessage().equals("Subject does not have permission [system:user:add]")){
+ return Result.error("鏈垎閰嶆潈闄愶細鍒涘缓瀹㈡埛鐢ㄦ埛");
+ }
+ return Result.error("鐢佃瘽鍙风爜鎴栭偖绠遍噸澶�");
+ }
+ }
+
+ Contract contract = new Contract();
+ contract.setId(contractId);
+ contract.setCustomerName(customer.getEnterpriseName());
+
+ contractService.updateById(contract);
+
+ return Result.OK("娣诲姞鎴愬姛锛佸彲閫氳繃" + customer.getEnterpriseName() + "/123456璁块棶瀹㈡埛瑙嗗浘");
+ }
}
--
Gitblit v1.8.0