/*
|
* Copyright (c) 2018-2025, ztt All rights reserved.
|
*
|
* Redistribution and use in source and binary forms, with or without
|
* modification, are permitted provided that the following conditions are met:
|
*
|
* Redistributions of source code must retain the above copyright notice,
|
* this list of conditions and the following disclaimer.
|
* Redistributions in binary form must reproduce the above copyright
|
* notice, this list of conditions and the following disclaimer in the
|
* documentation and/or other materials provided with the distribution.
|
* Neither the name of the pig4cloud.com developer nor the names of its
|
* contributors may be used to endorse or promote products derived from
|
* this software without specific prior written permission.
|
* Author: ztt
|
*/
|
|
package com.chinaztt.mes.technology.controller;
|
|
import com.alibaba.excel.EasyExcel;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.chinaztt.mes.common.wrapper.QueryWrapperUtil;
|
import com.chinaztt.mes.quality.dto.TestStandardDTO;
|
import com.chinaztt.mes.technology.dto.BatchAddDocSamplingRuleParamDTO;
|
import com.chinaztt.mes.technology.dto.BatchAddDocTestStandardParamDTO;
|
import com.chinaztt.mes.technology.dto.JoinDocumentTestStandardDTO;
|
import com.chinaztt.mes.technology.entity.Document;
|
import com.chinaztt.mes.technology.entity.DocumentStandardParam;
|
import com.chinaztt.mes.technology.entity.JoinDocumentBomRouting;
|
import com.chinaztt.mes.technology.excel.DocumentTestStandardData;
|
import com.chinaztt.mes.technology.excel.DocumentTestStandardUploadListener;
|
import com.chinaztt.mes.technology.service.DocumentService;
|
import com.chinaztt.mes.technology.state.document.constant.DocumentStates;
|
import com.chinaztt.ztt.common.core.util.R;
|
import com.chinaztt.ztt.common.log.annotation.SysLog;
|
import com.chinaztt.ztt.common.security.annotation.Inner;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import lombok.AllArgsConstructor;
|
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.multipart.MultipartFile;
|
|
import javax.servlet.http.HttpServletResponse;
|
import java.io.IOException;
|
import java.util.List;
|
|
|
/**
|
* 工艺文件
|
*
|
* @author zhangxy
|
* @date 2021-05-07 09:45:58
|
*/
|
@RestController
|
@AllArgsConstructor
|
@RequestMapping("/document")
|
@Api(value = "document", tags = "工艺文件管理")
|
public class DocumentController {
|
|
private final DocumentService documentService;
|
|
/**
|
* 分页查询
|
*
|
* @param page 分页对象
|
* @param document 工艺文件
|
* @return
|
*/
|
@ApiOperation(value = "分页查询", notes = "分页查询")
|
@GetMapping("/page")
|
public R getDocumentPage(Page page, Document document) {
|
return R.ok(documentService.page(page, QueryWrapperUtil.gen(document).orderByDesc("id")));
|
}
|
|
/**
|
* 通过id查询工艺文件
|
*
|
* @param id id
|
* @return R
|
*/
|
@ApiOperation(value = "通过id查询", notes = "通过id查询")
|
@GetMapping("/{id}")
|
public R getById(@PathVariable("id") Long id) {
|
return R.ok(documentService.getDtoById(id));
|
}
|
|
/**
|
* 通过id查询工艺文件绑定的检测规则
|
*
|
* @param testStandardDTO id
|
* @return R
|
*/
|
@ApiOperation(value = "通过id查询工艺文件绑定的检测规则", notes = "通过id查询工艺文件绑定的检测规则")
|
@GetMapping("/getTestStand")
|
public R getTestStand(Page page, TestStandardDTO testStandardDTO) {
|
Long id = testStandardDTO.getDocumentId();
|
testStandardDTO.setDocumentId(null);
|
return R.ok(documentService.getTestStand(page, QueryWrapperUtil.gen(testStandardDTO), id));
|
}
|
|
/**
|
* 新增工艺文件
|
*
|
* @param document 工艺文件
|
* @return R
|
*/
|
@ApiOperation(value = "新增工艺文件", notes = "新增工艺文件")
|
@SysLog("新增工艺文件")
|
@PostMapping
|
public R save(@RequestBody Document document) {
|
return documentService.fullSave(document);
|
}
|
|
/**
|
* 修改工艺文件
|
*
|
* @param document 工艺文件
|
* @return R
|
*/
|
@ApiOperation(value = "修改工艺文件", notes = "修改工艺文件")
|
@SysLog("修改工艺文件")
|
@PutMapping
|
public R updateById(@RequestBody Document document) {
|
return R.ok(documentService.fullUpdate(document));
|
}
|
|
/**
|
* 通过id删除工艺文件
|
*
|
* @param id id
|
* @return R
|
*/
|
@ApiOperation(value = "通过id删除工艺文件", notes = "通过id删除工艺文件")
|
@SysLog("通过id删除工艺文件")
|
@DeleteMapping("/{id}")
|
public R removeById(@PathVariable Long id) {
|
return R.ok(documentService.removeById(id));
|
}
|
|
/**
|
* 通过id删除工艺文件
|
*
|
* @param ids id
|
* @return R
|
*/
|
@ApiOperation(value = "批量删除工艺文件", notes = "批量删除工艺文件")
|
@SysLog("批量删除工艺文件")
|
@PostMapping("/batchDel")
|
public R batchDel(@RequestBody List<Long> ids) {
|
return R.ok(documentService.batchDel(ids));
|
}
|
|
/**
|
* 计算材料用量
|
*
|
* @param documentId
|
* @return
|
*/
|
@PostMapping("/calcMaterialCost/{documentId}")
|
public R calcMaterialCost(@PathVariable Long documentId) {
|
return documentService.calcMaterialCost(documentId);
|
}
|
|
/**
|
* 保存工艺文件与BOM关系
|
*
|
* @param join
|
* @return
|
*/
|
@PostMapping("/saveBom")
|
public R saveBom(@RequestBody JoinDocumentBomRouting join) {
|
return documentService.saveBom(join);
|
}
|
|
/**
|
* 保存流程图json
|
*
|
* @param document
|
* @return
|
*/
|
@PostMapping("/saveLctJson")
|
public R saveLctJson(@RequestBody Document document) {
|
return R.ok(documentService.updateById(documentService.doUpdateRealUser(document)));
|
}
|
|
/**
|
* 获取流程图json
|
*
|
* @param id
|
* @return
|
*/
|
@GetMapping("/getLctJson/{id}")
|
public R getLctJson(@PathVariable("id") Long id) {
|
return R.ok(documentService.getById(id).getLctJson());
|
}
|
|
/**
|
* 保存工艺文件与检测标准关系
|
*
|
* @param joins
|
* @return
|
*/
|
@PostMapping("/saveTestStandard")
|
public R saveTestStandard(@RequestBody List<JoinDocumentTestStandardDTO> joins) {
|
return documentService.saveTestStandard(joins);
|
}
|
|
/**
|
* 删除工艺文件与检测标准关系
|
*
|
* @param join
|
* @return
|
*/
|
@PostMapping("/deleteTestStandard")
|
public R deleteTestStandard(@RequestBody JoinDocumentTestStandardDTO join) {
|
return documentService.deleteTestStandard(join);
|
}
|
|
/**
|
* 删除工艺文件与BOM关系
|
*
|
* @param join
|
* @return
|
*/
|
@PostMapping("/deleteBom")
|
public R deleteBom(@RequestBody JoinDocumentBomRouting join) {
|
return documentService.deleteBom(join);
|
}
|
|
/**
|
* 工艺路线判断是否有子节点
|
*
|
* @param id
|
* @return
|
*/
|
@GetMapping("/routingChildCheck/{id}")
|
public R routingChildCheck(@PathVariable Long id) {
|
return documentService.routingChildCheck(id);
|
}
|
|
/**
|
* 原材料用量导出
|
*
|
* @param documentId
|
* @param response
|
*/
|
@ApiOperation(value = "导出原材料用量", notes = "导出原材料用量")
|
@GetMapping("/exportMaterialCost/{documentId}")
|
public void exportDutyRecord(@PathVariable Long documentId, HttpServletResponse response) {
|
documentService.exportMaterialCost(documentId, response);
|
}
|
|
/**
|
* 上传结构图文件
|
*
|
* @param file
|
* @return
|
*/
|
@PostMapping("/uploadJgt")
|
public R uploadJgt(@RequestParam("file") MultipartFile file, @RequestParam("documentId") Long documentId) {
|
return documentService.uploadJgt(file, documentId);
|
}
|
|
/**
|
* 删除结构图
|
*
|
* @param jgtId
|
* @return
|
*/
|
@PostMapping("/removeJgt/{jgtId}")
|
public R removeJgt(@PathVariable Long jgtId) {
|
return documentService.removeJgt(jgtId);
|
}
|
|
/**
|
* 删除流程图
|
*
|
* @param documentId
|
* @return
|
*/
|
@PostMapping("/removeLct/{documentId}")
|
public R removeLct(@PathVariable Long documentId) {
|
return documentService.removeLct(documentId);
|
}
|
|
/**
|
* 上传流程图文件
|
*
|
* @param file
|
* @return
|
*/
|
@PostMapping("/uploadLct")
|
public R uploadLct(@RequestParam("file") MultipartFile file, @RequestParam("documentId") Long documentId, @RequestParam("lctRemark") String lctRemark) {
|
return documentService.uploadLct(file, documentId, lctRemark);
|
}
|
|
/**
|
* 查看附件图片
|
*
|
* @param fileName
|
* @param response
|
*/
|
@Inner(value = false)
|
@GetMapping("/file")
|
public void file(@RequestParam("fileName") String fileName, HttpServletResponse response) {
|
documentService.getFile(fileName, response);
|
}
|
|
/**
|
* 复制工艺路线
|
*
|
* @param documentList 工艺
|
* @return R
|
*/
|
@ApiOperation(value = "复制工艺路线", notes = "复制工艺路线")
|
@SysLog("复制工艺路线")
|
@PostMapping("/copy")
|
public R copyDocument(@RequestBody List<Document> documentList) {
|
return documentService.copyDocument(documentList);
|
}
|
|
/**
|
* 通过id查询工艺文件(oa页面展示)
|
*
|
* @param id id
|
* @return R
|
*/
|
@ApiOperation(value = "通过id查询工艺文件(oa页面展示)", notes = "通过id查询工艺文件(oa页面展示)")
|
@GetMapping("/oa/{id}")
|
@Inner(value = false)
|
public R getDocumentById(@PathVariable("id") Long id) {
|
return R.ok(documentService.getDocumentById(id));
|
}
|
|
/**
|
* 批准
|
*
|
* @param ids
|
* @return
|
*/
|
@SysLog("修改工艺文件状态为批准")
|
@PostMapping("/accept")
|
public R accept(@RequestBody List<Long> ids) {
|
return R.ok(documentService.updateStateByIds(ids, DocumentStates.ACCEPTED));
|
}
|
|
/**
|
* 拒绝
|
*
|
* @param ids
|
* @return
|
*/
|
@SysLog("修改工艺文件状态为拒绝")
|
@PostMapping("/reject")
|
public R reject(@RequestBody List<Long> ids) {
|
return R.ok(documentService.updateStateByIds(ids, DocumentStates.REJECT));
|
}
|
|
/**
|
* 取消
|
*
|
* @param ids
|
* @return
|
*/
|
@PostMapping("/cancel")
|
@SysLog("修改工艺文件状态为草稿")
|
public R cancel(@RequestBody List<Long> ids) {
|
return R.ok(documentService.updateStateByIds(ids, DocumentStates.DRAFT));
|
}
|
|
/**
|
* 数据同步到ifs
|
*
|
* @param id
|
* @return
|
*/
|
@GetMapping("/ifsSync/{id}")
|
public R ifsSync(@PathVariable Long id) {
|
try {
|
return documentService.ifsSync(id);
|
} catch (Exception e) {
|
return R.failed(e.getMessage());
|
}
|
}
|
|
/**
|
* 工艺文件-工艺路线-工序-检测标准主从表新增
|
*
|
* @param docBomId 工艺文件与BOM关系表id
|
* @param routingOperationId 工艺工序id
|
* @param testStandardId 检测标准id
|
* @return
|
*/
|
@ApiOperation(value = "工艺文件-工艺路线-工序-检测标准主从表新增", notes = "传参:工艺文件与BOM关系表id&工序id&检测标准id")
|
@SysLog("工艺文件-工艺路线-工序-检测标准主从表新增")
|
@PostMapping("/addDocTestStandard")
|
public R addDocTestStandard(@RequestParam("docBomId") Long docBomId, @RequestParam("routingOperationId") Long routingOperationId, @RequestParam("testStandardId") Long testStandardId) {
|
return R.ok(documentService.addDocTestStandard(docBomId, routingOperationId, testStandardId));
|
}
|
|
/**
|
* 工艺文件-工艺路线-工序-检测标准主从表批量新增
|
*
|
* @param paramList
|
* @return
|
*/
|
@ApiOperation(value = "工艺文件-工艺路线-工序-检测标准主从表批量新增", notes = "传参:工艺文件与BOM关系表id&工序id&检测标准id")
|
@SysLog("工艺文件-工艺路线-工序-检测标准主从表批量新增")
|
@PostMapping("/batchAddDocTestStandard")
|
public R batchAddDocTestStandard(@RequestBody List<BatchAddDocTestStandardParamDTO> paramList) {
|
for (BatchAddDocTestStandardParamDTO param : paramList) {
|
documentService.addDocTestStandard(param.getDocBomId(), param.getRoutingOperationId(), param.getTestStandardId());
|
}
|
Document document = documentService.changeTestStandard(paramList.get(0).getDocBomId());
|
return R.ok(document);
|
}
|
|
/**
|
* 工艺文件-工艺路线-工序-根据检测标准记录id删除检测标准
|
*
|
* @param id 检测标准id
|
* @return
|
*/
|
@ApiOperation(value = "工艺文件-工艺路线-工序-检测标准主表删除", notes = "传参:记录id")
|
@SysLog("工艺文件-工艺路线-工序-检测标准删除")
|
@DeleteMapping("/delDocTestStandardById/{id}")
|
public R delDocTestStandardById(@PathVariable("id") Long id) {
|
return R.ok(documentService.delDocTestStandardById(id));
|
}
|
|
/**
|
* 根据工艺文件-工艺路线-工序id查询检测标准
|
*
|
* @param docBomId 工艺文件与BOM关系表id
|
* @param routingOperationId 工艺工序id
|
* @return
|
*/
|
@ApiOperation(value = "根据工艺文件-工艺路线-查询检测标准", notes = "传参:工艺文件与BOM关系表id&工序id")
|
@GetMapping("/qryDocTestStandard")
|
public R qryDocTestStandard(@RequestParam("docBomId") Long docBomId, @RequestParam("routingOperationId") Long routingOperationId) {
|
return documentService.qryDocTestStandard(docBomId, routingOperationId);
|
}
|
|
/**
|
* 根据工艺文件-工艺路线-工序-检测标准-根据检测参数id删除记录
|
*
|
* @param id 检测参数id
|
* @return
|
*/
|
@ApiOperation(value = "根据工艺文件-工艺路线-工序-检测标准-检测参数记录删除", notes = "传参:记录id")
|
@SysLog("根据工艺文件-工艺路线-工序-检测标准-根据检测参数id删除记录")
|
@DeleteMapping("/delDocTestStandardDetailById/{id}")
|
public R delDocTestStandardDetailById(@PathVariable("id") Long id) {
|
return documentService.delDocTestStandardDetailById(id);
|
}
|
|
/**
|
* 根据工艺文件-工艺路线-工序-检测标准-检测参数明细更新
|
*
|
* @param documentStandardParamList
|
* @return
|
*/
|
@ApiOperation(value = "根据工艺文件-工艺路线-工序-检测标准-检测参数明细更新", notes = "")
|
@SysLog("根据工艺文件-工艺路线-工序-检测标准-检测参数明细更新")
|
@PostMapping("/updDocTestStandardDetails")
|
public R updDocTestStandardDetails(@RequestBody List<DocumentStandardParam> documentStandardParamList) {
|
return documentService.updDocTestStandardDetails(documentStandardParamList);
|
}
|
|
/**
|
* 根据工艺文件-工艺路线-工序-检测标准id查询检测参数明细
|
*
|
* @param standardId 检测标准id
|
* @return
|
*/
|
@ApiOperation(value = "根据工艺文件-工艺路线-工序-查询检测参数明细", notes = "传参:检测标准id")
|
@GetMapping("/qryDocTestStandardDetailsByStandardId")
|
public R qryDocTestStandardDetailsByStandardId(@RequestParam("standardId") Long standardId) {
|
return documentService.qryDocTestStandardDetailsByStandardId(standardId);
|
}
|
|
/**
|
* 根据工艺文件-工艺路线-工序-抽检规则-批量新增抽检规则
|
* @param paramList
|
*/
|
@ApiOperation(value = "根据工艺文件-工艺路线-工序-抽检规则-批量新增抽检规则")
|
@SysLog("根据工艺文件-工艺路线-工序-抽检规则-批量新增抽检规则")
|
@PostMapping("/batchAddDocSamplingRule")
|
public R batchAddDocSamplingRule(@RequestBody List<BatchAddDocSamplingRuleParamDTO> paramList) {
|
for (BatchAddDocSamplingRuleParamDTO param : paramList) {
|
documentService.addDocSamplingRule(param.getDocBomId(), param.getRoutingOperationId(), param.getSamplingRuleId(), null, null);
|
}
|
return R.ok();
|
}
|
|
/**
|
* 根据工艺文件-工艺路线-工序-抽检规则-查询抽检规则
|
* @param docBomId
|
* @param routingOperationId
|
*/
|
@ApiOperation(value = "根据工艺文件-工艺路线-工序-抽检规则-查询抽检规则")
|
@GetMapping("/qryDocSamplingRule")
|
public R qryDocSamplingRule(@RequestParam("docBomId") Long docBomId, @RequestParam("routingOperationId") Long routingOperationId) {
|
return R.ok(documentService.qryDocSamplingRule(docBomId, routingOperationId));
|
}
|
/**
|
* 导入模板下载
|
*
|
* @return
|
*/
|
@ApiOperation(value = "导入模板下载", notes = "导入模板下载")
|
@GetMapping("/export")
|
public void export(HttpServletResponse response) throws IOException {
|
documentService.export(response);
|
}
|
|
/**
|
* 导入工单批次
|
*
|
* @return
|
*/
|
@ApiOperation(value = "工艺文件检测标准导入", notes = "工艺文件检测标准导入")
|
@PostMapping("/upload")
|
public R upload(@RequestParam("file") MultipartFile file) {
|
try {
|
EasyExcel.read(file.getInputStream(), DocumentTestStandardData.class, new DocumentTestStandardUploadListener(documentService)).sheet().doRead();
|
} catch (IOException e) {
|
e.printStackTrace();
|
}
|
return R.ok();
|
}
|
|
}
|