whycxzp
2024-01-03 d2ba7ed50955701234b1b50ceaf04fe36b86c61d
src/main/java/com/whyc/controller/MaterialController.java
@@ -3,6 +3,7 @@
import com.whyc.dto.Response;
import com.whyc.pojo.Material;
import com.whyc.service.MaterialService;
import com.whyc.util.ActionUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
@@ -10,7 +11,9 @@
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
@Api(tags = "物料管理")
@@ -60,9 +63,51 @@
        return service.getAttachByMaterialId(materialId);
    }
    @ApiOperation(value = "根据物料型号('-','_'之前的部分)查询物料的历史版本",notes = "9.3修改后使用")
    @GetMapping("getMaterialVersion")
    public Response getMaterialVersion(@RequestParam String subModel){
        return service.getMaterialVersion(subModel);
    }
    @ApiOperation(value = "根据物料id查询物料信息",notes = "9.3修改后使用")
    @GetMapping("getMaterialById")
    public Response getMaterialById(@RequestParam int materialId){
        return service.getMaterialById(materialId);
    }
    /**物料id-物料编码-物料型号*/
    @ApiOperation(value = "追加附件",notes = "materialStr为json字符串,包含id,subCode,subModel")
    @PostMapping("attachment")
    public Response addAttachment(@RequestParam String materialStr, @RequestParam MultipartFile... file) throws IOException {
        Material material = ActionUtil.getGson().fromJson(materialStr, Material.class);
        List<MultipartFile> multipartFileList = Arrays.asList(file);
        return service.addAttachment(multipartFileList,material);
    }
    @ApiOperation("物料图纸对比")
    @GetMapping("dwgCompare")
    public Response dwgCompare(@RequestParam int materialId,@RequestParam int materialId2) throws IOException {
        return service.dwgCompare(materialId,materialId2);
    }
    /**物料id-物料编码-物料型号*/
    @ApiOperation(value = "更新图片或者图纸",notes = "materialStr为json字符串,包含id,subCode,subModel")
    @PutMapping("picOrDwg")
    public Response updatePicOrDwg(@RequestParam String materialStr, @RequestPart MultipartFile file) throws IOException {
        Material material = ActionUtil.getGson().fromJson(materialStr, Material.class);
        return service.updatePicOrDwg(file,material);
    }
    @PostMapping("checkNaming")
    @ApiOperation("命名规范校验")
    public void checkNaming( HttpServletResponse response,@RequestParam MultipartFile file) throws IOException, InvalidFormatException {
        service.checkNaming(file.getInputStream(),response);
    }
    @ApiOperation("物料推送弹窗使用")
    @GetMapping("getMaterialDialog")
    public Response getMaterialDialog(@RequestParam String subCode,@RequestParam String subName,@RequestParam String subModel)  {
        return service.getMaterialDialog(subCode,subName,subModel);
    }
}