Merge remote-tracking branch 'origin/master'

# Conflicts:
#	acs/nladmin-system/src/main/java/org/nl/acs/device/wql/task_inst.xls
This commit is contained in:
2023-11-09 09:58:00 +08:00
19 changed files with 2062 additions and 45 deletions

View File

@@ -298,7 +298,7 @@ public class CasingStationConveyorDeviceDriver extends AbstractOpcDeviceDriver i
} else {
message = applyPaperActionResponse.getMessage();
map.put("code", "to_command");
map.put("value", "5");
map.put("value", "99");
this.writing(map);
requireSucess = false;
message = "纸管不匹配";

View File

@@ -107,7 +107,7 @@ public class ItemProtocol {
list.add(new ItemDto(item_error, "报警", "DB101.W58"));
list.add(new ItemDto(item_task, "任务号", "DB101.W6"));
list.add(new ItemDto(item_material1, "物料1", "DB101.W7"));
list.add(new ItemDto(item_material2, "物料1", "DB101.W8"));
list.add(new ItemDto(item_material2, "物料2", "DB101.W8"));
return list;
}

View File

@@ -7,6 +7,7 @@ import cn.hutool.json.JSONUtil;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.formula.functions.T;
import org.jinterop.dcom.core.JIUnsignedInteger;
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
import java.util.ArrayList;
@@ -110,6 +111,47 @@ public class ItemProtocol {
this.driver = driver;
}
public String getTo_material1() {
return this.getOpcStringValue(item_to_material1);
}
public String getTo_material2() {
return this.getOpcStringValue(item_to_material2);
}
public String getTo_material3() {
return this.getOpcStringValue(item_to_material3);
}
public int getTo_out_qty1() {
return this.getOpcIntegerValue(item_to_out_qty1);
}
public int getTo_out_qty2() {
return this.getOpcIntegerValue(item_to_out_qty2);
}
public int getTo_out_qty3() {
return this.getOpcIntegerValue(item_to_out_qty3);
}
public int getTo_seq1() {
return this.getOpcIntegerValue(item_to_seq1);
}
public int getTo_seq2() {
return this.getOpcIntegerValue(item_to_seq2);
}
public int getTo_seq3() {
return this.getOpcIntegerValue(item_to_seq3);
}
public int getTo_position1() {
return this.getOpcIntegerValue(item_to_position1);
}
public int getTo_position2() {
return this.getOpcIntegerValue(item_to_position2);
}
public int getTo_position3() {
return this.getOpcIntegerValue(item_to_position3);
}
public int getHeartbeat() {
return this.getOpcIntegerValue(item_heartbeat);
}
@@ -201,6 +243,48 @@ public class ItemProtocol {
}
public int getQty1() {
return this.getOpcIntegerValue(item_qty1);
}
public int getQty2() {
return this.getOpcIntegerValue(item_qty2);
}
public int getQty3() {
return this.getOpcIntegerValue(item_qty3);
}
public int getQty4() {
return this.getOpcIntegerValue(item_qty4);
}
public int getQty5() {
return this.getOpcIntegerValue(item_qty5);
}
public int getQty6() {
return this.getOpcIntegerValue(item_qty6);
}
public int getQty7() {
return this.getOpcIntegerValue(item_qty7);
}
public int getQty8() {
return this.getOpcIntegerValue(item_qty8);
}
public int getQty9() {
return this.getOpcIntegerValue(item_qty9);
}
public int getQty10() {
return this.getOpcIntegerValue(item_qty10);
}
public int getQty11() {
return this.getOpcIntegerValue(item_qty11);
}
public int getQty12() {
return this.getOpcIntegerValue(item_qty12);
}
public int getTotarget() {
return this.getOpcIntegerValue(item_to_target);
}
@@ -244,6 +328,16 @@ public class ItemProtocol {
return new int[3];
}
public int[] getJIUnsignedInteger(String protocol) {
int[] jiUnsignedIntegerArrayValue = this.driver.getJIUnsignedIntegerArrayValue(protocol);
if (ObjectUtil.isNull(jiUnsignedIntegerArrayValue)) {
} else {
return jiUnsignedIntegerArrayValue;
}
return new int[3];
}
public List getOpcArrayValue1(String protocol) {
List arrayValue = this.driver.getArrayValue(protocol);
if (ObjectUtil.isNull(arrayValue)) {

View File

@@ -13,7 +13,7 @@ public class Paper implements Serializable {
//设备号
private String device_code;
//
private String meterial_code;
private String material_code;
private String qty;
}

View File

@@ -8,9 +8,12 @@ import cn.hutool.json.JSON;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.jinterop.dcom.core.JIUnsignedInteger;
import org.nl.acs.agv.server.AgvService;
import org.nl.acs.device.service.DeviceService;
import org.nl.acs.device_driver.DeviceDriver;
@@ -108,13 +111,93 @@ public class PaperTubeConveyor2DeviceDriver extends AbstractOpcDeviceDriver impl
//下发任务号
int to_task = 0;
int last_to_task = 0;
//出库顺序数组
String item_out_seq_arr = null;
List item_out_seq_arr1 = null;
String last_item_out_seq_arr = null;
//出库数量数组
int[] item_out_qty_arr = null;
int[] last_item_out_qty_arr = null;
String item_material1 = null;
String last_item_material1 = null;
String item_material2 = null;
String last_item_material2 = null;
String item_material3 = null;
String last_item_material3 = null;
String item_material4 = null;
String last_item_material4 = null;
String item_material5 = null;
String last_item_material5 = null;
String item_material6 = null;
String last_item_material6 = null;
String item_material7 = null;
String last_item_material7 = null;
String item_material8 = null;
String last_item_material8 = null;
String item_material9 = null;
String last_item_material9 = null;
String item_material10 = null;
String last_item_material10 = null;
String item_material11 = null;
String last_item_material11 = null;
String item_material12 = null;
String last_item_material12 = null;
int item_qty1 = 0;
int last_item_qty1 = 0;
int item_qty2 = 0;
int last_item_qty2 = 0;
int item_qty3 = 0;
int last_item_qty3 = 0;
int item_qty4 = 0;
int last_item_qty4 = 0;
int item_qty5 = 0;
int last_item_qty5 = 0;
int item_qty6 = 0;
int last_item_qty6 = 0;
int item_qty7 = 0;
int last_item_qty7 = 0;
int item_qty8 = 0;
int last_item_qty8 = 0;
int item_qty9 = 0;
int last_item_qty9 = 0;
int item_qty10 = 0;
int last_item_qty10 = 0;
int item_qty11 = 0;
int last_item_qty11 = 0;
int item_qty12 = 0;
int last_item_qty12 = 0;
String item_to_material1 = null;
String last_item_to_material1 = null;
String item_to_material2 = null;
String last_item_to_material2 = null;
String item_to_material3 = null;
String last_item_to_material3 = null;
int item_to_out_qty1 = 0;
int last_item_to_out_qty1 = 0;
int item_to_out_qty2 = 0;
int last_item_to_out_qty2 = 0;
int item_to_out_qty3 = 0;
int last_item_to_out_qty3 = 0;
int item_to_seq1 = 0;
int last_item_to_seq1 = 0;
int item_to_seq2 = 0;
int last_item_to_seq2 = 0;
int item_to_seq3 = 0;
int last_item_to_seq3 = 0;
int item_to_position1 = 0;
int last_item_to_position1 = 0;
int item_to_position2 = 0;
int last_item_to_position2 = 0;
int item_to_position3 = 0;
int last_item_to_position3 = 0;
//当前指令
Instruction inst = null;
@@ -149,7 +232,6 @@ public class PaperTubeConveyor2DeviceDriver extends AbstractOpcDeviceDriver impl
@Override
public void execute() {
try {
String message = null;
device_code = this.getDeviceCode();
heartbeat = this.itemProtocol.getHeartbeat();
mode = this.itemProtocol.getMode();
@@ -160,20 +242,48 @@ public class PaperTubeConveyor2DeviceDriver extends AbstractOpcDeviceDriver impl
to_command = this.itemProtocol.getTo_command();
to_target = this.itemProtocol.getTotarget();
to_task = this.itemProtocol.getTo_task();
//item_out_seq_arr1 = this.itemProtocol.getItem_out_seq_arr1();
item_out_seq_arr = this.itemProtocol.getItem_out_seq_arr();
item_out_qty_arr = this.itemProtocol.getItem_out_qty_arr();
item_material1 = this.itemProtocol.getMaterial1();
item_material2 = this.itemProtocol.getMaterial2();
item_material3 = this.itemProtocol.getMaterial3();
item_material4 = this.itemProtocol.getMaterial4();
item_material5 = this.itemProtocol.getMaterial5();
item_material6 = this.itemProtocol.getMaterial6();
item_material7 = this.itemProtocol.getMaterial7();
item_material8 = this.itemProtocol.getMaterial8();
item_material9 = this.itemProtocol.getMaterial9();
item_material10 = this.itemProtocol.getMaterial10();
item_material11 = this.itemProtocol.getMaterial11();
item_material12 = this.itemProtocol.getMaterial12();
item_qty1 = this.itemProtocol.getQty1();
item_qty2 = this.itemProtocol.getQty2();
item_qty3 = this.itemProtocol.getQty3();
item_qty4 = this.itemProtocol.getQty4();
item_qty5 = this.itemProtocol.getQty5();
item_qty6 = this.itemProtocol.getQty6();
item_qty7 = this.itemProtocol.getQty7();
item_qty8 = this.itemProtocol.getQty8();
item_qty9 = this.itemProtocol.getQty9();
item_qty10 = this.itemProtocol.getQty10();
item_qty11 = this.itemProtocol.getQty11();
item_qty12 = this.itemProtocol.getQty12();
item_to_material1 = this.itemProtocol.getTo_material1();
item_to_material2 = this.itemProtocol.getTo_material2();
item_to_material3 = this.itemProtocol.getTo_material3();
item_to_out_qty1 = this.itemProtocol.getTo_out_qty1();
item_to_out_qty2 = this.itemProtocol.getTo_out_qty2();
item_to_out_qty3 = this.itemProtocol.getTo_out_qty3();
item_to_seq1 = this.itemProtocol.getTo_seq1();
item_to_seq2 = this.itemProtocol.getTo_seq2();
item_to_seq3 = this.itemProtocol.getTo_seq3();
item_to_position1 = this.itemProtocol.getTo_position1();
item_to_position2 = this.itemProtocol.getTo_position2();
item_to_position3 = this.itemProtocol.getTo_position3();
if (to_command != last_to_command) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_command" + last_to_command + "->" + to_command);
}
if (to_target != last_to_target) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_target" + last_to_target + "->" + to_target);
}
if (to_task != last_to_task) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_task" + last_to_task + "->" + to_task);
}
//信号位置校验,记录日志
signal_verification();
if (mode != last_mode) {
JSONObject param = new JSONObject();
@@ -254,10 +364,13 @@ public class PaperTubeConveyor2DeviceDriver extends AbstractOpcDeviceDriver impl
request_for_shipment(String.valueOf(mode), item_out_seq_arr, item_out_qty_arr);
}
break;
default:
break;
}
}
last_heartbeat = heartbeat;
last_mode = mode;
last_move = move;
last_error = error;
last_carrier_direction = carrier_direction;
last_task = task;
@@ -266,6 +379,42 @@ public class PaperTubeConveyor2DeviceDriver extends AbstractOpcDeviceDriver impl
last_to_task = to_task;
last_item_out_seq_arr = item_out_seq_arr;
last_item_out_qty_arr = item_out_qty_arr;
last_item_material1 = item_material1;
last_item_material2 = item_material2;
last_item_material3 = item_material3;
last_item_material4 = item_material4;
last_item_material5 = item_material5;
last_item_material6 = item_material6;
last_item_material7 = item_material7;
last_item_material8 = item_material8;
last_item_material9 = item_material9;
last_item_material10 = item_material10;
last_item_material11 = item_material11;
last_item_material12 = item_material12;
last_item_qty1 = item_qty1;
last_item_qty2 = item_qty2;
last_item_qty3 = item_qty3;
last_item_qty4 = item_qty4;
last_item_qty5 = item_qty5;
last_item_qty6 = item_qty6;
last_item_qty7 = item_qty7;
last_item_qty8 = item_qty8;
last_item_qty9 = item_qty9;
last_item_qty10 = item_qty10;
last_item_qty11 = item_qty11;
last_item_qty12 = item_qty12;
last_item_to_material1 = item_to_material1;
last_item_to_material2 = item_to_material2;
last_item_to_material3 = item_to_material3;
last_item_to_out_qty1 = item_to_out_qty1;
last_item_to_out_qty2 = item_to_out_qty2;
last_item_to_out_qty3 = item_to_out_qty3;
last_item_to_seq1 = item_to_seq1;
last_item_to_seq2 = item_to_seq2;
last_item_to_seq3 = item_to_seq3;
last_item_to_position1 = item_to_position1;
last_item_to_position2 = item_to_position2;
last_item_to_position3 = item_to_position3;
}
@@ -331,26 +480,29 @@ public class PaperTubeConveyor2DeviceDriver extends AbstractOpcDeviceDriver impl
applyPaperActionRequest.setTask_code(String.valueOf(task));
//获取出库顺序
boolean contains = item_out_seq_arr.contains(",");
//String s = item_out_seq_arr.replaceAll("[\\[\\]]", "");
boolean contains1 = item_out_seq_arr.contains("");
if (contains) {
String[] split = item_out_seq_arr.split(",");
applyPaperActionRequest.setMaterial1(split[0]);
applyPaperActionRequest.setMaterial2(split[1]);
applyPaperActionRequest.setMaterial1(split[1]);
} else if (contains1) {
String[] split = item_out_seq_arr.split("");
applyPaperActionRequest.setMaterial1(split[0]);
applyPaperActionRequest.setMaterial1(split[1]);
} else {
applyPaperActionRequest.setMaterial1(item_out_seq_arr);
}
/*if (item_out_qty_arr.length == 2) {
// 去除方括号
applyPaperActionRequest.setMaterial1(String.valueOf(item_out_qty_arr[0]));
applyPaperActionRequest.setMaterial2(String.valueOf(item_out_qty_arr[1]));
} else if (item_out_qty_arr.length == 1) {
applyPaperActionRequest.setMaterial1(String.valueOf(item_out_qty_arr[0]));
}*/
if (item_out_qty_arr.length >= 1 && item_out_qty_arr.length < 4) {
applyPaperActionRequest.setQty1(String.valueOf(item_out_qty_arr[0]));
applyPaperActionRequest.setQty2(String.valueOf(item_out_qty_arr[1]));
}
ApplyPaperActionResponse applyPaperActionResponse = acsToWmsService.applyPaperActionRequest(applyPaperActionRequest);
if (ObjectUtil.isNull(applyPaperActionResponse)) {
message = "请求失败";
requireSucess = false;
return;
}
Map map3 = new HashMap();
if (applyPaperActionResponse.getstatus() == 200) {
map3.put("to_command", "4");
@@ -383,10 +535,7 @@ public class PaperTubeConveyor2DeviceDriver extends AbstractOpcDeviceDriver impl
//查找有没有对应的指令
//找指令类型是10的
Instruction inst = instructionService.findByDeviceCodeFromCache(this.device_code);
if (ObjectUtil.isNull(inst)) {
return false;
}
if (ObjectUtil.isNotNull(inst) && "10".equals(inst.getInstruction_code())) {
if (ObjectUtil.isNotNull(inst) && "10".equals(inst.getInstruction_type())) {
Device nextdevice = deviceAppservice.findDeviceByCode(inst.getNext_device_code());
String next_addr = nextdevice.getExtraValue().get("address").toString();
TaskDto taskDto = taskserver.findByCodeFromCache(inst.getTask_code());
@@ -424,10 +573,12 @@ public class PaperTubeConveyor2DeviceDriver extends AbstractOpcDeviceDriver impl
}
//判断当前任务号是否存在指令
Instruction inst1 = instructionService.findByTaskcodeAndStatus(taskdto.getTask_code());
Device nextdevice = deviceAppservice.findDeviceByCode(inst1.getNext_device_code());
String next_addr = nextdevice.getExtraValue().get("address").toString();
Device pointdevice = deviceAppservice.findDeviceByCode(inst1.getNext_point_code());
String point_addr = pointdevice.getExtraValue().get("address").toString();
/*if(ObjectUtil.isNotNull(inst1)){
Device nextdevice = deviceAppservice.findDeviceByCode(inst1.getNext_device_code());
String next_addr = nextdevice.getExtraValue().get("address").toString();
Device pointdevice = deviceAppservice.findDeviceByCode(inst1.getNext_point_code());
String point_addr = pointdevice.getExtraValue().get("address").toString();
}*/
//没有就创建指令
String taskid = taskdto.getTask_id();
String taskcode = taskdto.getTask_code();
@@ -435,7 +586,6 @@ public class PaperTubeConveyor2DeviceDriver extends AbstractOpcDeviceDriver impl
String start_point_code = taskdto.getStart_point_code();
String start_device_code = taskdto.getStart_device_code();
String route_plan_code = taskdto.getRoute_plan_code();
Instruction instdto = new Instruction();
instdto.setInstruction_id(IdUtil.simpleUUID());
instdto.setRoute_plan_code(route_plan_code);
@@ -448,9 +598,9 @@ public class PaperTubeConveyor2DeviceDriver extends AbstractOpcDeviceDriver impl
instdto.setCreate_time(now);
instdto.setCreate_by("auto");
instdto.setStart_device_code(start_device_code);
instdto.setNext_device_code(next_addr);
instdto.setNext_device_code(taskdto.getNext_device_code());
instdto.setStart_point_code(start_point_code);
instdto.setNext_point_code(point_addr);
instdto.setNext_point_code(taskdto.getNext_point_code());
instdto.setPriority(priority);
instdto.setInstruction_status("0");
instdto.setExecute_device_code(start_point_code);
@@ -475,7 +625,7 @@ public class PaperTubeConveyor2DeviceDriver extends AbstractOpcDeviceDriver impl
writeStatus(paperArray, map, 2);
writeStatus(paperArray, map, 3);
}
writeData(next_addr, instdto, map);
writeData(taskdto.getNext_device_code(), instdto, map);
this.writing(map);
requireSucess = true;
return true;
@@ -502,11 +652,13 @@ public class PaperTubeConveyor2DeviceDriver extends AbstractOpcDeviceDriver impl
}
public void writeStatus(List<Paper> paperArray, Map map, Integer status) {
Paper paper = paperArray.get(status);
map.put("to_material" + status, paper.getMeterial_code());
Paper paper = paperArray.get(status - 1);
map.put("to_material" + status, paper.getMaterial_code());
map.put("to_out_qty" + status, paper.getQty());
map.put("to_seq" + status, "1");
map.put("to_position" + status, paper.getDevice_code());
map.put("to_seq" + status, status);
Device nextdevice = deviceAppservice.findDeviceByCode(paper.getDevice_code());
String next_addr = nextdevice.getExtraValue().get("address").toString();
map.put("to_position" + status, next_addr);
}
@@ -560,8 +712,7 @@ public class PaperTubeConveyor2DeviceDriver extends AbstractOpcDeviceDriver impl
* 解析出库的顺序
*/
public List<Paper> getPaperArray(String paper_array) {
JSONArray jsonArray = JSONUtil.parseArray(paper_array);
List<Paper> papers = jsonArray.toList(Paper.class);
List<Paper> papers = JSONUtil.toList(paper_array, Paper.class);
return papers;
}
@@ -573,7 +724,6 @@ public class PaperTubeConveyor2DeviceDriver extends AbstractOpcDeviceDriver impl
Date date = new Date();
if (date.getTime() - this.instruction_update_time.getTime() < (long) this.instruction_update_time_out) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_update_time_out);
} else {
this.instruction_update_time = date;
inst = checkInst();
@@ -614,9 +764,149 @@ public class PaperTubeConveyor2DeviceDriver extends AbstractOpcDeviceDriver impl
return null;
}
private void signal_verification() {
if (!item_out_seq_arr.equals(last_item_out_seq_arr)) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号item_out_seq_arr" + last_item_out_seq_arr + "->" + item_out_seq_arr);
}
if (!arrayEquals(item_out_qty_arr, last_item_out_qty_arr)) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号item_out_qty_arr" + Arrays.toString(last_item_out_qty_arr) + "->" + Arrays.toString(item_out_qty_arr));
}
if (item_qty1 != (last_item_qty1)) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号qty1" + last_item_qty1 + "->" + item_qty1);
}
if (item_qty2 != (last_item_qty2)) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号qty2" + last_item_qty2 + "->" + item_qty2);
}
if (item_qty3 != (last_item_qty3)) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号qty3" + last_item_qty3 + "->" + item_qty3);
}
if (item_qty4 != (last_item_qty4)) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号qty4" + last_item_qty4 + "->" + item_qty4);
}
if (item_qty5 != (last_item_qty5)) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号qty5" + last_item_qty5 + "->" + item_qty5);
}
if (item_qty6 != (last_item_qty6)) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号qty6" + last_item_qty6 + "->" + item_qty6);
}
if (item_qty7 != (last_item_qty7)) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号qty7" + last_item_qty7 + "->" + item_qty7);
}
if (item_qty8 != (last_item_qty8)) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号qty8" + last_item_qty8 + "->" + item_qty8);
}
if (item_qty9 != (last_item_qty9)) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号qty9" + last_item_qty9 + "->" + item_qty9);
}
if (item_qty10 != (last_item_qty10)) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号qty10" + last_item_qty10 + "->" + item_qty10);
}
if (item_qty11 != (last_item_qty11)) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号qty11" + last_item_qty11 + "->" + item_qty11);
}
if (item_qty12 != (last_item_qty12)) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号qty12" + last_item_qty12 + "->" + item_qty12);
}
if (item_material1.equals(last_item_material1)) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号material1" + last_item_material1 + "->" + item_material1);
}
if (!item_material2.equals(last_item_material2)) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号material2" + last_item_material2 + "->" + item_material2);
}
if (!item_material3.equals(last_item_material3)) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号material3" + last_item_material3 + "->" + item_material3);
}
if (!item_material4.equals(last_item_material4)) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号material4" + last_item_material4 + "->" + item_material4);
}
if (!item_material5.equals(last_item_material5)) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号material5" + last_item_material5 + "->" + item_material5);
}
if (!item_material6.equals(last_item_material6)) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号material6" + last_item_material6 + "->" + item_material6);
}
if (!item_material7.equals(last_item_material7)) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号material7" + last_item_material7 + "->" + item_material7);
}
if (!item_material8.equals(last_item_material8)) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号material8" + last_item_material8 + "->" + item_material8);
}
if (!item_material9.equals(last_item_material9)) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号material9" + last_item_material9 + "->" + item_material9);
}
if (!item_material10.equals(last_item_material10)) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号material10" + last_item_material10 + "->" + item_material10);
}
if (!item_material11.equals(last_item_material11)) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号material11" + last_item_material11 + "->" + item_material11);
}
if (!item_material12.equals(last_item_material12)) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号material12" + last_item_material12 + "->" + item_material12);
}
if (to_command != last_to_command) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_command" + last_to_command + "->" + to_command);
}
if (to_target != last_to_target) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_target" + last_to_target + "->" + to_target);
}
if (to_task != last_to_task) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_task" + last_to_task + "->" + to_task);
}
if (!item_to_material1.equals(last_item_to_material1)) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_material1" + last_item_to_material1 + "->" + item_to_material1);
}
if (!item_to_material2.equals(last_item_to_material2)) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_material2" + last_item_to_material2 + "->" + item_to_material2);
}
if (!item_to_material3.equals(last_item_to_material3)) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_material3" + last_item_to_material2 + "->" + item_to_material2);
}
if (item_to_out_qty1 != (last_item_to_out_qty1)) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_out_qty1" + last_item_to_out_qty1 + "->" + item_to_out_qty1);
}
if (item_to_out_qty2 != (last_item_to_out_qty2)) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_out_qty2" + last_item_to_out_qty2 + "->" + item_to_out_qty2);
}
if (item_to_out_qty3 != (last_item_to_out_qty3)) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_out_qty3" + last_item_to_out_qty3 + "->" + item_to_out_qty3);
}
if (item_to_seq1 != (last_item_to_seq1)) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_seq1" + last_item_to_seq1 + "->" + item_to_seq1);
}
if (item_to_seq2 != (last_item_to_seq2)) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_seq2" + last_item_to_seq2 + "->" + item_to_seq2);
}
if (item_to_seq3 != (last_item_to_seq3)) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_seq3" + last_item_to_seq3 + "->" + item_to_seq3);
}
if (item_to_position1 != (last_item_to_position1)) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_position1" + last_item_to_position1 + "->" + item_to_position1);
}
if (item_to_position2 != (last_item_to_position2)) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_position2" + last_item_to_position2 + "->" + item_to_position2);
}
if (item_to_position3 != (last_item_to_position3)) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_position3" + last_item_to_position3 + "->" + item_to_position3);
}
}
@Override
public void setDeviceStatus(JSONObject data) {
}
public static boolean arrayEquals(int[] a, int[] b) {
// 判断两个数组长度是否相等
if (a.length != b.length) {
return false;
}
// 判断两个数组对应位置上的元素是否相同
for (int i = 0; i < a.length; i++) {
if (a[i] != b[i]) {
return false;
}
}
return true;
}
}

View File

@@ -4,6 +4,7 @@ package org.nl.acs.device_driver.driver;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.jinterop.dcom.core.JIUnsignedInteger;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.opc.Device;
import org.nl.acs.opc.OpcItemDto;
@@ -77,6 +78,21 @@ public interface OpcDeviceDriver extends DeviceDriver {
return (int[]) this.getOpcValueAccessor().getValue(this.getItem(protocol));
}
default int[] getJIUnsignedIntegerArrayValue(String protocol) {
JIUnsignedInteger[] jiUnsignedIntegers = (JIUnsignedInteger[]) this.getOpcValueAccessor().getValue(this.getItem(protocol));
if(ObjectUtil.isNull(jiUnsignedIntegers)){
return new int[3];
}
// 将 JIUnsignedInteger[] 转换为 int[]
int[] intArray = new int[jiUnsignedIntegers.length];
for (int i = 0; i < jiUnsignedIntegers.length; i++) {
intArray[i] = jiUnsignedIntegers[i].getValue().intValue();
}
return intArray;
}
default String getStringValue(String protocol) {
return (String) this.getOpcValueAccessor().getValue(this.getItem(protocol));
}

View File

@@ -1,7 +1,9 @@
package org.nl.acs.ext.wms.data;
import lombok.Data;
import org.nl.acs.device_driver.basedriver.paper_tube_device2.Paper;
import java.util.List;
import java.util.Map;
@Data
@@ -120,4 +122,6 @@ public class CreateTaskRequest extends BaseRequest {
*/
Map<String,String> params;
private List<Paper> paper_array;
}

View File

@@ -488,6 +488,9 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) {
String wmsUrl = paramService.findByCode(AcsConfig.WMSURL).getValue();
AddressDto addressDto = addressService.findByCode("applyPaperAction");
if(ObjectUtil.isNull(addressDto)){
return null;
}
String methods_url = addressDto.getMethods_url();
String url = wmsUrl + methods_url;
log.info("ApplyPaperActionRequest----请求参数{}", param);

View File

@@ -3,6 +3,7 @@ package org.nl.acs.ext.wms.service.impl;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
@@ -27,6 +28,7 @@ import org.nl.acs.device_driver.basedriver.hongxiang_device.HongXiangConveyorDev
import org.nl.acs.device_driver.basedriver.lamp_three_color.LampThreecolorDeviceDriver;
import org.nl.acs.device_driver.basedriver.oven_manipulator.OvenGantryManipulatorDeviceDriver;
import org.nl.acs.device_driver.basedriver.paper_tube_device.PaperTubeConveyorDeviceDriver;
import org.nl.acs.device_driver.basedriver.paper_tube_device2.Paper;
import org.nl.acs.device_driver.basedriver.plug_pull_device_site.PlugPullDeviceSiteDeviceDriver;
import org.nl.acs.device_driver.basedriver.siemens_conveyor.SiemensConveyorDeviceDriver;
import org.nl.acs.device_driver.basedriver.siemens_conveyor_ckk.SiemensConveyorCkkDeviceDriver;
@@ -614,6 +616,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
for (int i = 0; i < datas.size(); i++) {
String data = datas.get(i).toString();
CreateTaskRequest request = JsonUtl.format(data, CreateTaskRequest.class);
List<Paper> paper_array = request.getPaper_array();
String ext_task_id = request.getExt_task_id();
String task_code = request.getTask_code();
String start_device_code = request.getStart_device_code();
@@ -823,6 +826,8 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
jo.put("remark", remark);
jo.put("params", params);
jo.put("task_type", StrUtil.isEmpty(task_type) ? 1 : Integer.parseInt(task_type));
jo.put("paper_array", JSONUtil.toJsonStr(paper_array));
if (!StrUtil.isEmpty(ext_task_id)) {
jo.put("ext_task_id", ext_task_id);

View File

@@ -1,8 +1,16 @@
package org.nl.acs.task.service.dto;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Data;
import org.jinterop.dcom.core.JIUnsignedFactory;
import org.jinterop.dcom.core.JIUnsignedInteger;
import org.nl.acs.device_driver.basedriver.paper_tube_device2.Paper;
import java.io.Serializable;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
/**
* @author ldjun
@@ -329,11 +337,11 @@ public class TaskDto implements Serializable {
private String bushing_num;
//array device_code\material_code\qty
private String paper_array;
@Override
public String toString(){
return "task_code:" + this.getTask_code()

View File

@@ -0,0 +1,79 @@
package org.nl.wms.st.instor.rest;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.modules.logging.annotation.Log;
import org.nl.wms.st.instor.service.ProductScrapService;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
@RestController
@RequiredArgsConstructor
@Api(tags = "成品报废审核")
@RequestMapping("/api/productscrap")
@Slf4j
public class ProductScrapController {
private final ProductScrapService productScrapService;
@GetMapping
@Log("查询成品报废审核单")
@ApiOperation("查询成品报废审核单")
public ResponseEntity<Object> query(@RequestParam Map whereJson, Pageable page) {
return new ResponseEntity<>(productScrapService.pageQuery(whereJson, page), HttpStatus.OK);
}
@GetMapping("/getOutBillDtl")
@Log("查询明细")
@ApiOperation("查询明细")
public ResponseEntity<Object> getOutBillDtl(@RequestParam Map whereJson) {
return new ResponseEntity<>(productScrapService.getOutBillDtl(whereJson), HttpStatus.OK);
}
@Log("删除")
@ApiOperation("删除")
@DeleteMapping
public ResponseEntity<Object> delete(@RequestBody Long[] ids) {
productScrapService.deleteAll(ids);
return new ResponseEntity<>(HttpStatus.OK);
}
@PutMapping
@Log("修改")
@ApiOperation("修改")
public ResponseEntity<Object> update(@RequestBody JSONObject whereJson) {
productScrapService.update(whereJson);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
@PostMapping()
@Log("新增")
@ApiOperation("新增")
public ResponseEntity<Object> insertDtl(@RequestBody JSONObject whereJson) {
productScrapService.insertDtl(whereJson);
return new ResponseEntity<>(HttpStatus.CREATED);
}
@PostMapping("/auditPass")
@Log("审核通过")
@ApiOperation("审核通过")
public ResponseEntity<Object> auditPass(@RequestBody JSONObject whereJson) {
productScrapService.auditPass(whereJson);
return new ResponseEntity<>(HttpStatus.CREATED);
}
@PostMapping("/auditOut")
@Log("不通过")
@ApiOperation("不通过")
public ResponseEntity<Object> auditOut(@RequestBody JSONObject whereJson) {
productScrapService.auditOut(whereJson);
return new ResponseEntity<>(HttpStatus.CREATED);
}
}

View File

@@ -0,0 +1,52 @@
package org.nl.wms.st.instor.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.springframework.data.domain.Pageable;
import java.util.Map;
public interface ProductScrapService {
/**
* 查询数据分页
*
* @param whereJson 条件
* @param page 分页参数
* @return Map<String, Object>
*/
Map<String, Object> pageQuery(Map whereJson, Pageable page);
/**
* 多选删除
* @param ids /
*/
void deleteAll(Long[] ids);
/**
* 新增出库单
* @param whereJson /
*/
void insertDtl (JSONObject whereJson);
/**
* 查询出库单明细
* @param whereJson /
* @return
*/
JSONArray getOutBillDtl(Map whereJson);
/**
* 修改出库单
* @param whereJson /
*/
void update(JSONObject whereJson);
/**
* 审核通过
* @param whereJson /
*/
void auditPass(JSONObject whereJson);
/**
* 不通过
* @param whereJson /
*/
void auditOut(JSONObject whereJson);
}

View File

@@ -0,0 +1,287 @@
package org.nl.wms.st.instor.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.common.utils.SecurityUtils;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.system.util.CodeUtil;
import org.nl.modules.wql.WQL;
import org.nl.modules.wql.core.bean.WQLObject;
import org.nl.modules.wql.util.WqlUtil;
import org.nl.wms.basedata.st.service.impl.UserStorServiceImpl;
import org.nl.wms.st.inbill.service.CheckOutBillService;
import org.nl.wms.st.instor.service.ProductScrapService;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* PC端成品报废审核
*/
@Service
@RequiredArgsConstructor
@Slf4j
public class ProductScrapServiceImpl implements ProductScrapService {
private final CheckOutBillService checkOutBillService;
@Override
public Map<String, Object> pageQuery(Map whereJson, Pageable page) {
HashMap<String, String> map = new HashMap<>(whereJson);
map.put("flag", "1");
if (StrUtil.isNotEmpty(map.get("bill_code"))) {
map.put("bill_code", "%" + map.get("bill_code") + "%");
}
if (StrUtil.isNotEmpty(map.get("material_code"))) {
map.put("material_code", "%" + map.get("material_code") + "%");
}
if (StrUtil.isNotEmpty(map.get("pcsn"))) {
map.put("pcsn", (String) whereJson.get("pcsn"));
}
//获取人员对应的仓库
UserStorServiceImpl userStorService = new UserStorServiceImpl();
String in_stor_id = userStorService.getInStor();
if (ObjectUtil.isNotEmpty(in_stor_id)) map.put("in_stor_id", in_stor_id);
JSONObject jo = WQL.getWO("QST_IVT_PRODUCTSCRAP").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "scrap_code desc");
return jo;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteAll(Long[] ids) {
WQLObject wo_mst = WQLObject.getWQLObject("ST_IVT_ProductScrapMst");
JSONObject jsonObject = new JSONObject();
jsonObject.put("is_delete", "1");
for (Long scrap_id : ids) {
wo_mst.update(jsonObject,"scrap_id = '"+scrap_id+"'");
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public void insertDtl(JSONObject map) {
//主表
WQLObject wo_mst = WQLObject.getWQLObject("ST_IVT_ProductScrapMst");
JSONArray rows = map.getJSONArray("tableData");
map.remove("tableData");
String currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getCurrentNickName();
String now = DateUtil.now();
String changeinv_id = IdUtil.getSnowflake(1, 1).nextId() + "";
JSONObject mst_jo = new JSONObject();
mst_jo.put("scrap_id", changeinv_id);
mst_jo.put("scrap_code", CodeUtil.getNewCode("SCRAP_CODE"));
mst_jo.put("biz_date", DateUtil.today());
mst_jo.put("stor_id", MapUtil.getStr(map, "stor_id"));
mst_jo.put("stor_code", MapUtil.getStr(map, "stor_code"));
mst_jo.put("stor_name", MapUtil.getStr(map, "stor_name"));
mst_jo.put("bill_status", "10");
mst_jo.put("input_optid", currentUserId + "");
mst_jo.put("input_optname", nickName);
mst_jo.put("input_time", now);
mst_jo.put("is_delete", "0");
mst_jo.put("detail_count", rows.size());
//调用明细处理方法
JSONObject ret = this.insertDtlByRows(mst_jo, rows);
mst_jo.put("total_qty", ret.getDoubleValue("total_qty"));
wo_mst.insert(mst_jo);
}
/**
* 根据传进来的载具物料明细,查询载具所有库存记录,并生成移库明细
*
* @param rows
*/
@Transactional(rollbackFor = Exception.class)
JSONObject insertDtlByRows(JSONObject jsonMst, JSONArray rows) {
WQLObject wo_dtl = WQLObject.getWQLObject("ST_IVT_ProductScrapDtl");
//定义返回数据
JSONObject ret = new JSONObject();
double total_qty = 0;
for (int i = 0; i < rows.size(); i++) {
JSONObject json = rows.getJSONObject(i);
JSONObject jsonDtl = new JSONObject();
jsonDtl.put("scrapdtl_id", IdUtil.getSnowflake(1, 1).nextId());
jsonDtl.put("scrap_id", jsonMst.getLongValue("scrap_id"));
jsonDtl.put("seq_no", i);
jsonDtl.put("material_id", json.getLongValue("material_id"));
jsonDtl.put("pcsn", json.getString("pcsn"));
jsonDtl.put("package_box_sn", json.getString("storagevehicle_code"));
jsonDtl.put("fail_source", json.getString("fail_source"));
jsonDtl.put("qty_unit_id", json.getString("qty_unit_id"));
jsonDtl.put("qty_unit_name", json.getString("qty_unit_name"));
jsonDtl.put("qty", json.getDoubleValue("qty"));
jsonDtl.put("remark", json.getString("remark"));
wo_dtl.insert(jsonDtl);
total_qty = NumberUtil.add(total_qty, json.getDoubleValue("qty"));
}
ret.put("total_qty", total_qty);
return ret;
}
@Override
public JSONArray getOutBillDtl(Map whereJson) {
whereJson.put("flag", "2");
JSONArray jo = WQL.getWO("QST_IVT_PRODUCTSCRAP")
.addParamMap((HashMap) whereJson)
.process()
.getResultJSONArray(0);
return jo;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(JSONObject whereJson) {
//主表
WQLObject wo_mst = WQLObject.getWQLObject("ST_IVT_ProductScrapMst");
//主表
WQLObject wo_dtl = WQLObject.getWQLObject("ST_IVT_ProductScrapDtl");
String currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getCurrentNickName();
String now = DateUtil.now();
String scrap_id = (String) whereJson.get("scrap_id");
//查询主表
JSONObject jo_mst = wo_mst.query("scrap_id='" + scrap_id + "'").uniqueResult(0);
//删除所有明细
wo_dtl.delete("scrap_id = '"+scrap_id+"'");
//获取明细
JSONArray rows = whereJson.getJSONArray("tableData");
//调用明细处理方法
JSONObject ret = this.insertDtlByRows(jo_mst, rows);
jo_mst.put("remark", whereJson.get("remark"));
jo_mst.put("biz_date", whereJson.get("biz_date"));
jo_mst.put("detail_count", rows.size());
jo_mst.put("total_qty", ret.getString("total_qty"));
jo_mst.put("update_optid", currentUserId + "");
jo_mst.put("update_optname", nickName);
jo_mst.put("update_time", now);
//更新主表
wo_mst.update(jo_mst);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void auditPass(JSONObject whereJson) {
/*
* 1.校验此些子卷是否都在库内并没有被锁定
* 2.生成出库单
* 3.更新单据
*/
WQLObject mst = WQLObject.getWQLObject("ST_IVT_ProductScrapMst");
WQLObject dtl = WQLObject.getWQLObject("ST_IVT_ProductScrapDtl");
WQLObject ivt = WQLObject.getWQLObject("st_ivt_structivt");
// 查询所有明细
JSONArray dtlArr = dtl.query("scrap_id = '" + whereJson.getString("scrap_id") + "'").getResultJSONArray(0);
// 查询库存中这些子卷是否存在
String pcsnJoining = dtlArr.stream()
.map(row -> JSON.parseObject(row.toString()))
.map(row -> row.getString("pcsn"))
.collect(Collectors.joining("','"));
List<JSONObject> ivtList = ivt.query("pcsn in ('" + pcsnJoining + "') and canuse_qty > 0")
.getResultJSONArray(0).toJavaList(JSONObject.class);
if (dtlArr.size() != ivtList.size()) throw new BadRequestException("库存异常请检查!");
// 校验库存
boolean is_pass = ivtList.stream()
.allMatch(row -> pcsnJoining.contains(row.getString("pcsn")));
if (!is_pass) throw new BadRequestException("库存异常请检查!");
/* List<String> collect = ivtList.stream()
.filter(row -> !pcsnJoining.contains(row.getString("pcsn")))
.map(row -> row.getString("pcsn"))
.collect(Collectors.toList());
if (ObjectUtil.isNotEmpty(collect)) {
throw new BadRequestException("子卷:"+collect.toString()+"异常请检查!");
}*/
// 生成出库单
JSONObject jsonOutMst = new JSONObject();
jsonOutMst.put("stor_id",whereJson.getString("stor_id"));
jsonOutMst.put("stor_code", whereJson.getString("stor_code"));
jsonOutMst.put("stor_name", whereJson.getString("stor_name"));
jsonOutMst.put("detail_count", ivtList.size());
jsonOutMst.put("bill_status", "10");
jsonOutMst.put("create_mode", "03");
jsonOutMst.put("biz_date", DateUtil.now());
jsonOutMst.put("io_type", "1");
jsonOutMst.put("buss_type", "1002");
jsonOutMst.put("bill_type", "1002");
jsonOutMst.put("source_name", "成品报废审核单");
JSONArray tableData = new JSONArray();
for (int i = 0; i < dtlArr.size(); i++) {
JSONObject json = dtlArr.getJSONObject(i);
JSONObject jsonDtl = new JSONObject();
jsonDtl.put("pcsn", json.getString("pcsn"));
jsonDtl.put("box_no", json.getString("package_box_sn"));
jsonDtl.put("material_id", json.getString("material_id"));
jsonDtl.put("qty_unit_id", json.getLongValue("qty_unit_id"));
jsonDtl.put("qty_unit_name", json.getString("qty_unit_name"));
jsonDtl.put("plan_qty", json.getDoubleValue("qty"));
tableData.add(jsonDtl);
}
// 调用出库新增并分配
jsonOutMst.put("tableData", tableData);
String iostorinv_id = checkOutBillService.insertDtl(jsonOutMst);
JSONObject jsonObject = new JSONObject();
jsonObject.put("iostorinv_id", iostorinv_id);
checkOutBillService.allDiv(jsonObject);
// 更新主表为完成
JSONObject param = new JSONObject();
param.put("bill_status", "99");
param.put("confirm_optid", SecurityUtils.getCurrentUserId());
param.put("confirm_optname", SecurityUtils.getCurrentNickName());
param.put("confirm_time", DateUtil.now());
mst.update(param,"scrap_id = '"+whereJson.getString("scrap_id")+"'");
}
@Override
@Transactional(rollbackFor = Exception.class)
public void auditOut(JSONObject whereJson) {
WQLObject mst = WQLObject.getWQLObject("ST_IVT_ProductScrapMst");
// 更新主表为完成
JSONObject param = new JSONObject();
param.put("bill_status", "99");
param.put("confirm_optid", SecurityUtils.getCurrentUserId());
param.put("confirm_optname", SecurityUtils.getCurrentNickName());
param.put("confirm_time", DateUtil.now());
mst.update(param,"scrap_id = '"+whereJson.getString("scrap_id")+"'");
}
}

View File

@@ -0,0 +1,112 @@
[交易说明]
交易名: 成品报废审核分页查询
所属模块:
功能简述:
版权所有:
表引用:
版本经历:
[数据库]
--指定数据库为空采用默认值默认为db.properties中列出的第一个库
[IO定义]
#################################################
## 表字段对应输入参数
#################################################
输入.flag TYPEAS s_string
输入.material_code TYPEAS s_string
输入.bill_status TYPEAS s_string
输入.bill_code TYPEAS s_string
输入.stor_id TYPEAS s_string
输入.end_time TYPEAS s_string
输入.begin_time TYPEAS s_string
输入.pcsn TYPEAS s_string
输入.scrap_id TYPEAS s_string
输入.in_stor_id TYPEAS f_string
[临时表]
--这边列出来的临时表就会在运行期动态创建
[临时变量]
--所有中间过程变量均可在此处定义
[业务过程]
##########################################
# 1、输入输出检查 #
##########################################
##########################################
# 2、主过程前处理 #
##########################################
##########################################
# 3、业务主过程 #
##########################################
IF 输入.flag = "1"
PAGEQUERY
SELECT DISTINCT
mst.*
FROM
ST_IVT_ProductScrapMst mst
LEFT JOIN ST_IVT_ProductScrapDtl dtl ON mst.scrap_id = dtl.scrap_id
WHERE
1 = 1
AND mst.is_delete = '0'
and mst.stor_id in 输入.in_stor_id
OPTION 输入.bill_code <> ""
mst.scrap_code like 输入.bill_code
ENDOPTION
OPTION 输入.pcsn <> ""
dtl.pcsn = 输入.pcsn
ENDOPTION
OPTION 输入.stor_id <> ""
mst.stor_id = 输入.stor_id
ENDOPTION
OPTION 输入.bill_status <> ""
mst.bill_status = 输入.bill_status
ENDOPTION
OPTION 输入.begin_time <> ""
mst.input_time >= 输入.begin_time
ENDOPTION
OPTION 输入.end_time <> ""
mst.input_time <= 输入.end_time
ENDOPTION
ENDSELECT
ENDPAGEQUERY
ENDIF
IF 输入.flag = "2"
QUERY
SELECT DISTINCT
dtl.*,
dtl.package_box_sn AS storagevehicle_code,
mater.material_code,
mater.material_name
FROM
ST_IVT_ProductScrapDtl dtl
LEFT JOIN ST_IVT_ProductScrapMst mst ON mst.scrap_id = dtl.scrap_id
LEFT JOIN md_me_materialbase mater ON mater.material_id = dtl.material_id
WHERE
1 = 1
OPTION 输入.scrap_id <> ""
dtl.scrap_id = 输入.scrap_id
ENDOPTION
OPTION 输入.scrapdtl_id <> ""
dtl.scrapdtl_id = 输入.scrapdtl_id
ENDOPTION
order by dtl.seq_no
ENDSELECT
ENDQUERY
ENDIF

View File

@@ -0,0 +1,491 @@
<template>
<el-dialog
:title="crud.status.title"
append-to-body
fullscreen
:before-close="crud.cancelCU"
:visible.sync="crud.status.cu > 0 || crud.status.view > 0"
@open="open"
@close="close"
>
<el-row v-show="crud.status.cu > 0" :gutter="20">
<el-col :span="20" style="border: 1px solid white">
<span/>
</el-col>
<el-col :span="4">
<span>
<el-button
icon="el-icon-check"
size="mini"
:loading="crud.cu === 2"
type="primary"
@click="crud.submitCU"
>保存</el-button>
<el-button icon="el-icon-close" size="mini" type="info" @click="crud.cancelCU">关闭</el-button>
</span>
</el-col>
</el-row>
<el-form
ref="form"
style="border: 1px solid #cfe0df;margin-top: 10px;padding-top: 10px;"
:inline="true"
:model="form"
:rules="rules"
size="mini"
label-width="85px"
label-suffix=":"
>
<el-input v-show="false" v-model="form.stor_code" placeholder="仓库编码"/>
<el-input v-show="false" v-model="form.stor_name" placeholder="仓库名称"/>
<el-form-item label="单据号" prop="scrap_code">
<label slot="label">单&nbsp;&nbsp;据&nbsp;号:</label>
<el-input v-model="form.scrap_code" disabled placeholder="系统生成" clearable style="width: 210px"/>
</el-form-item>
<el-form-item label="仓库" prop="stor_id">
<label slot="label">仓&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;库:</label>
<el-select
v-model="form.stor_id"
clearable
placeholder="仓库"
class="filter-item"
style="width: 210px"
:disabled="crud.status.view > 0"
@change="storChange"
>
<el-option
v-for="item in storlist"
:key="item.stor_id"
:label="item.stor_name"
:value="item.stor_id"
/>
</el-select>
</el-form-item>
<el-form-item label="单据状态" prop="bill_status">
<el-select
v-model="form.bill_status"
placeholder="单据状态"
class="filter-item"
:disabled="true"
>
<el-option
v-for="item in dict.SCRAP_STATUS"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item label="明细数" prop="detail_count">
<label slot="label">明&nbsp;&nbsp;细&nbsp;数:</label>
<el-input v-model="form.detail_count" size="mini" disabled style="width: 210px"/>
</el-form-item>
<el-form-item label="总重量" prop="total_qty">
<label slot="label">总&nbsp;&nbsp;重&nbsp;量:</label>
<el-input-number
v-model="form.total_qty"
:controls="false"
:precision="3"
:min="0"
disabled
style="width: 210px"
/>
</el-form-item>
<el-form-item label="业务日期" prop="biz_date">
<el-date-picker
v-model="form.biz_date"
type="date"
placeholder="选择日期"
style="width: 210px"
value-format="yyyy-MM-dd"
:disabled="crud.status.view > 0"
/>
</el-form-item>
<el-form-item label="备注" prop="remark">
<label slot="label">备&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;注:</label>
<el-input
v-model="form.remark"
style="width: 380px;"
rows="2"
type="textarea"
:disabled="crud.status.view > 0"
/>
</el-form-item>
</el-form>
<el-card class="box-card" shadow="never" :body-style="{padding:'20px 20px 0 20px'}" style="margin-top: 5px;">
<el-form ref="form2" :inline="true" :model="form" :rules="rules" size="mini">
<el-form-item label="不合格品缺陷描述" prop="dtl_remark">
<el-input v-model="form.dtl_remark" :disabled="crud.status.view > 0" class="input-with-select"/>
</el-form-item>
<!-- <el-form-item label="不合格品来源" prop="fail_source">
<el-select
v-model="form.fail_source"
class="input-with-select"
style="width: 210px"
:disabled="crud.status.view > 0"
>
<el-option
v-for="item in dict.FAIL_SOURCE"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>-->
</el-form>
<el-button class="filter-item" :disabled="crud.status.view > 0" @click="allSend()" size="medium" icon="el-icon-plus" style="float: right; padding: 3px 0" type="warning">填充</el-button>
</el-card>
<div class="crud-opts2">
<span class="role-span">不合格品明细</span>
<span v-if="crud.status.cu > 0" class="crud-opts-right2">
<!--左侧插槽-->
<slot name="left"/>
<el-button
slot="left"
class="filter-item"
type="primary"
icon="el-icon-plus"
size="mini"
@click="queryDtl()"
>
添加库存物料
</el-button>
</span>
</div>
<!--表格渲染-->
<el-table
ref="table"
:data="form.tableData"
style="width: 100%;"
border
:header-cell-style="{background:'#f5f7fa',color:'#606266'}"
>
<el-table-column key="1" type="index" label="序号" width="50" align="center" />
<el-table-column key="3" prop="material_code" label="产品编码" width="150" align="center" />
<el-table-column key="4" prop="material_name" label="产品名称" align="center" min-width="200" />
<el-table-column key="5" prop="storagevehicle_code" label="木箱号" align="center" min-width="150" />
<el-table-column key="6" prop="pcsn" label="不合格品批次号" align="center" min-width="150" />
<el-table-column
key="10"
prop="qty"
label="不合格品重量(kg)"
:formatter="crud.formatNum3"
width="140"
align="center"
/>
<el-table-column key="7" width="150" prop="fail_source" label="不合格品来源">
<template scope="scope">
<el-select
v-model="scope.row.fail_source"
class="input-with-select"
@input="custNameInput2(form.tableData[scope.$index])"
:disabled="crud.status.view > 0"
>
<el-option
v-for="item in dict.FAIL_SOURCE"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</template>
</el-table-column>
<el-table-column key="8" width="150" prop="remark" label="不合格品缺陷描述">
<template scope="scope">
<el-input v-model="scope.row.remark" @input="custNameInput(form.tableData[scope.$index])" :disabled="crud.status.view > 0" class="input-with-select" />
</template>
</el-table-column>
<el-table-column width="150" label="是否填充" v-if="crud.status.cu > 0">
<template scope="scope">
<el-switch v-model="scope.row.is_used" @change="changeIsUsed(scope.row)" active-color="#13ce66" inactive-color="#ff4949" active-value="1" inactive-value="0" />
</template>
</el-table-column>
<el-table-column v-if="crud.status.cu > 0" align="center" label="操作" width="170" fixed="right">
<template scope="scope">
<el-button
type="danger"
class="filter-item"
size="mini"
icon="el-icon-delete"
@click.native.prevent="deleteRow(scope.$index, form.tableData)"
/>
</template>
</el-table-column>
</el-table>
<AddDtl :dialog-show.sync="dtlShow" :stor-id="storId" @tableChanged="tableChanged"/>
<StructDiv ref="child" :dialog-show.sync="structShow" @tableChanged="structChanged"/>
</el-dialog>
</template>
<script>
import CRUD, { crud, form } from '@crud/crud'
import AddDtl from '@/views/wms/st/inStor/productscrap/AddDtl'
import productscrap from '@/views/wms/st/inStor/productscrap/productscrap'
import StructDiv from '@/views/wms/pub/StructDialog'
import crudUserStor from '@/views/wms/basedata/st/userStor/userStor'
const defaultForm = {
bill_code: '',
stor_id: '',
stor_code: '',
stor_name: '',
bill_status: '10',
total_qty: '0',
detail_count: '0',
remark: '',
fail_source: '',
biz_date: new Date(),
dtl_remark: '',
tableData: []
}
export default {
name: 'AddDialog',
components: { AddDtl, StructDiv },
mixins: [crud(), form(defaultForm)],
props: {
dialogShow: {
type: Boolean,
default: false
}
},
dicts: ['SCRAP_STATUS', 'FAIL_SOURCE'],
data() {
return {
dialogVisible: false,
dtlShow: false,
structShow: false,
structShow2: false,
flagnow: false,
nowrow: {},
nowindex: '',
storlist: [],
invtypelist: [],
storId: null,
rules: {
stor_id: [
{ required: true, message: '仓库不能为空', trigger: 'blur' }
],
bill_type: [
{ required: true, message: '业务类型不能为空', trigger: 'blur' }
],
biz_date: [
{ required: true, message: '业务日期不能为空', trigger: 'blur' }
]
}
}
},
watch: {
dialogShow: {
handler(newValue) {
this.dialogVisible = newValue
}
}
},
methods: {
open() {
crudUserStor.getUserStor().then(res => {
this.storlist = res
})
},
close() {
this.$emit('AddChanged')
},
[CRUD.HOOK.afterToEdit]() {
productscrap.getOutBillDtl({ 'scrap_id': this.form.scrap_id }).then(res => {
this.form.tableData = res
// 将明细变成不可编辑
for (let i = 0; i < this.form.tableData.length; i++) {
const row = this.form.tableData[i]
this.$set(row, 'edit', true)
this.form.tableData.splice(i, 1, row)
}
})
},
[CRUD.HOOK.afterToView]() {
productscrap.getOutBillDtl({ 'scrap_id': this.form.scrap_id }).then(res => {
this.form.tableData = res
// 将明细变成不可编辑
for (let i = 0; i < this.form.tableData.length; i++) {
const row = this.form.tableData[i]
this.$set(row, 'edit', true)
this.form.tableData.splice(i, 1, row)
}
})
},
storChange(row) {
this.storlist.forEach((item) => {
if (item.stor_id === row) {
this.form.stor_code = item.stor_code
this.form.stor_name = item.stor_name
}
})
},
custNameInput(val) {
for (let i = 0; i < this.form.tableData.length; i++) {
if (this.form.tableData[i].storagevehicle_code === val.storagevehicle_code) {
this.$set(this.form.tableData[i], 'remark', val.remark)
this.form.tableData.splice(i, 1, this.form.tableData[i]) // 通过splice 替换数据 触发视图更新
}
}
},
custNameInput2(val) {
for (let i = 0; i < this.form.tableData.length; i++) {
if (this.form.tableData[i].storagevehicle_code === val.storagevehicle_code) {
this.$set(this.form.tableData[i], 'fail_source', val.fail_source)
this.form.tableData.splice(i, 1, this.form.tableData[i]) // 通过splice 替换数据 触发视图更新
}
}
},
async queryDtl() {
if (!this.form.stor_id) {
return this.crud.notify('请先选择仓库!', CRUD.NOTIFICATION_TYPE.INFO)
}
this.storId = this.form.stor_id
this.dtlShow = true
},
allSend() {
if (this.form.tableData.length === 0) {
this.crud.notify('请至少选择一条明细', CRUD.NOTIFICATION_TYPE.INFO)
return false
}
for (let i = 0; i < this.form.tableData.length; i++) {
// this.$set(this.form.tableData[i], 'fail_source', this.form.fail_source)
if (this.form.tableData[i].is_used === '1') {
this.$set(this.form.tableData[i], 'remark', this.form.dtl_remark)
this.form.tableData.splice(i, 1, this.form.tableData[i]) // 通过splice 替换数据 触发视图更新
}
}
},
tableChanged(rows) {
const tablemap = new Map()
rows.forEach((item) => {
if (this.form.tableData.length !== 0) {
this.flagnow = false
for (let i = 0; i < this.form.tableData.length; i++) {
if (this.form.tableData[i].stockrecord_id === item.stockrecord_id) {
this.flagnow = true
}
}
if (!this.flagnow) {
this.$set(item, 'edit', false)
this.$set(item, 'work_status', '10')
this.$set(item, 'turnin_sect_id', '')
this.$set(item, 'turnin_struct_id', '')
this.$set(item, 'turnin_sect_code', '')
this.$set(item, 'turnin_sect_name', '')
this.$set(item, 'turnin_struct_code', '')
this.$set(item, 'turnin_struct_name', '')
tablemap.set(item.stockrecord_id, item)
}
} else {
this.$set(item, 'edit', false)
this.$set(item, 'work_status', '10')
this.$set(item, 'turnin_sect_id', '')
this.$set(item, 'turnin_struct_id', '')
this.$set(item, 'turnin_sect_code', '')
this.$set(item, 'turnin_sect_name', '')
this.$set(item, 'turnin_struct_code', '')
this.$set(item, 'turnin_struct_name', '')
tablemap.set(item.stockrecord_id, item)
}
})
for (const value of tablemap.values()) {
this.form.tableData.push(value)
}
this.form.detail_count = this.form.tableData.length
},
structChanged(row) {
debugger
let structflag = false
for (let i = 0; i < this.form.tableData.length; i++) {
if ((this.form.tableData[i].turnin_struct_id === row.struct_id) || (this.form.tableData[i].turnout_struct_id === row.struct_id)) {
structflag = true
}
}
if (structflag) {
this.crud.notify('该货位已被设置,不允许重复设置!', CRUD.NOTIFICATION_TYPE.INFO)
return false
}
for (let i = 0; i < this.form.tableData.length; i++) {
if (this.form.tableData[i].storagevehicle_code === this.nowrow.storagevehicle_code) {
this.form.tableData[i].turnin_struct_id = row.struct_id
this.form.tableData[i].turnin_struct_code = row.struct_code
this.form.tableData[i].turnin_struct_name = row.struct_name
this.form.tableData[i].turnin_sect_id = row.sect_id
this.form.tableData[i].turnin_sect_code = row.sect_code
this.form.tableData[i].turnin_sect_name = row.sect_name
this.form.tableData.splice(i, 1, this.form.tableData[i]) // 通过splice 替换数据 触发视图更新
}
}
console.log(this.form.tableData)
},
deleteRow(index, rows) {
const storagevehicle_code = rows[index].storagevehicle_code
let len = rows.length
while (len--) {
const obj = rows[len]
if (storagevehicle_code === obj.storagevehicle_code) {
const index = rows.indexOf(obj)
if (index > -1) { // 移除找到的指定元素
this.form.total_qty = parseFloat(this.form.total_qty) - parseFloat(rows[index].qty)
rows.splice(index, 1)
this.nowindex = ''
this.nowrow = {}
this.form.detail_count = this.form.tableData.length
}
}
}
},
[CRUD.HOOK.beforeSubmit]() {
if (this.form.tableData.length === 0) {
this.crud.notify('请至少选择一条明细', CRUD.NOTIFICATION_TYPE.INFO)
return false
}
for (let i = 0; i < this.form.tableData.length; i++) {
const row = this.form.tableData[i]
if (!row.fail_source) {
this.crud.notify('请选择不合格来源', CRUD.NOTIFICATION_TYPE.INFO)
return false
}
}
},
changeIsUsed(item) {
for (let i = 0; i < this.form.tableData.length; i++) {
const row = this.form.tableData[i]
if (item.storagevehicle_code === row.storagevehicle_code) {
row.is_used = item.is_used
this.form.tableData.splice(i, 1, this.form.tableData[i])
}
}
}
}
}
</script>
<style>
.crud-opts2 {
padding: 0 0;
display: -webkit-flex;
display: flex;
align-items: center;
}
.crud-opts2 .crud-opts-right2 {
margin-left: auto;
padding: 4px 4px;
}
.input-with-select {
background-color: #fff;
}
</style>
<style rel="stylesheet/scss" lang="scss" scoped>
::v-deep .el-dialog__body {
padding-top: 10px;
}
</style>

View File

@@ -0,0 +1,231 @@
<template>
<el-dialog
title="库存物料选择"
append-to-body
:visible.sync="dialogVisible"
destroy-on-close
:show-close="false"
width="1300px"
@close="close"
@open="open"
>
<el-row style="padding-bottom: 5px;">
<el-col :span="6">
<!-- 搜索 -->
<el-cascader
placeholder="库区"
:options="sects"
:props="{ checkStrictly: true }"
style="width: 200px;"
clearable
@change="sectQueryChange"
/>
</el-col>
<el-col :span="6">
<el-input
v-model="query.remark"
clearable
size="mini"
placeholder="物料"
style="width: 200px;"
class="filter-item"
@keyup.enter.native="crud.toQuery"
/>
</el-col>
<el-col :span="6">
<el-input
v-model="query.package_box_sn"
clearable
size="mini"
placeholder="木箱码"
style="width: 200px;"
class="filter-item"
@keyup.enter.native="crud.toQuery"
/>
</el-col>
<el-col :span="6">
<el-input
v-model="query.pcsn"
clearable
size="mini"
placeholder="子卷批次"
style="width: 200px;"
class="filter-item"
@keyup.enter.native="crud.toQuery"
/>
</el-col>
</el-row>
<el-row style="padding-bottom: 5px;">
<el-col :span="6">
<el-input
v-model="query.sap_pcsn"
clearable
size="mini"
placeholder="SAP批次"
style="width: 200px;"
class="filter-item"
@keyup.enter.native="crud.toQuery"
/>
</el-col>
<el-col :span="6">
<el-input
v-model="query.sale_order_name"
clearable
size="mini"
placeholder="销售订单号"
style="width: 200px;"
class="filter-item"
@keyup.enter.native="crud.toQuery"
/>
</el-col>
<el-col :span="6" :offset="6">
<rrOperation />
</el-col>
</el-row>
<!--表格渲染-->
<el-table
ref="table"
v-loading="crud.loading"
:data="crud.data"
style="width: 100%;"
border
:header-cell-style="{background:'#f5f7fa',color:'#606266'}"
>
<el-table-column type="selection" width="55" />
<el-table-column show-overflow-tooltip prop="turnout_sect_name" label="库区"/>
<el-table-column show-overflow-tooltip prop="turnout_struct_code" label="货位" width="110px" />
<el-table-column show-overflow-tooltip prop="storagevehicle_code" width="250" label="载具号" />
<el-table-column show-overflow-tooltip prop="material_code" label="物料编码" width="150px" />
<el-table-column show-overflow-tooltip prop="material_name" label="物料名称" width="110px" />
<el-table-column show-overflow-tooltip prop="pcsn" label="子卷号" width="150" />
<el-table-column show-overflow-tooltip prop="sap_pcsn" label="SAP批次" width="120" />
<el-table-column show-overflow-tooltip prop="sale_order_name" width="150px" label="销售订单及批次" />
<el-table-column show-overflow-tooltip prop="customer_name" label="客户编码" />
<el-table-column show-overflow-tooltip prop="customer_description" label="客户描述" width="150"/>
<el-table-column show-overflow-tooltip prop="qty" label="重量" :formatter="crud.formatNum3" width="110px" />
<el-table-column show-overflow-tooltip prop="qty_unit_name" label="重量单位" />
</el-table>
<!--分页组件-->
<pagination />
<span slot="footer" class="dialog-footer">
<el-button slot="left" type="info" @click="dialogVisible = false">关闭</el-button>
<el-button slot="left" type="primary" @click="submit">保存</el-button>
</span>
</el-dialog>
</template>
<script>
import CRUD, { header, presenter } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import pagination from '@crud/Pagination'
import crudUserStor from '@/views/wms/basedata/st/userStor/userStor'
import handmovestor from '@/views/wms/st/inStor/moveStor/handmovestor'
export default {
name: 'AddDtl',
components: { rrOperation, pagination },
cruds() {
return CRUD({ title: '用户', idField: 'stockrecord_id', url: 'api/handmovestor/getStructIvt',
query: {
struct_code: '',
remark: '',
sect_id: '',
stor_id: ''
},
optShow: {
add: false,
edit: false,
del: false,
reset: true,
download: false
}})
},
mixins: [presenter(), header()],
props: {
dialogShow: {
type: Boolean,
default: false
},
openParam: {
type: String
},
storId: {
type: String
}
},
dicts: ['ST_QUALITY_SCODE', 'ST_IVT_LEVEL', 'is_usable'],
data() {
return {
dialogVisible: false,
opendtlParam: '',
sects: [],
rows: []
}
},
watch: {
dialogShow: {
handler(newValue, oldValue) {
this.dialogVisible = newValue
}
},
openParam: {
handler(newValue, oldValue) {
this.opendtlParam = newValue
}
}
},
methods: {
[CRUD.HOOK.beforeRefresh]() {
this.crud.query.stor_id = this.storId
},
open() {
crudUserStor.getSect({ 'stor_id': this.storId }).then(res => {
this.sects = res.content
})
this.crud.toQuery()
},
close() {
this.crud.resetQuery(false)
this.$emit('update:dialogShow', false)
},
quality_scodeFormat(row, column) {
return this.dict.label.ST_QUALITY_SCODE[row.quality_scode]
},
ivt_levelFormat(row, column) {
return this.dict.label.ST_IVT_LEVEL[row.ivt_level]
},
is_activeFormat(row, column) {
return this.dict.label.is_usable[row.is_active]
},
sectQueryChange(val) {
if (val.length === 1) {
this.crud.query.stor_id = val[0]
this.crud.query.sect_id = ''
}
if (val.length === 0) {
this.crud.query.sect_id = ''
this.crud.query.stor_id = ''
}
if (val.length === 2) {
this.crud.query.stor_id = val[0]
this.crud.query.sect_id = val[1]
}
},
submit() {
this.rows = this.$refs.table.selection
if (this.rows.length <= 0) {
this.$message('请先勾选物料')
return
}
this.crud.resetQuery(false)
handmovestor.getBoxIvt(this.rows).then(res => {
this.rows = res
this.$emit('update:dialogShow', false)
this.$emit('tableChanged', this.rows)
})
}
}
}
</script>

View File

@@ -0,0 +1,290 @@
<template>
<div class="app-container">
<!--工具栏-->
<div class="head-container">
<div v-if="crud.props.searchToggle">
<!-- 搜索 -->
<el-form
:inline="true"
class="demo-form-inline"
label-position="right"
label-width="80px"
label-suffix=":"
>
<el-form-item label="模糊查询">
<el-input
v-model="query.bill_code"
size="mini"
clearable
placeholder="单据号"
@keyup.enter.native="crud.toQuery"
/>
</el-form-item>
<el-form-item label="所属仓库">
<el-select
v-model="query.stor_id"
clearable
size="mini"
placeholder="全部"
class="filter-item"
@change="crud.toQuery"
>
<el-option
v-for="item in storlist"
:key="item.stor_id"
:label="item.stor_name"
:value="item.stor_id"
/>
</el-select>
</el-form-item>
<el-form-item label="子卷号">
<el-input
v-model="query.pcsn"
size="mini"
clearable
placeholder="子卷号"
@keyup.enter.native="crud.toQuery"
/>
</el-form-item>
<el-form-item label="单据状态">
<el-select
v-model="query.bill_status"
clearable
size="mini"
placeholder="单据状态"
class="filter-item"
@change="crud.toQuery"
>
<el-option
v-for="item in dict.SCRAP_STATUS"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item label="创建时间">
<el-date-picker
v-model="query.createTime"
type="daterange"
value-format="yyyy-MM-dd HH:mm:ss"
start-placeholder="开始日期"
end-placeholder="结束日期"
:default-time="['00:00:00', '23:59:59']"
@change="crud.toQuery"
/>
</el-form-item>
<rrOperation />
</el-form>
</div>
<!--如果想在工具栏加入更多按钮可以使用插槽方式 slot = 'left' or 'right'-->
<crudOperation :permission="permission">
<el-button
slot="right"
class="filter-item"
type="warning"
:permission="permission"
:disabled="confirm_flag"
:loading="loading_button"
icon="el-icon-check"
size="mini"
@click="auditPass"
>
通过
</el-button>
<el-button
slot="right"
class="filter-item"
type="warning"
:permission="permission"
:disabled="confirm_flag"
icon="el-icon-close"
size="mini"
@click="auditOut"
>
不通过
</el-button>
</crudOperation>
<!--表格渲染-->
<el-table
ref="table"
v-loading="crud.loading"
size="mini"
:data="crud.data"
style="width: 100%;"
:highlight-current-row="true"
@selection-change="crud.selectionChangeHandler"
@current-change="handleCurrentChange"
@select="handleSelectionChange"
@select-all="onSelectAll"
>
<el-table-column
v-permission="['admin','ivtchange:del','ivtchange:edit']"
label="操作"
width="160"
align="center"
fixed="right"
>
<template slot-scope="scope">
<udOperation
:data="scope.row"
:permission="permission"
:disabled-edit="canUd(scope.row)"
:disabled-dle="canUd(scope.row)"
/>
</template>
</el-table-column>
<el-table-column :selectable="checkboxT" type="selection" />
<el-table-column prop="scrap_code" label="单据号" :min-width="flexWidth('scrap_code',crud.data,'单据号')">
<template slot-scope="scope">
<el-link type="warning" @click="crud.toView(scope.row)">{{ scope.row.scrap_code }}</el-link>
</template>
</el-table-column>
<el-table-column :formatter="stateFormat" prop="bill_status" label="单据状态" :min-width="flexWidth('bill_status',crud.data,'单据状态')"/>
<el-table-column prop="stor_name" label="仓库" :min-width="flexWidth('stor_name',crud.data,'仓库')"/>
<el-table-column prop="biz_date" label="业务日期" :min-width="flexWidth('biz_date',crud.data,'业务日期')"/>
<el-table-column label="明细数" prop="detail_count" :min-width="flexWidth('detail_count',crud.data,'明细数')"/>
<el-table-column label="总重量" prop="total_qty" :min-width="flexWidth('total_qty',crud.data,'总重量')"/>
<el-table-column prop="input_optname" label="创建人" :min-width="flexWidth('input_optname',crud.data,'创建人')"/>
<el-table-column prop="input_time" label="创建日期" :min-width="flexWidth('input_time',crud.data,'创建日期')"/>
<el-table-column prop="confirm_optname" label="确认人" :min-width="flexWidth('confirm_optname',crud.data,'确认人')"/>
<el-table-column prop="confirm_time" label="确认时间" :min-width="flexWidth('confirm_time',crud.data,'确认时间')"/>
<el-table-column prop="remark" label="备注" :min-width="flexWidth('remark',crud.data,'备注')"/>
</el-table>
<!--分页组件-->
<pagination />
</div>
<AddDialog @AddChanged="querytable" />
</div>
</template>
<script>
import productscrap from '@/views/wms/st/inStor/productscrap/productscrap'
import CRUD, { crud, header, presenter } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'
import AddDialog from '@/views/wms/st/inStor/productscrap/AddDialog'
import crudUserStor from '@/views/wms/basedata/st/userStor/userStor'
export default {
name: 'Productscrap',
components: { AddDialog, crudOperation, rrOperation, udOperation, pagination },
cruds() {
return CRUD({ title: '成品报废审核', idField: 'scrap_id', url: 'api/productscrap', crudMethod: { ...productscrap },
optShow: {
add: true,
edit: false,
del: false,
reset: true,
download: false
}})
},
mixins: [presenter(), header(), crud()],
// 数据字典
dicts: ['SCRAP_STATUS'],
data() {
return {
height: document.documentElement.clientHeight - 180 + 'px;',
permission: {},
work_flag: true,
confirm_flag: true,
mstrow: {},
currentRow: null,
loading_button: false,
storlist: []
}
},
mounted: function() {
const that = this
window.onresize = function temp() {
that.height = document.documentElement.clientHeight - 180 + 'px;'
}
},
created() {
crudUserStor.getUserStor().then(res => {
this.storlist = res
})
},
methods: {
canUd(row) {
return row.bill_status !== '10'
},
[CRUD.HOOK.beforeRefresh]() {
this.crud.query.buss_type = ''
this.handleCurrentChange(null)
},
stateFormat(row) {
return this.dict.label.SCRAP_STATUS[row.bill_status]
},
handleSelectionChange(val, row) {
if (val.length > 1) {
this.$refs.table.clearSelection()
this.$refs.table.toggleRowSelection(val.pop())
this.buttonChange(row)
} else if (val.length === 1) {
this.buttonChange(row)
} else {
this.handleCurrentChange(null)
}
},
onSelectAll() {
this.$refs.table.clearSelection()
this.handleCurrentChange(null)
},
buttonChange(current) {
if (current !== null) {
this.currentRow = current
if (current.bill_status === '10') {
this.work_flag = false
} else {
this.work_flag = true
}
if (current.bill_status !== '99') {
this.confirm_flag = false
} else {
this.confirm_flag = true
}
}
},
handleCurrentChange(current) {
if (current === null) {
this.confirm_flag = true
this.work_flag = true
this.currentRow = {}
}
},
checkboxT(row) {
return row.bill_status !== '99'
},
auditPass() {
this.loading_button = true
productscrap.auditPass(this.currentRow).then(res => {
this.crud.toQuery()
this.crud.notify('操作成功!', CRUD.NOTIFICATION_TYPE.SUCCESS)
this.loading_button = false
}).catch(() => {
this.loading_button = false
})
},
auditOut() {
productscrap.auditOut(this.currentRow).then(res => {
this.crud.toQuery()
this.crud.notify('操作成功!', CRUD.NOTIFICATION_TYPE.SUCCESS)
})
},
querytable() {
this.onSelectAll()
this.crud.toQuery()
this.handleCurrentChange(null)
}
}
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
::v-deep .el-dialog__body {
padding-top: 10px;
}
</style>

View File

@@ -0,0 +1,55 @@
import request from '@/utils/request'
export function add(data) {
return request({
url: 'api/productscrap',
method: 'post',
data
})
}
export function del(ids) {
return request({
url: 'api/productscrap/',
method: 'delete',
data: ids
})
}
export function edit(data) {
return request({
url: 'api/productscrap',
method: 'put',
data
})
}
export function getOutBillDtl(params) {
return request({
url: '/api/productscrap/getOutBillDtl',
method: 'get',
params
})
}
export function insertDtl(data) {
return request({
url: '/api/productscrap/insertDtl',
method: 'post',
data
})
}
export function auditPass(data) {
return request({
url: '/api/productscrap/auditPass',
method: 'post',
data
})
}
export function auditOut(data) {
return request({
url: '/api/productscrap/auditOut',
method: 'post',
data
})
}
export default { add, edit, del, getOutBillDtl, auditPass, auditOut }