pcn line off diff time statistics

dev
王杰 2 years ago
parent 6587ea358a
commit 2f5453ae49

@ -0,0 +1,25 @@
package cn.estsh.i3plus.ext.mes.pcn.api.base.jx;
import cn.estsh.i3plus.ext.mes.pcn.pojo.bean.MesTimeSegmentStatistics;
import io.swagger.annotations.ApiOperation;
import java.util.List;
/**
* @Author: wangjie
* @CreateDate: 2021/01/18 11:22
* @Description:
**/
public interface IJxTimeSegmentStatisticsService {
/**
* 线,
* @param organizeCode
* @param workCenterCode 线
* @param shiftCode
* @return
*/
@ApiOperation(value = "根据生产线代码,班次代码查询分时段统计方式信息", notes = "根据生产线代码,班次代码查询分时段统计方式信息")
List<MesTimeSegmentStatistics> getTimeSegmentStatisticsListByShiftCode(String organizeCode, String workCenterCode, String shiftCode);
}

@ -0,0 +1,27 @@
package cn.estsh.i3plus.ext.mes.pcn.api.busi.jx;
import cn.estsh.i3plus.ext.mes.pcn.pojo.bean.MesOutPutStatisticsTimeSegment;
import io.swagger.annotations.ApiOperation;
import java.util.List;
/**
* @Author: wangjie
* @CreateDate: 2021/01/18 11:22
* @Description:
**/
public interface IJxOutPutStatisticsTimeSegmentService {
/**
* ,,
* @param organizeCode
* @param workOrderNo
* @param workTime
* @param shiftCode
* @param timeSegmentCode
* @return
*/
@ApiOperation(value = "根据工单,作业时间,班次代码,分时代码查询分时产量统计信息", notes = "根据工单,作业时间,班次代码,分时代码查询分时产量统计信息")
List<MesOutPutStatisticsTimeSegment> getOutPutStatisticsTimeSegmentByOrderAndTsCode(String organizeCode, String workOrderNo, String workTime, String shiftCode, String timeSegmentCode);
}

@ -0,0 +1,39 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.base.jx;
import cn.estsh.i3plus.ext.mes.pcn.api.base.jx.IJxTimeSegmentStatisticsService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.bean.MesTimeSegmentStatistics;
import cn.estsh.i3plus.ext.mes.pcn.pojo.repository.MesTimeSegmentStatisticsRepository;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import lombok.extern.slf4j.Slf4j;
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.Comparator;
import java.util.List;
import java.util.stream.Collectors;
/**
* @Author: wangjie
* @CreateDate: 2021/01/18 11:41
* @Description:
**/
@Slf4j
@Service
public class JxTimeSegmentStatisticsService implements IJxTimeSegmentStatisticsService {
@Autowired
private MesTimeSegmentStatisticsRepository timeSegmentStatisticsRepository;
@Override
public List<MesTimeSegmentStatistics> getTimeSegmentStatisticsListByShiftCode(String organizeCode, String workCenterCode, String shiftCode) {
if (StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(workCenterCode) || StringUtils.isEmpty(shiftCode)) return null;
List<MesTimeSegmentStatistics> timeCfgList = timeSegmentStatisticsRepository.findByProperty(
new String[]{MesPcnExtConstWords.ORGANIZE_CODE, MesPcnExtConstWords.IS_DELETED, MesPcnExtConstWords.IS_VALID, MesPcnExtConstWords.WORK_CENTER_CODE, MesPcnExtConstWords.SHIFT_CODE},
new Object[]{organizeCode, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), workCenterCode, shiftCode});
return CollectionUtils.isEmpty(timeCfgList) ? null :
timeCfgList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getStartTime()) && !StringUtils.isEmpty(o.getEndTime()))).sorted(Comparator.comparing(MesTimeSegmentStatistics::getStartTime)).collect(Collectors.toList());
}
}

