From 2b605f9a897ad39e4dd76242eb9890fcecc4f1ad Mon Sep 17 00:00:00 2001 From: wenjy Date: Sun, 12 Jun 2022 15:45:58 +0800 Subject: [PATCH] =?UTF-8?q?change=20-=20=E9=97=A8=E4=BD=93=E5=BA=93?= =?UTF-8?q?=E5=BA=93=E5=AD=98=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/StorageController.java | 4 +- .../entity/BaseLocationInfo.java | 2 +- .../service/impl/BaseLocationServiceImpl.java | 94 ++++++++++++++++--- .../main/resources/static/js/storage/index.js | 28 +++--- 4 files changed, 98 insertions(+), 30 deletions(-) diff --git a/productionboard/src/main/java/com/productionboard/controller/StorageController.java b/productionboard/src/main/java/com/productionboard/controller/StorageController.java index 53224af..558bd48 100644 --- a/productionboard/src/main/java/com/productionboard/controller/StorageController.java +++ b/productionboard/src/main/java/com/productionboard/controller/StorageController.java @@ -123,7 +123,7 @@ public class StorageController { @GetMapping("/getParamJson") @ResponseBody public String getParamJson(String ids){ - - return null; + String paramJson = locationService.getParamJson(ids); + return paramJson; } } diff --git a/productionboard/src/main/java/com/productionboard/entity/BaseLocationInfo.java b/productionboard/src/main/java/com/productionboard/entity/BaseLocationInfo.java index 0b34bde..955c5bc 100644 --- a/productionboard/src/main/java/com/productionboard/entity/BaseLocationInfo.java +++ b/productionboard/src/main/java/com/productionboard/entity/BaseLocationInfo.java @@ -84,7 +84,7 @@ public class BaseLocationInfo implements Serializable { * 库位状态 1:可用 2:空 0:空(锁) */ @TableField("LOCATION_STATUS") - private BigDecimal locationStatus; + private Long locationStatus; /** * 效率级别 diff --git a/productionboard/src/main/java/com/productionboard/service/impl/BaseLocationServiceImpl.java b/productionboard/src/main/java/com/productionboard/service/impl/BaseLocationServiceImpl.java index a85a980..9eadae4 100644 --- a/productionboard/src/main/java/com/productionboard/service/impl/BaseLocationServiceImpl.java +++ b/productionboard/src/main/java/com/productionboard/service/impl/BaseLocationServiceImpl.java @@ -4,13 +4,17 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.productionboard.entity.BaseLocationInfo; +import com.productionboard.entity.RecordTask; import com.productionboard.mapper.BaseLocationInfoMapper; import com.productionboard.mapper.RecordTaskMapper; import com.productionboard.service.IBaseLocationService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.text.NumberFormat; +import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Date; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -28,6 +32,8 @@ public class BaseLocationServiceImpl implements IBaseLocationService { @Autowired private RecordTaskMapper recordTaskMapper; + private SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + @Override public String getStoreStatistics(String ids) { QueryWrapper wrapper = new QueryWrapper<>(); @@ -60,23 +66,83 @@ public class BaseLocationServiceImpl implements IBaseLocationService { @Override public String getParamJson(String ids) { + String[] result =new String[12]; - QueryWrapper wrapper = new QueryWrapper<>(); - switch (ids) { - case"0": - wrapper.eq("STORE_CODE","B"); - break; - case"1": - wrapper.eq("STORE_CODE","A"); - break; - default: - break; - } + try{ + QueryWrapper locationWrapper = new QueryWrapper(); + QueryWrapper taskWrapper = new QueryWrapper<>(); + switch (ids) { + case"0": + locationWrapper.eq("STORE_CODE","B"); + taskWrapper.eq("STORE_CODE","B"); + break; + case"1": + locationWrapper.eq("STORE_CODE","A"); + taskWrapper.eq("STORE_CODE","A"); + break; + default: + break; + } + taskWrapper.like("RECORD_TIME",simpleDateFormat.format(new Date())); + + List recordTasks = recordTaskMapper.selectList(taskWrapper); + + if(recordTasks.size()>0){ + //1号库入库数量、出库数量:1入库2出库 + int inAmount1 = recordTasks.stream().filter(x -> x.getLocationArea().equals("1") && x.getTaskType().equals("1")).collect(Collectors.toList()).size(); + int outAmount1 = recordTasks.stream().filter(x -> x.getLocationArea().equals("1") && x.getTaskType().equals("2")).collect(Collectors.toList()).size(); + //2号库入库数量、出库数量:1入库2出库 + int inAmount2 = recordTasks.stream().filter(x -> x.getLocationArea().equals("2") && x.getTaskType().equals("1")).collect(Collectors.toList()).size(); + int outAmount2 = recordTasks.stream().filter(x -> x.getLocationArea().equals("2") && x.getTaskType().equals("2")).collect(Collectors.toList()).size(); + result[0] = inAmount1+""; + result[1] = outAmount1+""; + result[2] = inAmount2+""; + result[3] = outAmount2+""; + + } - //1号库入库数量、出库数量 + List baseLocationInfos = lcoationMapper.selectList(locationWrapper); + if(baseLocationInfos.size() > 0){ - //2 + //正在使用 + int inUse = baseLocationInfos.stream().filter(x -> x.getLocationStatus() == 1L).collect(Collectors.toList()).size(); + System.out.println("正在使用:"+inUse); + //未使用 + int unUse = baseLocationInfos.size() - inUse; + + //1#正在使用 + int size1 = baseLocationInfos.stream().filter(x -> x.getLocationArea().equals("1")).collect(Collectors.toList()).size(); + int size2 = baseLocationInfos.stream().filter(x -> x.getLocationArea().equals("2")).collect(Collectors.toList()).size(); + int inUse1 = baseLocationInfos.stream().filter(x -> x.getLocationArea().equals("1") && x.getLocationStatus().equals("1")).collect(Collectors.toList()).size(); + int inUse2 = baseLocationInfos.stream().filter(x -> x.getLocationArea().equals("2") && x.getLocationStatus().equals("1")).collect(Collectors.toList()).size(); + int unUse1 = size1 - inUse1; + int unUse2 = size2 - inUse2; + + result[4] = inUse1+""; + result[5] = unUse1+""; + result[6] = inUse2+""; + result[7] = unUse2+""; + result[8] = unUse+""; + + // 创建一个数值格式化对象 + NumberFormat numberFormat = NumberFormat.getInstance(); + // 设置精确到小数点后2位 + numberFormat.setMaximumFractionDigits(2); + String unUsePercentage = numberFormat.format((float)unUse/(float)baseLocationInfos.size()*100); + System.out.println("diliverNum和queryMailNum的百分比为:" + result + "%"); + result[9] = unUsePercentage+"%"; + result[10] = inUse+""; + String inUsePercentage = numberFormat.format((float)inUse/(float)baseLocationInfos.size()*100); + result[11] = inUsePercentage+"%"; + } + }catch (Exception e){ + System.out.println("门体库参数统计getParamJson异常:"+e.getMessage()); + for (int i = 0; i < 12; i++) { + // + result[i] = i+""; + } + } - return null; + return JSONArray.toJSONString(result); } } diff --git a/productionboard/src/main/resources/static/js/storage/index.js b/productionboard/src/main/resources/static/js/storage/index.js index 9309d2a..1b45a77 100644 --- a/productionboard/src/main/resources/static/js/storage/index.js +++ b/productionboard/src/main/resources/static/js/storage/index.js @@ -1,7 +1,4 @@ $(()=>{ - //单日出入库统计 - storageStatistics(123,233,211,124); - //生产计划 $.ajax({ url: '/storage/getProductionPlan', @@ -32,16 +29,21 @@ $(()=>{ $.getJSON(`/storage/getStoreStatistics?ids=${ids}`, function (result) { multipleThreeDimensionalCylindrical(result, document.getElementById("theCurrentInventory")); }); + //库位参数 + $.getJSON(`/storage/getParamJson?ids=${ids}`, function (result) { + //单日出入库统计 + storageStatistics(result[0] == null ? 0 : result[0],result[1] == null ? 0 : result[1],result[2] == null ? 0 : result[2],result[3] == null ? 0 : result[3]); - //库存统计 - $("#emptyLocation-left").text(123); - $("#emptyLocation-right").text(456); - $("#haveUsedLocation-left").text(789); - $("#haveUsedLocation-right").text(1234); + //库存统计 + $("#emptyLocation-left").text(result[4] == null ? 0 : result[4]); + $("#haveUsedLocation-left").text(result[6] == null ? 0 : result[5]); + $("#emptyLocation-right").text(result[5] == null ? 0 : result[6]); + $("#haveUsedLocation-right").text(result[7] == null ? 0 : result[7]); - //库位占比 - $("#emptyLocationNumber").text(68); - $("#emptyLocationRatio").text("39%"); - $("#haveUsedLocationNumber").text(132); - $("#haveUsedLocationRatio").text("61%"); + //库位占比 + $("#emptyLocationNumber").text(result[8] == null ? 0 : result[8]); + $("#emptyLocationRatio").text(result[9] == null ? 0 : result[9]); + $("#haveUsedLocationNumber").text(result[10] == null ? 0 : result[10]); + $("#haveUsedLocationRatio").text(result[11] == null ? 0 : result[11]); + }); }) \ No newline at end of file