update
parent
4907cde8a1
commit
42fbbb6da5
|
@ -3,16 +3,29 @@ package com.wsnet.cargo.controller;
|
|||
import com.wsnet.cargo.entity.HelpDoc;
|
||||
import com.wsnet.cargo.service.HelpDocService;
|
||||
import com.wsnet.core.annotation.Menu;
|
||||
import com.wsnet.core.response.ResultData;
|
||||
import com.wsnet.web.controller.BaseController;
|
||||
import com.wsnet.web.query.BaseQuery;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/help")
|
||||
@Menu(code = "0307", name = "帮助文档")
|
||||
@Tag(name = "帮助文档")
|
||||
public class HelpController extends BaseController<HelpDocService, HelpDoc, BaseQuery> {
|
||||
|
||||
@PostMapping({"/list"})
|
||||
@Operation(summary = "列表", operationId = "09")
|
||||
protected ResultData<List<HelpDoc>> list() {
|
||||
BaseQuery query = new BaseQuery();
|
||||
query.setFields("id, serial, name");
|
||||
List<HelpDoc> list = baseService.list(HelpDoc.class, query);
|
||||
return ResultData.success(list.stream().sorted().collect(Collectors.toList()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,8 +18,10 @@ import com.wsnet.cargo.query.ManifestDetailQuery;
|
|||
import com.wsnet.cargo.query.ManifestQuery;
|
||||
import com.wsnet.cargo.service.BusManifestService;
|
||||
import com.wsnet.cargo.service.BusSubscribeService;
|
||||
import com.wsnet.cargo.service.CargoService;
|
||||
import com.wsnet.cargo.service.DictBrandService;
|
||||
import com.wsnet.core.annotation.Menu;
|
||||
import com.wsnet.core.dto.DictDTO;
|
||||
import com.wsnet.core.enums.StatusEnums;
|
||||
import com.wsnet.core.holder.UserContext;
|
||||
import com.wsnet.core.response.ResultData;
|
||||
|
@ -60,7 +62,7 @@ public class ManifestController extends BaseController<BusManifestService, BusMa
|
|||
private DictBrandService brandService;
|
||||
|
||||
@Resource
|
||||
private BusSubscribeService subscribeService;
|
||||
private CargoService cargoService;
|
||||
|
||||
/**
|
||||
* 我发布的
|
||||
|
@ -268,6 +270,12 @@ public class ManifestController extends BaseController<BusManifestService, BusMa
|
|||
WriteSheet writeDetailSheet = EasyExcel.writerSheet(1, "舱单明细").head(ManifestDetailImportExcel.class).build();
|
||||
|
||||
// 查询数据
|
||||
CargoApiUser user = (CargoApiUser) UserContext.getUser();
|
||||
// 订阅的码头ID
|
||||
List<Long> collect = cargoService.getWharfIdList(user.getEnterpriseId(), user.getWharfId());
|
||||
query.setSubSchedule("1");
|
||||
query.setSubLoadWharfIds(collect);
|
||||
query.setSubWharfId(user.getWharfId());
|
||||
Page<BusManifest> page = baseService.page(BusManifest.class, query);
|
||||
|
||||
write(page.getRecords(), excelWriter, writeSheet, writeDetailSheet);
|
||||
|
@ -313,24 +321,47 @@ public class ManifestController extends BaseController<BusManifestService, BusMa
|
|||
|
||||
}
|
||||
|
||||
@Operation(summary = "我订阅的舱单列表", operationId = "14")
|
||||
@Operation(summary = "我订阅的舱单列表(分页)", operationId = "14", description = "可以传入船期ID:scheduleId, 和舱层deck")
|
||||
@PostMapping("/subscribe/page")
|
||||
public ResultData<Page<BusManifest>> subscribePage(@RequestBody ManifestQuery query) {
|
||||
CargoApiUser user = (CargoApiUser) UserContext.getUser();
|
||||
List<BusSubscribe> subscribes = subscribeService.lambdaQuery().eq(BusSubscribe::getEnterpriseId, user.getEnterpriseId())
|
||||
.eq(BusSubscribe::getSubStatus, SubscribeStatusEnums.SUBSCRIBE)
|
||||
.eq(user.getWharfId() != null, BusSubscribe::getWharfId, user.getWharfId()).list();
|
||||
if (CollectionUtils.isEmpty(subscribes)) {
|
||||
return ResultData.success(new Page<>());
|
||||
}
|
||||
// 订阅的码头ID
|
||||
List<Long> collect = subscribes.stream().map(s -> s.getSubWharfId()).collect(Collectors.toList());
|
||||
List<Long> collect = cargoService.getWharfIdList(user.getEnterpriseId(), user.getWharfId());
|
||||
query.setSubSchedule("1");
|
||||
query.setSubLoadWharfIds(collect);
|
||||
query.setSubWharfId(user.getWharfId());
|
||||
query.setFields("*+schedule@ship@name+schedule@voyage+brand@name");
|
||||
return super.page(query);
|
||||
}
|
||||
|
||||
@Operation(summary = "我订阅的舱单列表(非分页)", operationId = "15")
|
||||
@PostMapping("/subscribe/list")
|
||||
public ResultData<List<BusManifest>> subscribeList(@RequestParam("scheduleId") Long scheduleId, @RequestParam(required = false, name = "desk") Integer deck) {
|
||||
ManifestQuery query = new ManifestQuery();
|
||||
query.setScheduleId(scheduleId);
|
||||
query.setDeck(deck);
|
||||
query.setFields("*+schedule@ship@name+schedule@voyage+brand@name");
|
||||
return ResultData.success(baseService.list(BusManifest.class, query));
|
||||
}
|
||||
|
||||
@Operation(summary = "舱单明细可选择提单号列表", operationId = "16", description = "id为舱单ID")
|
||||
@PostMapping("/subscribe/bill_no/list")
|
||||
public ResultData<List<DictDTO>> billNoList(@RequestParam("scheduleId") Long scheduleId, @RequestParam(name = "q", required = false) String q) {
|
||||
ManifestQuery query = new ManifestQuery();
|
||||
query.setScheduleId(scheduleId);
|
||||
List<BusManifest> list = baseService.list(BusManifest.class, query);
|
||||
List<DictDTO> rst = list.stream().map(s -> {
|
||||
DictDTO dto = new DictDTO();
|
||||
dto.setId(s.getId() + "");
|
||||
dto.setText(s.getBillNo());
|
||||
return dto;
|
||||
}).collect(Collectors.toList());
|
||||
if (StringUtils.isNotEmpty(q)) {
|
||||
rst = rst.stream().filter(s -> s.getText().contains(q)).collect(Collectors.toList());
|
||||
}
|
||||
return ResultData.success(rst);
|
||||
}
|
||||
|
||||
/*
|
||||
@Operation(summary = "舱单导入", operationId = "11")
|
||||
@GetMapping("/tmp/export")
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.wsnet.cargo.controller;
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.excel.ExcelWriter;
|
||||
import com.alibaba.excel.write.metadata.WriteSheet;
|
||||
|
@ -9,6 +11,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
import com.wsnet.cargo.controller.mapper.PoMapper;
|
||||
import com.wsnet.cargo.entity.*;
|
||||
import com.wsnet.cargo.excel.ManifestDetailImportExcel;
|
||||
import com.wsnet.cargo.excel.ManifestImportExcel;
|
||||
import com.wsnet.cargo.query.ManifestDetailQuery;
|
||||
import com.wsnet.cargo.query.ManifestQuery;
|
||||
import com.wsnet.cargo.service.BusManifestDetailService;
|
||||
|
@ -17,7 +20,9 @@ import com.wsnet.cargo.service.DictVehicleTypeDetailService;
|
|||
import com.wsnet.cargo.service.DictVehicleTypeService;
|
||||
import com.wsnet.core.annotation.Menu;
|
||||
import com.wsnet.core.enums.StatusEnums;
|
||||
import com.wsnet.core.holder.UserContext;
|
||||
import com.wsnet.core.response.ResultData;
|
||||
import com.wsnet.dto.CargoApiUser;
|
||||
import com.wsnet.excel.handler.Cascade;
|
||||
import com.wsnet.excel.handler.CascadeGroup;
|
||||
import com.wsnet.excel.handler.CustomCellWriteHandler;
|
||||
|
@ -272,4 +277,73 @@ public class ManifestDetailController extends BaseController<BusManifestDetailSe
|
|||
|
||||
return ResultData.success("success");
|
||||
}
|
||||
|
||||
@Operation(summary = "舱单明细列表", operationId = "13", description = "必须传入舱单ID,可以传入提单号")
|
||||
@RequestMapping("/list")
|
||||
public ResultData<List<BusManifestDetail>> list(@RequestBody ManifestDetailQuery query) {
|
||||
|
||||
return ResultData.success(baseService.list(BusManifestDetail.class, query));
|
||||
}
|
||||
|
||||
@Operation(summary = "舱单明细导出", operationId = "14")
|
||||
@GetMapping("/export")
|
||||
public void exportExcel(ManifestDetailQuery query, HttpServletResponse response) {
|
||||
query.setPage(1);
|
||||
query.setRows(500);
|
||||
query.setFields("*+manifest@billNo+vehicleType@name+vehicleTypeDetail@name");
|
||||
|
||||
ExcelWriter excelWriter = null;
|
||||
OutputStream out = null;
|
||||
try {
|
||||
out = response.getOutputStream();
|
||||
|
||||
// 这里注意 有同学反应使用swagger 会导致各种问题,请直接用浏览器或者用postman
|
||||
response.setContentType("application/vnd.ms-excel");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
// 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系
|
||||
String fileName = URLEncoder.encode(DateUtil.format(new Date(), DatePattern.PURE_DATE_PATTERN) + "舱单明细", "UTF-8");
|
||||
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
|
||||
|
||||
excelWriter = EasyExcel.write(out).build();
|
||||
|
||||
WriteSheet writeDetailSheet = EasyExcel.writerSheet(0, "舱单明细").head(ManifestDetailImportExcel.class).build();
|
||||
|
||||
// 查询数据
|
||||
Page<BusManifestDetail> page = baseService.page(BusManifestDetail.class, query);
|
||||
|
||||
write(page.getRecords(), excelWriter, writeDetailSheet);
|
||||
|
||||
for (int i = 2; i <= page.getPages(); i++) {
|
||||
query.setPage(i);
|
||||
page = baseService.page(BusManifestDetail.class, query);
|
||||
|
||||
write(page.getRecords(), excelWriter, writeDetailSheet);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (excelWriter != null) {
|
||||
excelWriter.finish();
|
||||
}
|
||||
if (out != null) {
|
||||
try {
|
||||
out.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void write(List<BusManifestDetail> headers, ExcelWriter excelWriter, WriteSheet writeDetailSheet) {
|
||||
if (CollectionUtils.isEmpty(headers)) {
|
||||
return;
|
||||
}
|
||||
List<ManifestDetailImportExcel> details = headers.stream().map(item -> PoMapper.instance.manifestDetailEntityToExcel(item)).collect(Collectors.toList());
|
||||
|
||||
if (CollectionUtils.isNotEmpty(details)) {
|
||||
excelWriter.write(details, writeDetailSheet);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,11 +11,11 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
import com.wsnet.cargo.controller.mapper.PoMapper;
|
||||
import com.wsnet.cargo.entity.*;
|
||||
import com.wsnet.cargo.enums.ShipStatusEnums;
|
||||
import com.wsnet.cargo.enums.SubscribeStatusEnums;
|
||||
import com.wsnet.cargo.enums.TradeTypeEnums;
|
||||
import com.wsnet.cargo.excel.SailScheduleImportExcel;
|
||||
import com.wsnet.cargo.query.SailScheduleQuery;
|
||||
import com.wsnet.cargo.service.*;
|
||||
import com.wsnet.core.annotation.Guest;
|
||||
import com.wsnet.core.annotation.Menu;
|
||||
import com.wsnet.core.dto.DictDTO;
|
||||
import com.wsnet.core.enums.StatusEnums;
|
||||
|
@ -72,10 +72,10 @@ public class SailScheduleController extends BaseController<BusSailScheduleServic
|
|||
private DictWharfService wharfService;
|
||||
|
||||
@Resource
|
||||
private BusSubscribeService subscribeService;
|
||||
private BusSailScheduleHistoryService sailScheduleHistoryService;
|
||||
|
||||
@Resource
|
||||
private BusSailScheduleHistoryService sailScheduleHistoryService;
|
||||
private CargoService cargoService;
|
||||
|
||||
/**
|
||||
* 查看我发布的
|
||||
|
@ -83,6 +83,7 @@ public class SailScheduleController extends BaseController<BusSailScheduleServic
|
|||
* @param query
|
||||
* @return
|
||||
*/
|
||||
@Guest
|
||||
@Override
|
||||
public ResultData<Page<BusSailSchedule>> page(@RequestBody SailScheduleQuery query) {
|
||||
CargoApiUser user = (CargoApiUser) UserContext.getUser();
|
||||
|
@ -454,11 +455,11 @@ public class SailScheduleController extends BaseController<BusSailScheduleServic
|
|||
|
||||
@Operation(summary = "船期导出", operationId = "13")
|
||||
@GetMapping("/export")
|
||||
public void exportExcel(SailScheduleQuery query, HttpServletResponse response) throws IOException {
|
||||
query.setFields("*+enterprise@name+ship@name+route@name+loadWharf@name+dischargeWharf@name+loadPort@name+dischargePort@name");
|
||||
List<BusSailSchedule> list = baseService.list(BusSailSchedule.class, query);
|
||||
public void exportExcel(HttpServletResponse response) throws IOException {
|
||||
CargoApiUser user = (CargoApiUser) UserContext.getUser();
|
||||
List<BusSailSchedule> sailScheduleList = cargoService.getSailScheduleList(user.getEnterpriseId(), user.getWharfId(), 10);
|
||||
|
||||
List<SailScheduleImportExcel> collect = list.stream().map(s -> PoMapper.instance.sailScheduleEntityToExcel(s)).collect(Collectors.toList());
|
||||
List<SailScheduleImportExcel> collect = sailScheduleList.stream().map(s -> PoMapper.instance.sailScheduleEntityToExcel(s)).collect(Collectors.toList());
|
||||
|
||||
ExcelUtils.export(response, DateUtil.format(new Date(), DatePattern.PURE_DATE_PATTERN) + "船期", "船期", collect, SailScheduleImportExcel.class);
|
||||
}
|
||||
|
@ -468,17 +469,14 @@ public class SailScheduleController extends BaseController<BusSailScheduleServic
|
|||
public ResultData<Page<BusSailSchedule>> subPage(@RequestBody SailScheduleQuery query) {
|
||||
// 我订阅的码头
|
||||
CargoApiUser user = (CargoApiUser) UserContext.getUser();
|
||||
List<BusSubscribe> subscribes = subscribeService.lambdaQuery().eq(BusSubscribe::getEnterpriseId, user.getEnterpriseId())
|
||||
.eq(BusSubscribe::getSubStatus, SubscribeStatusEnums.SUBSCRIBE)
|
||||
.eq(user.getWharfId() != null, BusSubscribe::getWharfId, user.getWharfId()).list();
|
||||
if (CollectionUtils.isEmpty(subscribes)) {
|
||||
// 订阅的码头ID
|
||||
List<Long> collect = cargoService.getWharfIdList(user.getEnterpriseId(), user.getWharfId());
|
||||
if (CollectionUtils.isEmpty(collect)) {
|
||||
return ResultData.success(new Page<>());
|
||||
}
|
||||
// 订阅的码头ID
|
||||
List<Long> collect = subscribes.stream().map(s -> s.getSubWharfId()).collect(Collectors.toList());
|
||||
query.setDischargeWharfId(user.getWharfId());
|
||||
query.setSubWharfIdIds(collect);
|
||||
query.setCreateDate(DateUtils.addDays(new Date(), -11));
|
||||
query.setCreateDate(DateUtils.addDays(new Date(), -10));
|
||||
query.setFields("*+enterprise@name+ship@name+route@name+loadWharf@name+dischargeWharf@name+loadPort@name+dischargePort@name");
|
||||
return super.page(query);
|
||||
}
|
||||
|
@ -496,30 +494,24 @@ public class SailScheduleController extends BaseController<BusSailScheduleServic
|
|||
return ResultData.success("success");
|
||||
}
|
||||
|
||||
@Operation(summary = "订阅的船期下拉列表", operationId = "16")
|
||||
@Operation(summary = "订阅的船期下拉列表", operationId = "16", description = "id的值为船期ID, extra1的值为航次, extra2的值为船舶ID")
|
||||
@GetMapping("/ship/list")
|
||||
public ResultData<List<DictDTO>> getScheduleList(@RequestParam(name = "q", required = false) String q) {
|
||||
CargoApiUser user = (CargoApiUser) UserContext.getUser();
|
||||
List<BusSailSchedule> list = service.lambdaQuery().and(StringUtils.isNotBlank(q), (wrap) -> { // 匹配船名,或者航次
|
||||
wrap.like(BusSailSchedule::getVoyage, q)
|
||||
.or()
|
||||
.exists("select id from bus_ship B where B.id=bus_sail_schedule.ship_id and B.name like '%" + q + "%'");
|
||||
}).exists("select id from bus_subscribe B where B.sub_enterprise_id=bus_sail_schedule.enterprise_id and B.wharf_id=bus_sail_schedule.discharge_wharf_id and sub_status='3' and B.enterprise_id=" + user.getEnterpriseId() + " and B.wharf_id=" + user.getWharfId()).orderByDesc(BusSailSchedule::getId).last("limit 20")
|
||||
.list();
|
||||
|
||||
Map<Long, String> shipMap = new HashMap<>();
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
List<DictShip> ships = shipService.lambdaQuery().in(DictShip::getId, list.stream().map(s -> s.getShipId()).distinct().collect(Collectors.toList())).list();
|
||||
shipMap.putAll(ships.stream().collect(Collectors.toMap(s -> s.getId(), s -> s.getName())));
|
||||
List<BusSailSchedule> sailScheduleList = cargoService.getSailScheduleList(user.getEnterpriseId(), user.getWharfId(), 10);
|
||||
if (StringUtils.isNotEmpty(q)) {
|
||||
sailScheduleList = sailScheduleList.stream().filter(s -> StringUtils.containsAny(s.getShip().getName(), q)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
List<DictDTO> rst = list.stream().map(s -> {
|
||||
List<DictDTO> rst = sailScheduleList.stream().map(s -> {
|
||||
DictDTO dto = new DictDTO();
|
||||
dto.setId(s.getId() + "");
|
||||
dto.setText(shipMap.get(s.getShipId()));
|
||||
dto.setText(s.getShip().getName());
|
||||
dto.setExtra1(s.getVoyage());
|
||||
dto.setExtra2(s.getShipId()+"");
|
||||
return dto;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
return ResultData.success(rst);
|
||||
}
|
||||
|
||||
|
@ -528,7 +520,7 @@ public class SailScheduleController extends BaseController<BusSailScheduleServic
|
|||
public ResultData<Page<BusSailSchedule>> historyPublishPage(@RequestBody SailScheduleQuery query) {
|
||||
// 我订阅的码头
|
||||
CargoApiUser user = (CargoApiUser) UserContext.getUser();
|
||||
query.setCreateDate(DateUtils.addDays(new Date(), -31));
|
||||
query.setCreateDate(DateUtils.addDays(new Date(), -30));
|
||||
// 订阅的码头ID
|
||||
query.setLoadWharfId(user.getWharfId());
|
||||
query.setFields("*+enterprise@name+ship@name+route@name+loadWharf@name+dischargeWharf@name+loadPort@name+dischargePort@name");
|
||||
|
@ -541,9 +533,14 @@ public class SailScheduleController extends BaseController<BusSailScheduleServic
|
|||
public ResultData<Page<BusSailSchedule>> historyReceivePage(@RequestBody SailScheduleQuery query) {
|
||||
// 我订阅的码头
|
||||
CargoApiUser user = (CargoApiUser) UserContext.getUser();
|
||||
query.setCreateDate(DateUtils.addDays(new Date(), -31));
|
||||
// 订阅的码头ID
|
||||
List<Long> collect = cargoService.getWharfIdList(user.getEnterpriseId(), user.getWharfId());
|
||||
if (CollectionUtils.isEmpty(collect)) {
|
||||
return ResultData.success(new Page<>());
|
||||
}
|
||||
query.setDischargeWharfId(user.getWharfId());
|
||||
query.setSubWharfIdIds(collect);
|
||||
query.setCreateDate(DateUtils.addDays(new Date(), -30));
|
||||
query.setFields("*+enterprise@name+ship@name+route@name+loadWharf@name+dischargeWharf@name+loadPort@name+dischargePort@name");
|
||||
query.setSorts(Arrays.asList(new BaseQuery.SortField("createDate", "desc")));
|
||||
return super.page(query);
|
||||
|
@ -580,4 +577,13 @@ public class SailScheduleController extends BaseController<BusSailScheduleServic
|
|||
|
||||
return ResultData.success(rst);
|
||||
}
|
||||
|
||||
@Operation(summary = "订阅的船期信息表(不分页)", operationId = "20")
|
||||
@GetMapping("/list")
|
||||
public ResultData<List<BusSailSchedule>> getScheduleList() {
|
||||
CargoApiUser user = (CargoApiUser) UserContext.getUser();
|
||||
List<BusSailSchedule> sailScheduleList = cargoService.getSailScheduleList(user.getEnterpriseId(), user.getWharfId(), 10);
|
||||
|
||||
return ResultData.success(sailScheduleList);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,19 @@
|
|||
package com.wsnet.cargo.controller;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.wsnet.cargo.entity.BusManifest;
|
||||
import com.wsnet.cargo.entity.BusSailSchedule;
|
||||
import com.wsnet.cargo.entity.BusSubscribe;
|
||||
import com.wsnet.cargo.enums.SubscribeStatusEnums;
|
||||
import com.wsnet.cargo.enums.TradeTypeEnums;
|
||||
import com.wsnet.cargo.mapper.BusSailScheduleMapper;
|
||||
import com.wsnet.cargo.query.SubscribeQuery;
|
||||
import com.wsnet.cargo.service.BusManifestService;
|
||||
import com.wsnet.cargo.service.BusSailScheduleService;
|
||||
import com.wsnet.cargo.service.BusSubscribeService;
|
||||
import com.wsnet.cargo.service.CargoService;
|
||||
import com.wsnet.core.annotation.Menu;
|
||||
import com.wsnet.core.holder.UserContext;
|
||||
import com.wsnet.core.response.ResultData;
|
||||
|
@ -15,9 +24,15 @@ import io.swagger.v3.oas.annotations.Operation;
|
|||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.collections4.MapUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/subscribe")
|
||||
@Menu(code = "0304", name = "订阅")
|
||||
|
@ -27,12 +42,57 @@ public class SubscribeController extends BaseController<BusSubscribeService, Bus
|
|||
@Resource
|
||||
private BaseService baseService;
|
||||
|
||||
@Resource
|
||||
private BusSailScheduleMapper scheduleMapper;
|
||||
|
||||
@Resource
|
||||
private CargoService cargoService;
|
||||
|
||||
@Operation(summary = "我发布的订阅", operationId = "10")
|
||||
@PostMapping("/publish/page")
|
||||
public ResultData<IPage<BusSubscribe>> publishPage(@RequestBody SubscribeQuery query) {
|
||||
CargoApiUser user = (CargoApiUser) UserContext.getUser();
|
||||
query.setEnterpriseId(user.getEnterpriseId());
|
||||
IPage<BusSubscribe> page = baseService.page(BusSubscribe.class, query);
|
||||
|
||||
List<Long> wharfIdList = cargoService.getWharfIdList(user.getEnterpriseId(), user.getWharfId());
|
||||
|
||||
if (CollectionUtils.isNotEmpty(wharfIdList))
|
||||
{
|
||||
Map<Long, Long> countMap1 = new HashMap<>();
|
||||
Map<Long, Long> countMap2 = new HashMap<>();
|
||||
Map<Long, Long> countMap3 = new HashMap<>();
|
||||
// 处理收到的船期数和收到的提单号数
|
||||
List<Map<String, Object>> mapList1 = scheduleMapper.getScheduleCount(wharfIdList);
|
||||
mapList1.stream().forEach(s -> {
|
||||
countMap1.put(MapUtils.getLong(s, "load_wharf_id", 0L), MapUtils.getLong(s, "num", 0L));
|
||||
});
|
||||
|
||||
List<Map<String, Object>> mapList2 = scheduleMapper.getBillCount(wharfIdList);
|
||||
mapList2.stream().forEach(s -> {
|
||||
countMap2.put(MapUtils.getLong(s, "load_wharf_id", 0L), MapUtils.getLong(s, "num", 0L));
|
||||
});
|
||||
|
||||
List<Map<String, Object>> mapList3 = scheduleMapper.getBillDetailCount(wharfIdList);
|
||||
mapList3.stream().forEach(s -> {
|
||||
countMap3.put(MapUtils.getLong(s, "load_wharf_id", 0L), MapUtils.getLong(s, "num", 0L));
|
||||
});
|
||||
|
||||
for (BusSubscribe record : page.getRecords()) {
|
||||
record.setScheduleNum(countMap1.get(record.getSubWharfId()));
|
||||
record.setBillNoNum(countMap2.get(record.getSubWharfId()));
|
||||
record.setBillNoDetailNum(countMap3.get(record.getSubWharfId()));
|
||||
}
|
||||
}
|
||||
|
||||
// {
|
||||
// QueryWrapper<BusManifest> queryWrapper = new QueryWrapper<>();
|
||||
// queryWrapper.select("load_wharf_id, count(id) as num");
|
||||
// queryWrapper.in("load_wharf_id", wharfIdList);
|
||||
// queryWrapper.groupBy("load_wharf_id");
|
||||
// List<Map<String, Object>> map = sailScheduleService.listMaps(queryWrapper);
|
||||
// }
|
||||
|
||||
return ResultData.success(page);
|
||||
}
|
||||
|
||||
|
@ -41,6 +101,7 @@ public class SubscribeController extends BaseController<BusSubscribeService, Bus
|
|||
public ResultData<IPage<BusSubscribe>> receivePage(@RequestBody SubscribeQuery query) {
|
||||
CargoApiUser user = (CargoApiUser) UserContext.getUser();
|
||||
query.setSubEnterpriseId(user.getEnterpriseId());
|
||||
query.setSubWharfId(user.getWharfId());
|
||||
IPage<BusSubscribe> page = baseService.page(BusSubscribe.class, query);
|
||||
return ResultData.success(page);
|
||||
}
|
||||
|
@ -50,7 +111,8 @@ public class SubscribeController extends BaseController<BusSubscribeService, Bus
|
|||
public ResultData<Long> count() {
|
||||
CargoApiUser user = (CargoApiUser) UserContext.getUser();
|
||||
Long count = service.lambdaQuery().eq(BusSubscribe::getSubStatus, SubscribeStatusEnums.NO_ACCEPTED)
|
||||
.eq(BusSubscribe::getSubEnterpriseId, user.getEnterpriseId()).count();
|
||||
.eq(BusSubscribe::getSubEnterpriseId, user.getEnterpriseId())
|
||||
.eq(user.getWharfId() != null, BusSubscribe::getSubWharfId, user.getWharfId()).count();
|
||||
return ResultData.success(count);
|
||||
}
|
||||
|
||||
|
|
|
@ -107,6 +107,18 @@ public class BusSubscribe extends BaseEntity implements Serializable {
|
|||
@Schema(description = "订阅状态")
|
||||
private SubscribeStatusEnums subStatus;
|
||||
|
||||
@TableField(exist = false)
|
||||
@Schema(description = "收到船期数")
|
||||
private Long scheduleNum = 0L;
|
||||
|
||||
@TableField(exist = false)
|
||||
@Schema(description = "收到舱单数")
|
||||
private Long billNoNum = 0L;
|
||||
|
||||
@TableField(exist = false)
|
||||
@Schema(description = "收到舱单明细数")
|
||||
private Long billNoDetailNum = 0L;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
|
@ -2,6 +2,11 @@ package com.wsnet.cargo.mapper;
|
|||
|
||||
import com.wsnet.cargo.entity.BusSailSchedule;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author dj
|
||||
|
@ -10,7 +15,30 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||
* @Entity com.wsnet.cargo.entity.BusSailSchedule
|
||||
*/
|
||||
public interface BusSailScheduleMapper extends BaseMapper<BusSailSchedule> {
|
||||
@Select("<script>" +
|
||||
"select count(id) num, load_wharf_id from bus_sail_schedule where load_wharf_id in " +
|
||||
"<foreach item='item' index='index' collection='ids' open='(' separator=',' close=')'>" +
|
||||
"#{item}" +
|
||||
"</foreach> GROUP BY load_wharf_id" +
|
||||
"</script>")
|
||||
List<Map<String, Object>> getScheduleCount(@Param("ids") List<Long> ids);
|
||||
|
||||
|
||||
@Select("<script>" +
|
||||
"select count(B.id) num, a.load_wharf_id from bus_sail_schedule A left join bus_manifest B on A.\"id\"=B.schedule_id where A.load_wharf_id in " +
|
||||
"<foreach item='item' index='index' collection='ids' open='(' separator=',' close=')'>" +
|
||||
"#{item}" +
|
||||
"</foreach> group by A.load_wharf_id" +
|
||||
"</script>")
|
||||
List<Map<String, Object>> getBillCount(@Param("ids") List<Long> ids);
|
||||
|
||||
@Select("<script>" +
|
||||
"select count(C.id) num, a.load_wharf_id from bus_sail_schedule A left join bus_manifest B on A.\"id\"=B.schedule_id left join bus_manifest_detail C On B.\"id\"=C.manifest_id where A.load_wharf_id in " +
|
||||
"<foreach item='item' index='index' collection='ids' open='(' separator=',' close=')'>" +
|
||||
"#{item}" +
|
||||
"</foreach> group by A.load_wharf_id" +
|
||||
"</script>")
|
||||
List<Map<String, Object>> getBillDetailCount(@Param("ids") List<Long> ids);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.wsnet.core.db.annos.DbQuery;
|
|||
import com.wsnet.core.db.enums.SqlSymbol;
|
||||
import com.wsnet.web.query.BaseQuery;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -68,4 +69,7 @@ public class ManifestQuery extends BaseQuery {
|
|||
|
||||
@DbQuery(outer = true)
|
||||
private Long subWharfId;
|
||||
|
||||
@Schema(description = "舱层")
|
||||
private Integer deck;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
package com.wsnet.cargo.service;
|
||||
|
||||
import com.wsnet.cargo.entity.BusSailSchedule;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface CargoService {
|
||||
/**
|
||||
* 企业订阅的码头列表
|
||||
* @param enterpriseId
|
||||
* @param wharfId 可以为空
|
||||
* @return
|
||||
*/
|
||||
List<Long> getWharfIdList(Long enterpriseId, Long wharfId);
|
||||
|
||||
/**
|
||||
* 码头订阅的船期列表
|
||||
* @param enterpriseId
|
||||
* @param wharfId
|
||||
* @return
|
||||
*/
|
||||
List<BusSailSchedule> getSailScheduleList(Long enterpriseId, Long wharfId, int limit);
|
||||
}
|
|
@ -6,6 +6,9 @@ import com.wsnet.cargo.service.BusSailScheduleService;
|
|||
import com.wsnet.cargo.mapper.BusSailScheduleMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author dj
|
||||
* @description 针对表【bus_sail_schedule(船期)】的数据库操作Service实现
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
package com.wsnet.cargo.service.impl;
|
||||
|
||||
import com.wsnet.cargo.entity.BusSailSchedule;
|
||||
import com.wsnet.cargo.entity.BusSubscribe;
|
||||
import com.wsnet.cargo.enums.SubscribeStatusEnums;
|
||||
import com.wsnet.cargo.query.SailScheduleQuery;
|
||||
import com.wsnet.cargo.service.BusSubscribeService;
|
||||
import com.wsnet.cargo.service.CargoService;
|
||||
import com.wsnet.core.utils.DateUtils;
|
||||
import com.wsnet.web.service.BaseService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class CargoServiceImpl implements CargoService {
|
||||
@Resource
|
||||
private BusSubscribeService subscribeService;
|
||||
|
||||
@Resource
|
||||
private BaseService baseService;
|
||||
|
||||
@Override
|
||||
public List<Long> getWharfIdList(Long enterpriseId, Long wharfId) {
|
||||
List<BusSubscribe> list = subscribeService.lambdaQuery().eq(BusSubscribe::getEnterpriseId, enterpriseId)
|
||||
.eq(BusSubscribe::getSubStatus, SubscribeStatusEnums.SUBSCRIBE) // 订阅中
|
||||
.eq(wharfId != null, BusSubscribe::getWharfId, wharfId)
|
||||
.le(BusSubscribe::getBeginDate, new Date()) // 在有效时间内
|
||||
.ge(BusSubscribe::getEndDate, new Date()).list();
|
||||
return list.stream().map(s -> s.getSubWharfId()).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BusSailSchedule> getSailScheduleList(Long enterpriseId, Long wharfId, int limit) {
|
||||
List<Long> wharfIdList = getWharfIdList(enterpriseId, wharfId);
|
||||
if (CollectionUtils.isEmpty(wharfIdList)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
SailScheduleQuery query = new SailScheduleQuery();
|
||||
query.setDischargeWharfId(wharfId);
|
||||
query.setSubWharfIdIds(wharfIdList);
|
||||
query.setCreateDate(DateUtils.addDays(new Date(), 0-limit));
|
||||
query.setFields("*+enterprise@name+ship@name+route@name+loadWharf@name+dischargeWharf@name+loadPort@name+dischargePort@name");
|
||||
return baseService.list(BusSailSchedule.class, query);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue