no message
parent
49ce14dc32
commit
e73f573a42
|
|
@ -99,8 +99,8 @@ public class Pick extends BaseEntity implements Serializable {
|
||||||
private Stock stock;
|
private Stock stock;
|
||||||
|
|
||||||
@Column(name = "`source_id`")
|
@Column(name = "`source_id`")
|
||||||
@ApiModelProperty(value = "来源ID")
|
@ApiModelProperty(value = "回传状态")
|
||||||
private Long sourceId;
|
private Long sourceId;/** 0失败;1.成功*/
|
||||||
|
|
||||||
@OneToOne
|
@OneToOne
|
||||||
@JoinColumn(name = "`dept_id`", nullable = false)
|
@JoinColumn(name = "`dept_id`", nullable = false)
|
||||||
|
|
|
||||||
|
|
@ -136,12 +136,12 @@ public class PickDetail extends BaseEntity implements Serializable {
|
||||||
private Dept dept;
|
private Dept dept;
|
||||||
|
|
||||||
@Column(name = "`source_name`")
|
@Column(name = "`source_name`")
|
||||||
@ApiModelProperty(value = "来源名称")
|
@ApiModelProperty(value = "回传报文")
|
||||||
private String sourceName;
|
private String sourceName;
|
||||||
|
|
||||||
@Column(name = "`source_id`")
|
@Column(name = "`source_id`")
|
||||||
@ApiModelProperty(value = "来源序号")
|
@ApiModelProperty(value = "回传状态")
|
||||||
private Long sourceId;
|
private Long sourceId;/**0失败;1成功;*/
|
||||||
|
|
||||||
public PickDetail() {
|
public PickDetail() {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,6 @@ import static org.springframework.http.HttpStatus.OK;
|
||||||
public class MesController {
|
public class MesController {
|
||||||
private final MesService mesService;
|
private final MesService mesService;
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/yclbl")
|
@PostMapping("/yclbl")
|
||||||
@Log("mes-原材料备料")
|
@Log("mes-原材料备料")
|
||||||
@ApiOperation("mes-原材料备料")
|
@ApiOperation("mes-原材料备料")
|
||||||
|
|
@ -98,12 +97,10 @@ public class MesController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private ResponseEntity<Object> badResponse(String message) {
|
private ResponseEntity<Object> badResponse(String message) {
|
||||||
return new ResponseEntity<>(ApiResult.fail(BAD_REQUEST.value(), message, ""), HttpStatus.BAD_REQUEST);
|
return new ResponseEntity<>(ApiResult.fail(BAD_REQUEST.value(), message, ""), HttpStatus.BAD_REQUEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private ResponseEntity<Object> successResponse(String message) {
|
private ResponseEntity<Object> successResponse(String message) {
|
||||||
return new ResponseEntity<>(ApiResult.fail(OK.value(), message, ""), HttpStatus.OK);
|
return new ResponseEntity<>(ApiResult.fail(OK.value(), message, ""), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,10 +15,12 @@
|
||||||
*/
|
*/
|
||||||
package com.youchain.businessdata.rest;
|
package com.youchain.businessdata.rest;
|
||||||
|
|
||||||
|
import com.youchain.annotation.AnonymousAccess;
|
||||||
import com.youchain.annotation.Log;
|
import com.youchain.annotation.Log;
|
||||||
import com.youchain.businessdata.domain.Pick;
|
import com.youchain.businessdata.domain.Pick;
|
||||||
import com.youchain.businessdata.service.PickService;
|
import com.youchain.businessdata.service.PickService;
|
||||||
import com.youchain.businessdata.service.dto.PickQueryCriteria;
|
import com.youchain.businessdata.service.dto.PickQueryCriteria;
|
||||||
|
import com.youchain.exception.handler.ApiResult;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
|
@ -27,10 +29,9 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import static org.springframework.http.HttpStatus.OK;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author huojin
|
* @author huojin
|
||||||
|
|
@ -86,4 +87,13 @@ public class PickController {
|
||||||
return new ResponseEntity<>(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/returnPick")
|
||||||
|
@Log("mes-工单回传")
|
||||||
|
@ApiOperation("mes-工单回传")
|
||||||
|
@AnonymousAccess
|
||||||
|
public ResponseEntity<Object> returnPick(@Validated @RequestBody Long pickId) {
|
||||||
|
pickService.returnPick(pickId);
|
||||||
|
return new ResponseEntity<>(ApiResult.success(OK.value(), "", ""), HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@ package com.youchain.businessdata.service;
|
||||||
|
|
||||||
import com.youchain.RequestData.TransTask;
|
import com.youchain.RequestData.TransTask;
|
||||||
import com.youchain.RequestData.Yclbl;
|
import com.youchain.RequestData.Yclbl;
|
||||||
|
import com.youchain.businessdata.domain.Pick;
|
||||||
|
import com.youchain.businessdata.domain.PickDetail;
|
||||||
|
|
||||||
public interface MesService {
|
public interface MesService {
|
||||||
/**
|
/**
|
||||||
|
|
@ -37,4 +39,5 @@ public interface MesService {
|
||||||
* @param transTask 搬运任务
|
* @param transTask 搬运任务
|
||||||
*/
|
*/
|
||||||
void performTransportTask(TransTask transTask);
|
void performTransportTask(TransTask transTask);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -111,4 +111,24 @@ public interface PickService {
|
||||||
*/
|
*/
|
||||||
void refreshPickStatus(Pick pick);
|
void refreshPickStatus(Pick pick);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工单回传JSON
|
||||||
|
*
|
||||||
|
* @param pickDetail 工单明细
|
||||||
|
*/
|
||||||
|
String returnPickJson(PickDetail pickDetail);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工单回传
|
||||||
|
* @param pick 出库单
|
||||||
|
*/
|
||||||
|
void returnPick(Long pick);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下发回传任务
|
||||||
|
* @param url 地址
|
||||||
|
* @param pickDetail 参数
|
||||||
|
*/
|
||||||
|
void sendPick(String url, PickDetail pickDetail);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -98,10 +98,10 @@ public class PickDetailDto implements Serializable {
|
||||||
/** 仓库ID */
|
/** 仓库ID */
|
||||||
private Dept dept;
|
private Dept dept;
|
||||||
|
|
||||||
/** 来源名称 */
|
/** 回传报文 */
|
||||||
private String sourceName;
|
private String sourceName;
|
||||||
|
|
||||||
/** 封包系数 */
|
/** 回传状态 */
|
||||||
private Long sourceId;
|
private Long sourceId;
|
||||||
|
|
||||||
/** 创建人 */
|
/** 创建人 */
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ public class PickDto implements Serializable {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 来源ID
|
* 回传状态
|
||||||
*/
|
*/
|
||||||
private Long sourceId;
|
private Long sourceId;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ package com.youchain.businessdata.service.dto;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.sql.Timestamp;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.youchain.annotation.Query;
|
import com.youchain.annotation.Query;
|
||||||
|
|
@ -59,4 +60,7 @@ public class PickQueryCriteria {
|
||||||
@Query(type = Query.Type.EQUAL)
|
@Query(type = Query.Type.EQUAL)
|
||||||
private String orderType;
|
private String orderType;
|
||||||
|
|
||||||
|
@Query(type = Query.Type.BETWEEN)
|
||||||
|
private List<Timestamp> createTime;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
package com.youchain.businessdata.service.impl;
|
package com.youchain.businessdata.service.impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.youchain.RequestData.ItemDate;
|
import com.youchain.RequestData.ItemDate;
|
||||||
import com.youchain.RequestData.TransTask;
|
import com.youchain.RequestData.TransTask;
|
||||||
import com.youchain.RequestData.Yclbl;
|
import com.youchain.RequestData.Yclbl;
|
||||||
|
|
@ -19,6 +21,8 @@ import com.youchain.businessdata.service.AgvTaskService;
|
||||||
import com.youchain.businessdata.service.MesService;
|
import com.youchain.businessdata.service.MesService;
|
||||||
import com.youchain.businessdata.service.TaskService;
|
import com.youchain.businessdata.service.TaskService;
|
||||||
import com.youchain.exception.BadRequestException;
|
import com.youchain.exception.BadRequestException;
|
||||||
|
import com.youchain.modules.system.domain.Dict;
|
||||||
|
import com.youchain.modules.system.repository.DictRepository;
|
||||||
import com.youchain.modules.system.service.DeptService;
|
import com.youchain.modules.system.service.DeptService;
|
||||||
import com.youchain.utils.*;
|
import com.youchain.utils.*;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
@ -26,10 +30,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
@ -75,6 +76,8 @@ public class MesServiceImpl implements MesService {
|
||||||
createPicks.add(pick);
|
createPicks.add(pick);
|
||||||
zcData.getBlzcmx().forEach(itemDate -> {
|
zcData.getBlzcmx().forEach(itemDate -> {
|
||||||
Item item = itemMap.get(itemDate.getItemCode());
|
Item item = itemMap.get(itemDate.getItemCode());
|
||||||
|
item.setGoodType(BaseStatus.GD_TYPE_CT);
|
||||||
|
itemRepository.save(item);
|
||||||
PickDetail pickDetail = createPickDetail(pick, item, BaseStatus.GD_TYPE_CT, itemDate.getItemQty(), zcData.getCompleteQty());
|
PickDetail pickDetail = createPickDetail(pick, item, BaseStatus.GD_TYPE_CT, itemDate.getItemQty(), zcData.getCompleteQty());
|
||||||
createPickDetails.add(pickDetail);
|
createPickDetails.add(pickDetail);
|
||||||
});
|
});
|
||||||
|
|
@ -85,6 +88,8 @@ public class MesServiceImpl implements MesService {
|
||||||
Pick pick = createPick(orderNo, taskCode, lineNo.getAndIncrement(), itemDate.getItemCode(), itemDate.getStation(), BaseStatus.GD_TYPE_DP);
|
Pick pick = createPick(orderNo, taskCode, lineNo.getAndIncrement(), itemDate.getItemCode(), itemDate.getStation(), BaseStatus.GD_TYPE_DP);
|
||||||
createPicks.add(pick);
|
createPicks.add(pick);
|
||||||
Item item = itemMap.get(itemDate.getItemCode());
|
Item item = itemMap.get(itemDate.getItemCode());
|
||||||
|
item.setGoodType(BaseStatus.GD_TYPE_DP);
|
||||||
|
itemRepository.save(item);
|
||||||
PickDetail pickDetail = createPickDetail(pick, item, BaseStatus.GD_TYPE_DP, itemDate.getItemQty(), null);
|
PickDetail pickDetail = createPickDetail(pick, item, BaseStatus.GD_TYPE_DP, itemDate.getItemQty(), null);
|
||||||
createPickDetails.add(pickDetail);
|
createPickDetails.add(pickDetail);
|
||||||
});
|
});
|
||||||
|
|
@ -170,6 +175,7 @@ public class MesServiceImpl implements MesService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证参数有效性
|
* 验证参数有效性
|
||||||
*
|
*
|
||||||
|
|
@ -381,6 +387,5 @@ public class MesServiceImpl implements MesService {
|
||||||
|
|
||||||
// 下发任务
|
// 下发任务
|
||||||
kmReService.sendAgvTask(agvTask, kmReService.sendAgvTaskGtJson(agvTask));
|
kmReService.sendAgvTask(agvTask, kmReService.sendAgvTaskGtJson(agvTask));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,13 +15,18 @@
|
||||||
*/
|
*/
|
||||||
package com.youchain.businessdata.service.impl;
|
package com.youchain.businessdata.service.impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.youchain.basicdata.domain.Point;
|
import com.youchain.basicdata.domain.Point;
|
||||||
import com.youchain.basicdata.domain.Stock;
|
import com.youchain.basicdata.domain.Stock;
|
||||||
import com.youchain.basicdata.service.PointService;
|
import com.youchain.basicdata.service.PointService;
|
||||||
import com.youchain.basicdata.service.StockService;
|
import com.youchain.basicdata.service.StockService;
|
||||||
import com.youchain.businessdata.domain.*;
|
import com.youchain.businessdata.domain.*;
|
||||||
|
import com.youchain.businessdata.repository.PickDetailRepository;
|
||||||
import com.youchain.businessdata.service.*;
|
import com.youchain.businessdata.service.*;
|
||||||
import com.youchain.exception.BadRequestException;
|
import com.youchain.exception.BadRequestException;
|
||||||
|
import com.youchain.modules.system.domain.Dict;
|
||||||
|
import com.youchain.modules.system.repository.DictRepository;
|
||||||
import com.youchain.service.LogService;
|
import com.youchain.service.LogService;
|
||||||
import com.youchain.utils.*;
|
import com.youchain.utils.*;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
@ -37,6 +42,7 @@ import org.springframework.data.domain.Pageable;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -50,12 +56,11 @@ import javax.servlet.http.HttpServletResponse;
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class PickServiceImpl implements PickService {
|
public class PickServiceImpl implements PickService {
|
||||||
|
private final DictRepository dictRepository;
|
||||||
private final PickRepository pickRepository;
|
private final PickRepository pickRepository;
|
||||||
|
private final PickDetailRepository pickDetailRepository;
|
||||||
private final PickMapper pickMapper;
|
private final PickMapper pickMapper;
|
||||||
private final PickDetailService pickDetailService;
|
private final PickDetailService pickDetailService;
|
||||||
private final PointService pointService;
|
|
||||||
private final AgvTaskService agvTaskService;
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -163,4 +168,81 @@ public class PickServiceImpl implements PickService {
|
||||||
pickRepository.save(pick);
|
pickRepository.save(pick);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String returnPickJson(PickDetail pickDetail) {
|
||||||
|
JSONObject jsonObject = new JSONObject(new LinkedHashMap<>());
|
||||||
|
//需求工位
|
||||||
|
jsonObject.put("OpName", pickDetail.getPick().getStation());
|
||||||
|
//工单号
|
||||||
|
jsonObject.put("OrderCode", pickDetail.getPick().getGdCode());
|
||||||
|
//物料编码
|
||||||
|
jsonObject.put("MaterialCode", pickDetail.getItem().getCode());
|
||||||
|
//数量
|
||||||
|
jsonObject.put("number", pickDetail.getOrderQty());
|
||||||
|
//taskId
|
||||||
|
jsonObject.put("taskId", pickDetail.getPick().getTaskCode());
|
||||||
|
System.out.println("叫料回传JSON:" + jsonObject.toString());
|
||||||
|
return jsonObject.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void returnPick(Long pickId) {
|
||||||
|
Pick pick = pickRepository.getById(pickId);
|
||||||
|
List<PickDetail> pickDetailList = pickDetailRepository.findByAllPickDetail(pickId);
|
||||||
|
for (PickDetail pickDetail : pickDetailList) {
|
||||||
|
sendPick(UrlApi.stock(), pickDetail);
|
||||||
|
}
|
||||||
|
refreshPickReturn(pick);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void refreshPickReturn(Pick pick) {
|
||||||
|
List<PickDetail> pickDetailList = pickDetailRepository.findByAllPickDetail(pick.getId());
|
||||||
|
List<PickDetail> filteredList = pickDetailList.stream()
|
||||||
|
.filter(detail -> detail.getSourceId() == null || detail.getSourceId() == 0)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
if (filteredList.isEmpty()) {
|
||||||
|
pick.setSourceId(1L);
|
||||||
|
pickRepository.save(pick);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
pick.setSourceId(0L);
|
||||||
|
pickRepository.save(pick);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendPick(String url, PickDetail pickDetail) {
|
||||||
|
Dict dict = dictRepository.findDictByDescription("OPEN");
|
||||||
|
String message = null;
|
||||||
|
if (dict != null) {
|
||||||
|
String resultJson = HttpPostUtil.sendPostReq(url, returnPickJson(pickDetail));
|
||||||
|
if (StringUtils.isEmpty(resultJson)) {
|
||||||
|
pickDetail.setSourceId(0L);
|
||||||
|
pickDetail.setSourceName("MES返回信息:接口调用失败");
|
||||||
|
pickDetailRepository.save(pickDetail);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
JSONObject resultObject = JSON.parseObject(resultJson);
|
||||||
|
if (resultObject == null) {
|
||||||
|
pickDetail.setSourceId(0L);
|
||||||
|
pickDetail.setSourceName("MES返回信息:接口数据返回为空");
|
||||||
|
pickDetailRepository.save(pickDetail);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String code = resultObject.getString("code");
|
||||||
|
message = resultObject.getString("message");
|
||||||
|
if (!"0".equals(code)) {
|
||||||
|
pickDetail.setSourceId(0L);
|
||||||
|
pickDetail.setSourceName(message);
|
||||||
|
pickDetailRepository.save(pickDetail);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
pickDetail.setSourceId(1L);
|
||||||
|
pickDetail.setSourceName(message == null ? "成功" : message);
|
||||||
|
pickDetailRepository.save(pickDetail);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,10 @@ public class UrlApi {
|
||||||
return (String)getByKey("containerOut_url");
|
return (String)getByKey("containerOut_url");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String stock(){
|
||||||
|
return (String)getByKey("stock_url");
|
||||||
|
}
|
||||||
|
|
||||||
public static String containerQuery(){
|
public static String containerQuery(){
|
||||||
return (String)getByKey("containerQuery"+"_url");
|
return (String)getByKey("containerQuery"+"_url");
|
||||||
}
|
}
|
||||||
|
|
@ -69,6 +73,10 @@ public class UrlApi {
|
||||||
* 输送线点位查询
|
* 输送线点位查询
|
||||||
*//*
|
*//*
|
||||||
public static String QueryCount="http://10.177.188.11:4080/webapi/mes/QueryCount";
|
public static String QueryCount="http://10.177.188.11:4080/webapi/mes/QueryCount";
|
||||||
|
|
||||||
|
MES回传
|
||||||
|
public static String stock="http://30.3.56.2:80/rest/productcenter/v1/agv/stock";
|
||||||
|
http://10.177.202.230:10870/rest/productcenter/v1/agv/stock
|
||||||
*/
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue