0805代码更新

This commit is contained in:
2025-08-05 14:54:55 +08:00
parent ef833bec2f
commit 45a010bf30
11 changed files with 136 additions and 64 deletions

View File

@@ -1,10 +1,6 @@
package com.zg.common.utils.http; package com.zg.common.utils.http;
import java.io.BufferedReader; import java.io.*;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.ConnectException; import java.net.ConnectException;
import java.net.SocketTimeoutException; import java.net.SocketTimeoutException;
import java.net.URL; import java.net.URL;
@@ -290,4 +286,48 @@ public class HttpUtils
return true; return true;
} }
} }
public static String sendPostJson(String url, String jsonBody) {
BufferedReader in = null;
OutputStream os = null;
StringBuilder result = new StringBuilder();
try {
log.info("sendPostJson - {}", url);
URL realUrl = new URL(url);
URLConnection conn = realUrl.openConnection();
conn.setRequestProperty("accept", "*/*");
conn.setRequestProperty("connection", "Keep-Alive");
conn.setRequestProperty("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64)");
conn.setRequestProperty("Accept-Charset", "utf-8");
conn.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
conn.setDoOutput(true);
conn.setDoInput(true);
os = conn.getOutputStream();
os.write(jsonBody.getBytes(StandardCharsets.UTF_8));
os.flush();
in = new BufferedReader(new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8));
String line;
while ((line = in.readLine()) != null) {
result.append(line);
}
log.info("recv - {}", result);
} catch (Exception e) {
log.error("调用HttpUtils.sendPostJson异常, url=" + url + ",param=" + jsonBody, e);
} finally {
try {
if (os != null) {
os.close();
}
if (in != null) {
in.close();
}
} catch (IOException ex) {
log.error("关闭流异常", ex);
}
}
return result.toString();
}
} }

View File

@@ -120,6 +120,7 @@ public class SecurityConfig
"/system/config/**", "/system/config/**",
"/AutoInventory/**", "/AutoInventory/**",
"/ws/**", "/ws/**",
"/wisdom/**",
"/mock/**", "/mock/**",
"/information/device/**", "/information/device/**",
"/MatchScan/**", "/MatchScan/**",

View File

@@ -214,7 +214,7 @@ public class RkInfo extends BaseEntity
private String hasMoved; private String hasMoved;
/** 是否借料0否 1是 */ /** 是否借料0否 1是 */
@Excel(name = "是否借料", readConverterExp = "0=否,1=是") @Excel(name = "是否借料", readConverterExp = "0=否,1=是,2=已归还")
private String isBorrowed; private String isBorrowed;
/** 签字图片URLimage_type = 0 */ /** 签字图片URLimage_type = 0 */

View File

