需求修改及优化

This commit is contained in:
mashuai 2025-04-23 16:14:25 +08:00
parent a62e18a086
commit eb6eb41dae
13 changed files with 747 additions and 178 deletions

View File

@ -0,0 +1,340 @@
package com.bonus.sgzb.common.core.utils.http;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.util.Map;
import java.util.StringJoiner;
/**
* @Author ma_sh
* @create 2025/4/22 16:30
*/
public class HttpRequestHelper {
// 连接超时设置5秒
private static final int CONNECT_TIMEOUT = 5000;
// 读取超时设置5秒
private static final int READ_TIMEOUT = 5000;
/**
* 发送HTTP请求的通用方法
*
* @param baseUrl 基URL
* @param endpoint 请求的端点
* @param method 请求方法 (GET, POST, PUT, DELETE, PATCH)
* @param body 请求体适用于POSTPUTPATCH
* @param headers 请求头
* @return String 响应内容
*/
private static String sendRequest(String baseUrl, String endpoint, String method, String body, Map<String, String> headers) {
HttpURLConnection connection = null;
try {
// 创建URL对象并打开连接
URL url = new URL(baseUrl + endpoint);
connection = (HttpURLConnection) url.openConnection();
// 设置请求方法
connection.setRequestMethod(method);
// 设置连接超时和读取超时时间
connection.setConnectTimeout(CONNECT_TIMEOUT);
connection.setReadTimeout(READ_TIMEOUT);
// 设置请求头
if (headers != null) {
for (Map.Entry<String, String> entry : headers.entrySet()) {
connection.setRequestProperty(entry.getKey(), entry.getValue());
}
}
// 如果请求体不为空且方法是POSTPUT或PATCH则写入请求体
if (body != null && !body.isEmpty() && (method.equals("POST") || method.equals("PUT") || method.equals("PATCH"))) {
connection.setDoOutput(true);
try (OutputStream os = connection.getOutputStream()) {
os.write(body.getBytes());
os.flush();
}
}
// 连接服务器并检查响应代码
int responseCode = connection.getResponseCode();
if (responseCode != HttpURLConnection.HTTP_OK) {
throw new RuntimeException("Request failed with response code: " + responseCode);
}
// 获取输入流并读取响应内容
StringBuilder response = new StringBuilder();
try (BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()))) {
String inputLine;
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
}
return response.toString();
} catch (Exception e) {
e.printStackTrace();
return null;
} finally {
if (connection != null) {
connection.disconnect();
}
}
}
/**
* 将表单数据转换为application/x-www-form-urlencoded格式的方法
*
* @param formData 表单数据
* @return String 表单数据的URL编码格式
*/
private static String getFormBody(Map<String, String> formData) {
try {
StringJoiner sj = new StringJoiner("&");
for (Map.Entry<String, String> entry : formData.entrySet()) {
sj.add(URLEncoder.encode(entry.getKey(), "UTF-8") + "=" + URLEncoder.encode(entry.getValue(), "UTF-8"));
}
return sj.toString();
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
/**
* 发送GET请求
*
* @param baseUrl 基URL
* @param endpoint 请求的端点
* @param headers 请求头
* @return String 响应内容
*/
public static String get(String baseUrl, String endpoint, Map<String, String> headers) {
return sendRequest(baseUrl, endpoint, "GET", null, headers);
}
/**
* 发送POST请求
*
* @param baseUrl 基URL
* @param endpoint 请求的端点
* @param body 请求体
* @param headers 请求头
* @return String 响应内容
*/
public static String post(String baseUrl, String endpoint, String body, Map<String, String> headers) {
return sendRequest(baseUrl, endpoint, "POST", body, headers);
}
/**
* 发送POST表单请求
*
* @param baseUrl 基URL
* @param endpoint 请求的端点
* @param formData 表单数据
* @param headers 请求头
* @return String 响应内容
*/
public static String postForm(String baseUrl, String endpoint, Map<String, String> formData, Map<String, String> headers) {
headers.put("Content-Type", "application/x-www-form-urlencoded");
String formBody = getFormBody(formData);
return sendRequest(baseUrl, endpoint, "POST", formBody, headers);
}
/**
* 发送POST JSON请求
*
* @param baseUrl 基URL
* @param endpoint 请求的端点
* @param jsonBody JSON格式的请求体
* @param headers 请求头
* @return String 响应内容
*/
public static String postJson(String baseUrl, String endpoint, String jsonBody, Map<String, String> headers) {
headers.put("Content-Type", "application/json");
return sendRequest(baseUrl, endpoint, "POST", jsonBody, headers);
}
/**
* 发送POST XML请求
*
* @param baseUrl 基URL
* @param endpoint 请求的端点
* @param xmlBody XML格式的请求体
* @param headers 请求头
* @return String 响应内容
*/
public static String postXml(String baseUrl, String endpoint, String xmlBody, Map<String, String> headers) {
headers.put("Content-Type", "application/xml");
return sendRequest(baseUrl, endpoint, "POST", xmlBody, headers);
}
/**
* 发送POST原始数据请求
*
* @param baseUrl 基URL
* @param endpoint 请求的端点
* @param rawBody 原始请求体
* @param headers 请求头
* @return String 响应内容
*/
public static String postRaw(String baseUrl, String endpoint, String rawBody, Map<String, String> headers) {
return sendRequest(baseUrl, endpoint, "POST", rawBody, headers);
}
/**
* 发送PUT请求
*
* @param baseUrl 基URL
* @param endpoint 请求的端点
* @param body 请求体
* @param headers 请求头
* @return String 响应内容
*/
public static String put(String baseUrl, String endpoint, String body, Map<String, String> headers) {
return sendRequest(baseUrl, endpoint, "PUT", body, headers);
}
/**
* 发送PUT表单请求
*
* @param baseUrl 基URL
* @param endpoint 请求的端点
* @param formData 表单数据
* @param headers 请求头
* @return String 响应内容
*/
public static String putForm(String baseUrl, String endpoint, Map<String, String> formData, Map<String, String> headers) {
headers.put("Content-Type", "application/x-www-form-urlencoded");
String formBody = getFormBody(formData);
return sendRequest(baseUrl, endpoint, "PUT", formBody, headers);
}
/**
* 发送PUT JSON请求
*
* @param baseUrl 基URL
* @param endpoint 请求的端点
* @param jsonBody JSON格式的请求体
* @param headers 请求头
* @return String 响应内容
*/
public static String putJson(String baseUrl, String endpoint, String jsonBody, Map<String, String> headers) {
headers.put("Content-Type", "application/json");
return sendRequest(baseUrl, endpoint, "PUT", jsonBody, headers);
}
/**
* 发送PUT XML请求
*
* @param baseUrl 基URL
* @param endpoint 请求的端点
* @param xmlBody XML格式的请求体
* @param headers 请求头
* @return String 响应内容
*/
public static String putXml(String baseUrl, String endpoint, String xmlBody, Map<String, String> headers) {
headers.put("Content-Type", "application/xml");
return sendRequest(baseUrl, endpoint, "PUT", xmlBody, headers);
}
/**
* 发送PUT原始数据请求
*
* @param baseUrl 基URL
* @param endpoint 请求的端点
* @param rawBody 原始请求体
* @param headers 请求头
* @return String 响应内容
*/
public static String putRaw(String baseUrl, String endpoint, String rawBody, Map<String, String> headers) {
return sendRequest(baseUrl, endpoint, "PUT", rawBody, headers);
}
/**
* 发送DELETE请求
*
* @param baseUrl 基URL
* @param endpoint 请求的端点
* @param headers 请求头
* @return String 响应内容
*/
public static String delete(String baseUrl, String endpoint, Map<String, String> headers) {
return sendRequest(baseUrl, endpoint, "DELETE", null, headers);
}
/**
* 发送PATCH请求
*
* @param baseUrl 基URL
* @param endpoint 请求的端点
* @param body 请求体
* @param headers 请求头
* @return String 响应内容
*/
public static String patch(String baseUrl, String endpoint, String body, Map<String, String> headers) {
return sendRequest(baseUrl, endpoint, "PATCH", body, headers);
}
/**
* 发送PATCH表单请求
*
* @param baseUrl 基URL
* @param endpoint 请求的端点
* @param formData 表单数据
* @param headers 请求头
* @return String 响应内容
*/
public static String patchForm(String baseUrl, String endpoint, Map<String, String> formData, Map<String, String> headers) {
headers.put("Content-Type", "application/x-www-form-urlencoded");
String formBody = getFormBody(formData);
return sendRequest(baseUrl, endpoint, "PATCH", formBody, headers);
}
/**
* 发送PATCH JSON请求
*
* @param baseUrl 基URL
* @param endpoint 请求的端点
* @param jsonBody JSON格式的请求体
* @param headers 请求头
* @return String 响应内容
*/
public static String patchJson(String baseUrl, String endpoint, String jsonBody, Map<String, String> headers) {
headers.put("Content-Type", "application/json");
return sendRequest(baseUrl, endpoint, "PATCH", jsonBody, headers);
}
/**
* 发送PATCH XML请求
*
* @param baseUrl 基URL
* @param endpoint 请求的端点
* @param xmlBody XML格式的请求体
* @param headers 请求头
* @return String 响应内容
*/
public static String patchXml(String baseUrl, String endpoint, String xmlBody, Map<String, String> headers) {
headers.put("Content-Type", "application/xml");
return sendRequest(baseUrl, endpoint, "PATCH", xmlBody, headers);
}
/**
* 发送PATCH原始数据请求
*
* @param baseUrl 基URL
* @param endpoint 请求的端点
* @param rawBody 原始请求体
* @param headers 请求头
* @return String 响应内容
*/
public static String patchRaw(String baseUrl, String endpoint, String rawBody, Map<String, String> headers) {
return sendRequest(baseUrl, endpoint, "PATCH", rawBody, headers);
}
}

View File

@ -844,6 +844,125 @@ public class PoiOutPage {
RegionUtil.setBorderRight(BorderStyle.THIN, cellRange8, sheet);
return rowNum;
}
/**
* 创建入库单
* @param result
* @param list
* @param fileName
* @return
*/
public static HSSFWorkbook excelForCheckInput(List<Map<String, Object>> result, List<String> list, String fileName) {
// 创建工作簿和工作表
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet();
sheet.setDefaultColumnWidth(16); // 设置列宽
// 创建样式
HSSFCellStyle titleStyle = createTitleStyle(workbook);
HSSFCellStyle headerStyle = createHeaderStyle(workbook);
HSSFCellStyle contentStyle = createCellStyleCost(workbook);
// 设置工作簿名称
workbook.setSheetName(0, fileName);
// 填充标题行
int rowNum = 0;
rowNum = createTitleRow(sheet, rowNum, fileName, titleStyle, list.size());
rowNum = createProjectInfoRowInput(sheet, rowNum, titleStyle, list.size());
// 填充表头
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 = createTotalRowInput(sheet, rowNum, list, headerStyle);
return workbook;
}
/**
* 创建入库单
* @param sheet
* @param rowNum
* @param list
* @param headerStyle
* @return
*/
private static int createTotalRowInput(HSSFSheet sheet, int rowNum, List<String> list, HSSFCellStyle headerStyle) {
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("审核: " + " 库管员: " + " 经办人: ");
// 添加边框
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;
}
/**
* 创建入库单
* @param sheet
* @param rowNum
* @param titleStyle
* @param nColumn
* @return
*/
private static int createProjectInfoRowInput(HSSFSheet sheet, int rowNum, HSSFCellStyle titleStyle, int nColumn) {
// 第一行领料单位
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);*/
/*// 添加边框
CellRangeAddress cellRange1 = new CellRangeAddress(rowNum - 3, rowNum - 3, 0, 1);
CellRangeAddress cellRange2 = new CellRangeAddress(rowNum - 3, rowNum - 3, 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);*/
return rowNum;
}
}

View File

@ -0,0 +1,16 @@
package com.bonus.sgzb.common.core.utils.sms;
public class SmsConfig {
public static final String DOMAIN = "http://api.ktsms.cn/";
public static final String DDT_KEY = "bonusyn";
public static final String SECRET_KEY = "IU0ypHbH";
public static final String SMS_SIGNATURE = "【博诺思】";
public static final String SMS_TOKEN = "sms_token";
}

View File

@ -0,0 +1,53 @@
package com.bonus.sgzb.common.core.utils.sms;
import com.alibaba.fastjson2.JSON;
import com.bonus.sgzb.common.core.utils.http.HttpRequestHelper;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;
/**
* @Author ma_sh
* @create 2025/4/22 16:27
*/
public class SmsUtils {
/**
* 发送短信验证码
*
* @param mobile 发信发送的目的号码.多个号码之间用半角逗号隔开
* @param content 短信的内容内容需要UTF-8编码
* @param sendTime 为空表示立即发送定时发送格式20101024090810
* @return 是否发送成功
*/
public static String smsToken(String mobile, String content, String sendTime) {
Map<String, String> headers = new HashMap<>();
Map<String, Object> mapJson = new HashMap<>(6);
mapJson.put("ddtkey", SmsConfig.DDT_KEY);
mapJson.put("secretkey", SmsConfig.SECRET_KEY);
mapJson.put("mobile", mobile);
mapJson.put("content", SmsConfig.SMS_SIGNATURE + content);
mapJson.put("sendTime", sendTime);
mapJson.put("extno", "");
// 将mapJson转换为URL查询参数格式
StringBuilder urlBuilder = new StringBuilder(SmsConfig.SMS_TOKEN + "?");
for (Map.Entry<String, Object> entry : mapJson.entrySet()) {
try {
String encodedKey = URLEncoder.encode(entry.getKey(), "UTF-8");
String encodedValue = URLEncoder.encode(entry.getValue().toString(), "UTF-8");
urlBuilder.append(encodedKey).append("=").append(encodedValue).append("&");
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
// 移除最后一个&符号
urlBuilder.setLength(urlBuilder.length() - 1);
String urlWithParams = urlBuilder.toString();
String json = JSON.toJSONString(mapJson);
return HttpRequestHelper.postJson(SmsConfig.DOMAIN, urlWithParams, json, headers);
}
}

View File

@ -434,11 +434,9 @@ public class TmTaskController extends BaseController {
leaseAuditList = tmTaskService.getLeaseAuditManageList(task);
return AjaxResult.success(leaseAuditList);
}
// startPage();
startPage();
leaseAuditList = tmTaskService.getLeaseAuditManageList(task);
Integer pageIndex = Convert.toInt(ServletUtils.getParameter(PAGE_NUM), 1);
Integer pageSize = Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10);
return AjaxResult.success(ListPagingUtil.paging(pageIndex, pageSize, leaseAuditList));
return AjaxResult.success(getDataTable(leaseAuditList));
}
/**

View File

@ -893,157 +893,87 @@ public class TmTaskServiceImpl implements TmTaskService {
List<TmTask> tmTaskList = tmTaskMapper.getAuditManageListByLeaseTmTask(record);
for (TmTask tmTask : tmTaskList) {
int count = 0;
if (tmTask != null) {
// 去查询任务分单表
List<LeaseApplyInfo> collect = tmTaskMapper.getAuditManageListByLeaseInfo(tmTask);
if (collect.size() > 0) {
int deptId1 = tmTaskMapper.getDeptId(collect.get(0).getCreateBy());
if (roles.contains("admin") || deptId == 100) {
// 对领料任务集合查询具体详情
for (LeaseApplyInfo leaseApplyInfo : collect) {
if (leaseApplyInfo != null) {
// 去查询领料任务详情表
List<LeaseApplyDetails> leaseApplyDetails = tmTaskMapper.getLeaseApplyManageDetails(leaseApplyInfo);
if (leaseApplyDetails.size() > 0) {
for (LeaseApplyDetails leaseApplyDetail : leaseApplyDetails) {
if (leaseApplyDetail != null && leaseApplyDetail.getPreNum() != null) {
// 统计预领数量
count += leaseApplyDetail.getPreNum();
}
}
// 塞入领料任务详情的集合中
leaseApplyInfo.setLeaseApplyDetails(leaseApplyDetails);
// 存入领料任务实体集合
tmTask.setLeaseApplyInfoList(collect);
tmTask.setDeptId(Long.parseLong(String.valueOf(deptId1)));
tmTask.setRemark(collect.get(0).getRemark());
}
}
}
} else if (deptId == 101) { //机具经理书记副经理查看数据
List<LeaseApplyInfo> auditListByLeaseInfo = collect.stream().filter(t -> t.getCompanyId() != null).filter(t -> t.getCompanyId() == 101).collect(Collectors.toList());
if (deptId1 == 101) {
List<LeaseApplyInfo> applyInfoList = collect.stream().filter(t -> t.getCompanyId() != null).filter(t -> t.getCompanyId() == 102).collect(Collectors.toList());
auditListByLeaseInfo.addAll(applyInfoList);
}
if (auditListByLeaseInfo != null && !auditListByLeaseInfo.isEmpty()) {
// 对领料任务集合查询具体详情
for (LeaseApplyInfo leaseApplyInfo : auditListByLeaseInfo) {
if (leaseApplyInfo != null) {
// 去查询领料任务详情表
List<LeaseApplyDetails> leaseApplyDetails = tmTaskMapper.getLeaseApplyManageDetails(leaseApplyInfo);
if (leaseApplyDetails.size() > 0) {
for (LeaseApplyDetails leaseApplyDetail : leaseApplyDetails) {
if (leaseApplyDetail != null && leaseApplyDetail.getPreNum() != null) {
// 统计预领数量
count += leaseApplyDetail.getPreNum();
}
}
// 塞入领料任务详情的集合中
leaseApplyInfo.setLeaseApplyDetails(leaseApplyDetails);
// 存入领料任务实体集合
tmTask.setLeaseApplyInfoList(auditListByLeaseInfo);
tmTask.setDeptId(Long.parseLong(String.valueOf(deptId1)));
tmTask.setRemark(collect.get(0).getRemark());
}
}
}
}
} else if (deptId == 102) { // 调试公司可以看到的数据权限
List<LeaseApplyInfo> auditListByLeaseInfo = collect.stream().filter(t -> t.getCompanyId() != null).filter(t -> t.getCompanyId() == 102).collect(Collectors.toList());
if (deptId1 == 102) {
List<LeaseApplyInfo> list2 = collect.stream().filter(t -> t.getCompanyId() != null).filter(t -> t.getCompanyId() == 101).collect(Collectors.toList());
auditListByLeaseInfo.addAll(list2);
}
if (auditListByLeaseInfo != null && !auditListByLeaseInfo.isEmpty()) {
// 对领料任务集合查询具体详情
for (LeaseApplyInfo leaseApplyInfo : auditListByLeaseInfo) {
if (leaseApplyInfo != null) {
// 去查询领料任务详情表
List<LeaseApplyDetails> leaseApplyDetails = tmTaskMapper.getLeaseApplyManageDetails(leaseApplyInfo);
if (leaseApplyDetails.size() > 0) {
for (LeaseApplyDetails leaseApplyDetail : leaseApplyDetails) {
if (leaseApplyDetail != null && leaseApplyDetail.getPreNum() != null) {
// 统计预领数量
count += leaseApplyDetail.getPreNum();
}
}
// 塞入领料任务详情的集合中
leaseApplyInfo.setLeaseApplyDetails(leaseApplyDetails);
// 存入领料任务实体集合
tmTask.setLeaseApplyInfoList(auditListByLeaseInfo);
tmTask.setDeptId(Long.parseLong(String.valueOf(deptId1)));
tmTask.setRemark(collect.get(0).getRemark());
}
}
}
}
} else if (deptId == deptId1) { //其他各分公司可以看到的自己部门的数据
// 对领料任务集合查询具体详情
for (LeaseApplyInfo leaseApplyInfo : collect) {
if (leaseApplyInfo != null) {
// 去查询领料任务详情表
List<LeaseApplyDetails> leaseApplyDetails = tmTaskMapper.getLeaseApplyManageDetails(leaseApplyInfo);
if (leaseApplyDetails.size() > 0) {
for (LeaseApplyDetails leaseApplyDetail : leaseApplyDetails) {
if (leaseApplyDetail != null && leaseApplyDetail.getPreNum() != null) {
// 统计预领数量
count += leaseApplyDetail.getPreNum();
}
}
// 塞入领料任务详情的集合中
leaseApplyInfo.setLeaseApplyDetails(leaseApplyDetails);
// 存入领料任务实体集合
tmTask.setLeaseApplyInfoList(collect);
tmTask.setDeptId(Long.parseLong(String.valueOf(deptId1)));
tmTask.setRemark(collect.get(0).getRemark());
}
}
}
} else if (roles.contains("sgb")) {
// 对领料任务集合查询具体详情
List<LeaseApplyInfo> auditListByLeaseInfo = collect.stream().filter(t -> t.getCompanyId() != null).filter(t -> t.getCompanyId() == 101).collect(Collectors.toList());
if (deptId1 == 210) {
List<LeaseApplyInfo> list1 = collect.stream().filter(t -> t.getCompanyId() != null).filter(t -> t.getCompanyId() == 102).collect(Collectors.toList());
auditListByLeaseInfo.addAll(list1);
}
if (auditListByLeaseInfo != null && !auditListByLeaseInfo.isEmpty()) {
// 对领料任务集合查询具体详情
for (LeaseApplyInfo leaseApplyInfo : auditListByLeaseInfo) {
if (leaseApplyInfo != null) {
// 去查询领料任务详情表
List<LeaseApplyDetails> leaseApplyDetails = tmTaskMapper.getLeaseApplyManageDetails(leaseApplyInfo);
if (leaseApplyDetails.size() > 0) {
for (LeaseApplyDetails leaseApplyDetail : leaseApplyDetails) {
if (leaseApplyDetail != null && leaseApplyDetail.getPreNum() != null) {
// 统计预领数量
count += leaseApplyDetail.getPreNum();
}
}
// 塞入领料任务详情的集合中
leaseApplyInfo.setLeaseApplyDetails(leaseApplyDetails);
// 存入领料任务实体集合
tmTask.setLeaseApplyInfoList(auditListByLeaseInfo);
tmTask.setDeptId(Long.parseLong(String.valueOf(deptId1)));
tmTask.setRemark(collect.get(0).getRemark());
}
}
}
}
}
}
if (tmTask == null) {
continue;
}
tmTask.setPreCountNum(count);
List<LeaseApplyInfo> collect = tmTaskMapper.getAuditManageListByLeaseInfo(tmTask);
if (collect.isEmpty()) {
continue;
}
int deptId1 = tmTaskMapper.getDeptId(collect.get(0).getCreateBy());
List<LeaseApplyInfo> filteredList = filterLeaseApplyInfoList(roles, deptId, deptId1, collect);
processLeaseApplyInfoList(tmTaskMapper, tmTask, filteredList, deptId1, collect.get(0).getRemark());
}
List<TmTask> tmTasks = tmTaskList.stream().filter(t -> t.getLeaseApplyInfoList() != null).collect(Collectors.toList());
return tmTasks;
return tmTaskList;
}
private static List<LeaseApplyInfo> filterLeaseApplyInfoList(Set<String> roles, Long deptId, int deptId1, List<LeaseApplyInfo> collect) {
if (roles.contains("admin") || deptId == 100) {
return collect;
} else if (deptId == 101) {
List<LeaseApplyInfo> auditListByLeaseInfo = collect.stream()
.filter(t -> t.getCompanyId() != null && t.getCompanyId() == 101)
.collect(Collectors.toList());
if (deptId1 == 101) {
auditListByLeaseInfo.addAll(collect.stream()
.filter(t -> t.getCompanyId() != null && t.getCompanyId() == 102)
.collect(Collectors.toList()));
}
return auditListByLeaseInfo;
} else if (deptId == 102) {
List<LeaseApplyInfo> auditListByLeaseInfo = collect.stream()
.filter(t -> t.getCompanyId() != null && t.getCompanyId() == 102)
.collect(Collectors.toList());
if (deptId1 == 102) {
auditListByLeaseInfo.addAll(collect.stream()
.filter(t -> t.getCompanyId() != null && t.getCompanyId() == 101)
.collect(Collectors.toList()));
}
return auditListByLeaseInfo;
} else if (deptId == deptId1) {
return collect;
} else if (roles.contains("sgb")) {
List<LeaseApplyInfo> auditListByLeaseInfo = collect.stream()
.filter(t -> t.getCompanyId() != null && t.getCompanyId() == 101)
.collect(Collectors.toList());
if (deptId1 == 210) {
auditListByLeaseInfo.addAll(collect.stream()
.filter(t -> t.getCompanyId() != null && t.getCompanyId() == 102)
.collect(Collectors.toList()));
}
return auditListByLeaseInfo;
}
return new ArrayList<>();
}
private static void processLeaseApplyInfoList(TmTaskMapper tmTaskMapper, TmTask tmTask, List<LeaseApplyInfo> leaseApplyInfoList, int deptId1, String remark) {
if (leaseApplyInfoList.isEmpty()) {
return;
}
int count = 0;
for (LeaseApplyInfo leaseApplyInfo : leaseApplyInfoList) {
if (leaseApplyInfo == null) {
continue;
}
List<LeaseApplyDetails> leaseApplyDetails = tmTaskMapper.getLeaseApplyManageDetails(leaseApplyInfo);
if (!leaseApplyDetails.isEmpty()) {
for (LeaseApplyDetails leaseApplyDetail : leaseApplyDetails) {
if (leaseApplyDetail != null && leaseApplyDetail.getPreNum() != null) {
count += leaseApplyDetail.getPreNum();
}
}
leaseApplyInfo.setLeaseApplyDetails(leaseApplyDetails);
}
}
tmTask.setLeaseApplyInfoList(leaseApplyInfoList);
tmTask.setDeptId((long) deptId1);
tmTask.setRemark(remark);
tmTask.setPreCountNum(count);
}
/**
* 获取审核列表 - App端
*/

