Merge remote-tracking branch 'origin/guoshengxiong' into guoshengxiong

This commit is contained in:
guoshengxiong 2024-06-05 20:23:46 +08:00
commit ee062ba7a4
4 changed files with 61 additions and 15 deletions

View File

@ -1,6 +1,7 @@
package com.zhgd.xmgl.modules.exam.controller; package com.zhgd.xmgl.modules.exam.controller;
import com.zhgd.annotation.OperLog; import com.zhgd.annotation.OperLog;
import com.zhgd.xmgl.modules.exam.entity.ExamQuestionBank;
import com.zhgd.xmgl.modules.exam.vo.ExamPaperVo; import com.zhgd.xmgl.modules.exam.vo.ExamPaperVo;
import com.zhgd.xmgl.modules.exam.vo.ExamQuestionBankVo; import com.zhgd.xmgl.modules.exam.vo.ExamQuestionBankVo;
import com.zhgd.xmgl.util.PageUtil; import com.zhgd.xmgl.util.PageUtil;
@ -76,11 +77,13 @@ public class ExamPaperController {
public Result<IPage<ExamPaper>> queryPageList(@ApiIgnore @RequestBody Map<String, Object> map) { public Result<IPage<ExamPaper>> queryPageList(@ApiIgnore @RequestBody Map<String, Object> map) {
QueryWrapper<ExamPaper> queryWrapper = QueryGenerator.initPageQueryWrapper(ExamPaper.class, map); QueryWrapper<ExamPaper> queryWrapper = QueryGenerator.initPageQueryWrapper(ExamPaper.class, map);
Page<ExamPaper> page = PageUtil.getPage(map); Page<ExamPaper> page = PageUtil.getPage(map);
queryWrapper.orderByDesc("create_time");
IPage<ExamPaper> pageList = examPaperService.pageList(page, queryWrapper); IPage<ExamPaper> pageList = examPaperService.pageList(page, queryWrapper);
return Result.success(pageList); return Result.success(pageList);
} }
/** /**
*
* 列表查询 * 列表查询
* *
* @param examPaper * @param examPaper
@ -91,6 +94,7 @@ public class ExamPaperController {
@PostMapping(value = "/list") @PostMapping(value = "/list")
public Result<List<ExamPaper>> queryList(@RequestBody ExamPaper examPaper) { public Result<List<ExamPaper>> queryList(@RequestBody ExamPaper examPaper) {
QueryWrapper<ExamPaper> queryWrapper = QueryGenerator.initQueryWrapper(examPaper); QueryWrapper<ExamPaper> queryWrapper = QueryGenerator.initQueryWrapper(examPaper);
queryWrapper.lambda().orderByDesc(ExamPaper::getCreateTime);
List<ExamPaper> list = examPaperService.list(queryWrapper); List<ExamPaper> list = examPaperService.list(queryWrapper);
return Result.success(list); return Result.success(list);
} }

View File

@ -24,6 +24,7 @@ import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import java.sql.Array;
import java.util.*; import java.util.*;
import java.io.IOException; import java.io.IOException;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
@ -101,6 +102,7 @@ public class ExamQuestionBankController {
public Result<IPage<ExamQuestionBank>> queryPageList(@ApiIgnore @RequestBody Map<String, Object> map) { public Result<IPage<ExamQuestionBank>> queryPageList(@ApiIgnore @RequestBody Map<String, Object> map) {
QueryWrapper<ExamQuestionBank> queryWrapper = QueryGenerator.initPageQueryWrapper(ExamQuestionBank.class, map); QueryWrapper<ExamQuestionBank> queryWrapper = QueryGenerator.initPageQueryWrapper(ExamQuestionBank.class, map);
Page<ExamQuestionBank> page = PageUtil.getPage(map); Page<ExamQuestionBank> page = PageUtil.getPage(map);
queryWrapper.lambda().orderByDesc(ExamQuestionBank::getCreateTime);
IPage<ExamQuestionBank> pageList = examQuestionBankService.page(page, queryWrapper); IPage<ExamQuestionBank> pageList = examQuestionBankService.page(page, queryWrapper);
return Result.success(pageList); return Result.success(pageList);
} }
@ -120,6 +122,7 @@ public class ExamQuestionBankController {
@PostMapping(value = "/list") @PostMapping(value = "/list")
public Result<List<ExamQuestionBank>> queryList(@ApiIgnore @RequestBody ExamQuestionBank examQuestionBank) { public Result<List<ExamQuestionBank>> queryList(@ApiIgnore @RequestBody ExamQuestionBank examQuestionBank) {
QueryWrapper<ExamQuestionBank> queryWrapper = QueryGenerator.initQueryWrapper(examQuestionBank); QueryWrapper<ExamQuestionBank> queryWrapper = QueryGenerator.initQueryWrapper(examQuestionBank);
queryWrapper.lambda().orderByDesc(ExamQuestionBank::getCreateTime);
List<ExamQuestionBank> list = examQuestionBankService.list(queryWrapper); List<ExamQuestionBank> list = examQuestionBankService.list(queryWrapper);
return Result.success(list); return Result.success(list);
} }
@ -321,6 +324,7 @@ public class ExamQuestionBankController {
QueryWrapper<ExamQuestionBank> queryWrapper = QueryGenerator.initPageQueryWrapper(ExamQuestionBank.class, map); QueryWrapper<ExamQuestionBank> queryWrapper = QueryGenerator.initPageQueryWrapper(ExamQuestionBank.class, map);
//Step.2 AutoPoi 导出Excel //Step.2 AutoPoi 导出Excel
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
queryWrapper.lambda().orderByDesc(ExamQuestionBank::getCreateTime);
List<ExamQuestionBank> pageList = examQuestionBankService.list(queryWrapper); List<ExamQuestionBank> pageList = examQuestionBankService.list(queryWrapper);
List<ExamSubject> subList = examSubjectService.list(); List<ExamSubject> subList = examSubjectService.list();
List<ExamQuestionBankImport> resultList = new ArrayList<>(); List<ExamQuestionBankImport> resultList = new ArrayList<>();
@ -375,6 +379,9 @@ public class ExamQuestionBankController {
params.setNeedSave(true); params.setNeedSave(true);
try { try {
List<Map<String, String>> examQuestionBankImports = ExcelUtils.jxlExlToList(file.getInputStream(), 0); List<Map<String, String>> examQuestionBankImports = ExcelUtils.jxlExlToList(file.getInputStream(), 0);
if (examQuestionBankImports.size() == 0) {
throw new CustomException("未识别到有效数据!", HttpStatus.INTERNAL_SERVER_ERROR);
}
List<ExamQuestionBank> examQuestionBankList = new ArrayList<>(); List<ExamQuestionBank> examQuestionBankList = new ArrayList<>();
List<ExamQuestionOption> examQuestionOptionList = new ArrayList<>(); List<ExamQuestionOption> examQuestionOptionList = new ArrayList<>();
int index = 0; int index = 0;
@ -391,7 +398,14 @@ public class ExamQuestionBankController {
examQuestionBank.setQuestionName(examQuestionBankImport.get("*试题名称").trim()); examQuestionBank.setQuestionName(examQuestionBankImport.get("*试题名称").trim());
examQuestionBank.setType(getType(examQuestionBankImport.get("*试题类型").trim())); examQuestionBank.setType(getType(examQuestionBankImport.get("*试题类型").trim()));
examQuestionBank.setDifficulty(getDifficulty(examQuestionBankImport.get("*难易程度").trim())); examQuestionBank.setDifficulty(getDifficulty(examQuestionBankImport.get("*难易程度").trim()));
examQuestionBank.setOptions(examQuestionBankImport.get("*试题答案").trim()); String options = examQuestionBankImport.get("*试题答案").trim();
String [] option = new String[options.length()];
for (int i = 0; i < options.length(); i++) {
option[i] = options.substring(i, i + 1);
}
List<String> list = Arrays.asList(option);
Collections.sort(list);
examQuestionBank.setOptions(list.stream().collect(Collectors.joining()));
examQuestionBank.setIsEnable(examQuestionBankImport.get("*是否应用").trim().equals("") ? 1 : 0); examQuestionBank.setIsEnable(examQuestionBankImport.get("*是否应用").trim().equals("") ? 1 : 0);
try { try {
examQuestionBank.setScore(Integer.parseInt(examQuestionBankImport.get("*作答正确得分").trim())); examQuestionBank.setScore(Integer.parseInt(examQuestionBankImport.get("*作答正确得分").trim()));
@ -426,7 +440,7 @@ public class ExamQuestionBankController {
return Result.ok("文件导入成功!数据行数:" + examQuestionBankImports.size()); return Result.ok("文件导入成功!数据行数:" + examQuestionBankImports.size());
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage()); log.error(e.getMessage());
return Result.error("文件导入失败!"); return Result.error(e.getMessage());
} finally { } finally {
try { try {
file.getInputStream().close(); file.getInputStream().close();

View File

@ -260,14 +260,34 @@ public class XzWorkerInfoAuditRecordController {
workerIds.add(workerId); workerIds.add(workerId);
WorkerInfoAuditRecord infoAuditRecord = workerInfoAuditRecordService.getById(workerId); WorkerInfoAuditRecord infoAuditRecord = workerInfoAuditRecordService.getById(workerId);
List<WorkerContract> contractList = new ArrayList<>(); List<WorkerContract> contractList = new ArrayList<>();
JSONArray contract = object.getJSONArray("contract");
if (contract != null) {
StringBuilder builder = new StringBuilder();
for (int i = 0; i < contract.size(); i++) {
if (i > 0) {
builder.append(",");
}
builder.append(contract.getJSONObject(i).getString("name") + "*" + contract.getJSONObject(i).getString("url"));
}
WorkerContract workerContract = new WorkerContract(); WorkerContract workerContract = new WorkerContract();
workerContract.setImageUrl(object.getJSONArray("contract").getJSONObject(0).getString("name") + "*" + object.getJSONArray("contract").getJSONObject(0).getString("url")); workerContract.setImageUrl(builder.toString());
contractList.add(workerContract); contractList.add(workerContract);
}
infoAuditRecord.setContractInfo(JSON.toJSONString(contractList)); infoAuditRecord.setContractInfo(JSON.toJSONString(contractList));
List<WorkerInsurance> insuranceList = new ArrayList<>(); List<WorkerInsurance> insuranceList = new ArrayList<>();
JSONArray insurance = object.getJSONArray("insurance");
if (insurance != null) {
StringBuilder builder = new StringBuilder();
for (int i = 0; i < insurance.size(); i++) {
if (i > 0) {
builder.append(",");
}
builder.append(insurance.getJSONObject(i).getString("name") + "*" + insurance.getJSONObject(i).getString("url"));
}
WorkerInsurance workerInsurance = new WorkerInsurance(); WorkerInsurance workerInsurance = new WorkerInsurance();
workerInsurance.setPhotoUrl(object.getJSONArray("insurance").getJSONObject(0).getString("name") + "*" + object.getJSONArray("insurance").getJSONObject(0).getString("url")); workerInsurance.setPhotoUrl(builder.toString());
insuranceList.add(workerInsurance); insuranceList.add(workerInsurance);
}
infoAuditRecord.setInsuranceInfo(JSON.toJSONString(insuranceList)); infoAuditRecord.setInsuranceInfo(JSON.toJSONString(insuranceList));
List<WorkerCertificate> certificateList = new ArrayList<>(); List<WorkerCertificate> certificateList = new ArrayList<>();
JSONArray certificate = object.getJSONArray("certificate"); JSONArray certificate = object.getJSONArray("certificate");
@ -276,13 +296,21 @@ public class XzWorkerInfoAuditRecordController {
WorkerCertificate workerCertificate = new WorkerCertificate(); WorkerCertificate workerCertificate = new WorkerCertificate();
JSONObject jsonObject = certificate.getJSONObject(i); JSONObject jsonObject = certificate.getJSONObject(i);
for (String s : jsonObject.keySet()) { for (String s : jsonObject.keySet()) {
Object o1 = jsonObject.getJSONArray(s).get(0); JSONArray o1 = jsonObject.getJSONArray(s);
if (o1 instanceof JSONObject) { StringBuilder phoneUrl = new StringBuilder();
System.out.println("====json"); for (int j = 0; j < o1.size(); j++) {
workerCertificate.setPhotoUrl(jsonObject.getJSONArray(s).getJSONObject(0).getString("name") + "*" + jsonObject.getJSONArray(s).getJSONObject(0).getString("url")); if (o1.get(j) instanceof JSONObject) {
if (j > 0) {
phoneUrl.append(",");
}
JSONObject object1 = JSONObject.parseObject(JSON.toJSONString(o1.get(j)));
phoneUrl.append(object1.getString("name") + "*" + object1.getString("url"));
} else { } else {
System.out.println("====number"); workerCertificate.setCertificateType(Integer.parseInt(o1.get(j).toString()));
workerCertificate.setCertificateType(Integer.parseInt(jsonObject.getJSONArray(s).get(0).toString())); }
}
if (phoneUrl.length() > 0) {
workerCertificate.setPhotoUrl(phoneUrl.toString());
} }
} }
certificateList.add(workerCertificate); certificateList.add(workerCertificate);