This commit is contained in:
2022-11-25 18:44:52 +08:00
20 changed files with 682 additions and 201 deletions

View File

@@ -0,0 +1,245 @@
package org.nl.acs.auto.run;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.AcsConfig;
import org.nl.acs.agv.server.NDCAgvService;
import org.nl.acs.device.service.DeviceService;
import org.nl.acs.device_driver.basedriver.agv.ndcone.AgvNdcOneDeviceDriver;
import org.nl.acs.device_driver.basedriver.agv.ndctwo.AgvNdcTwoDefination;
import org.nl.acs.device_driver.basedriver.agv.ndctwo.AgvNdcTwoDeviceDriver;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.instruction.service.dto.Instruction;
import org.nl.acs.instruction.service.impl.InstructionServiceImpl;
import org.nl.acs.opc.Device;
import org.nl.acs.opc.DeviceAppService;
import org.nl.modules.system.service.ParamService;
import org.nl.modules.system.service.impl.ParamServiceImpl;
import org.nl.modules.wql.util.SpringContextHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.Socket;
import java.util.Date;
import static org.nl.acs.agv.server.impl.NDCAgvServiceImpl.Bytes2HexString;
@Slf4j
@Component
public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
Socket s;
String ip = "127.0.0.1";
int port = 1234;
static DataOutputStream dos;
static DataInputStream dis;
private int recordTimeOut = 10000;
private Date recordTime;
String[] ERROR = new String[]{
"货叉尖部传感器触发", "S300传感器触发", "载货状态改变", "急停按钮触发", "触边开关出发", "需要复位",
"停在充电位", "取货失败", "放货失败", "轮子打滑", "没有动作码不能进入站点", "取货时有货", "丢失定位",
"抬叉停止"};
boolean bConnected = true;
boolean isReConnect = false;
@Autowired
AutoRunService autoRunService;
public NDCSocketConnectionAutoRun() {
this.recordTime = new Date((new Date()).getTime() - (long) this.recordTimeOut);
}
public String getCode() {
return NDCSocketConnectionAutoRun.class.getSimpleName();
}
public String getName() {
return "NDC在线连接";
}
public void autoRun() {
try {
System.out.println("OneAgv链接开始");
ParamService paramService = SpringContextHolder.getBean(ParamServiceImpl.class);
InstructionService instructionService = SpringContextHolder.getBean(InstructionServiceImpl.class);
AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class);
NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class);
DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class);
DeviceService deviceService = SpringContextHolder.getBean(DeviceService.class);
ip = paramService.findByCode(AcsConfig.AGVURL).getValue();
port = Integer.parseInt(paramService.findByCode(AcsConfig.AGVPORT).getValue());
byte[] b = new byte[1028];
s = new Socket(ip, port);
System.out.println("Agv链接成功");
dos = new DataOutputStream(s.getOutputStream());
dis = new DataInputStream(s.getInputStream());
while (bConnected) {
int count = dis.read(b);
if (count == -1) {
break;
}
int[] arr = new int[count];
StringBuffer bs = new StringBuffer();
for (int i = 0; i < count; i++) {
int temp = b[i];
if (temp < 0)
temp += 256;
arr[i] = temp;
StringBuffer bs1 = new StringBuffer("0");
bs.append(temp < 16 ? bs1.append(Integer.toHexString(temp)) : Integer.toHexString(temp));
}
System.out.println("收到请求参数:" + bs);
boolean flag = false;
if (arr[8] * 256 + arr[9] == 0x73) {
byte[] data = null;
System.out.println("接收agv上报信息" + bs);
//执行阶段
int phase = arr[16] * 256 + arr[17];
// agv任务号
int index = arr[12] * 256 + arr[13];
//任务号
int ikey = arr[26] * 256 + arr[27];
//站点号
int agvaddr = arr[18] * 256 + arr[19];
//车号
int carno = arr[20];
Instruction inst = null;
if (ikey != 0) {
inst = instructionService.findByCodeFromCache(String.valueOf(ikey));
}
log.info("接收agv上报信息" + bs);
log.info("接收agv上报信息" + "phase--" + phase + " index--" + index + " ikey--" + ikey + " agvaddr--" + agvaddr + " Car--" + carno);
Device device = null;
String device_code = null;
String old_device_code = null;
String emptyNum = null;
if (agvaddr != 0) {
old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr);
if (StrUtil.contains(old_device_code, "-")) {
String[] point = old_device_code.split("-");
device_code = point[0];
} else if (StrUtil.contains(old_device_code, ".")) {
String[] point = old_device_code.split("\\.");
device_code = point[0];
emptyNum = point[1];
} else {
device_code = old_device_code;
}
device = deviceAppService.findDeviceByCode(device_code);
}
AgvNdcTwoDeviceDriver agvNdcTwoDeviceDriver;
//开始任务
if (phase == 0x01) {
if (!ObjectUtil.isEmpty(inst)) {
inst.setInstruction_status("1");
inst.setAgv_jobno(String.valueOf(index));
inst.setSend_status("1");
instructionService.update(inst);
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
}
flag = true;
}
//任务完毕
//无车id及状态
else if (phase == 0x14) {
if (ObjectUtil.isEmpty(inst)) {
log.info("未找到指令号{}对应的指令", ikey);
break;
}
inst.setInstruction_status("2");
instructionService.finish(inst);
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
}
//请求删除任务
//(需要WCS反馈)
else if (phase == 0x30) {
if (ObjectUtil.isEmpty(inst)) {
log.info("未找到指令号{}对应的指令", ikey);
break;
}
data = ndcAgvService.sendAgvTwoModeInst(0x8F, index, 0);
}
//任务删除确认
//(需要WCS反馈)
else if (phase == 0xFF) {
if (ObjectUtil.isEmpty(inst)) {
log.info("未找到指令号{}对应的指令", ikey);
break;
}
instructionService.cancel(inst.getInstruction_id());
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
} else {
//上报异常信息
//不需要WCS反馈
if(phase == 0x67){
device = deviceAppService.findDeviceByCode(Integer.toString(arr[27]));
} else {
device = deviceAppService.findDeviceByCode(Integer.toString(arr[20]));
}
if (device.getDeviceDriver() instanceof AgvNdcTwoDeviceDriver) {
agvNdcTwoDeviceDriver = (AgvNdcTwoDeviceDriver) device.getDeviceDriver();
agvNdcTwoDeviceDriver.processSocket(arr);
}
}
if (!ObjectUtil.isEmpty(data)) {
write(data);
}
} else {
System.out.println("agv上报不是0073类型动作不处理");
}
}
} catch (Exception e) {
} finally {
}
}
@Override
public void stop() {
super.after();
try {
s.close();
} catch (Exception e) {
e.printStackTrace();
}
}
public static void write(byte[] b) {
try {
log.info("下发agv数据:" + Bytes2HexString(b));
System.out.println("下发agv数据:" + Bytes2HexString(b));
dos.write(b);
dos.flush();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

View File

@@ -79,7 +79,6 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
try { try {
byte[] b = new byte[1024]; byte[] b = new byte[1024];
s = new Socket(ip, port); s = new Socket(ip, port);
dos = new DataOutputStream(s.getOutputStream()); dos = new DataOutputStream(s.getOutputStream());
@@ -150,9 +149,10 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
instructionService.update(inst); instructionService.update(inst);
} }
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
}
//任务完毕
} else if (phase == 0x0A) { //无车id及状态
else if (phase == 0x0A) {
for (Instruction inst : insts) { for (Instruction inst : insts) {
if (!ObjectUtil.isEmpty(inst)) { if (!ObjectUtil.isEmpty(inst)) {
@@ -161,10 +161,16 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
} }
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
} else if(phase == 0x30){ }
data = NDCAgvService.sendAgvOneModeInst(143, index, 0); //请求删除任务
//(需要WCS反馈)
else if(phase == 0x30){
data = NDCAgvService.sendAgvOneModeInst(0x8F, index, 0);
} else if(phase == 0xFF) { }
//任务删除确认
//(需要WCS反馈)
else if(phase == 0xFF) {
for (Instruction inst : insts) { for (Instruction inst : insts) {
if (!ObjectUtil.isEmpty(inst)) { if (!ObjectUtil.isEmpty(inst)) {
@@ -173,15 +179,9 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
} }
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
}else if(phase == 0x50){//离开区域
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
}else if(phase == 0x51){//离开区域
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
} else { } else {
//上报异常信息
//不需要WCS反馈
if(phase == 0x67){ if(phase == 0x67){
device = deviceAppService.findDeviceByCode(Integer.toString(arr[27])); device = deviceAppService.findDeviceByCode(Integer.toString(arr[27]));
} else { } else {
@@ -197,7 +197,7 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
} }
} else { } else {
// System.out.println("agv上报不是0073类型动作不处理"); System.out.println("agv上报不是0073类型动作不处理");
} }
} }

View File

@@ -25,7 +25,6 @@ import org.nl.acs.opc.DeviceAppService;
import org.nl.modules.system.service.ParamService; import org.nl.modules.system.service.ParamService;
import org.nl.modules.system.service.impl.ParamServiceImpl; import org.nl.modules.system.service.impl.ParamServiceImpl;
import org.nl.modules.wql.util.SpringContextHolder; import org.nl.modules.wql.util.SpringContextHolder;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List; import java.util.List;
@@ -109,7 +108,8 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
//货架 //货架
StandardStorageDeviceDriver standardStorageDeviceDriver; StandardStorageDeviceDriver standardStorageDeviceDriver;
//开始任务/上报订单号 //分配 车id
//(不需要WCS反馈)
if (phase == 0x02) { if (phase == 0x02) {
for (Instruction inst : insts) { for (Instruction inst : insts) {
inst.setCarno(String.valueOf(carno)); inst.setCarno(String.valueOf(carno));
@@ -117,7 +117,8 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
} }
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase" + "反馈:" + data); logServer.deviceExecuteLog(this.device_code, "", "", "agvphase" + "反馈:" + data);
//请求取货 //到达取货
//(需要WCS反馈)
} else if (phase == 0x03) { } else if (phase == 0x03) {
if (agvaddr == 0) { if (agvaddr == 0) {
agvaddr = agvaddr_copy; agvaddr = agvaddr_copy;
@@ -167,34 +168,8 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
} }
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
} }
} else if (phase == 0x65) {//param,重量待定
//1、得到重量信息
int weight = (arr[18] * 256 + arr[19]) * 10;
for (Instruction inst : insts) {
//校验agv上报站点编号与指令起始点相同
if (ObjectUtil.isEmpty(inst)) {
log.info("未找到关联编号{}对应的指令", ikey);
break;
}
// 4010 待处理
if (StrUtil.equals(inst.getStart_device_code(), device_code)) {
inst.setWeight(String.valueOf(weight));
}
}
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
//取货完毕/取满框完毕1/点对点取货完毕
} else if (phase == 0x64) {//param,agv货位id待定
//1、根据货位id找到对应三工位设备赋给agv属性地址对应的满料位设备
agvaddr = arr[18] * 256 + arr[19];
agvaddr_copy = agvaddr;
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
//取货完毕 //取货完毕
//(需要WCS反馈)
} else if (phase == 0x05) { } else if (phase == 0x05) {
if (agvaddr == 0) { if (agvaddr == 0) {
agvaddr = agvaddr_copy; agvaddr = agvaddr_copy;
@@ -248,7 +223,8 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
} }
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
//请求放货 //到达放货
//(需要WCS反馈)
} else if (phase == 0x07) { } else if (phase == 0x07) {
if (agvaddr == 0) { if (agvaddr == 0) {
agvaddr = agvaddr_copy; agvaddr = agvaddr_copy;
@@ -298,7 +274,8 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
} }
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
//放货完 //放货完
//(需要WCS反馈)
} else if (phase == 0x09) { } else if (phase == 0x09) {
if (agvaddr == 0) { if (agvaddr == 0) {
agvaddr = agvaddr_copy; agvaddr = agvaddr_copy;
@@ -348,36 +325,21 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
} }
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
} else if (phase == 0x71) { }
x = ikey; //到达位置点
if (x != last_x) { //(需要WCS反馈)
logServer.deviceExecuteLog(this.device_code,"", "x", String.valueOf(x)); else if (phase == 0x64) {//param,agv货位id待定
} //1、根据货位id找到对应三工位设备赋给agv属性地址对应的满料位设备
} else if (phase == 0x72) { agvaddr = arr[18] * 256 + arr[19];
y = ikey; agvaddr_copy = agvaddr;
if (y != last_y) { data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
logServer.deviceExecuteLog(this.device_code, "","y", String.valueOf(y)); logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
} }else if(phase == 0x50){//进入交通灯区域
} else if (phase == 0x73) { data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
angle = last_angle; logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
if (angle != last_angle) { }else if(phase == 0x51){//离开交通灯区域
logServer.deviceExecuteLog(this.device_code, "","angle", String.valueOf(angle)); data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
} logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
} else if (phase == 0x74) {
electric_qty = ikey;
if (electric_qty != last_electric_qty) {
logServer.deviceExecuteLog(this.device_code, "","electric_qty", String.valueOf(electric_qty));
}
} else if (phase == 0x75) {
status = ikey;
if (status != last_status) {
logServer.deviceExecuteLog(this.device_code, "","status", String.valueOf(status));
}
} else if (phase == 0x76) {
error = ikey;
if (error != last_error) {
logServer.deviceExecuteLog(this.device_code, "","error", String.valueOf(error));
}
} }
if (!ObjectUtil.isEmpty(data)) { if (!ObjectUtil.isEmpty(data)) {
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);

View File

@@ -6,7 +6,7 @@ import lombok.Data;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.nl.acs.agv.server.NDCAgvService; import org.nl.acs.agv.server.NDCAgvService;
import org.nl.acs.auto.run.TwoNDCSocketConnectionAutoRun; import org.nl.acs.auto.run.NDCSocketConnectionAutoRun;
import org.nl.acs.device.service.DeviceService; import org.nl.acs.device.service.DeviceService;
import org.nl.acs.device_driver.DeviceDriver; import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.basedriver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver; import org.nl.acs.device_driver.basedriver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
@@ -25,10 +25,9 @@ import org.nl.acs.opc.DeviceAppService;
import org.nl.modules.system.service.ParamService; import org.nl.modules.system.service.ParamService;
import org.nl.modules.wql.util.SpringContextHolder; import org.nl.modules.wql.util.SpringContextHolder;
import java.util.List;
/** /**
* NDC工位AGV * NDC工位AGV
*/ */
@Slf4j @Slf4j
@Data @Data
@@ -38,29 +37,17 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
ParamService ParamService = SpringContextHolder.getBean(ParamService.class); ParamService ParamService = SpringContextHolder.getBean(ParamService.class);
InstructionService instructionService = SpringContextHolder.getBean(InstructionServiceImpl.class); InstructionService instructionService = SpringContextHolder.getBean(InstructionServiceImpl.class);
AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class); AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class);
NDCAgvService NDCAgvService = SpringContextHolder.getBean(NDCAgvService.class); NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class);
DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class); DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class);
DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class); DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class);
DeviceService deviceService = SpringContextHolder.getBean(DeviceService.class); DeviceService deviceService = SpringContextHolder.getBean(DeviceService.class);
int agvaddr = 0; int agvaddr = 0;
int agvaddr_copy = 0; int agvaddr_copy = 0;
int weight = 0; int weight = 0;
int agv_power = 0;
String device_code = ""; String device_code = "";
int phase = 0; int phase = 0;
int region = 0;
int x = 0; //x坐标
int y = 0; //y坐标
int angle = 0; //角度
int electric_qty = 0; //电量
int status = 0; //三色灯状态
int error = 0; //车辆故障
int last_x = 0;
int last_y = 0;
int last_angle = 0;
int last_electric_qty = 0;
int last_status = 0;
int last_error = 0;
@LokiLog(type = LokiLogType.ACA_TO_LMS) @LokiLog(type = LokiLogType.ACA_TO_LMS)
public synchronized void processSocket(int[] arr) throws Exception { public synchronized void processSocket(int[] arr) throws Exception {
@@ -105,87 +92,172 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
} }
device = deviceAppService.findDeviceByCode(device_code); device = deviceAppService.findDeviceByCode(device_code);
if (phase == 0x67) {
//故障信息
if (arr[18] * 256 + arr[19] == 0) {
}
data = NDCAgvService.sendAgvTwoModeInst(phase, index, 0);
}
//普通站点 //普通站点
StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver;
//货架 //货架
StandardStorageDeviceDriver standardStorageDeviceDriver; StandardStorageDeviceDriver standardStorageDeviceDriver;
//开始任务/上报订单号
if (phase == 0x02) { if (phase == 0x02) {
if (ObjectUtil.isEmpty(inst)) {
log.info("未找到指令号{}对应的指令", ikey);
return;
}
inst.setCarno(String.valueOf(carno)); inst.setCarno(String.valueOf(carno));
instructionService.update(inst); instructionService.update(inst);
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase" + "反馈:" + data); logServer.deviceExecuteLog(this.device_code, "", "", "agvphase" + "反馈:" + data);
}
//请求取货 //到达取货
} else if (phase == 0x03) { //(Itype=1/2/3,需要WCS反馈Phase)
//判断普通站点驱动是否开启等待 else if (phase == 0x03) {
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { if (ObjectUtil.isEmpty(inst)) {
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); log.info("未找到指令号{}对应的指令", ikey);
if(StrUtil.equals("true",this.getDevice().getExtraValue().get("max_emptypalletnum").toString())){ return;
if(standardOrdinarySiteDeviceDriver.getStatus() == 1){ }
data = NDCAgvService.sendAgvTwoModeInst(phase, index, 0); data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
} else { }
logServer.deviceExecuteLog(this.device_code, "", "", "上位系统未允许取货"); // 取货完毕
} //(Itype=1/2/3,需要WCS反馈Phase)
} else { else if (phase == 0x05) {
data = NDCAgvService.sendAgvTwoModeInst(phase, index, 0); if (ObjectUtil.isEmpty(inst)) {
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); log.info("未找到指令号{}对应的指令", ikey);
} return;
}
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
}
//到达取货点(Itype=1、3需要WCS反馈)
else if (phase == 0x08) {
if (ObjectUtil.isEmpty(inst)) {
log.info("未找到指令号{}对应的指令", ikey);
return;
}
String instruction_type = inst.getInstruction_type();
if (StrUtil.equals(instruction_type, "1") || StrUtil.equals(instruction_type, "3")) {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
}
}
// 取货完毕
//(Itype=1、3,需要WCS反馈)
else if (phase == 0x0A) {
if (ObjectUtil.isEmpty(inst)) {
log.info("未找到指令号{}对应的指令", ikey);
return;
}
String instruction_type = inst.getInstruction_type();
if (StrUtil.equals(instruction_type, "1") || StrUtil.equals(instruction_type, "3")) {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
} }
}
} else if (phase == 0x65) {//param,重量待定 //Itype=1,上传称重数据)
//1、得到重量信息 else if (phase == 0x64) {
int weight = (arr[18] * 256 + arr[19]) * 10; if (ObjectUtil.isEmpty(inst)) {
log.info("未找到指令号{}对应的指令", ikey);
data = NDCAgvService.sendAgvTwoModeInst(phase, index, 0); return;
}
String instruction_type = inst.getInstruction_type();
//上传称重数据
if (StrUtil.equals(instruction_type, "1")) {
weight = arr[18] * 256 + arr[19];
inst.setWeight(String.valueOf(weight));
instructionService.update(inst);
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
}
}
// 到达放货点
//Itype=1/2/3,需要WCS反馈
else if (phase == 0x0C) {
if (ObjectUtil.isEmpty(inst)) {
log.info("未找到指令号{}对应的指令", ikey);
return;
}
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
}
//放货完成
//(Itype=1/2/3,需要WCS反馈)
else if (phase == 0x0E) {
if (ObjectUtil.isEmpty(inst)) {
log.info("未找到指令号{}对应的指令", ikey);
return;
}
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
}
//到达放货点
//Itype=1、3,需要WCS反馈
else if (phase == 0x10) {
if (ObjectUtil.isEmpty(inst)) {
log.info("未找到指令号{}对应的指令", ikey);
return;
}
String instruction_type = inst.getInstruction_type();
if (StrUtil.equals(instruction_type, "1") || StrUtil.equals(instruction_type, "3")) {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
}
}
//放货完成
//Itype=1、3,需要WCS反馈
else if (phase == 0x12) {
if (ObjectUtil.isEmpty(inst)) {
log.info("未找到指令号{}对应的指令", ikey);
return;
}
String instruction_type = inst.getInstruction_type();
if (StrUtil.equals(instruction_type, "1") || StrUtil.equals(instruction_type, "3")) {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
}
}
//上传AGV电量
else if (phase == 0x73) {
if (ObjectUtil.isEmpty(inst)) {
log.info("未找到指令号{}对应的指令", ikey);
return;
}
agv_power = ikey;
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
} //进入区域phase值
else if (phase == 0x50) {
if (ObjectUtil.isEmpty(inst)) {
log.info("未找到指令号{}对应的指令", ikey);
return;
}
region = arr[18] * 256 + arr[19];
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
} else if (phase == 0x64) {//param,agv货位id待定 }
//离开区域phase值
//取货完毕 else if (phase == 0x51) {
} else if (phase == 0x05) { if (ObjectUtil.isEmpty(inst)) {
log.info("未找到指令号{}对应的指令", ikey);
return;
} else if (phase == 0x07) { }
region = arr[18] * 256 + arr[19];
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
} else if (phase == 0x09) { logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
} else if (phase == 0x71) {
} else if (phase == 0x72) {
} else if (phase == 0x73) {
} else if (phase == 0x74) {
} else if (phase == 0x75) {
} else if (phase == 0x76) {
}
//上报异常信息
//不需要WCS反馈
else if (phase == 0x67) {
//故障信息
if (arr[18] * 256 + arr[19] == 0) {
}
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
} }
if (!ObjectUtil.isEmpty(data)) { if (!ObjectUtil.isEmpty(data)) {
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
TwoNDCSocketConnectionAutoRun.write(data); NDCSocketConnectionAutoRun.write(data);
} }
} }

View File

@@ -108,6 +108,14 @@ public class InstructionController {
return new ResponseEntity<>(HttpStatus.OK); return new ResponseEntity<>(HttpStatus.OK);
} }
@Log("强制取消指令")
@ApiOperation("强制取消指令")
@PostMapping(value = "/forceCancel/{id}")
public ResponseEntity<Object> forceCancel(@RequestBody String id) throws Exception {
instructionService.forceCancel(id);
return new ResponseEntity<>(HttpStatus.OK);
}
@Log("导出指令") @Log("导出指令")
@ApiOperation("导出指令") @ApiOperation("导出指令")
@GetMapping(value = "/download") @GetMapping(value = "/download")

View File

@@ -164,6 +164,13 @@ public interface InstructionService {
*/ */
void cancel(String id) throws Exception; void cancel(String id) throws Exception;
/**
* 取消指令
*
* @param id
*/
void forceCancel(String id) throws Exception;
/** /**
* 取消指令不下发agv * 取消指令不下发agv
* *

View File

@@ -833,6 +833,60 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
} }
} }
@Override
public void forceCancel(String id) throws Exception {
//flag= true时取消指令
boolean flag = false;
Instruction entity = this.findById(id);
if (entity == null) {
throw new BadRequestException("被删除或无权限,操作失败!");
}
TaskDto task = taskService.findByCodeFromCache(entity.getTask_code());
if (StrUtil.isEmpty(entity.getRoute_plan_code())) {
entity.setRoute_plan_code(task.getRoute_plan_code());
}
String currentUsername = SecurityUtils.getCurrentUsername();
String now = DateUtil.now();
entity.setUpdate_time(now);
entity.setUpdate_by(currentUsername);
entity.setInstruction_status("3");
WQLObject wo = WQLObject.getWQLObject("acs_instruction");
JSONObject json = (JSONObject) JSONObject.toJSON(entity);
wo.update(json);
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class);
// 如果是无光电的设备 指令完成变更起点、终点状态
JSONObject jo = new JSONObject();
jo.put("device_code", entity.getStart_device_code());
if (StrUtil.equals(entity.getMaterial(), "1")) {
jo.put("hasGoodStatus", "1");
} else if (!StrUtil.equals(entity.getMaterial(), "1") && !StrUtil.isEmpty(entity.getMaterial())) {
jo.put("hasGoodStatus", "2");
} else {
jo.put("hasGoodStatus", "0");
}
jo.put("material_type", entity.getMaterial());
jo.put("batch", entity.getBatch());
jo.put("islock", "false");
deviceService.changeDeviceStatus(jo);
JSONObject jo1 = new JSONObject();
jo1.put("device_code", entity.getNext_device_code());
jo.put("hasGoodStatus", "0");
jo.put("material_type", "");
jo.put("batch", "");
jo1.put("islock", "false");
deviceService.changeDeviceStatus(jo1);
String instnextdevice = entity.getNext_device_code();
Device device = appService.findDeviceByCode(instnextdevice);
if (device == null) {
log.debug("地址对应设备未找到");
return;
}
removeByCodeFromCache(entity.getInstruction_code());
}
@Override @Override
public void cancelNOSendAgv(String id) throws Exception { public void cancelNOSendAgv(String id) throws Exception {

View File

@@ -40,6 +40,14 @@ export function cancel(instruction_id) {
}) })
} }
export function forceCancel(instruction_id) {
return request({
url: 'api/instruction/forceCancel/' + instruction_id,
method: 'post',
data: instruction_id
})
}
export function queryUnFinish() { export function queryUnFinish() {
return request({ return request({
url: 'api/instruction/unfinish/', url: 'api/instruction/unfinish/',
@@ -62,4 +70,4 @@ export function reload() {
}) })
} }
export default { add, edit, del, finish, cancel, queryUnFinish, queryByTaskId, reload } export default { add, edit, del, finish, cancel, forceCancel, queryUnFinish, queryByTaskId, reload }

View File

@@ -160,6 +160,7 @@
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item :command="beforeHandleCommand(scope.$index, scope.row,'a')">完成</el-dropdown-item> <el-dropdown-item :command="beforeHandleCommand(scope.$index, scope.row,'a')">完成</el-dropdown-item>
<el-dropdown-item :command="beforeHandleCommand(scope.$index, scope.row,'b')">取消</el-dropdown-item> <el-dropdown-item :command="beforeHandleCommand(scope.$index, scope.row,'b')">取消</el-dropdown-item>
<el-dropdown-item :command="beforeHandleCommand(scope.$index, scope.row,'c')">强制取消</el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
</template> </template>
@@ -290,6 +291,14 @@ export default {
console.log(err.response.data.message) console.log(err.response.data.message)
}) })
}, },
forceCancel(index, row) {
crudInstruction.forceCancel(row.instruction_id).then(res => {
this.crud.toQuery()
this.crud.notify('强制取消成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
}).catch(err => {
console.log(err.response.data.message)
})
},
reload() { reload() {
crudInstruction.reload().then(res => { crudInstruction.reload().then(res => {
this.crud.toQuery() this.crud.toQuery()
@@ -313,6 +322,9 @@ export default {
case 'b':// 取消 case 'b':// 取消
this.cancel(command.index, command.row) this.cancel(command.index, command.row)
break break
case 'c':// 强制取消
this.forceCancel(command.index, command.row)
break
} }
} }

View File

@@ -189,4 +189,9 @@ public class CustomerbaseDto implements Serializable {
* 送货单打印模板号 * 送货单打印模板号
*/ */
private String shd_print_no; private String shd_print_no;
/**
* 送货单明细数
*/
private String shd_dtl_num;
} }

