huminmin
昨天 49133ae6eafda4d6bd86ed9a9241177a12a47348
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
package com.ruoyi.sales.controller;
 
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.approve.service.impl.ApproveProcessServiceImpl;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.domain.R;
import com.ruoyi.sales.dto.ShippingInfoDto;
import com.ruoyi.sales.mapper.ShippingInfoMapper;
import com.ruoyi.sales.pojo.ShippingInfo;
import com.ruoyi.sales.service.ShippingInfoService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import lombok.AllArgsConstructor;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
 
import java.io.IOException;
import java.util.List;
 
/**
 * @author :yys
 * @date : 2025/10/22 9:34
 */
@RestController
@RequestMapping("/shippingInfo")
@Tag(name = "发货信息管理")
@AllArgsConstructor
public class ShippingInfoController extends BaseController {
 
    private ShippingInfoService shippingInfoService;
    private ApproveProcessServiceImpl approveProcessService;
    private ShippingInfoMapper shippingInfoMapper;
 
 
    @GetMapping("/listPage")
    @Operation(summary = "发货信息列表")
    public AjaxResult listPage(Page page, ShippingInfo req) {
        IPage<ShippingInfoDto> listPage = shippingInfoService.listPage(page,req);
        return AjaxResult.success(listPage);
    }
 
    @PostMapping("/add")
    @Operation(summary = "添加发货信息")
    @Transactional(rollbackFor = Exception.class)
    @Log(title = "发货信息管理", businessType = BusinessType.INSERT)
    public AjaxResult add(@RequestBody ShippingInfoDto req) throws Exception {
        return AjaxResult.success(shippingInfoService.addReq(req) ? "添加成功" : "添加失败");
    }
 
    @Operation(summary = "发货扣库存")
    @PostMapping("/deductStock")
    @Transactional(rollbackFor = Exception.class)
    @Log(title = "发货信息管理", businessType = BusinessType.UPDATE)
    public AjaxResult deductStock(@RequestBody ShippingInfoDto req) throws IOException {
        return shippingInfoService.deductStock( req) ? AjaxResult.success() : AjaxResult.error();
    }
 
    @PostMapping("/update")
    @Operation(summary = "修改发货信息")
    @Transactional(rollbackFor = Exception.class)
    @Log(title = "发货信息管理", businessType = BusinessType.UPDATE)
    public AjaxResult update(@RequestBody ShippingInfo req) {
        ShippingInfo byId = shippingInfoService.getById(req.getId());
        if (byId == null) {
            return AjaxResult.error("发货信息不存在");
        }
        boolean update = shippingInfoService.updateById(req);
        return update ? AjaxResult.success() : AjaxResult.error();
    }
 
    @DeleteMapping("/delete")
    @Operation(summary = "删除发货信息")
    @Transactional(rollbackFor = Exception.class)
    @Log(title = "发货信息管理", businessType = BusinessType.DELETE)
    public AjaxResult delete(@RequestBody List<Long> ids) {
 
        return shippingInfoService.delete(ids) ? AjaxResult.success("删除成功") : AjaxResult.error("删除失败");
    }
 
    /**
     * 导出发货信息管理
     */
    @PostMapping("/export")
    @Operation(summary = "导出发货信息")
    public void export(HttpServletResponse response) {
        List<ShippingInfo> list = shippingInfoMapper.listAll();
        ExcelUtil<ShippingInfo> util = new ExcelUtil<ShippingInfo>(ShippingInfo.class);
        util.exportExcel(response, list, "发货信息");
    }
 
 
    @GetMapping("/getByCustomerName")
    @Operation(summary = "通过客户名称查询关联的发货单号")
    public AjaxResult getByCustomerName(String customerName) {
        return AjaxResult.success(shippingInfoService.getShippingInfoByCustomerName(customerName));
    }
 
    @GetMapping("/getDateil/{id}")
    @Operation(summary = "通过id查询详情")
    public R getDateil(@PathVariable("id") Long id) {
        return R.ok(shippingInfoService.getDetail(id));
    }
 
    @GetMapping("/getDateilByShippingNo")
    @Operation(summary = "通过发货单号查询详情")
    public R getDateilByShippingNo(String shippingNo) {
        return R.ok(shippingInfoService.getDateilByShippingNo(shippingNo));
    }
}