Browse Source

新增证书导出接口

zhongwei
ty 11 months ago
parent
commit
992a21ec14
  1. 6
      hzims-service-api/basic-api/pom.xml
  2. 7
      hzims-service-api/basic-api/src/main/java/com/hnac/hzims/basic/entity/CertificatetNoticeEntity.java
  3. 122
      hzims-service-api/basic-api/src/main/java/com/hnac/hzims/basic/vo/PersonManagemetExportVo.java
  4. 22
      hzims-service/hzims-basic/src/main/java/com/hnac/hzims/basic/controller/CertificatetNoticeController.java
  5. 58
      hzims-service/hzims-basic/src/main/java/com/hnac/hzims/basic/controller/PresonManagementController.java
  6. 6
      hzims-service/hzims-basic/src/main/java/com/hnac/hzims/basic/mapper/PersonManagemetMapper.java
  7. 41
      hzims-service/hzims-basic/src/main/java/com/hnac/hzims/basic/mapper/PersonManagemetMapper.xml
  8. 5
      hzims-service/hzims-basic/src/main/java/com/hnac/hzims/basic/service/IImsPresonManagementService.java
  9. 19
      hzims-service/hzims-basic/src/main/java/com/hnac/hzims/basic/service/impl/PresonManagementServiceImpl.java
  10. 41
      hzims-service/hzims-basic/src/main/java/com/hnac/hzims/basic/utils/CertificatetType.java

6
hzims-service-api/basic-api/pom.xml

@ -7,6 +7,12 @@
<groupId>com.hnac.hzims</groupId> <groupId>com.hnac.hzims</groupId>
<version>4.0.0-SNAPSHOT</version> <version>4.0.0-SNAPSHOT</version>
</parent> </parent>
<dependencies>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
</dependency>
</dependencies>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>basic-api</artifactId> <artifactId>basic-api</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>

7
hzims-service-api/basic-api/src/main/java/com/hnac/hzims/basic/entity/CertificatetNoticeEntity.java

@ -1,6 +1,7 @@
package com.hnac.hzims.basic.entity; package com.hnac.hzims.basic.entity;
import com.baomidou.mybatisplus.annotation.SqlCondition; import com.baomidou.mybatisplus.annotation.SqlCondition;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
@ -41,4 +42,10 @@ public class CertificatetNoticeEntity extends TenantEntity {
@ApiModelProperty(value = "通知用户") @ApiModelProperty(value = "通知用户")
@QueryField(condition = SqlCondition.LIKE) @QueryField(condition = SqlCondition.LIKE)
private String noticeUsers; private String noticeUsers;
/**
* 通知用户
*/
@TableField(exist = false)
@ApiModelProperty(value = "通知用户")
private String noticeUserNames;
} }

122
hzims-service-api/basic-api/src/main/java/com/hnac/hzims/basic/vo/PersonManagemetExportVo.java

@ -0,0 +1,122 @@
package com.hnac.hzims.basic.vo;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
* 实体类
* @author Chill
*/
@Data
@ApiModel(value = "档案管理导出类",description = "档案管理导出类")
public class PersonManagemetExportVo{
private static final long serialVersionUID = 1L;
@ExcelIgnore()
@ColumnWidth(value = 20)
@ApiModelProperty(value = "用户ID")
private String userId;
/**
* 单位名称
*/
@ExcelProperty(value = "单位名称", index = 0)
@ColumnWidth(value = 20)
@ApiModelProperty(value = "单位名称")
private String unitName;
/**
* 用户名称
*/
@ExcelProperty(value = "用户名称", index = 1)
@ColumnWidth(value = 20)
@ApiModelProperty(value = "用户名称")
private String name;
/**
* 性别
*/
@ExcelProperty(value = "性别", index = 2)
@ColumnWidth(value = 20)
@ApiModelProperty(value = "性别")
private String sex;
/**
* 职位
*/
@ExcelProperty(value = "职位", index = 3)
@ColumnWidth(value = 20)
@ApiModelProperty(value = "职位")
private String job;
/**
* 职称
*/
@ExcelProperty(value = "职称", index = 4)
@ColumnWidth(value = 20)
@ApiModelProperty(value = "职称")
private String academicTitle;
/**
* 电话号码
*/
@ExcelProperty(value = "电话号码", index = 5)
@ColumnWidth(value = 20)
@ApiModelProperty(value = "电话号码")
private String phone;
/**
* 档案类型
*/
@ExcelProperty(value = "档案类型", index = 6)
@ColumnWidth(value = 20)
@ApiModelProperty(value = "档案类型")
private String type;
/**
* 到期时间
*/
@ExcelProperty(value = "到期时间", index = 7)
@ColumnWidth(value = 20)
@DateTimeFormat(
pattern = "yyyy-MM-dd HH:mm:ss"
)
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss"
)
@ApiModelProperty(value = "到期时间")
private Date deadTime;
/**
* 创建时间
*/
@ExcelProperty(value = "创建时间", index = 8)
@ColumnWidth(value = 20)
@DateTimeFormat(
pattern = "yyyy-MM-dd HH:mm:ss"
)
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss"
)
@ApiModelProperty(value = "创建时间")
private Date createTime;
/**
* 是否过期
*/
@ExcelProperty(value = "是否过期", index = 9)
@ColumnWidth(value = 20)
@ApiModelProperty(value = "是否过期")
private String isDead;
}

