diff --git a/wsnet-cargo-sharing-service/src/main/java/com/wsnet/cargo/controller/EnterpriseController.java b/wsnet-cargo-sharing-service/src/main/java/com/wsnet/cargo/controller/EnterpriseController.java index 197ceca..8bc6420 100644 --- a/wsnet-cargo-sharing-service/src/main/java/com/wsnet/cargo/controller/EnterpriseController.java +++ b/wsnet-cargo-sharing-service/src/main/java/com/wsnet/cargo/controller/EnterpriseController.java @@ -23,6 +23,7 @@ import com.wsnet.user.service.impl.UserRegService; import com.wsnet.web.controller.BaseDictController; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.annotation.Resource; import jakarta.validation.constraints.NotBlank; @@ -114,15 +115,18 @@ public class EnterpriseController extends BaseDictController upload( - @NotNull(message = "文件类型不能为空") - @Parameter(name = "type", description = "文件类型 0-营业执照, 1-身份证") Integer type, - @NotBlank(message = "文件编号不能为空") - @Parameter(name = "no", description = "文件编号, 营业执照则为信用代码, 身份证则为手机号码") String no, + @NotNull(message = "文件类型不能为空") Integer type, + @NotBlank(message = "文件编号不能为空") String no, MultipartFile file) throws IOException { // 按年月创建目录 YearMonth ym = YearMonth.now(); - String foldPath = StringUtils.join(path, File.pathSeparator, ym.getYear(), File.pathSeparator, ym.getMonthValue()); + String foldPath = StringUtils.join(path, File.separator, ym.getYear(), File.separator, ym.getMonthValue()); // 创建文件目录 File fold = new File(foldPath); @@ -132,7 +136,7 @@ public class EnterpriseController extends BaseDictController> page(@RequestBody ManifestQuery query) { + CargoApiUser user = (CargoApiUser) UserContext.getUser(); + if (user.getWharfId() == null) { // 没有绑定码头,不能发布信息 + return ResultData.success(new Page<>()); + } + query.setPubSchedule("1"); + query.setPubEnterpriseId(user.getEnterpriseId()); + query.setPubWharfId(user.getWharfId()); + query.setFields("*+schedule@ship@name+schedule@voyage+brand@name"); return super.page(query); } @@ -293,6 +313,24 @@ public class ManifestController extends BaseController> subscribePage(@RequestBody ManifestQuery query) { + CargoApiUser user = (CargoApiUser) UserContext.getUser(); + List 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 collect = subscribes.stream().map(s -> s.getSubWharfId()).collect(Collectors.toList()); + query.setSubLoadWharfIds(collect); + query.setSubWharfId(user.getWharfId()); + query.setFields("*+schedule@ship@name+schedule@voyage+brand@name"); + return super.page(query); + } + /* @Operation(summary = "舱单导入", operationId = "11") @GetMapping("/tmp/export") diff --git a/wsnet-cargo-sharing-service/src/main/java/com/wsnet/cargo/controller/ManifestDetailController.java b/wsnet-cargo-sharing-service/src/main/java/com/wsnet/cargo/controller/ManifestDetailController.java index 44d2d16..b660a05 100644 --- a/wsnet-cargo-sharing-service/src/main/java/com/wsnet/cargo/controller/ManifestDetailController.java +++ b/wsnet-cargo-sharing-service/src/main/java/com/wsnet/cargo/controller/ManifestDetailController.java @@ -9,6 +9,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.query.ManifestDetailQuery; import com.wsnet.cargo.query.ManifestQuery; import com.wsnet.cargo.service.BusManifestDetailService; import com.wsnet.cargo.service.BusManifestService; @@ -47,7 +48,7 @@ import java.util.stream.Collectors; @RequestMapping("/manifest/detail") @Menu(code = "0303", name = "舱单明细") @Tag(name = "舱单明细") -public class ManifestDetailController extends BaseController { +public class ManifestDetailController extends BaseController { @Resource private DictVehicleTypeService vehicleTypeService; @@ -62,7 +63,7 @@ public class ManifestDetailController extends BaseController> page(@RequestBody ManifestQuery query) { + public ResultData> page(@RequestBody ManifestDetailQuery query) { return super.page(query); } diff --git a/wsnet-cargo-sharing-service/src/main/java/com/wsnet/cargo/controller/NoticeController.java b/wsnet-cargo-sharing-service/src/main/java/com/wsnet/cargo/controller/NoticeController.java index dab4ee3..23edf6c 100644 --- a/wsnet-cargo-sharing-service/src/main/java/com/wsnet/cargo/controller/NoticeController.java +++ b/wsnet-cargo-sharing-service/src/main/java/com/wsnet/cargo/controller/NoticeController.java @@ -2,15 +2,21 @@ package com.wsnet.cargo.controller; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.wsnet.cargo.entity.BusNotice; +import com.wsnet.cargo.entity.BusNoticeView; import com.wsnet.cargo.query.NoticeQuery; import com.wsnet.cargo.service.BusNoticeService; +import com.wsnet.cargo.service.BusNoticeViewService; import com.wsnet.core.annotation.Menu; +import com.wsnet.core.holder.UserContext; import com.wsnet.core.response.ResultData; +import com.wsnet.dto.CargoApiUser; import com.wsnet.web.controller.BaseController; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import jakarta.annotation.Resource; +import org.springframework.web.bind.annotation.*; + import java.util.HashSet; import java.util.Set; @@ -19,6 +25,10 @@ import java.util.Set; @Menu(code = "0305", name = "公告") @Tag(name = "公告") public class NoticeController extends BaseController { + + @Resource + private BusNoticeViewService noticeViewService; + @Override public ResultData> page(@RequestBody NoticeQuery query) { Set excludeFields = new HashSet<>(); @@ -26,4 +36,27 @@ public class NoticeController extends BaseController count() { + CargoApiUser user = (CargoApiUser) UserContext.getUser(); + Long count = service.lambdaQuery() + .notExists("select id from bus_notice_view B where B.notice_id=bus_notice.id and B.user_id={0}", Long.valueOf(user.getId())) + .count(); + return ResultData.success(count); + } + + @Override + protected ResultData get(@RequestParam("id") @Parameter(description = "id") Long id) { + CargoApiUser user = (CargoApiUser) UserContext.getUser(); + boolean exists = noticeViewService.lambdaQuery().eq(BusNoticeView::getNoticeId, id).eq(BusNoticeView::getUserId, Long.valueOf(user.getId())).exists(); + if (!exists) { + BusNoticeView view = new BusNoticeView(); + view.setUserId(Long.valueOf(user.getId())); + view.setNoticeId(id); + noticeViewService.save(view); + } + return super.get(id); + } } diff --git a/wsnet-cargo-sharing-service/src/main/java/com/wsnet/cargo/controller/SailScheduleController.java b/wsnet-cargo-sharing-service/src/main/java/com/wsnet/cargo/controller/SailScheduleController.java index 333e0e3..baedba2 100644 --- a/wsnet-cargo-sharing-service/src/main/java/com/wsnet/cargo/controller/SailScheduleController.java +++ b/wsnet-cargo-sharing-service/src/main/java/com/wsnet/cargo/controller/SailScheduleController.java @@ -11,11 +11,13 @@ 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.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; @@ -34,6 +36,7 @@ import jakarta.validation.ConstraintViolation; import jakarta.validation.Validation; import jakarta.validation.Validator; import jakarta.validation.ValidatorFactory; +import jakarta.validation.constraints.NotNull; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.validation.annotation.Validated; @@ -63,8 +66,23 @@ public class SailScheduleController extends BaseController> page(@RequestBody SailScheduleQuery query) { + CargoApiUser user = (CargoApiUser) UserContext.getUser(); + if (user.getWharfId() == null) { // 没有绑定码头,不能发布信息 + return ResultData.success(new Page<>()); + } + query.setEnterpriseId(user.getEnterpriseId()); + query.setLoadWharfId(user.getWharfId()); query.setFields("*+enterprise@name+ship@name+route@name+loadWharf@name+dischargeWharf@name+loadPort@name+dischargePort@name"); return super.page(query); } @@ -253,7 +271,7 @@ public class SailScheduleController extends BaseController> subPage(@RequestBody SailScheduleQuery query) { + // 我订阅的码头 + CargoApiUser user = (CargoApiUser) UserContext.getUser(); + List 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 collect = subscribes.stream().map(s -> s.getSubWharfId()).collect(Collectors.toList()); + query.setDischargeWharfId(user.getWharfId()); + query.setSubWharfIdIds(collect); + query.setFields("*+enterprise@name+ship@name+route@name+loadWharf@name+dischargeWharf@name+loadPort@name+dischargePort@name"); + return super.page(query); + } + + @Validated + @Operation(summary = "修改船舶状态", operationId = "15") + @PostMapping("/status/update") + public ResultData updateStatus(@RequestParam("id") @NotNull(message = "ID不能为空") Long id, @RequestParam("status") @NotNull(message = "船舶状态不能为空") ShipStatusEnums status) { + service.lambdaUpdate().eq(BusSailSchedule::getId, id).set(BusSailSchedule::getShipStatus, status).update(); + return ResultData.success("success"); + } + + @Operation(summary = "订阅的船期下拉列表", operationId = "16") + @GetMapping("/ship/list") + public ResultData> getScheduleList(@RequestParam(name = "q", required = false) String q) { + CargoApiUser user = (CargoApiUser) UserContext.getUser(); + List 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 shipMap = new HashMap<>(); + if (CollectionUtils.isNotEmpty(list)) { + List 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 rst = list.stream().map(s -> { + DictDTO dto = new DictDTO(); + dto.setId(s.getId() + ""); + dto.setText(shipMap.get(s.getShipId())); + dto.setExtra1(s.getVoyage()); + return dto; + }).collect(Collectors.toList()); + return ResultData.success(rst); + } } diff --git a/wsnet-cargo-sharing-service/src/main/java/com/wsnet/cargo/controller/StatisticsController.java b/wsnet-cargo-sharing-service/src/main/java/com/wsnet/cargo/controller/StatisticsController.java new file mode 100644 index 0000000..04d4452 --- /dev/null +++ b/wsnet-cargo-sharing-service/src/main/java/com/wsnet/cargo/controller/StatisticsController.java @@ -0,0 +1,301 @@ +package com.wsnet.cargo.controller; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.wsnet.cargo.dto.StatisticsVo; +import com.wsnet.cargo.entity.BusSailSchedule; +import com.wsnet.cargo.entity.DictShipRoute; +import com.wsnet.cargo.enums.TradeTypeEnums; +import com.wsnet.cargo.service.BusSailScheduleService; +import com.wsnet.cargo.service.DictShipRouteService; +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.core.utils.DateUtils; +import com.wsnet.dto.CargoApiUser; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.annotation.Resource; +import org.apache.commons.collections4.MapUtils; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +@RestController +@RequestMapping("/statistics") +@Menu(code = "0306", name = "业务统计") +@Tag(name = "业务统计") +public class StatisticsController { + + @Resource + private BusSailScheduleService sailScheduleService; + + @Resource + private DictShipRouteService shipRouteService; + + @Operation(summary = "数据统计", operationId = "01") + @GetMapping("/") + public ResultData statistics() { + StatisticsVo rst = new StatisticsVo(); + { + // 累计船舶艘次 + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.select("count(id) as num"); + Map map = sailScheduleService.getMap(queryWrapper); + rst.setTotalVoyages(MapUtils.getLong(map, "num", 0L)); + } + + { + // 年度船舶艘次 + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.select("count(id) as num"); + queryWrapper.between("departure_date_plan", DateUtils.getYearStart(new Date()), DateUtils.getYearEnd(new Date())); + Map map = sailScheduleService.getMap(queryWrapper); + rst.setYearVoyages(MapUtils.getLong(map, "num", 0L)); + + } + + { + // 累计货物数量 + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.select("sum(car_num_plan) as num"); + Map map = sailScheduleService.getMap(queryWrapper); + rst.setYearCargos(MapUtils.getLong(map, "num", 0L)); + } + + { + // 年度货物数量 + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.select("sum(car_num_plan) as num"); + queryWrapper.between("departure_date_plan", DateUtils.getYearStart(new Date()), DateUtils.getYearEnd(new Date())); + Map map = sailScheduleService.getMap(queryWrapper); + rst.setYearCargos(MapUtils.getLong(map, "num", 0L)); + + } + + CargoApiUser user = (CargoApiUser) UserContext.getUser(); + if (user.getEnterpriseId() != null) { + { + // 本港累计船舶艘次 + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.select("count(id) as num"); + queryWrapper.eq("enterprise_id", user.getEnterpriseId()); + Map map = sailScheduleService.getMap(queryWrapper); + rst.setTotalPortVoyages(MapUtils.getLong(map, "num", 0L)); + } + + { + // 本港年度船舶艘次 + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.select("count(id) as num"); + queryWrapper.eq("enterprise_id", user.getEnterpriseId()); + queryWrapper.between("departure_date_plan", DateUtils.getYearStart(new Date()), DateUtils.getYearEnd(new Date())); + Map map = sailScheduleService.getMap(queryWrapper); + rst.setYearPortVoyages(MapUtils.getLong(map, "num", 0L)); + + } + + { + // 本港累计货物数量 + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.select("sum(car_num_plan) as num"); + queryWrapper.eq("enterprise_id", user.getEnterpriseId()); + Map map = sailScheduleService.getMap(queryWrapper); + rst.setTotalPortCargos(MapUtils.getLong(map, "num", 0L)); + } + + { + // 本港年度货物数量 + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.select("sum(car_num_plan) as num"); + queryWrapper.eq("enterprise_id", user.getEnterpriseId()); + queryWrapper.between("departure_date_plan", DateUtils.getYearStart(new Date()), DateUtils.getYearEnd(new Date())); + Map map = sailScheduleService.getMap(queryWrapper); + rst.setYearPortCargos(MapUtils.getLong(map, "num", 0L)); + + } + } + + // 获取所有的航线 + List list = shipRouteService.lambdaQuery().eq(DictShipRoute::getStatus, StatusEnums.active).list(); + Map stringMap = list.stream().collect(Collectors.toMap(s -> s.getId(), s -> s.getName())); + + { + // 外贸进口艘次 + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.select("ship_route_id, count(id) as num"); + queryWrapper.eq("trade_type", TradeTypeEnums.OUT_IMPORT); + queryWrapper.groupBy("ship_route_id"); + List> map = sailScheduleService.listMaps(queryWrapper); + List fields = new ArrayList<>(); + List datas = new ArrayList<>(); + map.forEach(m -> { + fields.add(stringMap.get(MapUtils.getLong(m, "ship_route_id", 0L))); + datas.add(MapUtils.getLong(m, "num", 0L)); + }); + + StatisticsVo.RingData ringData = new StatisticsVo.RingData(); + ringData.setFields(fields); + ringData.setDatas(datas); + + rst.setOutImportVoyages(ringData); + } + + { + // 外贸出口艘次 + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.select("ship_route_id, count(id) as num"); + queryWrapper.eq("trade_type", TradeTypeEnums.OUT_EXPORT); + queryWrapper.groupBy("ship_route_id"); + List> map = sailScheduleService.listMaps(queryWrapper); + List fields = new ArrayList<>(); + List datas = new ArrayList<>(); + map.forEach(m -> { + fields.add(stringMap.get(MapUtils.getLong(m, "ship_route_id", 0L))); + datas.add(MapUtils.getLong(m, "num", 0L)); + }); + + StatisticsVo.RingData ringData = new StatisticsVo.RingData(); + ringData.setFields(fields); + ringData.setDatas(datas); + + rst.setOutExportVoyages(ringData); + } + + { + // 内贸累计艘次 + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.select("ship_route_id, count(id) as num"); + queryWrapper.eq("trade_type", TradeTypeEnums.IN); + queryWrapper.groupBy("ship_route_id"); + List> map = sailScheduleService.listMaps(queryWrapper); + List fields = new ArrayList<>(); + List datas = new ArrayList<>(); + map.forEach(m -> { + fields.add(stringMap.get(MapUtils.getLong(m, "ship_route_id", 0L))); + datas.add(MapUtils.getLong(m, "num", 0L)); + }); + + StatisticsVo.RingData ringData = new StatisticsVo.RingData(); + ringData.setFields(fields); + ringData.setDatas(datas); + + rst.setInTotalVoyages(ringData); + } + + { + // 内贸年度艘次 + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.select("ship_route_id, count(id) as num"); + queryWrapper.eq("trade_type", TradeTypeEnums.IN); + queryWrapper.groupBy("ship_route_id"); + queryWrapper.between("departure_date_plan", DateUtils.getYearStart(new Date()), DateUtils.getYearEnd(new Date())); + List> map = sailScheduleService.listMaps(queryWrapper); + List fields = new ArrayList<>(); + List datas = new ArrayList<>(); + map.forEach(m -> { + fields.add(stringMap.get(MapUtils.getLong(m, "ship_route_id", 0L))); + datas.add(MapUtils.getLong(m, "num", 0L)); + }); + + StatisticsVo.RingData ringData = new StatisticsVo.RingData(); + ringData.setFields(fields); + ringData.setDatas(datas); + + rst.setInYearVoyages(ringData); + } + + { + // 外贸进口货物 + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.select("ship_route_id, sum(car_num_plan) as num"); + queryWrapper.eq("trade_type", TradeTypeEnums.OUT_IMPORT); + queryWrapper.groupBy("ship_route_id"); + List> map = sailScheduleService.listMaps(queryWrapper); + List fields = new ArrayList<>(); + List datas = new ArrayList<>(); + map.forEach(m -> { + fields.add(stringMap.get(MapUtils.getLong(m, "ship_route_id", 0L))); + datas.add(MapUtils.getLong(m, "num", 0L)); + }); + + StatisticsVo.RingData ringData = new StatisticsVo.RingData(); + ringData.setFields(fields); + ringData.setDatas(datas); + + rst.setOutImportCargos(ringData); + } + + { + // 外贸出口货物 + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.select("ship_route_id, sum(car_num_plan) as num"); + queryWrapper.eq("trade_type", TradeTypeEnums.OUT_EXPORT); + queryWrapper.groupBy("ship_route_id"); + List> map = sailScheduleService.listMaps(queryWrapper); + List fields = new ArrayList<>(); + List datas = new ArrayList<>(); + map.forEach(m -> { + fields.add(stringMap.get(MapUtils.getLong(m, "ship_route_id", 0L))); + datas.add(MapUtils.getLong(m, "num", 0L)); + }); + + StatisticsVo.RingData ringData = new StatisticsVo.RingData(); + ringData.setFields(fields); + ringData.setDatas(datas); + + rst.setOutExportCargos(ringData); + } + + { + // 内贸累计货物 + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.select("ship_route_id, sum(car_num_plan) as num"); + queryWrapper.eq("trade_type", TradeTypeEnums.IN); + queryWrapper.groupBy("ship_route_id"); + List> map = sailScheduleService.listMaps(queryWrapper); + List fields = new ArrayList<>(); + List datas = new ArrayList<>(); + map.forEach(m -> { + fields.add(stringMap.get(MapUtils.getLong(m, "ship_route_id", 0L))); + datas.add(MapUtils.getLong(m, "num", 0L)); + }); + + StatisticsVo.RingData ringData = new StatisticsVo.RingData(); + ringData.setFields(fields); + ringData.setDatas(datas); + + rst.setInTotalCargos(ringData); + } + + { + // 内贸年度货物 + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.select("ship_route_id, sum(car_num_plan) as num"); + queryWrapper.eq("trade_type", TradeTypeEnums.IN); + queryWrapper.groupBy("ship_route_id"); + queryWrapper.between("departure_date_plan", DateUtils.getYearStart(new Date()), DateUtils.getYearEnd(new Date())); + List> map = sailScheduleService.listMaps(queryWrapper); + List fields = new ArrayList<>(); + List datas = new ArrayList<>(); + map.forEach(m -> { + fields.add(stringMap.get(MapUtils.getLong(m, "ship_route_id", 0L))); + datas.add(MapUtils.getLong(m, "num", 0L)); + }); + + StatisticsVo.RingData ringData = new StatisticsVo.RingData(); + ringData.setFields(fields); + ringData.setDatas(datas); + + rst.setInYearCargos(ringData); + } + + return ResultData.success(rst); + } +} diff --git a/wsnet-cargo-sharing-service/src/main/java/com/wsnet/cargo/controller/SubscribeController.java b/wsnet-cargo-sharing-service/src/main/java/com/wsnet/cargo/controller/SubscribeController.java index 1a6671f..dafd983 100644 --- a/wsnet-cargo-sharing-service/src/main/java/com/wsnet/cargo/controller/SubscribeController.java +++ b/wsnet-cargo-sharing-service/src/main/java/com/wsnet/cargo/controller/SubscribeController.java @@ -2,6 +2,7 @@ package com.wsnet.cargo.controller; import com.baomidou.mybatisplus.core.metadata.IPage; import com.wsnet.cargo.entity.BusSubscribe; +import com.wsnet.cargo.enums.SubscribeStatusEnums; import com.wsnet.cargo.query.SubscribeQuery; import com.wsnet.cargo.service.BusSubscribeService; import com.wsnet.core.annotation.Menu; @@ -13,11 +14,9 @@ import com.wsnet.web.service.BaseService; 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.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; @RestController @RequestMapping("/subscribe") @@ -46,9 +45,26 @@ public class SubscribeController extends BaseController count() { + CargoApiUser user = (CargoApiUser) UserContext.getUser(); + Long count = service.lambdaQuery().eq(BusSubscribe::getSubStatus, SubscribeStatusEnums.NO_ACCEPTED) + .eq(BusSubscribe::getSubEnterpriseId, user.getEnterpriseId()).count(); + return ResultData.success(count); + } + + @Validated + @Operation(summary = "修改订阅状态", operationId = "13") + @GetMapping("/update") + public ResultData update(@RequestParam("id") @NotNull(message = "ID不能为空") Long id, @RequestParam("status") @NotNull(message = "订阅状态不能为空") SubscribeStatusEnums status) { + service.lambdaUpdate().set(BusSubscribe::getSubStatus, status) + .eq(BusSubscribe::getId, id).update(); + return ResultData.success("success"); + } + @Override protected ResultData save(@RequestBody @Validated BusSubscribe entity) { - // 提单号不允许重复 CargoApiUser user = (CargoApiUser) UserContext.getUser(); entity.setEnterpriseId(user.getEnterpriseId()); return super.save(entity); diff --git a/wsnet-cargo-sharing-service/src/main/java/com/wsnet/cargo/dto/StatisticsVo.java b/wsnet-cargo-sharing-service/src/main/java/com/wsnet/cargo/dto/StatisticsVo.java new file mode 100644 index 0000000..b716fbf --- /dev/null +++ b/wsnet-cargo-sharing-service/src/main/java/com/wsnet/cargo/dto/StatisticsVo.java @@ -0,0 +1,66 @@ +package com.wsnet.cargo.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + + +@Data +@Schema(description = "数据统计") +public class StatisticsVo implements Serializable { + @Schema(title = "累计船舶艘次") + private Long totalVoyages; + + @Schema(title = "年度船舶艘次") + private Long yearVoyages; + + @Schema(title = "本港累计船舶艘次") + private Long totalPortVoyages; + + @Schema(title = "本港年度船舶艘次") + private Long yearPortVoyages; + + @Schema(title = "累计货物数量") + private Long totalCargos; + + @Schema(title = "年度货物数量") + private Long yearCargos; + + @Schema(title = "本港累计货物数量") + private Long totalPortCargos; + + @Schema(title = "本港年度货物数量") + private Long yearPortCargos; + + @Schema(title = "外贸进口艘次") + private RingData outImportVoyages; + + @Schema(title = "外贸出口艘次") + private RingData outExportVoyages; + + @Schema(title = "内贸累计艘次") + private RingData inTotalVoyages; + + @Schema(title = "内贸年度艘次") + private RingData inYearVoyages; + + @Schema(title = "外贸进口货物") + private RingData outImportCargos; + + @Schema(title = "外贸出口货物") + private RingData outExportCargos; + + @Schema(title = "内贸累计货物") + private RingData inTotalCargos; + + @Schema(title = "内贸年度货物") + private RingData inYearCargos; + + @Data + public static class RingData implements Serializable { + private List fields; + private List datas; + } +} diff --git a/wsnet-cargo-sharing-service/src/main/java/com/wsnet/cargo/entity/BusManifest.java b/wsnet-cargo-sharing-service/src/main/java/com/wsnet/cargo/entity/BusManifest.java index f57d374..f657f18 100644 --- a/wsnet-cargo-sharing-service/src/main/java/com/wsnet/cargo/entity/BusManifest.java +++ b/wsnet-cargo-sharing-service/src/main/java/com/wsnet/cargo/entity/BusManifest.java @@ -139,6 +139,11 @@ public class BusManifest extends BaseEntity implements Serializable { @DbBean(ref = "brandId") private DictBrand brand; + @TableField(exist = false) + @Schema(description = "船期") + @DbBean(ref = "scheduleId") + private BusSailSchedule schedule; + @TableField(exist = false) private static final long serialVersionUID = 1L; } \ No newline at end of file diff --git a/wsnet-cargo-sharing-service/src/main/java/com/wsnet/cargo/entity/BusNoticeView.java b/wsnet-cargo-sharing-service/src/main/java/com/wsnet/cargo/entity/BusNoticeView.java new file mode 100644 index 0000000..464a436 --- /dev/null +++ b/wsnet-cargo-sharing-service/src/main/java/com/wsnet/cargo/entity/BusNoticeView.java @@ -0,0 +1,30 @@ +package com.wsnet.cargo.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.wsnet.core.db.entity.BaseEntity; +import java.io.Serializable; +import lombok.Data; + +/** + * 已查看的公告 + * @TableName bus_notice_view + */ +@TableName(value ="bus_notice_view") +@Data +public class BusNoticeView extends BaseEntity implements Serializable { + /** + * 公告标题 + */ + @TableField(value = "user_id") + private Long userId; + + /** + * 公告内容 + */ + @TableField(value = "notice_id") + private Long noticeId; + + @TableField(exist = false) + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/wsnet-cargo-sharing-service/src/main/java/com/wsnet/cargo/query/ManifestDetailQuery.java b/wsnet-cargo-sharing-service/src/main/java/com/wsnet/cargo/query/ManifestDetailQuery.java index c4be459..46b8299 100644 --- a/wsnet-cargo-sharing-service/src/main/java/com/wsnet/cargo/query/ManifestDetailQuery.java +++ b/wsnet-cargo-sharing-service/src/main/java/com/wsnet/cargo/query/ManifestDetailQuery.java @@ -15,4 +15,8 @@ public class ManifestDetailQuery extends BaseQuery { @Schema(description = "舱单ID列表") @DbQuery(symbol = SqlSymbol.IN) private List manifestId; + + @Schema(description = "提单号") + @DbQuery(outer = true, symbol = SqlSymbol.EXISTS, field = "select id from bus_manifest B where B.id=bus_manifest_detail.manifest_id and B.bill_no like '%${billNo}%'") + private String billNo; } diff --git a/wsnet-cargo-sharing-service/src/main/java/com/wsnet/cargo/query/ManifestQuery.java b/wsnet-cargo-sharing-service/src/main/java/com/wsnet/cargo/query/ManifestQuery.java index 3bf16a8..a316dc5 100644 --- a/wsnet-cargo-sharing-service/src/main/java/com/wsnet/cargo/query/ManifestQuery.java +++ b/wsnet-cargo-sharing-service/src/main/java/com/wsnet/cargo/query/ManifestQuery.java @@ -7,10 +7,15 @@ import com.wsnet.web.query.BaseQuery; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import java.util.List; + @Data @Schema(title = "舱单查询") public class ManifestQuery extends BaseQuery { + @Schema(description = "船期ID") + private Long scheduleId; + @Schema(description = "船ID") @DbQuery(outer = true) private Long shipId; @@ -43,4 +48,24 @@ public class ManifestQuery extends BaseQuery { // 和船期有关的关联查询 @DbQuery(symbol = SqlSymbol.EXISTS, field = "select id from bus_sail_schedule b where b.id=bus_manifest.schedule_id and b.ship_id=${shipId} and b.voyage=${voyage}") private String schedule; + + // 我发布的 + @DbQuery(symbol = SqlSymbol.EXISTS, field = "select id from bus_sail_schedule b where b.id=bus_manifest.schedule_id and b.enterprise_id=${pubEnterpriseId} and b.load_wharf_id=${pubWharfId}") + private String pubSchedule; + + @DbQuery(outer = true) + private Long pubEnterpriseId; + + @DbQuery(outer = true) + private Long pubWharfId; + + // 我订阅的 + @DbQuery(symbol = SqlSymbol.EXISTS, field = "select id from bus_sail_schedule b where b.id=bus_manifest.schedule_id and b.discharge_wharf_id=${subWharfId} and load_wharf_id in (${subLoadWharfIds})") + private String subSchedule; + + @DbQuery(outer = true) + private List subLoadWharfIds; + + @DbQuery(outer = true) + private Long subWharfId; } diff --git a/wsnet-cargo-sharing-service/src/main/java/com/wsnet/cargo/query/SailScheduleQuery.java b/wsnet-cargo-sharing-service/src/main/java/com/wsnet/cargo/query/SailScheduleQuery.java index bcc5da2..5473dfd 100644 --- a/wsnet-cargo-sharing-service/src/main/java/com/wsnet/cargo/query/SailScheduleQuery.java +++ b/wsnet-cargo-sharing-service/src/main/java/com/wsnet/cargo/query/SailScheduleQuery.java @@ -2,10 +2,14 @@ package com.wsnet.cargo.query; import com.wsnet.cargo.enums.ShipStatusEnums; import com.wsnet.cargo.enums.TradeTypeEnums; +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 lombok.Data; +import java.util.List; + @Data @Schema(title = "船期查询") public class SailScheduleQuery extends BaseQuery { @@ -68,4 +72,21 @@ public class SailScheduleQuery extends BaseQuery { */ @Schema(description = "卸货港口") private Long dischargePortId; + + /** + * 我订阅的 + */ +// @DbQuery(symbol = SqlSymbol.EXISTS, field = "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=${subEnterpriseId} and B.wharf_id=${subWharfIdId}") +// private Boolean mySubscribe; +// +// @Schema(description = "订阅企业ID") +// @DbQuery(outer = true) +// private Long subEnterpriseId; +// +// @Schema(description = "订阅码头ID") +// @DbQuery(outer = true) +// private Long subWharfIdId; + @Schema(description = "我订阅的码头ID列表") + @DbQuery(symbol = SqlSymbol.IN, field = "loadWharfId") + private List subWharfIdIds; } diff --git a/wsnet-cargo-sharing-service/src/main/java/com/wsnet/cargo/service/BusNoticeViewService.java b/wsnet-cargo-sharing-service/src/main/java/com/wsnet/cargo/service/BusNoticeViewService.java new file mode 100644 index 0000000..35ab6fb --- /dev/null +++ b/wsnet-cargo-sharing-service/src/main/java/com/wsnet/cargo/service/BusNoticeViewService.java @@ -0,0 +1,13 @@ +package com.wsnet.cargo.service; + +import com.wsnet.cargo.entity.BusNoticeView; +import com.baomidou.mybatisplus.extension.service.IService; + +/** +* @author dj +* @description 针对表【bus_notice_view(已查看的公告)】的数据库操作Service +* @createDate 2024-11-11 13:40:49 +*/ +public interface BusNoticeViewService extends IService { + +} diff --git a/wsnet-cargo-sharing-service/src/main/java/com/wsnet/cargo/service/impl/BusNoticeViewServiceImpl.java b/wsnet-cargo-sharing-service/src/main/java/com/wsnet/cargo/service/impl/BusNoticeViewServiceImpl.java new file mode 100644 index 0000000..ea8a2ab --- /dev/null +++ b/wsnet-cargo-sharing-service/src/main/java/com/wsnet/cargo/service/impl/BusNoticeViewServiceImpl.java @@ -0,0 +1,22 @@ +package com.wsnet.cargo.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.wsnet.cargo.entity.BusNoticeView; +import com.wsnet.cargo.service.BusNoticeViewService; +import com.wsnet.cargo.mapper.BusNoticeViewMapper; +import org.springframework.stereotype.Service; + +/** +* @author dj +* @description 针对表【bus_notice_view(已查看的公告)】的数据库操作Service实现 +* @createDate 2024-11-11 13:40:49 +*/ +@Service +public class BusNoticeViewServiceImpl extends ServiceImpl + implements BusNoticeViewService{ + +} + + + + diff --git a/wsnet-cargo-sharing-service/src/main/resources/mapper/BusNoticeViewMapper.xml b/wsnet-cargo-sharing-service/src/main/resources/mapper/BusNoticeViewMapper.xml new file mode 100644 index 0000000..65d390a --- /dev/null +++ b/wsnet-cargo-sharing-service/src/main/resources/mapper/BusNoticeViewMapper.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + id,create_by,create_date, + update_by,update_date,version, + user_id,notice_id + + diff --git a/wsnet-cargo-sharing-service/src/test/java/com/wsnet/cargo/SqlTest.java b/wsnet-cargo-sharing-service/src/test/java/com/wsnet/cargo/SqlTest.java index 6f05ea0..cca8959 100644 --- a/wsnet-cargo-sharing-service/src/test/java/com/wsnet/cargo/SqlTest.java +++ b/wsnet-cargo-sharing-service/src/test/java/com/wsnet/cargo/SqlTest.java @@ -8,6 +8,7 @@ import com.wsnet.web.query.BaseQuery; import net.sf.jsqlparser.JSQLParserException; import org.apache.commons.lang3.StringUtils; +import java.io.File; import java.lang.reflect.Field; import java.util.Arrays; import java.util.Collection; @@ -15,26 +16,28 @@ import java.util.Date; public class SqlTest { public static void main(String[] args) throws JSQLParserException { - String sql = "select id from bus_sail_schedule b where b.id=bus_manifest.schedule_id and b.ship_id = ${shipId} and b.voyage = '${voyage}' and b.status='${status}' and b.create_date='${createDate}' and b.status in (${statusList}) and b.status in (${statusArray})"; +// String sql = "select id from bus_sail_schedule b where b.id=bus_manifest.schedule_id and b.ship_id = ${shipId} and b.voyage = '${voyage}' and b.status='${status}' and b.create_date='${createDate}' and b.status in (${statusList}) and b.status in (${statusArray})"; +// +// +// ManifestQuery query = new ManifestQuery(); +//// query.setVoyage("12345"); +// query.setShipId(123l); +//// query.setStatus(StatusEnums.active); +//// query.setCreateDate(new Date()); +// +// String[] statusArray = new String[3]; +// statusArray[0] = "1"; +// statusArray[1] = "2"; +//// query.setStatusArray(statusArray); +// +//// query.setStatusList(Arrays.asList("4", "5")); +// +// SqlTest test = new SqlTest(); +// String fmtSql = test.formatExistSql(sql, query); +// +// System.err.println(fmtSql); - - ManifestQuery query = new ManifestQuery(); -// query.setVoyage("12345"); - query.setShipId(123l); -// query.setStatus(StatusEnums.active); -// query.setCreateDate(new Date()); - - String[] statusArray = new String[3]; - statusArray[0] = "1"; - statusArray[1] = "2"; -// query.setStatusArray(statusArray); - -// query.setStatusList(Arrays.asList("4", "5")); - - SqlTest test = new SqlTest(); - String fmtSql = test.formatExistSql(sql, query); - - System.err.println(fmtSql); + System.err.println(File.separator); }