问题修复
This commit is contained in:
parent
fdbeb27506
commit
514e0f4fcc
|
|
@ -27,6 +27,7 @@ import org.springframework.util.CollectionUtils;
|
|||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
|
@ -517,15 +518,18 @@ public class PurchaseCheckInfoServiceImpl implements IPurchaseCheckInfoService {
|
|||
String fileName = file.getOriginalFilename();
|
||||
if (fileName != null) {
|
||||
String fileExtension = fileName.substring(fileName.lastIndexOf(".") + 1);
|
||||
if (!MaterialConstants.XLSX.equalsIgnoreCase(fileExtension)) {
|
||||
// 文件后缀名不符合要求
|
||||
return AjaxResult.error("导入失败:文件后缀名不符合要求,必须为xlsx结尾");
|
||||
// 修复1:支持.xls和.xlsx两种格式
|
||||
if (!"xls".equalsIgnoreCase(fileExtension) && !"xlsx".equalsIgnoreCase(fileExtension)) {
|
||||
return AjaxResult.error("导入失败:文件后缀名不符合要求,必须为xls或xlsx结尾");
|
||||
}
|
||||
}
|
||||
InputStream inputStream = null;
|
||||
try {
|
||||
inputStream = file.getInputStream();
|
||||
Workbook workbook = new XSSFWorkbook(inputStream); // 处理.xlsx文件
|
||||
|
||||
// 修复2:读取文件为字节数组,支持多次流读取
|
||||
byte[] fileBytes = file.getBytes();
|
||||
try (InputStream workbookStream = new ByteArrayInputStream(fileBytes);
|
||||
Workbook workbook = WorkbookFactory.create(workbookStream); // 自动适配xls/xlsx格式
|
||||
InputStream excelUtilStream = new ByteArrayInputStream(fileBytes)) { // 用于ExcelUtil的独立流
|
||||
|
||||
|
||||
Sheet sheet = workbook.getSheetAt(0);
|
||||
// 得到Excel的行数
|
||||
|
|
@ -593,12 +597,10 @@ public class PurchaseCheckInfoServiceImpl implements IPurchaseCheckInfoService {
|
|||
}
|
||||
}
|
||||
}
|
||||
inputStream.close();
|
||||
|
||||
return AjaxResult.success(templateVos);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
inputStream.close();
|
||||
}
|
||||
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMsg());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -397,8 +397,8 @@ public class PurchaseMacodeInfoServiceImpl implements IPurchaseMacodeInfoService
|
|||
List<PurchaseCheckDetails> purchaseCheckDetailsList = checkDetailsMapper.selectPurchaseCheckDetailsByTaskId(taskId);
|
||||
//判断每种设备的验收数量和绑定数量一致
|
||||
for (PurchaseCheckDetails purchaseCheckDetails : purchaseCheckDetailsList) {
|
||||
if (StringUtils.isNotNull(purchaseCheckDetails.getBindNum())) {
|
||||
if (purchaseCheckDetails.getCheckNum().compareTo(purchaseCheckDetails.getBindNum()) != 0) {
|
||||
if (StringUtils.isNotNull(purchaseCheckDetails.getInputNum())) {
|
||||
if (purchaseCheckDetails.getCheckNum().compareTo(purchaseCheckDetails.getInputNum()) != 0) {
|
||||
//全部操作以后如果还有未绑定的,则不改变状态
|
||||
count = 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,8 +58,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="companyId != null ">and pcd.company_id = #{companyId}</if>
|
||||
</select>
|
||||
|
||||
<select id="selectPurchaseCheckDetailsByTaskId" parameterType="Long" resultMap="PurchaseCheckDetailsResult">
|
||||
<include refid="selectPurchaseCheckDetailsVo"/>
|
||||
<select id="selectPurchaseCheckDetailsByTaskId" parameterType="Long" resultType="com.bonus.sgzb.material.domain.PurchaseCheckDetails">
|
||||
select id, task_id as taskId, type_id as typeId, purchase_price as purchasePrice, purchase_num as purchaseNum, check_num as checkNum,bind_num as bindNum, check_result as checkResult,
|
||||
supplier_id as supplierId, status, create_by as createBy,input_num as inputNum,
|
||||
production_time as productionTime, create_time as createTime, update_by as updateBy, update_time as updateTime,
|
||||
remark, check_url_name as checkUrlName, check_url as checkUrl, file_name as fileName, file_url as fileUrl, company_id as companyId, purveyor_id as purveyorId
|
||||
from purchase_check_details
|
||||
where task_id = #{taskId}
|
||||
</select>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue