101 lines
4.2 KiB
Java
101 lines
4.2 KiB
Java
package com.xkrs.service.impl;
|
|
|
|
import com.xkrs.dao.FileDao;
|
|
import com.xkrs.dao.QcSourceDao;
|
|
import com.xkrs.encapsulation.PromptMessageEnum;
|
|
import com.xkrs.model.qo.FileQo;
|
|
import com.xkrs.service.FileService;
|
|
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
|
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.Locale;
|
|
|
|
import static com.xkrs.encapsulation.OutputEncapsulation.outputEncapsulationObject;
|
|
|
|
/**
|
|
* @Author: XinYi Song
|
|
* @Date: 2022/1/20 15:24
|
|
*/
|
|
@Service
|
|
public class FileServiceImpl implements FileService {
|
|
|
|
@Resource
|
|
private FileDao fileDao;
|
|
|
|
@Resource
|
|
private QcSourceDao qcSourceDao;
|
|
|
|
/**
|
|
* 添加模板信息
|
|
*
|
|
* @param fileQo
|
|
* @return
|
|
*/
|
|
@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(lotNo, machineNo, materialNo, modelNo, machineTypeNo, craftItemName);
|
|
// if (fileEntity.isPresent()) {
|
|
// return outputEncapsulationObject(PromptMessageEnum.DATA_EXIT, "已存在该产品的模板!", locale);
|
|
// }
|
|
// if (fileExcel == null) {
|
|
// return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "模板不能为空!", locale);
|
|
// }
|
|
// String file = ExcelUploadUtil.memoryFile(fileExcel, 1);
|
|
// FileEntity fileEntity1 = new FileEntity();
|
|
// fileEntity1.setLotNo(fileQo.getLotNo());
|
|
// fileEntity1.setMachineNo(fileQo.getMachineNo());
|
|
// fileEntity1.setMaterialNo(fileQo.getMaterialNo());
|
|
// fileEntity1.setModelNo(fileQo.getModelNo());
|
|
// fileEntity1.setMachineTypeNo(fileQo.getMachineTypeNo());
|
|
// fileEntity1.setFileUploadPath(file);
|
|
// fileDao.save(fileEntity1);
|
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "添加成功!", locale);
|
|
}
|
|
|
|
/**
|
|
* 导出excel
|
|
*
|
|
* @param fileQo
|
|
* @return
|
|
*/
|
|
@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(lotNo, machineNo, materialNo, modelNo, machineTypeNo, craftItemName);
|
|
// if (fileEntity.isEmpty()) {
|
|
// return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "暂时没有该产品的模板,请添加!", locale);
|
|
// }
|
|
// String fileUploadPath = fileEntity.get().getFileUploadPath();
|
|
// List<Map<String, Object>> resultList = qcSourceDao.queryQcSource(lotNo, machineNo, materialNo, modelNo, machineTypeNo, "");
|
|
// if (resultList == null || resultList.size() == 0) {
|
|
// return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "暂时没有该产品的信息!", locale);
|
|
// }
|
|
// Map<String, String> map = new HashMap<>();
|
|
// for (Map<String, Object> result : resultList) {
|
|
// map.put((String) result.get("qcItemNo"), (String) result.get("qcValue"));
|
|
// }
|
|
// String fill = ExportExcel.exportToProveExcel(map, fileUploadPath);
|
|
// fileDao.updateFileDownloadPath(lotNo, machineNo, materialNo, modelNo, machineTypeNo, craftItemName, fill);
|
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "导出成功", locale);
|
|
}
|
|
}
|