|
@@ -14,13 +14,12 @@ import com.mt.wms.core.vo.PageVo; |
|
|
import com.mt.wms.core.vo.R; |
|
|
import com.mt.wms.core.vo.R; |
|
|
import com.mt.wms.empty.controller.ApmsController; |
|
|
import com.mt.wms.empty.controller.ApmsController; |
|
|
import com.mt.wms.empty.enums.TaskTypeEnum; |
|
|
import com.mt.wms.empty.enums.TaskTypeEnum; |
|
|
import com.mt.wms.empty.params.AutoCurrTaskParam; |
|
|
|
|
|
import com.mt.wms.empty.params.CurrTaskQueryParam; |
|
|
|
|
|
import com.mt.wms.empty.params.TaskCreateParam; |
|
|
|
|
|
|
|
|
import com.mt.wms.empty.params.*; |
|
|
import com.mt.wms.empty.service.*; |
|
|
import com.mt.wms.empty.service.*; |
|
|
import com.mt.wms.empty.task.RunTaskUtils; |
|
|
import com.mt.wms.empty.task.RunTaskUtils; |
|
|
import com.mt.wms.empty.task.TaskDistanceUtils; |
|
|
import com.mt.wms.empty.task.TaskDistanceUtils; |
|
|
import com.mt.wms.empty.vo.*; |
|
|
import com.mt.wms.empty.vo.*; |
|
|
|
|
|
import com.mt.wms.empty.websocket.WebSocketServer; |
|
|
import org.slf4j.Logger; |
|
|
import org.slf4j.Logger; |
|
|
import org.slf4j.LoggerFactory; |
|
|
import org.slf4j.LoggerFactory; |
|
|
import org.springframework.beans.BeanUtils; |
|
|
import org.springframework.beans.BeanUtils; |
|
@@ -28,8 +27,10 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
import java.io.IOException; |
|
|
import java.io.IOException; |
|
|
import java.time.LocalDateTime; |
|
|
import java.time.LocalDateTime; |
|
|
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
import java.util.*; |
|
|
import java.util.*; |
|
|
import java.util.stream.Collectors; |
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
@@ -59,6 +60,8 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService |
|
|
|
|
|
|
|
|
@Autowired |
|
|
@Autowired |
|
|
ApmsController apmsControl; |
|
|
ApmsController apmsControl; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
WebSocketServer webSocketServer; |
|
|
|
|
|
|
|
|
@Autowired |
|
|
@Autowired |
|
|
OrderInfoServiceBiz orderInfoServiceBiz; |
|
|
OrderInfoServiceBiz orderInfoServiceBiz; |
|
@@ -165,7 +168,7 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService |
|
|
List<CurrTaskVo> currTaskVos = com.mt.wms.core.utils.BeanUtils.copyList(currTasks, CurrTaskVo.class); |
|
|
List<CurrTaskVo> currTaskVos = com.mt.wms.core.utils.BeanUtils.copyList(currTasks, CurrTaskVo.class); |
|
|
currTaskInfoVo.setCurrTaskVoList(currTaskVos); |
|
|
currTaskInfoVo.setCurrTaskVoList(currTaskVos); |
|
|
String allStep="液压台"; |
|
|
String allStep="液压台"; |
|
|
String nowStep=""; |
|
|
|
|
|
|
|
|
String nowStep="未开始"; |
|
|
for (CurrTask currTask1:currTasks |
|
|
for (CurrTask currTask1:currTasks |
|
|
) { |
|
|
) { |
|
|
if (currTask1.getStatus()==1){ |
|
|
if (currTask1.getStatus()==1){ |
|
@@ -198,7 +201,80 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService |
|
|
return successful(list); |
|
|
return successful(list); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public R<String> updateCurrTaskStatus(CurrTaskParam param) { |
|
|
|
|
|
CurrTask currTask = currTaskServiceBiz.getById(param.getId()); |
|
|
|
|
|
Integer status = param.getStatus(); |
|
|
|
|
|
//修改为加工中,多步骤任务修改为加工中,查询缓存区,查询前置任务状态,并修改 |
|
|
|
|
|
if (status==1){ |
|
|
|
|
|
InStockInfo inStockInfo = inStockInfoServiceBiz.getOne(new QueryWrapper<InStockInfo>().eq(InStockInfo.TASK_ID, currTask.getId())); |
|
|
|
|
|
if (inStockInfo!=null){ |
|
|
|
|
|
//更新库位状态为未占用 |
|
|
|
|
|
Location location = locationServiceBiz.getById(inStockInfo.getLocationId()); |
|
|
|
|
|
location.setStatus(0); |
|
|
|
|
|
locationServiceBiz.updateById(location); |
|
|
|
|
|
//删除库位缓存 |
|
|
|
|
|
inStockInfoServiceBiz.removeById(inStockInfo); |
|
|
|
|
|
} |
|
|
|
|
|
if (currTask.getIsAuto()==1){ |
|
|
|
|
|
AutoExeTask autoExeTask = autoExeTaskServiceBiz.getById(currTask.getAutoExeTaskId()); |
|
|
|
|
|
if (currTask.getId().equals(autoExeTask.getFTaskId())){ |
|
|
|
|
|
//该任务为自动任务第一条,是否有sheetNo,若无上报apms |
|
|
|
|
|
if (currTask.getSheetNo()==null){ |
|
|
|
|
|
try { |
|
|
|
|
|
apmsCreateProcess(currTask); |
|
|
|
|
|
} catch (IOException e) { |
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if (currTask.getId().equals(autoExeTask.getTTaskId())){ |
|
|
|
|
|
//该任务为自动任务第二条,修改自动任务第一条的状态 |
|
|
|
|
|
CurrTask currTask1 = currTaskServiceBiz.getById(autoExeTask.getFTaskId()); |
|
|
|
|
|
currTask1.setStatus(2); |
|
|
|
|
|
currTask1.setIsIn(2); |
|
|
|
|
|
//99代表该条记录手动修改过 |
|
|
|
|
|
currTask1.setCreatorId(99); |
|
|
|
|
|
currTaskServiceBiz.updateById(currTask1); |
|
|
|
|
|
}else if (currTask.getId().equals(autoExeTask.getThTaskId())){ |
|
|
|
|
|
//该任务为自动任务第三条,修改自动任务第二条的状态 |
|
|
|
|
|
CurrTask currTask2 = currTaskServiceBiz.getById(autoExeTask.getFTaskId()); |
|
|
|
|
|
currTask2.setStatus(2); |
|
|
|
|
|
currTask2.setIsIn(2); |
|
|
|
|
|
//99代表该条记录手动修改过 |
|
|
|
|
|
currTask2.setCreatorId(99); |
|
|
|
|
|
currTaskServiceBiz.updateById(currTask2); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
currTask.setStatus(1); |
|
|
|
|
|
currTask.setCreatorId(99); |
|
|
|
|
|
currTask.setBeginTime(LocalDateTime.now()); |
|
|
|
|
|
currTaskServiceBiz.updateById(currTask); |
|
|
|
|
|
return successful("修改任务状态为加工中成功"); |
|
|
|
|
|
} |
|
|
|
|
|
//修改为加工完成,查询缓存,并修改 |
|
|
|
|
|
if (status==2){ |
|
|
|
|
|
InStockInfo inStockInfo = inStockInfoServiceBiz.getOne(new QueryWrapper<InStockInfo>().eq(InStockInfo.TASK_ID, currTask.getId())); |
|
|
|
|
|
if (inStockInfo!=null){ |
|
|
|
|
|
//更新库位状态为未占用 |
|
|
|
|
|
Location location = locationServiceBiz.getById(inStockInfo.getLocationId()); |
|
|
|
|
|
location.setStatus(0); |
|
|
|
|
|
locationServiceBiz.updateById(location); |
|
|
|
|
|
//删除库位缓存 |
|
|
|
|
|
inStockInfoServiceBiz.removeById(inStockInfo); |
|
|
|
|
|
} |
|
|
|
|
|
currTask.setStatus(1); |
|
|
|
|
|
currTask.setCreatorId(99); |
|
|
|
|
|
currTask.setBeginTime(LocalDateTime.now()); |
|
|
|
|
|
currTaskServiceBiz.updateById(currTask); |
|
|
|
|
|
return successful("修改任务状态为加工完成成功"); |
|
|
|
|
|
} |
|
|
|
|
|
currTask.setStatus(status); |
|
|
|
|
|
currTask.setCreatorId(99); |
|
|
|
|
|
currTask.setBeginTime(LocalDateTime.now()); |
|
|
|
|
|
currTaskServiceBiz.updateById(currTask); |
|
|
|
|
|
return successful("修改任务状态为未加工成功"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
@@ -408,4 +484,57 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService |
|
|
inStockInfoServiceBiz.updateById(inStockInfo); |
|
|
inStockInfoServiceBiz.updateById(inStockInfo); |
|
|
return R.ok("当前任务置顶成功",""); |
|
|
return R.ok("当前任务置顶成功",""); |
|
|
} |
|
|
} |
|
|
|
|
|
/** |
|
|
|
|
|
* 上报apms创建生产单并开始处理 |
|
|
|
|
|
* |
|
|
|
|
|
* @param currTask 任务 |
|
|
|
|
|
* @return 成功与否 |
|
|
|
|
|
* @throws IOException |
|
|
|
|
|
*/ |
|
|
|
|
|
private Boolean apmsCreateProcess(CurrTask currTask) throws IOException { |
|
|
|
|
|
List<CurrTaskDet> currTaskDetList = currTaskDetServiceBiz.list(new QueryWrapper<CurrTaskDet>().eq(CurrTaskDet.CURR_TASK_ID, currTask.getId())); |
|
|
|
|
|
String code = kilnInfoServiceBiz.getById(currTask.getKilnId()).getCode(); |
|
|
|
|
|
//通知apms创建一个生产单 |
|
|
|
|
|
ApmsCreateProcessSheet apmsCreateSheet = new ApmsCreateProcessSheet(); |
|
|
|
|
|
apmsCreateSheet.setWorkShopCode("BM"); |
|
|
|
|
|
apmsCreateSheet.setStartTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); |
|
|
|
|
|
apmsCreateSheet.setTechCode(currTask.getCraftCodeId().toString()); |
|
|
|
|
|
//fixme 暂时没有正式user,使用测试账户 |
|
|
|
|
|
apmsCreateSheet.setStartUser("QJJP03"); |
|
|
|
|
|
ArrayList<CreateItem> createItems = new ArrayList<>(); |
|
|
|
|
|
currTaskDetList.forEach(e -> { |
|
|
|
|
|
CreateItem createItem = new CreateItem(); |
|
|
|
|
|
createItem.setItemCode(e.getIdenCardNum()); |
|
|
|
|
|
createItem.setQuantity(e.getQuantity().intValue()); |
|
|
|
|
|
createItem.setWeight(e.getWeight().doubleValue()); |
|
|
|
|
|
createItems.add(createItem); |
|
|
|
|
|
}); |
|
|
|
|
|
apmsCreateSheet.setStoveCode(code); |
|
|
|
|
|
apmsCreateSheet.setItems(createItems); |
|
|
|
|
|
logger.info(currTask.getId() + "开始创建apms生产单号"); |
|
|
|
|
|
R<ApmsCreateProcessSheetVo> processSheet = apmsControl.createProcessSheet(apmsCreateSheet); |
|
|
|
|
|
if (!processSheet.getData().getSuccess()) { |
|
|
|
|
|
logger.info(currTask.getId() + "创建失败,APMS报错:" + processSheet.getData().getMsg()); |
|
|
|
|
|
webSocketServer.sendtoUser("创建失败,APMS报错:" + processSheet.getData().getMsg(), "1"); |
|
|
|
|
|
return false; |
|
|
|
|
|
} else { |
|
|
|
|
|
logger.info(currTask.getId() + "创建apms生产单号成功"); |
|
|
|
|
|
currTask.setSheetNo(processSheet.getData().getSheetNo()); |
|
|
|
|
|
currTaskServiceBiz.updateById(currTask); |
|
|
|
|
|
//多步骤任务除了第一步写入sheetNo |
|
|
|
|
|
if (currTask.getIsAuto()==1){ |
|
|
|
|
|
AutoExeTask autoExeTask = autoExeTaskServiceBiz.getById(currTask.getAutoExeTaskId()); |
|
|
|
|
|
CurrTask secondCurrTask = currTaskServiceBiz.getById(autoExeTask.getTTaskId()); |
|
|
|
|
|
secondCurrTask.setSheetNo(currTask.getSheetNo()); |
|
|
|
|
|
currTaskServiceBiz.updateById(secondCurrTask); |
|
|
|
|
|
//三步任务 |
|
|
|
|
|
if (autoExeTask.getProcessFlowType()==2){ |
|
|
|
|
|
CurrTask threeCurrTask = currTaskServiceBiz.getById(autoExeTask.getThTaskId()); |
|
|
|
|
|
threeCurrTask.setSheetNo(currTask.getSheetNo()); |
|
|
|
|
|
currTaskServiceBiz.updateById(threeCurrTask); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |