功能优化及小工具导入
This commit is contained in:
parent
d7cdc490b7
commit
cf61a7adc2
|
|
@ -557,4 +557,14 @@ public class GlobalConstants {
|
||||||
*/
|
*/
|
||||||
public static final Long LONG_65535 = 65535L;
|
public static final Long LONG_65535 = 65535L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xls
|
||||||
|
*/
|
||||||
|
public static final String XLS = "xls";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* XLSX
|
||||||
|
*/
|
||||||
|
public static final String XLSX = "xlsx";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -301,7 +301,11 @@ public class BmQrBoxServiceImpl implements BmQrBoxService {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public AjaxResult appTransfer(BmQrBoxInfo bmQrBoxInfo) {
|
public AjaxResult appTransfer(BmQrBoxInfo bmQrBoxInfo) {
|
||||||
|
// 根据boxId查询该标准箱里面是否存在设备,空箱不允许移交
|
||||||
|
List<BmQrBoxInfo> list = bmQrBoxMapper.getList(bmQrBoxInfo);
|
||||||
|
if (CollectionUtils.isEmpty(list)) {
|
||||||
|
return AjaxResult.error("该标准箱中无相关设备,无法进行移交!");
|
||||||
|
}
|
||||||
bmQrBoxInfo.setBoxCode(null).setBoxName(null).setBoxType(null).setStatus(QrBoxStatusEnum.QR_BOX_STATUS_WAIT_RECEIVE.getStatus().toString());
|
bmQrBoxInfo.setBoxCode(null).setBoxName(null).setBoxType(null).setStatus(QrBoxStatusEnum.QR_BOX_STATUS_WAIT_RECEIVE.getStatus().toString());
|
||||||
bmQrBoxInfo.setTransferUser(SecurityUtils.getLoginUser().getUserid());
|
bmQrBoxInfo.setTransferUser(SecurityUtils.getLoginUser().getUserid());
|
||||||
return 0 < bmQrBoxMapper.updateBmQrcodeInfoById(bmQrBoxInfo) ? AjaxResult.success(HttpCodeEnum.SUCCESS.getMsg()) :
|
return 0 < bmQrBoxMapper.updateBmQrcodeInfoById(bmQrBoxInfo) ? AjaxResult.success(HttpCodeEnum.SUCCESS.getMsg()) :
|
||||||
|
|
|
||||||
|
|
@ -9,13 +9,16 @@ import com.bonus.common.log.enums.OperaType;
|
||||||
import com.bonus.common.security.utils.SecurityUtils;
|
import com.bonus.common.security.utils.SecurityUtils;
|
||||||
import com.bonus.material.codeCollection.domain.WsMaInfo;
|
import com.bonus.material.codeCollection.domain.WsMaInfo;
|
||||||
import com.bonus.material.codeCollection.service.WsMaInfoService;
|
import com.bonus.material.codeCollection.service.WsMaInfoService;
|
||||||
import com.bonus.material.common.annotation.PreventRepeatSubmit;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.context.request.RequestContextHolder;
|
||||||
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 机具信息控制器
|
* 机具信息控制器
|
||||||
|
|
@ -147,4 +150,26 @@ public class WsMaInfoController extends BaseController {
|
||||||
public AjaxResult updateGadgetInfo(@RequestBody WsMaInfo info) {
|
public AjaxResult updateGadgetInfo(@RequestBody WsMaInfo info) {
|
||||||
return service.updateGadgetInfo(info);
|
return service.updateGadgetInfo(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导入小工具信息模板
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "小工具导入模版下载")
|
||||||
|
@PostMapping("/downLoad")
|
||||||
|
public void downLoadExcelFile(){
|
||||||
|
HttpServletResponse resp = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getResponse();
|
||||||
|
service.downLoadTemplate(resp);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 小工具信息导入
|
||||||
|
* @param file
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "小工具信息导入")
|
||||||
|
@PostMapping("/importData")
|
||||||
|
public AjaxResult importData(MultipartFile file)
|
||||||
|
{
|
||||||
|
return service.importTbData(file);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,10 @@ package com.bonus.material.codeCollection.service;
|
||||||
|
|
||||||
import com.bonus.common.core.web.domain.AjaxResult;
|
import com.bonus.common.core.web.domain.AjaxResult;
|
||||||
import com.bonus.material.codeCollection.domain.WsMaInfo;
|
import com.bonus.material.codeCollection.domain.WsMaInfo;
|
||||||
import org.apache.ibatis.annotations.MapKey;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* WsMaInfoService
|
* WsMaInfoService
|
||||||
|
|
@ -120,4 +119,17 @@ public interface WsMaInfoService {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
AjaxResult updateGadgetInfo(WsMaInfo info);
|
AjaxResult updateGadgetInfo(WsMaInfo info);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 小工具导入模版下载
|
||||||
|
* @param resp
|
||||||
|
*/
|
||||||
|
void downLoadTemplate(HttpServletResponse resp);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导入小工具信息
|
||||||
|
* @param file
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
AjaxResult importTbData(MultipartFile file);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,30 @@
|
||||||
package com.bonus.material.codeCollection.service.impl;
|
package com.bonus.material.codeCollection.service.impl;
|
||||||
|
|
||||||
import com.alibaba.nacos.common.utils.CollectionUtils;
|
import com.alibaba.nacos.common.utils.CollectionUtils;
|
||||||
|
import com.bonus.common.biz.constant.GlobalConstants;
|
||||||
|
import com.bonus.common.core.utils.poi.ExcelUtil;
|
||||||
import com.bonus.common.core.web.domain.AjaxResult;
|
import com.bonus.common.core.web.domain.AjaxResult;
|
||||||
import com.bonus.common.security.utils.SecurityUtils;
|
import com.bonus.common.security.utils.SecurityUtils;
|
||||||
import com.bonus.material.codeCollection.domain.WsMaInfo;
|
import com.bonus.material.codeCollection.domain.WsMaInfo;
|
||||||
import com.bonus.material.codeCollection.mapper.WsMaInfoMapper;
|
import com.bonus.material.codeCollection.mapper.WsMaInfoMapper;
|
||||||
import com.bonus.material.codeCollection.service.WsMaInfoService;
|
import com.bonus.material.codeCollection.service.WsMaInfoService;
|
||||||
|
import com.bonus.material.ma.domain.vo.ExceptionEnum;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.commons.lang3.ObjectUtils;
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
|
import org.apache.poi.ss.usermodel.Cell;
|
||||||
|
import org.apache.poi.ss.usermodel.Row;
|
||||||
|
import org.apache.poi.ss.usermodel.Sheet;
|
||||||
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
@ -281,4 +295,146 @@ public class WsMaInfoServiceImpl implements WsMaInfoService {
|
||||||
return AjaxResult.error("更新失败");
|
return AjaxResult.error("更新失败");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 小工具导入模版下载
|
||||||
|
* @param response
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void downLoadTemplate(HttpServletResponse response) {
|
||||||
|
//模板名称
|
||||||
|
String templateName = "机具检验标识信息导入模板.xls";
|
||||||
|
OutputStream out = null;
|
||||||
|
InputStream input =null;
|
||||||
|
try {
|
||||||
|
input = this.getClass().getClassLoader().getResourceAsStream("template/机具检验标识信息导入模板.xls");
|
||||||
|
response.setCharacterEncoding("UTF-8");
|
||||||
|
response.setHeader("content-Type", "application/vnd.ms-excel");
|
||||||
|
response.setHeader("Content-Disposition",
|
||||||
|
"attachment;filename=" + new String((templateName).getBytes(), "iso-8859-1"));
|
||||||
|
response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
|
||||||
|
out = response.getOutputStream();
|
||||||
|
// 缓冲区
|
||||||
|
byte[] buffer = new byte[1024];
|
||||||
|
int bytesToRead = -1;
|
||||||
|
// 通过循环将读入内容输出到浏览器中
|
||||||
|
while ((bytesToRead = input.read(buffer)) != -1) {
|
||||||
|
out.write(buffer, 0, bytesToRead);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error(e.getMessage());
|
||||||
|
} finally {
|
||||||
|
IOUtils.closeQuietly(input);
|
||||||
|
IOUtils.closeQuietly(out);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导入数据
|
||||||
|
* @param file
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public AjaxResult importTbData(MultipartFile file) {
|
||||||
|
String fileName = file.getOriginalFilename();
|
||||||
|
if (fileName != null) {
|
||||||
|
String fileExtension = fileName.substring(fileName.lastIndexOf(".") + 1);
|
||||||
|
if (!GlobalConstants.XLSX.equalsIgnoreCase(fileExtension) && !GlobalConstants.XLS.equalsIgnoreCase(fileExtension)) {
|
||||||
|
// 文件后缀名不符合要求
|
||||||
|
return AjaxResult.error("导入失败:文件后缀名不符合要求,必须为xlsx或xls结尾");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
InputStream inputStream = file.getInputStream();
|
||||||
|
Workbook workbook = new XSSFWorkbook(inputStream);
|
||||||
|
Sheet sheet = workbook.getSheetAt(0);
|
||||||
|
// 得到Excel的行数
|
||||||
|
int totalRows = sheet.getPhysicalNumberOfRows();
|
||||||
|
// 检查是否有行数
|
||||||
|
if (totalRows <= 1) {
|
||||||
|
throw new IllegalArgumentException("导入失败:Excel文件中没有数据,请检查后重新导入");
|
||||||
|
}
|
||||||
|
// 读取第一行表头
|
||||||
|
Row headerRow = sheet.getRow(0);
|
||||||
|
if (headerRow == null) {
|
||||||
|
throw new IllegalArgumentException("导入失败:文件中没有表头");
|
||||||
|
}
|
||||||
|
// 获取表头的列数
|
||||||
|
int totalCells = headerRow.getPhysicalNumberOfCells();
|
||||||
|
// 预期的表头列数为5列,可以根据实际需求修改这个条件
|
||||||
|
if (totalCells != 5) {
|
||||||
|
throw new IllegalArgumentException("导入失败:表头列数与预期不符,请检查导入模板");
|
||||||
|
}
|
||||||
|
// 读取表头内容并验证每一列
|
||||||
|
extracted(headerRow, totalCells);
|
||||||
|
//读取Excel表格数据,做非空及格式判断
|
||||||
|
//extractedCell(sheet, totalRows, totalCells);
|
||||||
|
ExcelUtil<WsMaInfo> util = new ExcelUtil<>(WsMaInfo.class);
|
||||||
|
List<WsMaInfo> wsMaInfos = util.importExcel(file.getInputStream());
|
||||||
|
int result = 0;
|
||||||
|
for (WsMaInfo wmInfo : wsMaInfos) {
|
||||||
|
List<WsMaInfo> wsMaInfoList = mapper.queryByName(wmInfo);
|
||||||
|
if (CollectionUtils.isNotEmpty(wsMaInfoList)) {
|
||||||
|
for (WsMaInfo wmInfo : wsMaInfoList) {
|
||||||
|
if () {
|
||||||
|
//进行更新操作
|
||||||
|
|
||||||
|
} else {
|
||||||
|
//新增操作
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (result > 0) {
|
||||||
|
return AjaxResult.success(ExceptionEnum.SUCCESS.getMsg(), result);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return AjaxResult.error(ExceptionEnum.SAVE_TO_DATABASE.getCode(), ExceptionEnum.SAVE_TO_DATABASE.getMsg());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 读取Excel表头模板方法抽取
|
||||||
|
* @param headerRow
|
||||||
|
* @param totalCells
|
||||||
|
*/
|
||||||
|
private void extracted(Row headerRow, int totalCells) {
|
||||||
|
for (int cellNum = 0; cellNum < totalCells; cellNum++) {
|
||||||
|
Cell cell = headerRow.getCell(cellNum);
|
||||||
|
// 获取单元格内容并去除首尾空格
|
||||||
|
String headerValue = cell.getStringCellValue().trim();
|
||||||
|
// 根据列索引进行验证
|
||||||
|
switch (cellNum) {
|
||||||
|
case 0:
|
||||||
|
if (!"姓名".equals(headerValue)) {
|
||||||
|
throw new IllegalArgumentException("第 " + (cellNum + 1) + " 列表头列名与预期不符,请检查导入模板");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
if (!"性别(0 女 1 男)".equals(headerValue)) {
|
||||||
|
throw new IllegalArgumentException("第 " + (cellNum + 1) + " 列表头列名与预期不符,请检查导入模板");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
if (!"岗位工种".equals(headerValue)) {
|
||||||
|
throw new IllegalArgumentException("第 " + (cellNum + 1) + " 列表头列名与预期不符,请检查导入模板");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
if (!"身份证号码".equals(headerValue)) {
|
||||||
|
throw new IllegalArgumentException("第 " + (cellNum + 1) + " 列表头列名与预期不符,请检查导入模板");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
if (!"电话".equals(headerValue)) {
|
||||||
|
throw new IllegalArgumentException("第 " + (cellNum + 1) + " 列表头列名与预期不符,请检查导入模板");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ import com.bonus.common.core.utils.DateUtils;
|
||||||
import com.bonus.common.core.utils.StringUtils;
|
import com.bonus.common.core.utils.StringUtils;
|
||||||
import com.bonus.common.security.utils.SecurityUtils;
|
import com.bonus.common.security.utils.SecurityUtils;
|
||||||
import com.bonus.material.back.mapper.BackApplyInfoMapper;
|
import com.bonus.material.back.mapper.BackApplyInfoMapper;
|
||||||
import com.bonus.material.basic.domain.report.PurChaseReportInfo;
|
|
||||||
import com.bonus.material.repair.domain.*;
|
import com.bonus.material.repair.domain.*;
|
||||||
import com.bonus.material.repair.domain.vo.RepairAuditDetailsVO;
|
import com.bonus.material.repair.domain.vo.RepairAuditDetailsVO;
|
||||||
import com.bonus.material.repair.domain.vo.RepairHomeInfo;
|
import com.bonus.material.repair.domain.vo.RepairHomeInfo;
|
||||||
|
|
@ -28,7 +27,6 @@ import com.bonus.material.task.domain.TmTaskAgreement;
|
||||||
import com.bonus.material.task.mapper.TmTaskAgreementMapper;
|
import com.bonus.material.task.mapper.TmTaskAgreementMapper;
|
||||||
import com.bonus.material.task.mapper.TmTaskMapper;
|
import com.bonus.material.task.mapper.TmTaskMapper;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.ObjectUtils;
|
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
@ -910,8 +908,13 @@ public class RepairAuditDetailsServiceImpl implements IRepairAuditDetailsService
|
||||||
private Long insertScrapTt() {
|
private Long insertScrapTt() {
|
||||||
Long newTask = null;
|
Long newTask = null;
|
||||||
int thisMonthMaxOrder = taskMapper.getMonthMaxOrderByDate(DateUtils.getCurrentYear(), DateUtils.getCurrentMonth(), TmTaskTypeEnum.TM_TASK_SCRAP.getTaskTypeId());
|
int thisMonthMaxOrder = taskMapper.getMonthMaxOrderByDate(DateUtils.getCurrentYear(), DateUtils.getCurrentMonth(), TmTaskTypeEnum.TM_TASK_SCRAP.getTaskTypeId());
|
||||||
// 生成修饰入库单号
|
// 生成报废单号
|
||||||
String code = genderBfTaskCode(thisMonthMaxOrder);
|
String code = genderBfTaskCode(thisMonthMaxOrder);
|
||||||
|
// 根据单号查询该任务是否存在
|
||||||
|
TmTask task = taskMapper.selectTaskByCode(code);
|
||||||
|
if (task != null) {
|
||||||
|
throw new RuntimeException("该审核任务正在进行中,请勿重复提交!");
|
||||||
|
}
|
||||||
TmTask tmTask = new TmTask(null, TmTaskTypeEnum.TM_TASK_SCRAP.getTaskTypeId(), ScrapTaskStatusEnum.SCRAP_TASK_NO_FINISHED.getStatus(),
|
TmTask tmTask = new TmTask(null, TmTaskTypeEnum.TM_TASK_SCRAP.getTaskTypeId(), ScrapTaskStatusEnum.SCRAP_TASK_NO_FINISHED.getStatus(),
|
||||||
null,thisMonthMaxOrder + 1, code);
|
null,thisMonthMaxOrder + 1, code);
|
||||||
tmTask.setCreateTime(DateUtils.getNowDate());
|
tmTask.setCreateTime(DateUtils.getNowDate());
|
||||||
|
|
@ -963,6 +966,11 @@ public class RepairAuditDetailsServiceImpl implements IRepairAuditDetailsService
|
||||||
null,thisMonthMaxOrder + 1, code);
|
null,thisMonthMaxOrder + 1, code);
|
||||||
tmTask.setCreateTime(DateUtils.getNowDate());
|
tmTask.setCreateTime(DateUtils.getNowDate());
|
||||||
tmTask.setCreateBy(SecurityUtils.getLoginUser().getSysUser().getNickName());
|
tmTask.setCreateBy(SecurityUtils.getLoginUser().getSysUser().getNickName());
|
||||||
|
// 根据code查询此任务单号是否存在
|
||||||
|
TmTask task = taskMapper.selectTaskByCode(code);
|
||||||
|
if (task != null) {
|
||||||
|
throw new RuntimeException("该审核任务正在进行中,请勿重复提交!");
|
||||||
|
}
|
||||||
// 插入任务
|
// 插入任务
|
||||||
int taskId = taskMapper.insertTmTask(tmTask);
|
int taskId = taskMapper.insertTmTask(tmTask);
|
||||||
// 如果插入成功且返回的 taskId 大于 0
|
// 如果插入成功且返回的 taskId 大于 0
|
||||||
|
|
|
||||||
|
|
@ -448,6 +448,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<update id="updateBoxStatus">
|
<update id="updateBoxStatus">
|
||||||
update bm_qrcode_box set box_status = 5 where box_id = #{boxId}
|
update bm_qrcode_box set box_status = 6 where box_id = #{boxId}
|
||||||
</update>
|
</update>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
||||||
Binary file not shown.
Loading…
Reference in New Issue