|
|
@@ -0,0 +1,124 @@
|
|
|
+package com.yc.ship.module.trade.controller.admin.orderjzdetail;
|
|
|
+
|
|
|
+import com.yc.ship.module.product.dal.dataobject.voyage.VoyageDO;
|
|
|
+import com.yc.ship.module.product.service.voyage.VoyageService;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
+import io.swagger.v3.oas.annotations.Parameter;
|
|
|
+import io.swagger.v3.oas.annotations.Operation;
|
|
|
+
|
|
|
+import javax.annotation.security.PermitAll;
|
|
|
+import javax.validation.constraints.*;
|
|
|
+import javax.validation.*;
|
|
|
+import javax.servlet.http.*;
|
|
|
+import java.util.*;
|
|
|
+import java.io.IOException;
|
|
|
+
|
|
|
+import com.yc.ship.framework.common.pojo.PageParam;
|
|
|
+import com.yc.ship.framework.common.pojo.PageResult;
|
|
|
+import com.yc.ship.framework.common.pojo.CommonResult;
|
|
|
+import com.yc.ship.framework.common.util.object.BeanUtils;
|
|
|
+
|
|
|
+import static com.yc.ship.framework.common.pojo.CommonResult.success;
|
|
|
+
|
|
|
+import com.yc.ship.framework.excel.core.util.ExcelUtils;
|
|
|
+
|
|
|
+import com.yc.ship.framework.apilog.core.annotation.ApiAccessLog;
|
|
|
+
|
|
|
+import static com.yc.ship.framework.apilog.core.enums.OperateTypeEnum.*;
|
|
|
+
|
|
|
+import com.yc.ship.module.trade.controller.admin.orderjzdetail.vo.*;
|
|
|
+import com.yc.ship.module.trade.dal.dataobject.orderjzdetail.OrderJzDetailDO;
|
|
|
+import com.yc.ship.module.trade.service.orderjzdetail.OrderJzDetailService;
|
|
|
+
|
|
|
+@Tag(name = "管理后台 - 订单接站人员名单")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/trade/order-jz-detail")
|
|
|
+@Validated
|
|
|
+public class OrderJzDetailController {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private OrderJzDetailService orderJzDetailService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private VoyageService voyageService;
|
|
|
+
|
|
|
+ @PostMapping("/create")
|
|
|
+ @Operation(summary = "创建订单接站人员名单")
|
|
|
+ @PreAuthorize("@ss.hasPermission('trade:order-jz-detail:create')")
|
|
|
+ public CommonResult<Long> createOrderJzDetail(@Valid @RequestBody OrderJzDetailSaveReqVO createReqVO) {
|
|
|
+ return success(orderJzDetailService.createOrderJzDetail(createReqVO));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PutMapping("/update")
|
|
|
+ @Operation(summary = "更新订单接站人员名单")
|
|
|
+ @PreAuthorize("@ss.hasPermission('trade:order-jz-detail:update')")
|
|
|
+ public CommonResult<Boolean> updateOrderJzDetail(@Valid @RequestBody OrderJzDetailSaveReqVO updateReqVO) {
|
|
|
+ orderJzDetailService.updateOrderJzDetail(updateReqVO);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @DeleteMapping("/delete")
|
|
|
+ @Operation(summary = "删除订单接站人员名单")
|
|
|
+ @Parameter(name = "id", description = "编号", required = true)
|
|
|
+ @PreAuthorize("@ss.hasPermission('trade:order-jz-detail:delete')")
|
|
|
+ public CommonResult<Boolean> deleteOrderJzDetail(@RequestParam("id") Long id) {
|
|
|
+ orderJzDetailService.deleteOrderJzDetail(id);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/get")
|
|
|
+ @Operation(summary = "获得订单接站人员名单")
|
|
|
+ @Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
|
+ @PreAuthorize("@ss.hasPermission('trade:order-jz-detail:query')")
|
|
|
+ public CommonResult<OrderJzDetailRespVO> getOrderJzDetail(@RequestParam("id") Long id) {
|
|
|
+ OrderJzDetailDO orderJzDetail = orderJzDetailService.getOrderJzDetail(id);
|
|
|
+ return success(BeanUtils.toBean(orderJzDetail, OrderJzDetailRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/page")
|
|
|
+ @Operation(summary = "获得订单接站人员名单分页")
|
|
|
+ @PreAuthorize("@ss.hasPermission('trade:order-jz-detail:query')")
|
|
|
+ public CommonResult<PageResult<OrderJzDetailRespVO>> getOrderJzDetailPage(@Valid OrderJzDetailPageReqVO pageReqVO) {
|
|
|
+ PageResult<OrderJzDetailDO> pageResult = orderJzDetailService.getOrderJzDetailPage(pageReqVO);
|
|
|
+ return success(BeanUtils.toBean(pageResult, OrderJzDetailRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/export-excel")
|
|
|
+ @Operation(summary = "导出订单接站人员名单 Excel")
|
|
|
+ @ApiAccessLog(operateType = EXPORT)
|
|
|
+// @PreAuthorize("@ss.hasPermission('trade:order-jz-detail:query')")
|
|
|
+ public void exportOrderJzDetailExcel(@Valid OrderJzDetailPageReqVO pageReqVO,
|
|
|
+ HttpServletResponse response) throws IOException {
|
|
|
+ if (StringUtils.isEmpty(pageReqVO.getVoyageId())) {
|
|
|
+ throw new RuntimeException("航次编号不能为空");
|
|
|
+ }
|
|
|
+ VoyageDO voyageDO = voyageService.getVoyage(Long.valueOf(pageReqVO.getVoyageId()));
|
|
|
+ if (voyageDO == null) {
|
|
|
+ throw new RuntimeException("航次信息不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
+ List<OrderJzDetailDO> list = orderJzDetailService.selectPageByVoyageId(pageReqVO.getVoyageId());
|
|
|
+ // 导出 Excel
|
|
|
+ List<OrderJzDetailRespVO> exportList = BeanUtils.toBean(list, OrderJzDetailRespVO.class);
|
|
|
+ exportList.forEach(vo -> {
|
|
|
+ vo.setVoyage(voyageDO.getName());
|
|
|
+ });
|
|
|
+ ExcelUtils.write(response, "订单接站人员名单.xls", "数据", OrderJzDetailRespVO.class,
|
|
|
+ BeanUtils.toBean(list, OrderJzDetailRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping("/sign")
|
|
|
+ @PermitAll
|
|
|
+ public CommonResult<Long> createOrderJzDetail(@Valid @RequestBody List<OrderJzDetailSaveReqVO> createReqVOList) {
|
|
|
+ return success(orderJzDetailService.createOrderJzDetail(createReqVOList));
|
|
|
+ }
|
|
|
+}
|