This commit is contained in:
JinLu.Yin 2022-05-17 23:11:44 +08:00
parent 7dbadb12a4
commit efaface48b
2 changed files with 58 additions and 8 deletions

View File

@ -3,7 +3,10 @@ package com.ktg.mes.qc.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ArrayUtil;
import com.ktg.common.constant.UserConstants;
import com.ktg.common.utils.StringUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
@ -30,7 +33,7 @@ import com.ktg.common.core.page.TableDataInfo;
* @date 2022-05-17
*/
@RestController
@RequestMapping("/qc/qctemplate")
@RequestMapping("/mes/qc/qctemplate")
public class QcTemplateController extends BaseController
{
@Autowired
@ -39,19 +42,28 @@ public class QcTemplateController extends BaseController
/**
* 查询检测模板列表
*/
@PreAuthorize("@ss.hasPermi('qc:qctemplate:list')")
@PreAuthorize("@ss.hasPermi('mes:qc:qctemplate:list')")
@GetMapping("/list")
public TableDataInfo list(QcTemplate qcTemplate)
{
startPage();
List<QcTemplate> list = qcTemplateService.selectQcTemplateList(qcTemplate);
if(CollUtil.isNotEmpty(list)){
int i=0;
for (QcTemplate template: list
) {
template.setQcTypesParam(template.getQcTypes().split(","));
list.set(i,template);
}
i++;
}
return getDataTable(list);
}
/**
* 导出检测模板列表
*/
@PreAuthorize("@ss.hasPermi('qc:qctemplate:export')")
@PreAuthorize("@ss.hasPermi('mes:qc:qctemplate:export')")
@Log(title = "检测模板", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, QcTemplate qcTemplate)
@ -64,7 +76,7 @@ public class QcTemplateController extends BaseController
/**
* 获取检测模板详细信息
*/
@PreAuthorize("@ss.hasPermi('qc:qctemplate:query')")
@PreAuthorize("@ss.hasPermi('mes:qc:qctemplate:query')")
@GetMapping(value = "/{templateId}")
public AjaxResult getInfo(@PathVariable("templateId") Long templateId)
{
@ -74,7 +86,7 @@ public class QcTemplateController extends BaseController
/**
* 新增检测模板
*/
@PreAuthorize("@ss.hasPermi('qc:qctemplate:add')")
@PreAuthorize("@ss.hasPermi('mes:qc:qctemplate:add')")
@Log(title = "检测模板", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody QcTemplate qcTemplate)
@ -82,13 +94,26 @@ public class QcTemplateController extends BaseController
if(UserConstants.NOT_UNIQUE.equals(qcTemplateService.checkTemplateCodeUnique(qcTemplate))){
return AjaxResult.error("检测模板编号已存在!");
}
if(ArrayUtil.isNotEmpty(qcTemplate.getQcTypesParam())){
String[] types = qcTemplate.getQcTypesParam();
for (String type:types
) {
if(StringUtils.isNotNull(qcTemplate.getQcTypes())){
qcTemplate.setQcTypes(qcTemplate.getQcTypes()+','+type);
}else{
qcTemplate.setQcTypes(type);
}
}
}
return toAjax(qcTemplateService.insertQcTemplate(qcTemplate));
}
/**
* 修改检测模板
*/
@PreAuthorize("@ss.hasPermi('qc:qctemplate:edit')")
@PreAuthorize("@ss.hasPermi('mes:qc:qctemplate:edit')")
@Log(title = "检测模板", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody QcTemplate qcTemplate)
@ -96,13 +121,24 @@ public class QcTemplateController extends BaseController
if(UserConstants.NOT_UNIQUE.equals(qcTemplateService.checkTemplateCodeUnique(qcTemplate))){
return AjaxResult.error("检测模板编号已存在!");
}
if(ArrayUtil.isNotEmpty(qcTemplate.getQcTypesParam())){
String[] types = qcTemplate.getQcTypesParam();
for (String type:types
) {
if(StringUtils.isNotNull(qcTemplate.getQcTypes())){
qcTemplate.setQcTypes(qcTemplate.getQcTypes()+','+type);
}else{
qcTemplate.setQcTypes(type);
}
}
}
return toAjax(qcTemplateService.updateQcTemplate(qcTemplate));
}
/**
* 删除检测模板
*/
@PreAuthorize("@ss.hasPermi('qc:qctemplate:remove')")
@PreAuthorize("@ss.hasPermi('mes:qc:qctemplate:remove')")
@Log(title = "检测模板", businessType = BusinessType.DELETE)
@DeleteMapping("/{templateIds}")
public AjaxResult remove(@PathVariable Long[] templateIds)

View File

@ -30,6 +30,11 @@ public class QcTemplate extends BaseEntity
@Excel(name = "检测种类")
private String qcTypes;
/**
* 用来传递检测种类参数
*/
private String[] qcTypesParam;
/** 是否启用 */
@Excel(name = "是否启用")
private String enableFlag;
@ -82,7 +87,16 @@ public class QcTemplate extends BaseEntity
{
return qcTypes;
}
public void setEnableFlag(String enableFlag)
public String[] getQcTypesParam() {
return qcTypesParam;
}
public void setQcTypesParam(String[] qcTypesParam) {
this.qcTypesParam = qcTypesParam;
}
public void setEnableFlag(String enableFlag)
{
this.enableFlag = enableFlag;
}