no message

main
bbl\baobl 2024-05-20 15:38:46 +08:00
parent 6b8a6fe2e7
commit 6c1eedfa91
34 changed files with 253 additions and 242 deletions

View File

@ -45,7 +45,7 @@ public class HttpPutUtil {
}
if (url != null) {
try {
/*HttpURLConnection urlConn = (HttpURLConnection) url.openConnection();
HttpURLConnection urlConn = (HttpURLConnection) url.openConnection();
urlConn.setRequestProperty("content-type", "application/json");
urlConn.setDoInput(true);
urlConn.setDoOutput(true);
@ -77,10 +77,10 @@ public class HttpPutUtil {
}
isr.close();
urlConn.disconnect();
}*/
}
} catch (Exception e) {
e.printStackTrace();
System.out.println("SAP接口异常");
}
}

Binary file not shown.

View File

@ -126,6 +126,13 @@
<version>4.1.42.Final</version>
</dependency>
<dependency>
<groupId>com.youchain</groupId>
<artifactId>ModuleAPI_J</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/ModuleAPI_J.jar</systemPath>
</dependency>
</dependencies>
@ -135,6 +142,9 @@
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>
<!-- 跳过单元测试 -->
<plugin>

View File

@ -129,7 +129,7 @@ public class SceneAppController {
String stockType = BizStatus.getBillToAgv(box.getLampStatus());
ApiResult apiResult;
apiResult = agvTaskService.pointStockRk(stockType,box.getPoint().getId());
Point pointEndCode=pointRepository.findByTypeAndArea(BaseStatus.PLATFORM,"TAGM");
Point pointEndCode=BaseStatus.DoorPoint;
if (apiResult.getStatus()==200){
apiResult = agvTaskService.addAgvTask(box.getPoint().getId(),pointEndCode.getCode());
}
@ -144,7 +144,7 @@ public class SceneAppController {
int agvFlag=request.getIntValue("agvFlag");
Point point= pointRepository.findByName(request.getString("pointCode"));
// 人工入库 直接生成库存
ApiResult apiResult = taskService.manualReceiving(rfid,point,agvFlag);
ApiResult apiResult = taskService.manualReceiving(rfid,point,agvFlag,null);
if (point.getType().equals(BaseStatus.BOX)){
if (apiResult.getStatus()==200){
// AGV入库 生成搬运任务(目标库区,单据任务类型)
@ -247,7 +247,7 @@ public class SceneAppController {
apiResult=ApiResult.fail(500,"非半成品",null);
System.out.println();
}else {
apiResult = taskService.manualReceiving(rfid, point, agvFlag);
apiResult = taskService.manualReceiving(rfid, point, agvFlag,null);
}
data.put("status", apiResult.getMessage());
if (apiResult.getStatus()!=200){
@ -572,6 +572,7 @@ public class SceneAppController {
public ResponseEntity<Object> lxJhSub(@RequestBody(required=false) JSONObject request) {
JSONArray taskIds=request.getJSONArray("ids");
/** AGV料箱出库生成AgvTask*/
agvTaskService.pointStockRk(BizStatus.LXZ_STO,BaseStatus.LxZPoint.getId());
ApiResult apiResult = taskService.rmCkPickUp(taskIds);
return new ResponseEntity<>(apiResult, HttpStatus.valueOf(apiResult.getStatus()));
}

View File

@ -17,6 +17,8 @@ package com.youchain.basicdata.domain;
import com.youchain.base.BaseEntity;
import com.youchain.modules.system.domain.Dept;
import com.youchain.utils.BaseStatus;
import com.youchain.utils.BizStatus;
import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
@ -55,7 +57,7 @@ public class Point extends BaseEntity implements Serializable {
private String status;
@Column(name = "`agvStatus`")
@ApiModelProperty(value = "锁定状态")
private String agvStatus;
private String agvStatus= BaseStatus.FREE;
@Column(name = "`description`")
@ApiModelProperty(value = "备注")
private String description;

View File

@ -20,7 +20,9 @@ import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
import com.youchain.annotation.AnonymousAccess;
import com.youchain.annotation.Log;
import com.youchain.basicdata.domain.Area;
import com.youchain.basicdata.domain.Item;
import com.youchain.basicdata.domain.Point;
import com.youchain.basicdata.domain.StockType;
import com.youchain.basicdata.repository.ItemRepository;
import com.youchain.basicdata.service.ItemService;
@ -30,6 +32,7 @@ import com.youchain.basicdata.service.dto.ItemQueryCriteria;
import com.youchain.basicdata.service.dto.StockTypeQueryCriteria;
import com.youchain.config.FileProperties;
import com.youchain.exception.handler.ApiError;
import com.youchain.exception.handler.ApiResult;
import com.youchain.modules.system.domain.DictDetail;
import com.youchain.modules.system.service.DictDetailService;
import com.youchain.modules.system.service.DictService;
@ -51,6 +54,7 @@ import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -115,63 +119,44 @@ public class ItemController {
@Transactional
@AnonymousAccess
public ResponseEntity<Object> createSysAppUpdate( @RequestParam("file") MultipartFile multipartFile) {
FileUtil.checkSize(properties.getMaxSize(), multipartFile.getSize());
String suffix = FileUtil.getExtensionName(multipartFile.getOriginalFilename());
String type = FileUtil.getFileType(suffix);
log.error("--" + properties.getPath().getPath() + type + File.separator);
File file = FileUtil.upload(multipartFile, properties.getPath().getPath() + type + File.separator);
log.error("--" + file.getPath());
Map<String, StockType> map_stock = stockTypeService.queryAll();
DictQueryCriteria dictQueryCriteria=new DictQueryCriteria();
dictQueryCriteria.setBlurry("item_unit");
Map<String, DictDetail> map_dic = dictDetailService.getDictDetailByName("item_unit");
DictQueryCriteria itemTypeDc=new DictQueryCriteria();
itemTypeDc.setBlurry("item_type");
Map<String, DictDetail> item_type_dic = dictDetailService.getDictDetailByName("item_type");
ExcelReader reader = ExcelUtil.getReader(file);
int i=0;
int edit_len=0;
int new_len=0;
try{
List<Map<String, Object>> readAll = reader.readAll();
for ( i = 0; i < readAll.size(); i++) {
Item item = new Item();
String code=readAll.get(i).get("物料代码").toString().trim();
item.setCode(code);
item.setName("" + readAll.get(i).get("物料名称"));
//容器类型
String stocktype_Str = "" + readAll.get(i).get("容器类型");
item.setStockType(map_stock.get(stocktype_Str));
String unit=readAll.get(i).get("单位")+"";
item.setUnit(map_dic.get(unit).getValue());
String packNumber=readAll.get(i).get("默认容器装载数").toString().trim();
item.setPackNumber(Integer.parseInt(packNumber));
String itemType=readAll.get(i).get("物料类型")+"";
item.setGoodType(item_type_dic.get(itemType).getValue());
item.setLength(Double.parseDouble("" + readAll.get(i).get("长")));
item.setWidth(Double.parseDouble("" + readAll.get(i).get("宽")));
item.setHeight(Double.parseDouble("" + readAll.get(i).get("高")));
ItemQueryCriteria itemQueryCriteria=new ItemQueryCriteria();
itemQueryCriteria.setCode(code);
List<ItemDto> itemDto_list=itemService.queryAll(itemQueryCriteria);
if(itemDto_list.size()<=0){
new_len++;
log.error("不存在--" + readAll.get(i).get("编码")+"--");
itemService.create(item);
}else{
edit_len++;
log.error("存在--" + readAll.get(i).get("编码")+"--");
item.setId(itemDto_list.get(0).getId());
itemService.update(item);
List<String> msgError= new ArrayList<>();
int a=0;
int b=0;
int c=0;
List<Map<String, Object>> mapList=FileUtil.importUpload(multipartFile,properties);
for (int i = 0; i < mapList.size(); i++) {
Map map=mapList.get(i);
Item item;
String code=(map.get("sku")+"").equals("null")||(map.get("sku")+"").length()<1? null : (map.get("sku")+"");
String name=(map.get("名称")+"").equals("null")||(map.get("名称")+"").length()<1? null : (map.get("名称")+"");
String goodType=(map.get("存储库区")+"").equals("null")||(map.get("存储库区")+"").length()<1? null : (map.get("存储库区")+"");
String extendD1=(map.get("预期占用数")+"").equals("null")||(map.get("预期占用数")+"").length()<1? null : (map.get("预期占用数")+"");
String enabled=(map.get("是否启用")+"").equals("null")||(map.get("是否启用")+"").length()<1? null : (map.get("是否启用")+"");
String del=(map.get("删除")+"").equals("null")||(map.get("删除")+"").length()<1? null : (map.get("删除")+"");
if (code!=null){
item=itemRepository.findByCode(code);
if (item==null){
item=new Item();
item.setDept(UserUtils.getDept());
b=b+1;
}else {
c=c+1;
}
if (code!=null) item.setCode(code);
if (name!=null) item.setName(name);
if (goodType!=null) item.setGoodType(goodType);
if (extendD1!=null) item.setExtendD1(Double.valueOf(extendD1));
if (enabled!=null) item.setEnabled(Boolean.valueOf(enabled));
itemRepository.save(item);
if (del!=null){
itemRepository.delete(item);
continue;
}
}
}catch (Exception e){
ApiError apiError = ApiError.errorJosn(HttpStatus.BAD_REQUEST.value(), "导入异常---第"+(i+1)+"行:"+e.toString());
return new ResponseEntity(apiError, HttpStatus.valueOf(apiError.getStatus()));
}
ApiError apiError = ApiError.errorJosn(HttpStatus.OK.value(), "导入成功:"+(i)+"行 新增("+new_len+")修改("+edit_len+")");
return new ResponseEntity(apiError, HttpStatus.valueOf(apiError.getStatus()));
ApiResult apiResult=ApiResult.fail(200,"导入"+a+"行,新增"+b+"行,修改"+c+"行"+";异常信息"+msgError.toString(),null);
return new ResponseEntity(apiResult, HttpStatus.valueOf(apiResult.getStatus()));
}

View File

@ -85,84 +85,6 @@ public class PointController {
@ApiOperation("导入点位")
@PreAuthorize("@el.check('point:importPoint')")
public ResponseEntity<Object> importPoint(@RequestParam("file") MultipartFile multipartFile) {
/*FileUtil.checkSize(properties.getMaxSize(), multipartFile.getSize());
String suffix = FileUtil.getExtensionName(multipartFile.getOriginalFilename());
String type = FileUtil.getFileType(suffix);
File file = FileUtil.upload(multipartFile, properties.getPath().getPath() + type + File.separator);
Dept dept = UserUtils.getDept();
//编码、类型、库区、存储类型、X、Y
ExcelReader reader = ExcelUtil.getReader(file);
int i = 0;
int edit_len = 0;
int new_len = 0;
try {
List<Map<String, Object>> readAll = reader.readAll();
for (i = 0; i < readAll.size(); i++) {
String code = readAll.get(i).get("编码").toString().trim();
String types = readAll.get(i).get("类型").toString().trim();
String areaCode = readAll.get(i).get("库区").toString().trim();
String ccTYPE = readAll.get(i).get("存储类型") == null ? "" : readAll.get(i).get("存储类型").toString().trim();
Double x = readAll.get(i).get("坐标X") == null ? 0 : Double.parseDouble(readAll.get(i).get("坐标X").toString());
Double y = readAll.get(i).get("坐标Y") == null ? 0 : Double.parseDouble(readAll.get(i).get("坐标Y").toString());
Area area = areaService.findByCode(areaCode);
if (area == null) {
ApiError apiError = ApiError.errorJosn(BAD_REQUEST.value(), "找不到库区" + areaCode);
return new ResponseEntity(apiError, HttpStatus.valueOf(apiError.getStatus()));
}
Point point = pointService.getPoint(code, null, null, null);
if (point == null) {
point = new Point();
point.setCode(code);
point.setName(code);
String lx = "";
if (types.equals("缓存点")) {
lx = BaseStatus.STORAGE;
} else if (types.equals("线边点位")) {
lx = BaseStatus.BOX;
}
point.setType(lx);
point.setArea(area);
point.setDept(dept);
point.setDescription(ccTYPE);
point.setPosX(x);
point.setPosY(y);
point.setEnabled(true);
point.setStatus(BaseStatus.FREE);
pointService.create(point);
new_len++;
} else {
point.setCode(code);
point.setName(code);
String lx = "";
if (types.equals("缓存点")) {
lx = BaseStatus.STORAGE;
} else if (types.equals("线边点位")) {
lx = BaseStatus.BOX;
}
point.setType(lx);
point.setArea(area);
point.setDept(dept);
point.setDescription(ccTYPE);
point.setPosX(x);
point.setPosY(y);
pointService.update(point);
edit_len++;
}
log.info("导入" + (i + 1) + "行");
}
} catch (Exception e) {
ApiError apiError = ApiError.errorJosn(HttpStatus.BAD_REQUEST.value(), "导入异常---第" + (i + 1) + "行:" + e.toString());
return new ResponseEntity(apiError, HttpStatus.valueOf(apiError.getStatus()));
}
ApiError apiError = ApiError.errorJosn(HttpStatus.OK.value(), "导入成功:" + (i) + "行 新增(" + new_len + ")修改(" + edit_len + ")");
return new ResponseEntity(apiError, HttpStatus.valueOf(apiError.getStatus()));*/
ApiResult apiResult = pointService.importPoint(multipartFile);
return new ResponseEntity<>(apiResult, HttpStatus.valueOf(apiResult.getStatus()));
}

View File

@ -123,34 +123,11 @@ public class ItemServiceImpl implements ItemService {
List<Map<String, Object>> list = new ArrayList<>();
for (ItemDto item : all) {
Map<String,Object> map = new LinkedHashMap<>();
map.put("代码", item.getCode());
map.put("sku", item.getCode());
map.put("名称", item.getName());
map.put("规格", item.getSpecs());
map.put("客户ID", item.getStructureId());
map.put("描述", item.getDescription());
map.put("状态", item.getEnabled());
map.put("保质期", item.getValidPeriod());
map.put("预警天数", item.getAlertLeadingDays());
map.put("大类", item.getLargeClass());
map.put("中类", item.getCenterClass());
map.put("小类", item.getSmallClass());
map.put("物料类型", item.getGoodType());
map.put("长", item.getLength());
map.put("宽", item.getWidth());
map.put("高", item.getHeight());
map.put("重量", item.getWeight());
map.put("体积", item.getVolume());
map.put("单位", item.getUnit());
map.put("大单位", item.getMasterUnit());
map.put("包装系数", item.getPackNumber());
map.put("条码", item.getBarCode());
map.put("仓库ID", item.getDept());
map.put("来源名称", item.getSourceName());
map.put("来源序号", item.getSourceId());
map.put("创建人", item.getCreateBy());
map.put("修改人", item.getUpdateBy());
map.put("创建时间", item.getCreateTime());
map.put("修改时间", item.getUpdateTime());
map.put("存储库区", item.getGoodType());
map.put("预期占用数", item.getExtendD1());
map.put("是否启用", item.getEnabled());
list.add(map);
}
FileUtil.downloadExcel(list, response);

View File

@ -100,7 +100,6 @@ public class LampLogServiceImpl implements LampLogService {
lampLog.setOperationType("入库门");
lampLog.setRequestContent(rc);
lampLogRepository.save(lampLog);
// LampLog lampLog = lampLogRepository.getById(41688l);
return lampLog;
}

View File

@ -145,8 +145,8 @@ public class PointServiceImpl implements PointService {
map.put("名称", point.getName());
map.put("类型", point.getType());
map.put("库区", point.getArea().getName());
map.put("状态", point.getStatus());
map.put("当前容器", point.getStorageType());
map.put("预占用", point.getStatus());
map.put("分配容器", point.getStorageType());
map.put("深浅位", point.getHeat());
map.put("区域", point.getBeatCode());
map.put("是否启用", point.getEnabled());
@ -372,8 +372,8 @@ public class PointServiceImpl implements PointService {
String name=(map.get("名称")+"").equals("null")||(map.get("名称")+"").length()<1? null : (map.get("名称")+"");
String type=(map.get("类型")+"").equals("null")||(map.get("类型")+"").length()<1? null : (map.get("类型")+"");
String areaName=(map.get("库区")+"").equals("null")||(map.get("库区")+"").length()<1? null : (map.get("库区")+"");
String status=(map.get("状态")+"").equals("null")||(map.get("状态")+"").length()<1? null : (map.get("状态")+"");
String storageType=(map.get("当前容器")+"").equals("null")||(map.get("当前容器")+"").length()<1? null : (map.get("当前容器")+"");
String status=(map.get("预占用")+"").equals("null")||(map.get("预占用")+"").length()<1? null : (map.get("预占用")+"");
String storageType=(map.get("分配容器")+"").equals("null")||(map.get("分配容器")+"").length()<1? null : (map.get("分配容器")+"");
String heat=(map.get("深浅位")+"").equals("null")||(map.get("深浅位")+"").length()<1? null : (map.get("深浅位")+"");
String beatCode=(map.get("区域")+"").equals("null")||(map.get("区域")+"").length()<1? null : (map.get("区域")+"");
String enabled=(map.get("是否启用")+"").equals("null")||(map.get("是否启用")+"").length()<1? null : (map.get("是否启用")+"");

View File

@ -71,7 +71,7 @@ public class AgvTask extends BaseEntity implements Serializable {
private String type;
@Column(name = "`job_id`")
@ApiModelProperty(value = "")
@ApiModelProperty(value = "任务编码")
private String jobId;
@Column(name = "`job_type`",nullable = true)

View File

@ -87,4 +87,6 @@ public interface AgvTaskRepository extends JpaRepository<AgvTask, Integer>, JpaS
/** 定时发送任务*/
@Query(value = "select * from data_agv_task where `status`='OPEN' ", nativeQuery = true)
List<AgvTask> findByTiming();
@Query(value = "select a FROM AgvTask a where a.jobId=?1")
AgvTask findByJobId(String jobId);
}

View File

@ -46,6 +46,11 @@ public interface AsnDetailRepository extends JpaRepository<AsnDetail, Long>, Jpa
/** 查询收获中的明细*/
@Query("select d from AsnDetail d where d.asn.status in ('ACTIVE','RECEIVING') and d.asn.billType.code=?2")
List<AsnDetail> findByAsnBillType(String billTypeCode);
/** 查询物料 待收货明细*/
@Query("select d from AsnDetail d where d.asn.status in ('ACTIVE','RECEIVING') " +
" and d.item.code=?1" +
" and d.orderQty>d.receivedQty")
List<AsnDetail> findByItem(String itemCode);
@Query(value = "select d.* from data_asn_detail d where d.asn_id=?1 having sum(d.order_qty)<=sum(d.received_qty)",nativeQuery = true)
List<AsnDetail> findByAsnId(Long asnId);
@Query(value = "select d.* from data_asn_detail d where d.asn_id=?1",nativeQuery = true)

View File

@ -157,6 +157,6 @@ public interface TaskRepository extends JpaRepository<Task, Long>, JpaSpecificat
+" left join data_agv_task agv on t.agv_task_id=agv.id "
+" where t.task_status='ALLOCATE' and t.be_skip=1 and t.agv_task_id is null " +
" and (?1 is null or ?1=ik.prop_c7)"
+" group by t.item_key_id ",nativeQuery = true)
,nativeQuery = true)
List<Map<String, Object>> findByLxJhTask(Object o);
}

View File

@ -109,13 +109,19 @@ public class AgvTaskController {
JSONObject jsonObject = JSON.parseObject(json);
String taskCode = jsonObject.getString("missionCode")==null?"":jsonObject.getString("missionCode");//任务编号
String podCode = jsonObject.getString("podCode")==null?"":jsonObject.getString("podCode");//容器编号
String currentNodeCode = jsonObject.getString("currentNodeCode")==null?"":jsonObject.getString("currentNodeCode");//当前位置
String currentPosition = jsonObject.getString("currentPosition")==null?"":jsonObject.getString("currentPosition");//当前位置
String missionStatus = jsonObject.getString("missionStatus")==null?"":jsonObject.getString("missionStatus");//作业当前状态
if (missionStatus.equals("UP_CONTAINER")) missionStatus="2";
if (missionStatus.equals("MOVE_ARRIVE")) missionStatus="2";
if (missionStatus.equals("COMPLETED")) missionStatus="3";
if (missionStatus.equals("CANCELED")) missionStatus="4";
if (missionStatus.equals("ARRIVED_RFID")) missionStatus="5";
agvTaskService.agvTaskCallback(taskCode,missionStatus);
if (missionStatus.equals("5")){
if (BaseStatus.DoorPointEd.getCode().equals(currentPosition)){
agvTaskService.agvTaskCallback(taskCode,missionStatus,currentPosition);
}
}else {
agvTaskService.agvTaskCallback(taskCode,missionStatus,currentPosition);
}
return new ResponseEntity<>(ApiResult.success("",""),HttpStatus.OK);
//查询对应BOX
/*try {

View File

@ -102,7 +102,8 @@ public class PickDetailController {
public ResponseEntity<Object> createPickDetail(@Validated @RequestBody PickDetail resources) {
resources.setPo(new Date().getTime() + "");
resources.setStatus(BizStatus.OPEN);
return new ResponseEntity<>(pickDetailService.create(resources), HttpStatus.CREATED);
pickDetailRepository.save(resources);
return new ResponseEntity<>(ApiResult.fail(200, "操作成功", null), HttpStatus.CREATED);
}
@PutMapping

View File

@ -104,7 +104,7 @@ public class TaskController {
Point point= pointRepository.getById(request.getLong("pointId"));
String type=point.getType();
// 人工入库 直接生成库存
ApiResult apiResult = taskService.manualReceiving(rfid,point,agvFlag);
ApiResult apiResult = taskService.manualReceiving(rfid,point,agvFlag,null);
if (type.equals(BaseStatus.BOX)){
if (apiResult.getStatus()==200){
// AGV入库 生成搬运任务(目标库区,单据任务类型)
@ -251,7 +251,7 @@ public class TaskController {
Point pointStartCode=pointRepository.findByTypeAndArea(BaseStatus.PLATFORM,"TAGM");
// 收货生成Task
try {
ApiResult apiResult = taskService.manualReceiving(rfid,pointStartCode,agvFlag);
ApiResult apiResult = taskService.manualReceiving(rfid,pointStartCode,agvFlag,null);
if (apiResult.getStatus()!=200){
return new ResponseEntity<>(apiResult, HttpStatus.valueOf(apiResult.getStatus()));
}

View File

@ -152,7 +152,7 @@ public interface AgvTaskService {
*
* @param status
*/
void agvTaskCallback(String taskCode,String status);
void agvTaskCallback(String taskCode,String status,String currentPosition);
/**
* AgvTasK

View File

@ -137,7 +137,7 @@ public interface TaskService {
/** RFIDTask
* agvFlag agv
* */
ApiResult manualReceiving(String rfid,Point point,int agvFlag);
ApiResult manualReceiving(String rfid,Point point,int agvFlag,String areaCode);
ApiResult getAsnTask(Point endPoint, Task task);

View File

@ -39,6 +39,8 @@ public class AgvTaskQueryCriteria{
/** 容器码 */
@Query(type = Query.Type.LEFT_LIKE)
private String stockCode;
@Query(type = Query.Type.INNER_LIKE)
private String stockTypeCode;
/** 起点位置 */
@Query(type = Query.Type.LEFT_LIKE)

View File

@ -32,6 +32,10 @@ public class InventoryQueryCriteria{
private String itemCode;*/
@Query(joinName = "itemKey>item", propName="id",type = Query.Type.EQUAL)
private String itemId;
@Query(joinName = "point", propName="code",type = Query.Type.RIGHT_LIKE)
private String pointCode;
@Query(joinName = "point>area", propName="code",type = Query.Type.EQUAL)
private String areaCode;
@Query(type = Query.Type.EQUAL)
private Double queuedQty;
@Query(joinName = "itemKey>item>", propName="name",type = Query.Type.INNER_LIKE)
@ -49,6 +53,10 @@ public class InventoryQueryCriteria{
// NOT_EQUAL 不等于
@Query(type = Query.Type.NOT_EQUAL)
private Double quantity;
@Query(type = Query.Type.INNER_LIKE)
private String prodMtrl;
@Query(type = Query.Type.INNER_LIKE)
private String owner;
@Query(joinName = "stock", propName="name",type = Query.Type.INNER_LIKE)
private String stockName;

View File

@ -162,8 +162,8 @@ public class AgvTaskServiceImpl implements AgvTaskService {
String api="";
if (agvTask.getType().equals(BizStatus.AGV)) {
//搬运任务
jsonObject.put("requestId", agvTask.getId());
jsonObject.put("missionCode", agvTask.getId());
jsonObject.put("requestId", agvTask.getJobId());
jsonObject.put("missionCode", agvTask.getJobId());
jsonObject.put("priority", agvTask.getJobPriority());
jsonObject.put("containerModeCode", agvTask.getStockTypeCode());
jsonObject.put("startPosition", agvTask.getStartSlotCode());
@ -172,14 +172,14 @@ public class AgvTaskServiceImpl implements AgvTaskService {
api=UrlApi.submitMission;
}
if (agvTask.getType().equals(BizStatus.AGV_R)){
jsonObject.put("requestId", agvTask.getId());
jsonObject.put("requestId", agvTask.getJobId());
jsonObject.put("containerModeCode", agvTask.getStockTypeCode());
// jsonObject.put("containerCode", agvTask.getStockTypeCode());
jsonObject.put("position", agvTask.getEndSlotCode());
api=UrlApi.containerIn;
}
if (agvTask.getType().equals(BizStatus.AGV_C)){
jsonObject.put("requestId", agvTask.getId());
jsonObject.put("requestId", agvTask.getJobId());
jsonObject.put("containerCode", "");
jsonObject.put("position", agvTask.getEndSlotCode());
api=UrlApi.containerOut;
@ -460,9 +460,10 @@ public class AgvTaskServiceImpl implements AgvTaskService {
}
@Override
public void agvTaskCallback(String taskCode, String status) {
public void agvTaskCallback(String taskCode, String status, String currentPosition) {
// agvTask搬运任务
AgvTask agvTask=agvTaskRepository.getById(Integer.valueOf(taskCode));
// AgvTask agvTask=agvTaskRepository.getById(Integer.valueOf(taskCode));
AgvTask agvTask=agvTaskRepository.findByJobId(taskCode);
// task库存任务
// List<Task> tasks=taskRepository.getAgvTaskList(agvTask.getId(),BizStatus.ASN);
Point startPoint=null;
@ -473,6 +474,10 @@ public class AgvTaskServiceImpl implements AgvTaskService {
// 开始执行
// agvTask.setStatus(BizStatus.ATWORK);
}else if (status.equals("2")){
if (!currentPosition.equals(startPoint.getCode())){
//结束运行
return;
}
// 取料完成
if (startPoint!=null) {
startPoint.setAgvStatus(BaseStatus.FREE);
@ -526,6 +531,10 @@ public class AgvTaskServiceImpl implements AgvTaskService {
List<Task> taskList=taskRepository.findByAgvTask(agvTask.getId());
/** 出库任务回调 生成删除库存*/
inventoryService.pickDelInventory(taskList);
if (taskList.get(0).getTaskType().equals(BizStatus.FC_CK)) {
// 如果是成品出库就做料车解绑
pointStockCk(BizStatus.CTP_STO, endPoint.getId());
}
}else if (agvTask.getJobType().equals(BizStatus.ASN)) {
// 感应门扫描 数据 并保存日志
addTaskRfid(startPoint.getArea().getCode());
@ -563,7 +572,7 @@ public class AgvTaskServiceImpl implements AgvTaskService {
if (rfid.length()<1){
continue;
}
ApiResult apiResult = taskService.manualReceiving(rfid,BaseStatus.DoorPoint,1);
ApiResult apiResult = taskService.manualReceiving(rfid,BaseStatus.DoorPoint,1,areaCode);
if (apiResult.getStatus()==200){
// 解析成功
@ -723,6 +732,9 @@ public class AgvTaskServiceImpl implements AgvTaskService {
agvTask.setStatus(status);
agvTask.setJobType(jobType);
AgvTask agv=agvTaskRepository.save(agvTask);
// 添加任务id
agv.setJobId(agv.getId()+"");
agvTaskRepository.save(agv);
// 生成任务占用库位
Point startPoint=pointRepository.findByCode(startSlotCode);
Point endPoint=pointRepository.findByCode(endSlotCode);
@ -744,16 +756,17 @@ public class AgvTaskServiceImpl implements AgvTaskService {
Point startPoint=pointRepository.getById(id);
Point endPoint=pointRepository.findByCode(pointEndCode);
if (endPoint!=null){
if (!startPoint.getStatus().equals(BaseStatus.FREE)){
if (startPoint.getAgvStatus()!=null&& startPoint.getAgvStatus().equals(BaseStatus.USED)){
return ApiResult.fail(500,startPoint.getCode()+":被任务占用",null);
}
if (!endPoint.getStatus().equals(BaseStatus.FREE)){
if (endPoint.getAgvStatus()!=null&& endPoint.getAgvStatus().equals(BaseStatus.USED)){
return ApiResult.fail(500,endPoint.getCode()+":被任务占用",null);
}
if (startPoint.getStorageType()==null||startPoint.getStorageType().length()<1){
return ApiResult.fail(500,startPoint.getCode()+":没有容器",null);
}
AgvTask agvTask = addAgvTask(BizStatus.AGV, startPoint.getStorageType(), startPoint.getCode(),endPoint.getCode() , BizStatus.OPEN, BizStatus.ASN);
sendAgvTaskImpl(agvTask);
}else {
return ApiResult.fail(500,pointEndCode+":目标点错误",null);
}

View File

@ -274,7 +274,7 @@ public class InventoryServiceImpl implements InventoryService {
Point point=pointRepository.getById(pointId);
inventory.setPoint(point);
}
inventory.setDept(UserUtils.getDept());
inventory.setDept(BaseStatus.Dept);
inventory.setStatus(BizStatus.OPEN);
inventoryRepository.save(inventory);
//添加库存日志

View File

@ -179,6 +179,9 @@ public class PickDetailServiceImpl implements PickDetailService {
private ApiResult getAllocate(PickDetail pickDetail, Item item, Dept dept, Double quantity,Integer agvFlag) {
Point endPoint;
endPoint = pointRepository.findByCode(pickDetail.getPropC5());
if (endPoint==null){
return ApiResult.fail(500, "未找到目标点位", null);
}
if (pickDetail.getOrderQty() > pickDetail.getAllocatedQty()) {
List<Inventory> inventoryList = inventoryRepository.queryInventory(item.getId());
if (inventoryList.size() > 0) {

View File

@ -32,8 +32,10 @@ import com.youchain.businessdata.domain.*;
import com.youchain.businessdata.inputJson.IPTask;
import com.youchain.businessdata.repository.*;
import com.youchain.businessdata.service.*;
import com.youchain.exception.BadRequestException;
import com.youchain.exception.handler.ApiResult;
import com.youchain.modules.system.domain.Dept;
import com.youchain.modules.system.repository.DeptRepository;
import com.youchain.utils.*;
import lombok.RequiredArgsConstructor;
import com.youchain.businessdata.service.dto.TaskDto;
@ -42,6 +44,7 @@ import com.youchain.businessdata.service.mapstruct.TaskMapper;
import lombok.extern.slf4j.Slf4j;
import org.hibernate.SQLQuery;
import org.hibernate.transform.AliasToEntityMapResultTransformer;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.data.domain.Page;
@ -67,8 +70,10 @@ import javax.servlet.http.HttpServletResponse;
public class TaskServiceImpl implements TaskService {
private final TaskRepository taskRepository;
private final DeptRepository deptRepository;
private final TaskMapper taskMapper;
private final AsnRepository asnRepository;
private final AgvTaskRepository agvTaskRepository;
private final InventoryRepository inventoryRepository;
private final InventoryService inventoryService;
private final PickDetailRepository pickDetailRepository;
@ -120,7 +125,24 @@ public class TaskServiceImpl implements TaskService {
@Override
public void deleteAll(Long[] ids) {
for (Long id : ids) {
taskRepository.deleteById(id);
Task task=taskRepository.getById(id);
if (task.getAsnDetail()!=null){
//删除 入库Task任务
if (task.getTaskStatus().equals(BizStatus.RECEIVING)){
// 失效itemKey 后退回订单库存
ItemKey itemKey=task.getItemKey();
itemKey.setEnabled(false);
itemKeyRepository.save(itemKey);
// 退回订单库存
AsnDetail asnDetail=task.getAsnDetail();
asnDetail.setReceivedQty(asnDetail.getReceivedQty()-task.getPlanQty());
asnDetailRepository.save(asnDetail);
// 删除
taskRepository.deleteById(id);
}else {
throw new BadRequestException(HttpStatus.NOT_IMPLEMENTED, "已生成任务无法删除");
}
}
}
}
@ -281,9 +303,21 @@ public class TaskServiceImpl implements TaskService {
@Override
@Transactional(rollbackFor = Exception.class)
public ApiResult manualReceiving(String rfid,Point pointStart,int agvFlag) {
public ApiResult manualReceiving(String rfid,Point pointStart,int agvFlag,String areaCode) {
ApiResult apiResult;
String billTypeCode="";//单据类型
if (areaCode!=null) {
if (areaCode.equals(BizStatus.BCP)) {
// 半成品区
billTypeCode = BizStatus.SM_RK;
} else if (areaCode.equals(BizStatus.LX)) {
// 料箱区
billTypeCode = BizStatus.RM_RK;
} else if (areaCode.equals(BizStatus.CP)) {
// 成品区
billTypeCode = BizStatus.FC_RK;
}
}
Point pointEnd=null;
// 解析RFID信息
String itemCode=rfid.substring(0, 9);
@ -294,18 +328,27 @@ public class TaskServiceImpl implements TaskService {
String propC1=rfid.substring(9, 11);
String propC2=rfid.substring(11, 13);
String propC3=rfid.substring(13, 19);// 系统单号
Asn asn=asnRepository.findByRelatedBill1(propC3);
if (!BizStatus.getBillToStock(asn.getBillType().getCode()).equals(item.getGoodType())){
return ApiResult.fail(500,"单据类型和物料类型不匹配",null);
}
if (asn==null){
List<AsnDetail> asnDetailList=asnDetailRepository.findByItem(itemCode);
if(asnDetailList.size()<1){
return ApiResult.fail(500,"收货单中没有对应物料或入库单未激活",null);
}//
AsnDetail asnDetail=asnDetailList.get(0);
Asn asn=asnDetailList.get(0).getAsn();
// Asn asn=asnRepository.findByRelatedBill1(propC3);
/*if (asn==null){
return ApiResult.result(201, "没有入库单", "");
}else {
if (!asn.getStatus().equals(BizStatus.RECEIVING)&&!asn.getStatus().equals(BizStatus.ACTIVE)){
return ApiResult.result(500, "入库单未激活", "");
}
}*/
if (billTypeCode.length()<1) {
billTypeCode = asn.getBillType().getCode();//入库-单据类型
}
if (!BizStatus.getBillToStock(billTypeCode).equals(item.getGoodType())){
return ApiResult.fail(500,"单据类型和物料类型不匹配",null);
}
billTypeCode=asn.getBillType().getCode();//入库-单据类型
String propC4=rfid.substring(19, 20);//供货商
String propC5=Integer.valueOf(rfid.substring(20, 24),16)+"";//16进制 供货数量
StringBuffer propC6 = new StringBuffer();//流水号
@ -354,7 +397,7 @@ public class TaskServiceImpl implements TaskService {
i=i+4;
}
// 查询是否有其他已分配库位的RFID票
List<Task> taskList=taskRepository.findByItemType(BizStatus.PUTAWAY, 1, billTypeCode);
List<Task> taskList=taskRepository.findByItemType(BizStatus.RECEIVING, 1, billTypeCode);
if (taskList.size()>0){
pointEnd=taskList.get(0).getDstPoint();
}
@ -405,7 +448,10 @@ public class TaskServiceImpl implements TaskService {
}
}
}
int asnQty = Integer.parseInt(propC5);//收货数量
if (asnDetail.getOrderQty()-asnDetail.getReceivedQty()<asnQty) {
return ApiResult.fail(500,"入库单收货数量溢出,剩余收货数量"+(asnDetail.getOrderQty()-asnDetail.getReceivedQty()),null);
}
ItemKey itemKey=itemKeyRepository.getByItemKeyPro7(rfid);
if (itemKey==null){
itemKey = itemKeyService.getItemKey(item, propC1, propC2, propC3, propC4, propC5, propC6.toString(), rfid);
@ -431,35 +477,15 @@ public class TaskServiceImpl implements TaskService {
taskSum = 1;//按 一张rfid生成一个task
}
// 更新收货明细
List<AsnDetail> asnDetailList=asnDetailRepository.findByAsnAndItem(asn.getRelatedBill1(), itemCode);
int asnQty = Integer.parseInt(propC5, 16);//收货数量
if(asnDetailList.size()<1){
return ApiResult.fail(500,"收货单中没有对应物料",null);
}
boolean adFlag=false;
AsnDetail asnDetail=null;
for (int i = 0; i < asnDetailList.size(); i++) {
asnDetail=asnDetailList.get(i);
if (!BizStatus.getBillToStock(asnDetail.getAsn().getBillType().getCode()).equals(item.getGoodType())){
return ApiResult.fail(500,"收货单类型错误",null);
}
if (asnDetail.getOrderQty()-asnDetail.getReceivedQty()>=asnQty){
asnDetail.setReceivedQty(asnDetail.getReceivedQty()+asnQty);
asnDetailRepository.save(asnDetail);
adFlag=true;
break;
}
}
if (adFlag==false){
return ApiResult.fail(500,"入库单剩余收货数量小于当前收货数量",null);
}
asnDetail.setReceivedQty(asnDetail.getReceivedQty()+asnQty);
asnDetailRepository.save(asnDetail);
task = new Task();
task.setAsnDetail(asnDetail);
task.setPlanQty(Double.valueOf(propC5));//收货数量
task.setPutCode(propC6.toString());
task.setItemKey(itemKey);
task.setDept(UserUtils.getDept());
task.setDept(deptRepository.getById(7l));
task.setTaskStatus(BizStatus.RECEIVING);
task.setBeSkip(agvFlag);
task.setBillCode(asn.getRelatedBill2());
@ -613,6 +639,12 @@ public class TaskServiceImpl implements TaskService {
String propC5=rfid.substring(20, 24)+"";// 收货数量16禁止
Asn asn=asnRepository.findByRelatedBill1(propC3);
List<AsnDetail> asnDetailList=asnDetailRepository.findByItem(sku);
if(asnDetailList.size()<1){
return ApiResult.fail(500,"收货单中没有对应物料或入库单未激活",null);
}
AsnDetail asnDetail=asnDetailList.get(0);
asn=asnDetail.getAsn();
if (asn!=null){
String billTypeCode=asn.getBillType().getCode();
data.put("relatedBill1",asn.getRelatedBill1());
@ -620,14 +652,9 @@ public class TaskServiceImpl implements TaskService {
data.put("billType",asn.getBillType());
data.put("sku",sku);
data.put("RFID",rfid);
List<AsnDetail> asnDetailList = asnDetailRepository.findByAsnAndItem(asn.getRelatedBill1(),sku);
if (asnDetailList.size()<1){
return ApiResult.fail(500,"未查询到入库信息",data);
}
double orderQty=0;
for (int i = 0; i < asnDetailList.size(); i++) {
orderQty=orderQty+(asnDetailList.get(i).getOrderQty()-asnDetailList.get(i).getReceivedQty());
}
orderQty=orderQty+(asnDetailList.get(0).getOrderQty()-asnDetailList.get(0).getReceivedQty());
data.put("orderQty",orderQty);
data.put("lineNos",asnDetailList.size());
data.put("receivedQty",Integer.parseInt(propC5, 16));
@ -759,11 +786,45 @@ public class TaskServiceImpl implements TaskService {
startPointCode=task.getDstPoint().getBeatCode();
}
// 第一个任务 先生成AgvTask任务
// agvTask = agvTaskService.addAgvTask(BizStatus.AGV, storageType, startPointCode, task.getDstPoint().getCode(), BizStatus.OPEN, BizStatus.PICK);
agvTask = addAgvTask(BizStatus.AGV, storageType, BaseStatus.LxZPoint.getCode(), task.getDstPoint().getCode(), BizStatus.OPEN, BizStatus.PICK);
}
task.setAgvTask(agvTask);
taskRepository.save(task);
}
return ApiResult.fail(200,"生成搬运任务:"+agvTask.getId(),null);
}
public AgvTask addAgvTask(String type, String stockTypeCode, String startSlotCode, String endSlotCode, String status, String jobType) {
AgvTask agvTask = new AgvTask();
List<AgvTask> agvTaskList=agvTaskRepository.findByRptAgvTask(startSlotCode,endSlotCode);
if (agvTaskList.size()>0){
System.out.println("搬运任务重复");
return agvTaskList.get(0);
}
agvTask.setType(type);
String storageType=stockTypeRepository.findByCode(stockTypeCode).getMode();
agvTask.setStockTypeCode(storageType);
agvTask.setStartSlotCode(startSlotCode);
agvTask.setEndSlotCode(endSlotCode);
agvTask.setStatus(status);
agvTask.setJobType(jobType);
AgvTask agv=agvTaskRepository.save(agvTask);
// 添加任务id
agv.setJobId(agv.getId()+"");
agvTaskRepository.save(agv);
// 生成任务占用库位
Point startPoint=pointRepository.findByCode(startSlotCode);
Point endPoint=pointRepository.findByCode(endSlotCode);
if (!type.equals(BizStatus.AGV_R)&&!type.equals(BizStatus.AGV_C)) {
if (startPoint!=null&&startPoint.getType().equals("STORAGE")) {
startPoint.setAgvStatus(BaseStatus.USED);
pointRepository.save(startPoint);
}
if (endPoint!=null&&endPoint.getType().equals("STORAGE")) {
endPoint.setAgvStatus(BaseStatus.USED);
pointRepository.save(endPoint);
}
}
return agv;
}
}

View File

@ -141,6 +141,9 @@ public class TestTask {
BaseStatus.Dept=deptRepository.getById(7l);
JSONObject requestJson=JSONObject.parseObject(req);
// 是否反馈信息到《上游系统》 0 不反馈 1 反馈
String sapBack = requestJson.getString("SAP_BACK");
BaseStatus.SAP_BACK=Integer.valueOf(sapBack);
// 感应门终点编码
String doorPointCodeEnd = requestJson.getString("DoorPointEnd");
BaseStatus.DoorPoint=pointRepository.findByCode(doorPointCodeEnd);
@ -157,10 +160,14 @@ public class TestTask {
}
@Transactional
public void asnPutaway(String req){
public void asnPutStart(){
Reader.READER_ERR err = RfidDocJava.startRfid();
System.out.println("开始扫描:"+err.toString());
}
public void asnPutaway(){
synchronized (BaseStatus.Lock.rfid_SJ) {
Point point=pointRepository.getById(BaseStatus.DoorPoint.getId());
String st = point.getStorageType();
// Point point=pointRepository.getById(BaseStatus.DoorPoint.getId());
String st = BaseStatus.DoorPoint.getStorageType();
if (st.equals("BTP")){
agvTaskService.addTaskRfid(BizStatus.BCP);
}else if (st.equals("LXZ")){

View File

@ -40,13 +40,13 @@ public class RfidDocJava {
rfidDocJava.stopRead();
return vt;
}
public static void startRfid(){
public static READER_ERR startRfid(){
RfidDocJava rfidDocJava=new RfidDocJava();
rfidDocJava.startRead();
return rfidDocJava.startRead();
}
public void startRead(){
public READER_ERR startRead(){
vt=new HashSet();
StartReadTags();
return StartReadTags();
}
public void stopRead(){
rdr.StopReading();

View File

@ -13,6 +13,7 @@ import java.util.List;
* @date 2023-08-16
**/
public class BaseStatus {
public static int SAP_BACK = 1;
/**
*
*/

View File

@ -58,7 +58,9 @@ public class UrlApi {
er.put("productId", productId);
erLine.add(er);
paramsJson.put("erLine",erLine);
String res = HttpPutUtil.sendPutReq(asnBack+"/"+owner+"/"+expectedReceiptId,paramsJson.toString());
if (BaseStatus.SAP_BACK==1){
String res = HttpPutUtil.sendPutReq(asnBack+"/"+owner+"/"+expectedReceiptId,paramsJson.toString());
}
}
/** 出库单反馈*/
public static String ptBack = sapIpPort+"/synq/orders/pick-confirmation";
@ -93,7 +95,9 @@ public class UrlApi {
order.put("attributeValue",attributeValue);
orderLine.add(order);
paramsJson.put("orderLine",orderLine);
String res = HttpPutUtil.sendPutReq(ptBack+"/"+owner+"/"+expectedReceiptId,paramsJson.toString());
if (BaseStatus.SAP_BACK==1){
String res = HttpPutUtil.sendPutReq(ptBack+"/"+owner+"/"+expectedReceiptId,paramsJson.toString());
}
}
/** 库存调整反馈*/
public static String invBack = UrlApi.asnBack = sapIpPort+"/synq/load-units/batch-update";
@ -131,7 +135,9 @@ public class UrlApi {
load.put("attributeValue",attributeValue);
loadUnit.add(load);
paramsJson.put("loadUnit",loadUnit);
String res = HttpPutUtil.sendPutReq(ptBack,paramsJson.toString());
if (BaseStatus.SAP_BACK==1){
String res = HttpPutUtil.sendPutReq(ptBack,paramsJson.toString());
}
}
public static Point DoorPoint;
}