chengf
2026-02-06 49158a77cb676a15bebe1be5507e18e5a30c1fa5
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/demo/contract/controller/ContractController.java
@@ -13,10 +13,14 @@
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.message.util.ChinesePinyinUtils;
import org.jeecg.modules.system.controller.SysUserController;
import org.jeecg.modules.system.entity.SysUser;
import org.jeecg.modules.system.service.ISysUserService;
@@ -202,7 +206,13 @@
             }
         }
         if (user.equals("无"));
         if (!user.equals("无")){
             QueryWrapper qw = new QueryWrapper<SysUser>();
             qw.eq("id", user);
             String userName = ((SysUser)((Page) sysUserService.queryPageList(req, qw, 1, 1).getResult()).getRecords().get(0)).getUsername();
             queryWrapper.eq("create_by", userName);
         }
         if (role.equals("无"));
         else if (role.equals("1972228581703651330")){//销售
//        else{
//            if (user.equals("无")){
@@ -222,9 +232,6 @@
                 // 内层 OR 条件:(create_by = 最后一个name 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:是否启用该排序(true=启用)
@@ -267,15 +274,47 @@
   public Result<String> add(@RequestBody ContractPage contractPage) {
      Contract contract = new Contract();
      BeanUtils.copyProperties(contractPage, contract);
        contract.setContractCode(ChinesePinyinUtils.getFirstLetter(contract.getContractName()));
        contract.setContractCode(getFirstLetter(contract.getContractName()));
      contractService.saveMain(contract, contractPage.getContractFileList(),contractPage.getSemanticWordList());
        addContract(contract,contractPage.getSemanticWordList());
//        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); // 如需保留非中文字符,解开此注释
             }
         }
         return firstLetters.toString();
     }
   /**
    *  编辑
    *
@@ -331,7 +370,22 @@
        }
      return Result.OK("编辑成功!");
   }
     @AutoLog(value = "停止服务合同")
     @Operation(summary="停止服务合同")
     @RequiresPermissions("contract:contract:dropService")
     @RequestMapping(value = "/dropService", method = {RequestMethod.PUT,RequestMethod.POST})
     public Result<String> dropService(@RequestBody ContractPage contractPage) {
         Contract contract = new Contract();
         contract.setId(contractPage.getId());
         contract.setIsDropService(contractPage.getIsDropService().isEmpty() ? "是" : contractPage.getIsDropService());
         boolean b = contractService.updateById(contract);
         if (b) {
             return Result.OK("更新完成");
         } else {
             return Result.error("更新失败");
         }
     }
   /**
    *   通过id删除
    *
@@ -622,13 +676,15 @@
             String sType = contract.getAgentsName() == null || contract.getAgentsName().equals("") ? "客户" : "代理商";
             String sTarget = semanticWord.getOutWord();
             String checkSql = "SELECT COUNT(1) FROM d_Contract WHERE sBookMarkName = ?";
             String contractId = 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("-", "");
@@ -644,13 +700,13 @@
                         ")";
                 // 执行插入,仅传入动态参数
                 jdbcTemplate.update(
                         insertSql,
                         uuid,               // 动态UUID
                         sBookMarkName, // 动态sBookMarkName
                         contractId,
                         semanticWord.getWord()  // 动态semantic_word
                 );
//                 jdbcTemplate.update(
//                         insertSql,
//                         uuid,               // 动态UUID
//                         sBookMarkName, // 动态sBookMarkName
//                         contractId,
//                         semanticWord.getWord()  // 动态semantic_word
//                 );
             }
         }
@@ -689,7 +745,7 @@
             contractFile.setContractId(one1.getId());
             contractFileService.save(contractFile);
         }
         addContract(contract,contract.getSemanticWordObjs());
//         addContract(contract,contract.getSemanticWordObjs());
         return Result.OK("添加成功!");
     }