@ -14,6 +14,7 @@ import org.springframework.stereotype.Service;
import java.util.* ;
import java.util.stream.Collectors ;
import java.text.DecimalFormat ;
@Service
public class FourthMesBoardServiceImpl implements IFourthMesBoardService {
@Autowired
@ -68,7 +69,7 @@ public class FourthMesBoardServiceImpl implements IFourthMesBoardService {
latestProductOrder . setMesProductPlanList ( mesProductPlanList ) ;
List < MesBaseProcessInfo > mesBaseProcessInfoList = this . computeProcessPercentage ( mesProductPlanList ) ;
List < MesBaseProcessInfo > mesBaseProcessInfoList = this . computeProcessPercentage ( mesProductPlanList ) ;
latestProductOrder . setBaseProcessInfoList ( mesBaseProcessInfoList ) ;
}
@ -79,17 +80,17 @@ public class FourthMesBoardServiceImpl implements IFourthMesBoardService {
/ * *
* 计 算 工 序 占 比
* /
private List < MesBaseProcessInfo > computeProcessPercentage ( List < MesProductPlan > mesProductPlanList ) {
private List < MesBaseProcessInfo > computeProcessPercentage ( List < MesProductPlan > mesProductPlanList ) {
//所有工序加起来的占比
int totalPercentage = mesProductPlanList . stream ( )
. mapToInt ( MesProductPlan : : getProcessPercentageInt )
. reduce ( 0 , Integer : : sum ) ;
Map < Long , String > processInfo = new HashMap < > ( ) ;
processInfo . put ( 41L , "激光切割" ) ;
processInfo . put ( 42L , "折弯" ) ;
processInfo . put ( 43L , "焊接" ) ;
processInfo . put ( 44L , "装配" ) ;
Map < Long , String > processInfo = new HashMap < > ( ) ;
processInfo . put ( 41L , "激光切割" ) ;
processInfo . put ( 42L , "折弯" ) ;
processInfo . put ( 43L , "焊接" ) ;
processInfo . put ( 44L , "装配" ) ;
Map < Long , List < MesProductPlan > > processIdMap = mesProductPlanList . stream ( ) . collect ( Collectors . groupingBy ( MesProductPlan : : getProcessId ) ) ;
@ -100,10 +101,14 @@ public class FourthMesBoardServiceImpl implements IFourthMesBoardService {
int processTotalPercentage = mesProductPlans . stream ( )
. mapToInt ( MesProductPlan : : getProcessPercentageInt )
. reduce ( 0 , Integer : : sum ) ;
int computePercentage = processTotalPercentage / totalPercentage * 75 ;
int computePercentage = 0 ;
if ( totalPercentage > 0 ) {
computePercentage = processTotalPercentage / totalPercentage * 75 ;
}
MesBaseProcessInfo baseProcessInfo = new MesBaseProcessInfo ( ) ; //喷塑
baseProcessInfo . setProcessPercentage ( computePercentage + "%" ) ;
baseProcessInfo . setProcessPercentage ( computePercentage + "%" ) ;
baseProcessInfo . setProcessName ( processInfo . get ( processId ) ) ;
mesBaseProcessInfoList . add ( baseProcessInfo ) ;
}
@ -124,12 +129,13 @@ public class FourthMesBoardServiceImpl implements IFourthMesBoardService {
/ * *
* 获 取 良 率 , 不 良 率 和 物 料 利 用 率 , 供 4 楼 生 产 看 板 右 下 方 展 示
*
* @return
* /
@Override
public JSONObject getQualityAndAvailablePercentage ( ) {
public JSONObject getQualityAndAvailablePercentage ( ) {
JSONObject resultJson = new JSONObject ( ) ;
// 定义良率范围
// 定义良率范围
double passRateMin = 95.0 ; // 最小值
double passRateMax = 100.0 ; // 最大值
@ -137,7 +143,7 @@ public class FourthMesBoardServiceImpl implements IFourthMesBoardService {
double passRate = generateRandomWithOneDecimal ( passRateMin , passRateMax ) ;
//不良率
double failureRate = 100 - passRate ;
double failureRate = 100 - passRate ;
DecimalFormat df = new DecimalFormat ( "#.0" ) ;
@ -147,9 +153,9 @@ public class FourthMesBoardServiceImpl implements IFourthMesBoardService {
double availableRate = generateRandomWithOneDecimal ( availableRateMin , availableRateMax ) ;
resultJson . put ( "passRate" , passRate + "%" ) ;
resultJson . put ( "failureRate" , Double . parseDouble ( df . format ( failureRate ) ) + "%" ) ;
resultJson . put ( "availableRate" , availableRate + "%" ) ;
resultJson . put ( "passRate" , passRate + "%" ) ;
resultJson . put ( "failureRate" , Double . parseDouble ( df . format ( failureRate ) ) + "%" ) ;
resultJson . put ( "availableRate" , availableRate + "%" ) ;
return resultJson ;