Commit 7d4eb2ad authored by lisong's avatar lisong

添加单位信息导出

parent b1505b3f
package com.yeejoin.amos.boot.module.elevator.api.dto;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.List;
/**
* @author ky
* @date 2023-07-28
*/
@Data
public class EnterpriseInfoExportDto {
@ExcelProperty(value = "统一社会信用代码", index = 1)
private String socialCreditCode;
@ExcelProperty(value = "单位名称", index = 0)
private String unitName;
@ExcelProperty(value = "所属区域", index = 2)
private String district;
@ExcelProperty(value = "地址", index = 3)
private String address;
@ExcelProperty(value = "法人", index = 4)
private String legalPerson;
@ExcelProperty(value = "电话", index = 5)
private String legalPersonPhone;
@ExcelProperty(value = "值班电话", index = 6)
private String dutyPhone;
@ExcelProperty(value = "主要负责人1", index = 7)
private String principalFirst;
@ExcelProperty(value = "主要负责人1手机号码", index = 8)
private String principalFirstPhone;
@ExcelProperty(value = "主要负责人2", index = 9)
private String principalSecond;
@ExcelProperty(value = "主要负责人2手机号码", index = 10)
private String principalSecondPhone;
}
......@@ -9,6 +9,8 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.List;
/**
* @author ky
* @date 2023-07-28
......@@ -27,7 +29,7 @@ public class EnterpriseInfo extends BaseEntity {
private String socialCreditCode;
@ApiModelProperty(value = "维护保养单位名称")
@TableField("supervise_org_name")
@TableField("use_unit")
private String unitName;
@ApiModelProperty(value = "省份")
......@@ -98,4 +100,6 @@ public class EnterpriseInfo extends BaseEntity {
@TableField("unit_type")
private String unitType;
@TableField(exist = false)
private List<String> ids;
}
......@@ -4,11 +4,9 @@ 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.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.biz.common.excel.ExcelUtil;
import com.yeejoin.amos.boot.biz.common.utils.NameUtils;
import com.yeejoin.amos.boot.module.elevator.api.dto.BaseEnterpriseInfoDto;
import com.yeejoin.amos.boot.module.elevator.api.dto.DutyPersonDto;
import com.yeejoin.amos.boot.module.elevator.api.dto.MaintenanceUnitDto;
import com.yeejoin.amos.boot.module.elevator.api.dto.MaintenanceUnitNameDto;
import com.yeejoin.amos.boot.module.elevator.api.dto.*;
import com.yeejoin.amos.boot.module.elevator.api.entity.Elevator;
import com.yeejoin.amos.boot.module.elevator.api.entity.EnterpriseInfo;
import com.yeejoin.amos.boot.module.elevator.api.entity.MaintenanceUnit;
......@@ -19,15 +17,13 @@ import com.yeejoin.amos.boot.module.elevator.biz.service.impl.ElevatorServiceImp
import com.yeejoin.amos.boot.module.elevator.biz.utils.BeanDtoVoUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
......@@ -35,6 +31,7 @@ import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
......@@ -289,6 +286,57 @@ public class MaintenanceUnitController extends BaseController {
return ResponseHelper.buildResponse(enterpriseInfoDtoIPage);
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/ocp/exportData/{unitType}")
@ApiOperation(httpMethod = "GET", value = "维保、使用单位列表导出", notes = "维保、使用单位列表导出")
public void exportData(HttpServletResponse response, @PathVariable(required = false) String unitType,
EnterpriseInfo enterpriseInfoDto) {
enterpriseInfoDto.setUnitType(unitType);
EnterpriseInfo enterpriseInfo = BeanDtoVoUtils.convert(enterpriseInfoDto, EnterpriseInfo.class);
QueryWrapper<EnterpriseInfo> enterpriseInfoQueryWrapper = new QueryWrapper<>();
Class<? extends EnterpriseInfo> aClass = enterpriseInfo.getClass();
Arrays.stream(aClass.getDeclaredFields()).forEach(field -> {
try {
field.setAccessible(true);
Object o = field.get(enterpriseInfo);
if (o != null) {
String name = NameUtils.camel2Underline(field.getName());
if ("city".equalsIgnoreCase(name) || "district".equalsIgnoreCase(name) || "qualification_level".equalsIgnoreCase(name)) {
String fileValue = (String) o;
enterpriseInfoQueryWrapper.eq(name, fileValue);
} else if ("credit_level".equalsIgnoreCase(name)) {
Integer fileValue = (Integer) o;
enterpriseInfoQueryWrapper.eq(name, fileValue);
} else if ("unit_type".equalsIgnoreCase(name)) {
// 1 维保单位,2 使用单位
String fileValue = (String) o;
if ("1".equals(fileValue)) {
// 此处由于写接口时表数据还未进行整理,所以此处先默认用文字做查询
enterpriseInfoQueryWrapper.like(name, "使用单位");
} else {
enterpriseInfoQueryWrapper.notLike(name, "使用单位");
}
} else {
String fileValue = (String) o;
enterpriseInfoQueryWrapper.like(name, fileValue);
}
}
} catch (Exception e) {
logger.error(e.getMessage());
}
});
if (!ObjectUtils.isEmpty(enterpriseInfoDto.getIds())){
enterpriseInfoQueryWrapper.lambda().in(EnterpriseInfo :: getSequenceNbr, enterpriseInfo.getIds());
}
ArrayList<EnterpriseInfoExportDto> list = new ArrayList<>();
List<EnterpriseInfo> enterpriseInfos = iEnterpriseInfoService.getBaseMapper().selectList(enterpriseInfoQueryWrapper);
enterpriseInfos.forEach(item ->{
EnterpriseInfoExportDto dto = new EnterpriseInfoExportDto();
BeanUtils.copyProperties(item, dto);
list.add(dto);
});
ExcelUtil.createTemplate(response, "单位信息", "单位信息", list, EnterpriseInfoExportDto.class, null, false);
}
/**
* 根据名称查询维保单位列表
*
......
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