master
dengjun 2024-11-13 10:07:14 +08:00
parent bc6c938b8c
commit a791845b53
17 changed files with 714 additions and 37 deletions

View File

@ -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<DictEnterpriseServi
@Anonymous
@Operation(summary = "文件上传")
@PostMapping("/upload")
@Parameters(value = {
@Parameter(name = "file", description = "文件"),
@Parameter(name = "no", description = "文件编号, 营业执照则为信用代码, 身份证则为手机号码"),
@Parameter(name = "type", description = "文件类型 0-营业执照, 1-身份证")
})
public ResultData<String> 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<DictEnterpriseServi
String fileName = StringUtils.join(type == 0 ? "license" : "id", "-",
no, ".", StringUtils.substringAfterLast(file.getOriginalFilename(), "."));
String filePath = StringUtils.join(foldPath, File.pathSeparator, fileName);
String filePath = StringUtils.join(foldPath, File.separator, fileName);
file.transferTo(new File(filePath));

View File

@ -11,15 +11,19 @@ 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.GoodsStatusEnums;
import com.wsnet.cargo.enums.SubscribeStatusEnums;
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.BusManifestService;
import com.wsnet.cargo.service.BusSubscribeService;
import com.wsnet.cargo.service.DictBrandService;
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.CascadeGroup;
import com.wsnet.excel.handler.CustomCellWriteHandler;
import com.wsnet.excel.utils.ExcelPropertiesUtils;
@ -55,8 +59,24 @@ public class ManifestController extends BaseController<BusManifestService, BusMa
@Resource
private DictBrandService brandService;
@Resource
private BusSubscribeService subscribeService;
/**
*
* @param query
* @return
*/
@Override
public ResultData<Page<BusManifest>> 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<BusManifestService, BusMa
}
@Operation(summary = "我订阅的舱单列表", operationId = "14")
@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());
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")

View File

@ -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<BusManifestDetailService, BusManifestDetail, ManifestQuery> {
public class ManifestDetailController extends BaseController<BusManifestDetailService, BusManifestDetail, ManifestDetailQuery> {
@Resource
private DictVehicleTypeService vehicleTypeService;
@ -62,7 +63,7 @@ public class ManifestDetailController extends BaseController<BusManifestDetailSe
private BusManifestDetailService manifestDetailService;
@Override
public ResultData<Page<BusManifestDetail>> page(@RequestBody ManifestQuery query) {
public ResultData<Page<BusManifestDetail>> page(@RequestBody ManifestDetailQuery query) {
return super.page(query);
}

View File

@ -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<BusNoticeService, BusNotice, NoticeQuery> {
@Resource
private BusNoticeViewService noticeViewService;
@Override
public ResultData<Page<BusNotice>> page(@RequestBody NoticeQuery query) {
Set<String> excludeFields = new HashSet<>();
@ -26,4 +36,27 @@ public class NoticeController extends BaseController<BusNoticeService, BusNotice
query.setExcludeFields(excludeFields);
return super.page(query);
}
@Operation(summary = "未查看通告数", operationId = "05")
@GetMapping("/count")
public ResultData<Long> 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<BusNotice> 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);
}
}

View File

@ -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<BusSailScheduleServic
@Resource
private DictWharfService wharfService;
@Resource
private BusSubscribeService subscribeService;
/**
*
*
* @param query
* @return
*/
@Override
public ResultData<Page<BusSailSchedule>> 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<BusSailScheduleServic
// 船名、航次不允许重复
if (existsShipVoyages.contains(StringUtils.join(rowData.getShipName(), "#$#", rowData.getVoyage()))) {
JSONObject o = JSONObject.from(rowData);
o.put("status", "excel中船名" + rowData.getShipName()+", 航次:" + rowData.getVoyage() + "重复");
o.put("status", "excel中船名" + rowData.getShipName() + ", 航次:" + rowData.getVoyage() + "重复");
errors.add(o);
} else {
existsShipVoyages.add(StringUtils.join(rowData.getShipName(), "#$#", rowData.getVoyage()));
@ -334,7 +352,7 @@ public class SailScheduleController extends BaseController<BusSailScheduleServic
boolean exists = service.lambdaQuery().eq(BusSailSchedule::getShipId, ship.get().getId()).eq(BusSailSchedule::getVoyage, rowData.getVoyage()).exists();
if (exists) {
JSONObject o = JSONObject.from(rowData);
o.put("status", "数据库中,船名:" + rowData.getShipName()+", 航次:" + rowData.getVoyage() + "已存在");
o.put("status", "数据库中,船名:" + rowData.getShipName() + ", 航次:" + rowData.getVoyage() + "已存在");
errors.add(o);
return ResultData.fail(JSON.toJSONString(errors));
}
@ -436,4 +454,58 @@ public class SailScheduleController extends BaseController<BusSailScheduleServic
ExcelUtils.export(response, DateUtil.format(new Date(), DatePattern.PURE_DATE_PATTERN) + "船期", "船期", collect, SailScheduleImportExcel.class);
}
@Operation(summary = "我订阅的船期分页列表", operationId = "14")
@PostMapping("/subscribe/page")
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)) {
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.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<String> 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<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<DictDTO> 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);
}
}

View File

@ -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<StatisticsVo> statistics() {
StatisticsVo rst = new StatisticsVo();
{
// 累计船舶艘次
QueryWrapper<BusSailSchedule> queryWrapper = new QueryWrapper<>();
queryWrapper.select("count(id) as num");
Map<String, Object> map = sailScheduleService.getMap(queryWrapper);
rst.setTotalVoyages(MapUtils.getLong(map, "num", 0L));
}
{
// 年度船舶艘次
QueryWrapper<BusSailSchedule> queryWrapper = new QueryWrapper<>();
queryWrapper.select("count(id) as num");
queryWrapper.between("departure_date_plan", DateUtils.getYearStart(new Date()), DateUtils.getYearEnd(new Date()));
Map<String, Object> map = sailScheduleService.getMap(queryWrapper);
rst.setYearVoyages(MapUtils.getLong(map, "num", 0L));
}
{
// 累计货物数量
QueryWrapper<BusSailSchedule> queryWrapper = new QueryWrapper<>();
queryWrapper.select("sum(car_num_plan) as num");
Map<String, Object> map = sailScheduleService.getMap(queryWrapper);
rst.setYearCargos(MapUtils.getLong(map, "num", 0L));
}
{
// 年度货物数量
QueryWrapper<BusSailSchedule> 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<String, Object> map = sailScheduleService.getMap(queryWrapper);
rst.setYearCargos(MapUtils.getLong(map, "num", 0L));
}
CargoApiUser user = (CargoApiUser) UserContext.getUser();
if (user.getEnterpriseId() != null) {
{
// 本港累计船舶艘次
QueryWrapper<BusSailSchedule> queryWrapper = new QueryWrapper<>();
queryWrapper.select("count(id) as num");
queryWrapper.eq("enterprise_id", user.getEnterpriseId());
Map<String, Object> map = sailScheduleService.getMap(queryWrapper);
rst.setTotalPortVoyages(MapUtils.getLong(map, "num", 0L));
}
{
// 本港年度船舶艘次
QueryWrapper<BusSailSchedule> 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<String, Object> map = sailScheduleService.getMap(queryWrapper);
rst.setYearPortVoyages(MapUtils.getLong(map, "num", 0L));
}
{
// 本港累计货物数量
QueryWrapper<BusSailSchedule> queryWrapper = new QueryWrapper<>();
queryWrapper.select("sum(car_num_plan) as num");
queryWrapper.eq("enterprise_id", user.getEnterpriseId());
Map<String, Object> map = sailScheduleService.getMap(queryWrapper);
rst.setTotalPortCargos(MapUtils.getLong(map, "num", 0L));
}
{
// 本港年度货物数量
QueryWrapper<BusSailSchedule> 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<String, Object> map = sailScheduleService.getMap(queryWrapper);
rst.setYearPortCargos(MapUtils.getLong(map, "num", 0L));
}
}
// 获取所有的航线
List<DictShipRoute> list = shipRouteService.lambdaQuery().eq(DictShipRoute::getStatus, StatusEnums.active).list();
Map<Long, String> stringMap = list.stream().collect(Collectors.toMap(s -> s.getId(), s -> s.getName()));
{
// 外贸进口艘次
QueryWrapper<BusSailSchedule> 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<String, Object>> map = sailScheduleService.listMaps(queryWrapper);
List<String> fields = new ArrayList<>();
List<Long> 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<BusSailSchedule> 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<String, Object>> map = sailScheduleService.listMaps(queryWrapper);
List<String> fields = new ArrayList<>();
List<Long> 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<BusSailSchedule> 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<String, Object>> map = sailScheduleService.listMaps(queryWrapper);
List<String> fields = new ArrayList<>();
List<Long> 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<BusSailSchedule> 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<String, Object>> map = sailScheduleService.listMaps(queryWrapper);
List<String> fields = new ArrayList<>();
List<Long> 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<BusSailSchedule> 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<String, Object>> map = sailScheduleService.listMaps(queryWrapper);
List<String> fields = new ArrayList<>();
List<Long> 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<BusSailSchedule> 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<String, Object>> map = sailScheduleService.listMaps(queryWrapper);
List<String> fields = new ArrayList<>();
List<Long> 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<BusSailSchedule> 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<String, Object>> map = sailScheduleService.listMaps(queryWrapper);
List<String> fields = new ArrayList<>();
List<Long> 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<BusSailSchedule> 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<String, Object>> map = sailScheduleService.listMaps(queryWrapper);
List<String> fields = new ArrayList<>();
List<Long> 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);
}
}

View File

@ -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<BusSubscribeService, Bus
return ResultData.success(page);
}
@Operation(summary = "待处理订阅数量", operationId = "12")
@GetMapping("/count")
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();
return ResultData.success(count);
}
@Validated
@Operation(summary = "修改订阅状态", operationId = "13")
@GetMapping("/update")
public ResultData<String> 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<Long> save(@RequestBody @Validated BusSubscribe entity) {
// 提单号不允许重复
CargoApiUser user = (CargoApiUser) UserContext.getUser();
entity.setEnterpriseId(user.getEnterpriseId());
return super.save(entity);

View File

@ -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<String> fields;
private List<Long> datas;
}
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -15,4 +15,8 @@ public class ManifestDetailQuery extends BaseQuery {
@Schema(description = "舱单ID列表")
@DbQuery(symbol = SqlSymbol.IN)
private List<Long> 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;
}

View File

@ -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<Long> subLoadWharfIds;
@DbQuery(outer = true)
private Long subWharfId;
}

View File

@ -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<Long> subWharfIdIds;
}

View File

@ -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<BusNoticeView> {
}

View File

@ -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<BusNoticeViewMapper, BusNoticeView>
implements BusNoticeViewService{
}

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.wsnet.cargo.mapper.BusNoticeViewMapper">
<resultMap id="BaseResultMap" type="com.wsnet.cargo.entity.BusNoticeView">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="createBy" column="create_by" jdbcType="BIGINT"/>
<result property="createDate" column="create_date" jdbcType="DATE"/>
<result property="updateBy" column="update_by" jdbcType="BIGINT"/>
<result property="updateDate" column="update_date" jdbcType="DATE"/>
<result property="version" column="version" jdbcType="SMALLINT"/>
<result property="userId" column="user_id" jdbcType="BIGINT"/>
<result property="noticeId" column="notice_id" jdbcType="BIGINT"/>
</resultMap>
<sql id="Base_Column_List">
id,create_by,create_date,
update_by,update_date,version,
user_id,notice_id
</sql>
</mapper>

View File

@ -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);
}