22
hzims-service/hzims-basic/src/main/java/com/hnac/hzims/basic/controller/CertificatetNoticeController.java

@ -1,5 +1,6 @@
package com.hnac.hzims.basic.controller; package com.hnac.hzims.basic.controller;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.basic.entity.CertificatetNoticeEntity; import com.hnac.hzims.basic.entity.CertificatetNoticeEntity;
@ -10,8 +11,14 @@ import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.system.user.cache.UserCache;
import org.springblade.system.user.entity.User;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
/** /**
* 控制器 * 控制器
@ -46,7 +53,7 @@ public class CertificatetNoticeController extends BladeController {
/** /**
* 新增或修改 * 新增或修改
*/ */
@PostMapping("/getCertificatetNotice") @GetMapping("/getCertificatetNotice")
@ApiOperationSupport(order = 1) @ApiOperationSupport(order = 1)
@ApiOperation(value = "增加", notes = "传入imsDutyClass") @ApiOperation(value = "增加", notes = "传入imsDutyClass")
public R getCertificatetNotice() { public R getCertificatetNotice() {
@ -54,10 +61,21 @@ public class CertificatetNoticeController extends BladeController {
.eq(CertificatetNoticeEntity::getIsDeleted, 0) .eq(CertificatetNoticeEntity::getIsDeleted, 0)
.last("limit 1;")); .last("limit 1;"));
if (ObjectUtil.isNotEmpty(res)) { if (ObjectUtil.isNotEmpty(res)) {
if (StringUtils.isNotBlank(res.getNoticeUsers())) {
String noticeUsers = res.getNoticeUsers();
List<String> list = Arrays.asList(noticeUsers.split(","));
String names = list.stream().map(s -> {
if (ObjectUtil.isNotEmpty(UserCache.getUser(Long.valueOf(s)))) {
return UserCache.getUser(Long.valueOf(s));
}else {
return new User();
}
}).filter(s->ObjectUtil.isNotEmpty(s)).map(User::getName).collect(Collectors.joining(","));
res.setNoticeUserNames(names);
}
return R.data(res); return R.data(res);
} }
return R.data(""); return R.data("");
} }
} }

58
hzims-service/hzims-basic/src/main/java/com/hnac/hzims/basic/controller/PresonManagementController.java

@ -1,31 +1,30 @@
package com.hnac.hzims.basic.controller; package com.hnac.hzims.basic.controller;
import com.alibaba.spring.util.BeanUtils; import com.alibaba.druid.support.json.JSONUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.alibaba.excel.EasyExcel;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.basic.entity.PersonManagemetEntity;
import com.hnac.hzims.basic.service.IImsPresonManagementService; import com.hnac.hzims.basic.service.IImsPresonManagementService;
import com.hnac.hzims.basic.vo.PersonManagemetExportVo;
import com.hnac.hzims.basic.vo.PersonManagemetVo; import com.hnac.hzims.basic.vo.PersonManagemetVo;
import com.hnac.hzims.common.logs.annotation.OperationAnnotation; import com.hnac.hzims.common.logs.annotation.OperationAnnotation;
import com.hnac.hzims.common.logs.enums.BusinessType; import com.hnac.hzims.common.logs.enums.BusinessType;
import com.hnac.hzims.common.logs.enums.OperatorType; import com.hnac.hzims.common.logs.enums.OperatorType;
import com.hnac.hzims.operational.duty.entity.ImsDutyClassEntity;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.Condition; import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.support.Query; import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.validation.Valid; import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
@ -79,5 +78,44 @@ public class PresonManagementController extends BladeController {
return R.fail("删除失败"); return R.fail("删除失败");
} }
/**
* 分页 代码自定义代号
*/
@GetMapping("/exportPersonManagemetVo")
@ApiOperationSupport(order = 2)
@ApiOperation(value = "分页", notes = "传入imsDutyClass")
@OperationAnnotation(moduleName = "档案管理",title = "档案管理",operatorType = OperatorType.MOBILE,businessType =
BusinessType.GENCODE,action
= "档案管理")
public void exportPersonManagemetVo(HttpServletResponse response,PersonManagemetVo personManagemetVo) {
try {
response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding("UTF-8");
// 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系
String fileName = URLEncoder.encode("档案管理报表", "UTF-8");
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
List<PersonManagemetExportVo> list=iImsPresonManagementService.exportPersonManagemet(personManagemetVo);
if(list!=null && list.size()>0){
System.out.println("---------------- size = " + list.size());
// 这里需要设置不关闭流
EasyExcel.write(response.getOutputStream(), PersonManagemetExportVo.class).autoCloseStream(Boolean.FALSE).sheet("档案管理报表")
.doWrite(list);
}
} catch (Exception e) {
System.out.println("exportExcel = " + e.toString());
// 重置response
response.reset();
response.setContentType("application/json");
response.setCharacterEncoding("utf-8");
Map<String, String> map = new HashMap<>();
map.put("isSuccess", "false");
map.put("msg", "档案管理报表导出失败" + e.getMessage());
try {
response.getWriter().println(JSONUtils.toJSONString(map));
} catch (IOException e3) {
throw new ServiceException( "发生异常 :" + e.toString());
}
}
}
} }

