Commit a6cfb4b8 by HlQ

[add]

1.项目资料文件导出
2.新增合同列表接口
[fix] 合同更新bug修改
1 parent 8112bb65
......@@ -59,6 +59,12 @@ public class ContractController {
return contractService.listPart(dto);
}
@GetMapping("/contractMain")
@SaCheckPermission(value = "contract:listMain", orRole = "admin")
public Page<ContractVO> listMain(ContractDTO dto) {
return contractService.listByMain(dto);
}
@GetMapping("/contract/{id}")
@SaCheckPermission(value = "contract:query", orRole = "admin")
public ContractVO getById(@PathVariable Long id) {
......@@ -73,7 +79,7 @@ public class ContractController {
@PostMapping("/contract/{id}")
@SaCheckPermission(value = "contract:edit", orRole = "admin")
public String updateById(@PathVariable Long id, @RequestBody ContractDTO dto) {
public String updateById(@PathVariable Long id, ContractDTO dto) {
return contractService.updateById(id, null, dto);
}
......
......@@ -5,6 +5,7 @@ import cn.dev33.satoken.stp.StpUtil;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.github.linpeilie.Converter;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.dromara.hutool.core.array.ArrayUtil;
......@@ -239,4 +240,11 @@ public class StoreController {
Assert.notEmpty(userIdStr, "未选择提醒人");
return storeService.fileNotify(storeName, contractNo, sourceName, fileNameArr, userIdStr) ? "钉钉提醒成功" : "钉钉提醒失败";
}
@PostMapping("/store/file/export")
@SaCheckPermission(value = "store:file:export", orRole = "admin")
public void storeFileExport(StoreDTO data, @RequestBody(required = false) List<OrderItem> orderItemList,
HttpServletResponse response) {
storeService.storeFileExport(data, orderItemList, response);
}
}
......@@ -340,7 +340,7 @@ public class ContractRunner {
var jsonR = JSONUtil.ofObj()
.set("sortMap", JSONUtil.ofObj()
.set("field", "updateTime")
.set("order", "desc"))
.set("sort", "desc"))
.set("conditions", JSONUtil.ofArray()
.put(JSONUtil.ofObj()
.set("attr", "date_3")
......
......@@ -25,6 +25,8 @@ public interface IContractService extends MPJBaseService<Contract> {
Page<ContractVO> listPart(ContractDTO dto);
Page<ContractVO> listByMain(ContractDTO dto);
ContractVO getVOById(Long id);
ContractVO getByNo(@PathVariable String no);
......
......@@ -3,6 +3,7 @@ package vion.service;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.base.MPJBaseService;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.RequestParam;
import vion.dto.StatusDTO;
import vion.dto.StoreDTO;
......@@ -38,4 +39,8 @@ public interface IStoreService extends MPJBaseService<Store> {
Boolean fileNotify(String storeName, String contractNo, String sourceName, String[] fileNameArr, String[] userIdStr);
void storeFileExport(StoreDTO data, List<OrderItem> orderItemList, HttpServletResponse response);
}
......@@ -5,9 +5,13 @@ import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.toolkit.Db;
import com.github.liaochong.myexcel.core.DefaultExcelBuilder;
import com.github.liaochong.myexcel.core.watermark.Watermark;
import com.github.liaochong.myexcel.utils.WatermarkUtil;
import com.github.yulichang.base.MPJBaseServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import io.github.linpeilie.Converter;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.dromara.hutool.core.array.ArrayUtil;
......@@ -39,13 +43,16 @@ import vion.mapper.TaskMapper;
import vion.model.*;
import vion.service.*;
import vion.third.DingMod;
import vion.utils.excel.AttachmentExportUtil;
import vion.vo.ContractVO;
import vion.vo.StoreVO;
import vion.vo.TagVO;
import vion.vo.UserVO;
import java.awt.*;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
......@@ -541,6 +548,79 @@ public class StoreServiceImpl extends MPJBaseServiceImpl<StoreMapper, Store> imp
return StrUtil.containsIgnoreCase(pushRes, "ok");
}
@Override
public void storeFileExport(StoreDTO data, List<OrderItem> orderItemList, HttpServletResponse response) {
UserVO user = (UserVO) StpUtil.getTokenSession().get("curLoginUser");
Page<StoreVO> voPage = this.getStoreList(data, orderItemList);
try (DefaultExcelBuilder<Map> defaultExcelBuilder = DefaultExcelBuilder.of(Map.class)) {
var records = voPage.getRecords();
var storeIds = records.stream().map(StoreVO::getId).toList();
var titles = List.of("项目", "合同编号",
"前期勘察", "点位表",
"竣工图纸", "验收报告",
"项目总结", "巡检报告",
"结算资料", "其它");
var files = fileService.lambdaQuery()
.in(FileInfo::getSourceId, storeIds)
.in(FileInfo::getStoreId, storeIds)
.in(FileInfo::getSourceType, 1, 24, 25, 26, 27, 28, 29, 30)
.list();
var contractId2NoMap = Opt.ofEmptyAble(files)
.map(f -> f.stream().map(FileInfo::getContractId).toList())
.map(contractService::listByIds)
.filter(CollUtil::isNotEmpty)
.map(contractList -> contractList.stream().collect(Collectors.toMap(Contract::getId, Contract::getContractNo)))
.orElse(Map.of());
// storeId -> <contractId -> <sourceType -> cnt>>
var storeId2CntMap = Opt.ofEmptyAble(files)
.map(fs -> fs.stream().collect(Collectors.groupingBy(FileInfo::getStoreId,
Collectors.groupingBy(f -> Opt.ofNullable(f.getContractId()).orElse(-1L),
Collectors.groupingBy(FileInfo::getSourceType,
Collectors.counting())))))
.orElse(Map.of());
List<Map> dataList = new ArrayList<>();
storeId2CntMap.forEach((storeId, contractMap) -> {
var store = records.stream().filter(v -> v.getId().equals(storeId)).findFirst().orElse(null);
if (ObjUtil.isNull(store)) {
return;
}
contractMap.forEach((contractId, typeCntMap) -> {
var map = MapUtil.<String, Object>builder("a", store.getName())
.put("b", contractId2NoMap.getOrDefault(contractId, "暂无"))
.put("c", typeCntMap.getOrDefault(28, 0L))
.put("d", typeCntMap.getOrDefault(26, 0L))
.put("e", typeCntMap.getOrDefault(25, 0L))
.put("f", typeCntMap.getOrDefault(24, 0L))
.put("g", typeCntMap.getOrDefault(27, 0L))
.put("h", typeCntMap.getOrDefault(29, 0L))
.put("i", typeCntMap.getOrDefault(30, 0L))
.put("j", typeCntMap.getOrDefault(1, 0L))
.build();
dataList.add(map);
});
});
var workbook = defaultExcelBuilder.sheetName("项目资料")
.titles(titles)
.widths(10, 20)
.fieldDisplayOrder(List.of("a", "b", "c", "d", "e", "f", "g", "h", "i", "j"))
.build(dataList);
// 水印添加指定字体,并在服务器上安装 SimSun 字体,解决中文字体变成方块的问题
Watermark watermark = new Watermark();
watermark.setText(user.getUsername() + "-" + user.getPhone());
watermark.setFont(new Font("SimSun", Font.PLAIN, 16));
WatermarkUtil.addWatermark(workbook, watermark);
AttachmentExportUtil.export(workbook, StrUtil.format("项目资料_{}", DateUtil.formatDateTime(new Date())),
response);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
JSONObject buildMsg(String storeName, String userid) {
var jsonObj = JSONUtil.ofObj()
.set("agent_id", 2358374016L)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!