package com.ruoyi.project.dc.thirdPartyTesting.controller;
|
|
import com.alibaba.fastjson.JSON;
|
import com.ruoyi.common.constant.DualControlConstants;
|
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
import com.ruoyi.framework.aspectj.lang.annotation.Log;
|
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
|
import com.ruoyi.framework.config.RuoYiConfig;
|
import com.ruoyi.framework.web.controller.BaseController;
|
import com.ruoyi.framework.web.domain.AjaxResult;
|
import com.ruoyi.framework.web.page.TableDataInfo;
|
import com.ruoyi.project.dc.thirdPartyTesting.domain.ThirdPartyTesting;
|
import com.ruoyi.project.dc.thirdPartyTesting.service.IThirdPartyTestingService;
|
import com.ruoyi.project.enumerate.DcAttachmentTypeEnum;
|
import com.ruoyi.project.system.attachment.domain.Attachment;
|
import com.ruoyi.project.system.attachment.service.IAttachmentService;
|
import com.ruoyi.project.system.user.domain.User;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.ui.ModelMap;
|
import org.springframework.web.bind.annotation.*;
|
|
import java.util.Date;
|
import java.util.List;
|
|
/**
|
* 第三方检测Controller
|
*
|
* @author wm
|
* @date 2020-12-07
|
*/
|
@Controller
|
@RequestMapping("/dc/thirdPartyTesting")
|
public class ThirdPartyTestingController extends BaseController {
|
private String prefix = "dc/thirdPartyTesting";
|
|
@Autowired
|
private IThirdPartyTestingService thirdPartyTestingService;
|
|
@Autowired
|
private IAttachmentService attachmentService;
|
|
@RequiresPermissions("dc:thirdPartyTesting:view")
|
@GetMapping()
|
public String thirdPartyTesting() {
|
return prefix + "/thirdPartyTesting";
|
}
|
|
/**
|
* 查询第三方检测列表
|
*/
|
@RequiresPermissions("dc:thirdPartyTesting:list")
|
@PostMapping("/list")
|
@ResponseBody
|
public TableDataInfo list(ThirdPartyTesting thirdPartyTesting) {
|
User user = getSysUser();
|
thirdPartyTesting.setCompanyId(user.getCompanyId());
|
|
startPage();
|
List<ThirdPartyTesting> list = thirdPartyTestingService.selectThirdPartyTestingList(thirdPartyTesting);
|
return getDataTable(list);
|
}
|
|
/**
|
* 导出第三方检测列表
|
*/
|
@RequiresPermissions("dc:thirdPartyTesting:export")
|
@Log(title = "第三方检测", businessType = BusinessType.EXPORT)
|
@PostMapping("/export")
|
@ResponseBody
|
public AjaxResult export(ThirdPartyTesting thirdPartyTesting) {
|
User user = getSysUser();
|
thirdPartyTesting.setCompanyId(user.getCompanyId());
|
|
List<ThirdPartyTesting> list = thirdPartyTestingService.selectThirdPartyTestingList(thirdPartyTesting);
|
ExcelUtil<ThirdPartyTesting> util = new ExcelUtil<ThirdPartyTesting>(ThirdPartyTesting.class);
|
return util.exportExcel(list, "thirdPartyTesting");
|
}
|
|
/**
|
* 新增第三方检测
|
*/
|
@GetMapping("/add")
|
public String add() {
|
return prefix + "/add";
|
}
|
|
/**
|
* 新增保存第三方检测
|
*/
|
@RequiresPermissions("dc:thirdPartyTesting:add")
|
@Log(title = "第三方检测", businessType = BusinessType.INSERT)
|
@PostMapping("/add")
|
@ResponseBody
|
public AjaxResult addSave(ThirdPartyTesting thirdPartyTesting) {
|
User user = getSysUser();
|
thirdPartyTesting.setCompanyId(user.getCompanyId());
|
|
int addNum = thirdPartyTestingService.insertThirdPartyTesting(thirdPartyTesting);
|
|
//处理新增的附件
|
String testingOwnedFile = thirdPartyTesting.getTestingOwnedFile();
|
if(StringUtils.isNotEmpty(testingOwnedFile)&&addNum>0) {
|
List<Attachment> attachmentList = JSON.parseArray(testingOwnedFile, Attachment.class);
|
if (attachmentList.size() > 0) {
|
for (Attachment attachment : attachmentList) {
|
attachment.setFileJoinId(thirdPartyTesting.getTestingId());
|
attachment.setAttachmentType(DcAttachmentTypeEnum.Third_Party_Testing.getType());
|
attachment.setCompanyId(user.getCompanyId());
|
attachment.setCreateBy(user.getUserName());
|
attachment.setCreateUserId(user.getUserId());
|
attachment.setCreateTime(new Date());
|
|
attachmentService.insertAttachment(attachment);
|
}
|
}
|
}
|
return toAjax(addNum);
|
}
|
|
/**
|
* 修改第三方检测
|
*/
|
@GetMapping("/edit/{testingId}")
|
public String edit(@PathVariable("testingId") Long testingId, ModelMap mmap) {
|
ThirdPartyTesting thirdPartyTesting = thirdPartyTestingService.selectThirdPartyTestingById(testingId);
|
mmap.put("thirdPartyTesting", thirdPartyTesting);
|
|
Attachment attachment = new Attachment();
|
attachment.setFileJoinId(testingId);
|
attachment.setAttachmentType(DcAttachmentTypeEnum.Third_Party_Testing.getType());
|
List<Attachment> attachmentList = attachmentService.selectAttachmentList(attachment);
|
mmap.put("fileList",attachmentList);
|
|
mmap.put("serviceDomainName", DualControlConstants.SERVICE_DOMAIN_NAME);
|
|
return prefix + "/edit";
|
}
|
|
/**
|
* 修改第三方检测
|
*/
|
@GetMapping("/detail/{testingId}")
|
public String detail(@PathVariable("testingId") Long testingId, ModelMap mmap) {
|
ThirdPartyTesting thirdPartyTesting = thirdPartyTestingService.selectThirdPartyTestingById(testingId);
|
mmap.put("thirdPartyTesting", thirdPartyTesting);
|
|
Attachment attachment = new Attachment();
|
attachment.setFileJoinId(testingId);
|
attachment.setAttachmentType(DcAttachmentTypeEnum.Third_Party_Testing.getType());
|
List<Attachment> attachmentList = attachmentService.selectAttachmentList(attachment);
|
mmap.put("fileList",attachmentList);
|
|
mmap.put("serviceDomainName", DualControlConstants.SERVICE_DOMAIN_NAME);
|
|
return prefix + "/detail";
|
}
|
|
/**
|
* 修改保存第三方检测
|
*/
|
@RequiresPermissions("dc:thirdPartyTesting:edit")
|
@Log(title = "第三方检测", businessType = BusinessType.UPDATE)
|
@PostMapping("/edit")
|
@ResponseBody
|
public AjaxResult editSave(ThirdPartyTesting thirdPartyTesting) {
|
User user = getSysUser();
|
thirdPartyTesting.setCompanyId(user.getCompanyId());
|
|
int updateNum = thirdPartyTestingService.updateThirdPartyTesting(thirdPartyTesting);
|
|
//处理新增的附件
|
String testingOwnedFile = thirdPartyTesting.getTestingOwnedFile();
|
if(StringUtils.isNotEmpty(testingOwnedFile)&&updateNum>0) {
|
List<Attachment> attachmentList = JSON.parseArray(testingOwnedFile, Attachment.class);
|
if (attachmentList.size() > 0) {
|
for (Attachment attachment : attachmentList) {
|
attachment.setFileJoinId(thirdPartyTesting.getTestingId());
|
attachment.setAttachmentType(DcAttachmentTypeEnum.Third_Party_Testing.getType());
|
attachment.setCompanyId(user.getCompanyId());
|
attachment.setCreateBy(user.getUserName());
|
attachment.setCreateUserId(user.getUserId());
|
attachment.setCreateTime(new Date());
|
|
attachmentService.insertAttachment(attachment);
|
}
|
}
|
}
|
|
return toAjax(updateNum);
|
}
|
|
/**
|
* 删除第三方检测
|
*/
|
@RequiresPermissions("dc:thirdPartyTesting:remove")
|
@Log(title = "第三方检测", businessType = BusinessType.DELETE)
|
@PostMapping("/remove")
|
@ResponseBody
|
public AjaxResult remove(String ids) {
|
return toAjax(thirdPartyTestingService.deleteThirdPartyTestingByIds(ids));
|
}
|
}
|