| | |
| | | import com.ruili.wcp.web.common.LicenseException; |
| | | import com.ruili.wcp.web.model.AjaxResponse; |
| | | import com.ruili.wcp.web.model.ErrorInfo; |
| | | import com.zbooksoft.gdmis.data.entity.PackingManage; |
| | | import com.zbooksoft.gdmis.service.CatSwajxxService; |
| | | import com.zbooksoft.gdmis.service.PackingManageService; |
| | | import org.apache.poi.hssf.usermodel.HSSFSheet; |
| | | import org.apache.poi.hssf.usermodel.HSSFWorkbook; |
| | | import org.apache.poi.ss.usermodel.Cell; |
| | |
| | | ImportColumnService importColumnService; |
| | | @Autowired |
| | | CatSwajxxService catSwajxxService; |
| | | @Autowired |
| | | PackingManageService packingManageService; |
| | | // @Autowired |
| | | // CatSwzkxxService catSwzkxxService; |
| | | // @Autowired |
| | |
| | | return new AjaxResponse(true); |
| | | } catch (Exception e) { |
| | | logger.error(e.getMessage(), e); |
| | | return new AjaxResponse(new ErrorInfo("导入失败"), false); |
| | | return new AjaxResponse(new ErrorInfo(e.getMessage()), false); |
| | | } |
| | | } |
| | | |
| | |
| | | if (originalFilename.matches("^.+\\.(?i)(xls)$")) { |
| | | //创建工作簿对象 |
| | | HSSFWorkbook hssfWorkbook = new HSSFWorkbook(inputStream); |
| | | for (int i = 0; i < 2; i++) { |
| | | readExcel2003(hssfWorkbook, i, importTemplateIds.get(i), map); |
| | | } |
| | | // for (int i = 0; i < 2; i++) { |
| | | readExcel2003(hssfWorkbook, 1, importTemplateIds.get(1), map); |
| | | // } |
| | | } |
| | | if (originalFilename.matches("^.+\\.(?i)(xlsx)$")) { |
| | | //创建工作簿对象 |
| | |
| | | excelColumns.add(cellValue.toString()); |
| | | } |
| | | for (int j = 1; j <= maxRow; j++) { |
| | | Long id = 0l; |
| | | Row rowValue = sheet.getRow(j); |
| | | Map<String, Object> map = new HashMap(); |
| | | if (sheetAt == 1) { |
| | | Cell cell = rowValue.getCell(dhIndex); |
| | | Object cellValue = getExcelValue(cell); |
| | | String sql = "select id from cat_file_ajjxx where dh='" + cellValue + "'"; |
| | | Long id = jdbcTemplate.queryForObject(sql, Long.class); |
| | | map.put("AJ_ID", id); |
| | | map.put("YSZT", 3); |
| | | List<Map<String, Object>> mapList = jdbcTemplate.queryForList(sql); |
| | | if (mapList.size() > 0) { |
| | | Map<String, Object> stringObjectMap = mapList.get(0); |
| | | String string = stringObjectMap.get("id").toString(); |
| | | map.put("AJ_ID", string); |
| | | map.put("YSZT", 3); |
| | | } |
| | | map.put("AJ_DH", cellValue); |
| | | } |
| | | for (int z = 0; z < columnList.size(); z++) { |
| | |
| | | map.put(column.getColumnName(), cellValue); |
| | | } |
| | | } |
| | | iform.insert(importTemplate.getTableId(), map); |
| | | Long insert = iform.insert(importTemplate.getTableId(), map); |
| | | if (sheetAt == 1) { |
| | | PackingManage packingManage = new PackingManage(); |
| | | int columnIndex = excelColumns.indexOf("袋卷号"); |
| | | if (columnIndex >= 0) { |
| | | Cell cell = rowValue.getCell(columnIndex); |
| | | Object cellValue = getExcelValue(cell); |
| | | packingManage.setBoxNumber(cellValue == null ? "" : cellValue.toString()); |
| | | } |
| | | int columnInde = excelColumns.indexOf("档号"); |
| | | if (columnIndex >= 0) { |
| | | Cell cell = rowValue.getCell(columnInde); |
| | | Object cellValue = getExcelValue(cell); |
| | | String itemCode = cellValue == null ? "" : cellValue.toString(); |
| | | String newBarCode = itemCode.replace("底", "D").replace("测", "C").replace("观", "G").replace("探", "T").replace("样", "Y").replace("试", "S").replace("录", "L").replace("像", "X").replace("综", "Z").replace("文", "W").replace("实", "S").replace("物", "W").replace("钻", "Z").replace("设", "S").replace("相", "X").replace("油", "Y").replace("电", "D").replace("地", "D"); |
| | | packingManage.setItemNum(newBarCode + "-" + packingManage.getBoxNumber()); |
| | | } |
| | | packingManage.setItemId(insert == null ? "0" : insert.toString()); |
| | | packingManage.setAjId(id == null ? "0" : id.toString()); |
| | | packingManage.setType(0); |
| | | packingManage.setCreateTime(new java.util.Date()); |
| | | packingManageService.saveOrUpdate(packingManage); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | // Excel2007 xlsx |