feat: 新增导出历史数据
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package mjkf.xinke.main.controller;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.URLUtil;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.jgy.xxs.core.http.resp.HttpResponse;
|
||||
@@ -23,8 +25,13 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.io.Serializable;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.LocalDate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -52,6 +59,7 @@ public class PublicController {
|
||||
@ApiParam(value = "父id") @RequestParam(value="parent_id", required = false) String parentId
|
||||
) throws Exception {
|
||||
LambdaQueryWrapper<PricePublish> query = pricePublishService.getQuery(year, month, null, name, spec, PricePublishType.CURRENT);
|
||||
query.eq(PricePublish::getStatus, PricePublishStatus.DONE);
|
||||
query.isNotNull(PricePublish::getMaterialId); // 材料编号禁止为空
|
||||
if (keyword != null && ObjectUtil.isNotEmpty(keyword)) {
|
||||
query.and(e -> e
|
||||
@@ -93,9 +101,9 @@ public class PublicController {
|
||||
@Resource
|
||||
DevFileService devFileService;
|
||||
|
||||
@ApiOperation("历史文件")
|
||||
@GetMapping("/history-file")
|
||||
public HttpResponse historyFile () throws Exception {
|
||||
@ApiOperation("历史文件列表")
|
||||
@GetMapping("/history")
|
||||
public HttpResponse listHistoryFile () throws Exception {
|
||||
var query = new LambdaQueryWrapper<DevFile>();
|
||||
query.like(DevFile::getExtJson, "is_history_file");
|
||||
query.orderByDesc(DevFile::getName);
|
||||
@@ -103,6 +111,38 @@ public class PublicController {
|
||||
return FuHttpResponse.Builder().dataResponse(result.getRecords()).build();
|
||||
}
|
||||
|
||||
@Data
|
||||
class HistoryFileParam {
|
||||
@ApiModelProperty(value = "年")
|
||||
@NotEmpty(message="年不能为空")
|
||||
private String year;
|
||||
@ApiModelProperty(value = "月")
|
||||
@NotEmpty(message="月不能为空")
|
||||
private String month;
|
||||
}
|
||||
|
||||
@ApiOperation("历史文件")
|
||||
@GetMapping("/history/file")
|
||||
public void getHistoryFile (
|
||||
@Valid HistoryFileParam param,
|
||||
HttpServletResponse response
|
||||
) throws Exception {
|
||||
var query = new LambdaQueryWrapper<PricePublish>();
|
||||
query.eq(PricePublish::getYear, param.getYear());
|
||||
query.eq(PricePublish::getMonth, param.getMonth());
|
||||
query.eq(PricePublish::getType, PricePublishType.CURRENT);
|
||||
query.eq(PricePublish::getStatus, PricePublishStatus.DONE);
|
||||
query.orderByAsc(PricePublish::getMaterialId);
|
||||
var result = pricePublishService.list(query);
|
||||
result = result.stream().filter(i->ObjectUtil.isNotEmpty(i.getMaterialId())).collect(Collectors.toList());
|
||||
|
||||
String filename = URLUtil.encode("历史文件", StandardCharsets.UTF_8) + ".xlsx";
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.setHeader("Content-disposition", "attachment;filename=" + filename);
|
||||
response.setHeader("filename", filename);
|
||||
EasyExcel.write(response.getOutputStream(), PricePublish.class).sheet("sheet1").doWrite(result);
|
||||
}
|
||||
|
||||
@Data
|
||||
static public class PublicUpdateInfo implements Serializable {
|
||||
@ApiModelProperty("日期")
|
||||
|
@@ -1,5 +1,8 @@
|
||||
package mjkf.xinke.main.model.db;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnore;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
@@ -33,125 +36,159 @@ public class PricePublish extends Model<PricePublish> {
|
||||
|
||||
@ApiModelProperty("最后更新人id")
|
||||
@TableField("UPDATE_USER_ID")
|
||||
@ExcelIgnore
|
||||
private String updateUserId;
|
||||
|
||||
@ApiModelProperty("最后更新人名称")
|
||||
@TableField("UPDATE_USER_NAME")
|
||||
@ExcelIgnore
|
||||
private String updateUserName;
|
||||
|
||||
@ApiModelProperty("最后更新时间")
|
||||
@TableField("UPDATE_TIME")
|
||||
@ExcelIgnore
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
@ApiModelProperty("创建人id")
|
||||
@TableField("CREATE_USER_ID")
|
||||
@ExcelIgnore
|
||||
private String createUserId;
|
||||
|
||||
@ApiModelProperty("创建人名称")
|
||||
@TableField("CREATE_USER_NAME")
|
||||
@ExcelIgnore
|
||||
private String createUserName;
|
||||
|
||||
@ApiModelProperty("创建时间")
|
||||
@TableField("CREATE_TIME")
|
||||
@ExcelIgnore
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@ApiModelProperty("删除人id")
|
||||
@TableField("DELETE_USER_ID")
|
||||
@ExcelIgnore
|
||||
private String deleteUserId;
|
||||
|
||||
@ApiModelProperty("删除人名称")
|
||||
@TableField("DELETE_USER_NAME")
|
||||
@ExcelIgnore
|
||||
private String deleteUserName;
|
||||
|
||||
@ApiModelProperty("删除时间")
|
||||
@TableField("DELETE_TIME")
|
||||
@ExcelIgnore
|
||||
private LocalDateTime deleteTime;
|
||||
|
||||
@TableId(value = "ID", type = IdType.AUTO)
|
||||
@ExcelIgnore
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty("编号")
|
||||
@TableField("MATERIAL_ID")
|
||||
@ExcelProperty({"材料代码"})
|
||||
@ColumnWidth(15)
|
||||
private String materialId;
|
||||
|
||||
@ApiModelProperty("年份")
|
||||
@TableField("YEAR")
|
||||
@ExcelIgnore
|
||||
private Integer year;
|
||||
|
||||
@ApiModelProperty("月份")
|
||||
@TableField("MONTH")
|
||||
@ExcelIgnore
|
||||
private Integer month;
|
||||
|
||||
@ApiModelProperty("材料名称")
|
||||
@TableField("`NAME`")
|
||||
@ExcelProperty({"材料名称"})
|
||||
@ColumnWidth(20)
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("规格")
|
||||
@TableField("`SPEC`")
|
||||
@ExcelProperty({"规格"})
|
||||
@ColumnWidth(35)
|
||||
private String spec;
|
||||
|
||||
@ApiModelProperty("价格")
|
||||
@TableField("PRICE")
|
||||
@ExcelIgnore
|
||||
private BigDecimal price;
|
||||
|
||||
@ApiModelProperty("福州价格")
|
||||
@TableField("PRICE_FUZHOU")
|
||||
@ExcelProperty({"福州"})
|
||||
private BigDecimal priceFuzhou;
|
||||
|
||||
@ApiModelProperty("厦门价格")
|
||||
@TableField("PRICE_XIAMEN")
|
||||
@ExcelProperty({"厦门"})
|
||||
private BigDecimal priceXiamen;
|
||||
|
||||
@ApiModelProperty("莆田价格")
|
||||
@TableField("PRICE_PUTIAN")
|
||||
@ExcelProperty({"莆田"})
|
||||
private BigDecimal pricePutian;
|
||||
|
||||
@ApiModelProperty("三明价格")
|
||||
@TableField("PRICE_SANMING")
|
||||
@ExcelProperty({"三明"})
|
||||
private BigDecimal priceSanming;
|
||||
|
||||
@ApiModelProperty("泉州价格")
|
||||
@TableField("PRICE_QUANZHOU")
|
||||
@ExcelProperty({"泉州"})
|
||||
private BigDecimal priceQuanzhou;
|
||||
|
||||
@ApiModelProperty("漳州价格")
|
||||
@TableField("PRICE_ZHANGZHOU")
|
||||
@ExcelProperty({"漳州"})
|
||||
private BigDecimal priceZhangzhou;
|
||||
|
||||
@ApiModelProperty("南平价格")
|
||||
@TableField("PRICE_NANPIN")
|
||||
@ExcelProperty({"南平"})
|
||||
private BigDecimal priceNanpin;
|
||||
|
||||
@ApiModelProperty("龙岩价格")
|
||||
@TableField("PRICE_LONGYAN")
|
||||
@ExcelProperty({"龙岩"})
|
||||
private BigDecimal priceLongyan;
|
||||
|
||||
@ApiModelProperty("宁德价格")
|
||||
@TableField("PRICE_NINGDE")
|
||||
@ExcelProperty({"宁德"})
|
||||
private BigDecimal priceNingde;
|
||||
|
||||
@ApiModelProperty("平潭价格")
|
||||
@TableField("PRICE_PINTAN")
|
||||
@ExcelProperty({"平潭"})
|
||||
private BigDecimal pricePintan;
|
||||
|
||||
@ApiModelProperty("漳州开发区价格")
|
||||
@TableField("PRICE_ZHANGZHOUKFQ")
|
||||
@ExcelProperty({"漳州开发区"})
|
||||
private BigDecimal priceZhangzhouKfq;
|
||||
|
||||
@ApiModelProperty("税率")
|
||||
@TableField("TAX")
|
||||
@ExcelIgnore
|
||||
private BigDecimal tax;
|
||||
|
||||
@ApiModelProperty("状态")
|
||||
@TableField("STATUS")
|
||||
@ExcelIgnore
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty("类型")
|
||||
@TableField("TYPE")
|
||||
@ExcelIgnore
|
||||
private Integer type;
|
||||
|
||||
@ApiModelProperty("单位")
|
||||
@TableField("UNIT")
|
||||
@ExcelProperty(value={"单位"}, index=3)
|
||||
private String unit;
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user