Blame view

src/main/java/com/huaheng/api/tv/controller/TvController.java 11.3 KB
游杰 authored
1
2
3
4
package com.huaheng.api.tv.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
5
import com.huaheng.api.tv.domain.*;
游杰 authored
6
7
import com.huaheng.api.wcs.domain.WcsTask;
import com.huaheng.common.constant.QuantityConstant;
肖超群 authored
8
import com.huaheng.framework.aspectj.lang.annotation.ApiLogger;
游杰 authored
9
10
import com.huaheng.framework.web.controller.BaseController;
import com.huaheng.framework.web.domain.AjaxResult;
11
import com.huaheng.framework.web.domain.TVResult;
游杰 authored
12
13
14
15
16
17
18
19
20
21
22
23
24
import com.huaheng.pc.config.container.domain.Container;
import com.huaheng.pc.config.container.service.ContainerService;
import com.huaheng.pc.config.location.domain.Location;
import com.huaheng.pc.config.location.service.LocationService;
import com.huaheng.pc.config.material.domain.Material;
import com.huaheng.pc.config.material.service.MaterialService;
import com.huaheng.pc.config.zone.domain.Zone;
import com.huaheng.pc.config.zone.service.ZoneService;
import com.huaheng.pc.inventory.InventoryMaterialSummary.domain.InventoryMaterialSummary;
import com.huaheng.pc.inventory.InventoryMaterialSummary.service.InventoryMaterialSummaryService;
import com.huaheng.pc.inventory.inventoryDetail.domain.InventoryDetail;
import com.huaheng.pc.inventory.inventoryDetail.service.InventoryDetailService;
import com.huaheng.pc.inventory.inventoryTransaction.service.InventoryTransactionService;
25
import com.huaheng.pc.report.excelReport.mapper.ExcelReportMapper;
陈翱 authored
26
27
import com.huaheng.pc.shipment.shipmentDetail.domain.ShipmentDetailTv;
import com.huaheng.pc.shipment.shipmentDetail.mapper.ShipmentDetailMapper;
陈翱 authored
28
import com.huaheng.pc.task.taskDetail.domain.TaskDetail;
陈翱 authored
29
import com.huaheng.pc.task.taskDetail.service.TaskDetailService;
游杰 authored
30
31
32
33
34
35
import com.huaheng.pc.task.taskHeader.domain.TaskHeader;
import com.huaheng.pc.task.taskHeader.service.TaskHeaderService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
陈翱 authored
36
import java.util.*;
游杰 authored
37
38

@RestController
易文鹏 authored
39
@CrossOrigin
游杰 authored
40
41
42
43
44
45
@RequestMapping("/API/WMS/v2")
public class TvController extends BaseController {

    @Resource
    private TaskHeaderService taskHeaderService;
    @Resource
陈翱 authored
46
47
    private TaskDetailService taskDetailService;
    @Resource
游杰 authored
48
49
50
51
52
53
54
55
56
57
58
59
60
    private ContainerService containerService;
    @Resource
    private LocationService locationService;
    @Resource
    private InventoryTransactionService inventoryTransactionService;
    @Resource
    private ZoneService zoneService;
    @Resource
    private InventoryDetailService inventoryDetailService;
    @Resource
    private InventoryMaterialSummaryService inventoryMaterialSummaryService;
    @Resource
    private MaterialService materialService;
陈翱 authored
61
62
    @Resource
    private ShipmentDetailMapper shipmentDetailMapper;
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
116
117
118
119
120
121
122
123
124
125
126
127
    @Resource
    ExcelReportMapper mapper;

    //入库看板
    @PostMapping("/getTvReceiptView")
    @ResponseBody
    //@ApiLogger(apiName = "看板入库", from = "TV")
    public TVResult getTvReceiptView() {
        AllBean allBean = new AllBean();
        LambdaQueryWrapper<TaskDetail> queryWrapper = Wrappers.lambdaQuery();
        List<String> str = Arrays.asList("100", "200");
        queryWrapper.in(TaskDetail::getTaskType, str)
                .last(" and created >= CURRENT_DATE() and `status`>=100");
        List<TaskDetail> list = taskDetailService.list(queryWrapper);
        List<TopBean> topList = new ArrayList<>();
        if (!list.isEmpty()) {
            topList = taskDetailService.getTvReceiptView("1");
        }
        allBean.setTopList(topList);
        List<UpBean> upList = taskDetailService.getTvNotReceiptList("1");
        allBean.setUpList(upList);
        return TVResult.success(allBean);
    }

    //出库看板
    @PostMapping("/getTvShipmentView")
    @ResponseBody
    //@ApiLogger(apiName = "看板出库", from = "TV")
    public TVResult getTvShipmentView(@RequestBody Map<String, String> map) {
        AllBean allBean = new AllBean();
        List<String> str = Arrays.asList("300", "400");
        List<TaskDetail> list = taskDetailService.list(new LambdaQueryWrapper<TaskDetail>()
                .in(TaskDetail::getTaskType, str)
                .last(" and created >= CURRENT_DATE() and `status`>=100"));
        List<TopBean> topList = new ArrayList<>();
        if (!list.isEmpty()) {
            topList = taskDetailService.getTvReceiptView("2");//出库物料统计
        }
        allBean.setTopList(topList);
        List<UpBean> upList = taskDetailService.getTvNotReceiptList("2");//获取未完成订单看板
        allBean.setUpList(upList);
        String par = map.get("par");
        List<ShipmentDetailTv> portList = shipmentDetailMapper.getTvOutList(par);//当前站台出库明细
        allBean.setPortList(portList);
        return TVResult.success(allBean);
    }


    //二期新入库看板,显示入库次数和入库数量
    @PostMapping("/getTvReceiptFrequencyAndQty")
    @ResponseBody
    public TVResult getTvReceiptFrequencyAndQty() {

        //数量
        String sql = "SELECT a.click_date AS DATE,ifnull( b.taskQty, 0 ) AS qty FROM(SELECT curdate() AS click_date UNION ALL SELECT date_sub( curdate(), INTERVAL 1 DAY ) AS click_date UNION ALL SELECT date_sub( curdate(), INTERVAL 2 DAY ) AS click_date UNION ALL SELECT date_sub( curdate(), INTERVAL 3 DAY ) AS click_date UNION ALL SELECT date_sub( curdate(), INTERVAL 4 DAY ) AS click_date UNION ALL SELECT date_sub( curdate(), INTERVAL 5 DAY ) AS click_date UNION ALL SELECT date_sub( curdate(), INTERVAL 6 DAY ) AS click_date ) a LEFT JOIN (SELECT DATE ( h.completeTime ) AS completeTime,SUM( d.qty ) AS taskQty  FROM task_detail d JOIN task_header h ON d.taskId = h.id WHERE h.completeTime >= DATE_SUB( CURDATE(), INTERVAL 7 DAY ) AND h.STATUS = 100 AND h.internalTaskType=100 GROUP BY DATE ( h.completeTime )) b ON a.click_date = b.completeTime ORDER BY a.click_date;";
        List<LinkedHashMap<String, Object>> list = mapper.selectCommon(sql);
        //次数
        String sql2 = "SELECT a.click_date AS DATE,ifnull( b.taskCount, 0 ) AS count FROM(SELECT curdate() AS click_date UNION ALL SELECT date_sub( curdate(), INTERVAL 1 DAY ) AS click_date UNION ALL SELECT date_sub( curdate(), INTERVAL 2 DAY ) AS click_date UNION ALL SELECT date_sub( curdate(), INTERVAL 3 DAY ) AS click_date UNION ALL SELECT date_sub( curdate(), INTERVAL 4 DAY ) AS click_date UNION ALL SELECT date_sub( curdate(), INTERVAL 5 DAY ) AS click_date UNION ALL SELECT date_sub( curdate(), INTERVAL 6 DAY ) AS click_date ) a LEFT JOIN (SELECT DATE ( h.completeTime ) AS completeTime,COUNT( DISTINCT h.id ) AS taskCount FROM task_detail d JOIN task_header h ON d.taskId = h.id WHERE h.completeTime >= DATE_SUB( CURDATE(), INTERVAL 7 DAY ) AND h.STATUS = 100 AND h.internalTaskType=100 GROUP BY DATE ( h.completeTime )) b ON a.click_date = b.completeTime ORDER BY a.click_date;";
        List<LinkedHashMap<String, Object>> list2 = mapper.selectCommon(sql2);

        ReceiptFrequencyAndQty resultData = new ReceiptFrequencyAndQty();
        resultData.setReceiptQty(list);
        resultData.setReceiptFrequency(list2);
        return TVResult.success(resultData);
    }
游杰 authored
128
129

