|
|
|
@ -15,6 +15,7 @@ import com.chanko.yunxi.mes.module.biz.dal.dataobject.plansub.PlanSubDO;
|
|
|
|
|
import com.chanko.yunxi.mes.module.biz.dal.dataobject.processdesign.ProcessDesignDO;
|
|
|
|
|
import com.chanko.yunxi.mes.module.biz.dal.dataobject.projectorder.ProjectOrderDO;
|
|
|
|
|
import com.chanko.yunxi.mes.module.biz.dal.dataobject.projectorder.ProjectOrderSubDO;
|
|
|
|
|
import com.chanko.yunxi.mes.module.biz.dal.dataobject.scequipment.ScEquipmentDO;
|
|
|
|
|
import com.chanko.yunxi.mes.module.biz.dal.dataobject.screen.ScreenDO;
|
|
|
|
|
import com.chanko.yunxi.mes.module.biz.dal.dataobject.taskdispatch.TaskDispatchDO;
|
|
|
|
|
import com.chanko.yunxi.mes.module.biz.dal.dataobject.taskdispatch.TaskDispatchDetailDO;
|
|
|
|
@ -24,6 +25,7 @@ import com.chanko.yunxi.mes.module.biz.dal.mysql.plansub.PlanSubMapper;
|
|
|
|
|
import com.chanko.yunxi.mes.module.biz.dal.mysql.processdesign.ProcessDesignMapper;
|
|
|
|
|
import com.chanko.yunxi.mes.module.biz.dal.mysql.projectorder.ProjectOrderMapper;
|
|
|
|
|
import com.chanko.yunxi.mes.module.biz.dal.mysql.projectorder.ProjectOrderSubMapper;
|
|
|
|
|
import com.chanko.yunxi.mes.module.biz.dal.mysql.scequipment.ScEquipmentMapper;
|
|
|
|
|
import com.chanko.yunxi.mes.module.biz.dal.mysql.screen.ScreenMapper;
|
|
|
|
|
import com.chanko.yunxi.mes.module.biz.dal.mysql.taskdispatch.TaskDispatchDetailMapper;
|
|
|
|
|
import com.chanko.yunxi.mes.module.biz.dal.mysql.taskdispatch.TaskDispatchMapper;
|
|
|
|
@ -47,6 +49,7 @@ import java.util.stream.Collectors;
|
|
|
|
|
import static com.chanko.yunxi.mes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
|
|
import static com.chanko.yunxi.mes.module.biz.enums.ErrorCodeConstants.SCREEN_NOT_EXISTS;
|
|
|
|
|
import static com.chanko.yunxi.mes.module.biz.enums.ScreenTypeEnum.ProductionOrderState;
|
|
|
|
|
import static com.chanko.yunxi.mes.module.biz.enums.ScreenTypeEnum.QualifiedRateOfEachProduct;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 大屏数据 Service 实现类
|
|
|
|
@ -79,6 +82,8 @@ public class ScreenServiceImpl implements ScreenService {
|
|
|
|
|
private ProcessDesignMapper processDesignMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private PlanSubMapper planSubMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private ScEquipmentMapper scEquipmentMapper;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Long createScreen(ScreenSaveReqVO createReqVO) {
|
|
|
|
@ -170,16 +175,24 @@ public class ScreenServiceImpl implements ScreenService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ScreenDO productionOrderState = todayDataList.stream().filter(screenDO -> ProductionOrderState.name().equals(screenDO.getType())).findFirst().get();
|
|
|
|
|
ScreenDO qualifiedRateOfEachProduct = todayDataList.stream().filter(screenDO -> QualifiedRateOfEachProduct.name().equals(screenDO.getType())).findFirst().get();
|
|
|
|
|
// 设置今天数据
|
|
|
|
|
todayDataList.forEach(screenDO -> {
|
|
|
|
|
switch (ScreenTypeEnum.valueOf(screenDO.getType())){
|
|
|
|
|
case ProductionStateList:
|
|
|
|
|
// 同时设置 生产订单状态
|
|
|
|
|
buildProductionStateList(screenDO, productionOrderState);
|
|
|
|
|
// 同时设置 各产品合格率
|
|
|
|
|
buildProductionStateList(screenDO, productionOrderState, qualifiedRateOfEachProduct);
|
|
|
|
|
break;
|
|
|
|
|
case QuantityOfEachProductProduced:
|
|
|
|
|
buildQuantityOfEachProductProduced(screenDO);
|
|
|
|
|
break;
|
|
|
|
|
case UtilizationRateOfEquipment:
|
|
|
|
|
buildUtilizationRateOfEquipment(screenDO);
|
|
|
|
|
break;
|
|
|
|
|
case EquipmentOperationState:
|
|
|
|
|
buildEquipmentOperationState(screenDO);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -193,6 +206,85 @@ public class ScreenServiceImpl implements ScreenService {
|
|
|
|
|
return todayDataList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 包装设备运行状态
|
|
|
|
|
*
|
|
|
|
|
* "2D": ["equipmentNo","qualifiedQuantity","qualifiedRate","overallEquipmentEffectiveness","shutdownTimes","operationState"]
|
|
|
|
|
* [["1#",22,33.33,44,0,"NORMAL"],["2#","门扇",44,55.55,66,2,"MALFUNCTION"],["3#","横头",66,77.77,77,4,"SHUTDOWN"]]
|
|
|
|
|
*
|
|
|
|
|
* @param screenDO
|
|
|
|
|
*/
|
|
|
|
|
private void buildEquipmentOperationState(ScreenDO screenDO) {
|
|
|
|
|
LinkedList<LinkedList> resultData = new LinkedList<>();
|
|
|
|
|
List<ScEquipmentDO> scEquipmentDOList = scEquipmentMapper.selectList(new LambdaQueryWrapper<ScEquipmentDO>(){{
|
|
|
|
|
orderByAsc(ScEquipmentDO::getId);
|
|
|
|
|
}});
|
|
|
|
|
|
|
|
|
|
for (ScEquipmentDO scEquipmentDO : scEquipmentDOList) {
|
|
|
|
|
resultData.add(new LinkedList(){{
|
|
|
|
|
add(scEquipmentDO.getNmae());
|
|
|
|
|
add(scEquipmentDO.getNum());
|
|
|
|
|
add(scEquipmentDO.getQualificationRate().multiply(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_CEILING));
|
|
|
|
|
add(scEquipmentDO.getOee());
|
|
|
|
|
add(scEquipmentDO.getShutdownTime());
|
|
|
|
|
add(scEquipmentDO.getUtilizationRate().multiply(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_CEILING));
|
|
|
|
|
}});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
screenDO.setData(JSON.toJSONString(resultData));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 包装各产品合格率
|
|
|
|
|
*
|
|
|
|
|
* "1D": ["product","qualifiedRate"]
|
|
|
|
|
* [["门套","门扇"],[95,98]]
|
|
|
|
|
*
|
|
|
|
|
* @param screenDO
|
|
|
|
|
* @param doList
|
|
|
|
|
*/
|
|
|
|
|
private void buildQualifiedRateOfEachProduct(ScreenDO screenDO, List<ProjectOrderSubDO> doList) {
|
|
|
|
|
LinkedList<LinkedList> resultData = new LinkedList<>();
|
|
|
|
|
|
|
|
|
|
LinkedList<String> productList = new LinkedList<>();
|
|
|
|
|
LinkedList<BigDecimal> rateList = new LinkedList<>();
|
|
|
|
|
resultData.add(productList);
|
|
|
|
|
resultData.add(rateList);
|
|
|
|
|
|
|
|
|
|
for (ProjectOrderSubDO subDO : doList) {
|
|
|
|
|
productList.add(subDO.getProjectSubName());
|
|
|
|
|
rateList.add(new BigDecimal(100)
|
|
|
|
|
.subtract(new BigDecimal(subDO.getUnqualifiedQuantity()*100).divide(new BigDecimal(subDO.getAmount())))
|
|
|
|
|
.setScale(2, BigDecimal.ROUND_CEILING));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
screenDO.setData(JSON.toJSONString(resultData));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 包装设备利用率
|
|
|
|
|
* "1D": ["equipmentNo","utilizationRate"]
|
|
|
|
|
* [["1#","2#","3#"],[45,35,60]]
|
|
|
|
|
*
|
|
|
|
|
* @param screenDO
|
|
|
|
|
*/
|
|
|
|
|
private void buildUtilizationRateOfEquipment(ScreenDO screenDO) {
|
|
|
|
|
LinkedList<LinkedList> resultData = new LinkedList<>();
|
|
|
|
|
|
|
|
|
|
LinkedList<String> equipmentNo = new LinkedList<>();
|
|
|
|
|
LinkedList<BigDecimal> utilizationRate = new LinkedList<>();
|
|
|
|
|
resultData.add(equipmentNo);
|
|
|
|
|
resultData.add(utilizationRate);
|
|
|
|
|
List<ScEquipmentDO> scEquipmentDOList = scEquipmentMapper.selectList(new LambdaQueryWrapper<ScEquipmentDO>(){{
|
|
|
|
|
orderByAsc(ScEquipmentDO::getId);
|
|
|
|
|
}});
|
|
|
|
|
for (ScEquipmentDO scEquipmentDO : scEquipmentDOList) {
|
|
|
|
|
equipmentNo.add(scEquipmentDO.getNmae());
|
|
|
|
|
utilizationRate.add(scEquipmentDO.getUtilizationRate());
|
|
|
|
|
}
|
|
|
|
|
screenDO.setData(JSON.toJSONString(resultData));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 包装各产品生产数量
|
|
|
|
|
* "1D": ["product","sixDaysAgo","fiveDaysAgo","fourDaysAgo","threeDaysAgo","twoDaysAgo","oneDayAgo","today"]
|
|
|
|
@ -274,18 +366,18 @@ public class ScreenServiceImpl implements ScreenService {
|
|
|
|
|
*
|
|
|
|
|
* @param screenDO
|
|
|
|
|
* @param productionOrderState
|
|
|
|
|
* @param qualifiedRateOfEachProduct
|
|
|
|
|
*/
|
|
|
|
|
private void buildProductionStateList(ScreenDO screenDO, ScreenDO productionOrderState) {
|
|
|
|
|
private void buildProductionStateList(ScreenDO screenDO, ScreenDO productionOrderState, ScreenDO qualifiedRateOfEachProduct) {
|
|
|
|
|
ArrayList<LinkedList> resultData = new ArrayList<>(16);
|
|
|
|
|
MPJLambdaWrapper<TaskDispatchDO> query = new MPJLambdaWrapper<>();
|
|
|
|
|
query.selectAll(TaskDispatchDO.class)
|
|
|
|
|
MPJLambdaWrapper<ProjectOrderSubDO> query = new MPJLambdaWrapper<>();
|
|
|
|
|
query.selectAll(ProjectOrderSubDO.class)
|
|
|
|
|
.select("c.code as projectCode", "DateDiff(c.project_end_time,CURRENT_DATE) as restDays")
|
|
|
|
|
.select("d.name as projectSubName", "d.code as projectSubCode")
|
|
|
|
|
.select("b.amount", "d.unit")
|
|
|
|
|
.select("d.name as projectSubName", "d.code as projectSubCode", "d.unit")
|
|
|
|
|
.select("COALESCE(sum(e.amount),0) as qualifiedQuantity")
|
|
|
|
|
.select("COALESCE(sum(f.amount),0) as unqualifiedQuantity")
|
|
|
|
|
.leftJoin(PlanDO.class, "a", PlanDO::getId, TaskDispatchDO::getPlanId)
|
|
|
|
|
.leftJoin(ProjectOrderSubDO.class, "b", ProjectOrderSubDO::getId, TaskDispatchDO::getProjectSubId)
|
|
|
|
|
.leftJoin(TaskDispatchDO.class, "b", TaskDispatchDO::getProjectSubId, ProjectOrderSubDO::getId)
|
|
|
|
|
.leftJoin(ProjectOrderDO.class, "c", ProjectOrderDO::getId, ProcessDesignDO::getProjectId)
|
|
|
|
|
.leftJoin(MaterialDO.class, "d", MaterialDO::getId, ProjectOrderSubDO::getMaterialId)
|
|
|
|
|
.leftJoin(TaskReportDO.class, "e", Wrapper -> Wrapper.eq(TaskReportDO::getDispatchId, TaskDispatchDO::getId)
|
|
|
|
@ -293,34 +385,36 @@ public class ScreenServiceImpl implements ScreenService {
|
|
|
|
|
.eq(TaskReportDO::getHasReport, YesOrNoEnum.Y.getCode())
|
|
|
|
|
)
|
|
|
|
|
.leftJoin(UnqualifiedNotificationDO.class, "f", Wrapper -> Wrapper.eq(UnqualifiedNotificationDO::getProjectSubId, TaskDispatchDO::getProjectSubId)
|
|
|
|
|
.eq(UnqualifiedNotificationDO::getNotificationStatus, UnqualifiedNotificationStatusEnum.AUDIT.getCode()))
|
|
|
|
|
.eq(UnqualifiedNotificationDO::getNotificationStatus, UnqualifiedNotificationStatusEnum.AUDIT.getCode())
|
|
|
|
|
.eq(UnqualifiedNotificationDO::getAuditOpinion, UnqualifiedNotificationAuditOpinionEnum.SCRAP.getCode())
|
|
|
|
|
)
|
|
|
|
|
.notIn(PlanDO::getStatus, Arrays.asList(ProjectPlanStatusEnum.COMPLETE.getCode(), ProjectPlanStatusEnum.TERMINATE.getCode()))
|
|
|
|
|
.orderByDesc(TaskDispatchDO::getId)
|
|
|
|
|
.groupBy(TaskDispatchDO::getId)
|
|
|
|
|
.orderByDesc(ProjectOrderSubDO::getId)
|
|
|
|
|
.groupBy(ProjectOrderSubDO::getId)
|
|
|
|
|
.disableSubLogicDel();
|
|
|
|
|
|
|
|
|
|
BigDecimal sumProductionProgress = new BigDecimal(0);
|
|
|
|
|
List<TaskDispatchDO> taskDispatchDOList = taskDispatchMapper.selectList(query);
|
|
|
|
|
taskDispatchDOList.forEach(taskDispatchDO -> {
|
|
|
|
|
|
|
|
|
|
BigDecimal productionProgress = new BigDecimal(taskDispatchDO.getQualifiedQuantity() * 100).divide(new BigDecimal(taskDispatchDO.getAmount()), 2, BigDecimal.ROUND_CEILING);
|
|
|
|
|
List<ProjectOrderSubDO> doList = projectOrderSubMapper.selectList(query);
|
|
|
|
|
for (ProjectOrderSubDO aDo : doList) {
|
|
|
|
|
BigDecimal productionProgress = new BigDecimal(aDo.getQualifiedQuantity() * 100).divide(new BigDecimal(aDo.getAmount()), 2, BigDecimal.ROUND_CEILING);
|
|
|
|
|
resultData.add(new LinkedList<Object>(){{
|
|
|
|
|
add(taskDispatchDO.getProjectSubCode());
|
|
|
|
|
add(taskDispatchDO.getProjectSubName());
|
|
|
|
|
add(taskDispatchDO.getAmount());
|
|
|
|
|
add(taskDispatchDO.getQualifiedQuantity());
|
|
|
|
|
add(taskDispatchDO.getRestDays());
|
|
|
|
|
add(aDo.getProjectSubCode());
|
|
|
|
|
add(aDo.getProjectSubName());
|
|
|
|
|
add(aDo.getAmount());
|
|
|
|
|
add(aDo.getQualifiedQuantity());
|
|
|
|
|
add(aDo.getRestDays());
|
|
|
|
|
add(productionProgress);
|
|
|
|
|
}});
|
|
|
|
|
|
|
|
|
|
sumProductionProgress.add(sumProductionProgress);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
screenDO.setData(JSON.toJSONString(resultData));
|
|
|
|
|
|
|
|
|
|
BigDecimal completionRate = sumProductionProgress.divide(new BigDecimal(taskDispatchDOList.size()), 2, BigDecimal.ROUND_CEILING);
|
|
|
|
|
BigDecimal completionRate = sumProductionProgress.divide(new BigDecimal(doList.size()), 2, BigDecimal.ROUND_CEILING);
|
|
|
|
|
BigDecimal deliveryRate = null;
|
|
|
|
|
buildProductionOrderState(productionOrderState, completionRate, deliveryRate);
|
|
|
|
|
|
|
|
|
|
buildQualifiedRateOfEachProduct(qualifiedRateOfEachProduct, doList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|