Merge branch 'master' of http://10.153.19.25:10105/r/YiWuProject
| | |
| | | const saveScheduling = async () => { |
| | | try { |
| | | let type = 1; |
| | | // 1. 动态确定 type 和接口路径(根据 activeTab 切换) |
| | | const apiPath = activeTab.value === 'tempered' |
| | | ? 'updateEngineerScheduling' |
| | | : 'updateCuttingLayout'; |
| | | |
| | | if (activeTab.value === 'cutting2') type = 2; |
| | | else if (activeTab.value === 'tempered') type = 3; |
| | | |
| | |
| | | })) |
| | | |
| | | const response = await request.post( |
| | | `/loadGlass/optimizeProject/updateEngineerScheduling?type=${type}`, |
| | | engineerList |
| | | `/loadGlass/optimizeProject/${apiPath}?type=${type}`, engineerList |
| | | ) |
| | | |
| | | if (response.code === 200) { |
| | |
| | | |
| | | // 查找所有非进行中任务的位置 |
| | | const nonProgressIndices = newList |
| | | .map((item, i) => ({ item, index: i })) |
| | | .map((item, i) => ({item, index: i})) |
| | | .filter(item => item.item.state !== 1) |
| | | .map(item => item.index); |
| | | |
| | |
| | | width="90" |
| | | :formatter="stateFormatter" |
| | | /> |
| | | <el-table-column :label="t('scheduling.operate')" :width="activeTab === 'tempered' ? 200 : 300" :align="center"> |
| | | <el-table-column :label="t('scheduling.operate')" :width="activeTab === 'tempered' ? 200 : 300" |
| | | :align="center"> |
| | | <template #default="{ row }"> |
| | | <div style="display: flex; gap: 5px; align-items: center;"> |
| | | <el-button |
| | |
| | | align-items: center; |
| | | gap: 20px; |
| | | margin-bottom: 20px; |
| | | overflow: auto; |
| | | } |
| | | |
| | | /* 详情表格样式 */ |
| | |
| | | }; |
| | | const selectgong = async (queryString: string) => { |
| | | try { |
| | | const response = await request.post('/loadGlass/optimizeProject/listByState', { |
| | | const response = await request.post('/loadGlass/engineerScheduling/queryEngineerScheduling', { |
| | | ...requestData, |
| | | query: queryString |
| | | }); |
| | |
| | | package com.mes.engineerScheduling.controller; |
| | | |
| | | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import com.mes.engineerScheduling.entity.EngineerScheduling; |
| | | import com.mes.engineerScheduling.service.EngineerSchedulingService; |
| | | import com.mes.pp.entity.OptimizeProject; |
| | | import com.mes.pp.entity.request.OptimizeRequest; |
| | | import com.mes.pp.service.OptimizeProjectService; |
| | | import com.mes.utils.Result; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @since 2025-10-27 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/engineerScheduling/engineer-scheduling") |
| | | @RequestMapping("/engineerScheduling") |
| | | @Slf4j |
| | | @Api(tags = "排产信息") |
| | | public class EngineerSchedulingController { |
| | | @Autowired |
| | | //获取待选择的工程号 |
| | | private EngineerSchedulingService engineerSchedulingService; |
| | | |
| | | @ApiOperation("显示工程选择信息") |
| | | @PostMapping("/queryEngineerScheduling") //显示工程选择信息 |
| | | @ResponseBody |
| | | public Result<List<EngineerScheduling>> queryEngineerScheduling() { |
| | | //获取待选择的工程号 |
| | | List<EngineerScheduling> engineerScheduling = engineerSchedulingService.listByState(); |
| | | return Result.build(200, "", engineerScheduling); |
| | | } |
| | | } |
| | | |
| | |
| | | package com.mes.engineerScheduling.service; |
| | | |
| | | import com.baomidou.dynamic.datasource.annotation.DS; |
| | | import com.mes.engineerScheduling.entity.EngineerScheduling; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @author wf |
| | | * @since 2025-10-27 |
| | | */ |
| | | @DS("north_glass_mes") |
| | | public interface EngineerSchedulingService extends IService<EngineerScheduling> { |
| | | //查询当前切割排版的工程号 |
| | | List<EngineerScheduling> listByState(); |
| | | //查询当前钢化排版工程号 |
| | | List<EngineerScheduling> queryByType(Integer type); |
| | | //修改已取消的钢化排版状态 |
| | | void updateState(List<String> engineerIds); |
| | | //取消当前类型的工程排产信息 |
| | | void updateByType(Integer type); |
| | | |
| | | } |
| | |
| | | package com.mes.engineerScheduling.service.impl; |
| | | |
| | | import com.baomidou.dynamic.datasource.annotation.DS; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.mes.engineerScheduling.entity.EngineerScheduling; |
| | | import com.mes.engineerScheduling.mapper.EngineerSchedulingMapper; |
| | | import com.mes.engineerScheduling.service.EngineerSchedulingService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @since 2025-10-27 |
| | | */ |
| | | @Service |
| | | @DS("north_glass_mes") |
| | | public class EngineerSchedulingServiceImpl extends ServiceImpl<EngineerSchedulingMapper, EngineerScheduling> implements EngineerSchedulingService { |
| | | |
| | | @Override |
| | | public List<EngineerScheduling> listByState() { |
| | | QueryWrapper<EngineerScheduling> wrapper = new QueryWrapper<>(); |
| | | wrapper.lt("type", 3); |
| | | return baseMapper.selectList(wrapper); |
| | | } |
| | | |
| | | @Override |
| | | public List<EngineerScheduling> queryByType(Integer type) { |
| | | QueryWrapper<EngineerScheduling> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("type", type); |
| | | return baseMapper.selectList(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public void updateState(List<String> engineerIds) { |
| | | QueryWrapper<EngineerScheduling> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.in("project_no", engineerIds); |
| | | EngineerScheduling engineerScheduling = new EngineerScheduling(); |
| | | engineerScheduling.setState(200); |
| | | baseMapper.update(engineerScheduling, queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public void updateByType(Integer type) { |
| | | QueryWrapper<EngineerScheduling> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("type", type); |
| | | EngineerScheduling engineerScheduling = new EngineerScheduling(); |
| | | engineerScheduling.setState(200); |
| | | baseMapper.update(engineerScheduling, queryWrapper); |
| | | } |
| | | } |
| | |
| | | List<OptimizeProject> resultList = optimizeProjectService.updateEngineerScheduling(type, engineerList); |
| | | return Result.build(200, "更新成功", resultList); |
| | | } |
| | | @ApiOperation("更新切割工程信息") |
| | | @PostMapping("/updateCuttingLayout") //更新工程排产信息 engineerScheduling表 |
| | | @ResponseBody |
| | | public Result<List<OptimizeProject>> updateCuttingLayout(@RequestParam Integer type, @RequestBody List<OptimizeProject> engineerList) { |
| | | List<OptimizeProject> resultList = optimizeProjectService.updateCuttingLayout(type, engineerList); |
| | | return Result.build(200, "更新成功", resultList); |
| | | } |
| | | @ApiOperation("查询工程进度") |
| | | @PostMapping("/selectProgress") //更新工程排产信息 engineerScheduling表 |
| | | @ResponseBody |
| | |
| | | List<OptimizeProject> updateEngineerScheduling(Integer type, List<OptimizeProject> engineerList); |
| | | |
| | | /** |
| | | * 更新工程排产信息 |
| | | * |
| | | * @return |
| | | */ |
| | | List<OptimizeProject> updateCuttingLayout(Integer type, List<OptimizeProject> engineerList); |
| | | |
| | | /** |
| | | * 删除工程排产信息 |
| | | * |
| | | * @return |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.github.yulichang.base.MPJBaseServiceImpl; |
| | | import com.mes.engineerScheduling.entity.EngineerScheduling; |
| | | import com.mes.engineerScheduling.service.EngineerSchedulingService; |
| | | import com.mes.engineering.entity.Engineering; |
| | | import com.mes.engineering.service.EngineeringService; |
| | | import com.mes.pp.entity.OptimizeProject; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | public class OptimizeProjectServiceImpl extends MPJBaseServiceImpl<OptimizeProjectMapper, OptimizeProject> implements OptimizeProjectService { |
| | | @Autowired |
| | | private EngineeringService engineeringService; |
| | | @Autowired |
| | | private EngineerSchedulingService engineerSchedulingService; |
| | | |
| | | @Override |
| | | public List<OptimizeProject> listByState(OptimizeRequest optimizeRequest) { |
| | |
| | | public List<OptimizeProject> updateEngineerScheduling(Integer type, List<OptimizeProject> projectList) { |
| | | // 1. 删除对应类型的数据 |
| | | baseMapper.deleteByType(type); |
| | | |
| | | // 2. 设置值 |
| | | projectList.forEach(project -> { |
| | | project.setType(type); |
| | |
| | | |
| | | return projectList; |
| | | } |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @DS("north_glass_mes") |
| | | public List<OptimizeProject> updateCuttingLayout(Integer type, List<OptimizeProject> projectList) { |
| | | //获取当前钢化排版信息 |
| | | List<EngineerScheduling> engineerScheduling = engineerSchedulingService.queryByType(3); |
| | | List<EngineerScheduling> cutting = new ArrayList<>(); |
| | | if(type==1){ |
| | | cutting = engineerSchedulingService.queryByType(2); |
| | | }else { |
| | | cutting = engineerSchedulingService.queryByType(1); |
| | | } |
| | | //保存新增钢化排版信息 |
| | | List<EngineerScheduling> newSchedulingList = new ArrayList<>(); |
| | | Set<String> existingProjectNoSet = engineerScheduling.stream() |
| | | .map(EngineerScheduling::getProjectNo) |
| | | .collect(Collectors.toSet()); |
| | | // 获取当前排版新增工程 |
| | | for (OptimizeProject project : projectList) { |
| | | String projectNo = project.getProjectNo(); |
| | | // 工程号非空,且不在已有钢化排产数据中 |
| | | if (projectNo != null && !existingProjectNoSet.contains(projectNo)) { |
| | | EngineerScheduling newEs = new EngineerScheduling(); |
| | | newEs.setProjectNo(projectNo); |
| | | newEs.setProjectName(project.getProjectName()); |
| | | newEs.setType(3); |
| | | newEs.setState(100); |
| | | newSchedulingList.add(newEs); |
| | | } |
| | | } |
| | | //获取当前排版取消工程 |
| | | Set<String> cuttingProjectNos = new HashSet<>(); |
| | | for (EngineerScheduling es : cutting) { |
| | | if (es.getProjectNo() != null) { // 避免空指针 |
| | | cuttingProjectNos.add(es.getProjectNo()); |
| | | } |
| | | } |
| | | engineerScheduling = engineerScheduling.stream() |
| | | .filter(es -> es.getProjectNo() == null || !cuttingProjectNos.contains(es.getProjectNo())) |
| | | .collect(Collectors.toList()); |
| | | //1号线钢化数据对比1号线切割数据 |
| | | Set<String> projectNoSet2 = new HashSet<>(); |
| | | for (OptimizeProject project : projectList) { |
| | | String projectNo = project.getProjectNo(); |
| | | if (projectNo != null) { // 避免空指针 |
| | | projectNoSet2.add(projectNo); |
| | | } |
| | | } |
| | | // 2. 筛选并收集符合条件的工程号(String类型)到 List<String> |
| | | List<String> missingProjectNos = engineerScheduling.stream() |
| | | .map(EngineerScheduling::getProjectNo) // 提取 engineerScheduling 中的工程号 |
| | | .filter(esProjectNo -> esProjectNo != null // 排除空工程号 |
| | | && !projectNoSet2.contains(esProjectNo)) // 排除 projectList 中存在的工程号 |
| | | .collect(Collectors.toList()); // 收集结果到 List<String> |
| | | for (OptimizeProject project : projectList) { |
| | | project.setType(type); |
| | | project.setState(100); |
| | | } |
| | | //新增钢化排版数据 |
| | | engineerSchedulingService.saveBatch(newSchedulingList); |
| | | //更新已取消的钢化排版状态 |
| | | if(CollectionUtils.isNotEmpty(missingProjectNos)){ |
| | | engineerSchedulingService.updateState(missingProjectNos); |
| | | } |
| | | //取消当前类型的工程排产信息 |
| | | engineerSchedulingService.updateByType(type); |
| | | //保存当前新切割排版数据 |
| | | baseMapper.batchInsert(projectList); |
| | | return projectList; |
| | | } |
| | | |
| | | @Override |
| | | public void deleteengineerSchedulingByid(String engineerId, List<Integer> types) { |
| | |
| | | if (null == edgStorageCageDetails) { |
| | | // 获取历史表中上次任务最后一片尺寸 |
| | | EdgStorageDeviceTaskHistory edgeData = edgStorageDeviceTaskHistoryService.getOne(new LambdaQueryWrapper<EdgStorageDeviceTaskHistory>() |
| | | .eq(EdgStorageDeviceTaskHistory::getDeviceId, cell) |
| | | .eq(EdgStorageDeviceTaskHistory::getEndCell, cell) |
| | | .in(EdgStorageDeviceTaskHistory::getTaskType, Const.GLASS_CACHE_TYPE_OUT, Const.GLASS_CACHE_TYPE_THROUGH) |
| | | .orderByDesc(EdgStorageDeviceTaskHistory::getId).last("limit 1")); |
| | | log.info("{}获取上次任务信息:{}", deviceId, edgeData); |
| | |
| | | .eq(BigStorageCage::getEnableState, Const.SLOT_ON) |
| | | .eq(BigStorageCage::getRemainWidth, slotWidth).orderByAsc(BigStorageCage::getSlot) |
| | | .inSql(BigStorageCage::getDeviceId, |
| | | "select distinct device_id from big_storage_cage_details where engineer_id = '" + EngineerId + "'") |
| | | "select distinct device_id from big_storage_cage_details where engineer_id = '" + EngineerId + "' and device_id not in (5,6)") |
| | | .last("limit 1")); |
| | | if (null != bigStorageCage) { |
| | | log.info("根据版图id找到笼子内的目标格子:{},玻璃id:{}", bigStorageCage.getSlot(), glassId); |
| | |
| | | return; |
| | | } |
| | | Integer slotWidth = sysConfigService.queryConfigValue(ConstSysConfig.VERTICAL_SLOT_WIDTH); |
| | | // Integer glassGap = sysConfigService.queryConfigValue(ConstSysConfig.VERTICAL_GLASS_GAP); |
| | | Integer outCarMaxSize = sysConfigService.queryConfigValue(ConstSysConfig.VERTICAL_OUT_CAR_SIZE); |
| | | // Engineering engineering = engineeringMapper.selectOne(new LambdaQueryWrapper<Engineering>() |
| | | // .eq(Engineering::getEngineerId, glassInfo.getEngineerId())); |
| | | //获取玻璃的工程id,按照工程id获取工程下的所有玻璃信息 |
| | | List<GlassInfo> glassInfoList = glassInfoService.list(new LambdaQueryWrapper<GlassInfo>() |
| | | .eq(GlassInfo::getEngineerId, engineerId) |
| | |
| | | <select id="queryFreeDeviceByUsed" resultType="java.lang.Integer"> |
| | | SELECT T.DEVICE_ID |
| | | FROM BIG_STORAGE_CAGE T |
| | | LEFT JOIN (SELECT * FROM BIG_STORAGE_CAGE_DETAILS WHERE STATE NOT IN (101, 8, 9)) T1 |
| | | ON T.SLOT = T1.SLOT |
| | | LEFT JOIN (SELECT * FROM BIG_STORAGE_CAGE_DETAILS WHERE STATE NOT IN (101, 8, 9)) T1 |
| | | ON T.SLOT = T1.SLOT |
| | | WHERE T.MAX_THICKNESS >= #{thickness} |
| | | and t.MIN_THICKNESS <= #{thickness} |
| | | AND T.ENABLE_STATE = 1 |
| | | and t.MIN_THICKNESS <= #{thickness} |
| | | AND T.ENABLE_STATE = 1 |
| | | and t.device_id not in (5,6) |
| | | GROUP BY T.DEVICE_ID |
| | | HAVING count(t.slot) - COUNT(DISTINCT T1.slot) > 0 |
| | | ORDER BY COUNT(DISTINCT T1.ENGINEER_ID), count(t.slot) - COUNT(DISTINCT T1.slot) desc |
| | | </select> |
| | | |
| | | <select id="selectBigStorageSummary" resultType="com.mes.bigstorage.entity.dto.BigStorageSummaryDTO"> |
| | | SELECT engineer_id as engineerId, |
| | | count(tempering_layout_id) AS countTemp, |
| | | sum(countGlass) AS countGlass, |
| | | round(sum(area), 2) as area, |
| | | sum(fullTemp) AS fullTemp, |
| | | sum(countSlot) AS countSlot, |
| | | sum(countGlass) / sum(countGlass1) * 100 AS percent, |
| | | thickness |
| | | SELECT engineer_id as engineerId, |
| | | count(tempering_layout_id) AS countTemp, |
| | | sum(countGlass) AS countGlass, |
| | | round(sum(area), 2) as area, |
| | | sum(fullTemp) AS fullTemp, |
| | | sum(countSlot) AS countSlot, |
| | | sum(countGlass) / sum(countGlass1) * 100 AS percent, |
| | | thickness |
| | | FROM ( |
| | | SELECT bscd.engineer_id, |
| | | bscd.tempering_layout_id, |
| | | count(*) AS countGlass, |
| | | sum(bscd.width * bscd.height / 1000000) AS area, |
| | | IF |
| | | (gi.countGlass1 = count(*), 1, 0) AS fullTemp, |
| | | count(DISTINCT bscd.slot) AS countSlot, |
| | | countGlass1, |
| | | gi.thickness |
| | | FROM big_storage_cage_details bscd |
| | | INNER JOIN (SELECT engineer_id, tempering_layout_id, count(*) AS countGlass1, thickness |
| | | FROM glass_info |
| | | GROUP BY engineer_id, tempering_layout_id) gi ON bscd.engineer_id = gi.engineer_id |
| | | AND bscd.tempering_layout_id = gi.tempering_layout_id |
| | | WHERE bscd.state = 100 |
| | | GROUP BY bscd.engineer_id, |
| | | bscd.tempering_layout_id |
| | | ) AS cageSummary |
| | | SELECT bscd.engineer_id, |
| | | bscd.tempering_layout_id, |
| | | count(*) AS countGlass, |
| | | sum(bscd.width * bscd.height / 1000000) AS area, |
| | | IF |
| | | (gi.countGlass1 = count(*), 1, 0) AS fullTemp, |
| | | count(DISTINCT bscd.slot) AS countSlot, |
| | | countGlass1, |
| | | gi.thickness |
| | | FROM big_storage_cage_details bscd |
| | | INNER JOIN (SELECT engineer_id, tempering_layout_id, count(*) AS countGlass1, thickness |
| | | FROM glass_info |
| | | GROUP BY engineer_id, tempering_layout_id) gi ON bscd.engineer_id = gi.engineer_id |
| | | AND bscd.tempering_layout_id = gi.tempering_layout_id |
| | | WHERE bscd.state = 100 |
| | | GROUP BY bscd.engineer_id, |
| | | bscd.tempering_layout_id |
| | | ) AS cageSummary |
| | | GROUP BY engineer_id |
| | | ORDER BY percent DESC, |
| | | countSlot DESC, |
| | | thickness DESC |
| | | countSlot DESC, |
| | | thickness DESC |
| | | </select> |
| | | <select id="queryPieChart" resultType="com.mes.largenscreen.entity.PieChartVO"> |
| | | SELECT round(sum(CASE WHEN e.station_cell = 5 THEN 1 ELSE 0 END), 2) as oneCompletedQuantity, |
| | | round(sum(CASE WHEN e.station_cell = 5 THEN bscd.width * bscd.height / 1000000 ELSE 0 END), |
| | | 2) as oneCompletedArea, |
| | | round(sum(CASE WHEN e.station_cell = 6 THEN 1 ELSE 0 END), 2) as twoCompletedQuantity, |
| | | round(sum(CASE WHEN e.station_cell = 6 THEN bscd.width * bscd.height / 1000000 ELSE 0 END), |
| | | 2) as twoCompletedArea, |
| | | round(sum(CASE WHEN e.station_cell = 5 and bscd.device_id is null THEN 1 ELSE 0 END), |
| | | 2) as oneUncompletedQuantity, |
| | | round(sum(CASE |
| | | WHEN e.station_cell = 5 and bscd.device_id is null THEN gi.width * gi.height / 1000000 |
| | | ELSE 0 END), |
| | | 2) as oneUncompletedArea, |
| | | round(sum(CASE WHEN e.station_cell = 6 and bscd.device_id is null THEN 1 ELSE 0 END), |
| | | 2) as twoUncompletedQuantity, |
| | | round(sum(CASE |
| | | WHEN e.station_cell = 6 and bscd.device_id is null THEN gi.width * gi.height / 1000000 |
| | | ELSE 0 END), |
| | | 2) as twoUncompletedArea |
| | | round(sum(CASE WHEN e.station_cell = 5 THEN bscd.width * bscd.height / 1000000 ELSE 0 END), |
| | | 2) as oneCompletedArea, |
| | | round(sum(CASE WHEN e.station_cell = 6 THEN 1 ELSE 0 END), 2) as twoCompletedQuantity, |
| | | round(sum(CASE WHEN e.station_cell = 6 THEN bscd.width * bscd.height / 1000000 ELSE 0 END), |
| | | 2) as twoCompletedArea, |
| | | round(sum(CASE WHEN e.station_cell = 5 and bscd.device_id is null THEN 1 ELSE 0 END), |
| | | 2) as oneUncompletedQuantity, |
| | | round(sum(CASE |
| | | WHEN e.station_cell = 5 and bscd.device_id is null THEN gi.width * gi.height / 1000000 |
| | | ELSE 0 END), |
| | | 2) as oneUncompletedArea, |
| | | round(sum(CASE WHEN e.station_cell = 6 and bscd.device_id is null THEN 1 ELSE 0 END), |
| | | 2) as twoUncompletedQuantity, |
| | | round(sum(CASE |
| | | WHEN e.station_cell = 6 and bscd.device_id is null THEN gi.width * gi.height / 1000000 |
| | | ELSE 0 END), |
| | | 2) as twoUncompletedArea |
| | | FROM glass_info gi |
| | | left join big_storage_cage_details bscd ON gi.glass_id = bscd.glass_id |
| | | left join engineering e on gi.engineer_id = e.engineer_id |
| | | left join big_storage_cage_details bscd ON gi.glass_id = bscd.glass_id |
| | | left join engineering e on gi.engineer_id = e.engineer_id |
| | | WHERE date(e.create_time) = date(now()) |
| | | </select> |
| | | |
| | |
| | | import com.mes.hollow.entity.HollowBigStorageCageDetails; |
| | | import com.mes.hollow.entity.HollowFormulaDetails; |
| | | import com.mes.hollow.entity.HollowGlassOutRelationInfo; |
| | | import com.mes.hollow.entity.dto.*; |
| | | import com.mes.hollow.entity.dto.LisecHollowDetails; |
| | | import com.mes.hollow.entity.dto.LisecHollowFrameDetails; |
| | | import com.mes.hollow.entity.dto.LisecHollowGlassAndFrameDetails; |
| | | import com.mes.hollow.entity.dto.LisecHollowGlassDetails; |
| | | import com.mes.hollow.entity.request.HollowHistoryTaskRequest; |
| | | import com.mes.hollow.entity.request.HollowTaskRequest; |
| | | import com.mes.hollow.mapper.HollowGlassOutRelationInfoMapper; |
| | |
| | | private static final int ID_RATIO = 10; |
| | | |
| | | @Override |
| | | @Transactional |
| | | // @Transactional |
| | | public HollowGlassOutRelationInfo receiveTask(HollowTaskRequest request) { |
| | | return childrenTask(request, 0); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | // @Transactional |
| | | public HollowGlassOutRelationInfo forceOutGlass(HollowTaskRequest request) { |
| | | return childrenTask(request, 1); |
| | | } |
| | |
| | | if (CollectionUtil.isEmpty(outRelationList) || outRelationList.size() != 1) { |
| | | return "本条线不存在该流程任务或者同流程卡任务数大于1"; |
| | | } |
| | | log.info("李赛克流程卡:{}", flowCardId); |
| | | HollowGlassOutRelationInfo relationInfo = outRelationList.get(0); |
| | | if (relationInfo.getTotalLayer() < 2) { |
| | | return "任务总层数小于2,不生成李赛克文件"; |
| | |
| | | if (null == order) { |
| | | return "生成失败,相关订单信息不存在"; |
| | | } |
| | | log.info("李赛克相关订单信息{}", order); |
| | | //获取配方相关信息 |
| | | HollowFormulaDetails formulaDetails = hollowFormulaDetailsService.getById(relationInfo.getFormulaId()); |
| | | if (null == formulaDetails) { |
| | |
| | | if (layerCount != relationInfo.getTotalLayer() && isForce == 0) { |
| | | return "生成失败,该流程卡内层数与进笼关系表内层数数量不相同"; |
| | | } |
| | | |
| | | log.info("李赛克总层数{}", layerCount); |
| | | //设置文件的主体内容 |
| | | LisecHollowDetails details = new LisecHollowDetails(); |
| | | String randomNumber = "" + (int) (Math.random() * 100000 + 100000); |
| | |
| | | // 创建Calculator实例 |
| | | Blank blank = new Blank(); |
| | | |
| | | log.info("李赛克基础数据已生成:{}", details); |
| | | // 创建数据模型 |
| | | Map<String, Object> root = new HashMap<>(); |
| | | root.put("blank", blank); |
| | |
| | | writer.write(out.toString()); |
| | | } catch (TemplateException | IOException e) { |
| | | e.printStackTrace(); |
| | | |
| | | log.info("李赛克生成异常:{}", e.getMessage()); |
| | | } |
| | | return "success"; |
| | | } |
| | |
| | | } |
| | | |
| | | private HollowGlassOutRelationInfo childrenTask(HollowTaskRequest request, int isForce) { |
| | | GlassInfo glassInfo = glassInfoService.getOne(new LambdaQueryWrapper<GlassInfo>().eq(GlassInfo::getFlowCardId, request.getFlowCardId()).last("limit 1")); |
| | | HollowGlassOutRelationInfo info = new HollowGlassOutRelationInfo(); |
| | | if (null == glassInfo) { |
| | | log.info("该流程卡信息系统未找到"); |
| | | return info; |
| | | } |
| | | List<HollowGlassOutRelationInfo> outRelationInfos = this.list(new LambdaQueryWrapper<HollowGlassOutRelationInfo>() |
| | | .eq(HollowGlassOutRelationInfo::getFlowCardId, request.getFlowCardId()) |
| | | .in(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_NEW, Const.HOLLOW_FLOW_CARD_START, Const.HOLLOW_FLOW_CARD_PAUSE)); |
| | | if (CollectionUtil.isNotEmpty(outRelationInfos)) { |
| | | log.info("当前流程卡有未完成的任务"); |
| | | return null; |
| | | } |
| | | //保存任务关系主表 |
| | | info.setFlowCardId(request.getFlowCardId()); |
| | | info.setCell(request.getCell()); |
| | | info.setIsForce(isForce); |
| | | info.setTotalLayer(glassInfo.getTotalLayer()); |
| | | info.setState(Const.HOLLOW_FLOW_CARD_NEW); |
| | | info.setTotalPairQuantity(request.getTotalPairQuantity()); |
| | | info.setFormulaId(request.getFormulaId()); |
| | | this.save(info); |
| | | // 查询出需要出玻璃的队列 |
| | | List<HollowBigStorageCageDetails> hollowBigStorageCageDetailsList = hollowBigStorageCageDetailsService |
| | | .queryOutGlassList(request.getFlowCardId(), request.getCell()); |
| | | int isPairCount = glassInfo.getTotalLayer() * request.getTotalPairQuantity(); |
| | | List<HollowGlassQueueInfo> hollowQueues = new ArrayList<>(); |
| | | Integer carWidth = sysConfigService.queryConfigValue(ConstSysConfig.HOLLOW_CAR_WIDTH); |
| | | // Integer glassGap = sysConfigService.queryConfigValue(ConstSysConfig.HOLLOW_GLASS_GAP); |
| | | Integer glassGap = hollowGlassRelationInfoService.getGlassGapByThickness(hollowBigStorageCageDetailsList.get(0).getThickness()); |
| | | if (930 == request.getCell()) { |
| | | Map<Integer, List<HollowBigStorageCageDetails>> listMap = hollowBigStorageCageDetailsList.stream() |
| | | .collect(Collectors.groupingBy(HollowBigStorageCageDetails::getHollowSequence)); |
| | | Map<Integer, List<HollowBigStorageCageDetails>> sortListMap = new TreeMap<>(); |
| | | sortListMap.putAll(listMap); |
| | | for (Map.Entry<Integer, List<HollowBigStorageCageDetails>> entry : sortListMap.entrySet()) { |
| | | //创建队列接收不满足成对情况下:一对玻璃分几次上车的次序问题 |
| | | List<HollowGlassQueueInfo> tempList = new ArrayList<>(); |
| | | //先将玻璃按照正常顺序排列,计算一车最多放几块,算好块数之后将一车的玻璃按照倒序存储 |
| | | List<HollowBigStorageCageDetails> reverse = CollectionUtil.reverse(entry.getValue()); |
| | | int remainWidth = carWidth; |
| | | for (HollowBigStorageCageDetails item : reverse) { |
| | | remainWidth = remainWidth - (int) Math.max(item.getWidth(), item.getHeight()); |
| | | if (remainWidth < 0) { |
| | | hollowQueues.addAll(CollectionUtil.reverse(tempList)); |
| | | tempList = new ArrayList<>(); |
| | | remainWidth = carWidth - (int) Math.max(item.getWidth(), item.getHeight()); |
| | | } |
| | | HollowGlassQueueInfo queueInfo = HollowBDetailToQueue(item, info.getId(), request.getCell()); |
| | | tempList.add(queueInfo); |
| | | remainWidth = remainWidth - glassGap; |
| | | } |
| | | hollowQueues.addAll(CollectionUtil.reverse(tempList)); |
| | | HollowBigStorageCageDetails cageDetails = entry.getValue().get(0); |
| | | if (cageDetails.getIsPair() == 1) { |
| | | isPairCount = isPairCount - cageDetails.getTotalLayer(); |
| | | if (isPairCount == 0) { |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | } else { |
| | | loop: |
| | | for (HollowBigStorageCageDetails item : hollowBigStorageCageDetailsList) { |
| | | HollowGlassQueueInfo queueInfo = HollowBDetailToQueue(item, info.getId(), request.getCell()); |
| | | hollowQueues.add(queueInfo); |
| | | if (item.getIsPair() == 1) { |
| | | isPairCount = isPairCount - 1; |
| | | if (isPairCount == 0) { |
| | | break loop; |
| | | try { |
| | | |
| | | GlassInfo glassInfo = glassInfoService.getOne(new LambdaQueryWrapper<GlassInfo>().eq(GlassInfo::getFlowCardId, request.getFlowCardId()).last("limit 1")); |
| | | HollowGlassOutRelationInfo info = new HollowGlassOutRelationInfo(); |
| | | if (null == glassInfo) { |
| | | log.info("该流程卡信息系统未找到"); |
| | | return info; |
| | | } |
| | | log.error("创建任务时获取玻璃信息:{}", info); |
| | | List<HollowGlassOutRelationInfo> outRelationInfos = this.list(new LambdaQueryWrapper<HollowGlassOutRelationInfo>() |
| | | .eq(HollowGlassOutRelationInfo::getFlowCardId, request.getFlowCardId()) |
| | | .in(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_NEW, Const.HOLLOW_FLOW_CARD_START, Const.HOLLOW_FLOW_CARD_PAUSE)); |
| | | if (CollectionUtil.isNotEmpty(outRelationInfos)) { |
| | | log.info("当前流程卡有未完成的任务"); |
| | | return null; |
| | | } |
| | | //保存任务关系主表 |
| | | info.setFlowCardId(request.getFlowCardId()); |
| | | info.setCell(request.getCell()); |
| | | info.setIsForce(isForce); |
| | | info.setTotalLayer(glassInfo.getTotalLayer()); |
| | | info.setState(Const.HOLLOW_FLOW_CARD_NEW); |
| | | info.setTotalPairQuantity(request.getTotalPairQuantity()); |
| | | info.setFormulaId(request.getFormulaId()); |
| | | this.save(info); |
| | | // 查询出需要出玻璃的队列 |
| | | List<HollowBigStorageCageDetails> hollowBigStorageCageDetailsList = hollowBigStorageCageDetailsService |
| | | .queryOutGlassList(request.getFlowCardId(), request.getCell()); |
| | | int isPairCount = glassInfo.getTotalLayer() * request.getTotalPairQuantity(); |
| | | List<HollowGlassQueueInfo> hollowQueues = new ArrayList<>(); |
| | | Integer carWidth = sysConfigService.queryConfigValue(ConstSysConfig.HOLLOW_CAR_WIDTH); |
| | | Integer glassGap = hollowGlassRelationInfoService.getGlassGapByThickness(hollowBigStorageCageDetailsList.get(0).getThickness()); |
| | | if (930 == request.getCell()) { |
| | | Map<Integer, List<HollowBigStorageCageDetails>> listMap = hollowBigStorageCageDetailsList.stream() |
| | | .collect(Collectors.groupingBy(HollowBigStorageCageDetails::getHollowSequence)); |
| | | Map<Integer, List<HollowBigStorageCageDetails>> sortListMap = new TreeMap<>(); |
| | | sortListMap.putAll(listMap); |
| | | for (Map.Entry<Integer, List<HollowBigStorageCageDetails>> entry : sortListMap.entrySet()) { |
| | | //创建队列接收不满足成对情况下:一对玻璃分几次上车的次序问题 |
| | | List<HollowGlassQueueInfo> tempList = new ArrayList<>(); |
| | | //先将玻璃按照正常顺序排列,计算一车最多放几块,算好块数之后将一车的玻璃按照倒序存储 |
| | | List<HollowBigStorageCageDetails> reverse = CollectionUtil.reverse(entry.getValue()); |
| | | int remainWidth = carWidth; |
| | | for (HollowBigStorageCageDetails item : reverse) { |
| | | remainWidth = remainWidth - (int) Math.max(item.getWidth(), item.getHeight()); |
| | | if (remainWidth < 0) { |
| | | hollowQueues.addAll(CollectionUtil.reverse(tempList)); |
| | | tempList = new ArrayList<>(); |
| | | remainWidth = carWidth - (int) Math.max(item.getWidth(), item.getHeight()); |
| | | } |
| | | HollowGlassQueueInfo queueInfo = HollowBDetailToQueue(item, info.getId(), request.getCell()); |
| | | tempList.add(queueInfo); |
| | | remainWidth = remainWidth - glassGap; |
| | | } |
| | | hollowQueues.addAll(CollectionUtil.reverse(tempList)); |
| | | HollowBigStorageCageDetails cageDetails = entry.getValue().get(0); |
| | | if (cageDetails.getIsPair() == 1) { |
| | | isPairCount = isPairCount - cageDetails.getTotalLayer(); |
| | | if (isPairCount == 0) { |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | } else { |
| | | loop: |
| | | for (HollowBigStorageCageDetails item : hollowBigStorageCageDetailsList) { |
| | | HollowGlassQueueInfo queueInfo = HollowBDetailToQueue(item, info.getId(), request.getCell()); |
| | | hollowQueues.add(queueInfo); |
| | | if (item.getIsPair() == 1) { |
| | | isPairCount = isPairCount - 1; |
| | | if (isPairCount == 0) { |
| | | break loop; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | hollowGlassQueueInfoService.saveBatch(hollowQueues); |
| | | try { |
| | | if (request.getCell() == 930) { |
| | | generateHollowLisecFile(request.getFlowCardId(), 930, isForce, 0); |
| | | hollowGlassQueueInfoService.saveBatch(hollowQueues); |
| | | try { |
| | | log.info("李赛克生成文件:{}", request); |
| | | if (request.getCell() == 930) { |
| | | generateHollowLisecFile(request.getFlowCardId(), 930, isForce, 0); |
| | | } |
| | | } catch (Exception e) { |
| | | log.info("生成李赛克文件时发生异常,流程卡号为{}", request.getFlowCardId()); |
| | | } |
| | | return info; |
| | | |
| | | } catch (Exception e) { |
| | | log.info("生成李赛克文件时发生异常,流程卡号为{}", request.getFlowCardId()); |
| | | log.error("创建任务时发生异常:{}", e.getMessage()); |
| | | throw new RuntimeException(e); |
| | | } |
| | | return info; |
| | | } |
| | | |
| | | private HollowGlassQueueInfo HollowBDetailToQueue(HollowBigStorageCageDetails details, Long taskId, int targetCell) { |
| | |
| | | .eq(HollowBigStorageCageDetails::getSlot, THROUGH_SLOT) |
| | | .in(HollowBigStorageCageDetails::getState, Const.GLASS_STATE_IN_ALL).last("limit 1")); |
| | | log.info("中空大理片直通台玻璃信息{}", details); |
| | | if (details != null && details.getGlassId().equals(unFinishHollowQueueList.get(0).getGlassId())) { |
| | | unFinishHollowQueueList.get(0).setSlot(THROUGH_SLOT); |
| | | log.info("将中空队列中的格子号替换为直通台{}", unFinishHollowQueueList); |
| | | if (details != null) { |
| | | unFinishHollowQueueList.stream().forEach(e -> { |
| | | if (e.getGlassId().equals(details.getGlassId())) { |
| | | e.setSlot(THROUGH_SLOT); |
| | | e.setDeviceId(0); |
| | | log.info("将中空队列中的格子号替换为直通台{}", e); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | List<HollowGlassQueueInfo> infoList = unFinishHollowQueueList.stream().filter(e -> !(e.getSlot() > 500 && e.getSlot() < 900 && e.getIsPair() != 1)).collect(Collectors.toList()); |
| | | log.info("有正在出片的中空任务"); |
| | | Integer isPair = unFinishHollowQueueList.get(0).getIsPair(); |
| | | hollowOutGlassByIsPair(unFinishHollowQueueList, hollowGlassOutRelationInfo.getCell(), isPair, hollowGlassOutRelationInfo.getTotalLayer(), hollowGlassOutRelationInfo.getIsForce()); |
| | | Integer isPair = infoList.get(0).getIsPair(); |
| | | hollowOutGlassByIsPair(infoList, hollowGlassOutRelationInfo.getCell(), isPair, hollowGlassOutRelationInfo.getTotalLayer(), hollowGlassOutRelationInfo.getIsForce()); |
| | | Date endDate = new Date(); |
| | | log.info("大理片笼出片任务结束时间:{},共耗时:{}ms,结束扫码任务", endDate, endDate.getTime() - startDate.getTime()); |
| | | return; |
| | |
| | | int count = hollowBigStorageCageDetailsService.count(new LambdaQueryWrapper<HollowBigStorageCageDetails>() |
| | | .eq(HollowBigStorageCageDetails::getState, Const.GLASS_STATE_IN) |
| | | .eq(HollowBigStorageCageDetails::getSlot, THROUGH_SLOT)); |
| | | log.info("直通片台的任务数量为:{}", count); |
| | | if (count > 0) { |
| | | return; |
| | | } |
| | | List<HollowBigStorageCageDetails> list = hollowBigStorageCageDetailsService.list(new LambdaQueryWrapper<HollowBigStorageCageDetails>() |
| | | .eq(HollowBigStorageCageDetails::getState, Const.GLASS_STATE_IN) |
| | | .in(HollowBigStorageCageDetails::getDeviceId, 6) |
| | | // .in(HollowBigStorageCageDetails::getDeviceId, 6) |
| | | .in(HollowBigStorageCageDetails::getGlassId, glassIdList)); |
| | | log.info("获取调度任务列表:{}", list); |
| | | if (CollectionUtil.isEmpty(list)) { |
| | | return; |
| | | } |
| | | HollowBigStorageCageDetails details = list.get(0); |
| | | //todo:生成进进片大车任务 |
| | | log.info("获取需要调度的单条任务:{}", details); |
| | | //生成进进片大车任务 |
| | | hollowBigStorageCageDetailsService.update(new LambdaUpdateWrapper<HollowBigStorageCageDetails>() |
| | | .set(HollowBigStorageCageDetails::getState, Const.RAW_GLASS_STATE_OUT) |
| | | .eq(HollowBigStorageCageDetails::getGlassId, details.getGlassId())); |
| | |
| | | Integer glassGap = hollowGlassRelationInfoService.getGlassGapByThickness(list.get(0).getThickness()); |
| | | log.info("中空生成一车任务:{}", list); |
| | | for (T e : list) { |
| | | //格子为第五个笼子时不添加出片任务 |
| | | HollowBigStorageCage hollowBigStorageCage = hollowBigStorageCageService.getOne( |
| | | new LambdaQueryWrapper<HollowBigStorageCage>() |
| | | .eq(HollowBigStorageCage::getSlot, e.getSlot()) |
| | | ); |
| | | |
| | | if (hollowBigStorageCage != null && hollowBigStorageCage.getDeviceId() == 6) { |
| | | break; |
| | | } |
| | | if (templist.size() >= outCarMaxSize || Math.max((int) e.getWidth(), (int) e.getHeight()) > remainWidth) { |
| | | break; |
| | | } |
| | |
| | | for (T t : baseInfoList) { |
| | | bigStorageCageTaskList.add(new BigStorageCageTask(t.getGlassId(), t.getSlot(), targetSlot, 0)); |
| | | } |
| | | |
| | | List<BigStorageCageTask> tasks = bigStorageCageTaskList.stream().filter(e -> e.getStartSlot() >= 500 && e.getStartSlot() < 900).collect(Collectors.toList()); |
| | | if (CollectionUtil.isNotEmpty(tasks)) { |
| | | log.info("当前出片队列存在新笼子的玻璃小片,结束本次任务:{}", tasks); |
| | | return false; |
| | | } |
| | | //清空任务表数据 |
| | | resetOutTask(); |
| | | log.info("生成出片任务数据{}", bigStorageCageTaskList); |
| | |
| | | |
| | | <select id="queryNeedInCarGlass" resultType="java.lang.String"> |
| | | WITH queue_temp AS ( |
| | | SELECT slot, |
| | | glass_id, |
| | | LEAST(width, height) AS height, |
| | | relation_id, |
| | | ROW_NUMBER() OVER ( PARTITION BY cell ORDER BY hollow_sequence ) AS rn |
| | | FROM hollow_glass_queue_info |
| | | WHERE state = - 1 |
| | | SELECT |
| | | slot, |
| | | glass_id, |
| | | LEAST( width, height ) AS height, |
| | | relation_id, |
| | | is_pair, |
| | | ROW_NUMBER() OVER ( PARTITION BY cell ORDER BY hollow_sequence ) AS rn |
| | | FROM |
| | | hollow_glass_queue_info |
| | | WHERE |
| | | state = - 1 |
| | | ), |
| | | glass_id_temp AS (SELECT * FROM queue_temp WHERE rn = 1), |
| | | task_temp AS (SELECT * |
| | | FROM glass_id_temp t |
| | | INNER JOIN hollow_glass_out_relation_info t1 ON t.relation_id = t1.id |
| | | WHERE t1.state = 1) |
| | | SELECT glass_id |
| | | FROM task_temp |
| | | task_temp AS ( |
| | | SELECT |
| | | t.* |
| | | FROM |
| | | queue_temp t |
| | | INNER JOIN hollow_glass_out_relation_info t1 ON t.relation_id = t1.id |
| | | WHERE |
| | | t1.state = 1 |
| | | and t.slot BETWEEN 500 and 900 |
| | | AND ( |
| | | t.is_pair = 1 |
| | | OR ( t.is_pair = 0 AND t1.is_force = 1 )) )SELECT |
| | | glass_id |
| | | FROM |
| | | task_temp |
| | | ORDER BY |
| | | rn |
| | | </select> |
| | | </mapper> |