嘉兴 mes 节拍客制化报表

tags/yfai-mes-ext-v1.0
王杰 1 year ago
parent 09f7451661
commit 40084c90be

@ -1,6 +1,7 @@
package cn.estsh.i3plus.ext.mes.api.busi.jx;
import cn.estsh.i3plus.ext.mes.pojo.bean.SxWorkCellTaktCollectRecord;
import cn.estsh.i3plus.ext.mes.pojo.model.jx.JxCellTaktReportModel;
import cn.estsh.i3plus.pojo.base.bean.ListPager;
import cn.estsh.i3plus.pojo.base.common.Pager;
import io.swagger.annotations.ApiOperation;
@ -12,17 +13,25 @@ public interface ISxWorkCellTaktCollectRecordService {
* @param workCellTaktCollectRecord
* @return
*/
@ApiOperation(value = "根据产品条码查询包装条码明细信息", notes = "根据产品条码查询包装条码明细信息")
ListPager<SxWorkCellTaktCollectRecord> queryWorkCellTaktCollectRecrodLByPager(SxWorkCellTaktCollectRecord workCellTaktCollectRecord, Pager pager);
@ApiOperation(value = "条件分页查询松下工位节拍采集记录", notes = "条件分页查询松下工位节拍采集记录")
ListPager<SxWorkCellTaktCollectRecord> queryWorkCellTaktCollectRecordListByPager(SxWorkCellTaktCollectRecord workCellTaktCollectRecord, Pager pager);
/**
*
* /
* @param ids id
* @param status
* @param userName
* @return
*/
@ApiOperation(value = "根据产品条码查询包装条码明细信息", notes = "根据产品条码查询包装条码明细信息")
@ApiOperation(value = "批量禁用/启用状态", notes = "批量禁用/启用状态")
int updateWorkCellTaktCollectRecordValid(String[] ids, int status, String userName);
/**
*
* @param modl
* @param pager
* @return
*/
@ApiOperation(value = "按条件分页工位节拍报表", notes = "按条件分页工位节拍报表")
ListPager<JxCellTaktReportModel> queryCellTaktReportListByPager(JxCellTaktReportModel modl, Pager pager);
}

@ -2,6 +2,7 @@ package cn.estsh.i3plus.ext.mes.apiservice.controller.busi.jx;
import cn.estsh.i3plus.ext.mes.api.busi.jx.ISxWorkCellTaktCollectRecordService;
import cn.estsh.i3plus.ext.mes.pojo.bean.SxWorkCellTaktCollectRecord;
import cn.estsh.i3plus.ext.mes.pojo.model.jx.JxCellTaktReportModel;
import cn.estsh.i3plus.ext.mes.pojo.util.MesExtConstWords;
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
import cn.estsh.i3plus.pojo.base.bean.ListPager;
@ -12,6 +13,7 @@ import cn.estsh.impp.framework.boot.auth.AuthUtil;
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
import cn.estsh.impp.framework.boot.util.ResultBean;
import cn.estsh.impp.framework.boot.util.ValidatorBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
@ -36,10 +38,10 @@ public class SxWorkCelITaktCollectRecordReportController extends MesBaseControll
@GetMapping(value = "/work-cell-takt-collect-record/query")
@ApiOperation(value = "按条件分页查询MES工位节拍采集记录数据")
public ResultBean queryMesProdBindRecord(SxWorkCellTaktCollectRecord workCelITaktCollectRecord, Pager pager) {
public ResultBean queryWorkCellTaktCollectRecordListByPager(SxWorkCellTaktCollectRecord workCelITaktCollectRecord, Pager pager) {
try {
workCelITaktCollectRecord.setOrganizeCode(AuthUtil.getOrganize().getOrganizeCode());
ListPager listPager = workCellTaktCollectRecordService.queryWorkCellTaktCollectRecrodLByPager(workCelITaktCollectRecord, pager);
ListPager listPager = workCellTaktCollectRecordService.queryWorkCellTaktCollectRecordListByPager(workCelITaktCollectRecord, pager);
return ResultBean.success("查询成功").setListPager(listPager)
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
} catch (ImppBusiException busExcep) {
@ -51,7 +53,7 @@ public class SxWorkCelITaktCollectRecordReportController extends MesBaseControll
@PutMapping(value = "/work-cell-takt-collect-record/update-valid-batch")
@ApiOperation(value = "批量禁用/启用状态", notes = "批量禁用/启用状态")
public ResultBean updateSxWorkCellTaktCollectPlcCfgStatus(String[] ids, int status) {
public ResultBean updateWorkCellTaktCollectRecordValid(String[] ids, int status) {
try {
ConvertBean.modelSafeArrayNumber(ids, true);
workCellTaktCollectRecordService.updateWorkCellTaktCollectRecordValid(ids, status, AuthUtil.getSessionUser().getUserName());
@ -64,4 +66,23 @@ public class SxWorkCelITaktCollectRecordReportController extends MesBaseControll
}
}
@GetMapping(value = "/work-cell-takt-report/query")
@ApiOperation(value = "按条件分页工位节拍报表")
public ResultBean queryCellTaktReportListByPager(JxCellTaktReportModel model, Pager pager) {
try {
ValidatorBean.beginValid(model)
.notNull(MesExtConstWords.DIMENSION, model.getDimension())
.notNull(MesExtConstWords.WORK_CENTER_CODE, model.getWorkCenterCode())
.notNull(MesExtConstWords.CREATE_DATE_TIME_START, model.getCreateDatetimeStart())
.notNull(MesExtConstWords.CREATE_DATE_TIME_END, model.getCreateDatetimeEnd());
model.setOrganizeCode(AuthUtil.getOrganize().getOrganizeCode());
return ResultBean.success("查询成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode())
.setListPager(workCellTaktCollectRecordService.queryCellTaktReportListByPager(model, pager));
} catch (ImppBusiException busExcep) {
return ResultBean.fail(busExcep);
} catch (Exception e) {
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
}
}
}

@ -2,20 +2,27 @@ package cn.estsh.i3plus.ext.mes.apiservice.serviceimpl.busi.jx;
import cn.estsh.i3plus.ext.mes.api.busi.jx.ISxWorkCellTaktCollectRecordService;
import cn.estsh.i3plus.ext.mes.pojo.bean.SxWorkCellTaktCollectRecord;
import cn.estsh.i3plus.ext.mes.pojo.model.jx.JxCellTaktReportModel;
import cn.estsh.i3plus.ext.mes.pojo.repository.SxWorkCellTaktCollectRecordRepository;
import cn.estsh.i3plus.ext.mes.pojo.sqlpack.MesExtHqlPack;
import cn.estsh.i3plus.ext.mes.pojo.util.MesExtConstWords;
import cn.estsh.i3plus.ext.mes.pojo.util.MesExtEnumUtil;
import cn.estsh.i3plus.platform.common.tool.MathOperation;
import cn.estsh.i3plus.platform.common.tool.TimeTool;
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
import cn.estsh.i3plus.pojo.base.bean.ListPager;
import cn.estsh.i3plus.pojo.base.common.Pager;
import cn.estsh.i3plus.pojo.base.common.PagerHelper;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
import cn.estsh.i3plus.pojo.base.tool.HqlPack;
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.List;
import java.util.*;
import java.util.stream.Collectors;
/**
* @PROJECT_NAME: i3plus-mes-panasonic-jx
@ -30,7 +37,7 @@ public class SxWorkCellTaktCollectRecordService implements ISxWorkCellTaktCollec
private SxWorkCellTaktCollectRecordRepository workCellTaktCollectRecordRepository;
@Override
public ListPager<SxWorkCellTaktCollectRecord> queryWorkCellTaktCollectRecrodLByPager(SxWorkCellTaktCollectRecord workCellTaktCollectRecord, Pager pager) {
public ListPager<SxWorkCellTaktCollectRecord> queryWorkCellTaktCollectRecordListByPager(SxWorkCellTaktCollectRecord workCellTaktCollectRecord, Pager pager) {
if (workCellTaktCollectRecord == null) {
pager = PagerHelper.getPager(pager, workCellTaktCollectRecordRepository.listCount());
return new ListPager(workCellTaktCollectRecordRepository.listPager(pager), pager);
@ -57,4 +64,65 @@ public class SxWorkCellTaktCollectRecordService implements ISxWorkCellTaktCollec
return num;
}
@Override
public ListPager<JxCellTaktReportModel> queryCellTaktReportListByPager(JxCellTaktReportModel model, Pager pager) {
List<JxCellTaktReportModel> resultList = new ArrayList<>();
List<SxWorkCellTaktCollectRecord> recordDbList;
DdlPackBean packBean = DdlPackBean.getDdlPackBean(model.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(model.getWorkCenterCode(), MesExtConstWords.WORK_CENTER_CODE, packBean);
DdlPreparedPack.getStringEqualPack(model.getWorkCellCode(), MesExtConstWords.WORK_CELL_CODE, packBean);
if (!StringUtils.isEmpty(model.getCreateDatetimeStart()) || !StringUtils.isEmpty(model.getCreateDatetimeEnd()))
DdlPreparedPack.timeBuilder(model.getCreateDatetimeStart(), model.getCreateDatetimeEnd(), MesExtConstWords.MODIFY_DATE_TIME, packBean, true);
DdlPreparedPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.ASC.getValue()}, new String[]{MesExtConstWords.CREATE_DATE_TIME}, packBean);
if (model.getDimension() == 1) {
pager = PagerHelper.getPager(pager, workCellTaktCollectRecordRepository.findByHqlWhereCount(packBean));
recordDbList = workCellTaktCollectRecordRepository.findByHqlWherePage(packBean, pager);
Integer index = (pager.getCurrentPage() - 1) * pager.getPageSize() + 1;
for (SxWorkCellTaktCollectRecord recordDb : recordDbList) {
JxCellTaktReportModel result = new JxCellTaktReportModel(model.getOrganizeCode(), model.getWorkCenterCode(), recordDb.getWorkCellCode());
result.setDay(recordDb.getCreateDatetime().substring(0, 10));
result.setTime(recordDb.getCreateDatetime().substring(11));
result.setIndex(index);
result.setWorkTakt(new Double(recordDb.getWorkTakt()));
result.setPartNo(recordDb.getPartNo());
result.setPartNameRdd(recordDb.getPartNameRdd());
result.setStandardWork(recordDb.getStandardWork());
result.setWorkerQty(recordDb.getWorkerQty());
if (!StringUtils.isEmpty(result.getStandardWork()) && !StringUtils.isEmpty(result.getWorkerQty()))
result.setWorkTaktCalc(MathOperation.div(MathOperation.mul(result.getStandardWork(), new Double(60)), result.getWorkerQty()));
resultList.add(result);
index ++;
}
} else {
recordDbList = workCellTaktCollectRecordRepository.findByHqlWhere(packBean);
Map<String, List<SxWorkCellTaktCollectRecord>> recordDbMap2Cell = CollectionUtils.isEmpty(recordDbList) ? null : recordDbList.stream().filter(o -> null != o).collect(Collectors.groupingBy(SxWorkCellTaktCollectRecord::getWorkCellCode));
DoubleSummaryStatistics statistics;
if (!CollectionUtils.isEmpty(recordDbMap2Cell)) {
recordDbMap2Cell = recordDbMap2Cell.entrySet().stream().sorted(Map.Entry.comparingByKey()).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e2, LinkedHashMap::new));
for (Map.Entry<String, List<SxWorkCellTaktCollectRecord>> entry : recordDbMap2Cell.entrySet()) {
if (null == entry) continue;
List<SxWorkCellTaktCollectRecord> recordDbList2Cell = entry.getValue();
statistics = recordDbList2Cell.stream().filter(o -> null != o).mapToDouble(o -> new Double(o.getWorkTakt())).summaryStatistics();
JxCellTaktReportModel result = new JxCellTaktReportModel(model.getOrganizeCode(), model.getWorkCenterCode(), entry.getKey());
result.setCreateDatetimeStart(model.getCreateDatetimeStart());
result.setCreateDatetimeEnd(model.getCreateDatetimeEnd());
result.setWorkTakt(statistics.getAverage());
result.setWorkTaktMax(statistics.getMax());
result.setWorkTaktMin(statistics.getMin());
resultList.add(result);
}
}
statistics = CollectionUtils.isEmpty(resultList) ? null : resultList.stream().filter(o -> null != o).mapToDouble(JxCellTaktReportModel::getWorkTaktMin).summaryStatistics();
pager = PagerHelper.getPager(pager, resultList.size());
resultList = CollectionUtils.isEmpty(resultList) ? resultList :
resultList.subList((pager.getCurrentPage() - 1) * pager.getPageSize(), (pager.getCurrentPage() * pager.getPageSize()) > resultList.size() ? resultList.size() : pager.getCurrentPage() * pager.getPageSize());
if (!CollectionUtils.isEmpty(resultList)) resultList.get(0).setWorkTaktCalc(statistics.getAverage());
}
return new ListPager(resultList, pager);
}
}

@ -0,0 +1,78 @@
package cn.estsh.i3plus.ext.mes.pojo.model.jx;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiParam;
import lombok.Data;
import java.io.Serializable;
/**
* @DESCRIPTION:
* @USER: wangjie
* @DATE: 2022-11-01 15:54
*/
@Data
@ApiModel("嘉兴节拍报表MODEL")
public class JxCellTaktReportModel implements Serializable {
private static final long serialVersionUID = -4833453374872130256L;
@ApiParam("组织代码")
public String organizeCode;
@ApiParam("工位维度")
public Integer dimension;
@ApiParam("查询时间")
public String createDatetimeStart;
@ApiParam("查询时间")
public String createDatetimeEnd;
@ApiParam("生产线代码")
public String workCenterCode;
@ApiParam("工位代码")
public String workCellCode;
@ApiParam("日期")
public String day;
@ApiParam("时间")
public String time;
@ApiParam("次数")
public Integer index;
@ApiParam("实际节拍")
private Double workTakt;
@ApiParam("物料编码")
private String partNo;
@ApiParam("物料名称")
private String partNameRdd;
@ApiParam("标准工数")
private Double standardWork;
@ApiParam("标准节拍/最小节拍平均")
private Double workTaktCalc;
@ApiParam("作业人数")
private Double workerQty;
@ApiParam("最大节拍")
private Double workTaktMax;
@ApiParam("最小节拍")
private Double workTaktMin;
public JxCellTaktReportModel() {}
public JxCellTaktReportModel(String organizeCode, String workCenterCode, String workCellCode) {
this.organizeCode = organizeCode;
this.workCenterCode = workCenterCode;
this.workCellCode = workCellCode;
}
}
Loading…
Cancel
Save