This commit is contained in:
zj
2025-12-15 17:33:20 +08:00
parent 2bc6feb754
commit 8c6329b191
12 changed files with 135 additions and 65 deletions

View File

@@ -143,7 +143,7 @@ public class ApiServiceImpl implements IApiService {
*/
@Override
public RequestLog finishMydoJob(Map<String, Object> param) {
return requestLogService.getRequestLog(JOB_FINISH_URL, "agv任务完成", JSONUtil.toJsonStr(param));
return requestLogService.getRequestLog(JOB_FINISH_URL, "任务完成上报", JSONUtil.toJsonStr(param));
}

View File

@@ -65,7 +65,7 @@ public class RequestLogServiceImpl implements IRequestLogService
if ("1".equals(requestLog.getIsSuccessful())){
return requestLogMapper.insertRequestLog(requestLog);
}else {
//log.error("请求失败:" + requestLog.getErrorDetails());
requestLogMapper.insertRequestLog(requestLog);
return 0;
}
}
@@ -126,26 +126,30 @@ public class RequestLogServiceImpl implements IRequestLogService
requestLog.setRequestHeaders(null);
requestLog.setRequestBody(param);
requestLog.setRequestUrl(url);
Date responseTime =new Date();
try {
String resStr = HttpUtil.post(url, param);
requestLog.setResponseBody(resStr);
InterfaceReceive bean = JSONUtil.toBean(resStr, InterfaceReceive.class);
Date responseTime =new Date();
if (bean.getCode() == 200) {
requestLog.setResponseTime(DateUtil.format(responseTime, "yyyy-MM-dd HH:mm:ss"));
requestLog.setResponseStatus("1");
requestLog.setDuration(Convert.toStr(DateUtil.between(requestTime, responseTime, DateUnit.MS)));
requestLog.setIsSuccessful("1");
}else {
requestLog.setResponseTime(DateUtil.format(responseTime, "yyyy-MM-dd HH:mm:ss"));
requestLog.setResponseStatus("0");
requestLog.setErrorDetails(bean.getMsg());
requestLog.setIsSuccessful("0");
requestLog.setDuration(Convert.toStr(DateUtil.between(requestTime, responseTime, DateUnit.MS)));
}
} catch (Exception e) {
requestLog.setResponseTime(DateUtil.format(responseTime, "yyyy-MM-dd HH:mm:ss"));
requestLog.setErrorDetails(e.getMessage());
requestLog.setIsSuccessful("0");
requestLog.setResponseStatus("0");
requestLog.setDuration(Convert.toStr(DateUtil.between(requestTime, responseTime, DateUnit.MS)));
} finally {
insertRequestLog(requestLog);
}

View File

@@ -60,4 +60,6 @@ public interface JobCallBackMapper
public int deleteJobCallBackByIds(Long[] ids);
List<JobCallBack> selectJobCallBackListNoSuccess();
List<JobCallBack> getTopJobCallBack();
}

View File

@@ -103,8 +103,22 @@ public class JobCallBackServiceImpl implements IJobCallBackService
@Override
public void jobCallBack() {
List<JobCallBack> jobCallBackList = jobCallBackMapper.selectJobCallBackListNoSuccess();
for (JobCallBack jobCallBack : jobCallBackList) {
// List<JobCallBack> jobCallBackList = jobCallBackMapper.selectJobCallBackListNoSuccess();
// for (JobCallBack jobCallBack : jobCallBackList) {
// Map<String, Object> param = new HashMap<>();
// param.put("jobId", jobCallBack.getMydojobId());
// param.put("taskNo", jobCallBack.getTaskNo());
// param.put("wmsType", jobCallBack.getType());
// RequestLog requestLog = apiService.finishMydoJob(param);
// if ("1".equals(requestLog.getIsSuccessful())){
// jobCallBack.setStatus("1");
// jobCallBackMapper.updateJobCallBack(jobCallBack);
// }
// }
List<JobCallBack> list = jobCallBackMapper.getTopJobCallBack();
if(list != null && list.size() > 0){
JobCallBack jobCallBack = list.get(0);
Map<String, Object> param = new HashMap<>();
param.put("jobId", jobCallBack.getMydojobId());
param.put("taskNo", jobCallBack.getTaskNo());
@@ -113,6 +127,14 @@ public class JobCallBackServiceImpl implements IJobCallBackService
if ("1".equals(requestLog.getIsSuccessful())){
jobCallBack.setStatus("1");
jobCallBackMapper.updateJobCallBack(jobCallBack);
}else{
if(Integer.parseInt(jobCallBack.getSpare1()) < 2){
jobCallBack.setSpare1(String.valueOf(Integer.parseInt(jobCallBack.getSpare1())+1));
jobCallBackMapper.updateJobCallBack(jobCallBack);
}else{
jobCallBack.setStatus("2");
jobCallBackMapper.updateJobCallBack(jobCallBack);
}
}
}
}

View File

@@ -234,7 +234,11 @@ public class PlcSsjRead implements Runnable {
return PlcSsjRead.WriteToSSJ(address, bytes);
}
public static int writeToSsjQH(String address, int size) {
SendData sizeSendData = new SendData(Tools.INT, size);
byte[] bytes = Tools.sendData(sizeSendData);
return PlcSsjRead.WriteToSSJ(address, bytes);
}
}

