main
黄海 1 year ago
parent 3eee22c87c
commit 7d5c787387

@ -1739,10 +1739,10 @@ public class CollectController extends Controller {
Record rs = personModel.getLoginInfoByPersonId(person_id);
String bureau_id = rs.get("bureau_id");
List<Integer> schoolStageList = cm.getSchoolStage(bureau_id);//有456哪几个学段
//查一下,这个任务的相关模板与学段的关系表,哪些表不是当前单位需要填写的,删除
File reduceExcel = cm.getHiddenExcel(job_id, excelPath, schoolStageList);
//查一下,这个任务的相关模板与学段的关系表,哪些表不是当前单位需要填写的,隐藏
File fillExcel = cm.getFillExcelTemplate(job_id, excelPath, schoolStageList);
//提供下载
renderFile(reduceExcel, job_name + ".xlsx");
renderFile(fillExcel, job_name + ".xlsx");
}
/**

@ -663,7 +663,9 @@ public class CollectModel {
for (int colNum = 0; colNum < ed.getLastCellNum(); colNum++) {
if (StrKit.isBlank(ed.getCell(colNum).toString())) {//下面没有,应该听上面的
original_name = CommonUtil.removeKuoHao(st.getCell(colNum).toString().replace("\n", ""));
if (StrKit.isBlank(original_name)) continue;
if (StrKit.isBlank(original_name)) {
continue;
}
column_name = ChineseCharacterUtil.getColumnNameByMemo(CommonUtil.removeKuoHao(st.getCell(colNum).toString()));
Record record = new Record();
record.set("original_name", original_name);
@ -3096,7 +3098,7 @@ public class CollectModel {
* @return 2024-04-07
*/
public List<Integer> getSchoolStage(String org_id) {
String sql = "select school_type_id from t_base_organization as t1 where t1.org_id=?";
String sql = "select t1.school_type_id from t_base_organization as t1 where t1.org_id=?";
int school_type_id = Db.queryInt(sql, org_id);
List<Integer> stage_ids = new ArrayList<>();
//如果不是学校,那么默认是全部保留
@ -3148,7 +3150,9 @@ public class CollectModel {
for (Record record : tList) {
int sheet_index = record.getInt("sheet_index");
String sheet_name = record.getStr("sheet_name");
Record r = new Record();
r.set("sheet_index", sheet_index);
r.set("sheet_name", sheet_name);
r.set("xiaoxue", _map.get(sheet_index + "_" + 4));
r.set("chuzhong", _map.get(sheet_index + "_" + 5));
@ -3233,7 +3237,7 @@ public class CollectModel {
* @param schoolStageList
* @return
*/
public File getHiddenExcel(int job_id, String excelPath, List<Integer> schoolStageList) {
public File getFillExcelTemplate(int job_id, String excelPath, List<Integer> schoolStageList) {
//哪些Sheet需要隐藏
List<Integer> hiddenSheetList = getHiddenSheetList(job_id, schoolStageList);
@ -3253,6 +3257,34 @@ public class CollectModel {
for (Integer x : hiddenSheetList) {
workbook.setSheetHidden(x, true);
}
// 设置单元格保护策略
CellStyle lockedStyle = workbook.createCellStyle();
lockedStyle.setLocked(true); // 设置单元格为锁定(即只读)
CellStyle unlockedStyle = workbook.createCellStyle();
unlockedStyle.setLocked(false); // 设置单元格为解锁(即可编辑)
//哪个Sheet表+哪一列是需要只读的?
String sql = "select sheet_index,column_index from t_collect_job_sheet_col where job_id=? and readonly=1";
List<Record> listSheetColumn = Db.find(sql, job_id);
for (Record record : listSheetColumn) {
int sheet_index = record.getInt("sheet_index");
int column_index = record.getInt("column_index");
XSSFSheet sheet = workbook.getSheetAt(sheet_index);
// 假设我们要将某一列设置为只读
for (Row row : sheet) {
for (Cell cell : row) {
if (cell.getColumnIndex() == column_index) {
cell.setCellStyle(lockedStyle);
} else {
cell.setCellStyle(unlockedStyle);
}
}
}
// 启用工作表保护
sheet.protectSheet("dsideal"); // 设置工作表保护密码
}
// 将修改后的工作簿写回文件
workbook.write(fos);
} catch (IOException e) {

Loading…
Cancel
Save