diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang/hailiang_feeding_trunk/HaiLiangFeedingTrunkDeviceDriver.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang/hailiang_feeding_trunk/HaiLiangFeedingTrunkDeviceDriver.java index 641d041..d06d964 100644 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang/hailiang_feeding_trunk/HaiLiangFeedingTrunkDeviceDriver.java +++ b/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang/hailiang_feeding_trunk/HaiLiangFeedingTrunkDeviceDriver.java @@ -10,8 +10,11 @@ import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; import org.nl.acs.opc.Device; import org.nl.acs.order.service.ProduceshiftorderService; +import org.nl.acs.order.service.ProduceshiftorderdetailService; import org.nl.acs.order.service.dto.ProduceshiftorderDto; +import org.nl.acs.order.service.dto.ProduceshiftorderdetailDto; import org.nl.exception.BadRequestException; +import org.nl.utils.SpringContextHolder; import org.openscada.opc.lib.da.Server; import org.springframework.beans.factory.annotation.Autowired; @@ -28,7 +31,10 @@ public class HaiLiangFeedingTrunkDeviceDriver extends AbstractOpcDeviceDriver im protected ItemProtocol itemProtocol = new ItemProtocol(this); @Autowired - ProduceshiftorderService produceshiftorderService; + ProduceshiftorderService produceshiftorderService = SpringContextHolder.getBean(ProduceshiftorderService.class); + + @Autowired + ProduceshiftorderdetailService produceshiftorderdetailService = SpringContextHolder.getBean(ProduceshiftorderdetailService.class); @Override public Device getDevice() { @@ -47,6 +53,8 @@ public class HaiLiangFeedingTrunkDeviceDriver extends AbstractOpcDeviceDriver im int ready = 0; int pause = 0; int clear = 0; + Boolean send_letter_flag_back = false; + Boolean send_letter_flag = false; @Override public void execute() throws Exception { @@ -88,11 +96,15 @@ public class HaiLiangFeedingTrunkDeviceDriver extends AbstractOpcDeviceDriver im break; case 3: //申请工单 - apply_order(); + if(!requireSucess && ready == 1 ){ + apply_order(); + } break; case 4: //申请工单明细 - apply_orderDetail(); + if(!requireSucess && ready == 1 && order != 0 ) { + apply_orderDetail(order); + } break; } } @@ -120,6 +132,7 @@ public class HaiLiangFeedingTrunkDeviceDriver extends AbstractOpcDeviceDriver im String wall_thickness = dto.getWall_thickness(); String length = dto.getLength(); String qty = dto.getQty(); + writing(ItemProtocol.item_to_order,order); writing(ItemProtocol.item_to_order_feeding_qty,qty); writing(ItemProtocol.item_to_outer_diameter,outer_diameter); @@ -130,14 +143,52 @@ public class HaiLiangFeedingTrunkDeviceDriver extends AbstractOpcDeviceDriver im writing(ItemProtocol.item_to_is_strapping,is_strapping); writing(ItemProtocol.item_to_is_coating,is_coating); writing(ItemProtocol.item_to_is_lettering,is_lettering); + writing(ItemProtocol.item_to_command,String.valueOf(mode)); + dto.setOrder_status("02"); produceshiftorderService.update(dto); - + requireSucess = true; return true; } - public boolean apply_orderDetail() throws Exception { + public boolean apply_orderDetail(int order) throws Exception { + ProduceshiftorderdetailDto dto = produceshiftorderdetailService.apply_orderDetail(String.valueOf(order)); + if(ObjectUtil.isEmpty(dto)){ + throw new BadRequestException("未找到可下发工单明细!"); + } + String orderDetail = dto.getOrder_detail_code(); + String feeding_qty = dto.getFeeding_qty(); + String strap_pack_number = dto.getStrap_pack_number(); + String strap_number = dto.getStrap_number(); + String str = dto.getLabeling_message(); + //判断是否最后一个客户 + boolean last_detail = produceshiftorderdetailService.isLastOrderDetail(String.valueOf(order)); + + //下发激光刻字信息 + //判断下发刻字成功 + if(!send_letter_flag){ + send_letter_flag = produceshiftorderdetailService.sendLetteringMess(str); + } + if(send_letter_flag_back) { + if(last_detail){ + writing(ItemProtocol.item_to_is_last,"1"); + } else { + writing(ItemProtocol.item_to_is_last,"0"); + } + writing(ItemProtocol.item_to_order_detail,orderDetail); + writing(ItemProtocol.item_to_detail_feeding_qty,feeding_qty); + writing(ItemProtocol.item_to_strapping_qty,strap_pack_number); + writing(ItemProtocol.item_to_one_strapping_qty,strap_number); + writing(ItemProtocol.item_to_coating_qty,strap_pack_number); + writing(ItemProtocol.item_to_labeling_qty,strap_pack_number); + writing(ItemProtocol.item_to_command,String.valueOf(mode)); + dto.setOrder_detail_status("01"); + produceshiftorderdetailService.update(dto); + send_letter_flag = false; + send_letter_flag_back = false; + requireSucess = true; + } return true; } @@ -148,7 +199,7 @@ public class HaiLiangFeedingTrunkDeviceDriver extends AbstractOpcDeviceDriver im String opcservcerid = this.getDevice().getOpc_server_id(); Server server = ReadUtil.getServer(opcservcerid); Map itemMap = new HashMap(); - itemMap.put(to_param, Integer.parseInt(value)); + itemMap.put(to_param, Double.parseDouble(value)); ReadUtil.write(itemMap, server); } diff --git a/nladmin-system/src/main/java/org/nl/acs/order/rest/ProduceshiftorderdetailController.java b/nladmin-system/src/main/java/org/nl/acs/order/rest/ProduceshiftorderdetailController.java new file mode 100644 index 0000000..4a13bf1 --- /dev/null +++ b/nladmin-system/src/main/java/org/nl/acs/order/rest/ProduceshiftorderdetailController.java @@ -0,0 +1,76 @@ + +package org.nl.acs.order.rest; + + +import org.nl.acs.order.service.ProduceshiftorderdetailService; +import org.nl.acs.order.service.dto.ProduceshiftorderdetailDto; +import org.springframework.data.domain.Pageable; +import lombok.RequiredArgsConstructor; +import org.nl.annotation.Log; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import io.swagger.annotations.*; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; +import java.util.Map; +import lombok.extern.slf4j.Slf4j; + +/** + * @author wangs + * @date 2022-05-30 + **/ +@RestController +@RequiredArgsConstructor +@Api(tags = "order管理") +@RequestMapping("/api/produceshiftorderdetail") +@Slf4j +public class ProduceshiftorderdetailController { + + private final ProduceshiftorderdetailService produceshiftorderdetailService; + + @GetMapping + @Log("查询order") + @ApiOperation("查询order") + //@PreAuthorize("@el.check('produceshiftorderdetail:list')") + public ResponseEntity query(@RequestParam Map whereJson, Pageable page){ + return new ResponseEntity<>(produceshiftorderdetailService.queryAll(whereJson,page),HttpStatus.OK); + } + + @PostMapping + @Log("新增order") + @ApiOperation("新增order") + //@PreAuthorize("@el.check('produceshiftorderdetail:add')") + public ResponseEntity create(@Validated @RequestBody ProduceshiftorderdetailDto dto){ + produceshiftorderdetailService.create(dto); + return new ResponseEntity<>(HttpStatus.CREATED); + } + + @PutMapping + @Log("修改order") + @ApiOperation("修改order") + //@PreAuthorize("@el.check('produceshiftorderdetail:edit')") + public ResponseEntity update(@Validated @RequestBody ProduceshiftorderdetailDto dto){ + produceshiftorderdetailService.update(dto); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + + @Log("删除order") + @ApiOperation("删除order") + //@PreAuthorize("@el.check('produceshiftorderdetail:del')") + @DeleteMapping + public ResponseEntity delete(@RequestBody String[] ids) { + produceshiftorderdetailService.deleteAll(ids); + return new ResponseEntity<>(HttpStatus.OK); + } + + @Log("导出order") + @ApiOperation("导出order") + @GetMapping(value = "/download") + //@PreAuthorize("@el.check('produceshiftorderdetail:list')") + public void download(HttpServletResponse response, @RequestParam Map whereJson) throws IOException { + produceshiftorderdetailService.download(produceshiftorderdetailService.queryAll(whereJson), response); + } +} diff --git a/nladmin-system/src/main/java/org/nl/acs/order/service/ProduceshiftorderService.java b/nladmin-system/src/main/java/org/nl/acs/order/service/ProduceshiftorderService.java index d50a992..01789f9 100644 --- a/nladmin-system/src/main/java/org/nl/acs/order/service/ProduceshiftorderService.java +++ b/nladmin-system/src/main/java/org/nl/acs/order/service/ProduceshiftorderService.java @@ -62,13 +62,6 @@ public interface ProduceshiftorderService { */ List queryAllOrder(String whereJson); - /** - * 查询所有未完成工单明细 - * - * @param whereJson 条件参数 - * @return List - */ - List queryAllOrderDteail(String whereJson); /** @@ -102,6 +95,7 @@ public interface ProduceshiftorderService { */ void update(ProduceshiftorderDto dto); + /** * 多选删除 * @@ -188,12 +182,11 @@ public interface ProduceshiftorderService { ProduceshiftorderDto findOrderByOrderIdFromCache(String order_code); - List findOrderDetailByOrderIdFromCache(String order_id); - List findOrderDetailByOrderCodeFromCache(String order_code); ProduceshiftorderDto apply_order(); + List findOrderByOrderStatusFromCache(String order_status); } diff --git a/nladmin-system/src/main/java/org/nl/acs/order/service/ProduceshiftorderdetailService.java b/nladmin-system/src/main/java/org/nl/acs/order/service/ProduceshiftorderdetailService.java new file mode 100644 index 0000000..8d94490 --- /dev/null +++ b/nladmin-system/src/main/java/org/nl/acs/order/service/ProduceshiftorderdetailService.java @@ -0,0 +1,87 @@ +package org.nl.acs.order.service; + +import org.nl.acs.order.service.dto.ProduceshiftorderdetailDto; +import org.springframework.data.domain.Pageable; +import java.util.Map; +import java.util.List; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; + +/** + * @description 服务接口 + * @author wangs + * @date 2022-05-30 + **/ +public interface ProduceshiftorderdetailService { + + /** + * 查询数据分页 + * @param whereJson 条件 + * @param page 分页参数 + * @return Map + */ + Map queryAll(Map whereJson, Pageable page); + + /** + * 查询所有数据不分页 + * @param whereJson 条件参数 + * @return List + */ + List queryAll(Map whereJson); + + /** + * 根据ID查询 + * @param orderDetail_id ID + * @return Produceshiftorderdetail + */ + ProduceshiftorderdetailDto findById(String orderDetail_id); + + /** + * 根据编码查询 + * @param code code + * @return Produceshiftorderdetail + */ + ProduceshiftorderdetailDto findByCode(String code); + + + /** + * 创建 + * @param dto / + */ + void create(ProduceshiftorderdetailDto dto); + + /** + * 编辑 + * @param dto / + */ + void update(ProduceshiftorderdetailDto dto); + + /** + * 多选删除 + * @param ids / + */ + void deleteAll(String[] ids); + + /** + * 导出数据 + * @param dtos 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List dtos, HttpServletResponse response) throws IOException; + + List queryAllOrderDteail(String whereJson); + + ProduceshiftorderdetailDto findOrderDetailByOrderFromCache(String order,String orderdetail_status); + + ProduceshiftorderdetailDto apply_orderDetail(String order); + + List findOrderDetailByOrderIdFromCache(String order_id); + + List findOrderDetailByOrderCodeFromCache(String order_code); + + Boolean sendLetteringMess(String message) throws IOException; + + Boolean isLastOrderDetail(String order); + +} diff --git a/nladmin-system/src/main/java/org/nl/acs/order/service/dto/ProduceshiftorderdetailDto.java b/nladmin-system/src/main/java/org/nl/acs/order/service/dto/ProduceshiftorderdetailDto.java index b30170e..b8cfb6d 100644 --- a/nladmin-system/src/main/java/org/nl/acs/order/service/dto/ProduceshiftorderdetailDto.java +++ b/nladmin-system/src/main/java/org/nl/acs/order/service/dto/ProduceshiftorderdetailDto.java @@ -106,6 +106,10 @@ public class ProduceshiftorderdetailDto implements Serializable { private String length; /** 工单明细状态 */ + //00-就绪、01-分拣中 + //02-下发工单明细暂停 03-工单明细暂停 + //04-下发强制完成 05-强制完成 + //06-自动完成 private String order_detail_status; /** 上料数量 */ diff --git a/nladmin-system/src/main/java/org/nl/acs/order/service/impl/ProduceshiftorderServiceImpl.java b/nladmin-system/src/main/java/org/nl/acs/order/service/impl/ProduceshiftorderServiceImpl.java index 8d70481..25a3392 100644 --- a/nladmin-system/src/main/java/org/nl/acs/order/service/impl/ProduceshiftorderServiceImpl.java +++ b/nladmin-system/src/main/java/org/nl/acs/order/service/impl/ProduceshiftorderServiceImpl.java @@ -14,6 +14,7 @@ import lombok.extern.slf4j.Slf4j; import org.nl.acs.device_driver.hailiang.hailiang_feeding_trunk.HaiLiangFeedingTrunkDeviceDriver; import org.nl.acs.opc.DeviceAppService; import org.nl.acs.order.service.ProduceshiftorderService; +import org.nl.acs.order.service.ProduceshiftorderdetailService; import org.nl.acs.order.service.dto.ProduceshiftorderDto; import org.nl.acs.order.service.dto.ProduceshiftorderdetailDto; import org.nl.exception.BadRequestException; @@ -47,13 +48,14 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A List order = new ArrayList(); - List detail = new ArrayList(); private final MongoTemplate mongoTemplate; @Autowired DeviceAppService deviceAppService; + @Autowired + ProduceshiftorderdetailService produceshiftorderdetailService; @Override public void autoInitial() throws Exception { @@ -62,7 +64,6 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A public synchronized void reload() { 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 @@ -175,13 +176,7 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A return list; } - @Override - public List queryAllOrderDteail(String whereJson) { - WQLObject wo = WQLObject.getWQLObject("acs_produceshiftorderdetail"); - JSONArray arr = wo.query(whereJson).getResultJSONArray(0); - List list = arr.toJavaList(ProduceshiftorderdetailDto.class); - return list; - } + @Override @@ -311,9 +306,6 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A if (StrUtil.equals(dto.getOrder_id(), "07") || StrUtil.equals(dto.getOrder_id(), "08")) { order.add(dto); } - - - } @Override @@ -569,40 +561,14 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A return null; } - @Override - public List findOrderDetailByOrderIdFromCache(String order_id) { - List list = null; - Iterator var3 = detail.iterator(); - while (var3.hasNext()) { - ProduceshiftorderdetailDto oneorderDetail = (ProduceshiftorderdetailDto) var3.next(); - if (StrUtil.equals(oneorderDetail.getOrder_id(), order_id)) { - list.add(oneorderDetail); - } - } - return list; - } - - @Override - public List findOrderDetailByOrderCodeFromCache(String order_code) { - List list = null; - Iterator var3 = detail.iterator(); - while (var3.hasNext()) { - ProduceshiftorderdetailDto oneorderDetail = (ProduceshiftorderdetailDto) var3.next(); - if (StrUtil.equals(oneorderDetail.getOrder_code(), order_code)) { - list.add(oneorderDetail); - } - } - return list; - } - @Override public ProduceshiftorderDto apply_order() { List list = this.findOrderByOrderStatusFromCache("01"); if(ObjectUtil.isEmpty(list)){ - throw new BadRequestException("未找到处于已下发状态的工单!"); + throw new BadRequestException("未找到处于已下发状态的工单!"); } if(list.size() !=1){ - throw new BadRequestException("已下发状态的工单数量不唯一,请校验!"); + throw new BadRequestException("已下发状态的工单数量不唯一,请校验!"); } ProduceshiftorderDto dto = list.get(0); return dto; @@ -610,8 +576,8 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A @Override public List findOrderByOrderStatusFromCache(String order_status) { - List list = null; - Iterator var3 = detail.iterator(); + List list = new ArrayList(); + Iterator var3 = order.iterator(); while (var3.hasNext()) { ProduceshiftorderDto oneorder = (ProduceshiftorderDto) var3.next(); if (StrUtil.equals(oneorder.getOrder_status(), order_status)) { @@ -622,6 +588,7 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A } + @Override public Map querySorting(Map whereJson, Pageable page) { WQLObject wo = WQLObject.getWQLObject("acs_produceshiftorder"); diff --git a/nladmin-system/src/main/java/org/nl/acs/order/service/impl/ProduceshiftorderdetailServiceImpl.java b/nladmin-system/src/main/java/org/nl/acs/order/service/impl/ProduceshiftorderdetailServiceImpl.java new file mode 100644 index 0000000..9d89141 --- /dev/null +++ b/nladmin-system/src/main/java/org/nl/acs/order/service/impl/ProduceshiftorderdetailServiceImpl.java @@ -0,0 +1,299 @@ +package org.nl.acs.order.service.impl; + + +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import lombok.RequiredArgsConstructor; +import org.nl.acs.order.service.ProduceshiftorderService; +import org.nl.acs.order.service.ProduceshiftorderdetailService; +import org.nl.acs.order.service.dto.ProduceshiftorderdetailDto; +import org.nl.exception.BadRequestException; +import org.nl.start.auto.initial.ApplicationAutoInitial; +import org.nl.start.auto.run.LetteringSocketConnectionAutoRun; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import org.springframework.data.domain.Pageable; + +import java.util.*; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.IdUtil; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import org.nl.utils.SecurityUtils; +import org.nl.wql.core.bean.ResultBean; +import org.nl.wql.core.bean.WQLObject; +import org.nl.wql.util.WqlUtil; +import org.nl.utils.FileUtil; +import lombok.extern.slf4j.Slf4j; + +/** + * @description 服务实现 + * @author wangs + * @date 2022-05-30 + **/ +@Service +@RequiredArgsConstructor +@Slf4j +public class ProduceshiftorderdetailServiceImpl implements ProduceshiftorderdetailService, ApplicationAutoInitial { + + List detail = new ArrayList(); + + @Autowired + ProduceshiftorderService produceshiftorderService; + + @Override + public Map queryAll(Map whereJson, Pageable page){ + WQLObject wo = WQLObject.getWQLObject("acs_produceshiftorderdetail"); + ResultBean rb = wo.pagequery(WqlUtil.getHttpContext(page), "", "update_time desc"); + final JSONObject json = rb.pageResult(); + return json; + } + + @Override + public List queryAll(Map whereJson){ + WQLObject wo = WQLObject.getWQLObject("acs_produceshiftorderdetail"); + JSONArray arr = wo.query().getResultJSONArray(0); + List list = arr.toJavaList(ProduceshiftorderdetailDto.class); + + return list; + } + + @Override + public ProduceshiftorderdetailDto findById(String orderDetail_id) { + WQLObject wo = WQLObject.getWQLObject("acs_produceshiftorderdetail"); + JSONObject json = wo.query("order_detail_id ='" + orderDetail_id + "'").uniqueResult(0); + final ProduceshiftorderdetailDto obj = (ProduceshiftorderdetailDto) JSONObject.toJavaObject(json, ProduceshiftorderdetailDto.class); + return obj; + } + + @Override + public ProduceshiftorderdetailDto findByCode(String code) { + WQLObject wo = WQLObject.getWQLObject("acs_produceshiftorderdetail"); + JSONObject json = wo.query("code ='" + code + "'").uniqueResult(0); + final ProduceshiftorderdetailDto obj = (ProduceshiftorderdetailDto) JSONObject.toJavaObject(json, ProduceshiftorderdetailDto.class); + return obj; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void create(ProduceshiftorderdetailDto dto) { + String currentUsername = SecurityUtils.getCurrentUsername(); + String now = DateUtil.now(); + + dto.setOrder_detail_id(IdUtil.simpleUUID()); + dto.setCreate_by(currentUsername); + dto.setUpdate_by(currentUsername); + dto.setUpdate_time(now); + dto.setCreate_time(now); + + WQLObject wo = WQLObject.getWQLObject("acs_produceshiftorderdetail"); + JSONObject json = (JSONObject) JSONObject.toJSON(dto); + + wo.insert(json); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(ProduceshiftorderdetailDto dto) { + ProduceshiftorderdetailDto entity = this.findById(dto.getOrder_detail_id()); + if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!"); + + String currentUsername = SecurityUtils.getCurrentUsername(); + String now = DateUtil.now(); + dto.setUpdate_time(now); + dto.setUpdate_by(currentUsername); + + WQLObject wo = WQLObject.getWQLObject("acs_produceshiftorderdetail"); + JSONObject json = (JSONObject) JSONObject.toJSON(dto); + + wo.update(json); + + + Iterator iterator = detail.iterator(); + while (iterator.hasNext()) { + ProduceshiftorderdetailDto produceshiftorderdetailDto = iterator.next(); + if (produceshiftorderdetailDto.getOrder_detail_id().equals(dto.getOrder_detail_id())) { + iterator.remove(); + } + } + if (StrUtil.equals(dto.getOrder_detail_status(), "07") || StrUtil.equals(dto.getOrder_detail_status(), "08")) { + detail.add(dto); + } + + + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void deleteAll(String[] ids) { + WQLObject wo = WQLObject.getWQLObject("acs_produceshiftorderdetail"); + for (String orderDetail_id: ids) { + wo.delete("orderDetail_id = '" + orderDetail_id + "'"); + } + } + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (ProduceshiftorderdetailDto produceshiftorderdetail : all) { + Map map = new LinkedHashMap<>(); + map.put("工单明细编码", produceshiftorderdetail.getOrder_detail_code()); + map.put("工单明细类型", produceshiftorderdetail.getOrder_detail_type()); + map.put("优先级", produceshiftorderdetail.getPriority()); + map.put("顺序号", produceshiftorderdetail.getSequence_number()); + map.put("工单标识", produceshiftorderdetail.getOrder_id()); + map.put("工单编码", produceshiftorderdetail.getOrder_code()); + map.put("工单数量", produceshiftorderdetail.getOrder_qty()); + map.put("捆扎包数", produceshiftorderdetail.getStrap_pack_number()); + map.put("当前捆扎包数", produceshiftorderdetail.getPresent_strap_pack_number()); + map.put("每捆数量", produceshiftorderdetail.getStrap_number()); + map.put("捆扎尾料数量", produceshiftorderdetail.getStrap_tailint_number()); + map.put("刻字信息", produceshiftorderdetail.getLettering_message()); + map.put("当前刻字数量", produceshiftorderdetail.getPresent_lettering_numer()); + map.put("贴标信息", produceshiftorderdetail.getLabeling_message()); + map.put("当前贴标数量", produceshiftorderdetail.getPresent_labeling_number()); + map.put("创建者", produceshiftorderdetail.getCreate_by()); + map.put("创建时间", produceshiftorderdetail.getCreate_time()); + map.put("修改者", produceshiftorderdetail.getUpdate_by()); + map.put("修改时间", produceshiftorderdetail.getUpdate_time()); + map.put("是否删除", produceshiftorderdetail.getIs_deleted()); + map.put("客户信息", produceshiftorderdetail.getCust_name()); + map.put("客户标识", produceshiftorderdetail.getCust_id()); + map.put("客户编码", produceshiftorderdetail.getCust_code()); + map.put("物料标识", produceshiftorderdetail.getMaterial_id()); + map.put("物料编码", produceshiftorderdetail.getMaterial_code()); + map.put("物料名称 ", produceshiftorderdetail.getMaterial_name()); + map.put("外径", produceshiftorderdetail.getOuter_diameter()); + map.put("壁厚", produceshiftorderdetail.getWall_thickness()); + map.put("物料长度", produceshiftorderdetail.getLength()); + map.put("工单明细状态", produceshiftorderdetail.getOrder_detail_status()); + map.put("上料数量", produceshiftorderdetail.getFeeding_qty()); + map.put("上料合格数量", produceshiftorderdetail.getLettering_qualified_qty()); + map.put("上料开始时间", produceshiftorderdetail.getFeeding_start_time()); + map.put("上料完成时间", produceshiftorderdetail.getFeeding_end_time()); + map.put("刻字合格数量", produceshiftorderdetail.getQualified_lettering_numer()); + map.put("刻字开始时间", produceshiftorderdetail.getLettering_start_time()); + map.put("刻字完成时间", produceshiftorderdetail.getLettering_finish_time()); + map.put("当前套冒数量", produceshiftorderdetail.getPresent_sleeveing_numer()); + map.put("套冒合格数量", produceshiftorderdetail.getQualified_sleeveing_number()); + map.put("套冒开始时间", produceshiftorderdetail.getSleeveing_start_time()); + map.put("套冒完成时间", produceshiftorderdetail.getSleeveing_finish_time()); + map.put("捆扎开始时间", produceshiftorderdetail.getStarp_start_time()); + map.put("捆扎完成时间", produceshiftorderdetail.getStarp_finish_time()); + map.put("裹膜数量", produceshiftorderdetail.getWraping_number()); + map.put("当前裹膜数量", produceshiftorderdetail.getPresent_wraping_number()); + map.put("裹膜合格数量", produceshiftorderdetail.getQualified_wraping_number()); + map.put("裹膜开始时间", produceshiftorderdetail.getWraping_start_time()); + map.put("裹膜完成时间", produceshiftorderdetail.getWraping_finish_time()); + map.put("贴标开始时间", produceshiftorderdetail.getLabeling_start_time()); + map.put("贴标完成时间", produceshiftorderdetail.getLabeling_finish_time()); + map.put("开始时间", produceshiftorderdetail.getStart_time()); + map.put("结束时间", produceshiftorderdetail.getEnd_time()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } + + @Override + public void autoInitial() throws Exception { + this.reload(); + } + + public synchronized void reload() { + this.detail = this.queryAllOrderDteail(" (order_detail_status != '04' or order_detail_status != '05') and is_deleted =0"); + } + + @Override + public List queryAllOrderDteail(String whereJson) { + WQLObject wo = WQLObject.getWQLObject("acs_produceshiftorderdetail"); + JSONArray arr = wo.query(whereJson).getResultJSONArray(0); + List list = arr.toJavaList(ProduceshiftorderdetailDto.class); + return list; + } + + @Override + public List findOrderDetailByOrderIdFromCache(String order_id) { + List list = null; + Iterator var3 = detail.iterator(); + while (var3.hasNext()) { + ProduceshiftorderdetailDto oneorderDetail = (ProduceshiftorderdetailDto) var3.next(); + if (StrUtil.equals(oneorderDetail.getOrder_id(), order_id)) { + list.add(oneorderDetail); + } + } + return list; + } + + @Override + public List findOrderDetailByOrderCodeFromCache(String order_code) { + List list = null; + Iterator var3 = detail.iterator(); + while (var3.hasNext()) { + ProduceshiftorderdetailDto oneorderDetail = (ProduceshiftorderdetailDto) var3.next(); + if (StrUtil.equals(oneorderDetail.getOrder_code(), order_code)) { + list.add(oneorderDetail); + } + } + return list; + } + + @Override + public Boolean sendLetteringMess(String message) { + //清缓存 + try { + LetteringSocketConnectionAutoRun.write("BUFFERCLEAR" + "\r\n"); + String yh = "\""; + String strInst = "SETTEXT " + "S1" + " " + yh + message + yh + "\r\n"; //2个变量 + LetteringSocketConnectionAutoRun.write(strInst + "\r\n"); + + } catch (Exception e) { + return false; + } + return true; + } + + + @Override + public ProduceshiftorderdetailDto findOrderDetailByOrderFromCache(String order,String orderdetail_status) { + Iterator var3 = detail.iterator(); + while (var3.hasNext()) { + ProduceshiftorderdetailDto onedetail = (ProduceshiftorderdetailDto) var3.next(); + if (StrUtil.equals(onedetail.getOrder_code(), order) && StrUtil.equals(onedetail.getOrder_detail_status(), orderdetail_status) ) { + return onedetail; + } + } + return null; + } + + @Override + public ProduceshiftorderdetailDto apply_orderDetail(String order) { + ProduceshiftorderdetailDto order_detail = this.findOrderDetailByOrderFromCache(order,"00"); + if(ObjectUtil.isEmpty(order_detail)){ + throw new BadRequestException("未找到处于就绪状态的工单明细!"); + } + + return order_detail; + } + + @Override + public Boolean isLastOrderDetail(String order) { + List list = new ArrayList<>(); + Iterator var3 = detail.iterator(); + while (var3.hasNext()) { + ProduceshiftorderdetailDto onedetail = (ProduceshiftorderdetailDto) var3.next(); + if (StrUtil.equals(onedetail.getOrder_code(), order) && StrUtil.equals(onedetail.getOrder_detail_status(), "00") ) { + list.add(onedetail); + } + } + if(list.size() != 1){ + return false; + } else { + return true; + } + } +} diff --git a/nladmin-system/src/main/java/org/nl/acs/order/service/wql/order.xls b/nladmin-system/src/main/java/org/nl/acs/order/service/wql/order.xls index cf6cb49..cc1c2fd 100644 Binary files a/nladmin-system/src/main/java/org/nl/acs/order/service/wql/order.xls and b/nladmin-system/src/main/java/org/nl/acs/order/service/wql/order.xls differ diff --git a/nladmin-system/src/main/java/org/nl/start/auto/run/LetteringSocketConnectionAutoRun.java b/nladmin-system/src/main/java/org/nl/start/auto/run/LetteringSocketConnectionAutoRun.java index 33943ab..2ad8649 100644 --- a/nladmin-system/src/main/java/org/nl/start/auto/run/LetteringSocketConnectionAutoRun.java +++ b/nladmin-system/src/main/java/org/nl/start/auto/run/LetteringSocketConnectionAutoRun.java @@ -5,7 +5,12 @@ import lombok.extern.slf4j.Slf4j; import org.nl.acs.config.AcsConfig; import org.nl.acs.config.server.AcsConfigService; import org.nl.acs.config.server.impl.AcsConfigServiceImpl; +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.exception.BadRequestException; import org.nl.utils.SpringContextHolder; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.io.DataInputStream; @@ -14,6 +19,7 @@ import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.Socket; import java.util.Date; +import java.util.List; @Slf4j @Component @@ -27,7 +33,8 @@ public class LetteringSocketConnectionAutoRun extends AbstractAutoRunnable { private int recordTimeOut = 10000; private Date recordTime; boolean bConnected = true; - + @Autowired + DeviceAppService deviceAppService; public LetteringSocketConnectionAutoRun() { this.recordTime = new Date((new Date()).getTime() - (long) this.recordTimeOut); } @@ -66,8 +73,16 @@ public class LetteringSocketConnectionAutoRun extends AbstractAutoRunnable { } System.out.println("收到请求参数:" + bs); //打印完成 - if (StrUtil.equals(bs.toString(), "MSG 3")) { - +// if (StrUtil.equals(bs.toString(), "MSG 3")) { +// +// } + if (StrUtil.equals(bs.toString(), "OK")) { + HaiLiangFeedingTrunkDeviceDriver haiLiangFeedingTrunkDeviceDriver; + List deviceAll = deviceAppService.findDeviceDriver(HaiLiangFeedingTrunkDeviceDriver.class); + if (deviceAll.get(0) instanceof HaiLiangFeedingTrunkDeviceDriver) { + haiLiangFeedingTrunkDeviceDriver = (HaiLiangFeedingTrunkDeviceDriver) deviceAll.get(0); + haiLiangFeedingTrunkDeviceDriver.setSend_letter_flag_back(true); + } } } }