静态台账文档上载功能,列表导出代码

main
liuyiliang 12 months ago
parent 501946be53
commit d7f3a56d16
  1. 35
      src/main/java/org/energy/modules/leger/controller/EquipmentLedgerController.java
  2. 41
      src/main/java/org/energy/modules/leger/excel/EquipmentLedgerExcel.java
  3. 6
      src/main/java/org/energy/modules/leger/mapper/EquipmentLedgerMapper.java
  4. 5
      src/main/java/org/energy/modules/leger/mapper/EquipmentLedgerMapper.xml
  5. 12
      src/main/java/org/energy/modules/leger/service/IEquipmentLedgerService.java
  6. 10
      src/main/java/org/energy/modules/leger/service/impl/EquipmentLedgerServiceImpl.java
  7. 5
      src/main/java/org/energy/modules/system/controller/FileController.java
  8. 5
      src/main/java/org/energy/modules/system/service/impl/FileServiceImpl.java
  9. 2
      src/main/java/org/energy/modules/system/util/EnumFileInfoType.java
  10. 2
      src/main/resources/application.yml

@ -15,17 +15,28 @@
*/
package org.energy.modules.leger.controller;
import com.alibaba.excel.EasyExcel;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dayu.daf.core.log.annotation.ApiLog;
import com.dayu.daf.core.secure.DafUser;
import com.dayu.daf.core.tool.constant.DafConstant;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import lombok.AllArgsConstructor;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import com.dayu.daf.core.mp.support.Condition;
import com.dayu.daf.core.mp.support.Query;
import com.dayu.daf.core.tool.api.R;
import com.dayu.daf.core.tool.utils.Func;
import lombok.SneakyThrows;
import org.apache.commons.codec.Charsets;
import org.energy.modules.leger.excel.EquipmentLedgerExcel;
import org.energy.modules.system.excel.UserExcel;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestParam;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -33,6 +44,11 @@ import org.energy.modules.leger.entity.EquipmentLedger;
import org.energy.modules.leger.vo.EquipmentLedgerVO;
import org.energy.modules.leger.service.IEquipmentLedgerService;
import com.dayu.daf.core.boot.ctrl.DafController;
import springfox.documentation.annotations.ApiIgnore;
import java.net.URLEncoder;
import java.util.List;
import java.util.Map;
/**
* 设备台账编码一览 控制器
@ -123,5 +139,24 @@ public class EquipmentLedgerController extends DafController {
return R.status(equipmentLedgerService.deleteLogic(Func.toLongList(ids)));
}
/**
* 导出
*/
@SneakyThrows
@GetMapping("export")
@ApiOperationSupport(order = 13)
@ApiOperation(value = "导出", notes = "传入")
@ApiLog
public void exportUser(@ApiIgnore @RequestParam Map<String, Object> entity, HttpServletResponse response) {
QueryWrapper<EquipmentLedger> queryWrapper = Condition.getQueryWrapper(entity, EquipmentLedger.class);
queryWrapper.lambda().eq(EquipmentLedger::getIsDeleted, DafConstant.DB_NOT_DELETED);
List<EquipmentLedgerExcel> list = equipmentLedgerService.export(queryWrapper);
response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding(Charsets.UTF_8.name());
String fileName = URLEncoder.encode("数据导出", Charsets.UTF_8.name());
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
EasyExcel.write(response.getOutputStream(), EquipmentLedgerExcel.class).sheet("数据表").doWrite(list);
}
}

@ -0,0 +1,41 @@
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.energy.modules.leger.excel;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
import lombok.Data;
import java.io.Serializable;
/**
* EquipmentLedge model export
* @author edwong
*/
@Data
@ColumnWidth(25)
@HeadRowHeight(20)
@ContentRowHeight(18)
public class EquipmentLedgerExcel implements Serializable {
private static final long serialVersionUID = 1L;
@ColumnWidth(15)
@ExcelProperty("eqLedgerCode")
private String eqLedgerCode;
}

@ -1,9 +1,13 @@
package org.energy.modules.leger.mapper;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import org.apache.ibatis.annotations.Param;
import org.energy.modules.leger.entity.EquipmentLedger;
import org.energy.modules.leger.vo.EquipmentLedgerVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.energy.modules.leger.excel.EquipmentLedgerExcel;
import java.util.List;
/**
@ -23,4 +27,6 @@ public interface EquipmentLedgerMapper extends BaseMapper<EquipmentLedger> {
*/
List<EquipmentLedgerVO> selectEquipmentLedgerPage(IPage page, EquipmentLedgerVO equipmentLedger);
List<EquipmentLedgerExcel> exportData(@Param("ew") Wrapper<EquipmentLedger> queryWrapper);
}

@ -56,4 +56,9 @@
select * from l_equipment_ledger where is_deleted = 0
</select>
<select id="exportData" resultType="org.energy.modules.leger.excel.EquipmentLedgerExcel">
SELECT eq_ledger_code
FROM l_equipment_ledger ${ew.customSqlSegment}
</select>
</mapper>

