111111
This commit is contained in:
parent
b96f7ed8dd
commit
21464905de
@ -1,5 +1,6 @@
|
||||
package com.ruoyi.cus.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
@ -11,6 +12,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.cus.service.ICusImportService;
|
||||
import com.ruoyi.cus.vo.CusMainVO;
|
||||
import com.ruoyi.cus.vo.MainVO;
|
||||
import com.ruoyi.utils.CodeGenerator;
|
||||
@ -33,6 +35,7 @@ import com.ruoyi.cus.domain.CusMain;
|
||||
import com.ruoyi.cus.service.ICusMainService;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* 客户信息Controller
|
||||
@ -42,12 +45,14 @@ import com.ruoyi.common.core.page.TableDataInfo;
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/cus/main")
|
||||
public class CusMainController extends BaseController
|
||||
{
|
||||
public class CusMainController extends BaseController {
|
||||
@Autowired
|
||||
private ICusMainService cusMainService;
|
||||
@Autowired
|
||||
private CodeGenerator codeGenerator;
|
||||
@Autowired
|
||||
private ICusImportService cusImportService;
|
||||
|
||||
/**
|
||||
* 生成客户编码
|
||||
*/
|
||||
@ -76,6 +81,7 @@ public class CusMainController extends BaseController
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询客户信息列表
|
||||
*/
|
||||
@ -83,8 +89,7 @@ public class CusMainController extends BaseController
|
||||
@GetMapping("/list")
|
||||
public AjaxResult list(MainVO cusMain,
|
||||
@RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize)
|
||||
{
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
|
||||
Page<CusMain> page = new Page<>(pageNum, pageSize);
|
||||
IPage<MainVO> list = cusMainService.queryListPage(cusMain, page);
|
||||
return success(list);
|
||||
@ -96,13 +101,29 @@ public class CusMainController extends BaseController
|
||||
@PreAuthorize("@ss.hasPermi('cus:main:export')")
|
||||
@Log(title = "客户信息", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, CusMain cusMain)
|
||||
{
|
||||
public void export(HttpServletResponse response, CusMain cusMain) {
|
||||
List<CusMain> list = cusMainService.list();
|
||||
ExcelUtil<CusMain> util = new ExcelUtil<CusMain>(CusMain.class);
|
||||
util.exportExcel(response, list, "客户信息数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 客户信息导入
|
||||
*
|
||||
* @param file TODO
|
||||
* @return com.ruoyi.common.core.domain.AjaxResult
|
||||
* @author PQZ
|
||||
* @date 14:29 2025/11/19
|
||||
**/
|
||||
@Log(title = "客户信息导入", businessType = BusinessType.IMPORT)
|
||||
@PostMapping("/importCus")
|
||||
public AjaxResult importCusAndContacts(@RequestParam("file") MultipartFile file) throws IOException {
|
||||
if (file.isEmpty()) {
|
||||
return AjaxResult.error("上传文件不能为空");
|
||||
}
|
||||
return cusImportService.importCusAndContacts(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取客户信息详细信息--编辑
|
||||
*/
|
||||
@ -142,8 +163,7 @@ public class CusMainController extends BaseController
|
||||
@PreAuthorize("@ss.hasPermi('cus:main:remove')")
|
||||
@Log(title = "客户信息", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable String[] ids)
|
||||
{
|
||||
public AjaxResult remove(@PathVariable String[] ids) {
|
||||
List<String> list = new ArrayList<>(Arrays.asList(ids));
|
||||
return toAjax(cusMainService.removeByIds(list));
|
||||
}
|
||||
|
||||
@ -0,0 +1,28 @@
|
||||
package com.ruoyi.cus.dto;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class CusBankImportDTO {
|
||||
@Excel(name = "客户代码")
|
||||
private String cusCode;
|
||||
@Excel(name = "银行账号")
|
||||
private String bankAccount;
|
||||
@Excel(name = "银行名称")
|
||||
private String bankName;
|
||||
@Excel(name = "币种")
|
||||
private String currency;
|
||||
@Excel(name = "银行代码")
|
||||
private String bankCode;
|
||||
@Excel(name = "银行swift代码")
|
||||
private String swiftCode;
|
||||
@Excel(name = "银行地址")
|
||||
private String bankAddress;
|
||||
@Excel(name = "分支机构代码")
|
||||
private String branchCode;
|
||||
@Excel(name = "税号")
|
||||
private String taxId;
|
||||
}
|
||||
@ -0,0 +1,77 @@
|
||||
package com.ruoyi.cus.dto;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class CusImportDTO {
|
||||
// 客户主表字段
|
||||
@Excel(name = "客户代码")
|
||||
private String cusCode;
|
||||
@Excel(name = "客户名称")
|
||||
private String fullName;
|
||||
@Excel(name = "客户简称")
|
||||
private String shortName;
|
||||
@Excel(name = "客户类型")
|
||||
private String cusType;
|
||||
@Excel(name = "国家/地区")
|
||||
private String country;
|
||||
@Excel(name = "时区")
|
||||
private String zoneName;
|
||||
@Excel(name = "主营产品")
|
||||
private String mainProds;
|
||||
@Excel(name = "企业网站")
|
||||
private String siteUrl;
|
||||
@Excel(name = "创建人")
|
||||
private String createBy;
|
||||
@Excel(name = "创建日期")
|
||||
private String createTime;
|
||||
@Excel(name = "修改日期")
|
||||
private String updateTime;
|
||||
@Excel(name = "客户备注")
|
||||
private String cusRemark;
|
||||
|
||||
// 客户公司信息表字段
|
||||
@Excel(name = "客户来源")
|
||||
private String cusSource;
|
||||
@Excel(name = "客户等级")
|
||||
private String cusLevel;
|
||||
@Excel(name = "业务类型")
|
||||
private String businessType;
|
||||
@Excel(name = "联系地址")
|
||||
private String contactAddress;
|
||||
|
||||
// 客户管理信息表字段
|
||||
@Excel(name = "部门")
|
||||
private String dept;
|
||||
@Excel(name = "业务员")
|
||||
private String userName;
|
||||
@Excel(name = "跟进阶段")
|
||||
private String followStep;
|
||||
@Excel(name = "预计转入公海原因")
|
||||
private String seasReason;
|
||||
@Excel(name = "公海组")
|
||||
private String seasGroup;
|
||||
@Excel(name = "原部门")
|
||||
private String oldDept;
|
||||
|
||||
// 客户联系人表字段
|
||||
@Excel(name = "姓名")
|
||||
private String name;
|
||||
@Excel(name = "昵称")
|
||||
private String nickName;
|
||||
@Excel(name = "邮箱")
|
||||
private String email;
|
||||
@Excel(name = "手机")
|
||||
private String telephone;
|
||||
@Excel(name = "性别")
|
||||
private String sex;
|
||||
@Excel(name = "生日")
|
||||
private String birthday;
|
||||
@Excel(name = "whatsApp")
|
||||
private String whatsApp;
|
||||
@Excel(name = "联系人备注")
|
||||
private String contactRemark;
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
package com.ruoyi.cus.service;
|
||||
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public interface ICusImportService {
|
||||
/**
|
||||
* 导入客户及联系人信息
|
||||
* @param file 导入文件
|
||||
* @return 导入结果
|
||||
*/
|
||||
AjaxResult importCusAndContacts(MultipartFile file) throws IOException;
|
||||
|
||||
}
|
||||
@ -0,0 +1,80 @@
|
||||
package com.ruoyi.cus.service.impl;
|
||||
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.cus.dto.CusBankImportDTO;
|
||||
import com.ruoyi.cus.dto.CusImportDTO;
|
||||
import com.ruoyi.cus.service.ICusImportService;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class CusImportServiceImpl implements ICusImportService {
|
||||
/**
|
||||
* 导入客户及联系人信息
|
||||
*
|
||||
* @param file 导入文件
|
||||
* @return 导入结果
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult importCusAndContacts(MultipartFile file) throws IOException {
|
||||
try {
|
||||
// 先打印所有sheet页名称
|
||||
Workbook workbook = new XSSFWorkbook(file.getInputStream());
|
||||
int numberOfSheets = workbook.getNumberOfSheets();
|
||||
System.out.println("总共有 " + numberOfSheets + " 个sheet页");
|
||||
|
||||
for (int i = 0; i < numberOfSheets; i++) {
|
||||
Sheet sheet = workbook.getSheetAt(i);
|
||||
System.out.println("Sheet " + i + " 名称: " + sheet.getSheetName());
|
||||
}
|
||||
|
||||
// 关闭workbook
|
||||
workbook.close();
|
||||
// 重新获取输入流用于数据读取
|
||||
InputStream inputStream = file.getInputStream();
|
||||
|
||||
// 读取第二个sheet页数据(索引为1)
|
||||
ExcelUtil<CusImportDTO> cusUtil = new ExcelUtil<>(CusImportDTO.class);
|
||||
List<CusImportDTO> secondSheetList = cusUtil.importExcel("客户联系人", inputStream, 1);
|
||||
|
||||
System.out.println("第二个sheet页数据条数: " + (secondSheetList != null ? secondSheetList.size() : 0));
|
||||
|
||||
// 重新获取输入流用于读取第三个sheet页数据
|
||||
InputStream thirdSheetInputStream = file.getInputStream();
|
||||
|
||||
// 读取第三个sheet页数据(索引为2)
|
||||
ExcelUtil<CusBankImportDTO> bankUtil = new ExcelUtil<>(CusBankImportDTO.class);
|
||||
List<CusBankImportDTO> thirdSheetList = bankUtil.importExcel("银行资料", thirdSheetInputStream, 0);
|
||||
System.out.println("第三个sheet页数据条数: " + (thirdSheetList != null ? thirdSheetList.size() : 0));
|
||||
return AjaxResult.success("导入成功");
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error("导入失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据处理
|
||||
*
|
||||
* @param cusList List<CusImportDTO>
|
||||
* @param bankList List<CusBankImportDTO>
|
||||
* @author PQZ
|
||||
* @date 15:30 2025/11/19
|
||||
**/
|
||||
private void saveCusAndBank(List<CusImportDTO> cusList, List<CusBankImportDTO> bankList) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -63,6 +63,16 @@
|
||||
v-hasPermi="['cus:main:export']"
|
||||
>导出</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="info"
|
||||
plain
|
||||
icon="el-icon-upload2"
|
||||
size="mini"
|
||||
@click="handleImport"
|
||||
>导入</el-button>
|
||||
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
@ -241,12 +251,28 @@
|
||||
|
||||
<!-- 添加或修改客户信息对话框 -->
|
||||
<draw-form ref="drawForm"></draw-form>
|
||||
<!-- 客户信息导入对话框 -->
|
||||
<el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
|
||||
<el-upload ref="upload" :limit="1" accept=".xlsx, .xls" :headers="upload.headers" :action="upload.url + '?updateSupport=' + upload.updateSupport" :disabled="upload.isUploading" :on-progress="handleFileUploadProgress" :on-success="handleFileSuccess" :auto-upload="false" drag>
|
||||
<i class="el-icon-upload"></i>
|
||||
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
||||
<div class="el-upload__tip text-center" slot="tip">
|
||||
<span>仅允许导入xls、xlsx格式文件。</span>
|
||||
<el-link type="primary" :underline="false" style="font-size: 12px; vertical-align: baseline">下载模板</el-link>
|
||||
</div>
|
||||
</el-upload>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitFileForm">确 定</el-button>
|
||||
<el-button @click="upload.open = false">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listMain, getMain, delMain, addMain, updateMain } from "@/api/cus/main";
|
||||
import DrawForm from './drawForm'
|
||||
import { getToken } from "@/utils/auth";
|
||||
|
||||
export default {
|
||||
name: "Main",
|
||||
@ -276,6 +302,21 @@ export default {
|
||||
country: null,
|
||||
mainProds: null,
|
||||
},
|
||||
// 客户导入参数
|
||||
upload: {
|
||||
// 是否显示弹出层(用户导入)
|
||||
open: false,
|
||||
// 弹出层标题(用户导入)
|
||||
title: "",
|
||||
// 是否禁用上传
|
||||
isUploading: false,
|
||||
// 是否更新已经存在的用户数据
|
||||
updateSupport: 0,
|
||||
// 设置上传的请求头部
|
||||
headers: { Authorization: "Bearer " + getToken() },
|
||||
// 上传的地址
|
||||
url: process.env.VUE_APP_BASE_API + "/cus/main/importCus"
|
||||
},
|
||||
};
|
||||
},
|
||||
activated() {
|
||||
@ -286,6 +327,18 @@ export default {
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
|
||||
// 提交上传文件
|
||||
submitFileForm() {
|
||||
this.$refs.upload.submit();
|
||||
},
|
||||
|
||||
/** 导入按钮操作 */
|
||||
handleImport() {
|
||||
this.upload.title = "用户导入";
|
||||
this.upload.open = true;
|
||||
},
|
||||
|
||||
/** 客户代码点击事件 */
|
||||
handleCodeClick(row) {
|
||||
this.$router.push({path:'/cus/viewForm',query:{id:row.id}})
|
||||
|
||||
Loading…
Reference in New Issue
Block a user