|
|
|
|
@ -1,9 +1,14 @@
|
|
|
|
|
package com.ruoyi.kaohe.controller;
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
|
|
|
|
import com.ruoyi.kaohe.domain.*;
|
|
|
|
|
import com.ruoyi.kaohe.service.IKhPcEmpService;
|
|
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.PutMapping;
|
|
|
|
|
@ -16,7 +21,6 @@ import com.ruoyi.common.annotation.Log;
|
|
|
|
|
import com.ruoyi.common.core.controller.BaseController;
|
|
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
|
|
import com.ruoyi.common.enums.BusinessType;
|
|
|
|
|
import com.ruoyi.kaohe.domain.KhPingce;
|
|
|
|
|
import com.ruoyi.kaohe.service.IKhPingceService;
|
|
|
|
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
|
|
|
import com.ruoyi.common.core.page.TableDataInfo;
|
|
|
|
|
@ -33,6 +37,8 @@ public class KhPingceController extends BaseController
|
|
|
|
|
{
|
|
|
|
|
@Autowired
|
|
|
|
|
private IKhPingceService khPingceService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private IKhPcEmpService pcEmpService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询考核评测列表
|
|
|
|
|
@ -74,10 +80,25 @@ public class KhPingceController extends BaseController
|
|
|
|
|
*/
|
|
|
|
|
@PreAuthorize("@ss.hasPermi('kaohe:pingce:add')")
|
|
|
|
|
@Log(title = "考核评测", businessType = BusinessType.INSERT)
|
|
|
|
|
@Transactional
|
|
|
|
|
@PostMapping
|
|
|
|
|
public AjaxResult add(@RequestBody KhPingce khPingce)
|
|
|
|
|
{
|
|
|
|
|
return toAjax(khPingceService.insertKhPingce(khPingce));
|
|
|
|
|
khPingceService.insertKhPingce(khPingce);
|
|
|
|
|
//增加关联表
|
|
|
|
|
List<KhEmployee> pcEmps = khPingce.getPcEmps();
|
|
|
|
|
if(pcEmps !=null&& pcEmps.size()>0){
|
|
|
|
|
for(KhEmployee item:pcEmps){
|
|
|
|
|
KhPcEmp pcEmp = new KhPcEmp();
|
|
|
|
|
pcEmp.setPcId(khPingce.getId());
|
|
|
|
|
pcEmp.setEmpId(item.getId());
|
|
|
|
|
pcEmp.setEmpName(item.getEmpName());
|
|
|
|
|
pcEmp.setDeptId(item.getDeptId());
|
|
|
|
|
pcEmp.setDeptName(item.getDeptName());
|
|
|
|
|
pcEmpService.insertKhPcEmp(pcEmp);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return AjaxResult.success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -86,9 +107,30 @@ public class KhPingceController extends BaseController
|
|
|
|
|
@PreAuthorize("@ss.hasPermi('kaohe:pingce:edit')")
|
|
|
|
|
@Log(title = "考核评测", businessType = BusinessType.UPDATE)
|
|
|
|
|
@PutMapping
|
|
|
|
|
@Transactional
|
|
|
|
|
public AjaxResult edit(@RequestBody KhPingce khPingce)
|
|
|
|
|
{
|
|
|
|
|
return toAjax(khPingceService.updateKhPingce(khPingce));
|
|
|
|
|
khPingceService.updateKhPingce(khPingce);
|
|
|
|
|
|
|
|
|
|
List<KhEmployee> pcEmps = khPingce.getPcEmps();
|
|
|
|
|
if(pcEmps !=null&& pcEmps.size()>0){
|
|
|
|
|
//删除原来关联
|
|
|
|
|
KhPcEmp query = new KhPcEmp();
|
|
|
|
|
query.setPcId(khPingce.getId());
|
|
|
|
|
List<KhPcEmp> temItems = pcEmpService.selectKhPcEmpList(query);
|
|
|
|
|
List<Long> ids = temItems.stream().map(KhPcEmp::getId).collect(Collectors.toList());
|
|
|
|
|
pcEmpService.deleteKhPcEmpByIds(ids.toArray(new Long[ids.size()]));
|
|
|
|
|
//增加新的关联
|
|
|
|
|
for(KhEmployee item:pcEmps){
|
|
|
|
|
KhPcEmp pcEmp = new KhPcEmp();
|
|
|
|
|
pcEmp.setEmpId(item.getId());
|
|
|
|
|
pcEmp.setEmpName(item.getEmpName());
|
|
|
|
|
pcEmp.setDeptId(item.getDeptId());
|
|
|
|
|
pcEmp.setDeptName(item.getDeptName());
|
|
|
|
|
pcEmpService.insertKhPcEmp(pcEmp);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return AjaxResult.success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -99,6 +141,12 @@ public class KhPingceController extends BaseController
|
|
|
|
|
@DeleteMapping("/{ids}")
|
|
|
|
|
public AjaxResult remove(@PathVariable Long[] ids)
|
|
|
|
|
{
|
|
|
|
|
for(Long id:ids){
|
|
|
|
|
KhPingce khPingce = khPingceService.selectKhPingceById(id);
|
|
|
|
|
if(!khPingce.getState().equals("0")){
|
|
|
|
|
return AjaxResult.error("评测:"+khPingce.getPcTitle()+" 不是未开始状态,不允许删除");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return toAjax(khPingceService.deleteKhPingceByIds(ids));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|