feat(credit): 添加失信被执行人和司法大数据管理功能
- 新增失信被执行人实体类、控制器、Mapper及Service实现 - 新增司法大数据实体类、控制器、Mapper及Service实现 - 实现分页查询、列表查询、详情查询接口 - 支持新增、修改、删除及批量操作接口 - 支持Excel模板下载与数据导入功能 - 配置MQTT生产环境启用开关及连接地址调整 - 移除旧审计报告相关控制器、枚举及DTO定义
This commit is contained in:
@@ -0,0 +1,272 @@
|
||||
package com.gxwebsoft.credit.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.credit.entity.CreditCompetitor;
|
||||
import com.gxwebsoft.credit.param.CreditCompetitorImportParam;
|
||||
import com.gxwebsoft.credit.param.CreditCompetitorParam;
|
||||
import com.gxwebsoft.credit.service.CreditCompetitorService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 竞争对手控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-12-19 19:49:05
|
||||
*/
|
||||
@Tag(name = "竞争对手管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/credit/credit-competitor")
|
||||
public class CreditCompetitorController extends BaseController {
|
||||
@Resource
|
||||
private CreditCompetitorService creditCompetitorService;
|
||||
|
||||
@Operation(summary = "分页查询竞争对手")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<CreditCompetitor>> page(CreditCompetitorParam param) {
|
||||
// 使用关联查询
|
||||
return success(creditCompetitorService.pageRel(param));
|
||||
}
|
||||
|
||||
@Operation(summary = "查询全部竞争对手")
|
||||
@GetMapping()
|
||||
public ApiResult<List<CreditCompetitor>> list(CreditCompetitorParam param) {
|
||||
// 使用关联查询
|
||||
return success(creditCompetitorService.listRel(param));
|
||||
}
|
||||
|
||||
@Operation(summary = "根据id查询竞争对手")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<CreditCompetitor> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(creditCompetitorService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('credit:creditCompetitor:save')")
|
||||
@OperationLog
|
||||
@Operation(summary = "添加竞争对手")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody CreditCompetitor creditCompetitor) {
|
||||
// 记录当前登录用户id
|
||||
// User loginUser = getLoginUser();
|
||||
// if (loginUser != null) {
|
||||
// creditCompetitor.setUserId(loginUser.getUserId());
|
||||
// }
|
||||
if (creditCompetitorService.save(creditCompetitor)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('credit:creditCompetitor:update')")
|
||||
@OperationLog
|
||||
@Operation(summary = "修改竞争对手")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody CreditCompetitor creditCompetitor) {
|
||||
if (creditCompetitorService.updateById(creditCompetitor)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('credit:creditCompetitor:remove')")
|
||||
@OperationLog
|
||||
@Operation(summary = "删除竞争对手")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (creditCompetitorService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('credit:creditCompetitor:save')")
|
||||
@OperationLog
|
||||
@Operation(summary = "批量添加竞争对手")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<CreditCompetitor> list) {
|
||||
if (creditCompetitorService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('credit:creditCompetitor:update')")
|
||||
@OperationLog
|
||||
@Operation(summary = "批量修改竞争对手")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<CreditCompetitor> batchParam) {
|
||||
if (batchParam.update(creditCompetitorService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('credit:creditCompetitor:remove')")
|
||||
@OperationLog
|
||||
@Operation(summary = "批量删除竞争对手")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (creditCompetitorService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量导入竞争对手
|
||||
*/
|
||||
@PreAuthorize("hasAuthority('credit:creditCompetitor:save')")
|
||||
@Operation(summary = "批量导入竞争对手")
|
||||
@PostMapping("/import")
|
||||
public ApiResult<List<String>> importBatch(@RequestParam("file") MultipartFile file) {
|
||||
List<String> errorMessages = new ArrayList<>();
|
||||
int successCount = 0;
|
||||
|
||||
try {
|
||||
ExcelImportSupport.ImportResult<CreditCompetitorImportParam> importResult = ExcelImportSupport.read(
|
||||
file, CreditCompetitorImportParam.class, this::isEmptyImportRow);
|
||||
List<CreditCompetitorImportParam> list = importResult.getData();
|
||||
int usedTitleRows = importResult.getTitleRows();
|
||||
int usedHeadRows = importResult.getHeadRows();
|
||||
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return fail("未读取到数据,请确认模板表头与示例格式一致", null);
|
||||
}
|
||||
|
||||
User loginUser = getLoginUser();
|
||||
Integer currentUserId = loginUser != null ? loginUser.getUserId() : null;
|
||||
Integer currentTenantId = loginUser != null ? loginUser.getTenantId() : null;
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
CreditCompetitorImportParam param = list.get(i);
|
||||
try {
|
||||
CreditCompetitor item = convertImportParamToEntity(param);
|
||||
|
||||
if (item.getUserId() == null && currentUserId != null) {
|
||||
item.setUserId(currentUserId);
|
||||
}
|
||||
if (item.getTenantId() == null && currentTenantId != null) {
|
||||
item.setTenantId(currentTenantId);
|
||||
}
|
||||
if (item.getStatus() == null) {
|
||||
item.setStatus(0);
|
||||
}
|
||||
if (item.getRecommend() == null) {
|
||||
item.setRecommend(0);
|
||||
}
|
||||
if (item.getDeleted() == null) {
|
||||
item.setDeleted(0);
|
||||
}
|
||||
|
||||
int excelRowNumber = i + 1 + usedTitleRows + usedHeadRows;
|
||||
if (ImportHelper.isBlank(item.getCompanyName())) {
|
||||
errorMessages.add("第" + excelRowNumber + "行:企业名称不能为空");
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean saved = creditCompetitorService.save(item);
|
||||
if (!saved) {
|
||||
CreditCompetitor existing = creditCompetitorService.lambdaQuery()
|
||||
.eq(CreditCompetitor::getCompanyName, item.getCompanyName())
|
||||
.one();
|
||||
if (existing != null) {
|
||||
item.setId(existing.getId());
|
||||
if (creditCompetitorService.updateById(item)) {
|
||||
successCount++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
successCount++;
|
||||
continue;
|
||||
}
|
||||
errorMessages.add("第" + excelRowNumber + "行:保存失败");
|
||||
} catch (Exception e) {
|
||||
int excelRowNumber = i + 1 + usedTitleRows + usedHeadRows;
|
||||
errorMessages.add("第" + excelRowNumber + "行:" + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (errorMessages.isEmpty()) {
|
||||
return success("成功导入" + successCount + "条数据", null);
|
||||
} else {
|
||||
return success("导入完成,成功" + successCount + "条,失败" + errorMessages.size() + "条", errorMessages);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return fail("导入失败:" + e.getMessage(), null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载竞争对手导入模板
|
||||
*/
|
||||
@Operation(summary = "下载竞争对手导入模板")
|
||||
@GetMapping("/import/template")
|
||||
public void downloadTemplate(HttpServletResponse response) throws IOException {
|
||||
List<CreditCompetitorImportParam> templateList = new ArrayList<>();
|
||||
|
||||
CreditCompetitorImportParam example = new CreditCompetitorImportParam();
|
||||
example.setCompanyName("示例科技有限公司");
|
||||
example.setLegalRepresentative("张三");
|
||||
example.setRegisteredCapital("5000");
|
||||
example.setEstablishmentDate("2015-01-01");
|
||||
example.setRegistrationStatus("存续");
|
||||
example.setIndustry("软件和信息服务业");
|
||||
example.setProvince("广东省");
|
||||
example.setComments("备注信息");
|
||||
templateList.add(example);
|
||||
|
||||
Workbook workbook = ExcelImportSupport.buildTemplate("竞争对手导入模板", "竞争对手", CreditCompetitorImportParam.class, templateList);
|
||||
|
||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
response.setHeader("Content-Disposition", "attachment; filename=credit_competitor_import_template.xlsx");
|
||||
|
||||
workbook.write(response.getOutputStream());
|
||||
workbook.close();
|
||||
}
|
||||
|
||||
private boolean isEmptyImportRow(CreditCompetitorImportParam param) {
|
||||
if (param == null) {
|
||||
return true;
|
||||
}
|
||||
return ImportHelper.isBlank(param.getCompanyName())
|
||||
&& ImportHelper.isBlank(param.getLegalRepresentative())
|
||||
&& ImportHelper.isBlank(param.getRegisteredCapital())
|
||||
&& ImportHelper.isBlank(param.getEstablishmentDate());
|
||||
}
|
||||
|
||||
private CreditCompetitor convertImportParamToEntity(CreditCompetitorImportParam param) {
|
||||
CreditCompetitor entity = new CreditCompetitor();
|
||||
|
||||
entity.setCompanyName(param.getCompanyName());
|
||||
entity.setLegalRepresentative(param.getLegalRepresentative());
|
||||
entity.setRegisteredCapital(ImportHelper.parseBigDecimal(param.getRegisteredCapital(), "注册资本"));
|
||||
entity.setEstablishmentDate(ImportHelper.parseLocalDate(param.getEstablishmentDate(), "成立日期"));
|
||||
entity.setRegistrationStatus(param.getRegistrationStatus());
|
||||
entity.setIndustry(param.getIndustry());
|
||||
entity.setProvince(param.getProvince());
|
||||
entity.setComments(param.getComments());
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user