@ -0,0 +1,46 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi.jx;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.jx.IJxOutPutStatisticsTimeSegmentService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.bean.MesOutPutStatisticsTimeSegment;
import cn.estsh.i3plus.ext.mes.pcn.pojo.repository.MesOutPutStatisticsTimeSegmentRepository;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.List;
/**
* @Author: wangjie
* @CreateDate: 2021/01/18 11:41
* @Description:
**/
@Slf4j
@Service
public class JxOutPutStatisticsTimeSegmentService implements IJxOutPutStatisticsTimeSegmentService {
@Autowired
private MesOutPutStatisticsTimeSegmentRepository outPutStatisticsTimeSegmentRepository;
@Override
public List<MesOutPutStatisticsTimeSegment> getOutPutStatisticsTimeSegmentByOrderAndTsCode(String organizeCode, String workOrderNo, String workTime, String shiftCode, String timeSegmentCode) {
if (StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(workOrderNo) || StringUtils.isEmpty(workTime) || StringUtils.isEmpty(shiftCode) || StringUtils.isEmpty(timeSegmentCode)) return null;
MesOutPutStatisticsTimeSegment outPutStatisticsTimeSegment = outPutStatisticsTimeSegmentRepository.getByProperty(
new String[]{MesPcnExtConstWords.ORGANIZE_CODE, MesPcnExtConstWords.IS_DELETED, MesPcnExtConstWords.IS_VALID, MesPcnExtConstWords.WORK_ORDER_NO, MesPcnExtConstWords.WORK_TIME, MesPcnExtConstWords.TIME_SEGMENT_CODE},
new Object[]{organizeCode, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), workOrderNo, workTime, timeSegmentCode});
List<MesOutPutStatisticsTimeSegment> outPutStatisticsTimeSegmentList;
if (null == outPutStatisticsTimeSegment)
outPutStatisticsTimeSegmentList = outPutStatisticsTimeSegmentRepository.findByProperty(
new String[]{MesPcnExtConstWords.ORGANIZE_CODE, MesPcnExtConstWords.IS_DELETED, MesPcnExtConstWords.IS_VALID, MesPcnExtConstWords.WORK_ORDER_NO, MesPcnExtConstWords.WORK_TIME, MesPcnExtConstWords.SHIFT_CODE},
new Object[]{organizeCode, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), workOrderNo, workTime, shiftCode});
else {
outPutStatisticsTimeSegmentList = new ArrayList<>();
outPutStatisticsTimeSegmentList.add(outPutStatisticsTimeSegment);
}
return outPutStatisticsTimeSegmentList;
}
}

