rev:飞书相关修改

This commit is contained in:
2024-03-07 09:14:11 +08:00
parent edfb48330a
commit 1c795ec3fb
5 changed files with 200 additions and 1 deletions

View File

@@ -18,10 +18,14 @@ package org.nl.modules.tools.repository;
import org.nl.modules.tools.domain.LocalStorage;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
/**
* @author Zheng Jie
* @date 2019-09-05
*/
public interface LocalStorageRepository extends JpaRepository<LocalStorage, Long>, JpaSpecificationExecutor<LocalStorage> {
@Query(value = "select a from LocalStorage a where a.name = ?1")
LocalStorage findByName(String name);
}

View File

@@ -2,6 +2,7 @@ package org.nl.system.service.quartz.config;
import org.quartz.spi.TriggerFiredBundle;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.quartz.AdaptableJobFactory;
import org.springframework.stereotype.Component;
@@ -13,6 +14,7 @@ import org.springframework.stereotype.Component;
* @date 2019-01-07
*/
@Configuration
@ConditionalOnProperty(name = "autojob", havingValue = "true")
public class QuartzConfig {
/**

View File

@@ -25,7 +25,6 @@ import org.redisson.api.RedissonClient;
import org.springframework.stereotype.Component;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.text.SimpleDateFormat;
import java.util.Date;

View File

@@ -0,0 +1,189 @@
package org.nl.wms.sch.manage;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.hibernate.criterion.Example;
import org.nl.modules.common.config.FileProperties;
import org.nl.modules.common.utils.FileUtil;
import org.nl.modules.common.utils.ValidationUtil;
import org.nl.modules.tools.domain.LocalStorage;
import org.nl.modules.tools.repository.LocalStorageRepository;
import org.nl.modules.wql.WQL;
import org.nl.modules.wql.core.bean.WQLObject;
import org.nl.modules.wql.util.SpringContextHolder;
import org.nl.system.service.param.impl.SysParamServiceImpl;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Component;
import java.io.File;
import java.io.FileOutputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
@Slf4j
@Component
@RequiredArgsConstructor
public class AutoSendIvtExcel {
private final RedissonClient redissonClient;
private final FileProperties properties;
private final LocalStorageRepository localStorageRepository;
@SneakyThrows
public void run() {
RLock lock = redissonClient.getLock(this.getClass().getName());
boolean tryLock = lock.tryLock(0, TimeUnit.SECONDS);
try {
if (tryLock) {
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet("TestSheet");
HSSFRow row = sheet.createRow(0);
//设置第一列
row.createCell(0).setCellValue("仓库");
row.createCell(1).setCellValue("库区");
row.createCell(2).setCellValue("木箱码");
row.createCell(3).setCellValue("物料名称");
row.createCell(4).setCellValue("子卷号");
row.createCell(5).setCellValue("客户名称");
row.createCell(6).setCellValue("销售订单");
row.createCell(7).setCellValue("业务员");
row.createCell(8).setCellValue("入库时间");
row.createCell(9).setCellValue("单箱装卷数");
row.createCell(10).setCellValue("库龄");
row.createCell(11).setCellValue("产品规格(幅宽)");
row.createCell(12).setCellValue("净重");
row.createCell(13).setCellValue("长度");
row.createCell(14).setCellValue("物料标准厚度");
row.createCell(15).setCellValue("管件类型");
row.createCell(16).setCellValue("管件描述");
//查询库存明细
JSONObject map = new JSONObject();
map.put("flag", "22");
JSONArray resultJSONArray = WQL.getWO("QST_STRUCTIVT001").addParamMap(map).process().getResultJSONArray(0);
for (int i = 0; i < resultJSONArray.size(); i++) {
HSSFRow row_dtl = sheet.createRow(i+1);
JSONObject dtl = resultJSONArray.getJSONObject(i);
row_dtl.createCell(0).setCellValue(dtl.getString("stor_name"));
row_dtl.createCell(1).setCellValue(dtl.getString("sect_name"));
row_dtl.createCell(3).setCellValue(dtl.getString("package_box_sn"));
row_dtl.createCell(4).setCellValue(dtl.getString("material_name"));
row_dtl.createCell(5).setCellValue(dtl.getString("pcsn"));
row_dtl.createCell(6).setCellValue(dtl.getString("customer_description"));
row_dtl.createCell(7).setCellValue(dtl.getString("sale_order_name"));
row_dtl.createCell(8).setCellValue(dtl.getString("sales_owner"));
row_dtl.createCell(9).setCellValue(dtl.getString("instorage_time"));
row_dtl.createCell(10).setCellValue(dtl.getString("quanlity_in_box"));
row_dtl.createCell(11).setCellValue(dtl.getString("sid_day"));
row_dtl.createCell(12).setCellValue(String.format("%.0f", dtl.getDoubleValue("width")));
row_dtl.createCell(13).setCellValue(dtl.getString("net_weight"));
row_dtl.createCell(14).setCellValue(dtl.getString("length"));
row_dtl.createCell(15).setCellValue(dtl.getString("thickness_request"));
row_dtl.createCell(16).setCellValue(dtl.getString("paper_type"));
row_dtl.createCell(17).setCellValue(dtl.getString("paper_name"));
}
String type = FileUtil.getFileType("xls");
Date date = new Date();
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
String nowStr = format.format(date) + "-";
String path = properties.getPath().getPath() + type + File.separator + "当天库存报表.xls";
FileOutputStream fileOut = new FileOutputStream(path);
LocalStorage localStorage1 = new LocalStorage();
localStorage1.setName("当天库存报表");
LocalStorage local = localStorageRepository.findByName("当天库存报表");
if (ObjectUtil.isNotEmpty(local)){
local.setUpdateTime(DateUtil.date().toTimestamp());
localStorageRepository.save(local);
}else {
LocalStorage localStorage = new LocalStorage(
nowStr + "库存报表.xls",
nowStr + "库存报表",
"xls",
path,
type,
"");
localStorageRepository.save(localStorage);
}
workbook.write(fileOut);
fileOut.close();
} else {
System.out.println("AutoQueryBillInfo" + DateUtil.now() + "被锁住!!!!");
}
} finally {
if (tryLock) {
lock.unlock();
}
}
}
void sendInfo(JSONArray send_rows) {
WQLObject wo = WQLObject.getWQLObject("em_bi_devicestatus");
String device_code = "BILL_INFO";
JSONObject device_jo = wo.query("device_code = '" + device_code + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(device_jo.getString("upload_user"))) {
return;
}
String upload_user = device_jo.getString("upload_user");
String[] split = upload_user.split(",");
JSONArray UserList = new JSONArray();
if (split.length > 0) {
for (String s : split) {
JSONObject jo = new JSONObject();
jo.put("User", s);
UserList.add(jo);
}
} else {
return;
}
for (int i = 0; i < send_rows.size(); i++) {
JSONObject row = send_rows.getJSONObject(i);
String bill_code = row.getString("bill_code");
String Message = "出库单号为:" + bill_code + "的单据还未填写必填的发货信息并回传SAP请及时回传";
JSONObject jo = new JSONObject();
jo.put("SendType", "L");
jo.put("Title", "发货信息填写");
jo.put("WarnType", "string");
jo.put("MessageType", "P");
jo.put("UserList", UserList);
jo.put("Message", Message);
String url = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("FEISHU_URL").getValue();
String api = "/FeiShuNoticesWebApi/CommunalApi";
url = url + api;
try {
String resultMsg = HttpRequest.post(url)
.body(String.valueOf(jo))
.execute().body();
log.info("飞书输入参数为:-------------------" + jo);
log.info("飞书输出参数为:-------------------" + resultMsg);
} catch (Exception e) {
log.info(e.getMessage());
}
}
}
}

View File

@@ -99,6 +99,11 @@
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<el-table-column prop="updateTime" label="修改日期">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.updateTime) }}</span>
</template>
</el-table-column>
</el-table>
<!--分页组件-->
<pagination />