View File

@@ -120,6 +120,7 @@ public class Floor1BothWayOutSsjThread implements Runnable {
jobCallBack.setStatus("0");
jobCallBack.setTaskNo(Convert.toLong(mydoJob.getTaskNo()));
jobCallBack.setCreateTime(new Date());
jobCallBack.setSpare1("0");
jobCallBackService.insertJobCallBack(jobCallBack);
log.info("完成任务 taskNo{} ", mydoJob.getTaskNo());

View File

@@ -129,6 +129,7 @@ public class Floor1SingleSsjThread implements Runnable {
jobCallBack.setStatus("0");
jobCallBack.setTaskNo(Convert.toLong(mydoJob.getTaskNo()));
jobCallBack.setCreateTime(new Date());
jobCallBack.setSpare1("0");
jobCallBackService.insertJobCallBack(jobCallBack);
log.info("完成任务 taskNo{} ", mydoJob.getTaskNo());
mydoJob.setStatus(TASK_STATUS_FINISH);

View File

@@ -14,6 +14,7 @@ import com.ruoyi.job.service.IMydoJobService;
import com.ruoyi.queue.agv.domain.AgvQueue;
import com.ruoyi.queue.agv.service.IAgvQueueService;
import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead;
import io.swagger.models.auth.In;
import lombok.extern.slf4j.Slf4j;
import java.util.ArrayList;
@@ -23,6 +24,7 @@ import java.util.List;
import static com.ruoyi.common.TaskStatusCode.*;
import static com.ruoyi.schedule.plcRead.ssj.PlcSsjRead.writeToSsj;
import static com.ruoyi.schedule.plcRead.ssj.PlcSsjRead.writeToSsjQH;
/**
* 二楼出入口输送线线程
@@ -98,6 +100,14 @@ public class Floor2InOutSsjThread implements Runnable {
agvQueue.setPositionCode2(inSsjDevice.getDeviceCode());
List<AgvQueue> agvQueues = agvQueueService.selectAgvQueueList(agvQueue);
//不允许放货 等着
if (!agvQueues.isEmpty() && inSsjDevice.getAllowPut() == 0 && "L1001".equals(inSsjDevice.getDeviceCode())) {
//下发输送线切换导向
int i = writeToSsjQH(inSsjDevice.getPlcDbWriteAddress(), Integer.parseInt(agvQueues.get(0).getCtnrType()));
if (i == 1) {
log.info("输送机{}下发切换导向{}成功", inSsjDevice.getDeviceCode(), agvQueues.get(0).getCtnrType());
}
}
//允许放货
if (!agvQueues.isEmpty() && inSsjDevice.getAllowPut() == 1) {
log.info("设备:{} 位置:{} 任务号:{} 请求放货成功", inSsjDevice.getDeviceCode(), "输送线", agvQueues.get(0).getTaskCode());
@@ -151,6 +161,7 @@ public class Floor2InOutSsjThread implements Runnable {
jobCallBack.setStatus("0");
jobCallBack.setTaskNo(Convert.toLong(mydoJob.getTaskNo()));
jobCallBack.setCreateTime(new Date());
jobCallBack.setSpare1("0");
jobCallBackService.insertJobCallBack(jobCallBack);
}
}

View File

@@ -38,12 +38,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="requestHeaders != null and requestHeaders != ''"> and request_headers = #{requestHeaders}</if>
<if test="requestBody != null and requestBody != ''"> and request_body like concat('%',#{requestBody},'%') </if>
<if test="responseTime != null and responseTime != ''"> and response_time = #{responseTime}</if>
<if test="responseBody != null and responseBody != ''"> and response_body = #{responseBody}</if>
<if test="responseBody != null and responseBody != ''"> and response_body like concat('%',#{responseBody},'%')</if>
<if test="responseStatus != null and responseStatus != ''"> and response_status = #{responseStatus}</if>
<if test="errorDetails != null and errorDetails != ''"> and error_details = #{errorDetails}</if>
<if test="errorDetails != null and errorDetails != ''"> and error_details like concat('%',#{errorDetails},'%')</if>
<if test="duration != null and duration != ''"> and duration = #{duration}</if>
<if test="isSuccessful != null and isSuccessful != ''"> and Is_successful = #{isSuccessful}</if>
</where>
order by request_time desc
</select>
<select id="selectRequestLogByRequestId" parameterType="Long" resultMap="RequestLogResult">

View File

@@ -91,4 +91,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{id}
</foreach>
</delete>
<select id="getTopJobCallBack" resultMap="JobCallBackResult">
select top(1) id, type, task_no, mydojob_id, status, create_time, spare1, spare2, spare3 from job_call_back
where status = '0' and spare1 in ('0','1','2')
order by create_time asc
</select>
</mapper>