@ -1,10 +1,12 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi.jx;
import cn.estsh.i3plus.ext.mes.pcn.api.base.*;
import cn.estsh.i3plus.ext.mes.pcn.api.base.jx.IJxTimeSegmentStatisticsService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IOutPutStatisticsService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IPackageExtService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IProduceSnTravelExtService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.ISxOutPutStatisticsTravelService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.jx.IJxOutPutStatisticsTimeSegmentService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.jx.IJxProdBusiStrategyService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.jx.IJxProduceSnExtService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.jx.IJxProduceSnMcRecordService;
@ -18,6 +20,7 @@ import cn.estsh.i3plus.mes.pcn.actor.shipping.dispatch.IFsmRouteDataService;
import cn.estsh.i3plus.mes.pcn.serviceimpl.busi.dispatch.cachedispatch.WorkCellDataCacheDispatch;
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
import cn.estsh.i3plus.platform.common.tool.MathOperation;
import cn.estsh.i3plus.platform.common.tool.TimeTool;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil;
import cn.estsh.i3plus.pojo.mes.bean.MesPackageDetail;
@ -122,6 +125,15 @@ public class JxProdBusiStrategyCommonService implements IJxProdBusiStrategyServi
@Autowired
private IPackageExtService packageExtService;
@Autowired
private IJxTimeSegmentStatisticsService timeSegmentStatisticsService;
@Autowired
private IJxOutPutStatisticsTimeSegmentService outPutStatisticsTimeSegmentService;
@Autowired
private MesOutPutStatisticsTimeSegmentRepository outPutStatisticsTimeSegmentRepository;
@Override
public StepResult checkLineOn(JxProdBusiStrategyParamsBuilder params) {
@ -669,7 +681,7 @@ public class JxProdBusiStrategyCommonService implements IJxProdBusiStrategyServi
savePackageInfo(params);
saveOutPutStatistics(params);
saveOutPutStatisticsByTimeSegment(params, saveOutPutStatistics(params));
doProductOffLine(params);
@ -755,7 +767,7 @@ public class JxProdBusiStrategyCommonService implements IJxProdBusiStrategyServi
}
private void saveOutPutStatistics(JxProdBusiStrategyParamsBuilder params) {
private MesOutPutStatistics saveOutPutStatistics(JxProdBusiStrategyParamsBuilder params) {
MesOutPutStatistics outPutStatistics = outPutStatisticsService.getOutPutStatisticsByTimeAndOrderNo(
params.getOrganizeCode(), params.getOrderModel().getOrderNo(), params.getWorkCenterExtDb().getWorkTime(), params.getWorkCenterExtDb().getShiftCode());
@ -797,6 +809,60 @@ public class JxProdBusiStrategyCommonService implements IJxProdBusiStrategyServi
}
outPutStatisticsTravelService.insertOutPutStatisticsTravel(outPutStatistics);
return outPutStatistics;
}
private void saveOutPutStatisticsByTimeSegment(JxProdBusiStrategyParamsBuilder params, MesOutPutStatistics outPutStatistics) {
List<MesTimeSegmentStatistics> timeCfgList = timeSegmentStatisticsService.getTimeSegmentStatisticsListByShiftCode(params.getOrganizeCode(), params.getWorkCenterCode(), params.getWorkCenterExtDb().getShiftCode());
if (CollectionUtils.isEmpty(timeCfgList)) return;
String nowTime = TimeTool.getNowTime(MesPcnExtConstWords.TIME_TRUNCATE_SECOND_FORMAT);
Optional<MesTimeSegmentStatistics> cfgOp = timeCfgList.stream().filter(o -> (null != o &&
TimeTool.stringParseToDate(o.getStartTime(), MesPcnExtConstWords.TIME_TRUNCATE_SECOND_FORMAT).compareTo(TimeTool.stringParseToDate(nowTime, MesPcnExtConstWords.TIME_TRUNCATE_SECOND_FORMAT)) <= 0 &&
TimeTool.stringParseToDate(o.getEndTime(), MesPcnExtConstWords.TIME_TRUNCATE_SECOND_FORMAT).compareTo(TimeTool.stringParseToDate(nowTime, MesPcnExtConstWords.TIME_TRUNCATE_SECOND_FORMAT)) >= 0)).findFirst();
if (null == cfgOp || !cfgOp.isPresent()) return;
List<MesOutPutStatisticsTimeSegment> outPutStatisticsTimeSegmentList = outPutStatisticsTimeSegmentService.
getOutPutStatisticsTimeSegmentByOrderAndTsCode(params.getOrganizeCode(), params.getOrderModel().getOrderNo(), params.getWorkCenterExtDb().getWorkTime(), params.getWorkCenterExtDb().getShiftCode(), cfgOp.get().getTimeSegmentCode());
MesOutPutStatisticsTimeSegment outPutStatisticsTimeSegment;
if (CollectionUtils.isEmpty(outPutStatisticsTimeSegmentList) || !outPutStatisticsTimeSegmentList.get(0).getTimeSegmentCode().equals(cfgOp.get().getTimeSegmentCode())) {
outPutStatisticsTimeSegment = new MesOutPutStatisticsTimeSegment();
outPutStatisticsTimeSegment.setWorkCenterCode(params.getWorkCenterCode());
outPutStatisticsTimeSegment.setWorkOrderNo(params.getOrderModel().getOrderNo());
outPutStatisticsTimeSegment.setPartNo(params.getOrderModel().getPartNo());
outPutStatisticsTimeSegment.setPartNameRdd(params.getOrderModel().getPartNameRdd());
outPutStatisticsTimeSegment.setShiftCode(params.getWorkCenterExtDb().getShiftCode());
outPutStatisticsTimeSegment.setWorkTime(params.getWorkCenterExtDb().getWorkTime());
Double qty = CollectionUtils.isEmpty(outPutStatisticsTimeSegmentList) ? new Double(0) : outPutStatisticsTimeSegmentList.stream().filter(o -> null != o).mapToDouble(MesOutPutStatisticsTimeSegment::getQty).sum();
outPutStatisticsTimeSegment.setQty(MathOperation.sub(outPutStatistics.getQty(), qty));
outPutStatisticsTimeSegment.setPlanQty(params.getOrderModel().getQty());
outPutStatisticsTimeSegment.setWorkOrderType(params.getOrderModel().getWorkOrderType());
outPutStatisticsTimeSegment.setTimeSegmentCode(cfgOp.get().getTimeSegmentCode());
outPutStatisticsTimeSegment.setTimeSegmentsStartTime(cfgOp.get().getStartTime());
outPutStatisticsTimeSegment.setTimeSegmentEndTime(cfgOp.get().getEndTime());
outPutStatisticsTimeSegment.setSystemSyncStatus(MesPcnExtEnumUtil.IF_SYNC_STATUS.NO_SYNC.getValue());
outPutStatisticsTimeSegment.setOrganizeCode(params.getOrganizeCode());
ConvertBean.serviceModelInitialize(outPutStatisticsTimeSegment, params.getUserInfo());
outPutStatisticsTimeSegment.setStartTime(outPutStatisticsTimeSegment.getModifyDatetime());
outPutStatisticsTimeSegment.setEndTime(outPutStatisticsTimeSegment.getStartTime());
outPutStatisticsTimeSegmentRepository.insert(outPutStatisticsTimeSegment);
} else {
outPutStatisticsTimeSegment = outPutStatisticsTimeSegmentList.get(0);
outPutStatisticsTimeSegment.setTimeSegmentsStartTime(cfgOp.get().getStartTime());
outPutStatisticsTimeSegment.setTimeSegmentEndTime(cfgOp.get().getEndTime());
outPutStatisticsTimeSegment.setQty(MathOperation.add(outPutStatisticsTimeSegment.getQty(), new Double(1)));
ConvertBean.serviceModelUpdate(outPutStatisticsTimeSegment, params.getUserInfo());
outPutStatisticsTimeSegment.setEndTime(outPutStatisticsTimeSegment.getModifyDatetime());
outPutStatisticsTimeSegment.setSystemSyncStatus(MesPcnExtEnumUtil.IF_SYNC_STATUS.NO_SYNC.getValue());
outPutStatisticsTimeSegmentRepository.save(outPutStatisticsTimeSegment);
}
}
private void doProductOffLine(JxProdBusiStrategyParamsBuilder params) {

@ -0,0 +1,110 @@
package cn.estsh.i3plus.ext.mes.pcn.pojo.bean;
import cn.estsh.i3plus.pojo.base.bean.BaseBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.ColumnDefault;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import javax.persistence.*;
import java.io.Serializable;
/**
* @Description:
* @Reference:
* @Author: wangjie
* @CreateDate: 2023\02\10 09:45
* @Modify:
**/
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Inheritance(strategy = InheritanceType.JOINED)
@Table(name = "MES_OUT_PUT_STATISTICS_TIME_SEGMENT", indexes = {
@Index(columnList = "WORK_ORDER_NO,WORK_TIME,TIME_SEGMENT_CODE"),
@Index(columnList = "WORK_ORDER_NO,WORK_TIME"),
@Index(columnList = "WORK_ORDER_NO"),
@Index(columnList = "WORK_CENTER_CODE"),
@Index(columnList = "PART_NO"),
@Index(columnList = "SHIFT_CODE"),
@Index(columnList = "WORK_TIME"),
@Index(columnList = "WORK_ORDER_TYPE")
})
@NoArgsConstructor
@AllArgsConstructor
@Api("分时产量统计表")
public class MesOutPutStatisticsTimeSegment extends BaseBean implements Serializable {
private static final long serialVersionUID = -3516752104569948931L;
@Column(name = "SYSTEM_SYNC_STATUS")
@ColumnDefault("2")
@ApiParam(value = "系统同步标志")
public Integer systemSyncStatus = 2;
@Column(name = "WORK_CENTER_CODE")
@ApiParam("产线代码")
private String workCenterCode;
@Column(name = "SHIFT_CODE")
@ApiParam("班次代码")
private String shiftCode;
@Column(name = "WORK_TIME")
@ApiParam("作业时间")
private String workTime;
@Column(name = "WORK_ORDER_NO")
@ApiParam("生产工单号")
private String workOrderNo;
@Column(name = "PART_NO")
@ApiParam("物料号")
private String partNo;
@Column(name = "PART_NAME_RDD")
@ApiParam("物料名称")
private String partNameRdd;
@Column(name = "START_TIME")
@ApiParam("开始时间")
private String startTime;
@Column(name = "END_TIME")
@ApiParam("结束时间")
private String endTime;
@Column(name = "QTY", columnDefinition = "decimal(18,8)")
@ColumnDefault("0")
@ApiParam("产量")
private Double qty;
@Column(name = "PLAN_QTY", columnDefinition = "decimal(18,8)")
@ColumnDefault("0")
@ApiParam("工单计划数量")
private Double planQty;
@Column(name = "WORK_ORDER_TYPE")
@ApiParam("工单类型")
private Integer workOrderType;
@Column(name = "TIME_SEGMENT_CODE")
@ApiParam("分时代码")
private String timeSegmentCode;
@Column(name = "TIME_SEGMENT_START_TIME")
@ApiParam("分时开始时间")
private String timeSegmentsStartTime;
@Column(name = "TIME_SEGMENT_END_TIME")
@ApiParam("分时结束时间")
private String timeSegmentEndTime;
}

@ -0,0 +1,70 @@
package cn.estsh.i3plus.ext.mes.pcn.pojo.bean;
import cn.estsh.i3plus.pojo.base.bean.BaseBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.ColumnDefault;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Index;
import javax.persistence.Table;
import java.io.Serializable;
/**
* @DESCRIPTION: MES_
* @USER: wangjie
* @DATE: 2023-02-03 16:11
*/
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name = "MES_TIME_SEGMENT_STATISTICS", indexes = {
@Index(columnList = "SYSTEM_SYNC_STATUS"),
@Index(columnList = "WORK_CENTER_CODE, SHIFT_CODE")
})
@Api("MES_分时段统计方式表")
public class MesTimeSegmentStatistics extends BaseBean implements Serializable {
private static final long serialVersionUID = -5490654692344095490L;
@Column(name = "WORK_CENTER_CODE")
@ApiParam("工作中心代码")
private String workCenterCode;
@Column(name = "SHIFT_CODE")
@ApiParam("班次")
private String shiftCode;
@Column(name = "START_TIME")
@ApiParam("开始时间")
private String startTime;
@Column(name = "END_TIME")
@ApiParam("结束时间")
private String endTime;
@Column(name = "REST_TIME")
@ApiParam("休息时间")
private String restTime;
@Column(name = "TIME_LENGTH")
@ApiParam("实际工作时间长度(分钟)")
private String timeLength;
@Column(name = "TIME_SEGMENT_CODE")
@ApiParam("分时代码(方便统计)")
private String timeSegmentCode;
@Column(name = "SYSTEM_SYNC_STATUS")
@ColumnDefault("2")
@ApiParam(value = "系统同步标志")
public Integer systemSyncStatus = 2;
}

