新增接口服务,去掉scada服务

highway
zhaoxiaolin 1 year ago
parent 2aa1ad4f2e
commit 15581ac8a3

@ -0,0 +1,609 @@
package com.op.system.api.domain.mes;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.op.common.core.annotation.Excel;
import com.op.common.core.web.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.math.BigDecimal;
import java.util.Date;
/**
* mes_report_work
*
* @author Open Platform
* @date 2023-08-24
*/
public class MesReportWorkDTO extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 记录id */
private String id;
/** 报工单编号 */
@Excel(name = "报工单编号")
private String reportCode;
/** 报工类型报工类型SELF自行报工、UNI统一报工 */
@Excel(name = "报工类型报工类型SELF上位机报工、UNI系统报工")
private String reportType;
/** 生产工单编码 */
@Excel(name = "生产工单编码")
private String workorderCode;
/** 产品编码 */
@Excel(name = "产品编码")
private String productCode;
/** 产品名称 */
@Excel(name = "产品名称")
private String productName;
/** 规格型号 */
@Excel(name = "规格型号")
private String spec;
/** 单位 */
@Excel(name = "单位")
private String unit;
/** 排产数量 */
@Excel(name = "排产数量")
private BigDecimal quantity;
/** 本次报工数量 */
@Excel(name = "本次报工数量")
private BigDecimal quantityFeedback;
/** 合格数量 */
//@Excel(name = "合格数量")
private BigDecimal quantityQualified;
/** 不合格数量 */
//@Excel(name = "不合格数量")
private BigDecimal quantityUnqualified;
/** 报工人员 */
@Excel(name = "报工人员")
private String userName;
/** 人员名称 */
@Excel(name = "人员名称")
private String nickName;
/** 报工途径PAD、MOBILE、PC */
//@Excel(name = "报工途径PAD、MOBILE、PC")
private String feedbackChannel;
/** 报工时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "报工时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date feedbackTime;
/** 录入人员 */
@Excel(name = "录入人员")
private String recordUser;
/** 状态 */
@Excel(name = "状态")
private String status;
/** 工时 */
@Excel(name = "工时")
private Long workTime;
/** 线体编码 */
@Excel(name = "线体编码")
private String machineCode;
/** 线体名称 */
@Excel(name = "线体名称")
private String machineName;
/** 班组编码 */
@Excel(name = "班组编码")
private String teamCode;
/** 班次编码 */
@Excel(name = "班次编码")
private String shiftCode;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "SAP报工时间")
private Date uploadTime;
@Excel(name = "SAP报工状态0待报工1成功2失败")
private String uploadStatus;
@Excel(name = "SAP报工信息")
private String uploadMsg;
/** 预留字段1 */
//@Excel(name = "预留字段1")
private String attr1;
/** 预留字段2 */
//@Excel(name = "预留字段2")
private String attr2;
/** 预留字段3 */
//@Excel(name = "预留字段3")
private String attr3;
/** 预留字段4 */
//@Excel(name = "预留字段4")
private String attr4;
@Excel(name = "计划生产日期")
private String productDate;
private String productDateStart;
private String productDateEnd;
@Excel(name = "订单编号")
private String orderCode;
@Excel(name = "规格型号")
private String productSpc;
@Excel(name = "工序名称")
private String processName;
@Excel(name = "工序编码")
private String processCode;
private String factoryCode;
private String factoryName;
private String carCode;
private String carName;
private String workorderCodeSap;
private String routeCode;
private String sac1;
private String sac2;
private String sac3;
private String sac4;
private String sac5;
private String sac6;
private String prodType;
private String createTimeStart;
private String createTimeEnd;
private String feedbackTimeStart;
private String feedbackTimeEnd;
public String getFeedbackTimeStart() {
return feedbackTimeStart;
}
public void setFeedbackTimeStart(String feedbackTimeStart) {
this.feedbackTimeStart = feedbackTimeStart;
}
public String getFeedbackTimeEnd() {
return feedbackTimeEnd;
}
public void setFeedbackTimeEnd(String feedbackTimeEnd) {
this.feedbackTimeEnd = feedbackTimeEnd;
}
public String getCreateTimeStart() {
return createTimeStart;
}
public void setCreateTimeStart(String createTimeStart) {
this.createTimeStart = createTimeStart;
}
public String getCreateTimeEnd() {
return createTimeEnd;
}
public void setCreateTimeEnd(String createTimeEnd) {
this.createTimeEnd = createTimeEnd;
}
public String getProdType() {
return prodType;
}
public void setProdType(String prodType) {
this.prodType = prodType;
}
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;
}
public void setFactoryCode(String factoryCode) {
this.factoryCode = factoryCode;
}
public String getFactoryName() {
return factoryName;
}
public void setFactoryName(String factoryName) {
this.factoryName = factoryName;
}
public String getCarCode() {
return carCode;
}
public void setCarCode(String carCode) {
this.carCode = carCode;
}
public String getCarName() {
return carName;
}
public void setCarName(String carName) {
this.carName = carName;
}
public String getProcessCode() {
return processCode;
}
public void setProcessCode(String processCode) {
this.processCode = processCode;
}
public String getProductDateStart() {
return productDateStart;
}
public void setProductDateStart(String productDateStart) {
this.productDateStart = productDateStart;
}
public String getProductDateEnd() {
return productDateEnd;
}
public void setProductDateEnd(String productDateEnd) {
this.productDateEnd = productDateEnd;
}
public void setId(String id) {
this.id = id;
}
public String getId() {
return id;
}
public void setReportType(String reportType) {
this.reportType = reportType;
}
public String getReportType() {
return reportType;
}
public void setReportCode(String reportCode) {
this.reportCode = reportCode;
}
public String getReportCode() {
return reportCode;
}
public void setWorkorderCode(String workorderCode) {
this.workorderCode = workorderCode;
}
public String getWorkorderCode() {
return workorderCode;
}
public void setProductCode(String productCode) {
this.productCode = productCode;
}
public String getProductCode() {
return productCode;
}
public void setProductName(String productName) {
this.productName = productName;
}
public String getProductName() {
return productName;
}
public void setSpec(String spec) {
this.spec = spec;
}
public String getSpec() {
return spec;
}
public void setUnit(String unit) {
this.unit = unit;
}
public String getUnit() {
return unit;
}
public void setQuantity(BigDecimal quantity) {
this.quantity = quantity;
}
public BigDecimal getQuantity() {
return quantity;
}
public void setQuantityFeedback(BigDecimal quantityFeedback) {
this.quantityFeedback = quantityFeedback;
}
public BigDecimal getQuantityFeedback() {
return quantityFeedback;
}
public void setQuantityQualified(BigDecimal quantityQualified) {
this.quantityQualified = quantityQualified;
}
public BigDecimal getQuantityQualified() {
return quantityQualified;
}
public void setQuantityUnqualified(BigDecimal quantityUnqualified) {
this.quantityUnqualified = quantityUnqualified;
}
public BigDecimal getQuantityUnqualified() {
return quantityUnqualified;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getUserName() {
return userName;
}
public void setNickName(String nickName) {
this.nickName = nickName;
}
public String getNickName() {
return nickName;
}
public void setFeedbackChannel(String feedbackChannel) {
this.feedbackChannel = feedbackChannel;
}
public String getFeedbackChannel() {
return feedbackChannel;
}
public void setFeedbackTime(Date feedbackTime) {
this.feedbackTime = feedbackTime;
}
public Date getFeedbackTime() {
return feedbackTime;
}
public void setRecordUser(String recordUser) {
this.recordUser = recordUser;
}
public String getRecordUser() {
return recordUser;
}
public void setStatus(String status) {
this.status = status;
}
public String getStatus() {
return status;
}
public void setWorkTime(Long workTime) {
this.workTime = workTime;
}
public Long getWorkTime() {
return workTime;
}
public void setMachineCode(String machineCode) {
this.machineCode = machineCode;
}
public String getMachineCode() {
return machineCode;
}
public void setMachineName(String machineName) {
this.machineName = machineName;
}
public String getMachineName() {
return machineName;
}
public void setTeamCode(String teamCode) {
this.teamCode = teamCode;
}
public String getTeamCode() {
return teamCode;
}
public void setShiftCode(String shiftCode) {
this.shiftCode = shiftCode;
}
public String getShiftCode() {
return shiftCode;
}
public void setAttr1(String attr1) {
this.attr1 = attr1;
}
public String getAttr1() {
return attr1;
}
public void setAttr2(String attr2) {
this.attr2 = attr2;
}
public String getAttr2() {
return attr2;
}
public void setAttr3(String attr3) {
this.attr3 = attr3;
}
public String getAttr3() {
return attr3;
}
public void setAttr4(String attr4) {
this.attr4 = attr4;
}
public String getAttr4() {
return attr4;
}
public String getProductDate() {
return productDate;
}
public void setProductDate(String productDate) {
this.productDate = productDate;
}
public String getOrderCode() {
return orderCode;
}
public void setOrderCode(String orderCode) {
this.orderCode = orderCode;
}
public String getProductSpc() {
return productSpc;
}
public void setProductSpc(String productSpc) {
this.productSpc = productSpc;
}
public String getProcessName() {
return processName;
}
public void setProcessName(String processName) {
this.processName = processName;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("reportType", getReportType())
.append("reportCode", getReportCode())
.append("workorderCode", getWorkorderCode())
.append("productCode", getProductCode())
.append("productName", getProductName())
.append("spec", getSpec())
.append("unit", getUnit())
.append("quantity", getQuantity())
.append("quantityFeedback", getQuantityFeedback())
.append("quantityQualified", getQuantityQualified())
.append("quantityUnqualified", getQuantityUnqualified())
.append("userName", getUserName())
.append("nickName", getNickName())
.append("feedbackChannel", getFeedbackChannel())
.append("feedbackTime", getFeedbackTime())
.append("recordUser", getRecordUser())
.append("status", getStatus())
.append("remark", getRemark())
.append("workTime", getWorkTime())
.append("machineCode", getMachineCode())
.append("machineName", getMachineName())
.append("teamCode", getTeamCode())
.append("shiftCode", getShiftCode())
.append("attr1", getAttr1())
.append("attr2", getAttr2())
.append("attr3", getAttr3())
.append("attr4", getAttr4())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateTime", getUpdateTime())
.append("updateBy", getUpdateBy())
.toString();
}
}

