| | |
| | | |
| | | 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.domain.dto.AxisBean; |
| | | import com.zy.asrs.domain.dto.WorkChartAxis; |
| | | import com.zy.asrs.domain.vo.LocChartPie; |
| | | import com.zy.asrs.entity.LocDetl; |
| | | import com.zy.asrs.entity.Mat; |
| | | import com.zy.asrs.entity.WrkDetl; |
| | | import com.zy.asrs.entity.WrkMast; |
| | | import com.zy.asrs.entity.param.*; |
| | | import com.zy.asrs.service.OpenService; |
| | | import com.zy.asrs.service.WorkService; |
| | | import com.zy.asrs.service.WrkMastService; |
| | | 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.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | /** |
| | | * Created by vincent on 2022/4/8 |
| | |
| | | private WrkMastService wrkMastService; |
| | | @Autowired |
| | | private WorkService workService; |
| | | @Autowired |
| | | private WrkDetlService wrkDetlService; |
| | | @Autowired |
| | | private ReportQueryMapper reportQueryMapper; |
| | | @Autowired |
| | | private LocDetlService locDetlService; |
| | | @Autowired |
| | | private MatService matService; |
| | | |
| | | /** |
| | | * 任务查询接口 |
| | | */ |
| | | @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.selectByTaskNo(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); |
| | | } |
| | | |
| | | /** |
| | | * 库存信息查询接口 |
| | | */ |
| | | @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) |
| | | ); |
| | | } |
| | | |
| | | @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("/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); |
| | | } |
| | | |
| | | @PostMapping("/order/matSync/default/v1") |
| | | @AppAuth(memo = "商品信息同步接口") |
| | |
| | | wrkMast.setWrkSts(4L);//4.任务结束 |
| | | } else if (wrkMast.getIoType() == 103 || wrkMast.getIoType() == 107 || wrkMast.getIoType() == 110) { |
| | | wrkMast.setWrkSts(14L); |
| | | }else if(wrkMast.getIoType() == 11) { |
| | | wrkMast.setWrkSts(4L); |
| | | } |
| | | wrkMast.setModiTime(new Date()); |
| | | if (wrkMastService.update(wrkMast,new EntityWrapper<WrkMast>().eq("wrk_no",wrkMast.getWrkNo()))) { |
| | |
| | | * 出库---目的地搬离 |
| | | */ |
| | | @RequestMapping("/leave/task") |
| | | public HashMap<String, Object> leaveTask(@RequestBody HashMap<String, Object> map) { |
| | | String taskNo = map.get("TaskNo") + ""; |
| | | public R leaveTask(@RequestBody HashMap<String, Object> map) { |
| | | String taskNo = String.valueOf(map.get("taskNo")); |
| | | String status = String.valueOf(map.get("status")); |
| | | HashMap<String, Object> map1 = new HashMap<>(); |
| | | if (Cools.isEmpty(taskNo)) { |
| | | map1.put("ReturnStatus", "1"); |
| | | map1.put("ErrorMessage", "任务号为空"); |
| | | return R.error("任务号为空"); |
| | | } else { |
| | | |
| | | WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wrk_no", Integer.valueOf(taskNo))); |
| | | if (wrkMast == null) { |
| | | map1.put("ReturnStatus", "1"); |
| | | map1.put("ErrorMessage", "没有找到该任务号:" + taskNo); |
| | | return map1; |
| | | return R.error("没有找到该任务号:" + taskNo); |
| | | } |
| | | if (wrkMast.getIoType() != 101) { |
| | | map1.put("ReturnStatus", "0"); |
| | | map1.put("ErrorMessage", ""); |
| | | return map1; |
| | | } else { |
| | | wrkMast.setWrkSts(14L);//出库到站点上 |
| | | wrkMast.setModiTime(new Date()); |
| | | if (wrkMastService.updateById(wrkMast)) { |
| | | map1.put("ReturnStatus", "0"); |
| | | map1.put("ErrorMessage", ""); |
| | | } else { |
| | | map1.put("ReturnStatus", "1"); |
| | | map1.put("ErrorMessage", "更新任务状态失败" + wrkMast); |
| | | |
| | | if (status.equals("complete")) { |
| | | // 入库 + 库位转移 |
| | | if (wrkMast.getWrkSts() < 4 || (wrkMast.getWrkSts() > 10 && wrkMast.getIoType()==11)) { |
| | | wrkMast.setWrkSts(4L); |
| | | // 出库 |
| | | } else if (wrkMast.getWrkSts() > 10) { |
| | | wrkMast.setWrkSts(14L); |
| | | } |
| | | Date now = new Date(); |
| | | wrkMast.setWrkSts(14L);//出库到站点上 |
| | | wrkMast.setCrnStrTime(DateUtils.calculate(now, 1L, TimeUnit.SECONDS, true)); |
| | | wrkMast.setCrnEndTime(now); |
| | | wrkMast.setModiTime(now); |
| | | wrkMastService.updateById(wrkMast); |
| | | |
| | | return R.ok(); |
| | | } else if (status.equals("cancel")) { |
| | | workService.cancelWrkMast(taskNo, 9527L); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | } |
| | | return map1; |
| | | return R.error(); |
| | | } |
| | | } |