|
@@ -28,6 +28,7 @@ import com.xc.luckysheet.utils.LuckySheet4SummaryHelp;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -74,6 +75,9 @@ public class JfGridUpdateService {
|
|
|
@Autowired
|
|
|
private SnowFlake snowFlake;
|
|
|
|
|
|
+ @Value("${row_size}")
|
|
|
+ private Integer rowSize;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 插入新的表格数据
|
|
@@ -100,15 +104,17 @@ public class JfGridUpdateService {
|
|
|
.index("1")
|
|
|
.sheetName("Sheet1")
|
|
|
.order(0)
|
|
|
+ .row(rowSize)
|
|
|
.build();
|
|
|
JSONObject sheet = LuckySheet4SummaryHelp.getEmptySheet(sheet1);
|
|
|
|
|
|
//配置信息
|
|
|
- SheetConfigResultDto configResultDto = assembleProjectSummaryTitle(paramExcelDto);
|
|
|
+ SheetConfigResultDto configResultDto = assembleProjectSummary(paramExcelDto);
|
|
|
|
|
|
JSONObject config = sheet.getJSONObject("config");
|
|
|
config.put("merge", configResultDto.getMergeConfig());
|
|
|
config.put("rowlen", configResultDto.getRowlenConfig());
|
|
|
+ config.put("columnlen", configResultDto.getColumnlenConfig());
|
|
|
config.put("borderInfo", configResultDto.getBorderInfoConfig());
|
|
|
|
|
|
sheet.getJSONObject("dataVerification").putAll(configResultDto.getDataVerification());
|
|
@@ -187,15 +193,19 @@ public class JfGridUpdateService {
|
|
|
* @param paramExcelDto
|
|
|
* @return
|
|
|
*/
|
|
|
- private SheetConfigResultDto assembleProjectSummaryTitle(ProjectSummaryParamExcelDto paramExcelDto) {
|
|
|
+ private SheetConfigResultDto assembleProjectSummary(ProjectSummaryParamExcelDto paramExcelDto) {
|
|
|
//合并配置
|
|
|
JSONObject mergeConfig = LuckySheet4SummaryHelp.getMergeConfig(paramExcelDto.getDeviceNumberList());
|
|
|
//边框信息
|
|
|
JSONArray borderInfo = LuckySheet4SummaryHelp.getBorderInfo(paramExcelDto.getDeviceNumberList());
|
|
|
//下拉框
|
|
|
JSONObject dataVerification = LuckySheet4SummaryHelp.getDataVerification(paramExcelDto);
|
|
|
+ //列宽
|
|
|
+ JSONObject columnLen = new JSONObject();
|
|
|
+ columnLen.put("2", 130); //部门
|
|
|
+ columnLen.put("3", 300); //内容
|
|
|
//数据
|
|
|
- JSONArray cellData = getCellData(paramExcelDto);
|
|
|
+ JSONArray cellData = getCellData(paramExcelDto, columnLen);
|
|
|
//行高
|
|
|
JSONObject rowLenObj = new JSONObject();
|
|
|
rowLenObj.put("0", 24);
|
|
@@ -206,6 +216,7 @@ public class JfGridUpdateService {
|
|
|
.celldata(cellData)
|
|
|
.mergeConfig(mergeConfig)
|
|
|
.rowlenConfig(rowLenObj)
|
|
|
+ .columnlenConfig(columnLen)
|
|
|
.build();
|
|
|
}
|
|
|
|
|
@@ -213,9 +224,10 @@ public class JfGridUpdateService {
|
|
|
* 获取数据
|
|
|
*
|
|
|
* @param paramExcelDto
|
|
|
+ * @param columnLen
|
|
|
* @return
|
|
|
*/
|
|
|
- private JSONArray getCellData(ProjectSummaryParamExcelDto paramExcelDto) {
|
|
|
+ private JSONArray getCellData(ProjectSummaryParamExcelDto paramExcelDto, JSONObject columnLen) {
|
|
|
|
|
|
String[] titleFirst = LuckySheet4SummaryHelp.MAIN_TITLE_FIRST;
|
|
|
String[] titleSecond = LuckySheet4SummaryHelp.MAIN_TITLE_SECOND;
|
|
@@ -249,6 +261,28 @@ public class JfGridUpdateService {
|
|
|
celldata.addAll(celldata1);
|
|
|
celldata.addAll(celldata2);
|
|
|
|
|
|
+ //自动换行
|
|
|
+ for(int m = 3, n = rowSize; m < n; m++) {
|
|
|
+ //部位
|
|
|
+ JSONObject positionCell = new JSONObject();
|
|
|
+ positionCell.put("r", m);
|
|
|
+ positionCell.put("c", 2);
|
|
|
+
|
|
|
+ JSONObject positionCellV = new JSONObject();
|
|
|
+ positionCellV.put("tb", 2);
|
|
|
+ positionCell.put("v", positionCellV);
|
|
|
+
|
|
|
+ //内容
|
|
|
+ JSONObject contentCell = new JSONObject();
|
|
|
+ contentCell.put("r", m);
|
|
|
+ contentCell.put("c", 3);
|
|
|
+
|
|
|
+ JSONObject contentCellV = new JSONObject();
|
|
|
+ contentCellV.put("tb", 2); //自动换行
|
|
|
+ contentCell.put("v", contentCellV);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
return celldata;
|
|
|
}
|
|
|
|