6
hzims-service/hzims-basic/src/main/java/com/hnac/hzims/basic/mapper/PersonManagemetMapper.java

@ -2,6 +2,7 @@ package com.hnac.hzims.basic.mapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hnac.hzims.basic.entity.PersonManagemetEntity; import com.hnac.hzims.basic.entity.PersonManagemetEntity;
import com.hnac.hzims.basic.vo.PersonManagemetExportVo;
import com.hnac.hzims.basic.vo.PersonManagemetVo; import com.hnac.hzims.basic.vo.PersonManagemetVo;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -27,4 +28,9 @@ public interface PersonManagemetMapper extends UserDataScopeBaseMapper<PersonMan
@Param(value = "name")String name, @Param(value = "unitName")String unitName, @Param(value = "sex")String sex, @Param(value = "job")String job, @Param(value = "name")String name, @Param(value = "unitName")String unitName, @Param(value = "sex")String sex, @Param(value = "job")String job,
@Param(value = "academicTitle")String academicTitle, @Param(value = "status")Integer status, @Param(value = "current")Integer current, @Param(value = "size")Integer size) ; @Param(value = "academicTitle")String academicTitle, @Param(value = "status")Integer status, @Param(value = "current")Integer current, @Param(value = "size")Integer size) ;
List<PersonManagemetExportVo> exportPersonManagemet(
@Param(value = "type")String type, @Param(value = "deadStartTime") Date deadStartTime, @Param(value = "deadTime")Date deadTime,
@Param(value = "name")String name, @Param(value = "unitName")String unitName, @Param(value = "sex")String sex, @Param(value = "job")String job,
@Param(value = "academicTitle")String academicTitle, @Param(value = "status")Integer status) ;
} }

41
hzims-service/hzims-basic/src/main/java/com/hnac/hzims/basic/mapper/PersonManagemetMapper.xml