@@ -14,8 +14,8 @@ import java.util.List;
public class StockOutDTO { public class StockOutDTO {
/** 领用时间(出库时间) */ /** 领用时间(出库时间) */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") // @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date lyTime; // private Date lyTime;
/** 借用时间 */ /** 借用时间 */
private Date borrowTime; private Date borrowTime;

View File

@@ -51,18 +51,18 @@ public class DdTaskServiceImpl implements IDdTaskService {
@Autowired @Autowired
private AgyWcsMapper agyWcsMapper; private AgyWcsMapper agyWcsMapper;
// //
// @Value("${agv.job.create-url}") @Value("${agv.job.create-url}")
// private String agvJobCreateUrl;
//
// @Value("${wcs.job.create-url}")
// private String wcsJobCreateUrl;
@Value("${mock.agv-job-create-url}")
private String agvJobCreateUrl; private String agvJobCreateUrl;
@Value("${mock.wcs-job-create-url}") @Value("${wcs.job.create-url}")
private String wcsJobCreateUrl; private String wcsJobCreateUrl;
// @Value("${mock.agv-job-create-url}")
// private String agvJobCreateUrl;
//
// @Value("${mock.wcs-job-create-url}")
// private String wcsJobCreateUrl;
@Override @Override
public List<DdTask> selectDdTaskList(DdTask ddTask) { public List<DdTask> selectDdTaskList(DdTask ddTask) {
return ddTaskMapper.selectDdTaskList(ddTask); return ddTaskMapper.selectDdTaskList(ddTask);
@@ -181,9 +181,7 @@ public class DdTaskServiceImpl implements IDdTaskService {
} }
log.info("[任务执行] 出库 → 调用WCStaskId={}, param={}", taskIdParam, wcsParam); log.info("[任务执行] 出库 → 调用WCStaskId={}, param={}", taskIdParam, wcsParam);
response = HttpUtils.sendPost(wcsJobCreateUrl, wcsParam.toJSONString()); response = HttpUtils.sendPostJson(wcsJobCreateUrl, wcsParam.toJSONString());
System.out.println("这是打印的出库时调用wcs的响应结果" + response);
JSONObject respJson; JSONObject respJson;
try { try {
@@ -198,7 +196,6 @@ public class DdTaskServiceImpl implements IDdTaskService {
throw new ServiceException("WCS任务执行失败: " + msg); throw new ServiceException("WCS任务执行失败: " + msg);
} }
// 写入 WCS 执行记录
WcsTaskResult wcs = new WcsTaskResult(); WcsTaskResult wcs = new WcsTaskResult();
wcs.setTaskId(taskIdParam); wcs.setTaskId(taskIdParam);
wcs.setTaskStatus("1"); wcs.setTaskStatus("1");
@@ -214,7 +211,7 @@ public class DdTaskServiceImpl implements IDdTaskService {
wcs.setUpdateTime(now); wcs.setUpdateTime(now);
wcsTaskResultMapper.insertWcsTaskResult(wcs); wcsTaskResultMapper.insertWcsTaskResult(wcs);
// 调用 AGV(立即) // 调用 AGV
requestId = taskNo + "12"; requestId = taskNo + "12";
JSONObject agvParam = new JSONObject(); JSONObject agvParam = new JSONObject();
agvParam.put("owner", "wms"); agvParam.put("owner", "wms");
@@ -226,7 +223,7 @@ public class DdTaskServiceImpl implements IDdTaskService {
agvParam.put("requestId", requestId); agvParam.put("requestId", requestId);
log.info("[任务执行] 出库 → 调用AGVrequestId={}, param={}", requestId, agvParam); log.info("[任务执行] 出库 → 调用AGVrequestId={}, param={}", requestId, agvParam);
response = HttpUtils.sendPost(agvJobCreateUrl, agvParam.toJSONString()); response = HttpUtils.sendPostJson(agvJobCreateUrl, agvParam.toJSONString());
try { try {
respJson = JSON.parseObject(response); respJson = JSON.parseObject(response);
@@ -256,7 +253,6 @@ public class DdTaskServiceImpl implements IDdTaskService {
agv.setUpdateTime(now); agv.setUpdateTime(now);
agvTaskResultMapper.insertAgvTaskResult(agv); agvTaskResultMapper.insertAgvTaskResult(agv);
// ✅ 保存 WCS 与 AGV 映射关系
AgyWcs mapping = new AgyWcs(); AgyWcs mapping = new AgyWcs();
mapping.setRequestId(requestId); mapping.setRequestId(requestId);
mapping.setTaskId(taskIdParam); mapping.setTaskId(taskIdParam);
@@ -275,11 +271,16 @@ public class DdTaskServiceImpl implements IDdTaskService {
param.put("requestId", requestId); param.put("requestId", requestId);
log.info("[任务执行] 类型={}AGVrequestId={}, param={}", taskType, requestId, param); log.info("[任务执行] 类型={}AGVrequestId={}, param={}", taskType, requestId, param);
response = HttpUtils.sendPost(agvJobCreateUrl, param.toJSONString()); response = HttpUtils.sendPostJson(agvJobCreateUrl, param.toJSONString());
JSONObject respJson = JSON.parseObject(response); JSONObject respJson;
try {
respJson = JSON.parseObject(response);
code = respJson.getInteger("code"); code = respJson.getInteger("code");
msg = respJson.getString("msg"); msg = respJson.getString("msg");
} catch (Exception e) {
throw new ServiceException("AGV响应解析失败: " + response);
}
if (code != 200) { if (code != 200) {
throw new ServiceException("任务执行失败: " + msg); throw new ServiceException("任务执行失败: " + msg);

View File

@@ -647,7 +647,7 @@ public class RkInfoServiceImpl implements IRkInfoService
update.setBillNoCk(billNo); update.setBillNoCk(billNo);
update.setCkType(dto.getCkType()); update.setCkType(dto.getCkType());
update.setTeamCode(dto.getTeamCode()); update.setTeamCode(dto.getTeamCode());
update.setLyTime(dto.getLyTime()); update.setLyTime(now); // ❗使用后端生成时间
update.setCkLihuoY(dto.getCkLihuoY()); update.setCkLihuoY(dto.getCkLihuoY());
update.setCkRemark(item.getCkRemark()); update.setCkRemark(item.getCkRemark());
update.setXmNoCk(dto.getXmNoCk()); update.setXmNoCk(dto.getXmNoCk());
@@ -663,18 +663,10 @@ public class RkInfoServiceImpl implements IRkInfoService
if (needAudit) { if (needAudit) {
update.setStatus("3"); // 出库待审核 update.setStatus("3"); // 出库待审核
if ("JLCK".equals(dto.getCkType())) { update.setIsChuku("JLCK".equals(dto.getCkType()) ? "3" : "2");
update.setIsChuku("3"); // 借料出库(待审核)
} else {
update.setIsChuku("2"); // 普通出库待审核
}
} else { } else {
update.setStatus("1"); // 审核通过 update.setStatus("1"); // 审核通过
if ("JLCK".equals(dto.getCkType())) { update.setIsChuku("JLCK".equals(dto.getCkType()) ? "3" : "1");
update.setIsChuku("3"); // 借料出库(已审核)
} else {
update.setIsChuku("1"); // 普通出库已审核
}
} }
rkInfoMapper.updateById(update); rkInfoMapper.updateById(update);
@@ -684,20 +676,18 @@ public class RkInfoServiceImpl implements IRkInfoService
if (needAudit) { if (needAudit) {
List<AuditSignature> recordList = new ArrayList<>(); List<AuditSignature> recordList = new ArrayList<>();
// 先检查是否已有发起人记录(逻辑规范化)
boolean hasOldSign = auditSignatureMapper.existsCurrentSigner(billNo, "0"); boolean hasOldSign = auditSignatureMapper.existsCurrentSigner(billNo, "0");
if (hasOldSign) { if (hasOldSign) {
auditSignatureMapper.updateIsCurrentToZero(billNo, "0"); auditSignatureMapper.updateIsCurrentToZero(billNo, "0");
} }
// ✅ 插入发起人签字记录(无论是否有签字图)
AuditSignature sign = new AuditSignature(); AuditSignature sign = new AuditSignature();
sign.setBillNo(billNo); sign.setBillNo(billNo);
sign.setBillType("1"); // 出库 sign.setBillType("1");
sign.setSignerId(userId); sign.setSignerId(userId);
sign.setSignerRole("0"); // 发起人 sign.setSignerRole("0");
sign.setSignUrl(dto.getSignatureUrl()); // 允许为空 sign.setSignUrl(dto.getSignatureUrl());
sign.setImageType("0"); // 签字图 sign.setImageType("0");
sign.setSignTime(now); sign.setSignTime(now);
sign.setAuditResult("2"); sign.setAuditResult("2");
sign.setApproverId(dto.getApproverId()); sign.setApproverId(dto.getApproverId());
@@ -707,7 +697,6 @@ public class RkInfoServiceImpl implements IRkInfoService
sign.setCreateTime(now); sign.setCreateTime(now);
recordList.add(sign); recordList.add(sign);
// ✅ 插入每条出库明细的现场拍照记录photoUrl不为空才插
for (StockOutItemDTO item : dto.getCkList()) { for (StockOutItemDTO item : dto.getCkList()) {
if (StringUtils.isBlank(item.getPhotoUrl())) continue; if (StringUtils.isBlank(item.getPhotoUrl())) continue;
@@ -715,9 +704,9 @@ public class RkInfoServiceImpl implements IRkInfoService
photo.setBillNo(billNo); photo.setBillNo(billNo);
photo.setBillType("1"); photo.setBillType("1");
photo.setSignerId(userId); photo.setSignerId(userId);
photo.setSignerRole("2"); // 拍照人 photo.setSignerRole("2");
photo.setSignUrl(item.getPhotoUrl()); photo.setSignUrl(item.getPhotoUrl());
photo.setImageType("1"); // 现场图 photo.setImageType("1");
photo.setSignTime(now); photo.setSignTime(now);
photo.setApproverId(dto.getApproverId()); photo.setApproverId(dto.getApproverId());
photo.setIsCurrent("1"); photo.setIsCurrent("1");
@@ -739,7 +728,6 @@ public class RkInfoServiceImpl implements IRkInfoService
return dto.getCkList().size(); return dto.getCkList().size();
} }
@Override @Override
public void matchWithStatus(QueryDTO dto) { public void matchWithStatus(QueryDTO dto) {
List<String> pcdeIds = dto.getIds(); List<String> pcdeIds = dto.getIds();
@@ -865,7 +853,7 @@ public class RkInfoServiceImpl implements IRkInfoService
newEntry.setIsChuku("0"); newEntry.setIsChuku("0");
newEntry.setPcode(newPcode); newEntry.setPcode(newPcode);
newEntry.setRkType(dto.getRkType()); newEntry.setRkType(dto.getRkType());
newEntry.setReturnTime(DateUtils.getNowDate()); newEntry.setRkTime(DateUtils.getNowDate());
newEntry.setBillNo(BillNoUtil.generateTodayBillNo("RK")); newEntry.setBillNo(BillNoUtil.generateTodayBillNo("RK"));
newEntry.setCreateBy(SecurityUtils.getUserId().toString()); newEntry.setCreateBy(SecurityUtils.getUserId().toString());
newEntry.setCreateTime(DateUtils.getNowDate()); newEntry.setCreateTime(DateUtils.getNowDate());
@@ -876,10 +864,11 @@ public class RkInfoServiceImpl implements IRkInfoService
// 3. 插入新入库记录 // 3. 插入新入库记录
int rows = rkInfoMapper.insertRkInfo(newEntry); int rows = rkInfoMapper.insertRkInfo(newEntry);
// ✅ 4. 更新原记录的 is_borrowed = '0' // ✅ 4. 更新原记录的 is_borrowed = '2'
RkInfo update = new RkInfo(); RkInfo update = new RkInfo();
update.setId(originalId); update.setId(originalId);
update.setIsBorrowed("0"); update.setIsBorrowed("2");
update.setReturnTime(DateUtils.getNowDate());
update.setUpdateBy(SecurityUtils.getUsername()); update.setUpdateBy(SecurityUtils.getUsername());
update.setUpdateTime(DateUtils.getNowDate()); update.setUpdateTime(DateUtils.getNowDate());
rkInfoMapper.updateById(update); rkInfoMapper.updateById(update);

View File

@@ -6,8 +6,8 @@ spring:
druid: druid:
# 主库数据源 # 主库数据源
master: master:
url: jdbc:mysql://192.168.1.20:3306/wisdom?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 # url: jdbc:mysql://192.168.1.20:3306/wisdom?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
# url: jdbc:mysql://192.168.1.251:3306/wisdom?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 url: jdbc:mysql://192.168.1.251:3306/wisdom?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
# url: jdbc:mysql://localhost:3306/wisdom?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 # url: jdbc:mysql://localhost:3306/wisdom?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root username: root
password: shzg password: shzg

View File

@@ -68,8 +68,8 @@ spring:
# redis 配置 # redis 配置
redis: redis:
# 地址 # 地址
host: 192.168.1.20 # host: 192.168.1.20
# host: 192.168.1.251 host: 192.168.1.251
# host: localhost # host: localhost
# 端口默认为6379 # 端口默认为6379
port: 6379 port: 6379
@@ -146,7 +146,7 @@ gen:
agv: agv:
job: job:
create-url: http://192.168.1.245:9012/agv/task/create create-url: http://192.168.1.155:1880/api/job/create
wcs: wcs:
job: job:

View File

@@ -11,6 +11,12 @@
<result property="taskNo" column="task_no"/> <result property="taskNo" column="task_no"/>
<result property="status" column="status"/> <result property="status" column="status"/>
<result property="msg" column="msg"/> <result property="msg" column="msg"/>
<result property="jobId" column="job_id"/>
<result property="owner" column="owner"/>
<result property="type" column="type"/>
<result property="priority" column="priority"/>
<result property="sourceName" column="source_name"/>
<result property="targetName" column="target_name"/>
<result property="createBy" column="create_by"/> <result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/> <result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/> <result property="updateBy" column="update_by"/>
@@ -18,8 +24,24 @@
<result property="isDelete" column="is_delete"/> <result property="isDelete" column="is_delete"/>
</resultMap> </resultMap>
<sql id="selectAgvTaskResultVo"> <sql id="selectAgvTaskResultVo">
id, request_id, task_no, status, msg, create_by, create_time, update_by, update_time, is_delete id,
request_id,
task_no,
status,
msg,
job_id,
owner,
type,
priority,
source_name,
target_name,
create_by,
create_time,
update_by,
update_time,
is_delete
</sql> </sql>
<select id="selectAgvTaskResultById" resultMap="AgvTaskResultResultMap"> <select id="selectAgvTaskResultById" resultMap="AgvTaskResultResultMap">
@@ -57,8 +79,16 @@
<if test="taskNo != null">task_no,</if> <if test="taskNo != null">task_no,</if>
<if test="status != null">status,</if> <if test="status != null">status,</if>
<if test="msg != null">msg,</if> <if test="msg != null">msg,</if>
<if test="jobId != null">job_id,</if>
<if test="owner != null">owner,</if>
<if test="type != null">type,</if>
<if test="priority != null">priority,</if>
<if test="sourceName != null">source_name,</if>
<if test="targetName != null">target_name,</if>
<if test="createBy != null">create_by,</if> <if test="createBy != null">create_by,</if>
<if test="updateBy != null">update_by,</if>
create_time, create_time,
update_time,
is_delete is_delete
</trim> </trim>
VALUES VALUES
@@ -67,7 +97,15 @@
<if test="taskNo != null">#{taskNo},</if> <if test="taskNo != null">#{taskNo},</if>
<if test="status != null">#{status},</if> <if test="status != null">#{status},</if>
<if test="msg != null">#{msg},</if> <if test="msg != null">#{msg},</if>
<if test="jobId != null">#{jobId},</if>
<if test="owner != null">#{owner},</if>
<if test="type != null">#{type},</if>
<if test="priority != null">#{priority},</if>
<if test="sourceName != null">#{sourceName},</if>
<if test="targetName != null">#{targetName},</if>
<if test="createBy != null">#{createBy},</if> <if test="createBy != null">#{createBy},</if>
<if test="updateBy != null">#{updateBy},</if>
NOW(),
NOW(), NOW(),
'0' '0'
</trim> </trim>

View File

@@ -77,6 +77,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
ri.gys_no, ri.gys_mc, ri.jh_amt, ri.ht_dj, ri.sap_no, ri.xh, ri.gys_jh_id, ri.gys_no, ri.gys_mc, ri.jh_amt, ri.ht_dj, ri.sap_no, ri.xh, ri.gys_jh_id,
ri.jh_qty, ri.ht_qty, ri.dw, ri.real_qty, ri.jh_qty, ri.ht_qty, ri.dw, ri.real_qty,
ri.pcode, ri.pcode_id, ri.tray_code, ri.entity_id, ri.pcode, ri.pcode_id, ri.tray_code, ri.entity_id,
ri.status, ri.has_moved,
ri.create_by, ri.create_time, ri.update_by, ri.update_time, ri.is_delete, ri.create_by, ri.create_time, ri.update_by, ri.update_time, ri.is_delete,
u.user_name AS lihuo_y_name u.user_name AS lihuo_y_name
FROM rk_info ri FROM rk_info ri
@@ -129,6 +130,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
pcode, tray_code, entity_id, pcode, tray_code, entity_id,
ck_lihuo_y, ck_type, team_code, ck_remark, ck_lihuo_y, ck_type, team_code, ck_remark,
ly_time, bill_no_ck, has_moved, ly_time, bill_no_ck, has_moved,
gys_jh_id,
create_by, create_time, update_by, update_time, is_delete create_by, create_time, update_by, update_time, is_delete
) VALUES ( ) VALUES (
#{rkType}, #{wlType}, #{cangku}, #{rkTime}, #{lihuoY}, #{rkType}, #{wlType}, #{cangku}, #{rkTime}, #{lihuoY},
@@ -138,6 +140,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{pcode}, #{trayCode}, #{entityId}, #{pcode}, #{trayCode}, #{entityId},
#{ckLihuoY}, #{ckType}, #{teamCode}, #{ckRemark}, #{ckLihuoY}, #{ckType}, #{teamCode}, #{ckRemark},
#{lyTime}, #{billNoCk}, #{hasMoved}, #{lyTime}, #{billNoCk}, #{hasMoved},
#{gysJhId},
#{createBy}, #{createTime}, #{updateBy}, #{updateTime}, #{isDelete} #{createBy}, #{createTime}, #{updateBy}, #{updateTime}, #{isDelete}
) )
</insert> </insert>

View File

@@ -62,8 +62,8 @@
<select id="countByTaskId" resultType="java.lang.Integer" parameterType="java.lang.String"> <select id="countByTaskId" resultType="java.lang.Integer" parameterType="java.lang.String">
SELECT COUNT(*) SELECT COUNT(*)
FROM wcs_status FROM wcs_task_result
WHERE TaskID = #{taskId} WHERE task_id = #{taskId}
AND TaskStatus = '1' AND TaskStatus = '1'
</select> </select>