| | |
| | | Date now = new Date(); |
| | | DataFormatter dataFormatter = new DataFormatter(); |
| | | for (int i = 1; i < totalRows; i++) { |
| | | Integer proSts = 0; |
| | | Row row = sheet.getRow(i); |
| | | //单据类型 |
| | | String docName = dataFormatter.formatCellValue(row.getCell(0)); |
| | |
| | | continue; |
| | | } |
| | | Double anfme = Double.parseDouble(dataFormatter.formatCellValue(row.getCell(5))); |
| | | |
| | | Mat mat = matService.selectByMatnr(matnr); |
| | | if (null == mat) { |
| | | throw new CoolException(matnr + "商品编码的商品不存在,请重新导入!"); |
| | |
| | | //String timeStr = DateUtils.convert(new Date()); |
| | | |
| | | DocType docType = docTypeService.selectOne(new EntityWrapper<DocType>().eq("doc_name", docName)); |
| | | |
| | | // 单据类型为 半成品入库单才有工序 |
| | | if (docType.getDocId().intValue() == 32) { |
| | | //工序 |
| | | if (Cools.isEmpty(dataFormatter.formatCellValue(row.getCell(6)))) { |
| | | // 工序为空,默认为无需加工 |
| | | proSts = 3; |
| | | } else { |
| | | String processSts = dataFormatter.formatCellValue(row.getCell(6)); |
| | | //1: 待加工 2:已加工 3:无需加工 |
| | | if ("待加工".equals(processSts)) { |
| | | proSts = 1; |
| | | } else if ("已加工".equals(processSts)) { |
| | | proSts = 2; |
| | | } else { |
| | | proSts = 3; |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | if(docType.getPakin() == 1){ |
| | | uuid += "_I"; |
| | |
| | | orderDetl.setDeadTime(isocode); |
| | | orderDetl.setStatus(1); |
| | | orderDetl.setQty(0.0D); |
| | | orderDetl.setProcessSts(proSts); |
| | | if (!orderDetlService.insert(orderDetl)) { |
| | | throw new CoolException("生成单据明细失败,请重新导入!"); |
| | | } |
| | |
| | | throw new CoolException("生成单据明细失败,请重新导入!"); |
| | | } |
| | | } |
| | | // 生成调拨单 |
| | | if (docType.getDocId().intValue() == 32) { |
| | | String dbUuid = "DB" + uuid; |
| | | Order order2 = orderService.selectByNo(dbUuid); |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 工序为1:待加工 生成加工单 |
| | | if (proSts == 1) { |
| | | if (docType.getDocId().intValue() == 32) { |
| | | String dbUuid = "JG" + uuid; |
| | | Order order3 = orderService.selectByNo(dbUuid); |
| | | if (null == order3) { |
| | | order3 = new Order( |
| | | String.valueOf(snowflakeIdWorker.nextId()), // 编号[非空] |
| | | dbUuid, // 订单编号 |
| | | null, // 单据日期 |
| | | 35L, // 单据类型 |
| | | null, // 项目编号 |
| | | null, // |
| | | null, // 调拨项目编号 |
| | | null, // 初始票据号 |
| | | null, // 票据号 |
| | | null, // 客户编号 |
| | | null, // 客户 |
| | | null, // 联系方式 |
| | | null, // 操作人员 |
| | | null, // 合计金额 |
| | | null, // 优惠率 |
| | | null, // 优惠金额 |
| | | null, // 销售或采购费用合计 |
| | | null, // 实付金额 |
| | | null, // 付款类型 |
| | | null, // 业务员 |
| | | null, // 结算天数 |
| | | null, // 邮费支付类型 |
| | | null, // 邮费 |
| | | null, // 付款时间 |
| | | null, // 发货时间 |
| | | null, // 物流名称 |
| | | null, // 物流单号 |
| | | 1L, // 订单状态 |
| | | 1, // 状态 |
| | | userId, // 添加人员 |
| | | now, // 添加时间 |
| | | userId, // 修改人员 |
| | | now, // 修改时间 |
| | | null // 备注 |
| | | ); |
| | | if (!orderService.insert(order3)) { |
| | | throw new CoolException("生成单据主档失败,请重新导入!"); |
| | | } |
| | | }else { |
| | | order3.setSettle(order.getSettle() == 1L ? 1L : 2L ); |
| | | orderService.updateById(order3); |
| | | } |
| | | |
| | | OrderDetl orderDetl3 = orderDetlService.selectItem(order3.getId(), matnr, null,csocode,isocode); |
| | | if (orderDetl3 == null) { |
| | | orderDetl3 = new OrderDetl(); |
| | | orderDetl3.sync(mat); |
| | | orderDetl3.setSource(35); |
| | | orderDetl3.setBatch(null); |
| | | orderDetl3.setAnfme(anfme); |
| | | orderDetl3.setOrderId(order3.getId()); |
| | | orderDetl3.setOrderNo(order3.getOrderNo()); |
| | | orderDetl3.setCreateBy(userId); |
| | | orderDetl3.setCreateTime(now); |
| | | orderDetl3.setUpdateBy(userId); |
| | | orderDetl3.setUpdateTime(now); |
| | | orderDetl3.setThreeCode(csocode); |
| | | orderDetl3.setDeadTime(isocode); |
| | | orderDetl3.setStatus(1); |
| | | orderDetl3.setQty(0.0D); |
| | | if (!orderDetlService.insert(orderDetl3)) { |
| | | throw new CoolException("生成单据明细失败,请重新导入!"); |
| | | } |
| | | } else { |
| | | if(!orderDetlService.increaseAnfme(order3.getId(), matnr, null, anfme,csocode,isocode)) { |
| | | throw new CoolException("生成单据明细失败,请重新导入!"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | return R.ok("导入成功"); |
| | | } |