@ -1,5 +1,8 @@
package com.productionboard.service.impl ;
package com.productionboard.service.impl ;
import cn.hutool.http.HttpRequest ;
import cn.hutool.http.HttpResponse ;
import cn.hutool.http.HttpUtil ;
import com.alibaba.fastjson.JSONArray ;
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 ;
@ -26,39 +29,50 @@ import java.util.stream.Collectors;
@Service
@Service
public class BaseLocationServiceImpl implements IBaseLocationService {
public class BaseLocationServiceImpl implements IBaseLocationService {
@Autowired
@Autowired private BaseLocationInfoMapper lcoationMapper ;
private BaseLocationInfoMapper lcoationMapper ;
@Autowired
@Autowired private RecordTaskMapper recordTaskMapper ;
private RecordTaskMapper recordTaskMapper ;
private SimpleDateFormat simpleDateFormat = new SimpleDateFormat ( "yyyy-MM-dd" ) ;
private SimpleDateFormat simpleDateFormat = new SimpleDateFormat ( "yyyy-MM-dd" ) ;
@Override
@Override
public String getStoreStatistics ( String ids ) {
public String getStoreStatistics ( String ids ) {
String STORE_CODE = "A" ;
QueryWrapper < BaseLocationInfo > wrapper = new QueryWrapper < > ( ) ;
QueryWrapper < BaseLocationInfo > wrapper = new QueryWrapper < > ( ) ;
switch ( ids ) {
switch ( ids ) {
case "0" :
case "0" :
wrapper . eq ( "STORE_CODE" , "B" ) ;
wrapper . eq ( "STORE_CODE" , "B" ) ;
STORE_CODE = "B" ;
break ;
break ;
case "1" :
case "1" :
wrapper . eq ( "STORE_CODE" , "A" ) ;
wrapper . eq ( "STORE_CODE" , "A" ) ;
STORE_CODE = "A" ;
break ;
break ;
default :
default :
break ;
break ;
}
}
List < BaseLocationInfo > baseLocationInfos = lcoationMapper . selectList ( wrapper ) ;
List < BaseLocationInfo > baseLocationInfos = lcoationMapper . SelectLocationInfo ( STORE_CODE ) ;
Map < String , List < BaseLocationInfo > > collect = baseLocationInfos . stream ( ) . collect ( Collectors . groupingBy ( BaseLocationInfo : : getMaterialType ) ) ;
List < String > materialType =
baseLocationInfos . stream ( )
. map ( BaseLocationInfo : : getMaterialType )
. distinct ( )
. collect ( Collectors . toList ( ) ) ;
Map < String , List < BaseLocationInfo > > collect =
baseLocationInfos . stream ( )
. collect ( Collectors . groupingBy ( BaseLocationInfo : : getMaterialType ) ) ;
List < JSONObject > result = new ArrayList < > ( ) ;
List < JSONObject > result = new ArrayList < > ( ) ;
for ( String item : collect . keySet ( ) ) {
for ( String item : materialType ) {
JSONObject jsonObject = new JSONObject ( ) ;
JSONObject jsonObject = new JSONObject ( ) ;
jsonObject . put ( "materialName" , item ) ;
jsonObject . put ( "materialName" , item ) ;
jsonObject . put ( "lineStoreAmount" , collect . get ( item ) . stream ( ) . filter ( x - > x . getLocationArea ( ) . equals ( "1" ) ) . collect ( Collectors . toList ( ) ) . size ( ) ) ;
jsonObject . put ( "lineStoreAmount" , lcoationMapper. SelectLocationInfoByArea ( STORE_CODE , "1" , item ) . size ( ) ) ;
jsonObject . put ( "hullStoreAmount" , collect . get ( item ) . stream ( ) . filter ( x - > x . getLocationArea ( ) . equals ( "2" ) ) . collect ( Collectors . toList ( ) ) . size ( ) ) ;
jsonObject . put ( "hullStoreAmount" , lcoationMapper. SelectLocationInfoByArea ( STORE_CODE , "2" , item ) . size ( ) ) ;
result . add ( jsonObject ) ;
result . add ( jsonObject ) ;
}
}
String s = JSONArray . toJSONString ( result ) ;
String s = JSONArray . toJSONString ( result ) ;
System . out . println ( "物料库存统计:" + s ) ;
System . out . println ( "物料库存统计:" + s ) ;
return s ;
return s ;
@ -66,46 +80,58 @@ public class BaseLocationServiceImpl implements IBaseLocationService {
@Override
@Override
public String getParamJson ( String ids ) {
public String getParamJson ( String ids ) {
String [ ] result = new String [ 12 ] ;
String urlStr = "http://10.100.71.119:8012/system/NorthWareHouse/getStoreInfo" ;
switch ( ids ) {
case "0" :
urlStr = "http://10.100.71.119:8012/system/NorthWareHouse/getStoreInfo" ;
break ;
case "1" :
urlStr = "http://10.100.71.119:8012/system/SouthWareHouse/getStoreInfo" ;
break ;
default :
break ;
}
String param =
"{\"StartTime\":\"2018-10-10 09:42:02\",\"EndTime\":\"2018-10-29 09:42:02\",\"StartIndex\":\"0\",\"PageSize\":\"30\"}" ;
String response = HttpUtil . post ( urlStr , param ) ;
return response ;
/ * String [ ] result = new String [ 12 ] ;
String STORE_CODE = "A" ;
try {
try {
QueryWrapper < BaseLocationInfo > locationWrapper = new QueryWrapper < BaseLocationInfo > ( ) ;
QueryWrapper < BaseLocationInfo > locationWrapper = new QueryWrapper < BaseLocationInfo > ( ) ;
QueryWrapper < RecordTask > taskWrapper = new QueryWrapper < > ( ) ;
QueryWrapper < RecordTask > taskWrapper = new QueryWrapper < > ( ) ;
switch ( ids ) {
switch ( ids ) {
case "0" :
case "0" :
locationWrapper . eq ( "STORE_CODE" , "B" ) ;
locationWrapper . eq ( "STORE_CODE" , "B" ) ;
taskWrapper . eq ( "STORE_CODE" , "B" ) ;
STORE_CODE = "B" ;
break ;
break ;
case "1" :
case "1" :
locationWrapper . eq ( "STORE_CODE" , "A" ) ;
locationWrapper . eq ( "STORE_CODE" , "A" ) ;
taskWrapper . eq ( "STORE_CODE" , "A" ) ;
STORE_CODE = "A" ;
break ;
break ;
default :
default :
break ;
break ;
}
}
taskWrapper . like ( "RECORD_TIME" , simpleDateFormat . format ( new Date ( ) ) ) ;
List < RecordTask > recordTasks = recordTaskMapper . selectList ( taskWrapper ) ;
if ( recordTasks . size ( ) > 0 ) {
int inAmount1 = recordTaskMapper . SelectRecordTaskByTaskType ( "A" , "1" , "1" ) . size ( ) ;
//1号库入库数量、出库数量:1入库2出库
int outAmount1 = recordTaskMapper . SelectRecordTaskByTaskType ( "A" , "1" , "2" ) . size ( ) ;
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出库
//2号库入库数量、出库数量:1入库2出库
int inAmount2 = recordTask s. stream ( ) . filter ( x - > x . getLocationArea ( ) . equals ( "2" ) & & x . getTaskType ( ) . equals ( "1" ) ) . collect ( Collectors . toList ( ) ) . size ( ) ;
int inAmount2 = recordTaskMapper . SelectRecordTaskByTaskType ( "A" , "2" , "1" ) . size ( ) ;
int outAmount2 = recordTask s. stream ( ) . filter ( x - > x . getLocationArea ( ) . equals ( "2" ) & & x . getTaskType ( ) . equals ( "2" ) ) . collect ( Collectors . toList ( ) ) . size ( ) ;
int outAmount2 = recordTask Mapper. SelectRecordTaskByTaskType ( "A" , "2" , "2" ) . size ( ) ;
result [ 0 ] = inAmount1 + "" ;
result [ 0 ] = inAmount1 + "" ;
result [ 1 ] = outAmount1 + "" ;
result [ 1 ] = outAmount1 + "" ;
result [ 2 ] = inAmount2 + "" ;
result [ 2 ] = inAmount2 + "" ;
result [ 3 ] = outAmount2 + "" ;
result [ 3 ] = outAmount2 + "" ;
}
List < BaseLocationInfo > baseLocationInfos = lcoationMapper . selectList ( locationWrapper ) ;
List < BaseLocationInfo > baseLocationInfos = lcoationMapper . selectList ( locationWrapper ) ;
if ( baseLocationInfos . size ( ) > 0 ) {
if ( baseLocationInfos . size ( ) > 0 ) {
//正在使用
//正在使用
int inUse = baseLocationInfos . stream ( ) . filter ( x - > x . getLocationStatus ( ) = = 1L ) . collect ( Collectors . toList ( ) ) . size ( ) ;
int inUse = lcoationMapper . SelectInUseLocationInfo ( STORE_CODE ) . size ( ) ;
System . out . println ( "正在使用:" + inUse ) ;
System . out . println ( "正在使用:" + inUse ) ;
//未使用
//未使用
int unUse = baseLocationInfos . size ( ) - inUse ;
int unUse = baseLocationInfos . size ( ) - inUse ;
@ -113,8 +139,8 @@ public class BaseLocationServiceImpl implements IBaseLocationService {
//1#正在使用
//1#正在使用
int size1 = baseLocationInfos . stream ( ) . filter ( x - > x . getLocationArea ( ) . equals ( "1" ) ) . collect ( Collectors . toList ( ) ) . size ( ) ;
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 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 inUse1 = lcoationMapper . SelectInUseLocationInfoByArea ( STORE_CODE , "1" ) . size ( ) ;
int inUse2 = baseLocationInfos . stream ( ) . filter ( x - > x . getLocationArea ( ) . equals ( "2" ) & & x . getLocationStatus ( ) . equals ( "1" ) ) . collect ( Collectors . toList ( ) ) . size ( ) ;
int inUse2 = lcoationMapper . SelectInUseLocationInfoByArea ( STORE_CODE , "2" ) . size ( ) ;
int unUse1 = size1 - inUse1 ;
int unUse1 = size1 - inUse1 ;
int unUse2 = size2 - inUse2 ;
int unUse2 = size2 - inUse2 ;
@ -143,6 +169,6 @@ public class BaseLocationServiceImpl implements IBaseLocationService {
}
}
}
}
return JSONArray . toJSONString ( result ) ;
return JSONArray . toJSONString ( result ) ; * /
}
}
}
}