@ -1,9 +1,13 @@
package org.energy.modules.leger.service;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import org.energy.modules.leger.entity.EquipmentLedger;
import org.energy.modules.leger.vo.EquipmentLedgerVO;
import com.dayu.daf.core.mp.base.BaseService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.energy.modules.leger.excel.EquipmentLedgerExcel;
import java.util.List;
/**
* 设备台账编码一览 服务类
@ -22,4 +26,12 @@ public interface IEquipmentLedgerService extends BaseService<EquipmentLedger> {
*/
IPage<EquipmentLedgerVO> selectEquipmentLedgerPage(IPage<EquipmentLedgerVO> page, EquipmentLedgerVO equipmentLedger);
/**
* 获取导出数据
*
* @param queryWrapper
* @return
*/
List<EquipmentLedgerExcel> export(Wrapper<EquipmentLedger> queryWrapper);
}

@ -1,13 +1,17 @@
package org.energy.modules.leger.service.impl;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import org.energy.modules.leger.entity.EquipmentLedger;
import org.energy.modules.leger.vo.EquipmentLedgerVO;
import org.energy.modules.leger.mapper.EquipmentLedgerMapper;
import org.energy.modules.leger.service.IEquipmentLedgerService;
import com.dayu.daf.core.mp.base.BaseServiceImpl;
import org.energy.modules.leger.excel.EquipmentLedgerExcel;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import java.util.List;
/**
* 设备台账编码一览 服务实现类
*
@ -22,4 +26,10 @@ public class EquipmentLedgerServiceImpl extends BaseServiceImpl<EquipmentLedgerM
return page.setRecords(baseMapper.selectEquipmentLedgerPage(page, equipmentLedger));
}
@Override
public List<EquipmentLedgerExcel> export(Wrapper<EquipmentLedger> queryWrapper) {
List<EquipmentLedgerExcel> list = baseMapper.exportData(queryWrapper);
return list;
}
}

@ -53,7 +53,6 @@ public class FileController {
*/
@ApiOperation("附件上载")
@PostMapping(value = "/upload")
@ResponseBody
public R upload(@RequestPart("file") MultipartFile picture,
@RequestParam("fileType") String fileType) {
Map<String, Object> resultMap = new HashMap<>();
@ -69,7 +68,7 @@ public class FileController {
String fileSavePath = dataConfig.getUploadPath();
fileSavePath = fileSavePath + EnumFileInfoType.getKeyDesc(fileType) + "/" + DateTimeUtils.getFormatDate(new Date(), DateTimeUtils.YEAR_MONTH_DATE_FORMAT) + "/";
String filePath = "/data/file/actual/" + EnumFileInfoType.getKeyDesc(fileType) + "/" + DateTimeUtils.getFormatDate(new Date(), DateTimeUtils.YEAR_MONTH_DATE_FORMAT) + "/";
String filePath = "/data/actual/" + EnumFileInfoType.getKeyDesc(fileType) + "/" + DateTimeUtils.getFormatDate(new Date(), DateTimeUtils.YEAR_MONTH_DATE_FORMAT) + "/";
if (!new File(fileSavePath).exists()) {
new File(fileSavePath).mkdirs();
}
@ -81,7 +80,7 @@ public class FileController {
log.error(e.getMessage(), e);
throw new ServiceException("上传图片出错");
}
return R.data(JSON.toJSONString(resultMap));
return R.data(resultMap);
}
}

@ -32,11 +32,14 @@ public class FileServiceImpl extends BaseServiceImpl<FileMapper, File> implement
file.setFilePath(filePath);
file.setFileName(fileName);
file.setFileSuffix(fileSuffix);
file.setFileOldName(oldFileName);
boolean saveFlag = super.save(file);
Map<String, Object> map = new HashMap<>();
if (saveFlag) {
map.put("id", file.getId());
map.put("filePath", file.getFilePath() + file.getFileName() + file.getFileSuffix());
map.put("url", "./api/system/file/download?fileName=" + fileName);
map.put("fileName", fileName);
map.put("name", oldFileName);
return map;
}
return null;

@ -5,7 +5,7 @@ package org.energy.modules.system.util;
*/
public enum EnumFileInfoType {
STATIC_LEDGER_DOCUMENT_INVENTORY("0", "STATIC_LEDGER_DOCUMENT_INVENTORY", "静态台账文档清册"),
STATIC_LEDGER_DOCUMENT_INVENTORY("1", "ST_LD_DOC_INV", "静态台账文档清册"),
;
private String key;

@ -141,4 +141,4 @@ daf:
tables:
- sys_notice
file:
upload_path: c:\\data\\actual #文件上传目录(不配置的话为java.io.tmpdir目录)
upload_path: c:\\data\\actual\\ #文件上传目录(不配置的话为java.io.tmpdir目录)

Loading…
Cancel
Save