| | |
| | | import com.core.common.Cools; |
| | | import com.core.common.DateUtils; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.DocType; |
| | | import com.zy.asrs.entity.Order; |
| | | import com.zy.asrs.entity.OrderDetl; |
| | | import com.zy.asrs.service.ApiLogService; |
| | | import com.zy.asrs.service.DocTypeService; |
| | | import com.zy.asrs.service.OrderDetlService; |
| | | import com.zy.asrs.service.OrderService; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.enums.OrderTypeEnum; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.task.AbstractHandler; |
| | | import com.zy.asrs.task.core.ReturnT; |
| | | import com.zy.asrs.utils.OrderInAndOutUtil; |
| | |
| | | import com.zy.common.model.MesPakoutParam; |
| | | import com.zy.common.utils.HttpHandler; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.jdbc.core.JdbcTemplate; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | private ApiLogService apiLogService; |
| | | @Autowired |
| | | private DocTypeService docTypeService; |
| | | @Autowired |
| | | private OrderPakinService orderPakinService; |
| | | @Autowired |
| | | private OrderDetlPakinService orderDetlPakinService; |
| | | |
| | | @Transactional |
| | | public ReturnT<String> startOrderIssuedOnceMore(Order order) { |
| | | DocType docType = docTypeService.selectById(order.getDocType()); |
| | | if (null == docType) { |
| | | return SUCCESS; |
| | | } |
| | | |
| | | Order order1 = OrderInAndOutUtil.selectByNo(order.getPakinPakoutStatus$(), order.getOrderNo()); |
| | | if (!Cools.isEmpty(order1)){ |
| | | return FAIL.setMsg("请等待...订单执行档案正在转历史档案!!!"); |
| | | } |
| | | List<OrderDetl> orderDetls = OrderInAndOutUtil.selectByOrderId(order.getPakinPakoutStatus$(), order.getId()); |
| | | if (!Cools.isEmpty(orderDetls) || !orderDetls.isEmpty()) { |
| | | return FAIL.setMsg("请等待...订单执行明细档案正在转历史档案!!!"); |
| | | } |
| | | |
| | | // 单据明细档 |
| | | List<OrderDetl> orderDetlList = orderDetlService.selectByOrderId(order.getId()); |
| | | for (OrderDetl orderDetl : orderDetlList){ |
| | | if (orderDetl.getQty().equals(0D)){ |
| | | continue; |
| | | } |
| | | orderDetl.setWorkQty(orderDetl.getQty()); |
| | | orderDetl.setAnfme(orderDetl.getAnfme()-orderDetl.getQty()); |
| | | orderDetl.setQty(0D); |
| | | orderDetlService.updateById(orderDetl); |
| | | } |
| | | |
| | | // 修改订单状态 99.再次作业 ===>> 1.待作业 |
| | | if (!orderService.updateSettle(order.getId(), 1L, null)) { |
| | | throw new CoolException("服务器内部错误,请联系管理员"); |
| | | } |
| | | return SUCCESS; |
| | | } |
| | | |
| | | @Transactional |
| | | public ReturnT<String> startOrderIssued(Order order) { |
| | | DocType docType = docTypeService.selectById(order.getDocType()); |
| | |
| | | |
| | | for (OrderDetl detail : orderDetls) { |
| | | DetlDto dto = new DetlDto(detail.getMatnr(), detail.getBatch(),detail.getBrand(),detail.getStandby1(),detail.getStandby2(),detail.getStandby3(), |
| | | detail.getBoxType1(),detail.getBoxType2(),detail.getBoxType3(), detail.getAnfme()); |
| | | detail.getBoxType1(),detail.getBoxType2(),detail.getBoxType3(), detail.getAnfme(), detail.getThreeCode()); |
| | | if (DetlDto.has(list, dto)) { |
| | | DetlDto detlDto = DetlDto.find(list, dto.getMatnr(), dto.getBatch(),dto.getBrand(),dto.getStandby1(),dto.getStandby2(),dto.getStandby3(),dto.getBoxType1(),dto.getBoxType2(),dto.getBoxType3()); |
| | | assert detlDto != null; |
| | |
| | | } |
| | | } |
| | | for (OrderDetl orderDetl : orderDetlList){ |
| | | orderDetl.setWorkQty(0D); |
| | | OrderInAndOutUtil.insertOrderDetl(order.getPakinPakoutStatus$(),order,orderDetl); |
| | | //小松:如果下发备货派工单,则生成备货出库+备货入库 |
| | | if (order.getDocType().equals(OrderTypeEnum.TRANSFER.type.longValue())){ |
| | | try { |
| | | ifTransfetInsertStockIn(order,orderDetl); |
| | | }catch (Exception e){ |
| | | throw new CoolException(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | } |
| | | // 修改订单状态 1.未作业 ===>> 2.作业中 |
| | | if (!orderService.updateSettle(order.getId(), 2L, null)) { |
| | |
| | | } |
| | | return SUCCESS; |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void ifTransfetInsertStockIn(Order order, OrderDetl orderDetl){ |
| | | OrderPakin orderPakin = new OrderPakin(); |
| | | BeanUtils.copyProperties(order,orderPakin); |
| | | orderPakin.setDocType(OrderTypeEnum.STOCK_IN.type.longValue()); |
| | | |
| | | if (!orderPakinService.insert(orderPakin)){ |
| | | throw new CoolException("插入备货入库单失败"); |
| | | } |
| | | OrderDetlPakin orderDetlPakin = new OrderDetlPakin(); |
| | | BeanUtils.copyProperties(orderDetl,orderDetlPakin); |
| | | orderDetlPakin.setOrderId(orderPakin.getId()); |
| | | |
| | | |
| | | if (!orderDetlPakinService.insert(orderDetlPakin)){ |
| | | throw new CoolException("插入备货入库单失败"); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | @Transactional |
| | | public ReturnT<String> startOrderInAndOutUtil(Order order) { |
| | | //小松:轮训到备货派工单是查询备货入库单是否完成 |
| | | if (order.getDocType().equals(OrderTypeEnum.STOCK_IN.type.longValue())){ |
| | | return SUCCESS; |
| | | } |
| | | if (order.getDocType().equals(OrderTypeEnum.TRANSFER.type.longValue())){ |
| | | OrderPakin orderPakin = orderPakinService.selectByNo(order.getOrderNo()); |
| | | if (null != orderPakin) { |
| | | if (!orderPakin.getSettle().equals(4L)){ |
| | | return SUCCESS; |
| | | } |
| | | } |
| | | } |
| | | DocType docType = docTypeService.selectById(order.getDocType()); |
| | | if (null == docType) { |
| | | return SUCCESS; |
| | |
| | | if (null == docType) { |
| | | return SUCCESS; |
| | | } |
| | | long settle = 6L; |
| | | List<OrderDetl> orderDetls = orderDetlService.selectByOrderId(order.getId()); |
| | | // 入库完成上报 |
| | | if (docType.getPakin() == 1) { |
| | |
| | | pakinParam.setLgortFrom("5008"); |
| | | pakinParam.setLgortTo("5006"); |
| | | for (OrderDetl orderDetl : orderDetls) { |
| | | if (!orderDetl.getQty().equals(orderDetl.getAnfme())){ |
| | | settle = 99L;//二次生成单据 |
| | | } |
| | | String serial = Cools.isEmpty(orderDetl.getBatch()) ? "" : orderDetl.getBatch(); |
| | | pakinParam.getList().add(new MesPakinParam.Detl(orderDetl.getMatnr() + (Cools.isEmpty(serial) ? "" : "-" + serial), orderDetl.getAnfme())); |
| | | } |
| | | |
| | | String response = ""; |
| | | boolean success = false; |
| | | try { |
| | | response = new HttpHandler.Builder() |
| | | .setUri(MesConstant.URL) |
| | | .setPath(MesConstant.PAKIN_URL) |
| | | .setJson(JSON.toJSONString(pakinParam)) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | if (jsonObject.getInteger("code").equals(200)) { |
| | | // response = new HttpHandler.Builder() |
| | | // .setUri(MesConstant.URL) |
| | | // .setPath(MesConstant.PAKIN_URL) |
| | | // .setJson(JSON.toJSONString(pakinParam)) |
| | | // .build() |
| | | // .doPost(); |
| | | // JSONObject jsonObject = JSON.parseObject(response); |
| | | // if (jsonObject.getInteger("code").equals(200)) { |
| | | if (true) { |
| | | success = true; |
| | | // 修改订单状态 4.完成 ===>> 6.已上报 |
| | | if (!orderService.updateSettle(order.getId(), 6L, null)) { |
| | | if (!orderService.updateSettle(order.getId(), settle, null)) { |
| | | throw new CoolException("服务器内部错误,请联系管理员"); |
| | | } |
| | | } else { |
| | |
| | | } |
| | | pakoutParam.setOrderNo(order.getOrderNo()); |
| | | for (OrderDetl orderDetl : orderDetls) { |
| | | if (!orderDetl.getQty().equals(orderDetl.getAnfme())){ |
| | | settle = 99L;//二次生成单据 |
| | | } |
| | | String serial = Cools.isEmpty(orderDetl.getBatch()) ? "" : orderDetl.getBatch(); |
| | | pakoutParam.getList().add(new MesPakoutParam.Detl(orderDetl.getMatnr() + (Cools.isEmpty(serial) ? "" : "-" + serial), orderDetl.getAnfme())); |
| | | } |
| | | String response = ""; |
| | | boolean success = false; |
| | | try { |
| | | response = new HttpHandler.Builder() |
| | | .setUri(MesConstant.URL) |
| | | .setPath(MesConstant.PAKOUT_URL) |
| | | .setJson(JSON.toJSONString(pakoutParam)) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | if (jsonObject.getInteger("code").equals(200)) { |
| | | // response = new HttpHandler.Builder() |
| | | // .setUri(MesConstant.URL) |
| | | // .setPath(MesConstant.PAKOUT_URL) |
| | | // .setJson(JSON.toJSONString(pakoutParam)) |
| | | // .build() |
| | | // .doPost(); |
| | | // JSONObject jsonObject = JSON.parseObject(response); |
| | | // if (jsonObject.getInteger("code").equals(200)) { |
| | | if (true) { |
| | | success = true; |
| | | // 修改订单状态 4.完成 ===>> 6.已上报 |
| | | if (!orderService.updateSettle(order.getId(), 6L, null)) { |
| | | if (!orderService.updateSettle(order.getId(), settle, null)) { |
| | | throw new CoolException("服务器内部错误,请联系管理员"); |
| | | } |
| | | } else { |