采购订单 采购申请单 延期提醒 提前提醒
This commit is contained in:
parent
c09c359e28
commit
0c2b53478d
@ -26,10 +26,7 @@ import com.ruoyi.common.utils.HttpRequestUtil;
|
|||||||
import com.ruoyi.common.utils.WxRobotUtil;
|
import com.ruoyi.common.utils.WxRobotUtil;
|
||||||
import com.ruoyi.system.domain.SafetyStock;
|
import com.ruoyi.system.domain.SafetyStock;
|
||||||
import com.ruoyi.system.domain.WlStockData;
|
import com.ruoyi.system.domain.WlStockData;
|
||||||
import com.ruoyi.system.domain.dto.JDInventoryDTO;
|
import com.ruoyi.system.domain.dto.*;
|
||||||
import com.ruoyi.system.domain.dto.JDProductionDTO;
|
|
||||||
import com.ruoyi.system.domain.dto.ProMoDTO;
|
|
||||||
import com.ruoyi.system.domain.dto.PurchaseOrderDTO;
|
|
||||||
import com.ruoyi.system.domain.vo.SafetyStockVo;
|
import com.ruoyi.system.domain.vo.SafetyStockVo;
|
||||||
import com.ruoyi.system.domain.vo.WlStockDataVo;
|
import com.ruoyi.system.domain.vo.WlStockDataVo;
|
||||||
import com.ruoyi.system.mapper.SafetyStockMapper;
|
import com.ruoyi.system.mapper.SafetyStockMapper;
|
||||||
@ -834,4 +831,67 @@ public class KingdeeWorkCenterDataController extends BaseController {
|
|||||||
|
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Log(title = "采购订单和采购申请单")
|
||||||
|
@XxlJob("getMassageDelayDate")
|
||||||
|
public R<Void> getMassageDelayDate1() {
|
||||||
|
try {
|
||||||
|
// String robotId = "4d2f037d-0cee-493a-a4ff-1758f67b8069";
|
||||||
|
String robotId = "483489b2-b219-468c-851f-f56a34a62d91";
|
||||||
|
List<PurchaseOrderExcelDTO> list = JdUtil.getPurchaseOrder();
|
||||||
|
List<PurchaseRequestExcelDTO> list2 = JdUtil.getPurchaseRequestOrder();
|
||||||
|
String currentTime = DateUtil.format(new Date(), "yyyy年MM月dd日 HH:mm:ss");
|
||||||
|
StringBuilder msg = new StringBuilder();
|
||||||
|
msg.append("🏭 采购订单和采购申请更新\n\n")
|
||||||
|
.append("更新时间:").append(currentTime).append("\n\n")
|
||||||
|
.append("🔧 订单数据统计:\n");
|
||||||
|
|
||||||
|
// 获取并统计每个工段的数据
|
||||||
|
for (String workCenter : workCenters) {
|
||||||
|
try {
|
||||||
|
R<List<KingdeeWorkCenterDataBo>> result = getKingdeeDelayData(workCenter);
|
||||||
|
if (R.isError(result) || CollUtil.isEmpty(result.getData())) {
|
||||||
|
msg.append("- ").append(workCenter).append(" (无数据)\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<KingdeeWorkCenterDataBo> dataList = result.getData();
|
||||||
|
msg.append("- ").append(workCenter).append(" (共").append(dataList.size()).append("条数据)\n");
|
||||||
|
|
||||||
|
// 生成Excel文件
|
||||||
|
String fileName = String.format("%s生产延期数据_%s.xlsx", workCenter,
|
||||||
|
DateUtil.format(new Date(), "yyyyMMddHHmmss"));
|
||||||
|
String filePath = FileUtils.getTempDirectoryPath() + File.separator + fileName;
|
||||||
|
|
||||||
|
// 使用EasyExcel写入数据
|
||||||
|
EasyExcel.write(filePath, KingdeeWorkCenterDataVo.class)
|
||||||
|
.sheet("工段数据")
|
||||||
|
.doWrite(BeanUtil.copyToList(dataList, KingdeeWorkCenterDataVo.class));
|
||||||
|
|
||||||
|
// 发送Excel文件
|
||||||
|
File excelFile = new File(filePath);
|
||||||
|
wxRobotUtil.sendFileToWeChatGroup(excelFile, robotId);
|
||||||
|
|
||||||
|
// 删除临时文件
|
||||||
|
FileUtils.deleteQuietly(excelFile);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("获取工段{}数据失败", workCenter, e);
|
||||||
|
msg.append("- ").append(workCenter).append(" (获取失败: ").append(e.getMessage()).append(")\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
msg.append("\n详细数据请查看发送的Excel文件!");
|
||||||
|
wxRobotUtil.sendMsgToWeChatGroup(msg.toString(), robotId, true); // @所有人
|
||||||
|
|
||||||
|
return R.ok();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("发送工段数据失败", e);
|
||||||
|
return R.fail("发送工段数据失败:" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,56 @@
|
|||||||
|
package com.ruoyi.system.domain.dto;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class PurchaseOrderExcelDTO {
|
||||||
|
/**
|
||||||
|
* 单据编号
|
||||||
|
*/
|
||||||
|
@JsonProperty("FBillNo")
|
||||||
|
private String FBillNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 采购日期
|
||||||
|
*/
|
||||||
|
@JsonProperty("FDate")
|
||||||
|
private String FDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 供应商名称
|
||||||
|
*/
|
||||||
|
@JsonProperty("FSupplierId.FName")
|
||||||
|
private String FSupplierIdFName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物料编码
|
||||||
|
*/
|
||||||
|
@JsonProperty("FMaterialId.FNumber")
|
||||||
|
private String FMaterialIdFNumber;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物料名称
|
||||||
|
*/
|
||||||
|
@JsonProperty("FMaterialName")
|
||||||
|
private String FMaterialName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数量
|
||||||
|
*/
|
||||||
|
@JsonProperty("FQty")
|
||||||
|
private String FQty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 交货日期
|
||||||
|
*/
|
||||||
|
@JsonProperty("FDeliveryDate")
|
||||||
|
private String FDeliveryDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生产令号
|
||||||
|
*/
|
||||||
|
@JsonProperty("F_UCHN_Text2")
|
||||||
|
private String FUCHNText2;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,75 @@
|
|||||||
|
package com.ruoyi.system.domain.dto;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class PurchaseRequestExcelDTO {
|
||||||
|
/**
|
||||||
|
* 单据编号
|
||||||
|
*/
|
||||||
|
@JsonProperty("FBillNo")
|
||||||
|
private String FBillNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单据类型
|
||||||
|
*/
|
||||||
|
@JsonProperty("FBillTypeID")
|
||||||
|
private String FBillTypeID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 建议采购日期
|
||||||
|
*/
|
||||||
|
@JsonProperty("FSuggestPurDate")
|
||||||
|
private String FSuggestPurDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 建议供应商名称
|
||||||
|
*/
|
||||||
|
@JsonProperty("FSuggestSupplierId.FName")
|
||||||
|
private String FSuggestSupplierId_FName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物料编码
|
||||||
|
*/
|
||||||
|
@JsonProperty("FMaterialId.FNumber")
|
||||||
|
private String FMaterialId_FNumber;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物料名称
|
||||||
|
*/
|
||||||
|
@JsonProperty("FMaterialName")
|
||||||
|
private String FMaterialName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计价单位
|
||||||
|
*/
|
||||||
|
@JsonProperty("FPriceUnitId.FName")
|
||||||
|
private String FPriceUnitId_FName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 申请数量
|
||||||
|
*/
|
||||||
|
@JsonProperty("FReqQty")
|
||||||
|
private String FReqQty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 到货日期
|
||||||
|
*/
|
||||||
|
@JsonProperty("FArrivalDate")
|
||||||
|
private String FArrivalDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 申请日期
|
||||||
|
*/
|
||||||
|
@JsonProperty("FApplicationDate")
|
||||||
|
private String FApplicationDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生产令号
|
||||||
|
*/
|
||||||
|
@JsonProperty("F_UCHN_Text")
|
||||||
|
private String FUCHNText;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -2518,4 +2518,114 @@ public class JdUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static List<PurchaseOrderExcelDTO> getPurchaseOrder() {
|
||||||
|
K3CloudApi client = new K3CloudApi();
|
||||||
|
// 请求参数,要求为json字符串
|
||||||
|
JsonObject json = new JsonObject();
|
||||||
|
json.addProperty("FormId", "PUR_PurchaseOrder");
|
||||||
|
json.addProperty("FieldKeys", "FBillNo,FDate,FSupplierId.FName,FMaterialId.FNumber,FMaterialName,FQty,FDeliveryDate,F_UCHN_Text2");
|
||||||
|
// 创建过滤条件
|
||||||
|
JsonObject filterObject = new JsonObject();
|
||||||
|
JsonArray filterString = new JsonArray();
|
||||||
|
filterObject.addProperty("FieldName", "FCloseStatus");
|
||||||
|
filterObject.addProperty("Compare", "67");
|
||||||
|
filterObject.addProperty("Value", 105);
|
||||||
|
filterObject.addProperty("Left", "");
|
||||||
|
filterObject.addProperty("Right", "");
|
||||||
|
filterObject.addProperty("Logic", 0);
|
||||||
|
filterString.add(filterObject);
|
||||||
|
|
||||||
|
JsonObject filterObject1 = new JsonObject();
|
||||||
|
filterObject1.addProperty("FieldName", "FMRPCloseStatus");
|
||||||
|
filterObject1.addProperty("Compare", "67");
|
||||||
|
filterObject1.addProperty("Value", 105);
|
||||||
|
filterObject1.addProperty("Left", "");
|
||||||
|
filterObject1.addProperty("Right", "");
|
||||||
|
filterObject1.addProperty("Logic", 0);
|
||||||
|
filterString.add(filterObject1);
|
||||||
|
|
||||||
|
JsonObject filterObject2 = new JsonObject();
|
||||||
|
filterObject2.addProperty("FieldName", "FDocumentStatus");
|
||||||
|
filterObject2.addProperty("Compare", "67");
|
||||||
|
filterObject2.addProperty("Value", 105);
|
||||||
|
filterObject2.addProperty("Left", "");
|
||||||
|
filterObject2.addProperty("Right", "");
|
||||||
|
filterObject2.addProperty("Logic", 0);
|
||||||
|
filterString.add(filterObject2);
|
||||||
|
|
||||||
|
json.add("FilterString", filterString);
|
||||||
|
json.addProperty("OrderString", "");
|
||||||
|
json.addProperty("TopRowCount", 0);
|
||||||
|
json.addProperty("StartRow", 0);
|
||||||
|
json.addProperty("Limit", 10000);
|
||||||
|
json.addProperty("SubSystemId", "");
|
||||||
|
|
||||||
|
String jsonData = json.toString();
|
||||||
|
List<PurchaseOrderExcelDTO> purcs = null;
|
||||||
|
try {
|
||||||
|
// 调用接口
|
||||||
|
String resultJson = String.valueOf(client.billQuery(jsonData));
|
||||||
|
JsonArray jsonArray = new Gson().fromJson(resultJson, JsonArray.class);
|
||||||
|
// 使用 ObjectMapper 将 JsonArray 转换为 List<PlannedProcessVo>
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
purcs = objectMapper.readValue(jsonArray.toString(),
|
||||||
|
new TypeReference<List<PurchaseOrderExcelDTO>>() {
|
||||||
|
});
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace(); // 输出异常日志
|
||||||
|
}
|
||||||
|
|
||||||
|
return purcs; // 返回结果
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<PurchaseRequestExcelDTO> getPurchaseRequestOrder() {
|
||||||
|
K3CloudApi client = new K3CloudApi();
|
||||||
|
// 请求参数,要求为json字符串
|
||||||
|
JsonObject json = new JsonObject();
|
||||||
|
json.addProperty("FormId", "PUR_Requisition");
|
||||||
|
json.addProperty("FieldKeys", "FBillNo,FBillTypeID,FSuggestPurDate,FSuggestSupplierId.FName,FMaterialId.FNumber,FMaterialName,FPriceUnitId.FName,FReqQty,FArrivalDate,FApplicationDate,F_UCHN_Text");
|
||||||
|
// 创建过滤条件
|
||||||
|
JsonObject filterObject = new JsonObject();
|
||||||
|
JsonArray filterString = new JsonArray();
|
||||||
|
filterObject.addProperty("FieldName", "FDocumentStatus");
|
||||||
|
filterObject.addProperty("Compare", "67");
|
||||||
|
filterObject.addProperty("Value", 105);
|
||||||
|
filterObject.addProperty("Left", "");
|
||||||
|
filterObject.addProperty("Right", "");
|
||||||
|
filterObject.addProperty("Logic", 0);
|
||||||
|
filterString.add(filterObject);
|
||||||
|
|
||||||
|
JsonObject filterObject1 = new JsonObject();
|
||||||
|
filterObject1.addProperty("FieldName", "FCloseStatus");
|
||||||
|
filterObject1.addProperty("Compare", "67");
|
||||||
|
filterObject1.addProperty("Value", 105);
|
||||||
|
filterObject1.addProperty("Left", "");
|
||||||
|
filterObject1.addProperty("Right", "");
|
||||||
|
filterObject1.addProperty("Logic", 0);
|
||||||
|
filterString.add(filterObject1);
|
||||||
|
|
||||||
|
json.add("FilterString", filterString);
|
||||||
|
json.addProperty("OrderString", "");
|
||||||
|
json.addProperty("TopRowCount", 0);
|
||||||
|
json.addProperty("StartRow", 0);
|
||||||
|
json.addProperty("Limit", 10000);
|
||||||
|
json.addProperty("SubSystemId", "");
|
||||||
|
|
||||||
|
String jsonData = json.toString();
|
||||||
|
List<PurchaseRequestExcelDTO> purchaseRequestExcelDTOList = null;
|
||||||
|
try {
|
||||||
|
// 调用接口
|
||||||
|
String resultJson = String.valueOf(client.billQuery(jsonData));
|
||||||
|
JsonArray jsonArray = new Gson().fromJson(resultJson, JsonArray.class);
|
||||||
|
// 使用 ObjectMapper 将 JsonArray 转换为 List<PlannedProcessVo>
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
purchaseRequestExcelDTOList = objectMapper.readValue(jsonArray.toString(),
|
||||||
|
new TypeReference<List<PurchaseRequestExcelDTO>>() {
|
||||||
|
});
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace(); // 输出异常日志
|
||||||
|
}
|
||||||
|
|
||||||
|
return purchaseRequestExcelDTOList; // 返回结果
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user