diff --git a/op-api/op-api-system/src/main/java/com/op/system/api/RemoteMesService.java b/op-api/op-api-system/src/main/java/com/op/system/api/RemoteMesService.java index 9ba5c354..135fda3b 100644 --- a/op-api/op-api-system/src/main/java/com/op/system/api/RemoteMesService.java +++ b/op-api/op-api-system/src/main/java/com/op/system/api/RemoteMesService.java @@ -32,4 +32,7 @@ public interface RemoteMesService { /**获取领料单**/ @PostMapping("/prepare/getMesPrepare") public R getMesPrepare(); + + @PostMapping("/prepare/reportWorkTask") + public R reportWorkTask(); } diff --git a/op-api/op-api-system/src/main/java/com/op/system/api/RemotePlanService.java b/op-api/op-api-system/src/main/java/com/op/system/api/RemotePlanService.java index b5814d40..92e89e1d 100644 --- a/op-api/op-api-system/src/main/java/com/op/system/api/RemotePlanService.java +++ b/op-api/op-api-system/src/main/java/com/op/system/api/RemotePlanService.java @@ -31,4 +31,5 @@ public interface RemotePlanService { @PostMapping("/order/syncSAPOrders") public R syncSAPOrders(); + } diff --git a/op-api/op-api-system/src/main/java/com/op/system/api/domain/mes/ProRfidProcessDetail.java b/op-api/op-api-system/src/main/java/com/op/system/api/domain/mes/ProRfidProcessDetail.java index 0fbb60c0..65a44a10 100644 --- a/op-api/op-api-system/src/main/java/com/op/system/api/domain/mes/ProRfidProcessDetail.java +++ b/op-api/op-api-system/src/main/java/com/op/system/api/domain/mes/ProRfidProcessDetail.java @@ -34,7 +34,7 @@ public class ProRfidProcessDetail extends BaseEntity { /** 机台编码 */ @Excel(name = "机台编码") private String machineCode; - + private String prodLineCode; /** 当前步 */ @Excel(name = "当前步") private String nowProcessId; @@ -87,6 +87,14 @@ public class ProRfidProcessDetail extends BaseEntity { private String productCode; private String productModel; + public String getProdLineCode() { + return prodLineCode; + } + + public void setProdLineCode(String prodLineCode) { + this.prodLineCode = prodLineCode; + } + public String getProductCode() { return productCode; } diff --git a/op-api/op-api-system/src/main/java/com/op/system/api/factory/RemoteMesFallbackFactory.java b/op-api/op-api-system/src/main/java/com/op/system/api/factory/RemoteMesFallbackFactory.java index b6c0c40c..0bd451f3 100644 --- a/op-api/op-api-system/src/main/java/com/op/system/api/factory/RemoteMesFallbackFactory.java +++ b/op-api/op-api-system/src/main/java/com/op/system/api/factory/RemoteMesFallbackFactory.java @@ -40,6 +40,11 @@ public class RemoteMesFallbackFactory implements FallbackFactory getProcessFinishList(MesProcessReport mesReportWork); public List getProductionList(MesReportProduction mesReportProduction); + + public List getReportWorkList(MesReportWork mesReportWork); + + void updateSyncSapStatus(MesReportWork work); } diff --git a/op-modules/op-mes/src/main/java/com/op/mes/mapper/ProRfidProcessDetailMapper.java b/op-modules/op-mes/src/main/java/com/op/mes/mapper/ProRfidProcessDetailMapper.java index 10af1522..22ca741c 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/mapper/ProRfidProcessDetailMapper.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/mapper/ProRfidProcessDetailMapper.java @@ -64,4 +64,6 @@ public interface ProRfidProcessDetailMapper { public ProRfidProcessDetail getRfidInfo(String rfidNo); public String getStationType(String equipmentCode); + + String getActuaEquips(ProRfidProcessDetail rfidInfo); } diff --git a/op-modules/op-mes/src/main/java/com/op/mes/service/IMesPrepareService.java b/op-modules/op-mes/src/main/java/com/op/mes/service/IMesPrepareService.java index 69228280..334c839c 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/service/IMesPrepareService.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/service/IMesPrepareService.java @@ -61,4 +61,6 @@ public interface IMesPrepareService { public int deleteMesPrepareByPrepareId(String prepareId); public R getMesPrepare(); + + public R reportWorkTask(); } diff --git a/op-modules/op-mes/src/main/java/com/op/mes/service/impl/IWCInterfaceServiceImpl.java b/op-modules/op-mes/src/main/java/com/op/mes/service/impl/IWCInterfaceServiceImpl.java index c5fe1461..a455733d 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/service/impl/IWCInterfaceServiceImpl.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/service/impl/IWCInterfaceServiceImpl.java @@ -1,5 +1,6 @@ package com.op.mes.service.impl; +import com.alibaba.fastjson2.JSONArray; import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder; import com.op.common.core.utils.DateUtils; import com.op.common.core.utils.bean.BeanUtils; @@ -20,7 +21,9 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; +import java.util.stream.Collectors; /** * wcs接口业务层处理 @@ -83,17 +86,33 @@ public class IWCInterfaceServiceImpl implements IWCSInterfaceService { ProRfidProcessDetail rfidInfo = proRfidProcessDetailMapper.getRfidInfo(wcsdto.getRfidNo()); //获取设备类型 if(rfidInfo!=null && StringUtils.isNotBlank(rfidInfo.getMachineCode())){ - String[] machineCodes = rfidInfo.getMachineCode().split(","); - String stationType = proRfidProcessDetailMapper.getStationType(machineCodes[0]); + //设备-工艺路线的设备大范围 + String[] machineCodes0 = rfidInfo.getMachineCode().split(","); + String stationType = proRfidProcessDetailMapper.getStationType(machineCodes0[0]); if(StringUtils.isNotBlank(stationType)){ dto.setStationType(stationType); } + //设备-根据工单获取实际规划设备路线 + String machinecode = rfidInfo.getProdLineCode();//proRfidProcessDetailMapper.getActuaEquips(rfidInfo); + JSONArray codeArray = JSONArray.parseArray(machinecode); + List list2 = new ArrayList<>(); + for(int c1=0;c1 list1 = Arrays.asList(machineCodes0); + List machineArray = list1.stream() + .filter(u1-> list2.contains(u1)) + .collect(Collectors.toList()); + dto.setSku(rfidInfo.getProductCode()); dto.setSpec(rfidInfo.getProductModel()); dto.setProductionState(rfidInfo.getNowProcessId()); List stationNos = new ArrayList<>(); WCSDataDTO wCSDataDTO = null; - for(String machineCode:machineCodes){ + for(String machineCode:machineArray){ wCSDataDTO = new WCSDataDTO(); if(StringUtils.isNotBlank(machineCode)){ wCSDataDTO.setStationNo(machineCode); @@ -104,5 +123,19 @@ public class IWCInterfaceServiceImpl implements IWCSInterfaceService { return dto; } - + public static void main(String args[]){ + String machinecode1 = "[[\"GX01\",\"LG2\"],[\"GX01\",\"LG3\"],[\"GX02\",\"S1\"],[\"GX02\",\"S2\"],[\"GX03\",\"HF01\"],[\"GX04\",\"SPJ01\"]]"; + JSONArray codeArray1 = JSONArray.parseArray(machinecode1); + String[] machineCodes1 = new String[codeArray1.size()]; + for(int c1=0;c1 list1 = Arrays.asList(machinecode0); + List list2 = Arrays.asList(machineCodes1); + List machineArray = list2.stream() + .filter(u1-> list1.contains(u1)) + .collect(Collectors.toList()); + System.out.println(machineArray.toString()); + } } diff --git a/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesPrepareServiceImpl.java b/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesPrepareServiceImpl.java index 145a36bd..0fe86094 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesPrepareServiceImpl.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesPrepareServiceImpl.java @@ -14,11 +14,14 @@ import com.op.common.core.utils.uuid.IdUtils; import com.op.common.core.web.domain.AjaxResult; import com.op.common.security.utils.SecurityUtils; import com.op.mes.domain.MesPrepareDetail; +import com.op.mes.domain.MesReportWork; import com.op.mes.mapper.MesPrepareDetailMapper; +import com.op.mes.mapper.MesReportWorkMapper; import com.op.system.api.RemoteSapService; import com.op.system.api.RemoteUserService; import com.op.system.api.domain.SysUser; import com.op.system.api.domain.sap.SapMaterialPreparation; +import com.op.system.api.domain.sap.SapRFW; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -46,6 +49,8 @@ public class MesPrepareServiceImpl implements IMesPrepareService { private RemoteUserService remoteUserService; @Autowired private MesPrepareDetailMapper mesPrepareDetailMapper; + @Autowired + private MesReportWorkMapper mesReportWorkMapper; /** * 查询备料单 @@ -216,6 +221,64 @@ public class MesPrepareServiceImpl implements IMesPrepareService { } + @Override + public R reportWorkTask() { + // 加载sf-cloud库的sys_datasource + SysUser sysUser = new SysUser(); + sysUser.setUserId(1L); + R>> dateSources0 = remoteUserService.getPoolNameList(sysUser); + List> dateSources = dateSources0.getData(); + ExecutorService executorService = new ThreadPoolExecutor( + dateSources.size(), + dateSources.size(), + 0L, TimeUnit.MILLISECONDS, + new LinkedBlockingQueue()); + try { + dateSources.forEach(dateSource -> { + logger.info("++++++++++++" + dateSource.get("poolName") + "++++报工开始++++++++++"); + Runnable run = () -> reportWorkByFactory(dateSource.get("poolName")); + executorService.execute(run); + }); + } catch (Exception e) { + logger.error("service == deviceOfflineTimingTask == exception", e); + return R.fail("service == deviceOfflineTimingTask == exception"); + } finally { + executorService.shutdown(); + } + return R.ok(true); + } + //报工 + public void reportWorkByFactory(String poolName) { + DynamicDataSourceContextHolder.push(poolName);// 这是数据源的key + MesReportWork mesReportWork = new MesReportWork(); + mesReportWork.setUploadStatus("1");//除了1报工成功的,都需要报工 + List reportWorks = mesReportWorkMapper.getReportWorkList(mesReportWork); + for(MesReportWork work:reportWorks){ + SapRFW sapRFW = new SapRFW(); + sapRFW.setAufnr(work.getWorkorderCodeSap());//虚拟工单号 + sapRFW.setGamng(work.getQuantityFeedback().toString());//报工数量 + SapRFW.lt_gs ltgs = sapRFW.getLt_gs();//生产订单报工工时修改 + ltgs.setConf_activity1(work.getSac1()); + ltgs.setConf_activity2(work.getSac2()); + ltgs.setConf_activity3(work.getSac3()); + ltgs.setConf_activity4(work.getSac4()); + ltgs.setConf_activity5(work.getSac5()); + ltgs.setConf_activity6(work.getSac6()); + SapRFW.lt_hw lthw = sapRFW.getLt_hw();//MES生产订单报工货物移动修改 + lthw.setEntry_qnt(work.getQuantityFeedback().toString()); + lthw.setMaterial(work.getProcessCode()); + R r = remoteSapService.sapRFWOrder(sapRFW); + //上传成功,更改mes_report_work状态 + if(r.getCode() == 200){ + work.setUploadStatus("1"); + }else{ + work.setUploadStatus("2"); + work.setUploadMsg(r.getMsg()); + } + work.setUploadTime(DateUtils.getNowDate()); + mesReportWorkMapper.updateSyncSapStatus(work); + } + } public static void main(String args[]) { List list = new ArrayList<>(); SapMaterialPreparation p1 = new SapMaterialPreparation(); diff --git a/op-modules/op-mes/src/main/resources/mapper/mes/MesReportWorkMapper.xml b/op-modules/op-mes/src/main/resources/mapper/mes/MesReportWorkMapper.xml index 595812c5..e52bed5f 100644 --- a/op-modules/op-mes/src/main/resources/mapper/mes/MesReportWorkMapper.xml +++ b/op-modules/op-mes/src/main/resources/mapper/mes/MesReportWorkMapper.xml @@ -156,8 +156,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and CONVERT(varchar(10),mrw.feedback_time, 120) >= #{productDateStart} and #{productDateEnd} >= CONVERT(varchar(10),mrw.feedback_time, 120) + - + insert into mes_report_work id, @@ -263,6 +282,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" create_time = #{createTime}, update_time = #{updateTime}, update_by = #{updateBy}, + create_time = #{createTime}, + update_time = #{updateTime}, + update_by = #{updateBy}, + + where id = #{id} + + + update mes_report_work + + upload_time = #{uploadTime}, + upload_status = #{uploadStatus}, + upload_msg = #{uploadMsg}, where id = #{id} diff --git a/op-modules/op-mes/src/main/resources/mapper/mes/ProRfidProcessDetailMapper.xml b/op-modules/op-mes/src/main/resources/mapper/mes/ProRfidProcessDetailMapper.xml index 136ef686..cc41b14d 100644 --- a/op-modules/op-mes/src/main/resources/mapper/mes/ProRfidProcessDetailMapper.xml +++ b/op-modules/op-mes/src/main/resources/mapper/mes/ProRfidProcessDetailMapper.xml @@ -70,7 +70,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" rfid.next_process_id nextProcessId, p.equipment machineCode, bp.product_code productCode, - bp.product_model productModel + bp.product_model productModel, + w.prod_line_code prodLineCode from pro_rfid_process_detail rfid left join pro_process p on p.process_id = rfid.next_process_id left join pro_order_workorder w on w.workorder_code = rfid.workorder_code @@ -85,6 +86,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" from base_equipment where equipment_code = #{equipmentCode} + insert into pro_rfid_process_detail diff --git a/op-modules/op-quality/src/main/java/com/op/quality/controller/QuaController.java b/op-modules/op-quality/src/main/java/com/op/quality/controller/QuaController.java index 71546200..56880bda 100644 --- a/op-modules/op-quality/src/main/java/com/op/quality/controller/QuaController.java +++ b/op-modules/op-quality/src/main/java/com/op/quality/controller/QuaController.java @@ -56,7 +56,7 @@ public class QuaController extends BaseController { * 获取【请填写功能名称】详细信息 */ - @GetMapping(value = "getInfoByRfid/{rfid}") + @GetMapping(value = "getInfoByRfid") public AjaxResult getInfo(QcProCheck qcProCheck) { return success(qcProCheckService.getInfoByRfid(qcProCheck)); } diff --git a/op-modules/op-quality/src/main/java/com/op/quality/mapper/BaseFileMapper.java b/op-modules/op-quality/src/main/java/com/op/quality/mapper/BaseFileMapper.java deleted file mode 100644 index 4ea57c8d..00000000 --- a/op-modules/op-quality/src/main/java/com/op/quality/mapper/BaseFileMapper.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.op.quality.mapper; - -import com.op.common.core.domain.BaseFileData; - -import com.op.quality.domain.BaseFile; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.util.List; - -/** - * 附件Mapper接口 - * - * @author Open Platform - * @date 2023-07-10 - */ -@Mapper -public interface BaseFileMapper { - /** - * 查询附件 - * - * @param fileId 附件主键 - * @return 附件 - */ - public BaseFile selectBaseFileByFileId(String fileId); - - /** - * 查询附件列表 - * - * @param baseFile 附件 - * @return 附件集合 - */ - public List selectBaseFileList(BaseFile baseFile); - - /** - * 新增附件 - * - * @param baseFile 附件 - * @return 结果 - */ - public int insertBaseFile(BaseFile baseFile); - - /** - * 修改附件 - * - * @param baseFile 附件 - * @return 结果 - */ - public int updateBaseFile(BaseFile baseFile); - - /** - * 删除附件 - * - * @param fileId 附件主键 - * @return 结果 - */ - public int deleteBaseFileByFileId(String fileId); - - /** - * 批量删除附件 - * - * @param fileIds 需要删除的数据主键集合 - * @return 结果 - */ - public int deleteBaseFileByFileIds(String[] fileIds); - - Boolean insertBaseFileBatch(@Param("baseFiles") List baseFiles); - - List getBaseFileBatch(String processId); - - void deleteBaseFileBySourceId(String processId); -} diff --git a/op-modules/op-quality/src/main/java/com/op/quality/mapper/QcProCheckMapper.java b/op-modules/op-quality/src/main/java/com/op/quality/mapper/QcProCheckMapper.java index a422aace..36961fd0 100644 --- a/op-modules/op-quality/src/main/java/com/op/quality/mapper/QcProCheckMapper.java +++ b/op-modules/op-quality/src/main/java/com/op/quality/mapper/QcProCheckMapper.java @@ -1,8 +1,10 @@ package com.op.quality.mapper; +import com.op.common.core.domain.BaseFileData; import com.op.common.core.domain.R; import com.op.quality.domain.QcProCheck; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; import java.util.List; @@ -26,4 +28,6 @@ public interface QcProCheckMapper { List selectQcProCheckList(QcProCheck qcProCheck); QcProCheck getInfoByRfid(QcProCheck qcProCheck); + + void insertBaseFileBatch(@Param("baseFiles") List baseFiles); } diff --git a/op-modules/op-quality/src/main/java/com/op/quality/service/serviceImpl/QcProCheckServiceImpl.java b/op-modules/op-quality/src/main/java/com/op/quality/service/serviceImpl/QcProCheckServiceImpl.java index 76ab2667..4e00df54 100644 --- a/op-modules/op-quality/src/main/java/com/op/quality/service/serviceImpl/QcProCheckServiceImpl.java +++ b/op-modules/op-quality/src/main/java/com/op/quality/service/serviceImpl/QcProCheckServiceImpl.java @@ -3,12 +3,10 @@ package com.op.quality.service.serviceImpl; import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder; import com.op.common.core.domain.BaseFileData; import com.op.common.core.domain.R; -//import com.op.quality.domain.BaseFile; import com.op.common.core.utils.StringUtils; import com.op.common.core.utils.uuid.IdUtils; import com.op.common.security.utils.SecurityUtils; import com.op.quality.domain.QcProCheck; -import com.op.quality.mapper.BaseFileMapper; import com.op.quality.mapper.QcProCheckMapper; import com.op.quality.service.QcProCheckService; import org.springframework.beans.factory.annotation.Autowired; @@ -29,8 +27,6 @@ import java.util.UUID; public class QcProCheckServiceImpl implements QcProCheckService { @Autowired private QcProCheckMapper qcProCheckMapper; - @Autowired - private BaseFileMapper baseFileMapper; @Override public R saveQcProCheck(QcProCheck qcProCheck) { @@ -52,7 +48,7 @@ public class QcProCheckServiceImpl implements QcProCheckService { file.setCreateTime(new Date()); files.add(file); } - baseFileMapper.insertBaseFileBatch(files); + qcProCheckMapper.insertBaseFileBatch(files); } qcProCheckMapper.insertQcProCheck(qcProCheck); diff --git a/op-modules/op-quality/src/main/resources/mapper/QcProCheckMapper.xml b/op-modules/op-quality/src/main/resources/mapper/QcProCheckMapper.xml index 3ae9dba4..c8ac56db 100644 --- a/op-modules/op-quality/src/main/resources/mapper/QcProCheckMapper.xml +++ b/op-modules/op-quality/src/main/resources/mapper/QcProCheckMapper.xml @@ -123,7 +123,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{fileId}, - + + INSERT INTO base_file(file_id, file_name, file_address, source_id, remark, create_by, create_time) + VALUES + + ( + #{baseFile.fileId}, + #{baseFile.fileName}, + #{baseFile.fileAddress}, + #{baseFile.sourceId}, + #{baseFile.remark}, + #{baseFile.createBy}, + #{baseFile.createTime} + ) + + @@ -177,7 +191,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" be.equipment_name machineName, ow.product_code productCode, ow.product_name productName, - ow.product_spc productSpc + ow.product_spc productSpc, + ow.order_code orderCode from pro_rfid_process_detail rfid left join base_equipment be on rfid.machine_code = be.equipment_code left join pro_order_workorder ow on ow.workorder_code = rfid.workorder_code diff --git a/op-modules/op-system/src/main/java/com/op/system/controller/SysUserController.java b/op-modules/op-system/src/main/java/com/op/system/controller/SysUserController.java index 790b2e0b..2fbf3307 100644 --- a/op-modules/op-system/src/main/java/com/op/system/controller/SysUserController.java +++ b/op-modules/op-system/src/main/java/com/op/system/controller/SysUserController.java @@ -180,7 +180,8 @@ public class SysUserController extends BaseController { } @PostMapping("/mobileGetInfo") - public AjaxResult mobileGetInfo(@RequestBody SysUser user) { + public AjaxResult mobileGetInfo(@RequestBody SysUser sysUser) { + SysUser user = userService.selectUserByUserName(sysUser.getUserName()); // 角色集合 Set roles = permissionService.getRolePermission(user); // 权限集合