修改Controller

This commit is contained in:
liuchengqian 2022-03-02 14:51:32 +08:00
parent 2f3a995359
commit fd01a3a3d6
19 changed files with 148 additions and 80 deletions

View File

@ -53,7 +53,8 @@ public class DataDictController {
* @return
*/
@GetMapping("/selectDataDict")
public String selectDataDict(@RequestParam("inspectionItemName") String inspectionItemName, @RequestParam("inspectionItemCode") String inspectionItemCode) {
public String selectDataDict(@RequestParam("inspectionItemName") String inspectionItemName,
@RequestParam("inspectionItemCode") String inspectionItemCode) {
Locale locale = LocaleContextHolder.getLocale();
List<DataDict> dataDict = dataDictQuery.selectDataDict(inspectionItemName, inspectionItemCode);
if (dataDict == null || dataDict.size() == 0) {

View File

@ -45,11 +45,12 @@ public class DataSourceController {
/**
* 查询某一产品的测量信息
*
* @param lotNo 批次号
* @param machineNo 机器号
* @param materialNo 物料号
* @param modelNo 模具号
* @param partNo 零件号
* @param lotNo 批次号
* @param machineNo 机器号
* @param materialNo 物料号
* @param modelNo 模具号
* @param machineTypeNo 机种号
* @param craftItemName 工艺项目名称
* @return
*/
@GetMapping("/selectDataSource")
@ -57,9 +58,10 @@ public class DataSourceController {
@RequestParam(required = false, value = "machineNo") String machineNo,
@RequestParam(required = false, value = "materialNo") String materialNo,
@RequestParam(required = false, value = "modelNo") String modelNo,
@RequestParam(required = false, value = "partNo") String partNo) {
@RequestParam(required = false, value = "machineTypeNo") String machineTypeNo,
@RequestParam(required = false, value = "craftItemName") String craftItemName) {
Locale locale = LocaleContextHolder.getLocale();
List<DataSource> dataSources = dataSourceQuery.selectDataSource(lotNo, machineNo, materialNo, modelNo, partNo);
List<DataSource> dataSources = dataSourceQuery.selectDataSource(lotNo, machineNo, materialNo, modelNo, machineTypeNo, craftItemName);
if (dataSources == null || dataSources.size() == 0) {
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "暂时没有该产品的测量信息!", locale);
}

View File

@ -58,9 +58,15 @@ public class FileController {
@PostMapping("/updateFileUploadPath")
@Transactional(rollbackOn = Exception.class)
public String updateFileUploadPath(@RequestBody FileUpdateQo fileUpdateQo, @RequestParam("fileExcel") MultipartFile fileExcel) throws IOException {
String lotNo = fileUpdateQo.getLotNo();
String machineNo = fileUpdateQo.getMachineNo();
String materialNo = fileUpdateQo.getMaterialNo();
String modelNo = fileUpdateQo.getModelNo();
String machineTypeNo = fileUpdateQo.getMachineTypeNo();
String craftItemName = fileUpdateQo.getCraftItemName();
Locale locale = LocaleContextHolder.getLocale();
String file = ExcelUploadUtil.memoryFile(fileExcel,1);
fileDao.updateFileUploadPath(fileUpdateQo.getLotNo(), fileUpdateQo.getMachineNo(), fileUpdateQo.getMaterialNo(), fileUpdateQo.getModelNo(), fileUpdateQo.getPartNo(), file);
String file = ExcelUploadUtil.memoryFile(fileExcel, 1);
fileDao.updateFileUploadPath(lotNo, machineNo, materialNo, modelNo, machineTypeNo, craftItemName, file);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功!", locale);
}

View File

@ -44,13 +44,14 @@ public class PictureController {
* 查询图片
*/
@GetMapping("/selectPicture")
public String selectPicture(@RequestParam("lotNo") String lotNo,
@RequestParam("machineNo") String machineNo,
@RequestParam("materialNo") String materialNo,
@RequestParam("modelNo") String modelNo,
@RequestParam("partNo") String partNo) {
public String selectPicture(@RequestParam(required = false, value = "lotNo") String lotNo,
@RequestParam(required = false, value = "machineNo") String machineNo,
@RequestParam(required = false, value = "materialNo") String materialNo,
@RequestParam(required = false, value = "modelNo") String modelNo,
@RequestParam(required = false, value = "machineTypeNo") String machineTypeNo,
@RequestParam(required = false, value = "craftItemName") String craftItemName) {
Locale locale = LocaleContextHolder.getLocale();
List<PictureEntity> pictureEntities = pictureQuery.selectPicture(lotNo, machineNo, materialNo, modelNo, partNo);
List<PictureEntity> pictureEntities = pictureQuery.selectPicture(lotNo, machineNo, materialNo, modelNo, machineTypeNo,craftItemName);
if (pictureEntities.isEmpty()) {
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "暂时没有该零件的图片!", locale);
}

View File

@ -41,10 +41,11 @@ public class SpecController {
* 查询规格信息
*/
@GetMapping("/selectSpec")
public String selectSpec(@RequestParam(required = false, value = "partNo") String partNo,
@RequestParam(required = false, value = "inspectionItemCode") String inspectionItemCode) {
public String selectSpec(@RequestParam(required = false, value = "machineTypeNo") String machineTypeNo,
@RequestParam(required = false, value = "inspectionItemCode") String inspectionItemCode,
@RequestParam(required = false, value = "craftItemName") String craftItemName) {
Locale locale = LocaleContextHolder.getLocale();
List<SpecEntity> specEntities = specQuery.selectSpec(partNo, inspectionItemCode);
List<SpecEntity> specEntities = specQuery.selectSpec(machineTypeNo, inspectionItemCode, craftItemName);
if (specEntities.isEmpty()) {
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "暂时没有该零件的规格信息!", locale);
}

View File

@ -19,15 +19,16 @@ public interface FileDao extends JpaRepository<FileEntity, Long>, JpaSpecificati
/**
* 查询文件信息
*
* @param lotNo 批次号
* @param machineNo 机器号
* @param materialNo 物料号
* @param modelNo 模具号
* @param partNo 零件号
* @param lotNo 批次号
* @param machineNo 机器号
* @param materialNo 物料号
* @param modelNo 模具号
* @param machineTypeNo 机种号
* @param craftItemName 工艺项目名称
* @return
*/
@Query(value = "SELECT * FROM qc_inspection_file WHERE lot_no = ? AND machine_no = ? AND material_no = ? AND model_no = ? AND part_no = ? ", nativeQuery = true)
Optional<FileEntity> selectFile(String lotNo, String machineNo, String materialNo, String modelNo, String partNo);
@Query(value = "SELECT * FROM qc_inspection_file WHERE lot_no = ? AND machine_no = ? AND material_no = ? AND model_no = ? AND machine_type_no = ? AND craft_item_name = ? ", nativeQuery = true)
Optional<FileEntity> selectFile(String lotNo, String machineNo, String materialNo, String modelNo, String machineTypeNo, String craftItemName);
/**
* 修改模板上传信息
@ -36,12 +37,13 @@ public interface FileDao extends JpaRepository<FileEntity, Long>, JpaSpecificati
* @param machineNo 机器号
* @param materialNo 物料号
* @param modelNo 模具号
* @param partNo 零件号
* @param machineTypeNo 机种号
* @param craftItemName 工艺项目名称
* @param fileUploadPath 模板路径
*/
@Modifying(clearAutomatically = true)
@Query(value = "UPDATE qc_inspection_file SET file_upload_path = ?6 WHERE lot_no = ?1 AND machine_no = ?2 AND material_no = ?3 AND model_no = ?4 AND part_no = ?5 ", nativeQuery = true)
void updateFileUploadPath(String lotNo, String machineNo, String materialNo, String modelNo, String partNo, String fileUploadPath);
@Query(value = "UPDATE qc_inspection_file SET file_upload_path = ?7 WHERE lot_no = ?1 AND machine_no = ?2 AND material_no = ?3 AND model_no = ?4 AND machine_type_no = ?5 AND craft_item_name = ?6 ", nativeQuery = true)
void updateFileUploadPath(String lotNo, String machineNo, String materialNo, String modelNo, String machineTypeNo, String craftItemName, String fileUploadPath);
/**
* 修改文件下载信息
@ -50,12 +52,13 @@ public interface FileDao extends JpaRepository<FileEntity, Long>, JpaSpecificati
* @param machineNo 机器号
* @param materialNo 物料号
* @param modelNo 模具号
* @param partNo 零件号
* @param machineTypeNo 机种号
* @param craftItemName 工艺项目名称
* @param fileDownloadPath 文件下载路径
*/
@Modifying(clearAutomatically = true)
@Query(value = "UPDATE qc_inspection_file SET file_download_path = ?6 WHERE lot_no = ?1 AND machine_no = ?2 AND material_no = ?3 AND model_no = ?4 AND part_no = ?5 ", nativeQuery = true)
void updateFileDownloadPath(String lotNo, String machineNo, String materialNo, String modelNo, String partNo, String fileDownloadPath);
@Query(value = "UPDATE qc_inspection_file SET file_download_path = ?7 WHERE lot_no = ?1 AND machine_no = ?2 AND material_no = ?3 AND model_no = ?4 AND machine_type_no = ?5 AND craft_item_name = ?6 ", nativeQuery = true)
void updateFileDownloadPath(String lotNo, String machineNo, String materialNo, String modelNo, String machineTypeNo, String craftItemName, String fileDownloadPath);
}

View File

@ -3,7 +3,6 @@ package com.xkrs.dao;
import com.xkrs.model.entity.PictureEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Component;
@ -19,27 +18,15 @@ public interface PictureDao extends JpaRepository<PictureEntity, Long>, JpaSpeci
/**
* 查询图片信息
*
* @param lotNo 批次号
* @param machineNo 机器号
* @param materialNo 物料号
* @param modelNo 模具号
* @param partNo 零件号
* @param lotNo 批次号
* @param machineNo 机器号
* @param materialNo 物料号
* @param modelNo 模具号
* @param machineTypeNo 机种号
* @param craftItemName 工艺项目名称
* @return
*/
@Query(value = "SELECT * FROM qc_inspection_picture WHERE lot_no = ? AND machine_no = ? AND material_no = ? AND model_no = ? AND part_no = ? ", nativeQuery = true)
Optional<PictureEntity> selectPicture(String lotNo, String machineNo, String materialNo, String modelNo, String partNo);
@Query(value = "SELECT * FROM qc_inspection_picture WHERE lot_no = ? AND machine_no = ? AND material_no = ? AND model_no = ? AND machine_type_no = ? AND craft_item_name = ? ", nativeQuery = true)
Optional<PictureEntity> selectPicture(String lotNo, String machineNo, String materialNo, String modelNo, String machineTypeNo, String craftItemName);
/**
* 修改图片路径信息
*
* @param lotNo 批次号
* @param machineNo 机器号
* @param materialNo 物料号
* @param modelNo 模具号
* @param partNo 零件号
* @param picturePath 图片路径
*/
@Modifying(clearAutomatically = true)
@Query(value = "UPDATE qc_inspection_picture SET picture_path = ?6 where lot_no = ?1 and machine_no = ?2 and material_no = ?3 and model_no = ?4 and part_no = ?5", nativeQuery = true)
void updatePicturePath(String lotNo, String machineNo, String materialNo, String modelNo, String partNo, String picturePath);
}

View File

@ -47,6 +47,13 @@ public class FileEntity {
@Column(length = 85, columnDefinition = "varchar(85)")
private String machineTypeNo;
/**
* 工艺项目名称
*/
@Column(length = 85, columnDefinition = "varchar(85)")
private String craftItemName;
/**
* 上传模板的路径
*/
@ -110,6 +117,14 @@ public class FileEntity {
this.machineTypeNo = machineTypeNo;
}
public String getCraftItemName() {
return craftItemName;
}
public void setCraftItemName(String craftItemName) {
this.craftItemName = craftItemName;
}
public String getFileUploadPath() {
return fileUploadPath;
}
@ -135,6 +150,7 @@ public class FileEntity {
", materialNo='" + materialNo + '\'' +
", modelNo='" + modelNo + '\'' +
", machineTypeNo='" + machineTypeNo + '\'' +
", craftItemName='" + craftItemName + '\'' +
", fileUploadPath='" + fileUploadPath + '\'' +
", fileDownloadPath='" + fileDownloadPath + '\'' +
'}';

View File

@ -40,6 +40,12 @@ public class FileQo {
@NotBlank(message = "{FileEntity.machineTypeNo.blank}", groups = {FileQoInsert.class})
private String machineTypeNo;
/**
* 工艺项目名称
*/
@NotBlank(message = "{FileEntity.craftItemName.blank}", groups = {FileQoInsert.class})
private String craftItemName;
/**
* 上传模板的路径
*/
@ -89,6 +95,14 @@ public class FileQo {
this.machineTypeNo = machineTypeNo;
}
public String getCraftItemName() {
return craftItemName;
}
public void setCraftItemName(String craftItemName) {
this.craftItemName = craftItemName;
}
public String getFileUploadPath() {
return fileUploadPath;
}

View File

@ -1,6 +1,7 @@
package com.xkrs.model.qo;
import com.xkrs.model.validation.FileQoInsert;
import com.xkrs.model.validation.FileUpdateQoUpdate;
import javax.validation.constraints.NotBlank;
@ -41,6 +42,12 @@ public class FileUpdateQo {
@NotBlank(message = "{FileEntity.machineTypeNo.blank}", groups = {FileUpdateQoUpdate.class})
private String machineTypeNo;
/**
* 工艺项目名称
*/
@NotBlank(message = "{FileEntity.craftItemName.blank}", groups = {FileQoInsert.class})
private String craftItemName;
public FileUpdateQo() {
}
@ -83,4 +90,12 @@ public class FileUpdateQo {
public void setMachineTypeNo(String machineTypeNo) {
this.machineTypeNo = machineTypeNo;
}
public String getCraftItemName() {
return craftItemName;
}
public void setCraftItemName(String craftItemName) {
this.craftItemName = craftItemName;
}
}

View File

@ -47,7 +47,8 @@ public class DataSourceServiceImpl implements DataSourceService {
dataSource.setMachineNo(dataSourceQo.getMachineNo());
dataSource.setMaterialNo(dataSourceQo.getMaterialNo());
dataSource.setModelNo(dataSourceQo.getModelNo());
dataSource.setPartNo(dataSourceQo.getPartNo());
dataSource.setMachineTypeNo(dataSourceQo.getMachineTypeNo());
dataSource.setCraftItemName(dataSourceQo.getCraftItemName());
dataSource.setInspectionItemCode(dataSourceQo.getInspectionItemCode());
dataSource.setInspectValue(dataSourceQo.getInspectValue());
dataSourceDao.save(dataSource);

View File

@ -42,8 +42,14 @@ public class FileServiceImpl implements FileService {
*/
@Override
public String insertFileExcel(FileQo fileQo, MultipartFile fileExcel) throws IOException {
String lotNo = fileQo.getLotNo();
String machineNo = fileQo.getMachineNo();
String materialNo = fileQo.getMaterialNo();
String modelNo = fileQo.getModelNo();
String machineTypeNo = fileQo.getMachineTypeNo();
String craftItemName = fileQo.getCraftItemName();
Locale locale = LocaleContextHolder.getLocale();
Optional<FileEntity> fileEntity = fileDao.selectFile(fileQo.getLotNo(), fileQo.getMachineNo(), fileQo.getMaterialNo(), fileQo.getModelNo(), fileQo.getPartNo());
Optional<FileEntity> fileEntity = fileDao.selectFile(lotNo, machineNo, materialNo, modelNo, machineTypeNo, craftItemName);
if (fileEntity.isPresent()) {
return outputEncapsulationObject(PromptMessageEnum.DATA_EXIT, "已存在该产品的模板!", locale);
}
@ -56,7 +62,7 @@ public class FileServiceImpl implements FileService {
fileEntity1.setMachineNo(fileQo.getMachineNo());
fileEntity1.setMaterialNo(fileQo.getMaterialNo());
fileEntity1.setModelNo(fileQo.getModelNo());
fileEntity1.setPartNo(fileQo.getPartNo());
fileEntity1.setMachineTypeNo(fileQo.getMachineTypeNo());
fileEntity1.setFileUploadPath(file);
fileDao.save(fileEntity1);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "添加成功!", locale);
@ -71,13 +77,19 @@ public class FileServiceImpl implements FileService {
@Transactional(rollbackOn = Exception.class)
@Override
public String exportExcel(FileQo fileQo) throws IOException, InvalidFormatException {
String lotNo = fileQo.getLotNo();
String machineNo = fileQo.getMachineNo();
String materialNo = fileQo.getMaterialNo();
String modelNo = fileQo.getModelNo();
String machineTypeNo = fileQo.getMachineTypeNo();
String craftItemName = fileQo.getCraftItemName();
Locale locale = LocaleContextHolder.getLocale();
Optional<FileEntity> fileEntity = fileDao.selectFile(fileQo.getLotNo(), fileQo.getMachineNo(), fileQo.getMaterialNo(), fileQo.getModelNo(), fileQo.getPartNo());
Optional<FileEntity> fileEntity = fileDao.selectFile(lotNo, machineNo, materialNo, modelNo, machineTypeNo, craftItemName);
if (fileEntity.isEmpty()) {
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "暂时没有该产品的模板,请添加!", locale);
}
String fileUploadPath = fileEntity.get().getFileUploadPath();
List<DataSource> dataSources = dataSourceQuery.selectDataSource(fileQo.getLotNo(), fileQo.getMachineNo(), fileQo.getMaterialNo(), fileQo.getModelNo(), fileQo.getPartNo());
List<DataSource> dataSources = dataSourceQuery.selectDataSource(lotNo, machineNo, materialNo, modelNo, machineTypeNo, craftItemName);
if (dataSources == null || dataSources.size() == 0) {
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "暂时没有该产品的信息!", locale);
}
@ -86,7 +98,7 @@ public class FileServiceImpl implements FileService {
map.put(dataSource.getInspectionItemCode(), dataSource.getInspectValue());
}
String fill = ExportExcel.exportToProveExcel(map, fileUploadPath);
fileDao.updateFileDownloadPath(fileQo.getLotNo(), fileQo.getMachineNo(), fileQo.getMaterialNo(), fileQo.getModelNo(), fileQo.getPartNo(), fill);
fileDao.updateFileDownloadPath(lotNo, machineNo, materialNo, modelNo, machineTypeNo, craftItemName, fill);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, fill, locale);
}
}

View File

@ -30,8 +30,9 @@ public class PictureServiceImpl implements PictureService {
String machineNo = pictureQo.getMachineNo();
String materialNo = pictureQo.getMaterialNo();
String modelNo = pictureQo.getModelNo();
String partNo = pictureQo.getPartNo();
Optional<PictureEntity> pictureEntity2 = pictureDao.selectPicture(lotNo, machineNo, materialNo, modelNo, partNo);
String machineTypeNo = pictureQo.getMachineTypeNo();
String craftItemName = pictureQo.getCraftItemName();
Optional<PictureEntity> pictureEntity2 = pictureDao.selectPicture(lotNo, machineNo, materialNo, modelNo, machineTypeNo, craftItemName);
if (pictureEntity2.isPresent()) {
return outputEncapsulationObject(PromptMessageEnum.DATA_EXIT, "请勿重复添加!", locale);
}
@ -41,7 +42,8 @@ public class PictureServiceImpl implements PictureService {
pictureEntity1.setMachineNo(machineNo);
pictureEntity1.setMaterialNo(materialNo);
pictureEntity1.setModelNo(modelNo);
pictureEntity1.setPartNo(partNo);
pictureEntity1.setMachineTypeNo(machineTypeNo);
pictureEntity1.setCraftItemName(craftItemName);
pictureEntity1.setPicturePath(file);
pictureDao.save(pictureEntity1);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "添加成功!", locale);

View File

@ -27,13 +27,14 @@ public class SpecServiceImpl implements SpecService {
@Override
public String insertSpec(SpecQo specQo) {
Locale locale = LocaleContextHolder.getLocale();
List<SpecEntity> specEntities = specQuery.selectSpec(specQo.getPartNo(), specQo.getInspectionItemCode());
List<SpecEntity> specEntities = specQuery.selectSpec(specQo.getMachineTypeNo(), specQo.getInspectionItemCode(),specQo.getCraftItemName());
if (!specEntities.isEmpty()) {
return outputEncapsulationObject(PromptMessageEnum.DATA_EXIT, "已存在该测量规格!", locale);
}
SpecEntity specEntity1 = new SpecEntity();
specEntity1.setPartNo(specQo.getPartNo());
specEntity1.setMachineTypeNo(specQo.getMachineTypeNo());
specEntity1.setInspectionItemCode(specQo.getInspectionItemCode());
specEntity1.setCraftItemName(specQo.getCraftItemName());
specEntity1.setMax(specQo.getMax());
specEntity1.setMean(specQo.getMean());
specEntity1.setMin(specQo.getMin());

View File

@ -6,10 +6,7 @@ import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import java.util.ArrayList;
import java.util.List;

View File

@ -26,7 +26,7 @@ public class DataSourceQuery {
*
* @return
*/
public List<DataSource> selectDataSource(String lotNo, String machineNo, String materialNo, String modelNo, String partNo) {
public List<DataSource> selectDataSource(String lotNo, String machineNo, String materialNo, String modelNo, String machineTypeNo, String craftItemName) {
Specification<DataSource> specification = (root, criteriaQuery, criteriaBuilder) -> {
List<Predicate> list = new ArrayList<>();
if (!TextUtils.isEmpty(lotNo)) {
@ -41,8 +41,11 @@ public class DataSourceQuery {
if (!TextUtils.isEmpty(modelNo)) {
list.add(criteriaBuilder.equal(root.get("modelNo").as(String.class), modelNo));
}
if (!TextUtils.isEmpty(partNo)) {
list.add(criteriaBuilder.equal(root.get("partNo").as(String.class), partNo));
if (!TextUtils.isEmpty(machineTypeNo)) {
list.add(criteriaBuilder.equal(root.get("machineTypeNo").as(String.class), machineTypeNo));
}
if (!TextUtils.isEmpty(craftItemName)) {
list.add(criteriaBuilder.equal(root.get("craftItemName").as(String.class), craftItemName));
}
Predicate[] predicates = new Predicate[list.size()];
return criteriaBuilder.and(list.toArray(predicates));

View File

@ -44,13 +44,13 @@ public class ExcelUploadUtil {
String newName = UUID.randomUUID().toString() + suffix;
//将图片保存到本地/usr/etc/images/Folder
// File file = new File("/Users/liuchengqian/Desktop/DaJiang/");
File file = new File("/home/sxy/server/industrial_measurement" + subDir);
File file = new File("/Users/liuchengqian/Desktop/DaJiang/" + subDir);
// File file = new File("/home/sxy/server/industrial_measurement" + subDir);
if (!file.exists()) {
file.mkdirs();
}
// String path = "/Users/liuchengqian/Desktop/DaJiang/"+newName;
String path = "/home/sxy/server/industrial_measurement" + subDir + newName;
String path = "/Users/liuchengqian/Desktop/DaJiang/" + subDir + newName;
// String path = "/home/sxy/server/industrial_measurement" + subDir + newName;
String uploadsImage = uploadPath + newName;
//实现上传
fileInput.transferTo(new File(path));

View File

@ -26,7 +26,7 @@ public class PictureQuery {
*
* @return
*/
public List<PictureEntity> selectPicture(String lotNo, String machineNo, String materialNo, String modelNo, String partNo) {
public List<PictureEntity> selectPicture(String lotNo, String machineNo, String materialNo, String modelNo, String machineTypeNo, String craftItemName) {
Specification<PictureEntity> specification = (root, criteriaQuery, criteriaBuilder) -> {
List<Predicate> list = new ArrayList<>();
if (!TextUtils.isEmpty(lotNo)) {
@ -41,8 +41,11 @@ public class PictureQuery {
if (!TextUtils.isEmpty(modelNo)) {
list.add(criteriaBuilder.equal(root.get("modelNo").as(String.class), modelNo));
}
if (!TextUtils.isEmpty(partNo)) {
list.add(criteriaBuilder.equal(root.get("partNo").as(String.class), partNo));
if (!TextUtils.isEmpty(machineTypeNo)) {
list.add(criteriaBuilder.equal(root.get("machineTypeNo").as(String.class), machineTypeNo));
}
if (!TextUtils.isEmpty(craftItemName)) {
list.add(criteriaBuilder.equal(root.get("craftItemName").as(String.class), craftItemName));
}
Predicate[] predicates = new Predicate[list.size()];
return criteriaBuilder.and(list.toArray(predicates));

View File

@ -26,15 +26,18 @@ public class SpecQuery {
*
* @return
*/
public List<SpecEntity> selectSpec(String partNo, String inspectionItemCode) {
public List<SpecEntity> selectSpec(String machineTypeNo, String inspectionItemCode, String craftItemName) {
Specification<SpecEntity> specification = (root, criteriaQuery, criteriaBuilder) -> {
List<Predicate> list = new ArrayList<>();
if (!TextUtils.isEmpty(partNo)) {
list.add(criteriaBuilder.equal(root.get("partNo").as(String.class), partNo));
if (!TextUtils.isEmpty(machineTypeNo)) {
list.add(criteriaBuilder.equal(root.get("machineTypeNo").as(String.class), machineTypeNo));
}
if (!TextUtils.isEmpty(inspectionItemCode)) {
list.add(criteriaBuilder.equal(root.get("inspectionItemCode").as(String.class), inspectionItemCode));
}
if (!TextUtils.isEmpty(craftItemName)) {
list.add(criteriaBuilder.equal(root.get("craftItemName").as(String.class), craftItemName));
}
Predicate[] predicates = new Predicate[list.size()];
return criteriaBuilder.and(list.toArray(predicates));
};