生成考核得分如果已生成直接更新

main
hshansha 2 months ago
parent 73a58bdba5
commit 8c7b7078f7

@ -1,6 +1,8 @@
package com.ruoyi.kaohe.controller; package com.ruoyi.kaohe.controller;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.net.URLEncoder;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@ -10,6 +12,7 @@ import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.kaohe.domain.*; import com.ruoyi.kaohe.domain.*;
import com.ruoyi.kaohe.service.IKhVoteEmpService; import com.ruoyi.kaohe.service.IKhVoteEmpService;
import com.ruoyi.kaohe.service.IKhVoteService; import com.ruoyi.kaohe.service.IKhVoteService;
import com.ruoyi.kaohe.util.EnhancedJsonExporter;
import com.ruoyi.kaohe.util.PinYinUtil; import com.ruoyi.kaohe.util.PinYinUtil;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -51,14 +54,16 @@ public class KhKhrwResultController extends BaseController {
@PreAuthorize("@ss.hasPermi('kaohe:kh_result:generate')") @PreAuthorize("@ss.hasPermi('kaohe:kh_result:generate')")
@PostMapping("/generateResult") @PostMapping("/generateResult")
public AjaxResult generateResult(KhPingce pc) { //传递参数 id、pcTitle、bkhdxtype public AjaxResult generateResult(KhPingce pc) { //传递参数 id、pcTitle、bkhdxtype
boolean isUpdate=false;
//查询是否已经生成结果 //查询是否已经生成结果
KhKhrwResult resultQuery = new KhKhrwResult(); KhKhrwResult resultQuery = new KhKhrwResult();
resultQuery.setPcId(pc.getId()); resultQuery.setPcId(pc.getId());
List<KhKhrwResult> khKhrwResults = khKhrwResultService.selectKhKhrwResultList(resultQuery); List<KhKhrwResult> khKhrwResults = khKhrwResultService.selectKhKhrwResultList(resultQuery);
if(khKhrwResults!=null&&khKhrwResults.size()>0){ if(khKhrwResults!=null&&khKhrwResults.size()>0){
return AjaxResult.error("该考核任务已有生成结果!"); isUpdate=true;
pc.setPcResultId(khKhrwResults.get(0).getId());
} }
return khKhrwResultService.generateResult(pc); return khKhrwResultService.generateResult(pc,isUpdate);
} }
/** /**
@ -83,6 +88,20 @@ public class KhKhrwResultController extends BaseController {
ExcelUtil<KhKhrwResult> util = new ExcelUtil<KhKhrwResult>(KhKhrwResult.class); ExcelUtil<KhKhrwResult> util = new ExcelUtil<KhKhrwResult>(KhKhrwResult.class);
util.exportExcel(response, list, "考核结果数据"); util.exportExcel(response, list, "考核结果数据");
} }
/**
* id
*/
@PreAuthorize("@ss.hasPermi('kaohe:kh_result:export')")
@Log(title = "考核结果", businessType = BusinessType.EXPORT)
@PostMapping("/exportById")
public void exportById(HttpServletResponse response, Long id) throws Exception {
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("汇总数据.xlsx", "UTF-8"));
KhKhrwResult khrwResult = khKhrwResultService.selectKhKhrwResultById(id);
String tableHeader = khrwResult.getTableHeader();
String tableData = khrwResult.getTableData();
EnhancedJsonExporter.exportWithMergedHeader(tableHeader,tableData,response);
}
/** /**
* *

@ -62,5 +62,5 @@ public interface IKhKhrwResultService
*/ */
public int deleteKhKhrwResultById(Long id); public int deleteKhKhrwResultById(Long id);
AjaxResult generateResult(KhPingce pc); AjaxResult generateResult(KhPingce pc,boolean isUpdate);
} }

@ -108,7 +108,7 @@ public class KhKhrwResultServiceImpl implements IKhKhrwResultService
} }
@Override @Override
public AjaxResult generateResult(KhPingce pc) { public AjaxResult generateResult(KhPingce pc,boolean isUpdate) {
JSONArray children = new JSONArray(); JSONArray children = new JSONArray();
JSONObject tableColumn = new JSONObject(); JSONObject tableColumn = new JSONObject();
tableColumn.put("name", "khdx"); tableColumn.put("name", "khdx");
@ -250,7 +250,12 @@ public class KhKhrwResultServiceImpl implements IKhKhrwResultService
pcResult.setPcName(pc.getPcTitle()); pcResult.setPcName(pc.getPcTitle());
pcResult.setTableHeader(children.toJSONString()); pcResult.setTableHeader(children.toJSONString());
pcResult.setTableData(endData.toJSONString()); pcResult.setTableData(endData.toJSONString());
if(isUpdate){
pcResult.setId(pc.getPcResultId());
this.updateKhKhrwResult(pcResult);
}else{
this.insertKhKhrwResult(pcResult); this.insertKhKhrwResult(pcResult);
}
return AjaxResult.success(); return AjaxResult.success();
} }
} }

Loading…
Cancel
Save