|
@ -7,6 +7,7 @@ import cn.hutool.core.util.ObjectUtil; |
|
|
import cn.hutool.core.util.StrUtil; |
|
|
import cn.hutool.core.util.StrUtil; |
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import lombok.RequiredArgsConstructor; |
|
|
import lombok.RequiredArgsConstructor; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.nl.common.utils.SecurityUtils; |
|
|
import org.nl.common.utils.SecurityUtils; |
|
@ -17,12 +18,20 @@ import org.nl.modules.wql.core.bean.WQLObject; |
|
|
import org.nl.modules.wql.util.SpringContextHolder; |
|
|
import org.nl.modules.wql.util.SpringContextHolder; |
|
|
import org.nl.wms.pda.mps.eum.RegionTypeEnum; |
|
|
import org.nl.wms.pda.mps.eum.RegionTypeEnum; |
|
|
import org.nl.wms.pda.mps.service.impl.BakingServiceImpl; |
|
|
import org.nl.wms.pda.mps.service.impl.BakingServiceImpl; |
|
|
|
|
|
import org.nl.wms.pdm.rawfoilworkorder.service.dao.CoolPointIvt; |
|
|
|
|
|
import org.nl.wms.pdm.rawfoilworkorder.service.dao.RawfoilWorkOrder; |
|
|
|
|
|
import org.nl.wms.pdm.rawfoilworkorder.service.dao.SbPointIvt; |
|
|
|
|
|
import org.nl.wms.pdm.rawfoilworkorder.service.dao.mapper.CoolPointIvtMapper; |
|
|
|
|
|
import org.nl.wms.pdm.rawfoilworkorder.service.dao.mapper.RawfoilWorkOrderMapper; |
|
|
|
|
|
import org.nl.wms.pdm.rawfoilworkorder.service.dao.mapper.SbPointIvtMapper; |
|
|
import org.nl.wms.sch.AcsTaskDto; |
|
|
import org.nl.wms.sch.AcsTaskDto; |
|
|
import org.nl.wms.sch.manage.AbstractAcsTask; |
|
|
import org.nl.wms.sch.manage.AbstractAcsTask; |
|
|
import org.nl.wms.sch.manage.TaskStatusEnum; |
|
|
import org.nl.wms.sch.manage.TaskStatusEnum; |
|
|
|
|
|
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 java.math.BigDecimal; |
|
|
import java.util.ArrayList; |
|
|
import java.util.ArrayList; |
|
|
import java.util.HashMap; |
|
|
import java.util.HashMap; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
@ -37,6 +46,14 @@ import java.util.List; |
|
|
@Slf4j |
|
|
@Slf4j |
|
|
public class CallEmpReelTask extends AbstractAcsTask { |
|
|
public class CallEmpReelTask extends AbstractAcsTask { |
|
|
private final String THIS_CLASS = CallEmpReelTask.class.getName(); |
|
|
private final String THIS_CLASS = CallEmpReelTask.class.getName(); |
|
|
|
|
|
@Autowired |
|
|
|
|
|
RawfoilWorkOrderMapper rawfoilWorkOrderMapper; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
SbPointIvtMapper sbPointIvtMapper; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
CoolPointIvtMapper coolPointIvtMapper; |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public List<AcsTaskDto> addTask() { |
|
|
public List<AcsTaskDto> addTask() { |
|
@ -87,18 +104,25 @@ public class CallEmpReelTask extends AbstractAcsTask { |
|
|
String currentUsername = SecurityUtils.getCurrentUsername(); |
|
|
String currentUsername = SecurityUtils.getCurrentUsername(); |
|
|
|
|
|
|
|
|
//更新车号和重量
|
|
|
//更新车号和重量
|
|
|
|
|
|
RawfoilWorkOrder rawfoilWorkOrder = null; |
|
|
|
|
|
if (ObjectUtil.isNotEmpty(jsonTask.getString("material_code"))) { |
|
|
|
|
|
rawfoilWorkOrder = rawfoilWorkOrderMapper.selectOne(new LambdaQueryWrapper<RawfoilWorkOrder>() |
|
|
|
|
|
.eq(RawfoilWorkOrder::getContainer_name, jsonTask.getString("material_code")) |
|
|
|
|
|
.ne(RawfoilWorkOrder::getStatus, "40") |
|
|
|
|
|
.eq(RawfoilWorkOrder::getIs_delete, "0")); |
|
|
|
|
|
} |
|
|
String car_no = taskObj.getString("car_no"); |
|
|
String car_no = taskObj.getString("car_no"); |
|
|
if (StrUtil.isNotEmpty(car_no)) { |
|
|
if (StrUtil.isNotEmpty(car_no) && rawfoilWorkOrder != null) { |
|
|
JSONObject update_jo = new JSONObject(); |
|
|
rawfoilWorkOrder.setAgvno(car_no); |
|
|
update_jo.put("agvno", car_no); |
|
|
rawfoilWorkOrder.setUpdate_time(DateUtil.now()); |
|
|
rawTab.update(update_jo, "container_name ='" + jsonTask.getString("material_code") + "' AND status <> '09' AND is_delete = '0'").uniqueResult(0); |
|
|
rawfoilWorkOrderMapper.updateById(rawfoilWorkOrder); |
|
|
} |
|
|
} |
|
|
// 更新生箔工单称重信息
|
|
|
// 更新生箔工单称重信息
|
|
|
String weight = taskObj.getString("weight"); |
|
|
String weight = taskObj.getString("weight"); |
|
|
if (ObjectUtil.isNotEmpty(weight)) { |
|
|
if (ObjectUtil.isNotEmpty(weight) && rawfoilWorkOrder != null) { |
|
|
JSONObject update_jo = new JSONObject(); |
|
|
rawfoilWorkOrder.setProductin_qty(new BigDecimal(weight)); |
|
|
update_jo.put("productin_qty", weight); |
|
|
rawfoilWorkOrder.setUpdate_time(DateUtil.now()); |
|
|
rawTab.update(update_jo, "container_name ='" + jsonTask.getString("material_code") + "' AND status <> '09' AND is_delete = '0'").uniqueResult(0); |
|
|
rawfoilWorkOrderMapper.updateById(rawfoilWorkOrder); |
|
|
} |
|
|
} |
|
|
if (StrUtil.equals(status, "0")) { |
|
|
if (StrUtil.equals(status, "0")) { |
|
|
// 更新删除字段
|
|
|
// 更新删除字段
|
|
@ -107,11 +131,12 @@ public class CallEmpReelTask extends AbstractAcsTask { |
|
|
taskTab.update(jsonTask); |
|
|
taskTab.update(jsonTask); |
|
|
|
|
|
|
|
|
// 更新生箔工单状态为初始化、清除称重信息
|
|
|
// 更新生箔工单状态为初始化、清除称重信息
|
|
|
JSONObject jsonRaw = rawTab.query("container_name ='" + jsonTask.getString("material_code") + "' AND status <> '09' AND is_delete = '0'").uniqueResult(0); |
|
|
if (rawfoilWorkOrder != null) { |
|
|
JSONObject update_jo = new JSONObject(); |
|
|
rawfoilWorkOrder.setStatus("00"); |
|
|
update_jo.put("status", "00"); |
|
|
rawfoilWorkOrder.setProductin_qty(new BigDecimal(0)); |
|
|
update_jo.put("productin_qty", 0); |
|
|
rawfoilWorkOrder.setUpdate_time(DateUtil.now()); |
|
|
rawTab.update(update_jo, "container_name ='" + jsonTask.getString("material_code") + "' AND status <> '09' AND is_delete = '0'"); |
|
|
rawfoilWorkOrderMapper.updateById(rawfoilWorkOrder); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (TaskStatusEnum.EXECUTING.getCode().equals(status)) { |
|
|
if (TaskStatusEnum.EXECUTING.getCode().equals(status)) { |
|
@ -122,104 +147,109 @@ public class CallEmpReelTask extends AbstractAcsTask { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (StrUtil.equals(status, TaskStatusEnum.FINISHED.getCode())) { |
|
|
if (StrUtil.equals(status, TaskStatusEnum.FINISHED.getCode())) { |
|
|
// 更改任务状态为完成
|
|
|
|
|
|
jsonTask.put("task_status", TaskStatusEnum.FINISHED.getCode()); |
|
|
|
|
|
jsonTask.put("update_optid", SecurityUtils.getCurrentUserId()); |
|
|
|
|
|
jsonTask.put("update_optname", SecurityUtils.getCurrentUsername()); |
|
|
|
|
|
jsonTask.put("update_time", DateUtil.now()); |
|
|
|
|
|
taskTab.update(jsonTask); |
|
|
|
|
|
|
|
|
|
|
|
String point_code1 = jsonTask.getString("point_code1"); |
|
|
String point_code1 = jsonTask.getString("point_code1"); |
|
|
String point_code2 = jsonTask.getString("point_code2"); |
|
|
String point_code2 = jsonTask.getString("point_code2"); |
|
|
String point_code3 = jsonTask.getString("point_code3"); |
|
|
String point_code3 = jsonTask.getString("point_code3"); |
|
|
String point_code4 = jsonTask.getString("point_code4"); |
|
|
String point_code4 = jsonTask.getString("point_code4"); |
|
|
JSONObject jsonRaw = rawTab.query("container_name ='" + jsonTask.getString("material_code") + "' AND status <> '09' AND is_delete = '0'").uniqueResult(0); |
|
|
|
|
|
if (ObjectUtil.isEmpty(jsonRaw)) { |
|
|
|
|
|
throw new BadRequestException("未找到满足条件的生箔工单:" + jsonTask.getString("material_code")); |
|
|
|
|
|
} |
|
|
|
|
|
String containerName = jsonRaw.getString("container_name"); |
|
|
|
|
|
String workorderId = jsonRaw.getString("workorder_id"); |
|
|
|
|
|
String productinQty = jsonRaw.getString("productin_qty"); |
|
|
|
|
|
// 取空取满放空放满
|
|
|
// 取空取满放空放满
|
|
|
if ("010101".equals(jsonTask.getString("task_type"))) { |
|
|
if ("010101".equals(jsonTask.getString("task_type"))) { |
|
|
|
|
|
if (rawfoilWorkOrder == null) { |
|
|
|
|
|
throw new BadRequestException("工单不存在"); |
|
|
|
|
|
} |
|
|
//更新生箔机点位库存
|
|
|
//更新生箔机点位库存
|
|
|
updateSbIvt(sbTab, point_code3, "01","02"); |
|
|
updateSbIvt(point_code3, "01", "02"); |
|
|
//更新冷却区点位库存
|
|
|
//更新冷却区点位库存
|
|
|
updateIvtIvt(ivtTab, point_code4, "02", "01", DateUtil.now(), containerName, workorderId, productinQty); |
|
|
updateIvtIvt(point_code4, "02", "01", rawfoilWorkOrder); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
//取满放满
|
|
|
//取满放满
|
|
|
if ("010102".equals(jsonTask.getString("task_type"))) { |
|
|
if ("010102".equals(jsonTask.getString("task_type"))) { |
|
|
|
|
|
if (rawfoilWorkOrder == null) { |
|
|
|
|
|
throw new BadRequestException("工单不存在"); |
|
|
|
|
|
} |
|
|
//更新生箔机点位库存
|
|
|
//更新生箔机点位库存
|
|
|
updateSbIvt(sbTab, point_code1, "01",null); |
|
|
updateSbIvt(point_code1, "01", null); |
|
|
//更新冷却区点位库存
|
|
|
//更新冷却区点位库存
|
|
|
updateIvtIvt(ivtTab, point_code2, "02", null, DateUtil.now(), containerName, workorderId, productinQty); |
|
|
updateIvtIvt(point_code2, "02", null, rawfoilWorkOrder); |
|
|
} |
|
|
} |
|
|
//起点是冷却区 取空放空
|
|
|
//起点是冷却区 取空放空
|
|
|
if ("010103".equals(jsonTask.getString("task_type"))) { |
|
|
if ("010103".equals(jsonTask.getString("task_type"))) { |
|
|
//更新生箔机点位库存
|
|
|
//更新生箔机点位库存
|
|
|
updateSbIvt(sbTab, point_code1, null,"02"); |
|
|
updateSbIvt(point_code2, null, "02"); |
|
|
//更新冷却区点位库存
|
|
|
//更新冷却区点位库存
|
|
|
updateIvtIvt(ivtTab, point_code2, null, "01", DateUtil.now(), null, null, null); |
|
|
updateIvtIvt(point_code1, null, "01", rawfoilWorkOrder); |
|
|
} |
|
|
} |
|
|
//起点是生箔机 取空放空
|
|
|
//起点是生箔机 取空放空
|
|
|
if ("010104".equals(jsonTask.getString("task_type"))) { |
|
|
if ("010104".equals(jsonTask.getString("task_type"))) { |
|
|
//更新生箔机点位库存
|
|
|
//更新生箔机点位库存
|
|
|
updateSbIvt(sbTab, point_code1, null,"01"); |
|
|
updateSbIvt(point_code1, null, "01"); |
|
|
//更新冷却区点位库存
|
|
|
//更新冷却区点位库存
|
|
|
updateIvtIvt(ivtTab, point_code2, null, "02", DateUtil.now(), null, null, null); |
|
|
updateIvtIvt(point_code2, null, "02", rawfoilWorkOrder); |
|
|
} |
|
|
} |
|
|
|
|
|
if ("010101".equals(jsonTask.getString("task_type")) || "010102".equals(jsonTask.getString("task_type"))) { |
|
|
//更新母卷工单状态
|
|
|
//更新母卷工单状态
|
|
|
HashMap<String, String> map = new HashMap<>(); |
|
|
HashMap<String, String> map = new HashMap<>(); |
|
|
map.put("status", "40"); |
|
|
rawfoilWorkOrder.setStatus("40"); |
|
|
map.put("origin", "1"); |
|
|
rawfoilWorkOrder.setOrigin("1"); |
|
|
map.put("roll_status", "0"); |
|
|
rawfoilWorkOrder.setRoll_status("0"); |
|
|
map.put("realend_time", DateUtil.now()); |
|
|
rawfoilWorkOrder.setRealend_time(DateUtil.now()); |
|
|
map.put("update_optid", currentUserId + ""); |
|
|
rawfoilWorkOrder.setUpdate_optid(currentUserId); |
|
|
map.put("update_optname", currentUsername); |
|
|
rawfoilWorkOrder.setUpdate_optname(currentUsername); |
|
|
map.put("finish_type", "01"); |
|
|
rawfoilWorkOrder.setFinish_type("01"); |
|
|
map.put("update_time", DateUtil.now()); |
|
|
rawfoilWorkOrder.setUpdate_time(DateUtil.now()); |
|
|
WQLObject.getWQLObject("PDM_BI_RawFoilWorkOrder").update(map, "container_name = '" + jsonTask.getString("material_code") + "'"); |
|
|
rawfoilWorkOrderMapper.updateById(rawfoilWorkOrder); |
|
|
|
|
|
} |
|
|
|
|
|
// 更改任务状态为完成
|
|
|
|
|
|
jsonTask.put("task_status", TaskStatusEnum.FINISHED.getCode()); |
|
|
|
|
|
jsonTask.put("update_optid", SecurityUtils.getCurrentUserId()); |
|
|
|
|
|
jsonTask.put("update_optname", SecurityUtils.getCurrentUsername()); |
|
|
|
|
|
jsonTask.put("update_time", DateUtil.now()); |
|
|
|
|
|
taskTab.update(jsonTask); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void updateSbIvt(WQLObject sbTab, String fullPointCode, |
|
|
private void updateSbIvt(String fullPointCode, |
|
|
String fullStatus, String emptyStatus) { |
|
|
String fullStatus, String emptyStatus) { |
|
|
JSONObject jsonSbIvt; |
|
|
SbPointIvt sbPointIvt; |
|
|
|
|
|
|
|
|
if (fullPointCode.endsWith("M")) { |
|
|
if (fullPointCode.endsWith("M")) { |
|
|
jsonSbIvt = sbTab.query("full_point_code = '" + fullPointCode + "'").uniqueResult(0); |
|
|
sbPointIvt = sbPointIvtMapper.selectOne(new LambdaQueryWrapper<SbPointIvt>() |
|
|
|
|
|
.eq(SbPointIvt::getFull_point_code, fullPointCode)); |
|
|
} else { |
|
|
} else { |
|
|
jsonSbIvt = sbTab.query("empty_point_code = '" + fullPointCode + "'").uniqueResult(0); |
|
|
sbPointIvt = sbPointIvtMapper.selectOne(new LambdaQueryWrapper<SbPointIvt>() |
|
|
|
|
|
.eq(SbPointIvt::getEmpty_point_code, fullPointCode)); |
|
|
} |
|
|
} |
|
|
if (ObjectUtil.isEmpty(jsonSbIvt)) { |
|
|
if (sbPointIvt == null) { |
|
|
throw new BadRequestException("未找到对应的点位: " + fullPointCode); |
|
|
throw new BadRequestException("未找到对应的点位: " + fullPointCode); |
|
|
} |
|
|
} |
|
|
if (fullStatus != null) jsonSbIvt.put("full_point_status", fullStatus); |
|
|
if (fullStatus != null) sbPointIvt.setFull_point_status(fullStatus); |
|
|
if (emptyStatus != null) jsonSbIvt.put("empty_point_status", emptyStatus); |
|
|
if (emptyStatus != null) sbPointIvt.setEmpty_point_status(emptyStatus); |
|
|
sbTab.update(jsonSbIvt); |
|
|
sbPointIvtMapper.updateById(sbPointIvt); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void updateIvtIvt(WQLObject ivtTab, String fullPointCode, |
|
|
private void updateIvtIvt(String fullPointCode, |
|
|
String fullStatus, String emptyStatus, |
|
|
String fullStatus, |
|
|
String instorageTime, String containerName, |
|
|
String emptyStatus, |
|
|
String workorderId, String ivtQty) { |
|
|
RawfoilWorkOrder rawfoilWorkOrder) { |
|
|
JSONObject jsonCoolIvt; |
|
|
CoolPointIvt coolPointIvt; |
|
|
if (fullPointCode.endsWith("M")) { |
|
|
if (fullPointCode.endsWith("M")) { |
|
|
jsonCoolIvt = ivtTab.query("full_point_code = '" + fullPointCode + "'").uniqueResult(0); |
|
|
coolPointIvt = coolPointIvtMapper.selectOne(new LambdaQueryWrapper<CoolPointIvt>() |
|
|
|
|
|
.eq(CoolPointIvt::getFull_point_code, fullPointCode)); |
|
|
} else { |
|
|
} else { |
|
|
jsonCoolIvt = ivtTab.query("empty_point_code = '" + fullPointCode + "'").uniqueResult(0); |
|
|
coolPointIvt = coolPointIvtMapper.selectOne(new LambdaQueryWrapper<CoolPointIvt>() |
|
|
|
|
|
.eq(CoolPointIvt::getEmpty_point_code, fullPointCode)); |
|
|
} |
|
|
} |
|
|
if (ObjectUtil.isEmpty(jsonCoolIvt)) { |
|
|
if (coolPointIvt == null) { |
|
|
throw new BadRequestException("未找到对应的点位: " + fullPointCode); |
|
|
throw new BadRequestException("未找到对应的点位: " + fullPointCode); |
|
|
} |
|
|
} |
|
|
if (fullStatus != null) jsonCoolIvt.put("full_point_status", fullStatus); |
|
|
coolPointIvt.setFull_point_status(fullStatus); |
|
|
if (emptyStatus != null) jsonCoolIvt.put("empty_point_status", emptyStatus); |
|
|
coolPointIvt.setEmpty_point_status(emptyStatus); |
|
|
if (instorageTime != null) jsonCoolIvt.put("instorage_time", instorageTime); |
|
|
if (rawfoilWorkOrder != null) { |
|
|
if (containerName != null) jsonCoolIvt.put("container_name", containerName); |
|
|
coolPointIvt.setInstorage_time(DateUtil.now()); |
|
|
if (workorderId != null) jsonCoolIvt.put("workorder_id", workorderId); |
|
|
coolPointIvt.setContainer_name(rawfoilWorkOrder.getContainer_name()); |
|
|
if (ivtQty != null) jsonCoolIvt.put("ivt_qty", ivtQty); |
|
|
coolPointIvt.setWorkorder_id(String.valueOf(rawfoilWorkOrder.getWorkorder_id())); |
|
|
ivtTab.update(jsonCoolIvt); |
|
|
} |
|
|
|
|
|
coolPointIvtMapper.updateById(coolPointIvt); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|