@ -58,6 +58,7 @@
<if test="academicTitle != null and academicTitle != ''"> <if test="academicTitle != null and academicTitle != ''">
and a.academic_title like CONCAT('%',#{academic_title},'%') and a.academic_title like CONCAT('%',#{academic_title},'%')
</if> </if>
ORDER BY a.CREATE_TIME,BCREATE_TIME DESC
LIMIT #{current}, #{size} LIMIT #{current}, #{size}
</select> </select>
<!--嵌套查询--> <!--嵌套查询-->
@ -95,5 +96,45 @@
and b.status =#{status} and b.status =#{status}
</if> </if>
</select> </select>
<select id="exportPersonManagemet" resultType="com.hnac.hzims.basic.vo.PersonManagemetExportVo">
select a.id as userId,a.name,a.unit_name as unitName, a.job ,a.academic_title,a.phone,
b.type,b.dead_time as deadTime,b.pic,b.CREATE_TIME as createTime,
case when a.sex=1 then "女" else "男" end as sex,
case when b.dead_time is null then null
when b.dead_time &lt; NOW() then "过期" else "未过期" end as isDead
from hzims_person_managemet as a
left join hzims_certificatet as b
on a.id=b.person_id and b.is_deleted = 0
where a.is_deleted = 0
<if test="type != null and type != ''">
and b.type = #{type}
</if>
<if test="deadStartTime != null and type != ''">
and b.dead_time &gt;= #{deadStartTime}
</if>
<if test="deadTime != null and type != ''">
and b.dead_time &lt;= #{deadTime}
</if>
<if test="name != null and name != ''">
and a.name like CONCAT('%',#{name},'%')
</if>
<if test="unitName != null and unitName != ''">
and a.unit_name like CONCAT('%',#{unitName},'%')
</if>
<if test="sex != null and sex != ''">
and a.sex = #{sex}
</if>
<if test="job != null and job != ''">
and a.job like CONCAT('%',#{job},'%')
</if>
<if test="academicTitle != null and academicTitle != ''">
and a.academic_title like CONCAT('%',#{academic_title},'%')
</if>
<if test="status != null and status != ''">
and b.status =#{status}
</if>
ORDER BY unitName,userId,b.type,createTime DESC
</select>
</mapper> </mapper>

5
hzims-service/hzims-basic/src/main/java/com/hnac/hzims/basic/service/IImsPresonManagementService.java

@ -3,10 +3,13 @@ package com.hnac.hzims.basic.service;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.hnac.hzims.basic.entity.PersonManagemetEntity; import com.hnac.hzims.basic.entity.PersonManagemetEntity;
import com.hnac.hzims.basic.vo.PersonManagemetExportVo;
import com.hnac.hzims.basic.vo.PersonManagemetVo; import com.hnac.hzims.basic.vo.PersonManagemetVo;
import org.springblade.core.mp.support.Query; import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import java.util.List;
/** /**
* 服务类 * 服务类
* *
@ -19,4 +22,6 @@ public interface IImsPresonManagementService extends IService<PersonManagemetEnt
R submit(PersonManagemetVo personManagemetVo) throws IllegalAccessException; R submit(PersonManagemetVo personManagemetVo) throws IllegalAccessException;
Boolean removeByPersonManagemetVo(PersonManagemetVo personManagemetVo); Boolean removeByPersonManagemetVo(PersonManagemetVo personManagemetVo);
List<PersonManagemetExportVo> exportPersonManagemet(PersonManagemetVo personManagemetVo);
} }

19
hzims-service/hzims-basic/src/main/java/com/hnac/hzims/basic/service/impl/PresonManagementServiceImpl.java

@ -9,6 +9,8 @@ import com.hnac.hzims.basic.entity.PersonManagemetEntity;
import com.hnac.hzims.basic.mapper.PersonManagemetMapper; import com.hnac.hzims.basic.mapper.PersonManagemetMapper;
import com.hnac.hzims.basic.service.IImsCertificatetService; import com.hnac.hzims.basic.service.IImsCertificatetService;
import com.hnac.hzims.basic.service.IImsPresonManagementService; import com.hnac.hzims.basic.service.IImsPresonManagementService;
import com.hnac.hzims.basic.utils.CertificatetType;
import com.hnac.hzims.basic.vo.PersonManagemetExportVo;
import com.hnac.hzims.basic.vo.PersonManagemetVo; import com.hnac.hzims.basic.vo.PersonManagemetVo;
import com.hnac.hzims.common.logs.utils.StringUtils; import com.hnac.hzims.common.logs.utils.StringUtils;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@ -131,5 +133,22 @@ public class PresonManagementServiceImpl extends BaseServiceImpl<PersonManagemet
} }
} }
@Override
public List<PersonManagemetExportVo> exportPersonManagemet(PersonManagemetVo personManagemetVo) {
List<PersonManagemetExportVo> list = baseMapper.exportPersonManagemet(personManagemetVo.getType(), personManagemetVo.getDeadStartTime(), personManagemetVo.getDeadTime(),
personManagemetVo.getName(), personManagemetVo.getUnitName(), personManagemetVo.getSex(), personManagemetVo.getJob(),
personManagemetVo.getAcademicTitle(), personManagemetVo.getStatus());
list = list.stream().map(s -> {
CertificatetType[] types = CertificatetType.values();
for (int i = 0; i < types.length; i++) {
if (types[i].getValue().equals(s.getType())) {
s.setType(types[i].getKey());
}
}
return s;
}).collect(Collectors.toList());
return list;
}
} }

41
hzims-service/hzims-basic/src/main/java/com/hnac/hzims/basic/utils/CertificatetType.java

@ -0,0 +1,41 @@
package com.hnac.hzims.basic.utils;
import lombok.Getter;
/**
* 证书类型
* @author ty
*/
public enum CertificatetType
{
/**
* 电工证
*/
Electrician("1","电工证"),
/**
* 安全员证
*/
Safety("2","安全员证"),
/**
* 登高证
*/
Climbe("3","登高证"),
/**
* 桥机证
*/
Bridge("4","桥机证");
@Getter
private String value;
@Getter
private String key;
CertificatetType(String value, String key){
this.key = key;
this.value = value;
}
}
Loading…
Cancel
Save