@ -114,6 +114,11 @@ public class WCSInterfaceController extends BaseController {
if(StringUtils.isBlank(mesReportWork.getReportCode())){
return error("[reportCode] is null");
}
if(mesReportWork.getFactoryCode().indexOf("ds")<0){
mesReportWork.setFactoryCode("ds_"+mesReportWork.getFactoryCode());
}
return success(wCInterfaceService.reportWork(mesReportWork));
}

@ -412,7 +412,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
s.Shift_Desc shiftName
from pro_order_workorder pow
left join base_shifts_t s on pow.shift_id = s.Shift_Id
where pow.del_flag = '0' and pow.status != 'w3' and pow.end_flag ='1'
where pow.del_flag = '0' and pow.status = 'w2' and pow.end_flag ='1'
order by pow.product_date desc
<if test="workorderCode != null and workorderCode != ''">
and pow.workorder_code like concat('%', #{workorderCode}, '%')

@ -9,10 +9,10 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>op-modules-scada</artifactId>
<artifactId>op-modules-open</artifactId>
<description>
op-modules-scada系统模块
op-modules-open接口模块
</description>
<dependencies>

@ -1,8 +1,8 @@
@echo off
echo --------------------------------自定义参数,启动前先修改--------------------------------------
set jarName=op-modules-scada.jar
set jarName=op-modules-open.jar
set profile=dev
set imageURI=192.168.202.36:30002/op-lanju/op-scada
set imageURI=192.168.202.36:30002/op-lanju/op-open
rem echo 获取当前日期字符串
for /f "tokens=1,2,3 delims=/- " %%a in ("%date%") do @set D=%%a%%b%%c
rem echo 获取当前时间字符串
@ -28,7 +28,6 @@ if exist %df% (
echo --------------------------------创建Dockerfile--------------------------------
::echo FROM 192.168.202.36:30002/library/openjdk:8u131-jdk-alpine >> Dockerfile
echo FROM 192.168.202.36:30002/library/openjdk:8-sw66>> Dockerfile
echo RUN apk add --update font-adobe-100dpi ttf-dejavu fontconfig
echo COPY %jarName% /application.jar >> Dockerfile
echo RUN echo "Asia/Shanghai" ^> /etc/timezone >> Dockerfile
echo CMD ["java", "-jar", "-Dspring.profiles.active=%profile%", "application.jar"] >> Dockerfile

@ -1,4 +1,4 @@
package com.op.wms;
package com.op.open;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@ -7,7 +7,7 @@ import com.op.common.security.annotation.EnableRyFeignClients;
import com.op.common.swagger.annotation.EnableCustomSwagger2;
/**
*
*
*
* @author OP
*/
@ -15,10 +15,10 @@ import com.op.common.swagger.annotation.EnableCustomSwagger2;
@EnableCustomSwagger2
@EnableRyFeignClients
@SpringBootApplication
public class ScadaApplication {
public class OpenApplication {
public static void main(String[] args) {
SpringApplication.run(ScadaApplication.class, args);
System.err.println("Scada服务启动成功\n"
SpringApplication.run(OpenApplication.class, args);
System.err.println("OPEN接口服务启动成功\n"
+ " | | \r\n"
+ " ___ _ __ ______ ___ _ _ ___| |_ ___ _ __ ___ \r\n"
+ " / _ \\| '_ \\______/ __| | | / __| __/ _ \\ '_ ` _ \\ \r\n"

@ -1,4 +1,4 @@
package com.op.scada.config;
package com.op.open.config;
import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DataSourceProperty;
import com.op.common.core.domain.R;

@ -0,0 +1,63 @@
package com.op.open.controller;
import com.op.common.core.utils.DateUtils;
import com.op.common.core.utils.StringUtils;
import com.op.common.core.web.controller.BaseController;
import com.op.common.core.web.domain.AjaxResult;
import com.op.open.service.OpenService;
import com.op.system.api.domain.dto.WCSDTO;
import com.op.system.api.domain.mes.MesReportWorkDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* mes
*
* @author sf
* @date 2023-05-18
*/
@RestController
@RequestMapping("/openInterface")
public class OpenController extends BaseController {
@Autowired
private OpenService openService;
/**
*
* WCS MES
* AGV
* @param
* @return
*/
//"下一工序机台集合获取"
@PostMapping("/requestDestinationStations")
public WCSDTO requestDestinationStations(@RequestBody WCSDTO wcsdto) {
if(StringUtils.isBlank(wcsdto.getFactory())){
wcsdto.setCode("1");
wcsdto.setMessage("factory is not null");
return wcsdto;
}
return openService.requestDestinationStations(wcsdto);
}
/**上位机报工**/
@PostMapping("/reportWork")
public AjaxResult reportWork(@RequestBody MesReportWorkDTO mesReportWork) {
if(StringUtils.isBlank(mesReportWork.getFactoryCode())){
return error("[factoryCode] is null");
}
if(StringUtils.isBlank(mesReportWork.getReportCode())){
return error("[reportCode] is null");
}
return success(openService.reportWork(mesReportWork));
}
public static void main(String args[]){
System.out.println(DateUtils.getDate());
}
}

@ -0,0 +1,42 @@
package com.op.open.mapper;
import com.op.system.api.domain.SysSapLog;
import com.op.system.api.domain.mes.MesReportWorkDTO;
import com.op.system.api.domain.mes.ProOrderWorkorderDTO;
import com.op.system.api.domain.mes.ProRfidProcessDetail;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* rfidMapper
*
* @author Open Platform
* @date 2023-08-18
*/
@Mapper
public interface OpenMapper {
public ProRfidProcessDetail getRfidInfo(String rfidNo);
public String getStationType(String equipmentCode);
Integer getEquipNum(String machineCode);
String getEquipStatus(String machineCode);
String getEquipMode(String machineCode);
List<MesReportWorkDTO> getReportWorkList(MesReportWorkDTO mesReportWork);
void addSapLog(SysSapLog sysSapLog);
void updateSyncSapStatus(MesReportWorkDTO work);
MesReportWorkDTO getProdResult(MesReportWorkDTO work);
void updateWorkOrderStatus(MesReportWorkDTO work);
ProOrderWorkorderDTO getOrderByCode(String workorderCode);
}

@ -0,0 +1,18 @@
package com.op.open.service;
import com.op.common.core.domain.R;
import com.op.system.api.domain.dto.WCSDTO;
import com.op.system.api.domain.mes.MesReportWorkDTO;
/**
* Service
*
* @author Open Platform
* @date 2023-07-13
*/
public interface OpenService {
WCSDTO requestDestinationStations(WCSDTO wcsdto);
R reportWork(MesReportWorkDTO mesReportWork);
}

@ -1,23 +1,35 @@
package com.op.scada.service.impl;
package com.op.open.service.impl;
import com.alibaba.fastjson2.JSONArray;
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
import com.op.common.core.domain.R;
import com.op.common.core.utils.DateUtils;
import com.op.common.core.utils.bean.BeanUtils;
import com.op.scada.mapper.ScadaMapper;
import com.op.scada.service.ScadaService;
import com.op.common.core.utils.uuid.IdUtils;
import com.op.open.mapper.OpenMapper;
import com.op.open.service.OpenService;
import com.op.system.api.RemoteSapService;
import com.op.system.api.domain.SysSapLog;
import com.op.system.api.domain.dto.WCSDTO;
import com.op.system.api.domain.dto.WCSDataDTO;
import com.op.system.api.domain.mes.MesReportWorkDTO;
import com.op.system.api.domain.mes.ProOrderWorkorderDTO;
import com.op.system.api.domain.mes.ProRfidProcessDetail;
import com.op.system.api.domain.sap.SapRFW;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
/**
@ -27,12 +39,13 @@ import java.util.stream.Collectors;
* @date 2023-07-13
*/
@Service
public class ScadaServiceImpl implements ScadaService {
public class OpenServiceImpl implements OpenService {
protected Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private ScadaMapper scadaMapper;
private OpenMapper openMapper;
@Autowired
private RemoteSapService remoteSapService;
/**
* JSON
@ -78,17 +91,17 @@ public class ScadaServiceImpl implements ScadaService {
try {
BeanUtils.copyBeanProp(dto, wcsdto);
//根据rfid跟工单绑定成型机跟工单绑定获取对应工艺。
ProRfidProcessDetail rfidInfo = scadaMapper.getRfidInfo(wcsdto.getRfidNo());
ProRfidProcessDetail rfidInfo = openMapper.getRfidInfo(wcsdto.getRfidNo());
//获取设备类型
if (rfidInfo != null && StringUtils.isNotBlank(rfidInfo.getMachineCode())) {
//设备-工艺路线的设备大范围
String[] machineCodes0 = rfidInfo.getMachineCode().split(",");
String stationType = scadaMapper.getStationType(machineCodes0[0]);
String stationType = openMapper.getStationType(machineCodes0[0]);
if (StringUtils.isNotBlank(stationType)) {
dto.setStationType(stationType);
}
//设备-根据工单获取实际规划设备路线
String machinecode = rfidInfo.getProdLineCode();//scadaMapper.getActuaEquips(rfidInfo);
String machinecode = rfidInfo.getProdLineCode();//openMapper.getActuaEquips(rfidInfo);
JSONArray codeArray = JSONArray.parseArray(machinecode);
List<String> list2 = new ArrayList<>();
for (int c1 = 0; c1 < codeArray.size(); c1++) {
@ -111,13 +124,13 @@ public class ScadaServiceImpl implements ScadaService {
wCSDataDTO = new WCSDataDTO();
if (StringUtils.isNotBlank(machineCode)) {
//设备是否正常
String status = scadaMapper.getEquipStatus(machineCode);
String status = openMapper.getEquipStatus(machineCode);
if(StringUtils.isNotBlank(status) && "1".equals(status)){//正常设备且没被删除
wCSDataDTO.setStationNo(machineCode);
if ("2".equals(stationType)) {
Integer qty = scadaMapper.getEquipNum(machineCode);
Integer qty = openMapper.getEquipNum(machineCode);
wCSDataDTO.setQty(qty == null ? 0 : qty);
String mode = scadaMapper.getEquipMode(machineCode);
String mode = openMapper.getEquipMode(machineCode);
wCSDataDTO.setFlag(mode);
}
stationNos.add(wCSDataDTO);
@ -137,6 +150,78 @@ public class ScadaServiceImpl implements ScadaService {
return dto;
}
@Override
public R reportWork(MesReportWorkDTO mesReportWork) {
DynamicDataSourceContextHolder.push("ds_"+mesReportWork.getFactoryCode());// 这是数据源的key
mesReportWork.setUploadStatus("1");//除了1报工成功的都需要报工
mesReportWork.setProdType("prod");
List<MesReportWorkDTO> reportWorks = openMapper.getReportWorkList(mesReportWork);
if(CollectionUtils.isEmpty(reportWorks)){
return R.fail("未查询到报工单");
}
MesReportWorkDTO work = reportWorks.get(0);
SapRFW sapRFW = new SapRFW();
sapRFW.setAufnr(work.getWorkorderCodeSap());//虚拟工单号
sapRFW.setGamng(work.getQuantityFeedback().toString());//报工数量
SapRFW.lt_gs ltgs = sapRFW.new lt_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.setLt_gs(ltgs);
SapRFW.lt_hw lthw = sapRFW.new lt_hw();//MES生产订单报工货物移动修改
lthw.setEntry_qnt(work.getQuantityFeedback().toString());//TODO;
lthw.setMaterial(work.getProcessCode());
sapRFW.setLt_hw(lthw);
//添加调用sap日志
SysSapLog sysSapLog = new SysSapLog();
sysSapLog.setId(IdUtils.fastSimpleUUID());
sysSapLog.setMesssge(sapRFW.toString());
sysSapLog.setMethod("reportWork");
sysSapLog.setReqcode("请求");
sysSapLog.setCreateTime(DateUtils.getNowDate());
openMapper.addSapLog(sysSapLog);
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());
openMapper.updateSyncSapStatus(work);
//工单完成数量>工单数量:关闭订单
MesReportWorkDTO proResult = openMapper.getProdResult(work);
ProOrderWorkorderDTO topOrder = this.getTopOrder(work.getWorkorderCode());
if(proResult.getQuantityFeedback().compareTo(new BigDecimal(topOrder.getQuantitySplit()))>=0){
//工单完成,关闭工单
remoteSapService.sapCloseOrder(work.getWorkorderCodeSap());
work.setStatus("w3");
work.setUpdateTime(DateUtils.getNowDate());
//pro_work_order status->w4报工
openMapper.updateWorkOrderStatus(work);
}
return R.ok();
}
//根据工单子单编码获取最顶级订单的母单
private ProOrderWorkorderDTO getTopOrder(String workorderCode) {
//pro_order_workorder
ProOrderWorkorderDTO topOrder = openMapper.getOrderByCode(workorderCode);
while (!"0".equals(topOrder.getParentOrder()) && StringUtils.isNotEmpty(topOrder.getParentOrder())) {
//pro_order_workorder
topOrder = openMapper.getOrderByCode(topOrder.getParentOrder());
}
return topOrder;
}
public static void main(String args[]){
DateTimeFormatter ymdhms = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDate today = LocalDate.now();

@ -1,12 +1,12 @@
# Tomcat
server:
port: 9211
port: 9214
# Spring
spring:
application:
# 应用名称
name: op-scada
name: op-open
profiles:
# 环境配置
active: dev

@ -0,0 +1,112 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.op.open.mapper.OpenMapper">
<insert id="addSapLog">
insert into sys_sap_log
(id,messsge,create_time,reqcode,method,remark,status)
values(
#{id},#{messsge}, #{createTime}, #{reqcode},#{method},#{remark},#{status})
</insert>
<update id="updateSyncSapStatus">
update mes_report_work
<trim prefix="SET" suffixOverrides=",">
<if test="uploadTime != null">upload_time = #{uploadTime},</if>
<if test="uploadStatus != null">upload_status = #{uploadStatus},</if>
<if test="uploadMsg != null">upload_msg = #{uploadMsg},</if>
</trim>
where 1=1
<if test="id != null">
and id = #{id}
</if>
<if test="reportCode != null">
and report_code = #{reportCode}
</if>
</update>
<update id="updateWorkOrderStatus">
update pro_order_workorder set status = #{status} where workorder_code = #{workorderCode}
</update>
<!--获取在邦rfid 工单的信息-->
<select id="getRfidInfo" resultType="com.op.system.api.domain.mes.ProRfidProcessDetail">
select
top 1
rfid.workorder_code workorderCode,
rfid.now_process_id nowProcessId,
rfid.next_process_id nextProcessId,
p.equipment machineCode,
bp.product_code productCode,
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
left join base_product bp on bp.product_code = w.product_code
where rfid.bind_status = '1'
and rfid.rfid = #{rfidNo}
order by rfid.create_time desc
</select>
<select id="getStationType" resultType="java.lang.String">
select
case when equipment_type_code ='equ_type_spj' then '3'
when equipment_type_code ='equ_type_hf' then '2'
else '' end
from base_equipment
where equipment_code = #{equipmentCode}
</select>
<select id="getEquipNum" resultType="java.lang.Integer">
select isvalue from base_equipment_attached
where property = 'dollyNumber'
and device_code = #{machineCode}
</select>
<select id="getEquipStatus" resultType="java.lang.String">
select status from base_equipment where equipment_code = #{machineCode} and del_flag = '0'
</select>
<select id="getEquipMode" resultType="java.lang.String">
select isvalue from base_equipment_attached
where property = 'Mode'
and device_code = #{machineCode}
</select>
<select id="getReportWorkList" resultType="com.op.system.api.domain.mes.MesReportWorkDTO">
select ow.order_code orderCode,
ow.workorder_code workorderCode,
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} and mrw.prod_type = #{prodType}
<if test="reportCode != null ">
and mrw.report_code = #{reportCode}
</if>
order by mrw.create_time
</select>
<select id="getProdResult" resultType="com.op.system.api.domain.mes.MesReportWorkDTO">
select
mrw.workorder_code workorderCode,
sum(mrw.quantity_feedback) quantityFeedback
from mes_report_work mrw
where mrw.del_flag = '0' and mrw.workorder_code = #{workorderCode}
group by mrw.workorder_code
</select>
<select id="getOrderByCode" resultType="com.op.system.api.domain.mes.ProOrderWorkorderDTO">
select workorder_code workorderCode,
parent_order parentOrder,
quantity_split quantitySplit,
unit
from pro_order_workorder where workorder_code = #{workorderCode}
</select>
</mapper>

@ -1,27 +0,0 @@
package com.op.scada.mapper;
import com.op.system.api.domain.mes.ProRfidProcessDetail;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* rfidMapper
*
* @author Open Platform
* @date 2023-08-18
*/
@Mapper
public interface ScadaMapper {
public ProRfidProcessDetail getRfidInfo(String rfidNo);
public String getStationType(String equipmentCode);
Integer getEquipNum(String machineCode);
String getEquipStatus(String machineCode);
String getEquipMode(String machineCode);
}

@ -1,18 +0,0 @@
package com.op.scada.service;
import com.op.system.api.domain.dto.WCSDTO;
import java.util.List;
import java.util.Map;
/**
* Service
*
* @author Open Platform
* @date 2023-07-13
*/
public interface ScadaService {
WCSDTO requestDestinationStations(WCSDTO wcsdto);
}

@ -1,49 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.op.scada.mapper.ScadaMapper">
<!--获取在邦rfid 工单的信息-->
<select id="getRfidInfo" resultType="com.op.system.api.domain.mes.ProRfidProcessDetail">
select
top 1
rfid.workorder_code workorderCode,
rfid.now_process_id nowProcessId,
rfid.next_process_id nextProcessId,
p.equipment machineCode,
bp.product_code productCode,
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
left join base_product bp on bp.product_code = w.product_code
where rfid.bind_status = '1'
and rfid.rfid = #{rfidNo}
order by rfid.create_time desc
</select>
<select id="getStationType" resultType="java.lang.String">
select
case when equipment_type_code ='equ_type_spj' then '3'
when equipment_type_code ='equ_type_hf' then '2'
else '' end
from base_equipment
where equipment_code = #{equipmentCode}
</select>
<select id="getEquipNum" resultType="java.lang.Integer">
select isvalue from base_equipment_attached
where property = 'dollyNumber'
and device_code = #{machineCode}
</select>
<select id="getEquipStatus" resultType="java.lang.String">
select status from base_equipment where equipment_code = #{machineCode} and del_flag = '0'
</select>
<select id="getEquipMode" resultType="java.lang.String">
select isvalue from base_equipment_attached
where property = 'Mode'
and device_code = #{machineCode}
</select>
</mapper>

@ -1,9 +1,8 @@
package com.op.scada.controller;
package com.op.security.controller;
import com.op.common.core.utils.DateUtils;
import com.op.common.core.utils.StringUtils;
import com.op.common.core.web.controller.BaseController;
import com.op.scada.service.ScadaService;
import com.op.system.api.domain.dto.WCSDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
@ -21,9 +20,6 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping("/scadaInterface")
public class ScadaController extends BaseController {
@Autowired
private ScadaService scadaService;
/**
*
@ -40,7 +36,7 @@ public class ScadaController extends BaseController {
wcsdto.setMessage("factory is not null");
return wcsdto;
}
return scadaService.requestDestinationStations(wcsdto);
return null;
}

@ -21,8 +21,8 @@
<module>op-device</module>
<module>op-energy</module>
<module>op-quality</module>
<module>op-scada</module>
<module>op-security</module>
<module>op-open</module>
</modules>
<artifactId>op-modules</artifactId>

Loading…
Cancel
Save