View File

@@ -68,7 +68,7 @@
IF 输入.flag = "2" IF 输入.flag = "2"
QUERY QUERY
SELECT SELECT
cust_code AS value, cust_name AS value,
cust_name AS label cust_name AS label
FROM FROM
MD_CS_TransportationBase MD_CS_TransportationBase

View File

@@ -695,6 +695,9 @@ public class MesToLmsServiceImpl implements MesToLmsService {
String Description = param.getString("Description"); // 来源卷位置 String Description = param.getString("Description"); // 来源卷位置
String DateOfFGInbound = param.getString("DateOfFGInbound"); // 来源卷位置 String DateOfFGInbound = param.getString("DateOfFGInbound"); // 来源卷位置
String box_type = param.getString("Attribute1"); // 木箱料号 String box_type = param.getString("Attribute1"); // 木箱料号
String box_length = param.getString("Attribute2"); // 木箱料号
String box_width = param.getString("Attribute3"); // 木箱料号
String box_high = param.getString("Attribute4"); // 木箱料号
JSONArray details = param.getJSONArray("details"); JSONArray details = param.getJSONArray("details");
@@ -723,6 +726,9 @@ public class MesToLmsServiceImpl implements MesToLmsService {
jo.put("package_box_sn", PackageBoxSN); jo.put("package_box_sn", PackageBoxSN);
jo.put("sap_pcsn", sap_pcsn); jo.put("sap_pcsn", sap_pcsn);
jo.put("box_type", box_type); jo.put("box_type", box_type);
jo.put("box_length", box_length);
jo.put("box_width", box_width);
jo.put("box_high", box_high);
jo.put("quanlity_in_box", QuanlityInBox); jo.put("quanlity_in_box", QuanlityInBox);
jo.put("box_weight", BoxWeight); jo.put("box_weight", BoxWeight);
jo.put("quality_guaran_period", QualityGuaranPeriod); jo.put("quality_guaran_period", QualityGuaranPeriod);

View File

@@ -176,4 +176,10 @@ public interface CheckOutBillService {
* @param whereJson / * @param whereJson /
*/ */
void downloadExcel(HttpServletResponse response, Map whereJson) throws IOException; void downloadExcel(HttpServletResponse response, Map whereJson) throws IOException;
/**
* 获取分配明细条数
* @param whereJson /
*/
JSONObject getDisNum(Map whereJson);
} }

View File

@@ -211,4 +211,11 @@ public class CheckOutBillController {
checkOutBillService.downloadExcel(response,whereJson); checkOutBillService.downloadExcel(response,whereJson);
return new ResponseEntity<>(HttpStatus.OK); return new ResponseEntity<>(HttpStatus.OK);
} }
@PostMapping("/getDisNum")
@Log("获取分配明细条数")
@ApiOperation("获取分配明细条数")
public ResponseEntity<Object> getDisNum(@RequestBody Map whereJson) {
return new ResponseEntity<>(checkOutBillService.getDisNum(whereJson),HttpStatus.OK);
}
} }

View File

@@ -2132,11 +2132,13 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
WQLObject custTab = WQLObject.getWQLObject("MD_CS_CustomerBase"); // 客户基本信息表 WQLObject custTab = WQLObject.getWQLObject("MD_CS_CustomerBase"); // 客户基本信息表
WQLObject mstTab = WQLObject.getWQLObject("ST_IVT_IOStorInv"); // 出入库主表 WQLObject mstTab = WQLObject.getWQLObject("ST_IVT_IOStorInv"); // 出入库主表
WQLObject subTab = WQLObject.getWQLObject("pdm_bi_subpackagerelation"); // 子卷包装关系表
JSONObject jsonMst = mstTab.query("iostorinv_id = '" + MapUtil.getStr(whereJson, "iostorinv_id") + "'").uniqueResult(0); JSONObject jsonMst = mstTab.query("iostorinv_id = '" + MapUtil.getStr(whereJson, "iostorinv_id") + "'").uniqueResult(0);
String cust_code = jsonMst.getString("cust_code"); String cust_code = jsonMst.getString("cust_code");
JSONObject jsonCust = custTab.query("cust_code = '" + cust_code + "'").uniqueResult(0); JSONObject jsonCust = custTab.query("cust_code = '" + cust_code + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(jsonCust)) throw new BadRequestException("客户不存在");
int j = Integer.parseInt((String) whereJson.get("j")); int j = Integer.parseInt((String) whereJson.get("j"));
//1.根据出入库主表中 收货单位 查询客户表中的模板路径 //1.根据出入库主表中 收货单位 查询客户表中的模板路径
@@ -2149,41 +2151,57 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
// WriteSheet sheet = EasyExcel.writerSheet().build(); // WriteSheet sheet = EasyExcel.writerSheet().build();
// 5.单组填充 // 5.单组填充
HashMap<String, Object> oneMap = new HashMap<>(); HashMap<String, Object> oneMap = new HashMap<>();
oneMap.put("vbeln", ""); oneMap.put("bill_code", jsonMst.getString("bill_code")); // 出库单号
oneMap.put("consignee", jsonMst.getString("consignee")); oneMap.put("create_date", DateUtil.today()); // 出库日期
oneMap.put("receiver", jsonMst.getString("receiver")); oneMap.put("consignee", jsonMst.getString("consignee")); // 客户
oneMap.put("receiptaddress", jsonMst.getString("receiptaddress")); oneMap.put("receiptaddress", jsonMst.getString("receiptaddress")); // 客户地址
oneMap.put("receiptphone", jsonMst.getString("receiptphone")); oneMap.put("trans_code", jsonMst.getString("trans_code")); // 承运公司
oneMap.put("logisticscompany", jsonMst.getString("logisticscompany")); oneMap.put("receiptaddress2", jsonMst.getString("receiptaddress")); // 收货地址
oneMap.put("drivername", jsonMst.getString("drivername")); oneMap.put("receiptphone", jsonMst.getString("receiver") +"/"+jsonMst.getString("receiptphone")); // 客户电话
oneMap.put("carno", jsonMst.getString("carno")); oneMap.put("deliveryphone", jsonMst.getString("deliveryname") +"/"+jsonMst.getString("deliveryphone") ); // 承运人电话
oneMap.put("driverphone", jsonMst.getString("driverphone")); // 总箱数
oneMap.put("contractno", jsonMst.getString("contractno")); /* JSONArray jsonAllBox = WQL.getWO("ST_OUTIVT02").addParam("flag", "4").addParam("iostorinv_id", MapUtil.getStr(whereJson, "iostorinv_id")).process().getResultJSONArray(0);
oneMap.put("all_box", ""); oneMap.put("all_box", jsonAllBox.size());
oneMap.put("all_qty", ""); oneMap.put("all_qty", "");
oneMap.put("deliveryaddress", jsonMst.getString("deliveryaddress")); oneMap.put("deliveryaddress", jsonMst.getString("deliveryaddress"));
oneMap.put("deliveryname", jsonMst.getString("deliveryname")); oneMap.put("deliveryname", jsonMst.getString("deliveryname"));
oneMap.put("deliveryphone", jsonMst.getString("deliveryphone")); oneMap.put("deliveryphone", jsonMst.getString("deliveryphone"));*/
// 6.多组填充 // 6.多组填充
JSONArray dtlArr = WQL.getWO("ST_OUTIVT02").addParam("flag", "3").addParam("iostorinv_id", MapUtil.getStr(whereJson, "iostorinv_id")).process().getResultJSONArray(0); JSONArray dtlArr = WQL.getWO("ST_OUTIVT02").addParam("flag", "3").addParam("iostorinv_id", MapUtil.getStr(whereJson, "iostorinv_id")).process().getResultJSONArray(0);
int shd_dtl_num = jsonCust.getIntValue("shd_dtl_num"); // 送货单明细数 int shd_dtl_num = jsonCust.getIntValue("shd_dtl_num"); // 送货单明细数
if (shd_dtl_num > dtlArr.size()) { if (shd_dtl_num > dtlArr.size()) {
double all_qty = 0;
ArrayList<HashMap<String, Object>> flData = new ArrayList<>(); ArrayList<HashMap<String, Object>> flData = new ArrayList<>();
WriteSheet sheet = EasyExcel.writerSheet().build(); WriteSheet sheet = EasyExcel.writerSheet().build();
for (int i = 0; i < dtlArr.size(); i++) { for (int i = 0; i < dtlArr.size(); i++) {
JSONObject json = dtlArr.getJSONObject(i); JSONObject json = dtlArr.getJSONObject(i);
HashMap<String, Object> mapFL = new HashMap<>(); JSONObject jsonSub = subTab.query("package_box_sn = '" + json.getString("box_no") + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(jsonSub)) throw new BadRequestException("没有查询到子卷包装");
mapFL.put("index", i + 1); // 规格: 厚度*幅宽
mapFL.put("source_bill_code", json.getString("source_bill_code")); String material_spec = jsonSub.getString("thickness") + "*" + jsonSub.getString("width");
// 箱号
String box_no = json.getString("box_no");
String sub_box_no = "";
if (ObjectUtil.isNotEmpty(box_no)) {
sub_box_no = box_no.substring(box_no.lastIndexOf("@")+1, box_no.length());
}
HashMap<String, Object> mapFL = new HashMap<>();
// 明细
String date_of_production = jsonSub.getString("date_of_production").replaceAll("[[\\s-:punct:]]", "");
mapFL.put("date_of_production", date_of_production); // 批号 : 子卷包装生产日期
mapFL.put("material_name", json.getString("material_name")); mapFL.put("material_name", json.getString("material_name"));
mapFL.put("material_spec", json.getString("material_spec")); mapFL.put("material_spec", material_spec);
mapFL.put("qty", json.getString("real_qty")); mapFL.put("qty_unit_name", "KG");
mapFL.put("remark", json.getString("remark")); mapFL.put("box_no", sub_box_no);
mapFL.put("qty", NumberUtil.round(json.getString("qty"), 2).doubleValue());
flData.add(mapFL); flData.add(mapFL);
all_qty = NumberUtil.add(String.valueOf(all_qty), json.getString("qty")).doubleValue();
} }
oneMap.put("all_qty",all_qty);
workBook.fill(oneMap, sheet); workBook.fill(oneMap, sheet);
workBook.fill(new FillWrapper("data", flData), sheet); workBook.fill(new FillWrapper("data", flData), sheet);
workBook.finish(); workBook.finish();
@@ -2192,22 +2210,42 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
double ceil = Math.ceil(div); double ceil = Math.ceil(div);
Integer integer = Integer.valueOf(String.valueOf(NumberUtil.round(ceil, 0))); Integer integer = Integer.valueOf(String.valueOf(NumberUtil.round(ceil, 0)));
double all_qty = 0;
ArrayList<HashMap<String, Object>> flData = new ArrayList<>(); ArrayList<HashMap<String, Object>> flData = new ArrayList<>();
for (int i = j * shd_dtl_num; i < (j + 1) * shd_dtl_num; i++) { for (int i = j * shd_dtl_num; i < (j + 1) * shd_dtl_num; i++) {
if (i == dtlArr.size()) { if (i == dtlArr.size()) {
break; break;
} }
JSONObject json = dtlArr.getJSONObject(i); JSONObject json = dtlArr.getJSONObject(i);
JSONObject jsonSub = subTab.query("package_box_sn = '" + json.getString("box_no") + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(jsonSub)) throw new BadRequestException("没有查询到子卷包装");
// 规格: 厚度*幅宽
String material_spec = jsonSub.getString("thickness") + "*" + jsonSub.getString("width");
// 箱号
String box_no = json.getString("box_no");
String sub_box_no = "";
if (ObjectUtil.isNotEmpty(box_no)) {
sub_box_no = box_no.substring(box_no.lastIndexOf("@")+1, box_no.length());
}
HashMap<String, Object> mapFL = new HashMap<>(); HashMap<String, Object> mapFL = new HashMap<>();
mapFL.put("index", i + 1); // 明细
mapFL.put("source_bill_code", json.getString("source_bill_code")); String date_of_production = jsonSub.getString("date_of_production").replaceAll("[[\\s-:punct:]]", "");
mapFL.put("date_of_production", date_of_production); // 批号 : 子卷包装生产日期
mapFL.put("material_name", json.getString("material_name")); mapFL.put("material_name", json.getString("material_name"));
mapFL.put("material_spec", json.getString("material_spec")); mapFL.put("material_spec", material_spec);
mapFL.put("qty", json.getString("real_qty")); mapFL.put("qty_unit_name", "KG");
mapFL.put("remark", json.getString("remark")); mapFL.put("box_no", sub_box_no);
mapFL.put("qty", NumberUtil.round(json.getString("qty"), 2).doubleValue());
flData.add(mapFL); flData.add(mapFL);
// 计算合计重量
all_qty = NumberUtil.add(String.valueOf(all_qty), json.getString("qty")).doubleValue();
} }
oneMap.put("all_qty",all_qty);
WriteSheet sheet = EasyExcel.writerSheet(0).build(); WriteSheet sheet = EasyExcel.writerSheet(0).build();
workBook.fill(oneMap, sheet); workBook.fill(oneMap, sheet);
workBook.fill(new FillWrapper("data", flData), sheet); workBook.fill(new FillWrapper("data", flData), sheet);
@@ -2215,6 +2253,15 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
} }
} }
@Override
public JSONObject getDisNum(Map whereJson) {
JSONArray dtlArr = WQL.getWO("ST_OUTIVT02").addParam("flag", "3").addParam("iostorinv_id", MapUtil.getStr(whereJson, "iostorinv_id")).process().getResultJSONArray(0);
JSONObject json = new JSONObject();
json.put("num", dtlArr.size());
return json;
}
/** /**
* 更新主表状态 * 更新主表状态
* *

View File

@@ -84,20 +84,40 @@
IF 输入.flag = "3" IF 输入.flag = "3"
QUERY QUERY
SELECT SELECT
dtl.*, SUM(dis.real_qty) AS qty,
mater.material_code, dis.box_no,
mater.material_name, MAX(mater.material_name) AS material_name
mater.material_spec
FROM FROM
ST_IVT_IOStorInvDtl dtl ST_IVT_IOStorInvDis dis
LEFT JOIN md_me_materialbase mater ON mater.material_id = dtl.material_id LEFT JOIN md_me_materialbase mater ON mater.material_id = dis.material_id
WHERE WHERE
1 = 1 1 = 1
OPTION 输入.iostorinv_id <> "" OPTION 输入.iostorinv_id <> ""
dtl.iostorinv_id = 输入.iostorinv_id dis.iostorinv_id = 输入.iostorinv_id
ENDOPTION ENDOPTION
group by dis.box_no
ENDSELECT
ENDQUERY
ENDIF
IF 输入.flag = "4"
QUERY
SELECT
count(*) AS num
FROM
ST_IVT_IOStorInvDis dis
WHERE
1 = 1
OPTION 输入.iostorinv_id <> ""
dis.iostorinv_id = 输入.iostorinv_id
ENDOPTION
group by dis.struct_id
ENDSELECT ENDSELECT
ENDQUERY ENDQUERY
ENDIF ENDIF

View File

@@ -92,6 +92,18 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row :gutter="20">
<el-col :span="8">
<el-form-item label="送货单打印模板路径">
<el-input v-model="form.shd_print_no" style="width: 200px;" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="送货单明细数">
<el-input-number v-model="form.shd_dtl_num" :min="1" :max="100" :precision="0" :controls="false" style="width: 200px;"/>
</el-form-item>
</el-col>
</el-row>
<el-form-item label="备注"> <el-form-item label="备注">
<el-input v-model="form.remark" style="width: 600px;" type="textarea" /> <el-input v-model="form.remark" style="width: 600px;" type="textarea" />
</el-form-item> </el-form-item>
@@ -115,6 +127,8 @@
<el-table-column prop="corp_tele_no" label="公司电话" /> <el-table-column prop="corp_tele_no" label="公司电话" />
<el-table-column prop="corp_address" label="公司地址" /> <el-table-column prop="corp_address" label="公司地址" />
<el-table-column prop="jurid_name" label="法人代表" /> <el-table-column prop="jurid_name" label="法人代表" />
<el-table-column prop="shd_print_no" label="送货单打印模板路径" width="150px" show-overflow-tooltip/>
<el-table-column prop="shd_dtl_num" label="送货单明细数" />
<el-table-column prop="update_optname" label="修改者" /> <el-table-column prop="update_optname" label="修改者" />
<el-table-column prop="update_time" label="修改时间" width="150" /> <el-table-column prop="update_time" label="修改时间" width="150" />
<el-table-column label="启用" align="center" prop="is_used"> <el-table-column label="启用" align="center" prop="is_used">

View File

@@ -169,4 +169,11 @@ export function moneySubmit(data) {
data data
}) })
} }
export default { add, edit, del, allDiv, allCancel, getOutBillDtl, getOutBillDis, setPoint, getOutBillTask, getStructIvt, manualDiv, confirm, issueTask, finishTask, cancleTaskfinish, getInvTypes, paramByCodeType, schAreaType, backConfirm, getOutBillDisDtl, getType, allDivOne, moneySubmit } export function getDisNum(data) {
return request({
url: '/api/checkoutbill/getDisNum',
method: 'post',
data
})
}
export default { add, edit, del, allDiv, allCancel, getOutBillDtl, getOutBillDis, setPoint, getOutBillTask, getStructIvt, manualDiv, confirm, issueTask, finishTask, cancleTaskfinish, getInvTypes, paramByCodeType, schAreaType, backConfirm, getOutBillDisDtl, getType, allDivOne, moneySubmit, getDisNum }

View File

@@ -550,16 +550,17 @@ export default {
return strStyle + arr.join('') return strStyle + arr.join('')
}, },
printExcel(jo) { printExcel(jo) {
debugger checkoutbill.getDisNum({ 'iostorinv_id': jo.iostorinv_id }).then(res => {
const j = Math.ceil(jo.detail_count / jo.shd_dtl_num) const j = Math.ceil(res.num / jo.shd_dtl_num)
for (let i = 0; i < j; i++) { for (let i = 0; i < j; i++) {
download('/api/checkoutbill/downloadExcel', { 'iostorinv_id': jo.iostorinv_id, 'j': i }).then(result => { download('/api/checkoutbill/downloadExcel', { 'iostorinv_id': jo.iostorinv_id, 'j': i }).then(result => {
downloadFile(result, '', 'xlsx') downloadFile(result, '发货单', 'xlsx')
crud.downloadLoading = false crud.downloadLoading = false
}).catch(() => { }).catch(() => {
crud.downloadLoading = false crud.downloadLoading = false
}) })
} }
})
} }
} }
} }