package org.springblade.modules.accreditation.controller;
|
|
import com.alibaba.excel.EasyExcel;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiParam;
|
import lombok.AllArgsConstructor;
|
import org.apache.commons.codec.Charsets;
|
import org.springblade.core.mp.support.Condition;
|
import org.springblade.core.mp.support.Query;
|
import org.springblade.core.tool.api.R;
|
import org.springblade.core.tool.utils.DateUtil;
|
import org.springblade.core.tool.utils.Func;
|
import org.springblade.modules.FTP.FtpUtil;
|
import org.springblade.modules.accreditation.excel.ExportSecurityBookPaperExcel;
|
import org.springblade.modules.accreditation.excel.ExportSecurityPaperExcel;
|
import org.springblade.modules.system.service.IUserService;
|
import org.springblade.modules.accreditation.entity.AccreditationRecords;
|
import org.springblade.modules.accreditation.service.AccreditationRecordsService;
|
import org.springblade.modules.accreditation.vo.AccreditationRecordsVo;
|
import org.springframework.web.bind.annotation.*;
|
|
import javax.servlet.http.HttpServletResponse;
|
import java.io.IOException;
|
import java.net.URLEncoder;
|
import java.text.SimpleDateFormat;
|
import java.util.*;
|
|
/**
|
* @author zhongrj
|
* @time 2021-11-3
|
* @desc 制证记录控制层
|
*/
|
@RestController
|
@AllArgsConstructor
|
@RequestMapping("/accreditationRecords")
|
public class AccreditationRecordsController {
|
|
private final AccreditationRecordsService accreditationRecordsService;
|
|
private final IUserService userService;
|
|
|
/**
|
* 自定义分页
|
* @param query page,size
|
* @param accreditationRecords 制证记录信息对象
|
*/
|
@GetMapping("/page")
|
public R<IPage<AccreditationRecordsVo>> page(AccreditationRecordsVo accreditationRecords, Query query) {
|
IPage<AccreditationRecordsVo> pages = accreditationRecordsService.selectAccreditationRecordsPage(Condition.getPage(query), accreditationRecords);
|
return R.data(pages);
|
}
|
|
/**
|
* 新增
|
* @param accreditationRecords 制证记录信息对象
|
*/
|
@PostMapping("/save")
|
@ApiOperation(value = "新增", notes = "传入accreditationRecords")
|
public R save(@RequestBody AccreditationRecords accreditationRecords){
|
return R.data(accreditationRecordsService.save(accreditationRecords));
|
}
|
|
|
|
/**
|
* 制证申请(批量)
|
* @param accreditationRecords 制证记录信息对象
|
*/
|
@PostMapping("/securityApply")
|
@ApiOperation(value = "新增", notes = "传入accreditationRecords")
|
public R securityApply(@RequestBody AccreditationRecordsVo accreditationRecords){
|
return R.data(accreditationRecordsService.securityApply(accreditationRecords));
|
}
|
|
|
/**
|
* 审核
|
* @param accreditationRecords 制证记录信息对象
|
*/
|
@PostMapping("/audit")
|
public R audit(@RequestBody AccreditationRecords accreditationRecords){
|
accreditationRecords.setAuditTime(new Date());
|
boolean b = accreditationRecordsService.updateById(accreditationRecords);
|
//内网同步
|
String s =
|
"update sys_accreditation_records set audit_status = " + accreditationRecords.getAuditStatus() + "" +
|
",audit_detail = " + accreditationRecords.getAuditDetail() + "" +
|
",audit_time = " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(accreditationRecords.getAuditTime()) + "" +
|
",audit_user = " + accreditationRecords.getAuditUser() + " " +
|
"where id = " + "'" + accreditationRecords.getId() + "'";
|
FtpUtil.sqlFileUpload(s);
|
//返回
|
return R.status(b);
|
}
|
|
|
/**
|
* 批量审核
|
* @param accreditationRecords 制证记录信息对象
|
*/
|
@PostMapping("/batchAudit")
|
public R batchAudit(@RequestBody AccreditationRecordsVo accreditationRecords){
|
//取出申请id
|
String ids = accreditationRecords.getIds();
|
List<String> list = Arrays.asList(ids.split(","));
|
//批量审核
|
list.forEach(id->{
|
accreditationRecords.setId(Long.parseLong(id));
|
accreditationRecords.setAuditTime(new Date());
|
accreditationRecordsService.updateById(accreditationRecords);
|
//内网同步
|
String s =
|
"update sys_accreditation_records set audit_status = " + accreditationRecords.getAuditStatus() + "" +
|
",audit_detail = " + accreditationRecords.getAuditDetail() + "" +
|
",audit_time = " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(accreditationRecords.getAuditTime()) + "" +
|
",audit_user = " + accreditationRecords.getAuditUser() + " " +
|
"where id = " + "'" + accreditationRecords.getId() + "'";
|
FtpUtil.sqlFileUpload(s);
|
});
|
//返回
|
return R.status(true);
|
}
|
|
|
/**
|
* 修改
|
* @param accreditationRecords 制证记录信息对象
|
*/
|
@PostMapping("/update")
|
public R update(@RequestBody AccreditationRecords accreditationRecords){
|
return R.status(accreditationRecordsService.updateById(accreditationRecords));
|
}
|
|
/**
|
* 新增或修改
|
* @param accreditationRecords 制证记录信息对象
|
*/
|
@PostMapping("/submit")
|
public R submit(@RequestBody AccreditationRecords accreditationRecords){
|
return R.data(accreditationRecordsService.saveOrUpdate(accreditationRecords));
|
}
|
|
/**
|
* 删除
|
* @param ids 制证记录信息ids 数组
|
*/
|
@PostMapping("/remove")
|
public R remove(@ApiParam(value = "主键集合") @RequestParam String ids) {
|
return R.status(accreditationRecordsService.removeByIds(Func.toLongList(ids)));
|
}
|
|
/**
|
* 详情
|
* @param accreditationRecords 制证记录信息对象
|
*/
|
@GetMapping("/detail")
|
@ApiOperation(value = "详情", notes = "传入accreditationRecords")
|
public R<AccreditationRecords> detail(AccreditationRecords accreditationRecords) {
|
AccreditationRecords detail = accreditationRecordsService.getOne(Condition.getQueryWrapper(accreditationRecords));
|
return R.data(detail);
|
}
|
|
|
/**
|
* 详情
|
* @param accreditationRecords 制证记录信息对象
|
*/
|
@GetMapping("/details")
|
@ApiOperation(value = "详情", notes = "传入accreditationRecords")
|
public R<AccreditationRecordsVo> details(AccreditationRecords accreditationRecords) {
|
AccreditationRecordsVo detail = accreditationRecordsService.getAccreditationRecordsDetails(accreditationRecords);
|
return R.data(detail);
|
}
|
|
/**
|
* 导出保安员证信息
|
*/
|
@GetMapping("export-security-paper")
|
public void exportSecurityPaper(AccreditationRecordsVo accreditationRecords, HttpServletResponse response) throws IOException {
|
//按条件查询成绩数据
|
List<ExportSecurityPaperExcel> excels = accreditationRecordsService.exportSecurityPaperList(accreditationRecords);
|
String fileName = null;
|
try {
|
response.setContentType("application/vnd.ms-excel");
|
response.setCharacterEncoding(org.apache.commons.codec.Charsets.UTF_8.name());
|
fileName = URLEncoder.encode("保安员证数据"+ DateUtil.time(), Charsets.UTF_8.name());
|
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
|
//修改单元格格式为文本格式
|
EasyExcel.write(response.getOutputStream(), ExportSecurityPaperExcel.class)
|
.sheet("保安员证数据表")
|
//自定义行高
|
// .registerWriteHandler(new CustomCellWriteHeightConfig())
|
//自定义宽度
|
// .registerWriteHandler(new CustomCellWriteWeightConfig())
|
//写入
|
.doWrite(excels);
|
} catch (Throwable var6) {
|
throw var6;
|
}
|
// ExcelUtil.export(response, "保安员证数据" + DateUtil.time(), "保安员证数据表", excels, ExportSecurityPaperExcel.class);
|
}
|
|
|
/**
|
* 导出证书制证信息
|
*/
|
@GetMapping("export-security-book-paper")
|
public void exportSecurityBookPaper(AccreditationRecordsVo accreditationRecords, HttpServletResponse response) throws IOException {
|
//按条件查询成绩数据
|
List<ExportSecurityBookPaperExcel> excels = accreditationRecordsService.exportSecurityBookPaper(accreditationRecords);
|
String fileName = null;
|
try {
|
response.setContentType("application/vnd.ms-excel");
|
response.setCharacterEncoding(org.apache.commons.codec.Charsets.UTF_8.name());
|
fileName = URLEncoder.encode("证书制证数据"+ DateUtil.time(), Charsets.UTF_8.name());
|
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
|
//修改单元格格式为文本格式
|
EasyExcel.write(response.getOutputStream(), ExportSecurityBookPaperExcel.class)
|
.sheet("证书制证数据表")
|
.doWrite(excels);
|
} catch (Throwable var6) {
|
throw var6;
|
}
|
}
|
|
|
}
|