|
@@ -13,7 +13,10 @@
|
|
|
package vip.xiaonuo.biz.modular.qyrecordinfo.controller;
|
|
|
|
|
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.util.URLUtil;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
@@ -22,6 +25,7 @@ import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
+import vip.xiaonuo.biz.modular.qyrecordinfo.entity.BusinessIdGenerator;
|
|
|
import vip.xiaonuo.common.annotation.CommonLog;
|
|
|
import vip.xiaonuo.common.pojo.CommonResult;
|
|
|
import vip.xiaonuo.biz.modular.qyrecordinfo.entity.QyRecordInfo;
|
|
@@ -34,10 +38,13 @@ import jakarta.servlet.http.HttpServletResponse;
|
|
|
import jakarta.annotation.Resource;
|
|
|
import jakarta.validation.Valid;
|
|
|
import jakarta.validation.constraints.NotEmpty;
|
|
|
+
|
|
|
import java.util.List;
|
|
|
import java.io.IOException;
|
|
|
+
|
|
|
import com.alibaba.excel.EasyExcel;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+
|
|
|
import java.net.URLEncoder;
|
|
|
import java.util.HashMap;
|
|
|
|
|
@@ -45,7 +52,7 @@ import java.util.HashMap;
|
|
|
* 企业备案信息控制器
|
|
|
*
|
|
|
* @author hgx
|
|
|
- * @date 2024/07/06 11:20
|
|
|
+ * @date 2024/07/06 11:20
|
|
|
*/
|
|
|
@Tag(name = "企业备案信息控制器")
|
|
|
@RestController
|
|
@@ -59,7 +66,7 @@ public class QyRecordInfoController {
|
|
|
* 获取企业备案信息分页
|
|
|
*
|
|
|
* @author hgx
|
|
|
- * @date 2024/07/06 11:20
|
|
|
+ * @date 2024/07/06 11:20
|
|
|
*/
|
|
|
@Operation(summary = "获取企业备案信息分页")
|
|
|
@SaCheckPermission("/biz/qyrecordinfo/page")
|
|
@@ -72,22 +79,45 @@ public class QyRecordInfoController {
|
|
|
* 添加企业备案信息
|
|
|
*
|
|
|
* @author hgx
|
|
|
- * @date 2024/07/06 11:20
|
|
|
+ * @date 2024/07/06 11:20
|
|
|
*/
|
|
|
@Operation(summary = "添加企业备案信息")
|
|
|
@CommonLog("添加企业备案信息")
|
|
|
@SaCheckPermission("/biz/qyrecordinfo/add")
|
|
|
@PostMapping("/biz/qyrecordinfo/add")
|
|
|
public CommonResult<String> add(@RequestBody @Valid QyRecordInfoAddParam qyRecordInfoAddParam) {
|
|
|
+ QyRecordInfoPageParam qyRecordInfoPageParam = BeanUtil.toBean(qyRecordInfoAddParam, QyRecordInfoPageParam.class);
|
|
|
+ IPage<QyRecordInfo> page = qyRecordInfoService.page(qyRecordInfoPageParam);
|
|
|
+ List<QyRecordInfo> records = page.getRecords();
|
|
|
+ String ylTzCode_;
|
|
|
+ String tzCode_;
|
|
|
+ if (CollectionUtil.isNotEmpty(records)) {
|
|
|
+ String ylTzCode = records.get(0).getYlTzCode();
|
|
|
+ String tzCode = records.get(0).getTzCode();
|
|
|
+ String ylCode = ylTzCode.substring(ylTzCode.length() - 5, ylTzCode.length());
|
|
|
+ String code = tzCode.substring(tzCode.length() - 3, tzCode.length());
|
|
|
+ int i = Integer.valueOf(ylCode);
|
|
|
+ i++;
|
|
|
+ ylTzCode_ = BusinessIdGenerator.generateBusinessId(i);
|
|
|
+ int j = Integer.valueOf(code);
|
|
|
+ j++;
|
|
|
+ tzCode_ = BusinessIdGenerator.generateCode(j);
|
|
|
+
|
|
|
+ } else {
|
|
|
+ ylTzCode_ = BusinessIdGenerator.generateBusinessId(0);
|
|
|
+ tzCode_ = BusinessIdGenerator.generateCode(0);
|
|
|
+ }
|
|
|
+ qyRecordInfoAddParam.setYlTzCode(ylTzCode_);
|
|
|
+ qyRecordInfoAddParam.setTzCode(tzCode_);
|
|
|
qyRecordInfoService.add(qyRecordInfoAddParam);
|
|
|
- return CommonResult.ok();
|
|
|
+ return CommonResult.ok(ylTzCode_);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 编辑企业备案信息
|
|
|
*
|
|
|
* @author hgx
|
|
|
- * @date 2024/07/06 11:20
|
|
|
+ * @date 2024/07/06 11:20
|
|
|
*/
|
|
|
@Operation(summary = "编辑企业备案信息")
|
|
|
@CommonLog("编辑企业备案信息")
|
|
@@ -102,59 +132,60 @@ public class QyRecordInfoController {
|
|
|
* 导出企业备案信息
|
|
|
*
|
|
|
* @author hgx
|
|
|
- * @date 2024/07/06 11:20
|
|
|
+ * @date 2024/07/06 11:20
|
|
|
*/
|
|
|
@Operation(summary = "导出企业备案信息")
|
|
|
@CommonLog("导出企业备案信息")
|
|
|
@SaCheckPermission("/biz/qyrecordinfo/export")
|
|
|
@PostMapping("/biz/qyrecordinfo/export")
|
|
|
public void export(@RequestBody @Valid QyRecordInfoPageParam qyRecordInfoPageParam, HttpServletResponse response) {
|
|
|
- Page<QyRecordInfo> page = qyRecordInfoService.page(qyRecordInfoPageParam);
|
|
|
+ Page<QyRecordInfo> page = qyRecordInfoService.page(qyRecordInfoPageParam);
|
|
|
List<QyRecordInfo> records = page.getRecords();
|
|
|
- exportExcel(response,QyRecordInfo.class,records,"企业备案信息");
|
|
|
+ exportExcel(response, QyRecordInfo.class, records, "企业备案信息");
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 导出表格数据
|
|
|
- * @param cl 表格字段实体类
|
|
|
- * @param data 查询数据
|
|
|
- * @param sheetName 表格名称
|
|
|
+ *
|
|
|
+ * @param cl 表格字段实体类
|
|
|
+ * @param data 查询数据
|
|
|
+ * @param sheetName 表格名称
|
|
|
*/
|
|
|
- public void exportExcel(HttpServletResponse response, Class cl, List data, String sheetName){
|
|
|
- HashMap<String, String> map = new HashMap<>();
|
|
|
- try {
|
|
|
- response.setHeader("Content-disposition", "attachment;filename=" + URLUtil.encode(sheetName) + ".xlsx");
|
|
|
- response.setHeader("Access-Control-Allow-Origin", "*");
|
|
|
- response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
|
|
|
- response.setContentType("application/octet-stream;charset=UTF-8");
|
|
|
- EasyExcel.write(response.getOutputStream(), cl).autoCloseStream(Boolean.FALSE).sheet(sheetName).doWrite(data);
|
|
|
- } catch (IOException e) {
|
|
|
- response.reset();
|
|
|
- response.setContentType("application/json");
|
|
|
- response.setCharacterEncoding("utf-8");
|
|
|
- map.put("status", "failure");
|
|
|
- map.put("message", "下载文件失败" + e.getMessage());
|
|
|
- try {
|
|
|
- response.getWriter().println(JSON.toJSONString(map));
|
|
|
- } catch (IOException ex) {
|
|
|
- ex.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
+ public void exportExcel(HttpServletResponse response, Class cl, List data, String sheetName) {
|
|
|
+ HashMap<String, String> map = new HashMap<>();
|
|
|
+ try {
|
|
|
+ response.setHeader("Content-disposition", "attachment;filename=" + URLUtil.encode(sheetName) + ".xlsx");
|
|
|
+ response.setHeader("Access-Control-Allow-Origin", "*");
|
|
|
+ response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
|
|
|
+ response.setContentType("application/octet-stream;charset=UTF-8");
|
|
|
+ EasyExcel.write(response.getOutputStream(), cl).autoCloseStream(Boolean.FALSE).sheet(sheetName).doWrite(data);
|
|
|
+ } catch (IOException e) {
|
|
|
+ response.reset();
|
|
|
+ response.setContentType("application/json");
|
|
|
+ response.setCharacterEncoding("utf-8");
|
|
|
+ map.put("status", "failure");
|
|
|
+ map.put("message", "下载文件失败" + e.getMessage());
|
|
|
+ try {
|
|
|
+ response.getWriter().println(JSON.toJSONString(map));
|
|
|
+ } catch (IOException ex) {
|
|
|
+ ex.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 删除企业备案信息
|
|
|
*
|
|
|
* @author hgx
|
|
|
- * @date 2024/07/06 11:20
|
|
|
+ * @date 2024/07/06 11:20
|
|
|
*/
|
|
|
@Operation(summary = "删除企业备案信息")
|
|
|
@CommonLog("删除企业备案信息")
|
|
|
@SaCheckPermission("/biz/qyrecordinfo/delete")
|
|
|
@PostMapping("/biz/qyrecordinfo/delete")
|
|
|
public CommonResult<String> delete(@RequestBody @Valid @NotEmpty(message = "集合不能为空")
|
|
|
- List<QyRecordInfoIdParam> qyRecordInfoIdParamList) {
|
|
|
+ List<QyRecordInfoIdParam> qyRecordInfoIdParamList) {
|
|
|
qyRecordInfoService.delete(qyRecordInfoIdParamList);
|
|
|
return CommonResult.ok();
|
|
|
}
|
|
@@ -163,7 +194,7 @@ public class QyRecordInfoController {
|
|
|
* 获取企业备案信息详情
|
|
|
*
|
|
|
* @author hgx
|
|
|
- * @date 2024/07/06 11:20
|
|
|
+ * @date 2024/07/06 11:20
|
|
|
*/
|
|
|
@Operation(summary = "获取企业备案信息详情")
|
|
|
@SaCheckPermission("/biz/qyrecordinfo/detail")
|