This commit is contained in:
parent
758b91dbbb
commit
374881ab17
|
|
@ -1,6 +1,7 @@
|
||||||
package com.bonus.sgzb.base.api.domain;
|
package com.bonus.sgzb.base.api.domain;
|
||||||
|
|
||||||
import com.alibaba.fastjson2.annotation.JSONField;
|
import com.alibaba.fastjson2.annotation.JSONField;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
@ -135,9 +136,13 @@ public class LeaseOutDetails implements Serializable {
|
||||||
* 创建时间
|
* 创建时间
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "创建时间")
|
@ApiModelProperty(value = "创建时间")
|
||||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||||
private Date createTime;
|
private Date createTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "创建时间")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||||
|
private String outTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新者
|
* 更新者
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -92,6 +92,11 @@ public class SysLoginService {
|
||||||
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户已停用,请联系管理员");
|
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户已停用,请联系管理员");
|
||||||
throw new ServiceException("对不起,您的账号:" + username + " 已停用");
|
throw new ServiceException("对不起,您的账号:" + username + " 已停用");
|
||||||
}
|
}
|
||||||
|
// 判断密码是否为原始密码,原始密码需要修改密码方可登录
|
||||||
|
if (passwordService.checkFirstLogin(user, password)) {
|
||||||
|
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "登录密码为系统默认密码,请修改密码后重新登录");
|
||||||
|
throw new ServiceException("登录密码为系统默认密码,请修改密码后重新登录");
|
||||||
|
}
|
||||||
passwordService.validate(user, password);
|
passwordService.validate(user, password);
|
||||||
recordLogService.recordLogininfor(username, Constants.LOGIN_SUCCESS, "登录成功");
|
recordLogService.recordLogininfor(username, Constants.LOGIN_SUCCESS, "登录成功");
|
||||||
return userInfo;
|
return userInfo;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
package com.bonus.sgzb.auth.service;
|
package com.bonus.sgzb.auth.service;
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import com.bonus.sgzb.common.core.domain.SystemConfig;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import com.bonus.sgzb.common.core.constant.CacheConstants;
|
import com.bonus.sgzb.common.core.constant.CacheConstants;
|
||||||
|
|
@ -10,6 +12,8 @@ import com.bonus.sgzb.common.redis.service.RedisService;
|
||||||
import com.bonus.sgzb.common.security.utils.SecurityUtils;
|
import com.bonus.sgzb.common.security.utils.SecurityUtils;
|
||||||
import com.bonus.sgzb.system.api.domain.SysUser;
|
import com.bonus.sgzb.system.api.domain.SysUser;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录密码方法
|
* 登录密码方法
|
||||||
*
|
*
|
||||||
|
|
@ -24,6 +28,9 @@ public class SysPasswordService {
|
||||||
|
|
||||||
private Long lockTime = CacheConstants.PASSWORD_LOCK_TIME;
|
private Long lockTime = CacheConstants.PASSWORD_LOCK_TIME;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private SystemConfig systemConfig;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SysRecordLogService recordLogService;
|
private SysRecordLogService recordLogService;
|
||||||
|
|
||||||
|
|
@ -71,4 +78,14 @@ public class SysPasswordService {
|
||||||
redisService.deleteObject(getCacheKey(loginName));
|
redisService.deleteObject(getCacheKey(loginName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean checkFirstLogin(SysUser user, String password) {
|
||||||
|
if (!systemConfig.getPasswordConfig().isForcePasswordChangeOnFirstLogin()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (matches(user, password)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,178 @@
|
||||||
|
package com.bonus.sgzb.common.core.domain;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author ma_sh
|
||||||
|
* @create 2025/4/17 14:11
|
||||||
|
*/
|
||||||
|
@RefreshScope
|
||||||
|
@Component
|
||||||
|
@ConfigurationProperties(prefix = "system-config")
|
||||||
|
@Data
|
||||||
|
public class SystemConfig {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录配置
|
||||||
|
*/
|
||||||
|
private LoginConfig loginConfig;
|
||||||
|
/**
|
||||||
|
* 增加配置以支持增加根节点公司的添加和删除功能
|
||||||
|
*/
|
||||||
|
private boolean addRootCompany;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公司是否添加地址信息
|
||||||
|
*/
|
||||||
|
private boolean addAddress;
|
||||||
|
/**
|
||||||
|
* token过期时间
|
||||||
|
*/
|
||||||
|
private Long tokenTime;
|
||||||
|
/**
|
||||||
|
* 是否是管理员登录,如果启用超级管理员,则除了登录时需要系统验证码还需要短信验证码
|
||||||
|
*/
|
||||||
|
private boolean admin;
|
||||||
|
/**
|
||||||
|
* 注册配置
|
||||||
|
*/
|
||||||
|
private RegistersConfig registersConfig;
|
||||||
|
/**
|
||||||
|
* 网络请求
|
||||||
|
*/
|
||||||
|
private RequestConfig requestConfig;
|
||||||
|
/**
|
||||||
|
* 密码配置校验
|
||||||
|
*/
|
||||||
|
private PasswordConfig passwordConfig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* websocketUrl
|
||||||
|
*/
|
||||||
|
private String websocketurl;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@RefreshScope
|
||||||
|
public static class LoginConfig {
|
||||||
|
/**
|
||||||
|
* 手机密码登录
|
||||||
|
*/
|
||||||
|
private boolean phonePassword;
|
||||||
|
/**
|
||||||
|
* 邮箱密码登录
|
||||||
|
*/
|
||||||
|
private boolean emailPassword;
|
||||||
|
/**
|
||||||
|
* 手机验证码
|
||||||
|
*/
|
||||||
|
private boolean phoneCode;
|
||||||
|
/**
|
||||||
|
* 邮箱验证码
|
||||||
|
*/
|
||||||
|
private boolean emailCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@RefreshScope
|
||||||
|
public static class RegistersConfig {
|
||||||
|
/**
|
||||||
|
* 手机注册
|
||||||
|
*/
|
||||||
|
private boolean phoneRegisters;
|
||||||
|
/**
|
||||||
|
* 邮箱注册
|
||||||
|
*/
|
||||||
|
private boolean emailRegisters;
|
||||||
|
/**
|
||||||
|
* 是否开启手机验证码
|
||||||
|
*/
|
||||||
|
private boolean verificationCode;
|
||||||
|
/**
|
||||||
|
* 注册是否审核
|
||||||
|
*/
|
||||||
|
private boolean approvalStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@RefreshScope
|
||||||
|
public static class RequestConfig {
|
||||||
|
/**
|
||||||
|
* 请求加密
|
||||||
|
*/
|
||||||
|
private boolean encryptRequest;
|
||||||
|
/**
|
||||||
|
* 数据完整性校验
|
||||||
|
*/
|
||||||
|
private boolean checkIntegrity;
|
||||||
|
/**
|
||||||
|
* 返回数据加密
|
||||||
|
*/
|
||||||
|
private boolean encryptResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@RefreshScope
|
||||||
|
public static class PasswordConfig {
|
||||||
|
/**
|
||||||
|
* 密码的最小长度
|
||||||
|
*/
|
||||||
|
private int minLength;
|
||||||
|
/**
|
||||||
|
* 密码的最大长度
|
||||||
|
*/
|
||||||
|
private int maxLength;
|
||||||
|
/**
|
||||||
|
* 是否需要包含大写字母
|
||||||
|
*/
|
||||||
|
private boolean requireUpperCase;
|
||||||
|
/**
|
||||||
|
* 是否需要包含小写字母
|
||||||
|
*/
|
||||||
|
private boolean requireLowerCase;
|
||||||
|
/**
|
||||||
|
* 是否需要包含数字
|
||||||
|
*/
|
||||||
|
private boolean requireDigit;
|
||||||
|
/**
|
||||||
|
* 是否需要包含特殊字符
|
||||||
|
*/
|
||||||
|
private boolean requireSpecialChar;
|
||||||
|
/**
|
||||||
|
* 常见的弱密码列表,禁止使用这些密码
|
||||||
|
*/
|
||||||
|
private List<String> weakPasswords;
|
||||||
|
/**
|
||||||
|
* 密码历史记录限制
|
||||||
|
*/
|
||||||
|
private int passwordHistoryLimit;
|
||||||
|
/**
|
||||||
|
* 是否限制连续相同字符
|
||||||
|
*/
|
||||||
|
private boolean restrictConsecutiveChars;
|
||||||
|
/**
|
||||||
|
* 最大允许的连续字符数
|
||||||
|
*/
|
||||||
|
private int maxConsecutiveChars;
|
||||||
|
/**
|
||||||
|
* 密码中是否不能包含用户名
|
||||||
|
*/
|
||||||
|
private boolean excludeUsernameInPassword;
|
||||||
|
/**
|
||||||
|
* 是否在首次登录时强制修改密码
|
||||||
|
*/
|
||||||
|
private boolean forcePasswordChangeOnFirstLogin;
|
||||||
|
/**
|
||||||
|
* 是否开启定期修改密码
|
||||||
|
*/
|
||||||
|
private boolean enableRegularlyChangePassword;
|
||||||
|
/**
|
||||||
|
* 定期修改密码天数
|
||||||
|
*/
|
||||||
|
private Integer regularlyChangePassword;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -385,4 +385,218 @@ public class PoiOutPage {
|
||||||
|
|
||||||
return style;
|
return style;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static HSSFWorkbook excelForCheckOut(List<Map<String, Object>> result, List<String> list, String fileName, String projectName, String unit, String code, String leasePerson) {
|
||||||
|
// 创建工作簿和工作表
|
||||||
|
HSSFWorkbook workbook = new HSSFWorkbook();
|
||||||
|
HSSFSheet sheet = workbook.createSheet();
|
||||||
|
sheet.setDefaultColumnWidth(15); // 设置列宽
|
||||||
|
|
||||||
|
// 创建样式
|
||||||
|
HSSFCellStyle titleStyle = createTitleStyle(workbook);
|
||||||
|
HSSFCellStyle headerStyle = createHeaderStyle(workbook);
|
||||||
|
HSSFCellStyle contentStyle = createCellStyleCost(workbook);
|
||||||
|
|
||||||
|
// 设置工作簿名称
|
||||||
|
workbook.setSheetName(0, fileName);
|
||||||
|
|
||||||
|
// 填充标题行
|
||||||
|
int rowNum = 0;
|
||||||
|
rowNum = createTitleRowStyle(sheet, rowNum, fileName, titleStyle, list.size());
|
||||||
|
rowNum = createProjectInfoRowOut(sheet, rowNum, projectName, unit, titleStyle, list.size(), code);
|
||||||
|
|
||||||
|
// 填充表头
|
||||||
|
rowNum = createHeaderRow(sheet, rowNum, list, headerStyle);
|
||||||
|
|
||||||
|
// 填充数据行
|
||||||
|
if (result != null && !result.isEmpty()) {
|
||||||
|
rowNum = createDataRows(sheet, rowNum, result, contentStyle, list.size());
|
||||||
|
} else {
|
||||||
|
// 如果没有数据,则仅显示表头
|
||||||
|
// rowNum++;
|
||||||
|
// rowNum = createDataRows(sheet, rowNum, result, contentStyle, list.size());
|
||||||
|
HSSFRow row = sheet.createRow(rowNum++);
|
||||||
|
HSSFCell cell = row.createCell(0);
|
||||||
|
cell.setCellStyle(headerStyle);
|
||||||
|
cell.setCellValue("暂无数据");
|
||||||
|
sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 0, (short) (list.size() - 1)));
|
||||||
|
CellRangeAddress cellRange = new CellRangeAddress(rowNum - 1, rowNum - 1, 0, (short) (list.size() - 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);
|
||||||
|
}
|
||||||
|
rowNum = createTotalRow(sheet, rowNum, list, leasePerson, headerStyle);
|
||||||
|
return workbook;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int createTotalRow(HSSFSheet sheet, int rowNum, List<String> list, String leasePerson, HSSFCellStyle headerStyle) {
|
||||||
|
|
||||||
|
/*HSSFRow row = sheet.createRow(rowNum++);
|
||||||
|
HSSFCell cell = row.createCell(0);
|
||||||
|
cell.setCellStyle(headerStyle);
|
||||||
|
cell.setCellValue(leasePerson + " " + "批注人:" + " " + "审批人:");
|
||||||
|
|
||||||
|
sheet.addMergedRegion(new CellRangeAddress(rowNum-1, rowNum-1, 1, (short) (list.size() - 1)));
|
||||||
|
CellRangeAddress cellRange = new CellRangeAddress(rowNum - 1, rowNum - 1, 1, (short) (list.size() - 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;*/
|
||||||
|
HSSFRow row = sheet.createRow(rowNum++);
|
||||||
|
row.setHeightInPoints(30);
|
||||||
|
sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 0, (short) (list.size() - 1)));
|
||||||
|
HSSFCell cell = row.createCell(0);
|
||||||
|
cell.setCellStyle(headerStyle);
|
||||||
|
cell.setCellValue("领料申请人:" + leasePerson + " 批注人: " + " 审批人: ");
|
||||||
|
|
||||||
|
// 添加边框
|
||||||
|
CellRangeAddress cellRange = new CellRangeAddress(rowNum - 1, rowNum - 1, 0, (short) (list.size() - 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 createTitleRowStyle(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);
|
||||||
|
// 添加边框
|
||||||
|
CellRangeAddress cellRange = new CellRangeAddress(rowNum - 1, rowNum - 1, rowNum - 1, (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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建内容样式
|
||||||
|
* @param workbook
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static HSSFCellStyle createCellStyleCost(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);
|
||||||
|
|
||||||
|
// 设置边框
|
||||||
|
style.setBorderTop(BorderStyle.THIN);
|
||||||
|
style.setBorderBottom(BorderStyle.THIN);
|
||||||
|
style.setBorderLeft(BorderStyle.THIN);
|
||||||
|
style.setBorderRight(BorderStyle.THIN);
|
||||||
|
|
||||||
|
// 设置边框颜色为黑色
|
||||||
|
style.setTopBorderColor(IndexedColors.BLACK.getIndex());
|
||||||
|
style.setBottomBorderColor(IndexedColors.BLACK.getIndex());
|
||||||
|
style.setLeftBorderColor(IndexedColors.BLACK.getIndex());
|
||||||
|
style.setRightBorderColor(IndexedColors.BLACK.getIndex());
|
||||||
|
|
||||||
|
|
||||||
|
// 设置数字格式为保留两位小数
|
||||||
|
DataFormat dataFormat = workbook.createDataFormat();
|
||||||
|
style.setDataFormat(dataFormat.getFormat("0.00")); // 设置格式为"0.00"
|
||||||
|
|
||||||
|
return style;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int createProjectInfoRowOut(HSSFSheet sheet, int rowNum, String projectName, String unit, HSSFCellStyle titleStyle, int nColumn, String code) {
|
||||||
|
// 第一行:领料单位
|
||||||
|
HSSFRow row1 = sheet.createRow(rowNum++);
|
||||||
|
row1.setHeightInPoints(30);
|
||||||
|
// bug修复:修改合并单元格区域,确保包含两个或以上单元格
|
||||||
|
sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 0, 1));
|
||||||
|
HSSFCell cell1 = row1.createCell(0);
|
||||||
|
cell1.setCellStyle(titleStyle);
|
||||||
|
cell1.setCellValue("领料单位:");
|
||||||
|
|
||||||
|
sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 2, (short) (nColumn - 1)));
|
||||||
|
HSSFCell cell2 = row1.createCell(2);
|
||||||
|
cell2.setCellStyle(titleStyle);
|
||||||
|
cell2.setCellValue(unit);
|
||||||
|
|
||||||
|
// 第二行:领料工程
|
||||||
|
HSSFRow row2 = sheet.createRow(rowNum++);
|
||||||
|
row2.setHeightInPoints(30);
|
||||||
|
sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 0, 1));
|
||||||
|
HSSFCell cell3 = row2.createCell(0);
|
||||||
|
cell3.setCellStyle(titleStyle);
|
||||||
|
cell3.setCellValue("领料工程:");
|
||||||
|
|
||||||
|
sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 2, (short) (nColumn - 1))); // projectName 占剩余的22
|
||||||
|
HSSFCell cell4 = row2.createCell(2);
|
||||||
|
cell4.setCellStyle(titleStyle);
|
||||||
|
cell4.setCellValue(projectName);
|
||||||
|
|
||||||
|
// 第二行:领料单号
|
||||||
|
HSSFRow row3 = sheet.createRow(rowNum++);
|
||||||
|
row2.setHeightInPoints(30);
|
||||||
|
sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 0, 1));
|
||||||
|
HSSFCell cell5 = row3.createCell(0);
|
||||||
|
cell5.setCellStyle(titleStyle);
|
||||||
|
cell5.setCellValue("领料单号:");
|
||||||
|
|
||||||
|
sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 2, (short) (nColumn - 1))); // projectName 占剩余的22
|
||||||
|
HSSFCell cell6 = row3.createCell(2);
|
||||||
|
cell6.setCellStyle(titleStyle);
|
||||||
|
cell6.setCellValue(code);
|
||||||
|
|
||||||
|
// 添加边框
|
||||||
|
CellRangeAddress cellRange1 = new CellRangeAddress(rowNum - 3, rowNum - 3, 0, 1);
|
||||||
|
CellRangeAddress cellRange2 = new CellRangeAddress(rowNum - 3, rowNum - 3, 2, (short) (nColumn - 1));
|
||||||
|
CellRangeAddress cellRange3 = new CellRangeAddress(rowNum - 2, rowNum - 2, 0, 1);
|
||||||
|
CellRangeAddress cellRange4 = new CellRangeAddress(rowNum - 2, rowNum - 2, 2, (short) (nColumn - 1));
|
||||||
|
CellRangeAddress cellRange5 = new CellRangeAddress(rowNum - 1, rowNum - 1, 0, 1);
|
||||||
|
CellRangeAddress cellRange6 = new CellRangeAddress(rowNum - 1, rowNum - 1, 2, (short) (nColumn - 1));
|
||||||
|
// 设置边框样式
|
||||||
|
RegionUtil.setBorderTop(BorderStyle.THIN, cellRange1, sheet);
|
||||||
|
RegionUtil.setBorderBottom(BorderStyle.THIN, cellRange1, sheet);
|
||||||
|
RegionUtil.setBorderLeft(BorderStyle.THIN, cellRange1, sheet);
|
||||||
|
RegionUtil.setBorderRight(BorderStyle.THIN, cellRange1, sheet);
|
||||||
|
RegionUtil.setBorderTop(BorderStyle.THIN, cellRange2, sheet);
|
||||||
|
RegionUtil.setBorderBottom(BorderStyle.THIN, cellRange2, sheet);
|
||||||
|
RegionUtil.setBorderLeft(BorderStyle.THIN, cellRange2, sheet);
|
||||||
|
RegionUtil.setBorderRight(BorderStyle.THIN, cellRange2, sheet);
|
||||||
|
RegionUtil.setBorderTop(BorderStyle.THIN, cellRange3, sheet);
|
||||||
|
RegionUtil.setBorderBottom(BorderStyle.THIN, cellRange3, sheet);
|
||||||
|
RegionUtil.setBorderLeft(BorderStyle.THIN, cellRange3, sheet);
|
||||||
|
RegionUtil.setBorderRight(BorderStyle.THIN, cellRange3, sheet);
|
||||||
|
RegionUtil.setBorderTop(BorderStyle.THIN, cellRange4, sheet);
|
||||||
|
RegionUtil.setBorderBottom(BorderStyle.THIN, cellRange4, sheet);
|
||||||
|
RegionUtil.setBorderLeft(BorderStyle.THIN, cellRange4, sheet);
|
||||||
|
RegionUtil.setBorderRight(BorderStyle.THIN, cellRange4, sheet);
|
||||||
|
RegionUtil.setBorderTop(BorderStyle.THIN, cellRange5, sheet);
|
||||||
|
RegionUtil.setBorderBottom(BorderStyle.THIN, cellRange5, sheet);
|
||||||
|
RegionUtil.setBorderLeft(BorderStyle.THIN, cellRange5, sheet);
|
||||||
|
RegionUtil.setBorderRight(BorderStyle.THIN, cellRange5, sheet);
|
||||||
|
RegionUtil.setBorderTop(BorderStyle.THIN, cellRange6, sheet);
|
||||||
|
RegionUtil.setBorderBottom(BorderStyle.THIN, cellRange6, sheet);
|
||||||
|
RegionUtil.setBorderLeft(BorderStyle.THIN, cellRange6, sheet);
|
||||||
|
RegionUtil.setBorderRight(BorderStyle.THIN, cellRange6, sheet);
|
||||||
|
|
||||||
|
|
||||||
|
return rowNum;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -138,16 +139,34 @@ public class LeaseOutDetailsController extends BaseController {
|
||||||
/**
|
/**
|
||||||
* 领料出库,出库单查询
|
* 领料出库,出库单查询
|
||||||
*
|
*
|
||||||
* @param parentId
|
* @param bean
|
||||||
*/
|
*/
|
||||||
@Log(title = "出库单查询", businessType = BusinessType.QUERY)
|
@Log(title = "出库单查询", businessType = BusinessType.QUERY)
|
||||||
@GetMapping("/getOutboundOrder")
|
@GetMapping("/getOutboundOrder")
|
||||||
public AjaxResult getOutboundOrder(String parentId) {
|
public AjaxResult getOutboundOrder(LeaseOutDetails bean) {
|
||||||
startPage();
|
startPage();
|
||||||
List<LeaseOutDetails> outboundOrder = leaseOutDetailsService.getOutboundOrder(parentId);
|
List<LeaseOutDetails> outboundOrder = leaseOutDetailsService.getOutboundOrder(bean);
|
||||||
return AjaxResult.success(getDataTable(outboundOrder));
|
return AjaxResult.success(getDataTable(outboundOrder));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Log(title = "出库单车牌号查询", businessType = BusinessType.QUERY)
|
||||||
|
@GetMapping("/getCarCodeList")
|
||||||
|
public AjaxResult getCarCodeList(LeaseOutDetails bean) {
|
||||||
|
List<String> outboundOrder = leaseOutDetailsService.getCarCodeList(bean);
|
||||||
|
return AjaxResult.success(outboundOrder);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 出库单导出
|
||||||
|
* @param bean
|
||||||
|
* @param response
|
||||||
|
*/
|
||||||
|
@Log(title = "出库单导出", businessType = BusinessType.EXPORT)
|
||||||
|
@PostMapping("/exportOutboundOrder")
|
||||||
|
public void exportInfo(LeaseOutDetails bean, HttpServletResponse response) {
|
||||||
|
leaseOutDetailsService.exportInfo(bean, response);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param recordList
|
* @param recordList
|
||||||
* @return
|
* @return
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,7 @@ public interface LeaseOutDetailsMapper {
|
||||||
|
|
||||||
int updateLeaseApplyDetails(@Param("record") LeaseOutDetails record);
|
int updateLeaseApplyDetails(@Param("record") LeaseOutDetails record);
|
||||||
|
|
||||||
List<LeaseOutDetails> getOutboundOrder(String parentId);
|
List<LeaseOutDetails> getOutboundOrder(LeaseOutDetails bean);
|
||||||
|
|
||||||
int getCountOfCodeMachine(@Param("record") LeaseOutDetails record);
|
int getCountOfCodeMachine(@Param("record") LeaseOutDetails record);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import com.bonus.sgzb.base.api.domain.LeaseOutDetails;
|
||||||
import com.bonus.sgzb.base.api.domain.MaMachine;
|
import com.bonus.sgzb.base.api.domain.MaMachine;
|
||||||
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
|
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -40,7 +41,7 @@ public interface LeaseOutDetailsService {
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
AjaxResult submitOut(LeaseOutDetails record);
|
AjaxResult submitOut(LeaseOutDetails record);
|
||||||
List<LeaseOutDetails> getOutboundOrder(String parentId);
|
List<LeaseOutDetails> getOutboundOrder(LeaseOutDetails bean);
|
||||||
/**
|
/**
|
||||||
* 根据code编码查询设备信息
|
* 根据code编码查询设备信息
|
||||||
* @param maCode 机具编码
|
* @param maCode 机具编码
|
||||||
|
|
@ -78,4 +79,18 @@ public interface LeaseOutDetailsService {
|
||||||
AjaxResult submitOutRfid(List<LeaseOutDetails> recordList);
|
AjaxResult submitOutRfid(List<LeaseOutDetails> recordList);
|
||||||
|
|
||||||
List<TmTask> getDetailsByApplyId(TmTask id);
|
List<TmTask> getDetailsByApplyId(TmTask id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据carCode查询设备信息
|
||||||
|
* @param bean
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<String> getCarCodeList(LeaseOutDetails bean);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 出库单导出
|
||||||
|
* @param bean
|
||||||
|
* @param response
|
||||||
|
*/
|
||||||
|
void exportInfo(LeaseOutDetails bean, HttpServletResponse response);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.bonus.sgzb.app.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import com.bonus.sgzb.app.domain.LeaseApplyDetails;
|
import com.bonus.sgzb.app.domain.LeaseApplyDetails;
|
||||||
|
import com.bonus.sgzb.app.mapper.TmTaskMapper;
|
||||||
import com.bonus.sgzb.base.api.domain.MachinePart;
|
import com.bonus.sgzb.base.api.domain.MachinePart;
|
||||||
import com.bonus.sgzb.app.domain.TmTask;
|
import com.bonus.sgzb.app.domain.TmTask;
|
||||||
import com.bonus.sgzb.app.mapper.LeaseApplyDetailsMapper;
|
import com.bonus.sgzb.app.mapper.LeaseApplyDetailsMapper;
|
||||||
|
|
@ -11,18 +12,23 @@ import com.bonus.sgzb.base.api.domain.*;
|
||||||
import com.bonus.sgzb.base.mapper.MaLabelBindMapper;
|
import com.bonus.sgzb.base.mapper.MaLabelBindMapper;
|
||||||
import com.bonus.sgzb.base.mapper.MaMachineMapper;
|
import com.bonus.sgzb.base.mapper.MaMachineMapper;
|
||||||
import com.bonus.sgzb.base.vo.MaLabelBindVO;
|
import com.bonus.sgzb.base.vo.MaLabelBindVO;
|
||||||
|
import com.bonus.sgzb.common.core.utils.DateUtils;
|
||||||
import com.bonus.sgzb.common.core.utils.StringUtils;
|
import com.bonus.sgzb.common.core.utils.StringUtils;
|
||||||
|
import com.bonus.sgzb.common.core.utils.poi.PoiOutPage;
|
||||||
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
|
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
|
||||||
import com.bonus.sgzb.common.security.utils.SecurityUtils;
|
import com.bonus.sgzb.common.security.utils.SecurityUtils;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.OutputStream;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.Date;
|
import java.net.URLEncoder;
|
||||||
import java.util.List;
|
import java.util.*;
|
||||||
import java.util.Objects;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description: 领料出库详情接口实现类
|
* Description: 领料出库详情接口实现类
|
||||||
|
|
@ -45,6 +51,9 @@ public class LeaseOutDetailsServiceImpl implements LeaseOutDetailsService {
|
||||||
@Resource
|
@Resource
|
||||||
private MaLabelBindMapper maLabelBindMapper;
|
private MaLabelBindMapper maLabelBindMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private TmTaskMapper tmTaskMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据任务id查询出库数据
|
* 根据任务id查询出库数据
|
||||||
*
|
*
|
||||||
|
|
@ -141,6 +150,144 @@ public class LeaseOutDetailsServiceImpl implements LeaseOutDetailsService {
|
||||||
return leaseApplyDetailsMapper.getDetailsByApplyId(typeId);
|
return leaseApplyDetailsMapper.getDetailsByApplyId(typeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getCarCodeList(LeaseOutDetails bean) {
|
||||||
|
List<String> list = new ArrayList<>();
|
||||||
|
List<LeaseOutDetails> outboundOrder = leaseOutDetailsMapper.getOutboundOrder(bean);
|
||||||
|
if (CollUtil.isNotEmpty(outboundOrder)) {
|
||||||
|
// 过滤出outboundOrder集合中carCode不为空的数据
|
||||||
|
List<LeaseOutDetails> carCodeList = outboundOrder.stream().filter(item -> StringUtils.isNotBlank(item.getCarCode())).collect(Collectors.toList());
|
||||||
|
if (CollUtil.isNotEmpty(carCodeList)) {
|
||||||
|
for (LeaseOutDetails leaseOutDetails : carCodeList) {
|
||||||
|
// list中不能包含相同的车牌号
|
||||||
|
if (!list.contains(leaseOutDetails.getCarCode())) {
|
||||||
|
list.add(leaseOutDetails.getCarCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 出库单导出
|
||||||
|
* @param bean
|
||||||
|
* @param response
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void exportInfo(LeaseOutDetails bean, HttpServletResponse response) {
|
||||||
|
if (bean == null || bean.getParentId() == null) {
|
||||||
|
throw new RuntimeException("参数不能为空");
|
||||||
|
}
|
||||||
|
TmTask tmTask = new TmTask();
|
||||||
|
tmTask.setId(String.valueOf(bean.getParentId()));
|
||||||
|
List<TmTask> taskList = tmTaskMapper.getLeaseOutListByAdmin(tmTask);
|
||||||
|
List<LeaseOutDetails> list = leaseOutDetailsMapper.getOutboundOrder(bean);
|
||||||
|
//将list集合中的createTime转换为字符串
|
||||||
|
list.forEach(item -> {
|
||||||
|
item.setOutTime(DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", item.getCreateTime()));
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
String fileName = "领料出库单";
|
||||||
|
String projectName = "";
|
||||||
|
String unitName = "";
|
||||||
|
String code = "";
|
||||||
|
String leasePerson = "";
|
||||||
|
if (CollUtil.isNotEmpty(taskList)) {
|
||||||
|
unitName = taskList.get(0).getUnitName();
|
||||||
|
code = taskList.get(0).getCode();
|
||||||
|
projectName = taskList.get(0).getProName();
|
||||||
|
leasePerson = taskList.get(0).getApplyFor();
|
||||||
|
}
|
||||||
|
expOutExcel(response, list, fileName, projectName, unitName, code, leasePerson);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.toString(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 出库单导出
|
||||||
|
* @param response
|
||||||
|
* @param list
|
||||||
|
* @param fileName
|
||||||
|
* @param projectName
|
||||||
|
* @param unitName
|
||||||
|
* @param code
|
||||||
|
*/
|
||||||
|
private void expOutExcel(HttpServletResponse response, List<LeaseOutDetails> list, String fileName, String projectName, String unitName, String code, String leasePerson)
|
||||||
|
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++) {
|
||||||
|
LeaseOutDetails bean = list.get(i);
|
||||||
|
Map<String, Object> maps = outReceiveDetailsBeanToMap(bean);
|
||||||
|
results.add(maps);
|
||||||
|
}
|
||||||
|
List<String> headers = receiveDetailsHeader();
|
||||||
|
HSSFWorkbook workbook = PoiOutPage.excelForCheckOut(results, headers, fileName,projectName,unitName, code, leasePerson);
|
||||||
|
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(LeaseOutDetails bean) {
|
||||||
|
Map<String, Object> maps = new LinkedHashMap<String, Object>();
|
||||||
|
maps.put("typeName", bean.getTypeName());
|
||||||
|
maps.put("typeModelName", bean.getTypeModelName());
|
||||||
|
maps.put("maCode", bean.getMaCode());
|
||||||
|
maps.put("preNum", bean.getPreNum());
|
||||||
|
maps.put("outNum", bean.getOutNum());
|
||||||
|
maps.put("leasePerson", bean.getLeasePerson());
|
||||||
|
maps.put("outPerson", bean.getOutPerson());
|
||||||
|
maps.put("createTime", bean.getOutTime());
|
||||||
|
maps.put("carCode", bean.getCarCode());
|
||||||
|
return maps;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 出库单导出头
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private List<String> receiveDetailsHeader() {
|
||||||
|
List<String> list = new ArrayList<String>();
|
||||||
|
list.add("设备类型");
|
||||||
|
list.add("规格型号");
|
||||||
|
list.add("设备编码");
|
||||||
|
list.add("申请数量");
|
||||||
|
list.add("出库数量");
|
||||||
|
list.add("领料人");
|
||||||
|
list.add("出库人");
|
||||||
|
list.add("出库日期");
|
||||||
|
list.add("车牌号");
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 领料出库处理
|
* 领料出库处理
|
||||||
*
|
*
|
||||||
|
|
@ -201,8 +348,8 @@ public class LeaseOutDetailsServiceImpl implements LeaseOutDetailsService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<LeaseOutDetails> getOutboundOrder(String parentId) {
|
public List<LeaseOutDetails> getOutboundOrder(LeaseOutDetails bean) {
|
||||||
return leaseOutDetailsMapper.getOutboundOrder(parentId);
|
return leaseOutDetailsMapper.getOutboundOrder(bean);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int insertRecords(LeaseOutDetails record) {
|
private int insertRecords(LeaseOutDetails record) {
|
||||||
|
|
|
||||||
|
|
@ -475,6 +475,9 @@
|
||||||
LEFT JOIN ma_type mt2 ON mt.parent_id = mt2.type_id
|
LEFT JOIN ma_type mt2 ON mt.parent_id = mt2.type_id
|
||||||
WHERE
|
WHERE
|
||||||
lod.parent_id = #{parentId}
|
lod.parent_id = #{parentId}
|
||||||
|
<if test="carCode != null and carCode != ''">
|
||||||
|
and lod.car_code like concat('%', #{carCode}, '%')
|
||||||
|
</if>
|
||||||
</select>
|
</select>
|
||||||
<select id="getCountOfCodeMachine" resultType="java.lang.Integer">
|
<select id="getCountOfCodeMachine" resultType="java.lang.Integer">
|
||||||
select count(mm.ma_id)
|
select count(mm.ma_id)
|
||||||
|
|
|
||||||
|
|
@ -1395,6 +1395,9 @@
|
||||||
<if test="taskStatus != null">
|
<if test="taskStatus != null">
|
||||||
and tt.task_status = #{taskStatus}
|
and tt.task_status = #{taskStatus}
|
||||||
</if>
|
</if>
|
||||||
|
<if test="id != null and id != ''">
|
||||||
|
and lai.id = #{id}
|
||||||
|
</if>
|
||||||
GROUP BY lai.id
|
GROUP BY lai.id
|
||||||
ORDER BY tt.task_status,tt.create_time desc
|
ORDER BY tt.task_status,tt.create_time desc
|
||||||
</select>
|
</select>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue