| | |
| | | package com.zy.asrs.controller; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.plugins.Page; |
| | | import com.core.annotations.AppAuth; |
| | | import com.core.common.*; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.param.OpenOrderCompleteParam; |
| | | import com.zy.asrs.entity.param.OpenOrderPakinParam; |
| | | import com.zy.asrs.entity.param.OpenOrderPakoutParam; |
| | | import com.zy.asrs.service.OpenService; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.AxisBean; |
| | | import com.zy.asrs.entity.param.*; |
| | | import com.zy.asrs.mapper.ReportQueryMapper; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.common.model.DetlDto; |
| | | import com.zy.common.web.BaseController; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * Created by vincent on 2022/4/8 |
| | |
| | | |
| | | @Autowired |
| | | private OpenService openService; |
| | | @Autowired |
| | | private MatService matService; |
| | | @Autowired |
| | | private LocMastService locMastService; |
| | | @Autowired |
| | | private LocDetlService locDetlService; |
| | | @Autowired |
| | | private ReportQueryMapper reportQueryMapper; |
| | | @Autowired |
| | | private WrkMastService wrkMastService; |
| | | @Autowired |
| | | private WrkDetlService wrkDetlService; |
| | | |
| | | @PostMapping("/order/matSync/default/v2") |
| | | // @AppAuth(memo = "商品信息同步接口") |
| | | public synchronized R syncMatInfoV2(@RequestHeader(required = false) String appkey, |
| | | @RequestBody(required = false) MatSyncParam.MatParam param, |
| | | HttpServletRequest request){ |
| | | |
| | | auth(appkey, param, request); |
| | | if (Cools.isEmpty(param)) { |
| | | return R.parse(BaseRes.PARAM); |
| | | } |
| | | MatSyncParam matSyncParam = new MatSyncParam(); |
| | | List<MatSyncParam.MatParam> objects = new ArrayList<>(); |
| | | objects.add(param); |
| | | matSyncParam.matDetails = objects; |
| | | openService.syncMat(matSyncParam); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @PostMapping("/order/matSync/default/v1") |
| | | // @AppAuth(memo = "商品信息同步接口") |
| | | public synchronized R syncMatInfo(@RequestHeader(required = false) String appkey, |
| | | @RequestBody(required = false) MatSyncParam param, |
| | | HttpServletRequest request){ |
| | | auth(appkey, param, request); |
| | | if (Cools.isEmpty(param)) { |
| | | return R.parse(BaseRes.PARAM); |
| | | } |
| | | openService.syncMat(param); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /****************************************************************************/ |
| | | /********************************* 打包上线 **********************************/ |
| | | /****************************************************************************/ |
| | | |
| | | |
| | | @PostMapping("/order/pakin/new/package/v1") |
| | | public synchronized R pakinOrderPackage(@RequestHeader(required = false) String appkey, |
| | | @RequestParam(required = false) String barcode) { |
| | | auth(appkey, barcode); |
| | | if (Cools.isEmpty(barcode)) { |
| | | return R.parse(BaseRes.PARAM); |
| | | } |
| | | openService.packageUp(barcode); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | // @PostMapping("/order/pakin/new/package/v1") |
| | | // @AppAuth(memo = "打包上线接口") |
| | | // public synchronized R pakinOrderPackage(@RequestHeader(required = false) String appkey, |
| | | // @RequestBody(required = false) PackParam param, |
| | | // HttpServletRequest request) { |
| | | // auth(appkey, param, request); |
| | | // if (Cools.isEmpty(param)) { |
| | | // return R.parse(BaseRes.PARAM); |
| | | // } |
| | | // openService.packageUp(param); |
| | | // return R.ok(); |
| | | // } |
| | | |
| | | /** |
| | | * 添加入库单 |
| | | */ |
| | | @PostMapping("/order/pakin/new/default/v1") |
| | | @PostMapping("/order/pakin/default/v1") |
| | | public synchronized R pakinOrderCreate(@RequestHeader(required = false) String appkey, |
| | | @RequestBody OpenOrderPakinParam param) { |
| | | auth(appkey, param); |
| | | @RequestBody OpenOrderPakinParam param, |
| | | HttpServletRequest request) { |
| | | auth(appkey, param, request); |
| | | if (Cools.isEmpty(param)) { |
| | | return R.parse(BaseRes.PARAM); |
| | | } |
| | |
| | | /** |
| | | * 入库单回写 |
| | | */ |
| | | @PostMapping("/order/pakin/complete/default/v1") |
| | | // @PostMapping("/order/pakin/complete/default/v1") |
| | | public synchronized R orderPakinComplete(@RequestHeader(required = false) String appkey, |
| | | @RequestBody(required = false) OpenOrderCompleteParam param) { |
| | | auth(appkey, param); |
| | | @RequestBody(required = false) OpenOrderCompleteParam param, |
| | | HttpServletRequest request) { |
| | | auth(appkey, param, request); |
| | | return R.ok().add(openService.pakinOrderComplete(param)); |
| | | } |
| | | |
| | | /** |
| | | * 添加出库单 |
| | | */ |
| | | @PostMapping("/order/pakout/new/default/v1") |
| | | @PostMapping("/order/pakout/default/v1") |
| | | @AppAuth(memo = "添加订单出库") |
| | | public synchronized R pakoutOrderCreate(@RequestHeader(required = false) String appkey, |
| | | @RequestBody OpenOrderPakoutParam param) { |
| | | auth(appkey, param); |
| | | @RequestBody OpenOrderPakoutParam param, |
| | | HttpServletRequest request) { |
| | | auth(appkey, param, request); |
| | | if (Cools.isEmpty(param)) { |
| | | return R.parse(BaseRes.PARAM); |
| | | } |
| | |
| | | if (Cools.isEmpty(param.getOrderType())) { |
| | | return R.error("单据类型[orderType]不能为空"); |
| | | } |
| | | if (Cools.isEmpty(param.getOrderDetails())) { |
| | | if (Cools.isEmpty(param.getMatList())) { |
| | | return R.error("单据明细[orderDetails]不能为空"); |
| | | } |
| | | openService.pakoutOrderCreate(param); |
| | |
| | | /** |
| | | * 出库单回写 |
| | | */ |
| | | @PostMapping("/order/pakout/complete/default/v1") |
| | | // @PostMapping("/order/pakout/complete/default/v1") |
| | | public synchronized R orderPakoutComplete(@RequestHeader(required = false) String appkey, |
| | | @RequestBody(required = false) OpenOrderCompleteParam param) { |
| | | auth(appkey, param); |
| | | @RequestBody(required = false) OpenOrderCompleteParam param, |
| | | HttpServletRequest request) { |
| | | auth(appkey, param, request); |
| | | return R.ok().add(openService.pakoutOrderComplete(param)); |
| | | } |
| | | |
| | |
| | | * 库存统计 |
| | | */ |
| | | @RequestMapping("/stock/default/v1") |
| | | public R queryStock(@RequestHeader(required = false) String appkey) { |
| | | auth(appkey, null); |
| | | public R queryStock(@RequestHeader(required = false) String appkey, |
| | | HttpServletRequest request) { |
| | | auth(appkey, null, request); |
| | | return R.ok().add(openService.queryStock()); |
| | | } |
| | | |
| | | |
| | | private void auth(String appkey, Object obj) { |
| | | log.info("{}接口被访问!appkey:{},请求数据:{}", "open/sensorType/list/auth/v1", appkey, JSON.toJSONString(obj)); |
| | | private void auth(String appkey, Object obj, HttpServletRequest request) { |
| | | log.info("{}接口被访问;appkey:{};请求数据:{}", "open/sensorType/list/auth/v1", appkey, JSON.toJSONString(obj)); |
| | | request.setAttribute("cache", obj); |
| | | if (!auth) { |
| | | return; |
| | | } |
| | |
| | | System.out.println(JSON.toJSONString(param1)); |
| | | } |
| | | |
| | | /*************************************电视机程序***********************************************/ |
| | | |
| | | @GetMapping("/locDetl/statistics") |
| | | public R locDetlStatistics(){ |
| | | HashMap<String, Object> param = new HashMap<>(); |
| | | Page<LocDetl> stockStatis = locDetlService.getStockStatis(toPage(1, 100, param, LocDetl.class)); |
| | | for (LocDetl locDetl : stockStatis.getRecords()) { |
| | | Mat mat = matService.selectByMatnr(locDetl.getMatnr()); |
| | | if (mat != null) { |
| | | locDetl.sync(mat); |
| | | } |
| | | } |
| | | return R.ok(stockStatis); |
| | | } |
| | | |
| | | @GetMapping("/line/charts") |
| | | public R locIoLineCharts(){ |
| | | Map<String,Object> map=new HashMap<String, Object>(); |
| | | List<AxisBean> list = new ArrayList<AxisBean>(); |
| | | |
| | | List<WorkChartAxis> listChart = reportQueryMapper.getChartAxis(); |
| | | |
| | | if(listChart!=null) { |
| | | ArrayList<Integer> data1 = new ArrayList<Integer>(); |
| | | ArrayList<Integer> data2 = new ArrayList<Integer>(); |
| | | |
| | | SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.add(Calendar.DATE, -12); |
| | | for(int i=0;i<12;i++) { |
| | | boolean flag = true; |
| | | calendar.add(Calendar.DATE, 1); |
| | | String str = sf.format(calendar.getTime()); |
| | | for(WorkChartAxis workChart : listChart) { |
| | | if(str.equals(workChart.getYmd())) { |
| | | data1.add(workChart.getInqty()); |
| | | data2.add(workChart.getOutqty()); |
| | | flag = false; |
| | | break; |
| | | } |
| | | } |
| | | if(flag) { |
| | | data1.add(0); |
| | | data2.add(0); |
| | | } |
| | | } |
| | | AxisBean inqty = new AxisBean(); |
| | | inqty.setName("入库数量"); |
| | | Integer[] array1 = new Integer[data1.size()]; |
| | | inqty.setData(data1.toArray(array1)); |
| | | list.add(inqty); |
| | | AxisBean outqty = new AxisBean(); |
| | | outqty.setName("出库数量"); |
| | | Integer[] array2 = new Integer[data2.size()]; |
| | | outqty.setData(data2.toArray(array2)); |
| | | list.add(outqty); |
| | | } |
| | | map.put("rows",list); |
| | | return R.ok(map); |
| | | } |
| | | |
| | | /** |
| | | * 库存信息查询接口 |
| | | */ |
| | | @GetMapping("/queryLoc") |
| | | public synchronized R queryLoc() { |
| | | List<Map<String, Object>> pie = new ArrayList<>(); |
| | | LocChartPie locUseRate = reportQueryMapper.getLocUseRate(); |
| | | |
| | | if (locUseRate != null) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("name", "在库"); |
| | | map.put("value", locUseRate.getFqty()); |
| | | pie.add(map); |
| | | |
| | | Map<String, Object> map1 = new HashMap<>(); |
| | | map1.put("name", "空"); |
| | | map1.put("value", locUseRate.getOqty()); |
| | | pie.add(map1); |
| | | |
| | | Map<String, Object> map2 = new HashMap<>(); |
| | | map2.put("name", "使用"); |
| | | map2.put("value", locUseRate.getUqty()); |
| | | pie.add(map2); |
| | | |
| | | Map<String, Object> map3 = new HashMap<>(); |
| | | map3.put("name", "禁用"); |
| | | map3.put("value", locUseRate.getXqty()); |
| | | pie.add(map3); |
| | | } |
| | | |
| | | // 总库位数 |
| | | Integer total = (int) Arith.add(0, locUseRate.getFqty(), locUseRate.getOqty(), locUseRate.getUqty(), locUseRate.getXqty()); |
| | | // 使用中 |
| | | Integer used = locUseRate.getFqty() + locUseRate.getUqty(); |
| | | // 库位使用率 |
| | | double usedDivides = Arith.divides(3, used, total); |
| | | double usedPr = Arith.multiplys(1, usedDivides, 100); |
| | | |
| | | return R.ok( |
| | | Cools.add("pie", pie) |
| | | .add("stockCount", locUseRate.getFqty()) |
| | | .add("emptyCount", locUseRate.getOqty()) |
| | | .add("disableCount", locUseRate.getXqty()) |
| | | .add("total", total) |
| | | .add("used", used) |
| | | .add("usedPr", usedPr) |
| | | ); |
| | | } |
| | | |
| | | /** |
| | | * 任务查询接口 |
| | | */ |
| | | @PostMapping("/queryTask") |
| | | public synchronized R queryTask(@RequestBody QueryTaskParam param) { |
| | | if (Cools.isEmpty(param)) { |
| | | return R.parse(BaseRes.PARAM); |
| | | } |
| | | if (Cools.isEmpty(param.getTaskNo())) { |
| | | return R.error("任务号[taskNo]不能为空"); |
| | | } |
| | | WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wrk_no", param.getTaskNo())); |
| | | if (wrkMast == null) { |
| | | return R.error("任务不存在"); |
| | | } |
| | | |
| | | List<WrkDetl> wrkDetls = wrkDetlService.selectByWrkNo(Integer.valueOf(param.getTaskNo())); |
| | | |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | map.put("taskNo", param.getTaskNo()); |
| | | map.put("ioType", wrkMast.getIoType()); |
| | | map.put("wrkDetls", wrkDetls); |
| | | return R.ok().add(map); |
| | | } |
| | | } |