import fs from 'fs' import path from 'path' import { fileURLToPath } from 'url' const __dirname = path.dirname(fileURLToPath(import.meta.url)) const p = path.resolve(__dirname, '../../fs-saas-admin/src/main/java/com/fs/company/controller/CompanyEasyCallController.java') const content = `package com.fs.company.controller; import com.fs.aicall.domain.CcLlmAgentAccount; import com.fs.aicall.domain.CcTtsAliyun; import com.fs.aicall.service.ICcLlmAgentAccountService; import com.fs.aicall.service.ICompanyBindAiModelService; import com.fs.common.core.controller.BaseController; import com.fs.common.core.domain.R; import com.fs.company.mapper.CompanyVoiceCloneRefMapper; import com.fs.company.service.easycall.IEasyCallService; import com.fs.company.support.AdminCompanyScopeHelper; import com.fs.company.vo.easycall.EasyCallBusiGroupVO; import com.fs.company.vo.easycall.EasyCallGatewayVO; import com.fs.company.vo.easycall.EasyCallVoiceCodeVO; import com.fs.company.vo.easycall.ExtensionVO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; /** * EasyCall \u5916\u547c\u57fa\u7840\u6570\u636e\uff08\u603b\u540e\u53f0\u6865\u63a5\uff09 * \u9500\u552e\u7aef\u4ece\u767b\u5f55\u6001\u53d6 companyId\uff1b\u603b\u540e\u53f0\u901a\u8fc7 companyId \u53c2\u6570\u6307\u5b9a\u516c\u53f8\u3002 */ @Api(tags = "EasyCallCenter365\u5916\u547c\u7ba1\u7406(\u603b\u540e\u53f0)") @RestController @RequestMapping("/company/easyCall") public class CompanyEasyCallController extends BaseController { @Autowired private IEasyCallService easyCallService; @Autowired private ICompanyBindAiModelService companyBindAiModelService; @Autowired private ICcLlmAgentAccountService ccLlmAgentAccountService; @Autowired private CompanyVoiceCloneRefMapper companyVoiceCloneRefMapper; @ApiOperation("\u83b7\u53d6\u7f51\u5173\u5217\u8868") @GetMapping("/gateway/list") public R getGatewayList(@RequestParam Long companyId) { Long cid = AdminCompanyScopeHelper.requireCompanyId(companyId, "\u8bf7\u9009\u62e9\u9500\u552e\u516c\u53f8"); List list = easyCallService.getGatewayList(cid); return R.ok().put("data", list); } @ApiOperation("\u83b7\u53d6\u5927\u6a21\u578b\u914d\u7f6e\u5217\u8868") @GetMapping("/llmAccount/list") public R getLlmAccountList(@RequestParam Long companyId) { Long cid = AdminCompanyScopeHelper.requireCompanyId(companyId, "\u8bf7\u9009\u62e9\u9500\u552e\u516c\u53f8"); List modelIds = companyBindAiModelService.selectVisibleModelIdsForCompany(cid); if (modelIds.isEmpty()) { return R.ok().put("data", new ArrayList<>()); } CcLlmAgentAccount ccLlmAgentAccount = new CcLlmAgentAccount(); ccLlmAgentAccount.setModelIds(modelIds); List list = ccLlmAgentAccountService.selectCcLlmAgentAccountList(ccLlmAgentAccount); return R.ok().put("data", list); } @ApiOperation("\u83b7\u53d6\u97f3\u8272\u5217\u8868") @GetMapping("/voiceCode/list") public R getVoiceCodeList(@RequestParam Long companyId) { Long cid = AdminCompanyScopeHelper.requireCompanyId(companyId, "\u8bf7\u9009\u62e9\u9500\u552e\u516c\u53f8"); List ttsIds = companyVoiceCloneRefMapper.selectActiveTtsIds(cid, null); List ccTtsAliyuns = companyVoiceCloneRefMapper.selectCcTtsAliyunList(); List result = ccTtsAliyuns.stream() .filter(item -> item.getPriority() == 1 || (item.getPriority() == 0 && ttsIds.contains(item.getId()))) .map(item -> { EasyCallVoiceCodeVO vo = new EasyCallVoiceCodeVO(); vo.setVoiceCode(item.getVoiceCode()); vo.setVoiceName(item.getVoiceName()); vo.setVoiceSource(item.getVoiceSource()); vo.setTtsModels(item.getTtsModels()); return vo; }) .collect(Collectors.toList()); return R.ok().put("data", result); } @ApiOperation("\u83b7\u53d6\u6280\u80fd\u7ec4\u5217\u8868") @GetMapping("/busiGroup/list") public R getBusiGroupList(@RequestParam Long companyId) { Long cid = AdminCompanyScopeHelper.requireCompanyId(companyId, "\u8bf7\u9009\u62e9\u9500\u552e\u516c\u53f8"); List list = easyCallService.getBusiGroupList(cid); return R.ok().put("data", list); } @ApiOperation("\u83b7\u53d6\u5206\u673a\u53f7\u7801list") @GetMapping("/getExtensionList") public R getExtensionList(@RequestParam Long companyId) { Long cid = AdminCompanyScopeHelper.requireCompanyId(companyId, "\u8bf7\u9009\u62e9\u9500\u552e\u516c\u53f8"); List extensionList = easyCallService.getExtensionList(cid); return R.ok().put("data", extensionList); } } ` fs.writeFileSync(p, content, 'utf8') const t = fs.readFileSync(p, 'utf8') console.log('written', p) console.log('FFFD', t.includes('\uFFFD')) console.log('sample', t.includes('\u8bf7\u9009\u62e9\u9500\u552e\u516c\u53f8'))