Browse Source

更新工单操作

master
汪菘 3 years ago
parent
commit
ded098c9b7
  1. 4
      nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang/hailiang_feeding_trunk/HaiLiangFeedingTrunkDeviceDriver.java
  2. 63
      nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang/hailiang_feeding_trunk/ItemProtocol.java
  3. 56
      nladmin-system/src/main/java/org/nl/acs/order/rest/ProduceshiftorderController.java
  4. 50
      nladmin-system/src/main/java/org/nl/acs/order/service/ProduceshiftorderService.java
  5. 90
      nladmin-system/src/main/java/org/nl/acs/order/service/impl/ProduceshiftorderServiceImpl.java

4
nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang/hailiang_feeding_trunk/HaiLiangFeedingTrunkDeviceDriver.java

@ -34,7 +34,7 @@ public class HaiLiangFeedingTrunkDeviceDriver extends AbstractOpcDeviceDriver im
int order_detail = 0;
int last_mode = 0;
int last_order = order;
int ready = 0;
@Override
public void execute() throws Exception {
String message = null;
@ -44,7 +44,7 @@ public class HaiLiangFeedingTrunkDeviceDriver extends AbstractOpcDeviceDriver im
error = this.itemProtocol.getError();
order = this.itemProtocol.getOrder();
order_detail = this.itemProtocol.getOrder_detail();
ready = this.itemProtocol.getReady();
if (mode != last_mode) {
this.setRequireSucess(false);
}

63
nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang/hailiang_feeding_trunk/ItemProtocol.java

@ -40,6 +40,18 @@ public class ItemProtocol {
public static String item_detail_rlabeling_qty = "detail_rlabeling_qty";
//设备就绪
public static String item_ready = "ready";
public static String item_line_speed = "line_speed";
public static String item_feeding_mouth = "feeding_mouth";
public static String item_is_lettering = "is_lettering";
public static String item_is_risking = "is_risking";
public static String item_is_coating = "is_coating";
public static String item_is_strapping = "is_strapping";
public static String item_is_labeling = "is_labeling";
public static String item_delay_time = "delay_time";
public static String item_lettering_frequency = "lettering_frequency";
public static String item_one_speed = "one_speed";
public static String item_coating_frequency = "coating_frequency";
public static String item_to_heartbeat = "to_heartbeat";
public static String item_to_command = "to_command";
@ -156,6 +168,53 @@ public class ItemProtocol {
return this.getOpcIntegerValue(item_ready);
}
public int getLline_speed() {
return this.getOpcIntegerValue(item_line_speed);
}
public int getFeeding_mouth() {
return this.getOpcIntegerValue(item_feeding_mouth);
}
public int getIs_lettering() {
return this.getOpcIntegerValue(item_is_lettering);
}
public int getIs_risking() {
return this.getOpcIntegerValue(item_is_risking);
}
public int getIs_coating() {
return this.getOpcIntegerValue(item_is_coating);
}
public int getIs_strapping() {
return this.getOpcIntegerValue(item_is_strapping);
}
public int getIs_labeling() {
return this.getOpcIntegerValue(item_is_labeling);
}
public int getDelay_time() {
return this.getOpcIntegerValue(item_delay_time);
}
public int getLettering_frequency() {
return this.getOpcIntegerValue(item_lettering_frequency);
}
public int getOne_speed() {
return this.getOpcIntegerValue(item_one_speed);
}
public int getCoating_frequency() {
return this.getOpcIntegerValue(item_coating_frequency);
}
public int getTo_heartbeat() {
return this.getOpcIntegerValue(item_to_heartbeat);
}
@ -337,7 +396,7 @@ public class ItemProtocol {
list.add(new ItemDto(item_to_command, "反馈命令", "DB610.D54", Boolean.valueOf(true)));
list.add(new ItemDto(item_to_stop, "急停", "DB610.D58"));
list.add(new ItemDto(item_to_clear, "清料", "DB610.D62"));
list.add(new ItemDto(item_to_pause, "复位\\暂停", "DB610.D66"));
list.add(new ItemDto(item_to_pause, "复位暂停", "DB610.D66"));
list.add(new ItemDto(item_to_order_detail_complete, "工单明细强制完成", "DB610.D70"));
list.add(new ItemDto(item_to_order_complete, "工单强制完成", "DB610.D74"));
list.add(new ItemDto(item_to_line_speed, "线体速度", "DB610.REAL78"));
@ -349,7 +408,7 @@ public class ItemProtocol {
list.add(new ItemDto(item_to_is_labeling, "是否贴标", "DB610.D102"));
list.add(new ItemDto(item_to_delay_time, "工段动作延时", "DB610.D106"));
list.add(new ItemDto(item_to_lettering_frequency, "刻字频率", "DB610.D110"));
list.add(new ItemDto(item_to_one_speed, "捆扎\\裹膜\\贴标段输送速度", "DB610.REAL114"));
list.add(new ItemDto(item_to_one_speed, "捆扎裹膜贴标段输送速度", "DB610.REAL114"));
list.add(new ItemDto(item_to_coating_frequency, "裹膜机频率", "DB610.D118"));
return list;
}

56
nladmin-system/src/main/java/org/nl/acs/order/rest/ProduceshiftorderController.java

@ -40,6 +40,15 @@ public class ProduceshiftorderController {
return new ResponseEntity<>(produceshiftorderService.queryAll(whereJson, page), HttpStatus.OK);
}
@GetMapping(value = "/querySorting")
@Log("查询分拣工单")
@ApiOperation("查询分拣工单")
//@PreAuthorize("@el.check('produceshiftorder:list')")
public ResponseEntity<Object> querySorting(@RequestParam Map whereJson, Pageable page) {
return new ResponseEntity<>(produceshiftorderService.querySorting(whereJson, page), HttpStatus.OK);
}
@Log("查询工单明细")
@ApiOperation("查询工单")
@GetMapping(value = "/getDtl")
@ -75,15 +84,54 @@ public class ProduceshiftorderController {
return new ResponseEntity<>(HttpStatus.OK);
}
@Log("下发工单")
@Log("工单分拣")
@ApiOperation("下发工单")
//@PreAuthorize("@el.check('produceshiftorder:del')")
@DeleteMapping
@PostMapping(value = "/工单分拣")
public ResponseEntity<Object> send(@RequestBody String id) {
produceshiftorderService.send(id);
return new ResponseEntity<>(HttpStatus.OK);
}
@Log("设备暂停")
@ApiOperation("设备暂停")
@PostMapping(value = "/device_pause")
public ResponseEntity<Object> device_pause() {
produceshiftorderService.device_pause();
return new ResponseEntity<>(HttpStatus.OK);
}
@Log("清料")
@ApiOperation("清料")
@PostMapping(value = "/clear")
public ResponseEntity<Object> clear() {
produceshiftorderService.clear();
return new ResponseEntity<>(HttpStatus.OK);
}
@Log("工单暂停")
@ApiOperation("工单暂停")
@PostMapping(value = "/order_pause")
public ResponseEntity<Object> order_pause(@RequestBody String id) {
produceshiftorderService.order_pause(id);
return new ResponseEntity<>(HttpStatus.OK);
}
@Log("工单强制完成")
@ApiOperation("工单强制完成")
@PostMapping(value = "/order_force_complete")
public ResponseEntity<Object> order_force_complete(@RequestBody String id) {
produceshiftorderService.order_force_complete(id);
return new ResponseEntity<>(HttpStatus.OK);
}
@Log("工单明细强制完成")
@ApiOperation("工单明细强制完成")
@PostMapping(value = "/detail_force_complete")
public ResponseEntity<Object> detail_force_complete(@RequestBody String id) {
produceshiftorderService.detail_force_complete(id);
return new ResponseEntity<>(HttpStatus.OK);
}
@Log("导出工单")
@ApiOperation("导出工单")
@GetMapping(value = "/download")
@ -101,4 +149,6 @@ public class ProduceshiftorderController {
}
}

50
nladmin-system/src/main/java/org/nl/acs/order/service/ProduceshiftorderService.java

@ -28,6 +28,16 @@ public interface ProduceshiftorderService {
*/
Map<String, Object> queryAll(Map whereJson, Pageable page);
/**
* 查询数据分页
*
* @param whereJson 条件
* @param page 分页参数
* @return Map<String, Object>
*/
Map<String, Object> querySorting(Map whereJson, Pageable page);
/**
* 查询所有数据不分页
*
@ -101,6 +111,46 @@ public interface ProduceshiftorderService {
*/
void send(String id);
/**
* 设备暂停
*
*/
void device_pause();
/**
* 清料
*
*/
void clear();
/**
* 工单暂停
*
* @param id /
*/
void order_pause(String id);
/**
* 工单强制完成
*
* @param id /
*/
void order_force_complete(String id);
/**
* 工单明细强制完成
*
* @param id /
*/
void detail_force_complete(String id);
/**
* 取消任务
*

90
nladmin-system/src/main/java/org/nl/acs/order/service/impl/ProduceshiftorderServiceImpl.java

@ -10,6 +10,12 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.device_driver.electric_fence.ElectricFenceDeviceDriver;
import org.nl.acs.device_driver.hailiang.hailiang_feeding_trunk.HaiLiangFeedingTrunkDeviceDriver;
import org.nl.acs.opc.Device;
import org.nl.acs.opc.DeviceAppService;
import org.nl.acs.opc.DeviceAppServiceImpl;
import org.nl.acs.opc.DeviceType;
import org.nl.acs.order.service.ProduceshiftorderService;
import org.nl.acs.order.service.dto.CustomerbaseDto;
import org.nl.acs.order.service.dto.ProduceshiftorderDto;
@ -19,6 +25,7 @@ import org.nl.exception.BadRequestException;
import org.nl.modules.system.util.CodeUtil;
import org.nl.start.auto.initial.ApplicationAutoInitial;
import org.nl.utils.SecurityUtils;
import org.nl.utils.SpringContextHolder;
import org.nl.wql.WQL;
import org.nl.wql.core.bean.ResultBean;
import org.nl.wql.core.bean.WQLObject;
@ -54,14 +61,17 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A
private final MongoTemplate mongoTemplate;
DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
@Override
public void autoInitial() throws Exception {
this.reload();
}
public synchronized void reload() {
this.order = this.queryAllOrder("order_status <2 and is_deleted =0");
this.detail = this.queryAllOrderDteail("order_detail_status <2 and is_deleted =0");
this.order = this.queryAllOrder("(order_status !='04' or order_status !='05' ) and is_deleted =0");
this.detail = this.queryAllOrderDteail(" (order_detail_status != '04' or order_detail_status != '05') and is_deleted =0");
}
@Override
@ -278,16 +288,31 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A
@Transactional(rollbackFor = Exception.class)
public void send(String id) {
ProduceshiftorderDto entity = this.findById(id);
if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!");
entity.setIs_deleted("1");
WQLObject wo = WQLObject.getWQLObject("acs_produceshiftorder");
JSONObject json= (JSONObject) JSONObject.toJSON(entity);
wo.update(json);
if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!");
if(!StrUtil.equals(entity.getOrder_status(),"00")){
throw new BadRequestException("该工单非就绪状态,无法下发!");
}
JSONObject checkone = wo.query("order_status = '01' ").uniqueResult(0);
if(!ObjectUtil.isEmpty(checkone)){
throw new BadRequestException("存在已确认的工单,请先暂停或完成!");
}
HashMap<String, String> map = new HashMap<>();
map.put("is_deleted","1");
WQLObject.getWQLObject("acs_produceshiftorderdetail").update(map,"order_id = '"+ id + "'");
HaiLiangFeedingTrunkDeviceDriver haiLiangFeedingTrunkDeviceDriver;
List<Device> deviceAll = deviceAppService.findDevice(DeviceType.conveyor);
for(int i=0;i<deviceAll.size();i++){
Device device = deviceAll.get(0);
if (device.getDeviceDriver() instanceof HaiLiangFeedingTrunkDeviceDriver) {
haiLiangFeedingTrunkDeviceDriver = (HaiLiangFeedingTrunkDeviceDriver) device.getDeviceDriver();
if(haiLiangFeedingTrunkDeviceDriver.getReady() != 1){
throw new BadRequestException("设备未就绪,无法下发!");
}
}
}
entity.setOrder_status("01");
JSONObject json= (JSONObject) JSONObject.toJSON(entity);
wo.update(json);
}
@ -309,4 +334,51 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A
return arr;
}
@Override
public Map<String, Object> querySorting(Map whereJson, Pageable page) {
WQLObject wo = WQLObject.getWQLObject("acs_produceshiftorder");
String where = "1=1 and (order_status !='00' or order_status !='04' or order_status !='05' ) and is_deleted= '0'";
ResultBean rb = wo.pagequery(WqlUtil.getHttpContext(page), where, "order_id desc");
final JSONObject json = rb.pageResult();
JSONArray newja = new JSONArray();
JSONArray ja = json.getJSONArray("content");
for (int i = 0; i < ja.size(); i++) {
JSONObject jo = (JSONObject) ja.get(i);
JSONArray orderDteail_ja = WQLObject.getWQLObject("acs_produceshiftorderdetail").query("is_deleted= '0' and order_id ='" + jo.getString("order_id") + "'").getResultJSONArray(0);
if (orderDteail_ja.size() > 0) {
JSONArray children = new JSONArray();
for (int j = 0; j < orderDteail_ja.size(); j++) {
JSONObject orderDteail_jo = orderDteail_ja.getJSONObject(j);
JSONObject new_jo = new JSONObject();
new_jo.put("order_id", orderDteail_jo.getString("order_detail_id"));
new_jo.put("order_code", orderDteail_jo.getString("order_detail_code"));
new_jo.put("order_status", orderDteail_jo.getString("order_detail_status"));
new_jo.put("is_active", orderDteail_jo.getString("is_active"));
new_jo.put("is_delete", orderDteail_jo.getString("is_delete"));
new_jo.put("create_by", orderDteail_jo.getString("create_by"));
new_jo.put("create_time", orderDteail_jo.getString("create_time"));
new_jo.put("update_by", orderDteail_jo.getString("update_by"));
new_jo.put("update_time", orderDteail_jo.getString("update_time"));
new_jo.put("cust_id", orderDteail_jo.getString("cust_id"));
new_jo.put("cust_code", orderDteail_jo.getString("cust_code"));
new_jo.put("cust_name", orderDteail_jo.getString("cust_name"));
new_jo.put("qty", orderDteail_jo.getString("order_detail_qty"));
new_jo.put("type", "orderDteail");
jo.put("is_flag", "0");
children.add(new_jo);
}
jo.put("children", children);
}
jo.put("type", "order");
//区分工单明细
jo.put("is_flag", "1");
newja.add(jo);
}
json.put("content", newja);
System.out.println("json:" + json);
return json;
}
}
Loading…
Cancel
Save