|
@@ -47,6 +47,7 @@ import com.github.zuihou.tenant.service.CodeRuleService;
|
|
|
import com.github.zuihou.tenant.service.ProductionlineService;
|
|
|
import com.github.zuihou.tenant.service.ProductionlineUserService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -1253,6 +1254,7 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
|
|
|
|
|
|
//推送到消息队列
|
|
|
msgUtil.pushToNextMq(taskNode, task, taskNodeList, n, callBackJson);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -1267,73 +1269,108 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
|
|
|
|
|
|
public void updateBizStatus(TaskNode taskNode, TTask task, List<TaskNode> taskNodeList, AAutoNodeLog lg, JSONObject callBackJson, R<String> r) {
|
|
|
//如果是推送当前节点到mq(一个节点执行多次。就不需要更新数据状态)
|
|
|
- if (!this.checkPushNextNode(taskNode, callBackJson))
|
|
|
- return;
|
|
|
+ if (this.checkPushNextNode(taskNode, callBackJson)){
|
|
|
+ //获取当前自动化节点的顺序
|
|
|
+ int n = taskNode.getCompleteBatchSort() - 1;
|
|
|
+ //插入执行日志
|
|
|
+ lg.setExeStatus("3");
|
|
|
+ if (r.getIsSuccess()) {
|
|
|
+ lg.setExeResult("1").setEndTime(new Date());
|
|
|
+ autoNodeLogMapper.updateAllById(lg);
|
|
|
+ } else {
|
|
|
+ lg.setExeResult("0").setFeedback(r.getMsg()).setEndTime(new Date());
|
|
|
+ autoNodeLogMapper.updateAllById(lg);
|
|
|
+ }
|
|
|
|
|
|
- //获取当前自动化节点的顺序
|
|
|
- int n = taskNode.getCompleteBatchSort() - 1;
|
|
|
- //插入执行日志
|
|
|
- lg.setExeStatus("3");
|
|
|
- if (r.getIsSuccess()) {
|
|
|
- lg.setExeResult("1").setEndTime(new Date());
|
|
|
- autoNodeLogMapper.updateAllById(lg);
|
|
|
- } else {
|
|
|
- lg.setExeResult("0").setFeedback(r.getMsg()).setEndTime(new Date());
|
|
|
- autoNodeLogMapper.updateAllById(lg);
|
|
|
- }
|
|
|
+ //更新节点任务
|
|
|
+ taskNode.setExeStatus("3").setExeResult("1").setEndTime(new Date());
|
|
|
+
|
|
|
+ // add by yejian on 20200212 for 判断是否是三坐标测量是否测量是否通过,不通过直接下料下线
|
|
|
+ // 判断当前工件是否是测量序,并且测量结果是否OK
|
|
|
+ BomProcedure bomProcedure = bomProcedureService.getById(task.getProcedureId());
|
|
|
+
|
|
|
+ // 三坐标测量
|
|
|
+ if(StringUtils.isNotBlank(bomProcedure.getProgramTestPrograme())){
|
|
|
+ // 测量NG
|
|
|
+ if("1".equals(callBackJson.getString("measuringResult"))){
|
|
|
+ taskNode.setTestResult("0");
|
|
|
+ // TODO 删除当前工件当前工序后的其他加工工序,直接下料,现在的都是最后工序是下料,删除到最后一个工序,后续根据新建单独下料需删除全部剩余结点在添加的方式
|
|
|
+ // 查找该工件最后工序
|
|
|
+ QueryWrapper<BomProcedure> queryBomProcedureWrapper = new QueryWrapper<BomProcedure>();
|
|
|
+ queryBomProcedureWrapper.eq("bomId", task.getBomId());
|
|
|
+ queryBomProcedureWrapper.orderByDesc("sort");
|
|
|
+ queryBomProcedureWrapper.last("limit 1");
|
|
|
+ BomProcedure bomLasProcedure = bomProcedureService.getOne(queryBomProcedureWrapper);
|
|
|
+
|
|
|
+ // 查找该工件最后排序的task
|
|
|
+ QueryWrapper<TTask> queryTTaskWrapper = new QueryWrapper<TTask>();
|
|
|
+ queryTTaskWrapper.eq("completeBatchNo", task.getCompleteBatchNo());
|
|
|
+ queryTTaskWrapper.eq("procedure_id",bomLasProcedure.getId());
|
|
|
+ TTask tTask = taskMapper.selectOne(queryTTaskWrapper);
|
|
|
+
|
|
|
+ // 删除tasknode表中除下料的未执行结点
|
|
|
+ QueryWrapper<TaskNode> deleteTaskNodeWrapper = new QueryWrapper<TaskNode>();
|
|
|
+ deleteTaskNodeWrapper.eq("completeBatchNo", task.getCompleteBatchNo());
|
|
|
+ deleteTaskNodeWrapper.eq("exeStatus","0");
|
|
|
+ deleteTaskNodeWrapper.ne("taskId",tTask.getId());
|
|
|
+ baseMapper.delete(deleteTaskNodeWrapper);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- //更新节点任务
|
|
|
- taskNode.setExeStatus("3").setExeResult("1").setEndTime(new Date());
|
|
|
- updateAllById(taskNode);
|
|
|
-
|
|
|
- //把当前完成的节点放入缓存,用于推送任务完成的百分比
|
|
|
- NumberFormat numberFormat = NumberFormat.getInstance();
|
|
|
- numberFormat.setMaximumFractionDigits(2);
|
|
|
-
|
|
|
- msgUtil.redis_set(CacheKey.TASK_CURRENT_NODE_PERCENT + "_" + task.getResourceId(), numberFormat.format(100 * (float) (n + 1) / (float) taskNodeList.size()));
|
|
|
- task.setProcess(Double.parseDouble(numberFormat.format(100 * (float) (n + 1) / (float) taskNodeList.size())));
|
|
|
-
|
|
|
- if (this.isLastTask(n, taskNode, taskNodeList)) {
|
|
|
- task.setStatus("3").setEndTime(new Date());
|
|
|
- taskMapper.updateById(task);
|
|
|
- //推送
|
|
|
- //删除正在执行的缓存
|
|
|
- msgUtil.redis_del(Arrays.asList(new String[]{CacheKey.PRESOURCE_CURRENT_TASK + "_" + task.getResourceId(), CacheKey.PRESOURCE_CURRENT_TASK_OBJECT + "_" + task.getResourceId(), CacheKey.TASK_CURRENT_NODE + "_" + task.getResourceId()}));
|
|
|
- msgUtil.pushDetailTask(task);
|
|
|
- } else {//主要更新完成比例
|
|
|
- taskMapper.updateById(task);
|
|
|
- }
|
|
|
+ // end by yejian on 20200212 for 判断是否是三坐标测量是否测量是否通过,不通过直接下线
|
|
|
|
|
|
- //更新订单表里的完成数量等等字段
|
|
|
- if (n == 0 && "1".equals(task.getFirstProcedureFlag())) {
|
|
|
- Order order = orderMapper.selectById(task.getOrderId());
|
|
|
- order.setProduceNum((order.getProduceNum() == null ? 0 : order.getProduceNum()) + 1);
|
|
|
- orderMapper.updateAllById(order);
|
|
|
- }
|
|
|
- //解锁相关资源
|
|
|
- unlockResource(taskNode, task);
|
|
|
- //更新订单表里的完成数量等等字段,一个任务执行完的时候更相信
|
|
|
- if (n == taskNodeList.size() - 1) {
|
|
|
- //执行最后一个
|
|
|
- //删除正在执行的缓存
|
|
|
- msgUtil.redis_del(Arrays.asList(new String[]{CacheKey.PRESOURCE_CURRENT_TASK + "_" + task.getResourceId(), CacheKey.PRESOURCE_CURRENT_TASK_OBJECT + "_" + task.getResourceId(), CacheKey.TASK_CURRENT_NODE + "_" + task.getResourceId()}));
|
|
|
-
|
|
|
- if ("1".equals(task.getLastProcedureFlag())) {
|
|
|
- //计划完成
|
|
|
- Plan plan = planMapper.selectById(task.getPlanId());
|
|
|
- plan.setProduceStatus("3");
|
|
|
- planMapper.updateById(plan);
|
|
|
-
|
|
|
- //订单完成
|
|
|
+ updateAllById(taskNode);
|
|
|
+
|
|
|
+ //把当前完成的节点放入缓存,用于推送任务完成的百分比
|
|
|
+ NumberFormat numberFormat = NumberFormat.getInstance();
|
|
|
+ numberFormat.setMaximumFractionDigits(2);
|
|
|
+
|
|
|
+ msgUtil.redis_set(CacheKey.TASK_CURRENT_NODE_PERCENT + "_" + task.getResourceId(), numberFormat.format(100 * (float) (n + 1) / (float) taskNodeList.size()));
|
|
|
+ task.setProcess(Double.parseDouble(numberFormat.format(100 * (float) (n + 1) / (float) taskNodeList.size())));
|
|
|
+
|
|
|
+ if (this.isLastTask(n, taskNode, taskNodeList)) {
|
|
|
+ task.setStatus("3").setEndTime(new Date());
|
|
|
+ taskMapper.updateById(task);
|
|
|
+ //推送
|
|
|
+ //删除正在执行的缓存
|
|
|
+ msgUtil.redis_del(Arrays.asList(new String[]{CacheKey.PRESOURCE_CURRENT_TASK + "_" + task.getResourceId(), CacheKey.PRESOURCE_CURRENT_TASK_OBJECT + "_" + task.getResourceId(), CacheKey.TASK_CURRENT_NODE + "_" + task.getResourceId()}));
|
|
|
+ msgUtil.pushDetailTask(task);
|
|
|
+ } else {//主要更新完成比例
|
|
|
+ taskMapper.updateById(task);
|
|
|
+ }
|
|
|
+
|
|
|
+ //更新订单表里的完成数量等等字段
|
|
|
+ if (n == 0 && "1".equals(task.getFirstProcedureFlag())) {
|
|
|
Order order = orderMapper.selectById(task.getOrderId());
|
|
|
- order.setCompleteNum((order.getCompleteNum() == null ? 0 : order.getCompleteNum()) + 1);
|
|
|
- order.setProduceStatus("3");//完成
|
|
|
+ order.setProduceNum((order.getProduceNum() == null ? 0 : order.getProduceNum()) + 1);
|
|
|
orderMapper.updateAllById(order);
|
|
|
-
|
|
|
- //设置计划结束
|
|
|
+ }
|
|
|
+ //解锁相关资源
|
|
|
+ unlockResource(taskNode, task);
|
|
|
+
|
|
|
+ //更新订单表里的完成数量等等字段,一个任务执行完的时候更相信
|
|
|
+ if (n == taskNodeList.size() - 1) {
|
|
|
+ //执行最后一个
|
|
|
+ //删除正在执行的缓存
|
|
|
+ msgUtil.redis_del(Arrays.asList(new String[]{CacheKey.PRESOURCE_CURRENT_TASK + "_" + task.getResourceId(), CacheKey.PRESOURCE_CURRENT_TASK_OBJECT + "_" + task.getResourceId(), CacheKey.TASK_CURRENT_NODE + "_" + task.getResourceId()}));
|
|
|
+
|
|
|
+ if ("1".equals(task.getLastProcedureFlag())) {
|
|
|
+ //计划完成
|
|
|
+ Plan plan = planMapper.selectById(task.getPlanId());
|
|
|
+ plan.setProduceStatus("3");
|
|
|
+ planMapper.updateById(plan);
|
|
|
+
|
|
|
+ //订单完成
|
|
|
+ Order order = orderMapper.selectById(task.getOrderId());
|
|
|
+ order.setCompleteNum((order.getCompleteNum() == null ? 0 : order.getCompleteNum()) + 1);
|
|
|
+ order.setProduceStatus("3");//完成
|
|
|
+ orderMapper.updateAllById(order);
|
|
|
+
|
|
|
+ //设置计划结束
|
|
|
// planMapper.updateproduceStatusFinish();
|
|
|
// ////设置订单结束
|
|
|
// orderMapper.updateproduceStatusFinish();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|