|
|
|
@ -1,17 +1,42 @@
|
|
|
|
|
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.station.function;
|
|
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionCustomContextStepService;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionDispatchContextStepService;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionProcessContextStepService;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesWorkOrderExtService;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProdShiftContext;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionPartContext;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionProcessContext;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
|
|
|
|
|
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseSwsService;
|
|
|
|
|
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.function.IFsmModuleFunctionService;
|
|
|
|
|
import cn.estsh.i3plus.mes.pcn.util.StationKvBeanUtil;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesFile;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesWorkCell;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesWorkOrder;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.model.ButtonDynamicModel;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.model.StationKvBean;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.model.StationResultBean;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.repository.MesFileRepository;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.google.common.base.Objects;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.StringJoiner;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @Description : 工位参数按钮事件接口实现【切换工位】
|
|
|
|
|
* @Description : 清除加工数【按钮】
|
|
|
|
|
**/
|
|
|
|
|
@Service
|
|
|
|
|
public class MesFunctionProductionStatisticsService extends BaseSwsService implements IFsmModuleFunctionService {
|
|
|
|
@ -19,16 +44,95 @@ public class MesFunctionProductionStatisticsService extends BaseSwsService imple
|
|
|
|
|
@Autowired
|
|
|
|
|
private IMesProductionCustomContextStepService productionCustomContextStepService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private MesFileRepository mesFileRepository;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private IMesWorkOrderExtService workOrderExtService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private IMesProductionDispatchContextStepService productionDispatchContextStepService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private IMesProductionProcessContextStepService productionProcessContextStepService;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Boolean doFunction(StationRequestBean reqBean, StationResultBean resultBean, ButtonDynamicModel buttonDynamicModel) {
|
|
|
|
|
|
|
|
|
|
productionCustomContextStepService.deleteProductionStatisticsContext(reqBean);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.sendMessage(reqBean, resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PICK.getValue()).scanInfo(buttonDynamicModel.getFunctionValue()),
|
|
|
|
|
String.format("生产线[%s]工位[%s]%s成功!", reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(), buttonDynamicModel.getButtonName()), MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT);
|
|
|
|
|
|
|
|
|
|
// 刷新加工数
|
|
|
|
|
MesProductionProcessContext productionProcessContext = productionProcessContextStepService.getEquipmentVariableList(reqBean, MesExtEnumUtil.EQUIP_VARIABLE_TYPE.PRODUCTION.getValue());
|
|
|
|
|
MesWorkCell mesWorkCell = productionProcessContext.getWorkCell();
|
|
|
|
|
|
|
|
|
|
MesProdShiftContext mesProdShiftKvBean = productionCustomContextStepService.getMesProdShiftKvBean(reqBean.getOrganizeCode(), reqBean.getWorkCenterCode());
|
|
|
|
|
|
|
|
|
|
List<StationKvBean> productionStatisticsContext = StationKvBeanUtil.addStationKvBeanList(new ArrayList<>(), new StationKvBean(new StringJoiner(MesPcnExtConstWords.AND).add(mesProdShiftKvBean.getShiftGroup()).add(mesProdShiftKvBean.getShiftCode()).toString(), "加工数", "0"),
|
|
|
|
|
new StationKvBean("color", "颜色", MesExtEnumUtil.COLOR.BLACK.getValue()));
|
|
|
|
|
|
|
|
|
|
StationResultBean shiftCountBean = getStationResultBean(reqBean, productionStatisticsContext,mesWorkCell, mesProdShiftKvBean);
|
|
|
|
|
|
|
|
|
|
this.sendMessage(reqBean, shiftCountBean);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
private StationResultBean getStationResultBean(StationRequestBean reqBean, List<StationKvBean> productionStatisticsContext, MesWorkCell mesWorkCell, MesProdShiftContext mesProdShiftKvBean) {
|
|
|
|
|
StationResultBean resultBean = new StationResultBean();
|
|
|
|
|
resultBean.setBusiType(MesPcnEnumUtil.STATION_BUSI_TYPE.MODULE_CUSTOM_CONTENT.getValue());
|
|
|
|
|
String dataType = MesPcnEnumUtil.STATION_DATA_TYPE.ECHART.getValue();
|
|
|
|
|
JSONObject reqJson = new JSONObject();
|
|
|
|
|
String url = "";
|
|
|
|
|
|
|
|
|
|
List<List<StationKvBean>> orderQtyKvBeans = new ArrayList<>();
|
|
|
|
|
if (!StringUtils.isEmpty(mesWorkCell.getFileId())) {
|
|
|
|
|
DdlPackBean packBean = DdlPackBean.getDdlPackBean();
|
|
|
|
|
|
|
|
|
|
DdlPreparedPack.getNumEqualPack(Long.parseLong(mesWorkCell.getFileId()), "id", packBean);
|
|
|
|
|
MesFile mesFile = mesFileRepository.getByProperty(packBean);
|
|
|
|
|
if (mesFile != null) {
|
|
|
|
|
url = mesFile.getFileUrl();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (Objects.equal(MesExtEnumUtil.WORK_FILE_TYPE.HISTOGRAM.getValue(), mesWorkCell.getIsShowMsg())) {
|
|
|
|
|
dataType = MesPcnEnumUtil.STATION_DATA_TYPE.ECHART.getValue();
|
|
|
|
|
List<MesWorkOrder> workOrderList = workOrderExtService.getWorkOrderListByShiftCode(reqBean.getOrganizeCode(), mesWorkCell.getWorkCenterCode(), mesProdShiftKvBean.getShiftCode());
|
|
|
|
|
if (CollectionUtils.isEmpty(workOrderList)) {
|
|
|
|
|
StationKvBeanUtil.addStationKvBeanList(orderQtyKvBeans, new ArrayList<>(),
|
|
|
|
|
new StationKvBean(MesPcnExtConstWords.QTY, "工单计划数", 0 + ""),
|
|
|
|
|
new StationKvBean(MesPcnExtConstWords.COMPLATED_QTY, "工单完成数", 0 + ""));
|
|
|
|
|
} else {
|
|
|
|
|
double qty = workOrderList.stream().map(MesWorkOrder::getQty).reduce((a, b) -> a + b).get();
|
|
|
|
|
double complateQty = workOrderList.stream().map(MesWorkOrder::getCompleteQty).reduce((a, b) -> a + b).get();
|
|
|
|
|
|
|
|
|
|
StationKvBeanUtil.addStationKvBeanList(orderQtyKvBeans, new ArrayList<>(),
|
|
|
|
|
new StationKvBean(MesPcnExtConstWords.QTY, "工单计划数", qty + ""),
|
|
|
|
|
new StationKvBean(MesPcnExtConstWords.COMPLATED_QTY, "工单完成数", complateQty + ""));
|
|
|
|
|
}
|
|
|
|
|
resultBean.setResultList(orderQtyKvBeans);
|
|
|
|
|
} else if (Objects.equal(MesExtEnumUtil.WORK_FILE_TYPE.PROD_VIDEO.getValue(), mesWorkCell.getIsShowMsg())) {
|
|
|
|
|
dataType = MesPcnEnumUtil.STATION_DATA_TYPE.VIDEO.getValue();
|
|
|
|
|
reqJson.put("url", url);
|
|
|
|
|
resultBean.setResultObj(reqJson);
|
|
|
|
|
} else if (Objects.equal(MesExtEnumUtil.WORK_FILE_TYPE.WORK_CELL_PICTURE.getValue(), mesWorkCell.getIsShowMsg())) {
|
|
|
|
|
dataType = MesPcnEnumUtil.STATION_DATA_TYPE.IMAGE.getValue();
|
|
|
|
|
reqJson.put("url", url);
|
|
|
|
|
resultBean.setResultObj(reqJson);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Objects.equal(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue(),mesWorkCell.getIsCountFinish())) {
|
|
|
|
|
dataType = MesPcnEnumUtil.STATION_DATA_TYPE.TEXT.getValue();
|
|
|
|
|
resultBean.setResultList(productionStatisticsContext);
|
|
|
|
|
}
|
|
|
|
|
resultBean.setDataType(dataType);
|
|
|
|
|
resultBean.setCustomPageName(MesPcnExtConstWords.CUSTOM_PAGE_NAME_WORK_CELL);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return resultBean;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|