maven
3 天以前 2a9c3934bb093c978a54a1c3e220e6a120855e77
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
package com.ruoyi.sales.controller;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.sales.mapper.ShipmentApprovalMapper;
import com.ruoyi.sales.mapper.ShippingInfoMapper;
import com.ruoyi.sales.pojo.SalesLedgerProduct;
import com.ruoyi.sales.pojo.ShipmentApproval;
import com.ruoyi.sales.pojo.ShippingInfo;
import com.ruoyi.sales.service.ISalesLedgerProductService;
import com.ruoyi.sales.service.ShipmentApprovalService;
import com.ruoyi.sales.service.ShippingInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
 
import javax.servlet.http.HttpServletResponse;
import java.util.List;
 
@RestController
@RequestMapping("/shipmentApproval")
@Api(tags = "发货审批管理")
public class ShipmentApprovalController extends BaseController {
 
    @Autowired
    private ShipmentApprovalService shipmentApprovalService;
    @Autowired
    private ShipmentApprovalMapper shipmentApprovalMapper;
 
    @Autowired
    private ISalesLedgerProductService salesLedgerProductService;
 
    @GetMapping("/listPage")
    @ApiOperation("发货审批列表")
    public AjaxResult listPage(Page page, ShipmentApproval req) {
        IPage<ShipmentApproval> listPage = shipmentApprovalService.listPage(page,req);
        return AjaxResult.success(listPage);
    }
 
    @PostMapping("/update")
    @ApiOperation("发货审批,更新发货审批状态")
    @Transactional(rollbackFor = Exception.class)
    public AjaxResult update(@RequestBody ShipmentApproval req) {
        ShipmentApproval shipmentApproval = shipmentApprovalMapper.selectById(req.getId());
        if (shipmentApproval == null) {
            return AjaxResult.error("发货审批不存在");
        }
 
        shipmentApproval.setApproveStatus(req.getApproveStatus());
        boolean update = shipmentApprovalService.updateById(shipmentApproval);
        if(update){
            SalesLedgerProduct salesLedgerProduct = salesLedgerProductService.getById(shipmentApproval.getSalesLedgerProductId());
            salesLedgerProduct.setApproveStatus(req.getApproveStatus());
            salesLedgerProductService.updateById(salesLedgerProduct);
        }
        return update ? AjaxResult.success() : AjaxResult.error();
    }
 
 
    /**
     * 导出发货信息管理
     */
    @PostMapping("/export")
    @ApiOperation("导出发货审批")
    public void export(HttpServletResponse response) {
        List<ShipmentApproval> list = shipmentApprovalService.list(null);
        ExcelUtil<ShipmentApproval> util = new ExcelUtil<ShipmentApproval>(ShipmentApproval.class);
        util.exportExcel(response, list, "发货审批");
    }
 
}