完善查询测量数据

This commit is contained in:
liuchengqian 2022-03-12 13:52:15 +08:00
parent b757013382
commit f11ae30b77
4 changed files with 74 additions and 24 deletions

View File

@ -1,7 +1,7 @@
package com.xkrs.service.impl;
import com.xkrs.encapsulation.PromptMessageEnum;
import com.xkrs.dao.QcItemDao;
import com.xkrs.encapsulation.PromptMessageEnum;
import com.xkrs.model.entity.QcItemEntity;
import com.xkrs.model.qo.QcItemQoDelete;
import com.xkrs.model.qo.QcItemQoInsert;
@ -54,6 +54,7 @@ public class QcItemServiceImpl implements QcItemService {
/**
* 删除检验项目
*/
@Transactional(rollbackOn = Exception.class)
@Override
public String deleteQcItem(QcItemQoDelete deleteQo) {
Integer id = deleteQo.getId();

View File

@ -1,27 +1,26 @@
package com.xkrs.service.impl;
import com.xkrs.encapsulation.PromptMessageEnum;
import com.xkrs.dao.QcItemDao;
import com.xkrs.dao.QcSourceDao;
import com.xkrs.encapsulation.PromptMessageEnum;
import com.xkrs.model.entity.QcItemEntity;
import com.xkrs.model.entity.QcSourceEntity;
import com.xkrs.model.qo.QcSourceQoDelete;
import com.xkrs.model.qo.QcSourceQoInsert;
import com.xkrs.service.QcSourceService;
import com.xkrs.util.Constant;
import com.xkrs.util.ExcelUploadUtil;
import com.xkrs.util.LocalDateUtils;
import com.xkrs.util.LocalStringUtils;
import com.xkrs.util.ExcelUploadUtil;
import org.apache.http.util.TextUtils;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.transaction.Transactional;
import java.io.IOException;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.*;
import static com.xkrs.encapsulation.OutputEncapsulation.outputEncapsulationObject;
@ -94,6 +93,7 @@ public class QcSourceServiceImpl implements QcSourceService {
/**
* 删除检验数据
*/
@Transactional(rollbackOn = Exception.class)
@Override
public String deleteQcSource(QcSourceQoDelete deleteQo) {
Integer id = deleteQo.getId();
@ -110,17 +110,63 @@ public class QcSourceServiceImpl implements QcSourceService {
*/
@Override
public String queryQcSource(String batchNo, String machineNo, String materialNo, String mouldNo, String varietyNo) {
List<Map<String, Object>> resultList = qcSourceDao.queryQcSource(LocalStringUtils.formatEmptyValue(batchNo), LocalStringUtils.formatEmptyValue(machineNo), LocalStringUtils.formatEmptyValue(materialNo), LocalStringUtils.formatEmptyValue(mouldNo), LocalStringUtils.formatEmptyValue(varietyNo));
if (resultList == null || resultList.isEmpty()) {
List<QcItemEntity> qcItemList = qcItemDao.findAll();
if (qcItemList.isEmpty()) {
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "未添加检验项目,请先添加检验项目!", locale);
}
List<Map<String, Object>> sourceList = qcSourceDao.queryQcSource(LocalStringUtils.formatEmptyValue(batchNo), LocalStringUtils.formatEmptyValue(machineNo), LocalStringUtils.formatEmptyValue(materialNo), LocalStringUtils.formatEmptyValue(mouldNo), LocalStringUtils.formatEmptyValue(varietyNo));
List<Map<String, Object>> resultList = generateResultList(sourceList, qcItemList);
if (resultList.isEmpty()) {
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "暂时没有该检验数据的信息!", locale);
}
if (1 == 1) {
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, resultList, locale);
}
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "查询成功!", locale);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, resultList, locale);
}
private List<Map<String, Object>> generateResultList(List<Map<String, Object>> sourceList, List<QcItemEntity> qcItemList) {
List<Map<String, Object>> resultList = new ArrayList<>();
if (sourceList == null || sourceList.isEmpty()) {
return resultList;
}
for (Map<String, Object> source : sourceList) {
String batchNo = (String) source.getOrDefault("batchNo", "");
String machineNo = (String) source.getOrDefault("machineNo", "");
String materialNo = (String) source.getOrDefault("materialNo", "");
String mouldNo = (String) source.getOrDefault("mouldNo", "");
String varietyNo = (String) source.getOrDefault("varietyNo", "");
String qcItemNo = (String) source.getOrDefault("qcItemNo", "");
String qcValue = (String) source.getOrDefault("qcValue", "");
if (TextUtils.isEmpty(qcItemNo) || TextUtils.isEmpty(qcValue)) {
continue;
}
Map<String, Object> emptyRoom = findEmptyRoom(resultList, batchNo, qcItemNo);
if (emptyRoom == null) {
Map<String, Object> newRoom = new HashMap<>();
newRoom.put("batchNo", batchNo);
newRoom.put("machineNo", machineNo);
newRoom.put("materialNo", materialNo);
newRoom.put("mouldNo", mouldNo);
newRoom.put("varietyNo", varietyNo);
newRoom.put(qcItemNo, qcValue);
resultList.add(newRoom);
} else {
emptyRoom.put(qcItemNo, qcValue);
}
}
return resultList;
}
private Map<String, Object> findEmptyRoom(List<Map<String, Object>> mapList, String batchNo, String qcItemNo) {
if (mapList == null || mapList.isEmpty() || TextUtils.isEmpty(batchNo) || TextUtils.isEmpty(qcItemNo)) {
return null;
}
for (Map<String, Object> room : mapList) {
if (room.getOrDefault("batchNo", "").equals(batchNo)) {
if (!room.containsKey(qcItemNo)) {
return room;
}
}
}
return null;
}
}

View File

@ -1,8 +1,8 @@
package com.xkrs.service.impl;
import com.xkrs.encapsulation.PromptMessageEnum;
import com.xkrs.dao.QcItemDao;
import com.xkrs.dao.QcSpecDao;
import com.xkrs.encapsulation.PromptMessageEnum;
import com.xkrs.model.entity.QcItemEntity;
import com.xkrs.model.entity.QcSpecEntity;
import com.xkrs.model.qo.QcSpecQoDelete;
@ -15,6 +15,7 @@ import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.transaction.Transactional;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@ -78,6 +79,7 @@ public class QcSpecServiceImpl implements QcSpecService {
/**
* 删除检验规格
*/
@Transactional(rollbackOn = Exception.class)
@Override
public String deleteQcSpec(QcSpecQoDelete deleteQo) {
Integer id = deleteQo.getId();
@ -92,6 +94,7 @@ public class QcSpecServiceImpl implements QcSpecService {
/**
* 更新检验规格
*/
@Transactional(rollbackOn = Exception.class)
@Override
public String updateQcSpec(QcSpecQoUpdate updateQo) {

View File

@ -39,17 +39,17 @@ public class ExcelUploadUtil {
String suffix = originalFilename.substring(index);
//uuid生成新的文件名
String newName = UUID.randomUUID().toString() + suffix;
// File file = new File("/Users/liuchengqian/Desktop/DaJiang/" + subDir);
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/" + subDir + 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;
//实现上传
fileInput.transferTo(new File(path));
// return path;
return subDir + newName;
return path;
// return subDir + newName;
}
return null;
}