change - 门体库库存统计

master
wenjy 3 years ago
parent d9be5dfb2c
commit 2b605f9a89

@ -123,7 +123,7 @@ public class StorageController {
@GetMapping("/getParamJson") @GetMapping("/getParamJson")
@ResponseBody @ResponseBody
public String getParamJson(String ids){ public String getParamJson(String ids){
String paramJson = locationService.getParamJson(ids);
return null; return paramJson;
} }
} }

@ -84,7 +84,7 @@ public class BaseLocationInfo implements Serializable {
* 1: 2 0 * 1: 2 0
*/ */
@TableField("LOCATION_STATUS") @TableField("LOCATION_STATUS")
private BigDecimal locationStatus; private Long locationStatus;
/** /**
* *

@ -4,13 +4,17 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.productionboard.entity.BaseLocationInfo; import com.productionboard.entity.BaseLocationInfo;
import com.productionboard.entity.RecordTask;
import com.productionboard.mapper.BaseLocationInfoMapper; import com.productionboard.mapper.BaseLocationInfoMapper;
import com.productionboard.mapper.RecordTaskMapper; import com.productionboard.mapper.RecordTaskMapper;
import com.productionboard.service.IBaseLocationService; import com.productionboard.service.IBaseLocationService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -28,6 +32,8 @@ public class BaseLocationServiceImpl implements IBaseLocationService {
@Autowired @Autowired
private RecordTaskMapper recordTaskMapper; private RecordTaskMapper recordTaskMapper;
private SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
@Override @Override
public String getStoreStatistics(String ids) { public String getStoreStatistics(String ids) {
QueryWrapper<BaseLocationInfo> wrapper = new QueryWrapper<>(); QueryWrapper<BaseLocationInfo> wrapper = new QueryWrapper<>();
@ -60,23 +66,83 @@ public class BaseLocationServiceImpl implements IBaseLocationService {
@Override @Override
public String getParamJson(String ids) { public String getParamJson(String ids) {
String[] result =new String[12];
QueryWrapper<BaseLocationInfo> wrapper = new QueryWrapper<>(); try{
switch (ids) { QueryWrapper<BaseLocationInfo> locationWrapper = new QueryWrapper<BaseLocationInfo>();
case"0": QueryWrapper<RecordTask> taskWrapper = new QueryWrapper<>();
wrapper.eq("STORE_CODE","B"); switch (ids) {
break; case"0":
case"1": locationWrapper.eq("STORE_CODE","B");
wrapper.eq("STORE_CODE","A"); taskWrapper.eq("STORE_CODE","B");
break; break;
default: case"1":
break; locationWrapper.eq("STORE_CODE","A");
} taskWrapper.eq("STORE_CODE","A");
break;
default:
break;
}
taskWrapper.like("RECORD_TIME",simpleDateFormat.format(new Date()));
List<RecordTask> 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<BaseLocationInfo> 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);
} }
} }

@ -1,7 +1,4 @@
$(()=>{ $(()=>{
//单日出入库统计
storageStatistics(123,233,211,124);
//生产计划 //生产计划
$.ajax({ $.ajax({
url: '/storage/getProductionPlan', url: '/storage/getProductionPlan',
@ -32,16 +29,21 @@ $(()=>{
$.getJSON(`/storage/getStoreStatistics?ids=${ids}`, function (result) { $.getJSON(`/storage/getStoreStatistics?ids=${ids}`, function (result) {
multipleThreeDimensionalCylindrical(result, document.getElementById("theCurrentInventory")); 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-left").text(result[4] == null ? 0 : result[4]);
$("#emptyLocation-right").text(456); $("#haveUsedLocation-left").text(result[6] == null ? 0 : result[5]);
$("#haveUsedLocation-left").text(789); $("#emptyLocation-right").text(result[5] == null ? 0 : result[6]);
$("#haveUsedLocation-right").text(1234); $("#haveUsedLocation-right").text(result[7] == null ? 0 : result[7]);
//库位占比 //库位占比
$("#emptyLocationNumber").text(68); $("#emptyLocationNumber").text(result[8] == null ? 0 : result[8]);
$("#emptyLocationRatio").text("39%"); $("#emptyLocationRatio").text(result[9] == null ? 0 : result[9]);
$("#haveUsedLocationNumber").text(132); $("#haveUsedLocationNumber").text(result[10] == null ? 0 : result[10]);
$("#haveUsedLocationRatio").text("61%"); $("#haveUsedLocationRatio").text(result[11] == null ? 0 : result[11]);
});
}) })
Loading…
Cancel
Save