@ -0,0 +1,15 @@
package cn.estsh.i3plus.ext.mes.pcn.pojo.repository;
import cn.estsh.i3plus.ext.mes.pcn.pojo.bean.MesOutPutStatisticsTimeSegment;
import cn.estsh.i3plus.pojo.base.jpa.dao.BaseRepository;
import org.springframework.stereotype.Repository;
/**
* @Description: RDao
* @Author: wangjie
* @Date: 2023/01/10 09:46
* @Modify:
*/
@Repository
public interface MesOutPutStatisticsTimeSegmentRepository extends BaseRepository<MesOutPutStatisticsTimeSegment,Long> {
}

@ -0,0 +1,9 @@
package cn.estsh.i3plus.ext.mes.pcn.pojo.repository;
import cn.estsh.i3plus.ext.mes.pcn.pojo.bean.MesTimeSegmentStatistics;
import cn.estsh.i3plus.pojo.base.jpa.dao.BaseRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface MesTimeSegmentStatisticsRepository extends BaseRepository<MesTimeSegmentStatistics, Long> {
}

@ -472,6 +472,9 @@ public class MesPcnExtConstWords {
//数据类型
public static final String DATA_TYPE = "dataType";
//分时代码
public static final String TIME_SEGMENT_CODE = "timeSegmentCode";
//-----------------PRINT--------------------------
//-----------------CONFIG--------------------------

Loading…
Cancel
Save