View File

@ -496,14 +496,14 @@
bai.agreement_code as agreementCode,
tt.create_time as createTimes, tt.update_time as updateTimes
FROM
tm_task tt
lease_apply_info lai
LEFT JOIN tm_task tt ON lai.task_id = tt.task_id
LEFT JOIN sys_user su ON tt.create_by = su.user_id
LEFT JOIN sys_dept sd ON su.dept_id = sd.dept_id
LEFT JOIN tm_task_agreement tta ON tt.task_id = tta.task_id
LEFT JOIN bm_agreement_info bai ON bai.agreement_id = tta.agreement_id
LEFT JOIN bm_project_lot bpl ON bpl.lot_id = bai.project_id
LEFT JOIN bm_unit_info bui ON bui.unit_id = bai.unit_id
LEFT JOIN lease_apply_info lai ON lai.task_id = tt.task_id
LEFT JOIN sys_dic d ON d.id = tt.task_status
WHERE
tt.task_type = '29' and tt.status = '1'
@ -561,14 +561,14 @@
bai.agreement_code as agreementCode,
tt.create_time as createTimes, tt.update_time as updateTimes
FROM
tm_task tt
lease_apply_info lai
LEFT JOIN tm_task tt ON lai.task_id = tt.task_id
LEFT JOIN sys_user su ON tt.create_by = su.user_id
LEFT JOIN sys_dept sd ON su.dept_id = sd.dept_id
LEFT JOIN tm_task_agreement tta ON tt.task_id = tta.task_id
LEFT JOIN bm_agreement_info bai ON bai.agreement_id = tta.agreement_id
LEFT JOIN bm_project_lot bpl ON bpl.lot_id = bai.project_id
LEFT JOIN bm_unit_info bui ON bui.unit_id = bai.unit_id
LEFT JOIN lease_apply_info lai ON lai.task_id = tt.task_id
LEFT JOIN sys_dic d ON d.id = tt.task_status
WHERE
tt.task_type = '29' and tt.status = '1'
@ -993,14 +993,14 @@
bai.agreement_code as agreementCode,
tt.create_time as createTimes, tt.update_time as updateTimes
FROM
tm_task tt
lease_apply_info lai
LEFT JOIN tm_task tt ON lai.task_id = tt.task_id
LEFT JOIN sys_user su ON tt.create_by = su.user_id
LEFT JOIN sys_dept sd ON su.dept_id = sd.dept_id
LEFT JOIN tm_task_agreement tta ON tt.task_id = tta.task_id
LEFT JOIN bm_agreement_info bai ON bai.agreement_id = tta.agreement_id
LEFT JOIN bm_project_lot bpl ON bpl.lot_id = bai.project_id
LEFT JOIN bm_unit_info bui ON bui.unit_id = bai.unit_id
LEFT JOIN lease_apply_info lai ON lai.task_id = tt.task_id
LEFT JOIN sys_dic d ON d.id = tt.task_status
WHERE
tt.task_type = '29' and tt.status = '1'

