Commit 32746a5e authored by hongguangwu's avatar hongguangwu

Merge remote-tracking branch 'origin/develop' into develop

parents bf1affd1 4196924b
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
package com.yifu.cloud.plus.v1.yifu.archives.entity; package com.yifu.cloud.plus.v1.yifu.archives.entity;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity; import com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity;
...@@ -99,4 +100,15 @@ public class FddPersonAccount extends BaseEntity { ...@@ -99,4 +100,15 @@ public class FddPersonAccount extends BaseEntity {
@Schema(description ="实名短信发送:0未发送 1已发送") @Schema(description ="实名短信发送:0未发送 1已发送")
private String realMessageFlag; private String realMessageFlag;
@Schema(description ="组织名称")
@TableField(exist = false)
private String companyName;
@Schema(description ="法大大印章ID")
@TableField(exist = false)
private String sealId;
@Schema(description ="印章名称")
@TableField(exist = false)
private String sealName;
} }
...@@ -69,35 +69,4 @@ public class FddReqLog extends BaseEntity { ...@@ -69,35 +69,4 @@ public class FddReqLog extends BaseEntity {
@Schema(description ="调用类名") @Schema(description ="调用类名")
private String className; private String className;
/**
* 创建者
*/
@Schema(description ="创建者")
private String createBy;
/**
* 更新人
*/
@Schema(description ="更新人")
private String updateBy;
/**
* 创建时间
*/
@Schema(description ="创建时间")
private LocalDateTime createTime;
/**
* 更新时间
*/
@Schema(description ="更新时间")
private LocalDateTime updateTime;
/**
* 创建人姓名
*/
@Schema(description ="创建人姓名")
private String createName;
} }
...@@ -81,35 +81,4 @@ public class FddSealInfo extends BaseEntity { ...@@ -81,35 +81,4 @@ public class FddSealInfo extends BaseEntity {
@Schema(description ="印章对应的公司id") @Schema(description ="印章对应的公司id")
private String sealCompanyId; private String sealCompanyId;
/**
* 创建者
*/
@Schema(description ="创建者")
private String createBy;
/**
* 更新人
*/
@Schema(description ="更新人")
private String updateBy;
/**
* 创建时间
*/
@Schema(description ="创建时间")
private LocalDateTime createTime;
/**
* 更新时间
*/
@Schema(description ="更新时间")
private LocalDateTime updateTime;
/**
* 创建人姓名
*/
@Schema(description ="创建人姓名")
private String createName;
} }
...@@ -14,6 +14,9 @@ import java.time.LocalDateTime; ...@@ -14,6 +14,9 @@ import java.time.LocalDateTime;
*/ */
@Data @Data
public class EmpBadRecordSearchVo extends TEmpBadRecord { public class EmpBadRecordSearchVo extends TEmpBadRecord {
/**
* 多选导出或删除等操作
*/
private String ids; private String ids;
/** /**
......
...@@ -123,6 +123,17 @@ public class FddSealInfoServiceImpl extends ServiceImpl<FddSealInfoMapper, FddSe ...@@ -123,6 +123,17 @@ public class FddSealInfoServiceImpl extends ServiceImpl<FddSealInfoMapper, FddSe
@Override @Override
public R<String> sealAuth(List<String> id, String fddPersonAccountId) throws ApiException { public R<String> sealAuth(List<String> id, String fddPersonAccountId) throws ApiException {
// //查询机构印章信息
// CompanySealListReq companySealListReq = new CompanySealListReq();
// companySealListReq.setToken(fddUtil.getToken());
// companySealListReq.setSealInfo(1);
// OwnerInfo owner1 = new OwnerInfo();
// owner1.setUnionId("6ecf01effd8647528255a72c9014ce08");
// companySealListReq.setOwner(owner1);
// SealClient sealClient1 = new SealClient(fddUtil.getFadadaApiClient());
// BaseRsp<CompanySealListRsp> rsp1 = sealClient1.companySealList(companySealListReq);
// CompanySealListRsp data1 = rsp1.getData();
for (String sId : id) { for (String sId : id) {
FddSealInfo entity = this.getById(sId); FddSealInfo entity = this.getById(sId);
if (entity == null) { if (entity == null) {
......
...@@ -53,7 +53,6 @@ import javax.servlet.http.HttpServletResponse; ...@@ -53,7 +53,6 @@ import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
......
...@@ -1196,8 +1196,10 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap ...@@ -1196,8 +1196,10 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap
list = gettEmpProInfoExportVos(idstr, projectDTO); list = gettEmpProInfoExportVos(idstr, projectDTO);
ServletOutputStream out = null; ServletOutputStream out = null;
if (list != null && !list.isEmpty()) {
list = new ArrayList<>();
}
try { try {
if (list.size() > 0) {
out = response.getOutputStream(); out = response.getOutputStream();
ExcelUtil<EmployeeProjectExportVO> util = new ExcelUtil<>(EmployeeProjectExportVO.class); ExcelUtil<EmployeeProjectExportVO> util = new ExcelUtil<>(EmployeeProjectExportVO.class);
for (EmployeeProjectExportVO vo : list) { for (EmployeeProjectExportVO vo : list) {
...@@ -1210,7 +1212,6 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap ...@@ -1210,7 +1212,6 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap
EasyExcel.write(out, EmployeeProjectExportVO.class).includeColumnFiledNames(includeColumnFiledNames).sheet("项目档案") EasyExcel.write(out, EmployeeProjectExportVO.class).includeColumnFiledNames(includeColumnFiledNames).sheet("项目档案")
.doWrite(list); .doWrite(list);
out.flush(); out.flush();
}
} catch (Exception e) { } catch (Exception e) {
log.error("执行异常", e); log.error("执行异常", e);
} finally { } finally {
......
...@@ -2,6 +2,7 @@ package com.yifu.cloud.plus.v1.yifu.common.core.util; ...@@ -2,6 +2,7 @@ package com.yifu.cloud.plus.v1.yifu.common.core.util;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants; import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -31,7 +32,25 @@ public class Common { ...@@ -31,7 +32,25 @@ public class Common {
public static boolean isEmpty(String str) { public static boolean isEmpty(String str) {
return null == str || "".equals(str.trim()) || "null".equals(str.trim()) || "undefinded".equals(str.trim()); return null == str || "".equals(str.trim()) || "null".equals(str.trim()) || "undefinded".equals(str.trim());
} }
/**
* 截取startStr和endStr中间的字符串(开区间)
*
* @param startStr 开始的标志
* @param endStr 结束标志
* @param src 源串
* @return 返回符合要求的字符串或者返回null
* @author: fxj
*/
public static String subByStr(String startStr, String endStr, String src) {
if (StringUtils.isNotBlank(src) && StringUtils.isNotBlank(startStr) && StringUtils.isNotBlank(endStr)) {
int start = src.indexOf(startStr);
int end = src.indexOf(endStr);
if (end > start && start > -1) {
return src.substring(start + 1, end);
}
}
return null;
}
/** /**
* 对象null * 对象null
* *
......
...@@ -94,7 +94,7 @@ public class SysHouseHoldInfoController { ...@@ -94,7 +94,7 @@ public class SysHouseHoldInfoController {
@PostMapping @PostMapping
@PreAuthorize("@pms.hasPermission('demo_syshouseholdinfo_add')" ) @PreAuthorize("@pms.hasPermission('demo_syshouseholdinfo_add')" )
public R save(@RequestBody SysHouseHoldInfo sysHouseHoldInfo) { public R save(@RequestBody SysHouseHoldInfo sysHouseHoldInfo) {
return R.ok(sysHouseHoldInfoService.saveInfo(sysHouseHoldInfo)); return sysHouseHoldInfoService.saveInfo(sysHouseHoldInfo);
} }
/** /**
......
...@@ -75,4 +75,9 @@ public class ColumnEntity { ...@@ -75,4 +75,9 @@ public class ColumnEntity {
*/ */
private Boolean hidden; private Boolean hidden;
/**
* 是否隐藏
*/
private String maxLength;
} }
...@@ -26,6 +26,7 @@ import com.yifu.cloud.plus.v1.yifu.codegen.entity.GenFormConf; ...@@ -26,6 +26,7 @@ import com.yifu.cloud.plus.v1.yifu.codegen.entity.GenFormConf;
import com.yifu.cloud.plus.v1.yifu.codegen.entity.TableEntity; import com.yifu.cloud.plus.v1.yifu.codegen.entity.TableEntity;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants; import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.exception.CheckedException; import com.yifu.cloud.plus.v1.yifu.common.core.exception.CheckedException;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import lombok.SneakyThrows; import lombok.SneakyThrows;
import lombok.experimental.UtilityClass; import lombok.experimental.UtilityClass;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -64,6 +65,10 @@ public class CodeGenKits { ...@@ -64,6 +65,10 @@ public class CodeGenKits {
private final String ENTITY_JAVA_VM = "Entity.java.vm"; private final String ENTITY_JAVA_VM = "Entity.java.vm";
private final String ENTITY_VO_JAVA_VM = "EntityVo.java.vm";
private final String ENTITY_SEARCH_VO_JAVA_VM = "EntitySearchVo.java.vm";
private final String MAPPER_JAVA_VM = "Mapper.java.vm"; private final String MAPPER_JAVA_VM = "Mapper.java.vm";
private final String SERVICE_JAVA_VM = "Service.java.vm"; private final String SERVICE_JAVA_VM = "Service.java.vm";
...@@ -93,6 +98,8 @@ public class CodeGenKits { ...@@ -93,6 +98,8 @@ public class CodeGenKits {
*/ */
private List<String> getTemplates(GenConfig config) { private List<String> getTemplates(GenConfig config) {
List<String> templates = new ArrayList<>(); List<String> templates = new ArrayList<>();
templates.add("template/EntityVo.java.vm");
templates.add("template/EntitySearchVo.java.vm");
templates.add("template/Entity.java.vm"); templates.add("template/Entity.java.vm");
templates.add("template/Mapper.java.vm"); templates.add("template/Mapper.java.vm");
templates.add("template/Mapper.xml.vm"); templates.add("template/Mapper.xml.vm");
...@@ -183,6 +190,9 @@ public class CodeGenKits { ...@@ -183,6 +190,9 @@ public class CodeGenKits {
String dataType = StrUtil.subBefore(columnEntity.getDataType(), "(", false); String dataType = StrUtil.subBefore(columnEntity.getDataType(), "(", false);
String attrType = config.getString(dataType, "unknowType"); String attrType = config.getString(dataType, "unknowType");
columnEntity.setAttrType(attrType); columnEntity.setAttrType(attrType);
if ("String".equals(attrType)) {
columnEntity.setMaxLength(Common.subByStr("(", ")", column.get("columnType")));
}
if (!hasBigDecimal && "BigDecimal".equals(attrType)) { if (!hasBigDecimal && "BigDecimal".equals(attrType)) {
hasBigDecimal = true; hasBigDecimal = true;
} }
...@@ -354,6 +364,14 @@ public class CodeGenKits { ...@@ -354,6 +364,14 @@ public class CodeGenKits {
return packagePath + "entity" + File.separator + className + ".java"; return packagePath + "entity" + File.separator + className + ".java";
} }
if (template.contains(ENTITY_VO_JAVA_VM)) {
return packagePath + "entity" + File.separator + className + "Vo.java";
}
if (template.contains(ENTITY_SEARCH_VO_JAVA_VM)) {
return packagePath + "entity" + File.separator + className + "SearchVo.java";
}
if (template.contains(MAPPER_JAVA_VM)) { if (template.contains(MAPPER_JAVA_VM)) {
return packagePath + "mapper" + File.separator + className + "Mapper.java"; return packagePath + "mapper" + File.separator + className + "Mapper.java";
} }
......
...@@ -68,7 +68,7 @@ public class ${className}Controller { ...@@ -68,7 +68,7 @@ public class ${className}Controller {
*/ */
@ApiOperation(value = "简单分页查询") @ApiOperation(value = "简单分页查询")
@GetMapping("/page") @GetMapping("/page")
public R<IPage<${className}>> get${className}Page(Page<${className}> page, ${className} ${classname}) { public R<IPage<${className}>> get${className}Page(Page<${className}> page, ${className}SearchVo ${classname}) {
return new R<>(${classname}Service.get${className}Page(page,${classname})); return new R<>(${classname}Service.get${className}Page(page,${classname}));
} }
/** /**
...@@ -79,7 +79,7 @@ public class ${className}Controller { ...@@ -79,7 +79,7 @@ public class ${className}Controller {
@Operation(summary = "不分页查询", description = "不分页查询") @Operation(summary = "不分页查询", description = "不分页查询")
@PostMapping("/noPage" ) @PostMapping("/noPage" )
//@PreAuthorize("@pms.hasPermission('${moduleName}_${pathName}_get')" ) //@PreAuthorize("@pms.hasPermission('${moduleName}_${pathName}_get')" )
public R<List<${className}>> get${className}NoPage(@RequestBody ${className} ${classname}) { public R<List<${className}>> get${className}NoPage(@RequestBody ${className}SearchVo ${classname}) {
return R.ok(${classname}Service.list(Wrappers.query(${classname}))); return R.ok(${classname}Service.list(Wrappers.query(${classname})));
} }
...@@ -134,4 +134,30 @@ public class ${className}Controller { ...@@ -134,4 +134,30 @@ public class ${className}Controller {
return R.ok(${classname}Service.removeById(${pk.lowerAttrName})); return R.ok(${classname}Service.removeById(${pk.lowerAttrName}));
} }
/**
* ${comments} 批量导入
*
* @author ${author}
* @date ${datetime}
**/
@SneakyThrows
@Operation(description = "批量新增${comments} hasPermission('${moduleName}_${pathName}-batch-import')")
@SysLog("批量新增${comments}")
@PostMapping("/importListAdd")
@PreAuthorize("@pms.hasPermission('${moduleName}_${pathName}-batch-import')")
public R<List<ErrorMessage>> importListAdd(@RequestBody MultipartFile file){
return ${classname}Service.importDiy(file.getInputStream());
}
/**
* ${comments} 批量导出
* @author ${author}
* @date ${datetime}
**/
@Operation(description = "导出${comments} hasPermission('${moduleName}_${pathName}-export')")
@PostMapping("/export")
@PreAuthorize("@pms.hasPermission('${moduleName}_${pathName}-export')")
public void export(HttpServletResponse response, @RequestBody ${className}SearchVo searchVo) {
${classname}Service.listExport(response,searchVo);
}
} }
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* this software without specific prior written permission. * this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com) * Author: lengleng (wangiegie@gmail.com)
*/ */
#set($excludeColumns = ["create_time","update_time","create_by","update_by"]) #*#set($excludeColumns = ["create_time","update_time","create_by","update_by"])*#
package ${package}.${moduleName}.entity; package ${package}.${moduleName}.entity;
import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.ExcelProperty;
...@@ -25,6 +25,9 @@ import com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity; ...@@ -25,6 +25,9 @@ import com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
#if(${hasBigDecimal}) #if(${hasBigDecimal})
import java.math.BigDecimal; import java.math.BigDecimal;
#end #end
...@@ -42,20 +45,29 @@ import java.math.BigDecimal; ...@@ -42,20 +45,29 @@ import java.math.BigDecimal;
public class ${className} extends BaseEntity { public class ${className} extends BaseEntity {
#foreach ($column in $columns) #foreach ($column in $columns)
## 排除部分字段 ## 排除部分字段
#if(!$excludeColumns.contains($column.columnName)) #if(!$excludeColumns.contains($column.columnName))
/** /**
* $column.comments * $column.comments
*/ */
#if($column.columnName == $pk.columnName) #if($column.columnName == $pk.columnName)
@TableId(type = IdType.ASSIGN_ID) @TableId(type = IdType.ASSIGN_ID)
#end #else
@ExcelAttribute(name = "$column.comments"#if($column.isNullable =='NO' && $column.attrType !='LocalDate' && $column.attrType !='LocalDateTime'), isNotEmpty = true,errorInfo = "$column.comments不能为空"#end #if($column.maxLength), maxLength = $column.maxLength #end) @ExcelAttribute(name = "$column.comments"#if($column.nullable), isNotEmpty = true,errorInfo = "$column.comments不能为空" #end #if($column.attrType =='LocalDate' || $column.attrType =='LocalDateTime') ,isDate = true #end #if($column.maxLength), maxLength = $column.maxLength #end)
@Schema(description ="$column.comments"#if($column.hidden),hidden=$column.hidden#end) #if($column.nullable)
@NotBlank(message = "$column.comments不能为空")
#end
#if($column.maxLength && $column.attrType =='String')
@Length(max=$column.maxLength,message = "$column.comments不能超过$column.maxLength个字符")
#end
#end
#end
@ExcelProperty("$column.comments") @ExcelProperty("$column.comments")
#if($column.attrType =='LocalDate' || $column.attrType =='LocalDateTime' || $column.attrType =='Date')
private Date $column.lowerAttrName;
#else
private $column.attrType $column.lowerAttrName; private $column.attrType $column.lowerAttrName;
#end
#end
#end #end
} }
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package ${package}.${moduleName}.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import ${package}.${moduleName}.entity.${className}
import lombok.Data;
/**
* ${comments}
*
* @author ${author}
* @date ${datetime}
*/
@Data
public class ${className}SearchVo extends ${className}{
/**
* 多选导出或删除等操作
*/
@Schema(description = "选中ID,多个逗号分割")
private String ids;
/**
* 创建时间区间 [开始时间,结束时间]
*/
@Schema(description = "创建时间区间")
private LocalDateTime[] createTimes;
/**
* @Author fxj
* 查询数据起
**/
@Schema(description = "查询limit 开始")
private int limitStart;
/**
* @Author fxj
* 查询数据止
**/
@Schema(description = "查询limit 数据条数")
private int limitEnd;
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
#set($excludeColumns = ["create_time","update_time","create_by","update_by"])
package ${package}.${moduleName}.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
#if(${hasBigDecimal})
import java.math.BigDecimal;
#end
/**
* ${comments}
*
* @author ${author}
* @date ${datetime}
*/
@Data
public class ${className}Vo extends RowIndex implements Serializable{
#foreach ($column in $columns)
## 排除部分字段
#if(!$excludeColumns.contains($column.columnName))
/**
* $column.comments
*/
#if($column.columnName == $pk.columnName)
@TableId(type = IdType.ASSIGN_ID)
#end
#end
#if($column.nullable)
@NotBlank(message = "$column.comments 不能为空")
#end
#if($column.maxLength && $column.attrType =='String')
@Length(max=$column.maxLength,message = "$column.comments 不能超过$column.maxLength 个字符")
#end
@ExcelAttribute(name = "$column.comments"#if($column.nullable), isNotEmpty = true,errorInfo = "$column.comments 不能为空" #end #if($column.attrType =='LocalDate' || $column.attrType =='LocalDateTime') ,isDate = true #end #if($column.maxLength), maxLength = $column.maxLength #end)
@Schema(description ="$column.comments"#if($column.hidden),hidden=$column.hidden#end)
@ExcelProperty("$column.comments")
#if($column.attrType =='LocalDate' || $column.attrType =='LocalDateTime' || $column.attrType =='Date')
private Date $column.lowerAttrName;
#else
private $column.attrType $column.lowerAttrName;
#end
#end
}
...@@ -32,5 +32,11 @@ public interface ${className}Service extends IService<${className}> { ...@@ -32,5 +32,11 @@ public interface ${className}Service extends IService<${className}> {
* @param ${classname} ${comments} * @param ${classname} ${comments}
* @return * @return
*/ */
IPage<${className}> get${className}Page(Page<${className}> page, ${className} ${classname}); IPage<${className}> get${className}Page(Page<${className}> page, ${className}SearchVo ${classname});
R<List<ErrorMessage>> importDiy(InputStream inputStream);
void listExport(HttpServletResponse response, ${className}SearchVo searchVo);
List<${className}> noPageDiy(${className}SearchVo searchVo)
} }
...@@ -36,7 +36,192 @@ public class ${className}ServiceImpl extends ServiceImpl<${className}Mapper, ${c ...@@ -36,7 +36,192 @@ public class ${className}ServiceImpl extends ServiceImpl<${className}Mapper, ${c
* @return * @return
*/ */
@Override @Override
public IPage<${className}> get${className}Page(Page<${className}> page, ${className} ${classname}){ public IPage<${className}> get${className}Page(Page<${className}> page, ${className}SearchVo ${classname}){
return baseMapper.get${className}Page(page,${classname}); return baseMapper.get${className}Page(page,${classname});
} }
/**
* ${comments}批量导入
*/
@Override
R<List<ErrorMessage>> importDiy(InputStream inputStream){
}
/**
* ${comments}批量导出
* @param ${classname} ${comments}
* @return
*/
@Override
void listExport(HttpServletResponse response, ${className}SearchVo searchVo){
String fileName = "不良记录批量导出" + DateUtil.getThisTime() + ".xlsx";
//获取要导出的列表
List<${className}> list = new ArrayList<>();
long count = noPageCountDiy(searchVo);
ServletOutputStream out = null;
try {
out = response.getOutputStream();
response.setContentType("multipart/form-data");
response.setCharacterEncoding("utf-8");
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName , "UTF-8"));
// 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭
//EasyExcel.write(out, TEmpBadRecord.class).sheet("不良记录").doWrite(list);
ExcelWriter excelWriter = EasyExcel.write(out, ${className}.class).build();
int index = 0;
if (count > CommonConstants.ZERO_INT){
for (int i = 0; i <= count; ) {
// 获取实际记录
searchVo.setLimitStart(i);
searchVo.setLimitEnd(CommonConstants.EXCEL_EXPORT_LIMIT);
list = noPageDiy(searchVo);
if (Common.isNotNull(list)){
ExcelUtil<${className}> util = new ExcelUtil<>(${className}.class);
for (${className} vo:list){
util.convertEntity(vo,null,null,null);
}
}
if (Common.isNotNull(list)){
WriteSheet writeSheet = EasyExcel.writerSheet(${comments}+index).build();
excelWriter.write(list,writeSheet);
index++;
}
i = i + CommonConstants.EXCEL_EXPORT_LIMIT;
if (Common.isNotNull(list)){
list.clear();
}
}
}else {
WriteSheet writeSheet = EasyExcel.writerSheet(${comments}+index).build();
excelWriter.write(list,writeSheet);
}
if (Common.isNotNull(list)){
list.clear();
}
out.flush();
excelWriter.finish();
}catch (Exception e){
log.error("执行异常" ,e);
}finally {
try {
if (null != out) {
out.close();
}
} catch (IOException e) {
log.error("执行异常", e);
}
}
}
@Override
public List<${className}> noPageDiy(${className}SearchVo searchVo) {
LambdaQueryWrapper<${className}> wrapper = buildQueryWrapper(searchVo);
List<String> idList = Common.getList(searchVo.getIds());
if (Common.isNotNull(idList)){
wrapper.in(TEmpBadRecord::getId,idList);
}
if (searchVo.getLimitStart() >= 0 && searchVo.getLimitEnd() > 0){
wrapper.last(" limit "+ searchVo.getLimitStart() +","+ searchVo.getLimitEnd());
}
wrapper.orderByDesc(BaseEntity::getCreateTime);
return baseMapper.selectList(wrapper);
}
private Long noPageCountDiy(${className}SearchVo searchVo) {
LambdaQueryWrapper<${className}> wrapper = buildQueryWrapper(searchVo);
List<String> idList = Common.getList(searchVo.getIds());
if (Common.isNotNull(idList)){
wrapper.in(${className}::getId,idList);
}
return baseMapper.selectCount(wrapper);
}
private LambdaQueryWrapper buildQueryWrapper(${className}SearchVo entity){
LambdaQueryWrapper<${className}> wrapper = Wrappers.lambdaQuery();
if (ArrayUtil.isNotEmpty(entity.getCreateTimes())) {
wrapper.ge(${className}::getCreateTime, entity.getCreateTimes()[0])
.le(${className}::getCreateTime,
entity.getCreateTimes()[1]);
}
if (Common.isNotNull(entity.getCreateName())){
wrapper.eq(${className}::getCreateName,entity.getCreateName());
}
return wrapper;
}
@Override
public R<List<ErrorMessage>> importDiy(InputStream inputStream) {
List<ErrorMessage> errorMessageList = new ArrayList<>();
ExcelUtil<${className}Vo> util1 = new ExcelUtil<>(${className}Vo.class);;
// 写法2
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
try {
EasyExcel.read(inputStream, ${className}Vo.class, new ReadListener<${className}Vo>() {
/**
* 单次缓存的数据量
*/
public static final int BATCH_COUNT = CommonConstants.BATCH_COUNT;
/**
*临时存储
*/
private List<${className}Vo> cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
@Override
public void invoke(${className}Vo data, AnalysisContext context) {
ReadRowHolder readRowHolder = context.readRowHolder();
Integer rowIndex = readRowHolder.getRowIndex();
data.setRowIndex(rowIndex+1);
ErrorMessage errorMessage = util1.checkEntity(data, data.getRowIndex());
if (Common.isNotNull(errorMessage)){
errorMessageList.add(errorMessage);
}else {
cachedDataList.add(data);
}
if (cachedDataList.size() >= BATCH_COUNT) {
saveData();
// 存储完成清理 list
cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
}
}
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
saveData();
}
/**
* 加上存储数据库
*/
private void saveData() {
log.info("{}条数据,开始存储数据库!", cachedDataList.size());
import${className}(cachedDataList,errorMessageList);
log.info("存储数据库成功!");
}
}).sheet().doRead();
}catch (Exception e){
log.error(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR,e);
return R.failed(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR);
}
return R.ok(errorMessageList);
}
private void import${className}(List<${className}Vo> excelVOList, List<ErrorMessage> errorMessageList) {
// 个性化校验逻辑
ErrorMessage errorMsg;
// 执行数据插入操作 组装
for (int i = 0; i < excelVOList.size(); i++) {
${className}Vo excel = excelVOList.get(i);
// 数据合法情况 TODO
// 插入
insertExcel(excel,emp);
errorMessageList.add(new ErrorMessage(excel.getRowIndex(),CommonConstants.SAVE_SUCCESS));
}
}
/**
* 插入excel bad record
*/
private void insertExcel(${className}Vo excel) {
${className} insert = new ${className}();
BeanUtil.copyProperties(excel, insert);
this.save(insert);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment