Index: ssts-web/src/main/java/com/forgon/disinfectsystem/inventoryrecord/service/InventoryRecordManagerImpl.java =================================================================== diff -u -r26836 -r26888 --- ssts-web/src/main/java/com/forgon/disinfectsystem/inventoryrecord/service/InventoryRecordManagerImpl.java (.../InventoryRecordManagerImpl.java) (revision 26836) +++ ssts-web/src/main/java/com/forgon/disinfectsystem/inventoryrecord/service/InventoryRecordManagerImpl.java (.../InventoryRecordManagerImpl.java) (revision 26888) @@ -1529,10 +1529,27 @@ sheetColumnSize = columns.size(); } } - buildExcelCell(record,paramsJson, wb,sheet, cellStyle,sheetColumnSize); + // 贵港市人民医院GGSRMYY-102(导出盘点后的一次性物品盘点信息表) + int disposableGoodsInventoryExportFormat = CssdUtils.getSystemSetConfigByNameInt("disposableGoodsInventoryExportFormat", 1); + // 已经更新库存的一次性物品盘点单 + if (StringUtils.equals(record.getType(), InventoryRecord.TYPE_DISPOSABLEGOOD) + && StringUtils.equals(record.getStatus(), InventoryRecord.STATUS_HAS_BEEN_UPDATED)) { + // 贵港市人民医院GGSRMYY-102,一次性物品盘点导出格式2 + if (disposableGoodsInventoryExportFormat == 2) { + sheetColumnSize = sheetColumnSize + 2; + buildExcelCellForGGSRMYY(record, paramsJson, wb, sheet, cellStyle, sheetColumnSize); + } else { + // 没有该配置项或者值为1时,格式为原来的格式 + buildExcelCell(record,paramsJson, wb,sheet, cellStyle,sheetColumnSize); + } + } else { + buildExcelCell(record,paramsJson, wb,sheet, cellStyle,sheetColumnSize); + } //调整列宽度 for(int i = 0 ;i sumColumnMap = new HashMap(); + int seriaNum = 1; + if(columnJsonArray != null && columnJsonArray.size() > 0 && record.getItems() != null){ + List items = record.getItems(); + //按物品顺序号排序 + Collections.sort(items); + JSONArray itemsArray = JSONArray.fromObject(items); + for (int i = 0 ;i < itemsArray.size() ; i++){ + // 填充内容 + HSSFRow operatingRow = sheet.createRow(sheet.getLastRowNum() + 1); + JSONObject obj = itemsArray.optJSONObject(i); + obj.put("rowIndex", seriaNum); + seriaNum++; + obj.put("totalPrice", MathTools.mul(obj.optInt("amount"), obj.optDouble("price"), 8).doubleValue()); + obj.put("differentPrice", MathTools.mul(obj.optInt("storageDifference"), obj.optDouble("price"), 8).doubleValue()); + for(int j = 0 ; j < columnJsonArray.size() ; j ++){ + JSONObject configObj = columnJsonArray.optJSONObject(j); + String propertyName = configObj.optString("dataIndex"); + // 序号"总合计",合计账面数量,盘点数量 设置为"合计列" + if (StringUtils.equals("rowIndex", propertyName) || StringUtils.equals("storage", propertyName) + || StringUtils.equals("amount", propertyName) || StringUtils.equals("storageDifference", propertyName)) { + configObj.put("columnValueSum", "true"); + } + if(propertyName.equals("inSixMonth")){ + obj.put("inSixMonth",isInSixMonthWithExpDate(obj.optString("expDateString"))); + } + // 是否合计列 + if(configObj.optBoolean("columnValueSum")){ + Double sumValue = sumColumnMap.get(propertyName); + if(sumValue == null){ + sumValue = 0d; + } + sumColumnMap.put(propertyName, MathTools.add(sumValue, obj.optDouble(propertyName), 8).doubleValue()); + } + // 若列为盘点差值列 + if(propertyName.equals("storageDifference") && configObj.optString("type").equals("int")){ + int difference = obj.optInt(propertyName); + if(difference > 0||difference < 0){ + // 创建差值列样式 + HSSFCellStyle differenceCellStyle = buildStorageDifferenceExcelStyle(wb,difference); + ExcelUtils.createIntCell(operatingRow, differenceCellStyle, j,obj.optInt(propertyName)); + }else{ + ExcelUtils.createIntCell(operatingRow, cellStyle, j,null); + } + continue; + } + if(configObj.optString("type").equals("int")){ + ExcelUtils.createIntCell(operatingRow, cellStyle, j,obj.optInt(propertyName)); + }else if(configObj.optString("type").equals("double")){ + if (propertyName.equals("differentPrice")) { + // 创建差异金额样式 + HSSFCellStyle differenceCellStyle = buildStorageDifferenceExcelStyle(wb,obj.optDouble(propertyName)); + ExcelUtils.createDoubleCell(operatingRow, differenceCellStyle, j,obj.optDouble(propertyName)); + continue; + } + ExcelUtils.createDoubleCell(operatingRow, cellStyle, j,obj.optDouble(propertyName)); + }else{ + ExcelUtils.createStringCell(operatingRow, cellStyle, j,obj.optString(propertyName)); + } + } + } + } + // 总合计 + if(sumColumnMap.size() > 0){ + HSSFRow operatingRow = sheet.createRow(sheet.getLastRowNum() + 1); + if(columnJsonArray != null){ + for(int i = 0 ; i < columnJsonArray.size() ; i ++){ + JSONObject obj = columnJsonArray.optJSONObject(i); + String propertyName = obj.optString("dataIndex"); + if (StringUtils.equals("rowIndex", obj.optString("dataIndex"))) { + ExcelUtils.createStringCell(operatingRow, cellStyle, i, "总合计:"); + continue; + } + Double columnTotalValue = sumColumnMap.get(obj.optString("dataIndex")); + if(columnTotalValue != null){ + if (StringUtils.equals(propertyName, "storageDifference") || + StringUtils.equals(propertyName, "differentPrice")) { + HSSFCellStyle tempCellStyle = buildStorageDifferenceExcelStyle(wb, columnTotalValue); + ExcelUtils.createDoubleCell(operatingRow, tempCellStyle, i, columnTotalValue); + } else { + ExcelUtils.createDoubleCell(operatingRow, cellStyle, i, columnTotalValue); + } + }else{ + ExcelUtils.createStringCell(operatingRow, cellStyle, i, ""); + } + } + } + } + // 手工签名行(贵港市人民医院GGSRMYY-102) + setFooterForInventoryRecord(wb, sheet, record); + } + + /** + * 手工签名,不用系统取值(贵港市人民医院GGSRMYY-102) + * @param wb + * @param sheet + * @param record 盘点记录 + */ + private void setFooterForInventoryRecord (HSSFWorkbook wb, HSSFSheet sheet, InventoryRecord record) { + HSSFCellStyle nullCellStyle = buildNullCellStyle(wb); + int row = sheet.getLastRowNum() + 1; + HSSFRow signRow = sheet.createRow(row); + ExcelUtils.createStringCell(signRow, nullCellStyle, 0,"制表:"); + ExcelUtils.createStringCell(signRow, nullCellStyle, 3,"消毒供应室:"); + ExcelUtils.createStringCell(signRow, nullCellStyle, 5,"设备会记:"); + ExcelUtils.createStringCell(signRow, nullCellStyle, 8,"设备科:"); + ExcelUtils.createStringCell(signRow, nullCellStyle, 11,"财务科:"); + } + private HSSFCellStyle buildNullCellStyle(HSSFWorkbook wb) { HSSFCellStyle cellStyle2 = wb.createCellStyle(); // 数据单元格格式 cellStyle2.setAlignment(HSSFCellStyle.ALIGN_CENTER); // 居中 @@ -1741,7 +1910,7 @@ * 差值大于0:红色字体 * 差值小于0:绿色字体 */ - private HSSFCellStyle buildStorageDifferenceExcelStyle(HSSFWorkbook wb,int difference){ + private HSSFCellStyle buildStorageDifferenceExcelStyle(HSSFWorkbook wb,Number difference){ if(wb != null){ HSSFCellStyle cellStyle = wb.createCellStyle(); // 数据单元格格式 cellStyle.setWrapText(true); @@ -1753,10 +1922,10 @@ HSSFFont font = wb.createFont(); font.setFontHeightInPoints((short) 10); // 设置字体大小为10 font.setFontName("宋体"); - if(difference >0){ + if(difference.doubleValue() > 0){ font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);//加粗 font.setColor(HSSFColor.RED.index);//红色字体 - }else if(difference <0){ + }else if(difference.doubleValue() < 0){ font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);//加粗 font.setColor(HSSFColor.GREEN.index);//绿色字体 }