View File

@ -19,7 +19,6 @@ import org.springframework.web.bind.annotation.*;
import com.bonus.sgzb.common.core.web.controller.BaseController;
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import com.bonus.sgzb.common.core.utils.poi.ExcelUtil;
import com.bonus.sgzb.common.core.web.page.TableDataInfo;
import static com.bonus.sgzb.common.core.web.page.TableSupport.PAGE_NUM;
import static com.bonus.sgzb.common.core.web.page.TableSupport.PAGE_SIZE;
@ -103,6 +102,18 @@ public class PurchaseMacodeInfoController extends BaseController {
return success(purchaseMacodeInfoService.warehousingEntry(purchaseMacodeInfo));
}
/**
* 新购入库单导出
* @param purchaseMacodeInfo
* @param response
*/
@Log(title = "新购入库单导出", businessType = BusinessType.EXPORT)
@PostMapping("/exportWareHousingEntry")
public void exportInfo(PurchaseMacodeInfo purchaseMacodeInfo, HttpServletResponse response) {
List<PurchaseMacodeInfo> details = purchaseMacodeInfoService.warehousingEntry(purchaseMacodeInfo);
purchaseMacodeInfoService.exportWareHousingEntry(details, response);
}
/**
* 新增新购验收编号管理
*/

View File

