计划-设备路线选择更改;报工定时任务;

highway
zhaoxiaolin 1 year ago
parent c1885b1805
commit 5a60b22157

@ -32,4 +32,7 @@ public interface RemoteMesService {
/**获取领料单**/
@PostMapping("/prepare/getMesPrepare")
public R getMesPrepare();
@PostMapping("/prepare/reportWorkTask")
public R reportWorkTask();
}

@ -31,4 +31,5 @@ public interface RemotePlanService {
@PostMapping("/order/syncSAPOrders")
public R syncSAPOrders();
}

@ -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;
}

@ -40,6 +40,11 @@ public class RemoteMesFallbackFactory implements FallbackFactory<RemoteMesServic
public R getMesPrepare() {
return R.fail("领料单获取失败:" + throwable.getMessage());
}
@Override
public R reportWorkTask() {
return R.fail("报工失败:" + throwable.getMessage());
}
};
}
}

@ -7,6 +7,8 @@ import com.op.system.api.RemoteMesService;
import com.op.system.api.RemotePlanService;
import com.op.system.api.RemoteSapService;
import com.op.system.api.model.SapProOrder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.op.common.core.utils.StringUtils;
@ -18,7 +20,7 @@ import com.op.common.core.utils.StringUtils;
*/
@Component("ryTask")
public class RyTask {
protected Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private RemoteMesService remoteMesService;
@ -51,14 +53,14 @@ public class RyTask {
* 0 00 22 * * ?
*/
public void getMesPrepareTask(){
System.out.println("++同步领料单+开始++getMesPrepareTask+++++");
logger.info("++同步领料单+开始++getMesPrepareTask+++++");
remoteMesService.getMesPrepare();
}
/**1
* 0 0 1 * * ?
*/
public void getRouteTask(){
System.out.println("++同步工艺+开始++getRouteTask+++++");
logger.info("++同步工艺+开始++getRouteTask+++++");
remoteSapService.sapRouterSync();
}
@ -66,7 +68,13 @@ public class RyTask {
* 0 00 21 * * ?
*/
public void getTOrderTask(){
System.out.println("++同步今日订单+开始++getTOrderTask+++++");
logger.info("++同步今日订单+开始++getTOrderTask+++++");
remotePlanService.syncSAPOrders();
}
/**每5分钟报工一次**/
public void reportWorkTask(){
logger.info("++报工接口+开始++reportWorkTask+++++");
remoteMesService.reportWorkTask();
}
}

@ -106,4 +106,10 @@ public class MesPrepareController extends BaseController {
return mesPrepareService.getMesPrepare();
}
@Log(title = "报工", businessType = BusinessType.SAP)
@PostMapping("/reportWorkTask")
public R reportWorkTask() {
return mesPrepareService.reportWorkTask();
}
}

@ -140,6 +140,105 @@ public class MesReportWork extends BaseEntity {
private String factoryName;
private String carCode;
private String carName;
private Date uploadTime;
private String uploadStatus;
private String uploadMsg;
private String workorderCodeSap;
private String routeCode;
private String sac1;
private String sac2;
private String sac3;
private String sac4;
private String sac5;
private String sac6;
public String getWorkorderCodeSap() {
return workorderCodeSap;
}
public void setWorkorderCodeSap(String workorderCodeSap) {
this.workorderCodeSap = workorderCodeSap;
}
public String getRouteCode() {
return routeCode;
}
public void setRouteCode(String routeCode) {
this.routeCode = routeCode;
}
public String getSac1() {
return sac1;
}
public void setSac1(String sac1) {
this.sac1 = sac1;
}
public String getSac2() {
return sac2;
}
public void setSac2(String sac2) {
this.sac2 = sac2;
}
public String getSac3() {
return sac3;
}
public void setSac3(String sac3) {
this.sac3 = sac3;
}
public String getSac4() {
return sac4;
}
public void setSac4(String sac4) {
this.sac4 = sac4;
}
public String getSac5() {
return sac5;
}
public void setSac5(String sac5) {
this.sac5 = sac5;
}
public String getSac6() {
return sac6;
}
public void setSac6(String sac6) {
this.sac6 = sac6;
}
public Date getUploadTime() {
return uploadTime;
}
public void setUploadTime(Date uploadTime) {
this.uploadTime = uploadTime;
}
public String getUploadStatus() {
return uploadStatus;
}
public void setUploadStatus(String uploadStatus) {
this.uploadStatus = uploadStatus;
}
public String getUploadMsg() {
return uploadMsg;
}
public void setUploadMsg(String uploadMsg) {
this.uploadMsg = uploadMsg;
}
public String getFactoryCode() {
return factoryCode;

@ -64,4 +64,8 @@ public interface MesReportWorkMapper {
public List<MesProcessReport> getProcessFinishList(MesProcessReport mesReportWork);
public List<MesReportProduction> getProductionList(MesReportProduction mesReportProduction);
public List<MesReportWork> getReportWorkList(MesReportWork mesReportWork);
void updateSyncSapStatus(MesReportWork work);
}

@ -64,4 +64,6 @@ public interface ProRfidProcessDetailMapper {
public ProRfidProcessDetail getRfidInfo(String rfidNo);
public String getStationType(String equipmentCode);
String getActuaEquips(ProRfidProcessDetail rfidInfo);
}

@ -61,4 +61,6 @@ public interface IMesPrepareService {
public int deleteMesPrepareByPrepareId(String prepareId);
public R getMesPrepare();
public R reportWorkTask();
}

@ -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<String> list2 = new ArrayList<>();
for(int c1=0;c1<codeArray.size();c1++){
String equipCode0 = codeArray.getJSONArray(c1).getString(1);
list2.add(equipCode0);
}
//取交集
List<String> list1 = Arrays.asList(machineCodes0);
List<String> machineArray = list1.stream()
.filter(u1-> list2.contains(u1))
.collect(Collectors.toList());
dto.setSku(rfidInfo.getProductCode());
dto.setSpec(rfidInfo.getProductModel());
dto.setProductionState(rfidInfo.getNowProcessId());
List<WCSDataDTO> 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<codeArray1.size();c1++){
machineCodes1[c1] = codeArray1.getJSONArray(c1).getString(1);
}
String[] machinecode0 = "LG1,LG2,LG3".split(",");
List<String> list1 = Arrays.asList(machinecode0);
List<String> list2 = Arrays.asList(machineCodes1);
List<String> machineArray = list2.stream()
.filter(u1-> list1.contains(u1))
.collect(Collectors.toList());
System.out.println(machineArray.toString());
}
}

@ -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<List<Map<String, String>>> dateSources0 = remoteUserService.getPoolNameList(sysUser);
List<Map<String, String>> dateSources = dateSources0.getData();
ExecutorService executorService = new ThreadPoolExecutor(
dateSources.size(),
dateSources.size(),
0L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<Runnable>());
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<MesReportWork> 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<SapMaterialPreparation> list = new ArrayList<>();
SapMaterialPreparation p1 = new SapMaterialPreparation();

@ -156,8 +156,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="productDateStart != null "> and CONVERT(varchar(10),mrw.feedback_time, 120) >= #{productDateStart}</if>
<if test="productDateEnd != null "> and #{productDateEnd} >= CONVERT(varchar(10),mrw.feedback_time, 120)</if>
</select>
<select id="getReportWorkList" resultType="com.op.mes.domain.MesReportWork">
select ow.workorder_code_sap workorderCodeSap,
ow.route_code routeCode,
rte.tec_machine sac1,
rte.tec_man sac2,
rte.tec_depreciation sac3,
rte.tec_other sac4,
rte.tec_conf_acivity5 sac5,
rte.tec_conf_acivity6 sac6,
mrw.id,
mrw.quantity_feedback quantityFeedback,
mrw.product_code productCode,
mrw.product_name productName
from mes_report_work mrw
left join pro_order_workorder ow on mrw.workorder_code = ow.workorder_code
left join pro_route rte on rte.route_code = ow.route_code
where mrw.upload_status != #{uploadStatus}
order by mrw.create_time
</select>
<insert id="insertMesReportWork" parameterType="MesReportWork">
<insert id="insertMesReportWork" parameterType="MesReportWork">
insert into mes_report_work
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
@ -263,6 +282,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
</trim>
where id = #{id}
</update>
<update id="updateSyncSapStatus">
update mes_report_work
<trim prefix="SET" suffixOverrides=",">
<if test="uploadTime != null and uploadTime != ''">upload_time = #{uploadTime},</if>
<if test="uploadStatus != null">upload_status = #{uploadStatus},</if>
<if test="uploadMsg != null">upload_msg = #{uploadMsg},</if>
</trim>
where id = #{id}
</update>

@ -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}
</select>
<select id="getActuaEquips" resultType="java.lang.String">
select prod_line_code
from pro_order_workorder
where workorder_code = #{workorderCode}
</select>
<insert id="insertProRfidProcessDetail" parameterType="ProRfidProcessDetail">
insert into pro_rfid_process_detail

@ -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));
}

@ -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<BaseFile> 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<BaseFileData> baseFiles);
List<BaseFile> getBaseFileBatch(String processId);
void deleteBaseFileBySourceId(String processId);
}

@ -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<QcProCheck> selectQcProCheckList(QcProCheck qcProCheck);
QcProCheck getInfoByRfid(QcProCheck qcProCheck);
void insertBaseFileBatch(@Param("baseFiles") List<BaseFileData> baseFiles);
}

@ -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<Boolean> 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);

@ -123,7 +123,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="fileId != null">#{fileId},</if>
</trim>
</insert>
<insert id="insertBaseFileBatch">
INSERT INTO base_file(file_id, file_name, file_address, source_id, remark, create_by, create_time)
VALUES
<foreach collection="baseFiles" index="" item="baseFile" separator=",">
(
#{baseFile.fileId},
#{baseFile.fileName},
#{baseFile.fileAddress},
#{baseFile.sourceId},
#{baseFile.remark},
#{baseFile.createBy},
#{baseFile.createTime}
)
</foreach>
</insert>
<update id="updateQcProCheckById" parameterType="QcProCheck">
@ -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

@ -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<String> roles = permissionService.getRolePermission(user);
// 权限集合

Loading…
Cancel
Save