    @PostMapping("/getTvView")
130
    //@ApiLogger(apiName = "获取电视信息", from="TV")
游杰 authored
131
    @ResponseBody
132
    public TVResult getTvView(@RequestBody WcsTask wcsTask) {
133
        String area = wcsTask.getArea();
易文鹏 authored
134
135
        List<TaskHeader> taskHeaderList = taskHeaderService.list(new LambdaQueryWrapper<TaskHeader>()
                .eq(TaskHeader::getArea, area)
易文鹏 authored
136
                .lt(TaskHeader::getStatus, QuantityConstant.TASK_STATUS_COMPLETED)
易文鹏 authored
137
138
139
140
                .orderByDesc(TaskHeader::getId));

        //写入物料编码
        if (taskHeaderList != null && !taskHeaderList.isEmpty()) {
141
            for (TaskHeader taskHeader : taskHeaderList) {
易文鹏 authored
142
143
144
                String materialCode = taskHeader.getMaterialCode();
                String warehouseCode = taskHeader.getWarehouseCode();
                Material material = materialService.getMaterialByCode(materialCode, warehouseCode);
145
                if (material != null) {
易文鹏 authored
146
147
148
149
                    taskHeader.setMaterialCode(material.getName());
                }
            }
        }
游杰 authored
150
易文鹏 authored
151
152
153
        //获取指定库区的空托盘数量
        List<Container> containerEmptyList = containerService.list(new LambdaQueryWrapper<Container>()
                .eq(Container::getArea, area)
易文鹏 authored
154
                .eq(Container::getStatus, QuantityConstant.STATUS_CONTAINER_EMPTY)
易文鹏 authored
155
                .ne(Container::getLocationCode, ""));
游杰 authored
156
157
        int containerEmptySize = containerEmptyList.size();
易文鹏 authored
158
159
160
161
162
163
164
165
166
167
168
169
        //获取指定库区的有货托盘数量
        //List<Container> manyEmptyList = containerService.list(new LambdaQueryWrapper<Container>()
        //        .eq(Container::getArea, area)
        //        .eq(Container::getStatus, QuantityConstant.STATUS_CONTAINER_MANY)
        //        .ne(Container::getLocationCode, ""));
        //int manyEmptyListSize = manyEmptyList.size();
        //空托盘的数量+有货托盘数量*6   (有货托盘数量这个项目好像没有啊,所以直接返回空托盘数量)
        //containerEmptySize = containerEmptySize + manyEmptyListSize * 6;

        //获取指定库区的有货托盘数量
        List<Container> containerSomeList = containerService.list(new LambdaQueryWrapper<Container>()
                .eq(Container::getArea, area)
游杰 authored
170
                .eq(Container::getStatus, QuantityConstant.STATUS_CONTAINER_SOME)
易文鹏 authored
171
                .ne(Container::getLocationCode, ""));
游杰 authored
172
173
        int containerSomeSize = containerSomeList.size();
易文鹏 authored
174
175
        //指定库区总库位数
        List<Location> locationList = locationService.list(new LambdaQueryWrapper<Location>().eq(Location::getArea, area));
游杰 authored
176
177
        int totalLocationSize = locationList.size();
易文鹏 authored
178
179
180
181
182

        //获取指定区域的所有库存数
        Zone zone = zoneService.getOne(new LambdaQueryWrapper<Zone>().eq(Zone::getArea, area));
        List<InventoryDetail> inventoryDetailList = inventoryDetailService.list(new LambdaQueryWrapper<InventoryDetail>()
                .eq(InventoryDetail::getZoneCode, zone.getCode()));
游杰 authored
183
184
185
        int inventorySize = inventoryDetailList.size();
易文鹏 authored
186
187
188
        //库存物料汇总
        List<InventoryMaterialSummary> list = inventoryMaterialSummaryService.list(new LambdaQueryWrapper<InventoryMaterialSummary>()
                .eq(InventoryMaterialSummary::getZoneCode, zone.getCode()));
游杰 authored
189
190
191
192
193
194
195
196
197
198
199
200
201
        if (list == null) {
            list = Collections.emptyList();
        }
        //筛选库存汇总数据的专用方法
        List<InventoryMaterialSummary> details = inventoryMaterialSummaryService.duplicateRemoval(list);

        TvBean tvBean = new TvBean();
        tvBean.setDetails(details);
        tvBean.setContainerEmptySize(containerEmptySize);
        tvBean.setContainerSomeSize(containerSomeSize);
        tvBean.setTotalLocationSize(totalLocationSize);
        tvBean.setTaskHeaderList(taskHeaderList);
        tvBean.setInventorySize(inventorySize);
202
        return TVResult.success(tvBean);
游杰 authored
203
    }
陈翱 authored
204
陈翱 authored
205
206
207
    @PostMapping("/getTvPortShipmentView")
    @ApiOperation("获取出站口出库信息")
    @ResponseBody
易文鹏 authored
208
    //@ApiLogger(apiName = "获取出站口出库信息", from = "TV")
209
    public TVResult getTvPortShipmentView(@RequestBody Map<String, String> map) {
陈翱 authored
210
        String par = map.get("par");
211
        List<ShipmentDetailTv> upList = shipmentDetailMapper.getTvOutList(par);
212
        return TVResult.success(upList);
陈翱 authored
213
    }
游杰 authored
214
}