@ -5,6 +5,7 @@ import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import com.bonus.sgzb.material.domain.PurchaseMacodeInfo;
import com.bonus.sgzb.base.api.domain.MaInputVO;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
@ -111,4 +112,11 @@ public interface IPurchaseMacodeInfoService
* @return List<PurchaseMacodeInfo>
*/
List<PurchaseMacodeInfo> warehousingEntry(PurchaseMacodeInfo purchaseMacodeInfo);
/**
* 新购入库单导出
* @param details
* @param response
*/
void exportWareHousingEntry(List<PurchaseMacodeInfo> details, HttpServletResponse response);
}

View File

@ -1,6 +1,8 @@
package com.bonus.sgzb.material.service.impl;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
@ -9,6 +11,7 @@ import com.bonus.sgzb.base.api.domain.*;
import com.bonus.sgzb.base.api.domain.MachinePart;
import com.bonus.sgzb.common.core.utils.StringHelper;
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.security.utils.SecurityUtils;
import com.bonus.sgzb.material.domain.*;
@ -19,11 +22,13 @@ import com.bonus.sgzb.common.core.utils.DateUtils;
import com.bonus.sgzb.material.vo.GlobalContants;
import com.bonus.sgzb.base.api.domain.MaInputVO;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
/**
* 新购验收编号管理Service业务层处理
@ -530,4 +535,94 @@ public class PurchaseMacodeInfoServiceImpl implements IPurchaseMacodeInfoService
return purchaseMacodeInfoMapper.warehousingEntry(purchaseMacodeInfo);
}
/**
* 导出入库清单
* @param list
* @param response
*/
@Override
public void exportWareHousingEntry(List<PurchaseMacodeInfo> list, HttpServletResponse response) {
try {
String fileName = "入库单";
expOutExcel(response, list, fileName);
} catch (Exception e) {
log.error(e.toString(), e);
}
}
/**
* 导出excel
* @param response
* @param list
* @param fileName
*/
private void expOutExcel(HttpServletResponse response, List<PurchaseMacodeInfo> list, String fileName)
throws Exception {
if (list != null) {
List<Map<String, Object>> results = new ArrayList<>();
int size = list.size();
for (int i = 0; i < size; i++) {
PurchaseMacodeInfo bean = list.get(i);
bean.setId((long) (i + 1));
Map<String, Object> maps = outReceiveDetailsBeanToMap(bean);
results.add(maps);
}
List<String> headers = receiveDetailsHeader();
HSSFWorkbook workbook = PoiOutPage.excelForCheckInput(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();
}else{
List<Map<String, Object>> results = new ArrayList<>();
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(PurchaseMacodeInfo bean) {
Map<String, Object> maps = new LinkedHashMap<>();
maps.put("id", bean.getId());
maps.put("typeName", bean.getTypeName());
maps.put("specificationType", bean.getSpecificationType());
maps.put("unitName", bean.getUnitName());
maps.put("checkNum", bean.getCheckNum());
maps.put("remark", bean.getRemark());
return maps;
}
/**
* 入库单头信息
* @return
*/
private List<String> receiveDetailsHeader() {
List<String> list = new ArrayList<>();
list.add("序号");
list.add("类型名称");
list.add("规格型号");
list.add("计量单位");
list.add("数量");
list.add("备注");
return list;
}
}

View File

@ -3,14 +3,13 @@ package com.bonus.sgzb.system.controller;
import com.bonus.sgzb.common.core.web.controller.BaseController;
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import com.bonus.sgzb.system.service.ISysSmsService;
import org.springframework.beans.factory.annotation.Autowired;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.Date;
/**
* Description: 短信控制器
@ -22,6 +21,7 @@ import java.util.Date;
@RestController
@RequestMapping("/sms")
@Slf4j
public class SysSmsController extends BaseController {
@Resource
@ -63,11 +63,12 @@ public class SysSmsController extends BaseController {
* @return
*/
@PostMapping("send")
public AjaxResult send(@RequestParam(value = "phone") String phone, @RequestParam(value = "msg",required = false) String msg){
public Boolean send(@RequestParam(value = "phone") String phone, @RequestParam(value = "msg",required = false) String msg){
try {
return smsService.sendSms(phone, msg);
} catch (Exception e) {
return error(e.getMessage());
log.error(e.getMessage());
return false;
}
}

View File

@ -19,7 +19,7 @@ public interface ISysSmsService {
* @param msg 内容
* @return 结果
*/
AjaxResult sendSms(String phone, String msg);
Boolean sendSms(String phone, String msg);
/**
* 发送短信

View File

@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject;
import com.bonus.sgzb.common.core.constant.UserConstants;
import com.bonus.sgzb.common.core.exception.ServiceException;
import com.bonus.sgzb.common.core.utils.GlobalConstants;
import com.bonus.sgzb.common.core.utils.sms.SmsUtils;
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import com.bonus.sgzb.common.redis.service.RedisService;
import com.bonus.sgzb.system.config.TencentSmsConfig;
@ -63,20 +64,13 @@ public class SysSmsServiceImpl implements ISysSmsService {
* @return
*/
@Override
public AjaxResult sendSms(String phone, String msg) {
public Boolean sendSms(String phone, String msg) {
if (phone == null || StringUtils.isEmpty(msg)) {
return AjaxResult.error("手机号码或短信内容不能为空");
throw new RuntimeException("手机号码或短信内容不能为空");
}
if (phone.length() != UserConstants.PHONE_DEFAULT_LENGTH_LOGIN) {
return AjaxResult.error("手机号格式不正确");
throw new RuntimeException("手机号码或短信内容不能为空");
}
/* try {
String[] args = msg.split(",");
String body = sendMessageNew(phone,tencentSmsConfig.getTemplateId().get(0),args);
return success("发送手机号码:" + phone + ",内容:" + msg + ",返回结果:" + body);
} catch (Exception e) {
return AjaxResult.error("发送失败:" + e.getMessage());
}*/
return sendMsgByPhone( phone, msg);
}
@ -108,23 +102,27 @@ public class SysSmsServiceImpl implements ISysSmsService {
* @param phone 手机号码
* @return AjaxResult对象
*/
private AjaxResult sendMsgByPhone(String phone, String msg) {
private Boolean sendMsgByPhone(String phone, String msg) {
// 校验手机号码
if (phone == null || phone.length() != UserConstants.PHONE_DEFAULT_LENGTH_LOGIN) {
return AjaxResult.error("手机号码不正确");
throw new ServiceException("手机号码不正确");
}
// 发送短信
try {
// String URL = "http://106.ihuyi.common/webservice/sms.php?method=Submit";
String content = URL + "&mobile=" + phone + "&content=【智慧仓储】" + msg + "";
String body = HttpRequest.post(content).execute(false).body();
//String body = HttpRequest.post(content).execute(false).body();
// System.out.println("发送手机号码:" + phone + ",内容:" + msg + ",返回结果:" + body);
String body = SmsUtils.smsToken(phone, msg,"");
if (body == null || !body.contains(GlobalConstants.STRING_OK)) {
return AjaxResult.error("发送失败");
log.error("发送失败:" + body);
throw new ServiceException("发送失败");
}
return success("发送手机号码:" + phone + ",内容:" + msg + ",返回结果:" + body);
log.error("发送手机号码:" + phone + ",内容:" + msg + ",返回结果:" + body);
return true;
} catch (Exception e) {
return AjaxResult.error("发送失败:" + e.getMessage());
log.error("发送失败:" + e.getMessage());
return false;
}
}