Merge branch 'master' of http://192.168.0.56:3000/bonus/Bonus-Cloud-Material
This commit is contained in:
commit
4a2041a72d
|
|
@ -0,0 +1,311 @@
|
||||||
|
package com.bonus.common.biz.config;
|
||||||
|
|
||||||
|
import org.apache.poi.hssf.usermodel.*;
|
||||||
|
import org.apache.poi.ss.usermodel.BorderStyle;
|
||||||
|
import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
||||||
|
import org.apache.poi.ss.usermodel.VerticalAlignment;
|
||||||
|
import org.apache.poi.ss.util.CellRangeAddress;
|
||||||
|
import org.apache.poi.ss.util.RegionUtil;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出模版样式
|
||||||
|
* @author ma_sh
|
||||||
|
*/
|
||||||
|
public class PoiOutPage {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成带有样式的 Excel 文件
|
||||||
|
* @param result
|
||||||
|
* @param list
|
||||||
|
* @param filename
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static HSSFWorkbook excel(List<Map<String, Object>> result, List<String> list, String filename) {
|
||||||
|
// 获取工作簿对象
|
||||||
|
HSSFWorkbook workbook = new HSSFWorkbook();
|
||||||
|
HSSFSheet sheet = workbook.createSheet();
|
||||||
|
HSSFCellStyle titleStyle = createTitleStyle(workbook);
|
||||||
|
HSSFCellStyle headerStyle = createHeaderStyle(workbook);
|
||||||
|
HSSFCellStyle contentStyle = createCellStyle(workbook);
|
||||||
|
|
||||||
|
// 设置默认列宽
|
||||||
|
sheet.setDefaultColumnWidth(15);
|
||||||
|
|
||||||
|
// 设置工作簿名称
|
||||||
|
workbook.setSheetName(0, filename);
|
||||||
|
|
||||||
|
// 如果数据为空,创建一个空的工作表
|
||||||
|
if (result == null || result.size() == 0) {
|
||||||
|
createEmptySheet(sheet, list, titleStyle, headerStyle, filename);
|
||||||
|
} else {
|
||||||
|
// 如果数据不为空,创建工作表并填充数据
|
||||||
|
int nColumn = list.size();
|
||||||
|
int rowNum = createTitleRow(sheet, titleStyle, filename, nColumn);
|
||||||
|
rowNum = createHeaderRow(sheet, headerStyle, list, rowNum);
|
||||||
|
createDataRows(sheet, result, contentStyle, nColumn, rowNum);
|
||||||
|
}
|
||||||
|
|
||||||
|
return workbook;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int createTitleRow(HSSFSheet sheet, HSSFCellStyle titleStyle, String filename, int nColumn) {
|
||||||
|
HSSFRow row = sheet.createRow(0);
|
||||||
|
row.setHeightInPoints(30);
|
||||||
|
sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, (short) (nColumn - 1)));
|
||||||
|
HSSFCell cell = row.createCell(0);
|
||||||
|
cell.setCellStyle(titleStyle);
|
||||||
|
cell.setCellValue(filename);
|
||||||
|
return 1; // 下一行是表头
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int createHeaderRow(HSSFSheet sheet, HSSFCellStyle headerStyle, List<String> list, int rowNum) {
|
||||||
|
HSSFRow row = sheet.createRow(rowNum);
|
||||||
|
row.setHeightInPoints(20);
|
||||||
|
for (int j = 0; j < list.size(); j++) {
|
||||||
|
HSSFCell cell = row.createCell(j);
|
||||||
|
String header = list.get(j);
|
||||||
|
cell.setCellStyle(headerStyle);
|
||||||
|
cell.setCellValue(header != null ? header : "");
|
||||||
|
}
|
||||||
|
return rowNum + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void createDataRows(HSSFSheet sheet, List<Map<String, Object>> result, HSSFCellStyle contentStyle, int nColumn, int rowNum) {
|
||||||
|
for (Map<String, Object> resultRow : result) {
|
||||||
|
List<Object> rowData = map2List(resultRow);
|
||||||
|
HSSFRow row = sheet.createRow(rowNum++);
|
||||||
|
row.setHeightInPoints(15);
|
||||||
|
|
||||||
|
// 第一列:单位数据
|
||||||
|
if (rowData.size() != nColumn) {
|
||||||
|
HSSFCell cell = row.createCell(0);
|
||||||
|
cell.setCellStyle(contentStyle);
|
||||||
|
cell.setCellValue(rowData.get(0).toString());
|
||||||
|
|
||||||
|
sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 1, (short) (nColumn - 1)));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 填充数据行
|
||||||
|
for (int j = 0; j < nColumn; j++) {
|
||||||
|
HSSFCell cell = row.createCell(j);
|
||||||
|
Object data = rowData.get(j);
|
||||||
|
if (data != null) {
|
||||||
|
setCellValue(cell, contentStyle, data);
|
||||||
|
} else {
|
||||||
|
cell.setCellStyle(contentStyle);
|
||||||
|
cell.setCellValue("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void setCellValue(HSSFCell cell, HSSFCellStyle contentStyle, Object data) {
|
||||||
|
if (isNumeric(data)) {
|
||||||
|
contentStyle.setDataFormat(HSSFDataFormat.getBuiltinFormat("0.00"));
|
||||||
|
cell.setCellStyle(contentStyle);
|
||||||
|
cell.setCellValue(Double.parseDouble(data.toString()));
|
||||||
|
} else {
|
||||||
|
cell.setCellStyle(contentStyle);
|
||||||
|
cell.setCellValue(data.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void createEmptySheet(HSSFSheet sheet, List<String> list, HSSFCellStyle titleStyle, HSSFCellStyle headerStyle, String filename) {
|
||||||
|
int nColumn = list.size();
|
||||||
|
int rowNum = createTitleRow(sheet, titleStyle, filename, nColumn);
|
||||||
|
createHeaderRow(sheet, headerStyle, list, rowNum);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成带有样式的 Excel 文件
|
||||||
|
*
|
||||||
|
* @param result 数据内容(每行是一个 Map)
|
||||||
|
* @param list 表头
|
||||||
|
* @param filename 文件名
|
||||||
|
* @param unit 单位信息
|
||||||
|
* @param projectName 项目名称
|
||||||
|
* @return HSSFWorkbook 生成的 Excel 文件
|
||||||
|
*/
|
||||||
|
public static HSSFWorkbook excelForcheck(List<Map<String, Object>> result, List<String> list,
|
||||||
|
String filename, String unit, String projectName) {
|
||||||
|
// 创建工作簿和工作表
|
||||||
|
HSSFWorkbook workbook = new HSSFWorkbook();
|
||||||
|
HSSFSheet sheet = workbook.createSheet();
|
||||||
|
sheet.setDefaultColumnWidth(15); // 设置列宽
|
||||||
|
|
||||||
|
// 创建样式
|
||||||
|
HSSFCellStyle titleStyle = createTitleStyle(workbook);
|
||||||
|
HSSFCellStyle headerStyle = createHeaderStyle(workbook);
|
||||||
|
HSSFCellStyle contentStyle = createCellStyle(workbook);
|
||||||
|
|
||||||
|
// 设置工作簿名称
|
||||||
|
workbook.setSheetName(0, filename);
|
||||||
|
|
||||||
|
// 填充标题行
|
||||||
|
int rowNum = 0;
|
||||||
|
rowNum = createTitleRow(sheet, rowNum, filename, titleStyle, list.size());
|
||||||
|
rowNum = createProjectInfoRow(sheet, rowNum, projectName, unit, titleStyle, list.size());
|
||||||
|
|
||||||
|
// 填充表头
|
||||||
|
rowNum = createHeaderRow(sheet, rowNum, list, headerStyle);
|
||||||
|
|
||||||
|
// 填充数据行
|
||||||
|
if (result != null && !result.isEmpty()) {
|
||||||
|
rowNum = createDataRows(sheet, rowNum, result, contentStyle, list.size());
|
||||||
|
} else {
|
||||||
|
// 如果没有数据,则仅显示表头
|
||||||
|
rowNum++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return workbook;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建标题行
|
||||||
|
*/
|
||||||
|
private static int createTitleRow(HSSFSheet sheet, int rowNum, String filename, HSSFCellStyle titleStyle, int nColumn) {
|
||||||
|
HSSFRow row = sheet.createRow(rowNum++);
|
||||||
|
row.setHeightInPoints(30);
|
||||||
|
sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, (short) (nColumn - 1)));
|
||||||
|
HSSFCell cell = row.createCell(0);
|
||||||
|
cell.setCellStyle(titleStyle);
|
||||||
|
cell.setCellValue(filename);
|
||||||
|
return rowNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建项目名称和单位信息行
|
||||||
|
*/
|
||||||
|
private static int createProjectInfoRow(HSSFSheet sheet, int rowNum, String projectName, String unit,
|
||||||
|
HSSFCellStyle titleStyle, int nColumn) {
|
||||||
|
HSSFRow row = sheet.createRow(rowNum++);
|
||||||
|
row.setHeightInPoints(30);
|
||||||
|
sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 0, (short) (nColumn - 1)));
|
||||||
|
HSSFCell cell = row.createCell(0);
|
||||||
|
cell.setCellStyle(titleStyle);
|
||||||
|
cell.setCellValue(projectName + " " + unit);
|
||||||
|
|
||||||
|
// 添加边框
|
||||||
|
CellRangeAddress cellRange = new CellRangeAddress(rowNum - 1, rowNum - 1, 0, (short) (nColumn - 1));
|
||||||
|
// 设置边框样式
|
||||||
|
RegionUtil.setBorderTop(BorderStyle.THIN, cellRange, sheet);
|
||||||
|
RegionUtil.setBorderBottom(BorderStyle.THIN, cellRange, sheet);
|
||||||
|
RegionUtil.setBorderLeft(BorderStyle.THIN, cellRange, sheet);
|
||||||
|
RegionUtil.setBorderRight(BorderStyle.THIN, cellRange, sheet);
|
||||||
|
|
||||||
|
return rowNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建表头行
|
||||||
|
*/
|
||||||
|
private static int createHeaderRow(HSSFSheet sheet, int rowNum, List<String> list, HSSFCellStyle headerStyle) {
|
||||||
|
HSSFRow row = sheet.createRow(rowNum++);
|
||||||
|
row.setHeightInPoints(20);
|
||||||
|
for (int j = 0; j < list.size(); j++) {
|
||||||
|
HSSFCell cell = row.createCell(j);
|
||||||
|
String header = list.get(j);
|
||||||
|
cell.setCellStyle(headerStyle);
|
||||||
|
cell.setCellValue(header != null ? header : "");
|
||||||
|
}
|
||||||
|
return rowNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建数据行
|
||||||
|
*/
|
||||||
|
private static int createDataRows(HSSFSheet sheet, int rowNum, List<Map<String, Object>> result,
|
||||||
|
HSSFCellStyle contentStyle, int nColumn) {
|
||||||
|
for (Map<String, Object> resultRow : result) {
|
||||||
|
HSSFRow row = sheet.createRow(rowNum++);
|
||||||
|
row.setHeightInPoints(15);
|
||||||
|
List<Object> rowData = map2List(resultRow);
|
||||||
|
|
||||||
|
for (int j = 0; j < nColumn; j++) {
|
||||||
|
HSSFCell cell = row.createCell(j);
|
||||||
|
Object data = rowData.get(j);
|
||||||
|
setCellData(cell, data, contentStyle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return rowNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置单元格数据,并自动判断数据类型
|
||||||
|
*/
|
||||||
|
private static void setCellData(HSSFCell cell, Object data, HSSFCellStyle contentStyle) {
|
||||||
|
if (data != null) {
|
||||||
|
if (isNumeric(data)) {
|
||||||
|
cell.setCellStyle(contentStyle);
|
||||||
|
cell.setCellValue(Double.parseDouble(data.toString()));
|
||||||
|
} else {
|
||||||
|
cell.setCellStyle(contentStyle);
|
||||||
|
cell.setCellValue(data.toString());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
cell.setCellStyle(contentStyle);
|
||||||
|
cell.setCellValue("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断是否是数字
|
||||||
|
*/
|
||||||
|
private static boolean isNumeric(Object data) {
|
||||||
|
if (data == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return data.toString().matches("^(-?\\d+)(\\.\\d+)?$");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将 Map 转换为 List
|
||||||
|
*/
|
||||||
|
private static List<Object> map2List(Map<String, Object> map) {
|
||||||
|
List<Object> list = new ArrayList<>();
|
||||||
|
for (Map.Entry<String, Object> entry : map.entrySet()) {
|
||||||
|
list.add(entry.getValue());
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 以下是创建样式的方法(可根据需要调整)
|
||||||
|
|
||||||
|
private static HSSFCellStyle createTitleStyle(HSSFWorkbook workbook) {
|
||||||
|
HSSFCellStyle style = workbook.createCellStyle();
|
||||||
|
style.setAlignment(HorizontalAlignment.CENTER);
|
||||||
|
style.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||||
|
HSSFFont font = workbook.createFont();
|
||||||
|
font.setBold(true);
|
||||||
|
font.setFontHeightInPoints((short) 14);
|
||||||
|
style.setFont(font);
|
||||||
|
return style;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static HSSFCellStyle createHeaderStyle(HSSFWorkbook workbook) {
|
||||||
|
HSSFCellStyle style = workbook.createCellStyle();
|
||||||
|
style.setAlignment(HorizontalAlignment.CENTER);
|
||||||
|
style.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||||
|
HSSFFont font = workbook.createFont();
|
||||||
|
font.setBold(true);
|
||||||
|
font.setFontHeightInPoints((short) 12);
|
||||||
|
style.setFont(font);
|
||||||
|
return style;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static HSSFCellStyle createCellStyle(HSSFWorkbook workbook) {
|
||||||
|
HSSFCellStyle style = workbook.createCellStyle();
|
||||||
|
style.setAlignment(HorizontalAlignment.CENTER);
|
||||||
|
style.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||||
|
HSSFFont font = workbook.createFont();
|
||||||
|
font.setFontHeightInPoints((short) 10);
|
||||||
|
style.setFont(font);
|
||||||
|
return style;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -159,4 +159,7 @@ public class BackApplyInfo implements Serializable {
|
||||||
|
|
||||||
@ApiModelProperty(value="设备编码")
|
@ApiModelProperty(value="设备编码")
|
||||||
private String maCode;
|
private String maCode;
|
||||||
|
|
||||||
|
@ApiModelProperty(value="二维码")
|
||||||
|
private String qrCode;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -282,4 +282,11 @@ public interface BackApplyInfoMapper {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int updateMaCode(MaCodeDto maCodeDto);
|
int updateMaCode(MaCodeDto maCodeDto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据二维码查询机具信息
|
||||||
|
* @param dto
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<MaCodeVo> getMachineByQrCode(BackApplyInfo dto);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -963,7 +963,12 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
||||||
@Override
|
@Override
|
||||||
public AjaxResult getMachine(BackApplyInfo dto) {
|
public AjaxResult getMachine(BackApplyInfo dto) {
|
||||||
//判断输入或者编码识别或者二维码识别是否为领料工程和单位对应
|
//判断输入或者编码识别或者二维码识别是否为领料工程和单位对应
|
||||||
List<MaCodeVo> list = backApplyInfoMapper.getMachine(dto);
|
List<MaCodeVo> list = new ArrayList<>();
|
||||||
|
if (dto.getMaCode() != null) {
|
||||||
|
list = backApplyInfoMapper.getMachine(dto);
|
||||||
|
} else if (dto.getQrCode() != null) {
|
||||||
|
list = backApplyInfoMapper.getMachineByQrCode(dto);
|
||||||
|
}
|
||||||
if (CollectionUtils.isNotEmpty(list)) {
|
if (CollectionUtils.isNotEmpty(list)) {
|
||||||
for (MaCodeVo maCodeVo : list) {
|
for (MaCodeVo maCodeVo : list) {
|
||||||
Map<String, String> maMachineMap = remoteConfig.getDictValue("ma_machine_status");
|
Map<String, String> maMachineMap = remoteConfig.getDictValue("ma_machine_status");
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,27 @@ public class LeaseApplyInfoController extends BaseController {
|
||||||
return success(leaseApplyInfoService.selectLeaseApplyInfoById(id, keyWord));
|
return success(leaseApplyInfoService.selectLeaseApplyInfoById(id, keyWord));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取领料出库单详细信息
|
||||||
|
* @param leaseApplyInfo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "获取领料出库单详细信息")
|
||||||
|
//@RequiresPermissions("lease:info:query")
|
||||||
|
@GetMapping(value = "/getInfo")
|
||||||
|
public AjaxResult getInfo(LeaseApplyInfo leaseApplyInfo) {
|
||||||
|
return success(leaseApplyInfoService.getInfo(leaseApplyInfo.getId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "导出领料出库单详情")
|
||||||
|
//@RequiresPermissions("lease:info:export")
|
||||||
|
@SysLog(title = "领料任务", businessType = OperaType.EXPORT, logType = 1,module = "仓储管理->导出领料任务详情")
|
||||||
|
@PostMapping("/exportInfo")
|
||||||
|
public void exportInfo(HttpServletResponse response, LeaseApplyInfo leaseApplyInfo) {
|
||||||
|
LeaseApplyRequestVo leaseApplyRequestVo = leaseApplyInfoService.getInfo(leaseApplyInfo.getId());
|
||||||
|
leaseApplyInfoService.exportInfo(leaseApplyRequestVo, response);
|
||||||
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "导出领料任务详情")
|
@ApiOperation(value = "导出领料任务详情")
|
||||||
@PreventRepeatSubmit
|
@PreventRepeatSubmit
|
||||||
//@RequiresPermissions("lease:info:export")
|
//@RequiresPermissions("lease:info:export")
|
||||||
|
|
|
||||||
|
|
@ -32,4 +32,6 @@ public class LeaseApplyRequestVo extends BaseEntity {
|
||||||
@ApiModelProperty(value = "领料-机具规格详情列表")
|
@ApiModelProperty(value = "领料-机具规格详情列表")
|
||||||
private List<LeaseApplyDetails> leaseApplyDetailsList;
|
private List<LeaseApplyDetails> leaseApplyDetailsList;
|
||||||
|
|
||||||
|
private List<LeaseOutVo> leaseOutVoList;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,64 @@
|
||||||
|
package com.bonus.material.lease.domain.vo;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author ma_sh
|
||||||
|
* @create 2024/12/25 13:42
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class LeaseOutVo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("主键")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@ApiModelProperty("任务id")
|
||||||
|
private Long taskId;
|
||||||
|
|
||||||
|
@ApiModelProperty("机具名称")
|
||||||
|
private String typeName;
|
||||||
|
|
||||||
|
@ApiModelProperty("规格型号")
|
||||||
|
private String typeModelName;
|
||||||
|
|
||||||
|
@ApiModelProperty("单位")
|
||||||
|
private String unit;
|
||||||
|
|
||||||
|
@ApiModelProperty("数量")
|
||||||
|
private BigDecimal num;
|
||||||
|
|
||||||
|
@ApiModelProperty("设备编码")
|
||||||
|
private String maCode;
|
||||||
|
|
||||||
|
@ApiModelProperty("额定载荷")
|
||||||
|
private String ratedLoad;
|
||||||
|
|
||||||
|
@ApiModelProperty("试验载荷")
|
||||||
|
private String testLoad;
|
||||||
|
|
||||||
|
@ApiModelProperty("持荷时间")
|
||||||
|
private String holdingTime;
|
||||||
|
|
||||||
|
@ApiModelProperty("试验日期")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
|
private Date testTime;
|
||||||
|
|
||||||
|
@ApiModelProperty("下次试验日期")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
|
private Date nextTestTime;
|
||||||
|
|
||||||
|
@ApiModelProperty("验收结论")
|
||||||
|
private String checkResult;
|
||||||
|
|
||||||
|
@ApiModelProperty("备注")
|
||||||
|
private String remark;
|
||||||
|
}
|
||||||
|
|
@ -6,6 +6,7 @@ import com.bonus.material.back.domain.vo.MaCodeVo;
|
||||||
import com.bonus.material.basic.domain.BmQrcodeInfo;
|
import com.bonus.material.basic.domain.BmQrcodeInfo;
|
||||||
import com.bonus.material.lease.domain.LeaseApplyDetails;
|
import com.bonus.material.lease.domain.LeaseApplyDetails;
|
||||||
import com.bonus.common.biz.domain.lease.LeaseOutDetails;
|
import com.bonus.common.biz.domain.lease.LeaseOutDetails;
|
||||||
|
import com.bonus.material.lease.domain.vo.LeaseOutVo;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -96,4 +97,11 @@ public interface LeaseApplyDetailsMapper {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<MaCodeVo> getCodeList(@Param("id") Long id, @Param("typeId") Long typeId);
|
List<MaCodeVo> getCodeList(@Param("id") Long id, @Param("typeId") Long typeId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取领料出库单详情
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<LeaseOutVo> selectLeaseOutDetailsList(Long id);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@ import com.bonus.material.lease.domain.LeaseApplyDetails;
|
||||||
import com.bonus.material.lease.domain.vo.LeaseApplyRequestVo;
|
import com.bonus.material.lease.domain.vo.LeaseApplyRequestVo;
|
||||||
import com.bonus.common.biz.domain.lease.LeaseOutRequestVo;
|
import com.bonus.common.biz.domain.lease.LeaseOutRequestVo;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 领料任务Service接口
|
* 领料任务Service接口
|
||||||
*
|
*
|
||||||
|
|
@ -94,4 +96,18 @@ public interface ILeaseApplyInfoService {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
AjaxResult getInfoByQrcode(BmQrcodeInfo bmQrcodeInfo);
|
AjaxResult getInfoByQrcode(BmQrcodeInfo bmQrcodeInfo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取领料任务详情
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
LeaseApplyRequestVo getInfo(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出领料出库详细
|
||||||
|
* @param leaseApplyRequestVo
|
||||||
|
* @param response
|
||||||
|
*/
|
||||||
|
void exportInfo(LeaseApplyRequestVo leaseApplyRequestVo, HttpServletResponse response);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,13 @@
|
||||||
package com.bonus.material.lease.service.impl;
|
package com.bonus.material.lease.service.impl;
|
||||||
|
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.net.URLEncoder;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import com.bonus.common.biz.config.PoiOutPage;
|
||||||
import com.bonus.common.biz.constant.MaterialConstants;
|
import com.bonus.common.biz.constant.MaterialConstants;
|
||||||
import com.bonus.common.biz.enums.HttpCodeEnum;
|
import com.bonus.common.biz.enums.HttpCodeEnum;
|
||||||
import com.bonus.common.biz.enums.LeaseTaskStatusEnum;
|
import com.bonus.common.biz.enums.LeaseTaskStatusEnum;
|
||||||
|
|
@ -21,12 +24,15 @@ import com.bonus.material.lease.domain.LeaseApplyDetails;
|
||||||
import com.bonus.common.biz.domain.lease.LeaseOutDetails;
|
import com.bonus.common.biz.domain.lease.LeaseOutDetails;
|
||||||
import com.bonus.material.lease.domain.vo.LeaseApplyRequestVo;
|
import com.bonus.material.lease.domain.vo.LeaseApplyRequestVo;
|
||||||
import com.bonus.common.biz.domain.lease.LeaseOutRequestVo;
|
import com.bonus.common.biz.domain.lease.LeaseOutRequestVo;
|
||||||
|
import com.bonus.material.lease.domain.vo.LeaseOutVo;
|
||||||
import com.bonus.material.lease.mapper.LeaseApplyDetailsMapper;
|
import com.bonus.material.lease.mapper.LeaseApplyDetailsMapper;
|
||||||
import com.bonus.material.lease.service.ILeaseOutDetailsService;
|
import com.bonus.material.lease.service.ILeaseOutDetailsService;
|
||||||
import com.bonus.material.task.domain.TmTask;
|
import com.bonus.material.task.domain.TmTask;
|
||||||
import com.bonus.material.task.domain.TmTaskAgreement;
|
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 org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||||
import org.springframework.dao.DataAccessException;
|
import org.springframework.dao.DataAccessException;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.bonus.material.lease.mapper.LeaseApplyInfoMapper;
|
import com.bonus.material.lease.mapper.LeaseApplyInfoMapper;
|
||||||
|
|
@ -35,6 +41,7 @@ import com.bonus.material.lease.service.ILeaseApplyInfoService;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 领料任务Service业务层处理
|
* 领料任务Service业务层处理
|
||||||
|
|
@ -43,6 +50,7 @@ import javax.annotation.Resource;
|
||||||
* @date 2024-10-16
|
* @date 2024-10-16
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
|
@Slf4j
|
||||||
public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService {
|
public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
|
|
@ -338,4 +346,132 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService {
|
||||||
result.put("msg", msg);
|
result.put("msg", msg);
|
||||||
return AjaxResult.success(result);
|
return AjaxResult.success(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LeaseApplyRequestVo getInfo(Long id) {
|
||||||
|
try {
|
||||||
|
Optional<LeaseApplyInfo> optionalInfo = Optional.ofNullable(leaseApplyInfoMapper.selectLeaseApplyInfoById(id));
|
||||||
|
LeaseApplyRequestVo leaseApplyRequestVo = new LeaseApplyRequestVo();
|
||||||
|
|
||||||
|
optionalInfo.ifPresent(info -> {
|
||||||
|
leaseApplyRequestVo.setLeaseApplyInfo(info);
|
||||||
|
// 获取领料单详情
|
||||||
|
List<LeaseOutVo> details = leaseApplyDetailsMapper.selectLeaseOutDetailsList(id);
|
||||||
|
if (!CollectionUtils.isEmpty(details)) {
|
||||||
|
leaseApplyRequestVo.setLeaseOutVoList(details);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return leaseApplyRequestVo;
|
||||||
|
} catch (Exception e) {
|
||||||
|
// 记录异常日志
|
||||||
|
System.err.println("Error occurred while selecting lease apply info by ID: " + id + e.getMessage());
|
||||||
|
throw new RuntimeException("Failed to select lease apply info", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void exportInfo(LeaseApplyRequestVo leaseApplyRequestVo, HttpServletResponse response) {
|
||||||
|
try {
|
||||||
|
String fileName = "施工机具设备出库检验记录表";
|
||||||
|
String projectName = "";
|
||||||
|
String unit = "";
|
||||||
|
if (leaseApplyRequestVo != null && leaseApplyRequestVo.getLeaseApplyInfo() != null) {
|
||||||
|
projectName ="领用工程:" + leaseApplyRequestVo.getLeaseApplyInfo().getProjectName();
|
||||||
|
unit ="使用单位:" + leaseApplyRequestVo.getLeaseApplyInfo().getLeaseUnit();
|
||||||
|
}
|
||||||
|
List<LeaseOutVo> list = leaseApplyRequestVo.getLeaseOutVoList();
|
||||||
|
expOutExcel(response,list,fileName,projectName,unit);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.toString(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出领料单
|
||||||
|
* @param response
|
||||||
|
* @param list
|
||||||
|
* @param filename
|
||||||
|
* @param projectName
|
||||||
|
* @param unit
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
private void expOutExcel(HttpServletResponse response, List<LeaseOutVo> list, String filename,String projectName,String unit)
|
||||||
|
throws Exception {
|
||||||
|
if (list != null) {
|
||||||
|
List<Map<String, Object>> results = new ArrayList<Map<String, Object>>();
|
||||||
|
int size = list.size();
|
||||||
|
for (int i = 0; i < size; i++) {
|
||||||
|
LeaseOutVo bean = list.get(i);
|
||||||
|
Map<String, Object> maps = outReceiveDetailsBeanToMap(bean);
|
||||||
|
results.add(maps);
|
||||||
|
}
|
||||||
|
List<String> headers = receiveDetailsHeader();
|
||||||
|
HSSFWorkbook workbook = PoiOutPage.excelForcheck(results, headers, filename,projectName,unit);
|
||||||
|
OutputStream out = null;
|
||||||
|
response.setContentType("application/vnd.ms-excel;charset=UTF-8");
|
||||||
|
response.addHeader("Content-Disposition",
|
||||||
|
"attachment;filename=" + URLEncoder.encode(filename, "UTF-8") + ".xls");
|
||||||
|
response.setHeader("Pragma", "No-cache");
|
||||||
|
out = response.getOutputStream();
|
||||||
|
workbook.write(out);
|
||||||
|
out.flush();
|
||||||
|
out.close();
|
||||||
|
}else{
|
||||||
|
List<Map<String, Object>> results = new ArrayList<Map<String, Object>>();
|
||||||
|
List<String> headers = receiveDetailsHeader();
|
||||||
|
HSSFWorkbook workbook = PoiOutPage.excel(results, headers, filename);
|
||||||
|
OutputStream out = null;
|
||||||
|
response.setContentType("application/vnd.ms-excel;charset=UTF-8");
|
||||||
|
response.addHeader("Content-Disposition",
|
||||||
|
"attachment;filename=" + URLEncoder.encode(filename, "UTF-8") + ".xls");
|
||||||
|
response.setHeader("Pragma", "No-cache");
|
||||||
|
out = response.getOutputStream();
|
||||||
|
workbook.write(out);
|
||||||
|
out.flush();
|
||||||
|
out.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 领料单数据转换
|
||||||
|
* @param bean
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private Map<String, Object> outReceiveDetailsBeanToMap(LeaseOutVo bean) {
|
||||||
|
Map<String, Object> maps = new LinkedHashMap<String, Object>();
|
||||||
|
maps.put("typeName", bean.getTypeName());
|
||||||
|
maps.put("typeModelName", bean.getTypeModelName());
|
||||||
|
maps.put("unit", bean.getUnit());
|
||||||
|
maps.put("num", bean.getNum());
|
||||||
|
maps.put("maCode", bean.getMaCode());
|
||||||
|
maps.put("ratedLoad", bean.getRatedLoad());
|
||||||
|
maps.put("testLoad", bean.getTestLoad());
|
||||||
|
maps.put("holdingTime", bean.getHoldingTime());
|
||||||
|
maps.put("testTime", bean.getTestTime());
|
||||||
|
maps.put("nextTestTime", bean.getNextTestTime());
|
||||||
|
maps.put("checkResult", bean.getCheckResult());
|
||||||
|
maps.put("remark", bean.getRemark());
|
||||||
|
return maps;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 领料单表头
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private List<String> receiveDetailsHeader() {
|
||||||
|
ArrayList<String> list = new ArrayList<String>();
|
||||||
|
list.add("机具名称");
|
||||||
|
list.add("规格型号");
|
||||||
|
list.add("单位");
|
||||||
|
list.add("数量");
|
||||||
|
list.add("设备编码");
|
||||||
|
list.add("额定载荷KN");
|
||||||
|
list.add("试验载荷KN");
|
||||||
|
list.add("持荷时间min");
|
||||||
|
list.add("试验日期");
|
||||||
|
list.add("下次试验日期");
|
||||||
|
list.add("检验结论");
|
||||||
|
list.add("备注");
|
||||||
|
return list;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -370,6 +370,40 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
where bcd.parent_id = #{parentId} and bcd.type_id = #{typeId}
|
where bcd.parent_id = #{parentId} and bcd.type_id = #{typeId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getMachineByQrCode" resultType="com.bonus.material.back.domain.vo.MaCodeVo">
|
||||||
|
SELECT
|
||||||
|
mm.ma_id AS maId,
|
||||||
|
mm.ma_code AS maCode,
|
||||||
|
mm.ma_status AS maStatus,
|
||||||
|
mt1.type_name AS typeName,
|
||||||
|
mm.type_id AS typeId,
|
||||||
|
mt.type_name AS materialName,
|
||||||
|
mt2.type_name AS materialType,
|
||||||
|
ba.unit_id AS unitId,
|
||||||
|
bu.unit_name AS unitName,
|
||||||
|
ba.project_id AS proId,
|
||||||
|
bp.pro_name AS proName,
|
||||||
|
ba.agreement_id AS agreementId
|
||||||
|
FROM
|
||||||
|
lease_out_details lod
|
||||||
|
LEFT JOIN ma_machine mm ON lod.ma_id = mm.ma_id
|
||||||
|
LEFT JOIN ma_type mt ON mm.type_id = mt.type_id
|
||||||
|
AND mt.del_flag = '0'
|
||||||
|
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
|
||||||
|
AND mt1.del_flag = '0'
|
||||||
|
LEFT JOIN ma_type mt2 ON mt1.parent_id = mt2.type_id
|
||||||
|
AND mt2.del_flag = '0'
|
||||||
|
LEFT JOIN lease_apply_info lai ON lod.parent_id = lai.id
|
||||||
|
LEFT JOIN tm_task_agreement tta ON lai.task_id = tta.task_id
|
||||||
|
LEFT JOIN bm_agreement_info ba ON tta.agreement_id = ba.agreement_id
|
||||||
|
LEFT JOIN bm_project bp on bp.pro_id = ba.project_id
|
||||||
|
AND bp.del_flag = '0'
|
||||||
|
LEFT JOIN bm_unit bu on bu.unit_id = ba.unit_id
|
||||||
|
AND bu.del_flag = '0'
|
||||||
|
WHERE
|
||||||
|
mm.ma_status = '2' and mm.qr_code = #{qrCode}
|
||||||
|
</select>
|
||||||
|
|
||||||
<insert id="insertBackApplyInfo" parameterType="com.bonus.material.back.domain.BackApplyInfo" useGeneratedKeys="true" keyProperty="id">
|
<insert id="insertBackApplyInfo" parameterType="com.bonus.material.back.domain.BackApplyInfo" useGeneratedKeys="true" keyProperty="id">
|
||||||
insert into back_apply_info
|
insert into back_apply_info
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
|
|
||||||
|
|
@ -269,4 +269,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
lod.parent_id = #{id}
|
lod.parent_id = #{id}
|
||||||
and mt.type_id = #{typeId}
|
and mt.type_id = #{typeId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectLeaseOutDetailsList" resultType="com.bonus.material.lease.domain.vo.LeaseOutVo">
|
||||||
|
SELECT
|
||||||
|
mt1.type_name AS typeName,
|
||||||
|
mt.type_name AS typeModelName,
|
||||||
|
mt.unit_name AS unit,
|
||||||
|
lod.out_num AS num,
|
||||||
|
mm.ma_code AS maCode,
|
||||||
|
mt.rated_load AS ratedLoad,
|
||||||
|
mt.test_load AS testLoad,
|
||||||
|
mt.holding_time AS holdingTime,
|
||||||
|
lod.create_time AS testTime,
|
||||||
|
pcd.check_result AS checkResult,
|
||||||
|
lad.remark AS remark,
|
||||||
|
DATE_SUB(DATE_ADD(lod.create_time, INTERVAL 1 YEAR), INTERVAL 1 DAY) AS nextTestTime -- 计算 nextTestTime
|
||||||
|
FROM
|
||||||
|
lease_out_details lod
|
||||||
|
LEFT JOIN ma_type mt ON lod.type_id = mt.type_id AND mt.del_flag = '0'
|
||||||
|
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id AND mt1.del_flag = '0'
|
||||||
|
LEFT JOIN ma_machine mm ON lod.ma_id = mm.ma_id
|
||||||
|
LEFT JOIN lease_apply_details lad ON lod.type_id = lad.type_id
|
||||||
|
LEFT JOIN purchase_check_details pcd ON lod.type_id = pcd.type_id
|
||||||
|
WHERE lod.parent_id = #{id}
|
||||||
|
GROUP BY lod.type_id, mm.ma_code
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
||||||
|
|
@ -132,6 +132,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<select id="selectPurchaseCheckInfoJoinList" resultMap="PurchaseCheckInfoResult">
|
<select id="selectPurchaseCheckInfoJoinList" resultMap="PurchaseCheckInfoResult">
|
||||||
<include refid="selectPurchaseCheckInfoJoinSQL"/>
|
<include refid="selectPurchaseCheckInfoJoinSQL"/>
|
||||||
<where>
|
<where>
|
||||||
|
<if test="code != null and code != ''"> and t.code = #{code}</if>
|
||||||
<if test="taskId != null "> and pci.task_id = #{taskId}</if>
|
<if test="taskId != null "> and pci.task_id = #{taskId}</if>
|
||||||
<if test="purchaseTime != null "> and pci.purchase_time = #{purchaseTime}</if>
|
<if test="purchaseTime != null "> and pci.purchase_time = #{purchaseTime}</if>
|
||||||
<if test="startTime != null "> and date_format(pci.arrival_time,'%y%m%d') >= date_format(#{startTime},'%y%m%d')</if>
|
<if test="startTime != null "> and date_format(pci.arrival_time,'%y%m%d') >= date_format(#{startTime},'%y%m%d')</if>
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
LEFT JOIN bm_project bpi ON bai2.project_id = bpi.pro_id and bpi.del_flag = '0'
|
LEFT JOIN bm_project bpi ON bai2.project_id = bpi.pro_id and bpi.del_flag = '0'
|
||||||
left join sys_user su on rd.create_by = su.user_id
|
left join sys_user su on rd.create_by = su.user_id
|
||||||
<where>
|
<where>
|
||||||
|
<if test="inputCode != null and inputCode != ''">
|
||||||
|
AND tt.CODE = #{inputCode}
|
||||||
|
</if>
|
||||||
<if test="keyWord != null and keyWord != ''">
|
<if test="keyWord != null and keyWord != ''">
|
||||||
AND (
|
AND (
|
||||||
locate(#{keyWord}, su.nick_name) > 0
|
locate(#{keyWord}, su.nick_name) > 0
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue