zhushi
zch 2 months ago
parent 70178b8a3c
commit d9cc58ecce

@ -56,11 +56,15 @@ public class EmsBaseEnergyPriceServiceImpl implements IEmsBaseEnergyPriceService
public int insertEmsBaseEnergyPrice(EmsBaseEnergyPrice emsBaseEnergyPrice)
{
try {
// 设置创建时间
emsBaseEnergyPrice.setCreateTime(DateUtils.getNowDate());
// 插入能源月份单价
emsBaseEnergyPriceMapper.insertEmsBaseEnergyPrice(emsBaseEnergyPrice);
} catch (Exception e) {
// 如果插入失败,抛出异常
throw new ServiceException("能源月份重复!");
}
// 返回结果
return 1;
}

@ -141,21 +141,28 @@ public class EmsBaseMonitorInfoServiceImpl implements IEmsBaseMonitorInfoService
@Override
public List<EmsBaseMonitorInfo> buildMonitorInfoTree(List<EmsBaseMonitorInfo> baseMonitorInfos)
{
// 定义一个返回的树结构列表
List<EmsBaseMonitorInfo> returnList = new ArrayList<EmsBaseMonitorInfo>();
// 将所有节点的父节点id存入一个临时列表
List<Long> tempList = baseMonitorInfos.stream().map(EmsBaseMonitorInfo::getObjId).collect(Collectors.toList());
// 遍历所有节点
for (EmsBaseMonitorInfo baseMonitorInfo : baseMonitorInfos)
{
// 如果是顶级节点, 遍历该父节点的所有子节点
if (!tempList.contains(baseMonitorInfo.getParentId()))
{
// 递归遍历该父节点的所有子节点
recursionFn(baseMonitorInfos, baseMonitorInfo);
// 将该父节点加入返回列表
returnList.add(baseMonitorInfo);
}
}
// 如果返回列表为空,则返回所有节点
if (returnList.isEmpty())
{
returnList = baseMonitorInfos;
}
// 返回树结构列表
return returnList;
}
/**

@ -46,18 +46,30 @@ public class EmsBaseMonitorThresholdServiceImpl implements IEmsBaseMonitorThresh
*/
@Override
public List<EmsBaseMonitorThreshold> selectEmsBaseMonitorThresholdList(EmsBaseMonitorThreshold emsBaseMonitorThreshold) {
// 查询计量设备阈值维护列表
List<EmsBaseMonitorThreshold> monitorThresholds = emsBaseMonitorThresholdMapper.selectEmsBaseMonitorThresholdList(emsBaseMonitorThreshold);
// 如果查询结果为空,并且传入的监控编号不为空
if (monitorThresholds.size() == 0 && StringUtils.isNotEmpty(emsBaseMonitorThreshold.getMonitorCode())) {
// 创建监控信息对象
EmsBaseMonitorInfo monitorInfo = new EmsBaseMonitorInfo();
// 设置监控编号
monitorInfo.setMonitorCode(emsBaseMonitorThreshold.getMonitorCode());
// 查询监控信息列表
List<EmsBaseMonitorInfo> monitorInfoList = emsBaseMonitorInfoMapper.selectEmsBaseMonitorInfoList(monitorInfo);
// 如果查询结果不为空并且第一条数据的是否电表字段为1
if (monitorInfoList.size() > 0 && monitorInfoList.get(0).getIsAmmeter().equals("1")) {
// 创建计量设备阈值维护对象
EmsBaseMonitorInfo emsBaseMonitorInfo = monitorInfoList.get(0);
// 设置创建者
emsBaseMonitorThreshold.setCreateBy(SecurityUtils.getUsername());
// 设置监控类型
emsBaseMonitorThreshold.setMonitorType(emsBaseMonitorInfo.getMonitorType());
// 设置监控名称
emsBaseMonitorThreshold.setMonitorName(emsBaseMonitorInfo.getMonitorName());
// 插入计量设备阈值维护
this.insertEmsBaseMonitorThreshold(emsBaseMonitorThreshold);
// 将插入的数据添加到查询结果列表中
monitorThresholds.add(emsBaseMonitorThreshold);
}
}

@ -91,15 +91,22 @@ public class EmsBaseWorkUnitServiceImpl implements IEmsBaseWorkUnitService
@Override
public int deleteEmsBaseWorkUnitByObjIds(Long[] objIds)
{
// 遍历统计单元信息主键数组
for (Long objId : objIds) {
// 根据主键查询统计单元信息
EmsBaseWorkUnit baseWorkUnit = this.selectEmsBaseWorkUnitByObjId(objId);
// 创建一个计量设备信息对象
EmsBaseMonitorWorkUnit monitorWorkUnit = new EmsBaseMonitorWorkUnit();
// 设置计量设备信息对象的单位编码
monitorWorkUnit.setWorkUnitCode(baseWorkUnit.getWorkUnitCode());
// 根据单位编码查询计量设备信息列表
List<EmsBaseMonitorWorkUnit> workUnits = emsBaseMonitorWorkUnitMapper.selectEmsBaseMonitorWorkUnitList(monitorWorkUnit);
// 如果计量设备信息列表长度大于0则抛出异常
if (workUnits.size() > 0){
throw new ServiceException(baseWorkUnit.getWorkUnitName() + "已关联计量设备,无法删除!");
}
}
// 返回删除统计单元信息的结果
return emsBaseWorkUnitMapper.deleteEmsBaseWorkUnitByObjIds(objIds);
}

@ -144,38 +144,60 @@ public class EmsRecordAlarmDataServiceImpl implements IEmsRecordAlarmDataService
*
*/
public void collectDeviceAlarmsTask() {
// 定义分钟值
long minuteValue = 1000 * 60;
// 获取当前时间
Date date = new Date();
// 实例化EmsRecordAlarmRule
EmsRecordAlarmRule alarmRule = new EmsRecordAlarmRule();
// 设置触发规则
alarmRule.setTriggerRule(1L);
// 查询告警规则
List<EmsRecordAlarmRule> alarmRules = emsRecordAlarmRuleMapper.selectEmsRecordAlarmRuleList(alarmRule);
// 如果查询结果不为空
if (alarmRules.size() > 0) {
// 设置分钟值
minuteValue = alarmRules.get(0).getDeviceOfflineTime() * minuteValue;
} else {
// 如果查询结果为空,直接返回
return;
}
// 实例化EmsBaseCollectDeviceInfo
EmsBaseCollectDeviceInfo collectDeviceInfo = new EmsBaseCollectDeviceInfo();
// 设置标志位
collectDeviceInfo.setIsFlag("1");
// 查询采集设备信息
List<EmsBaseCollectDeviceInfo> deviceInfoList = emsBaseCollectDeviceInfoMapper.selectEmsBaseCollectDeviceInfoList(collectDeviceInfo);
// 如果查询结果不为空
if (deviceInfoList.size() > 0) {
// 实例化EmsRecordAlarmData
EmsRecordAlarmData recordAlarmData = new EmsRecordAlarmData();
// 设置告警类型
recordAlarmData.setAlarmType(1L);
// 设置告警状态
recordAlarmData.setAlarmStatus(1L);
// 查询告警数据
List<EmsRecordAlarmData> alarmDataList = emsRecordAlarmDataMapper.selectEmsRecordAlarmDataList(recordAlarmData);
// 获取告警数据的collectDeviceId
List<String> collectDeviceIdList = alarmDataList.stream().map(EmsRecordAlarmData::getCollectDeviceId).collect(Collectors.toList());
// 遍历采集设备信息
for (EmsBaseCollectDeviceInfo deviceInfo : deviceInfoList) {
// 如果告警数据中包含当前采集设备,跳过
if (collectDeviceIdList.contains(deviceInfo.getCollectDeviceId())) {
continue;
}
// 如果采集设备离线超过设置的分钟值,插入告警数据
if ((deviceInfo.getUpdateTime().getTime() + minuteValue) < date.getTime()) {
EmsRecordAlarmData alarmData = new EmsRecordAlarmData();
alarmData.setCollectDeviceId(deviceInfo.getCollectDeviceId());
alarmData.setCollectTime(new Date());
alarmData.setAlarmType(1L);
alarmData.setAlarmStatus(1L);
// 设置告警数据
alarmData.setAlarmData("设备离线已超过" + alarmRules.get(0).getDeviceOfflineTime() + "分钟");
// 插入告警数据
this.insertEmsRecordAlarmData(alarmData);
}
}
@ -186,19 +208,28 @@ public class EmsRecordAlarmDataServiceImpl implements IEmsRecordAlarmDataService
*
*/
public void exceedDnbThresholdAlarmsTask() {
// 创建EmsBaseMonitorThreshold对象设置监测类型为2
EmsBaseMonitorThreshold monitorThreshold = new EmsBaseMonitorThreshold();
monitorThreshold.setMonitorType(2L);
// 查询阈值列表
List<EmsBaseMonitorThreshold> thresholdList = emsBaseMonitorThresholdMapper.selectEmsBaseMonitorThresholdList(monitorThreshold);
// 创建EmsRecordDnbInstant对象
EmsRecordDnbInstant dnbInstant = new EmsRecordDnbInstant();
// 查询记录列表
List<EmsRecordDnbInstant> dnbInstantList = emsRecordDnbInstantMapper.selectEmsRecordDnbInstantList(dnbInstant);
// 比较阈值和记录将超过阈值的记录存入map
Map<String, String> thresholdMap = compareThresholdAndRecord(thresholdList, dnbInstantList);
//防止多次存入异常数据
// 创建EmsRecordAlarmData对象设置异常类型为0异常状态为1
EmsRecordAlarmData recordAlarmData = new EmsRecordAlarmData();
recordAlarmData.setAlarmType(0L);
recordAlarmData.setAlarmStatus(1L);
// 查询异常数据列表
List<EmsRecordAlarmData> alarmDataList = emsRecordAlarmDataMapper.selectEmsRecordAlarmDataList(recordAlarmData);
// 将异常数据monitorId存入list
List<String> monitorIdList = alarmDataList.stream().map(EmsRecordAlarmData::getMonitorId).collect(Collectors.toList());
// 遍历超过阈值的记录,如果已经存入异常数据,则跳过,否则存入异常数据
for (String monitorId : thresholdMap.keySet()) {
if (monitorIdList.contains(monitorId)) {
continue;
@ -222,23 +253,33 @@ public class EmsRecordAlarmDataServiceImpl implements IEmsRecordAlarmDataService
* @return
*/
public Map<String, String> compareThresholdAndRecord(List<EmsBaseMonitorThreshold> baseDnbThresholds, List<EmsRecordDnbInstant> recordDnbInstants) {
// 创建一个Map用于存放结果
Map<String, String> resultMap = new HashMap<>();
// 遍历记录DnbInstants
for (EmsRecordDnbInstant recordDnbInstant : recordDnbInstants) {
// 获取监测码
String monitorCode = recordDnbInstant.getMonitorCode();
// 定义一个baseDnbThreshold用于存放阈值
EmsBaseMonitorThreshold baseDnbThreshold = null;
// 遍历baseDnbThresholds查找阈值
for (EmsBaseMonitorThreshold threshold : baseDnbThresholds) {
if (threshold.getMonitorCode().equals(monitorCode)) {
baseDnbThreshold = threshold;
break;
}
}
// 如果baseDnbThreshold不为空
if (baseDnbThreshold != null) {
// 调用compare方法比较记录和阈值
String reason = compare(recordDnbInstant, baseDnbThreshold);
// 如果比较结果不为空
if (reason != null) {
// 将结果存入Map
resultMap.put(monitorCode, reason);
}
}
}
// 返回结果
return resultMap;
}
@ -294,16 +335,25 @@ public class EmsRecordAlarmDataServiceImpl implements IEmsRecordAlarmDataService
*
*/
public void hourlyConsumptionAlarmsTask() {
// 创建EmsBaseMonitorThreshold对象
EmsBaseMonitorThreshold monitorThreshold = new EmsBaseMonitorThreshold();
// 设置监控类型为2
monitorThreshold.setMonitorType(2L);
// 查询监控阈值列表
List<EmsBaseMonitorThreshold> thresholdList = emsBaseMonitorThresholdMapper.selectEmsBaseMonitorThresholdList(monitorThreshold);
// 遍历监控阈值列表
for (EmsBaseMonitorThreshold threshold : thresholdList) {
// 获取小时耗量
BigDecimal consumption = threshold.getHourConsumption();
// 如果小时耗量为0则跳过本次循环
if (consumption.equals(new BigDecimal(0))){
continue;
}
// 创建EmsReportPointDnb对象
EmsReportPointDnb reportPointDnb = new EmsReportPointDnb();
// 设置监控编码
reportPointDnb.setMonitorCode(threshold.getMonitorCode());
// 查询报告点列表
List<EmsReportPointDnb> dnbList = emsReportPointDnbMapper.selectEmsReportPointDnbList(reportPointDnb);
}

@ -35,25 +35,34 @@ public class EmsReportServiceImpl implements IEmsReportService {
private EmsBaseWorkUnitMapper emsBaseWorkUnitMapper;
/**
/**
*
* <p>
* null
*
* </p>
*
* @param hashMap
* @return
* @param hashMap (dateType)(energyType)
* @return null
*/
@Override
public List<EnergyStatisticalReport> energyStatisticalReportList(Map hashMap) {
@Override
public List<EnergyStatisticalReport> energyStatisticalReportList(Map hashMap) {
// 检查必要的参数是否缺失
if (!hashMap.containsKey("dateType") && !hashMap.containsKey("energyType")) {
return null;
}
// 计算时间差,基于日期类型
hashMap.put("timeSub", Integer.parseInt(String.valueOf(hashMap.get("dateType"))));
// 初始化能耗报表列表
List<EnergyStatisticalReport> reportList = new ArrayList<>();
// 根据能耗类型调用相应的报表生成逻辑
if (Objects.equals(String.valueOf(hashMap.get("energyType")), "2")){
reportList = emsReportMapper.energyStatisticalDnbReportList(hashMap);
}
// 返回报表列表
return reportList;
}
}
/**
*
@ -69,43 +78,57 @@ public class EmsReportServiceImpl implements IEmsReportService {
return emsReportMapper.peaksValleysConsumptionReportList(hashMap);
}
/**
/**
*
*
*
* @param hashMap
* @return
* @param hashMap startTime, endTime, dateType, energyType
* @return
*/
@Override
public List<Map<String, Object>> energyPreviewReportList(Map hashMap) {
@Override
public List<Map<String, Object>> energyPreviewReportList(Map hashMap) {
// 初始化结果列表
List<Map<String, Object>> resultList = new ArrayList<>();
// 检查是否同时提供了开始时间和结束时间,如果未提供则直接返回空列表
if (!hashMap.containsKey("startTime") || !hashMap.containsKey("endTime")) {
return resultList;
}
// 创建并查询所有工作单元信息
EmsBaseWorkUnit workUnit = new EmsBaseWorkUnit();
List<EmsBaseWorkUnit> workUnits = emsBaseWorkUnitMapper.selectEmsBaseWorkUnitList(workUnit);
// 初始化用于查询能源统计报告的参数映射
HashMap<String, String> selectMap = new HashMap<>();
selectMap.put("dateType", String.valueOf(hashMap.get("dateType")));
selectMap.put("energyType", String.valueOf(hashMap.get("energyType")));
selectMap.put("beginCollectTime", String.valueOf(hashMap.get("startTime")));
selectMap.put("endCollectTime", String.valueOf(hashMap.get("endTime")));
// 遍历每个工作单元,查询并统计能源消耗数据
for (EmsBaseWorkUnit unit : workUnits) {
// 初始化当前工作单元的能源消耗结果映射
HashMap<String, Object> typeResultMap = new HashMap<>();
typeResultMap.put("unitName", unit.getWorkUnitName());
// 在查询映射中添加工作单元代码
selectMap.put("workUnitCode", unit.getWorkUnitCode());
// 调用方法查询当前工作单元的能源统计报告列表
List<EnergyStatisticalReport> reportList = this.energyStatisticalReportList(selectMap);
// 初始化能源消耗总和
BigDecimal expendSum = new BigDecimal(0);
// 遍历报告列表,累加能源消耗数据
for (EnergyStatisticalReport report : reportList) {
typeResultMap.put("expend" + report.getBeginTime(), report.getExpend());
expendSum = expendSum.add(report.getExpend());
}
// 将能源消耗总和添加到结果映射中
typeResultMap.put("expendSum", expendSum.toPlainString());
// 将当前工作单元的能源消耗结果映射添加到结果列表中
resultList.add(typeResultMap);
}
// 返回能源预览报告列表
return resultList;
}
}
}

@ -31,12 +31,19 @@ public class ERPPortController extends BaseController {
*/
@PostMapping("/getERPOrderData")
public AjaxResult getERPOrderData(@RequestBody Map paramMap) {
// 创建ERPParamDto对象
ERPParamDto paramDto = new ERPParamDto();
// 设置AppCode
paramDto.setAppCode(String.valueOf(paramMap.get("AppCode")));
// 设置Controller
paramDto.setController(String.valueOf(paramMap.get("Controller")));
// 设置ActionName
paramDto.setActionName(String.valueOf(paramMap.get("ActionName")));
// 设置OrderStartTime
paramDto.setOrderStartTime(String.valueOf(paramMap.get("OrderStartTime")));
// 设置OrderEndTime
paramDto.setOrderEndTime(String.valueOf(paramMap.get("OrderEndTime")));
// 调用portService的getERPOrderData方法传入paramDto获取ERP订单数据
return AjaxResult.success(portService.getERPOrderData(paramDto));
}
@ -48,10 +55,15 @@ public class ERPPortController extends BaseController {
*/
@PostMapping("/getERPEmployeeWageData")
public AjaxResult getERPEmployeeWageData(@RequestBody Map paramMap) {
// 创建ERPParamDto对象
ERPParamDto paramDto = new ERPParamDto();
// 设置AppCode
paramDto.setAppCode(String.valueOf(paramMap.get("AppCode")));
// 设置Controller
paramDto.setController(String.valueOf(paramMap.get("Controller")));
// 设置ActionName
paramDto.setActionName(String.valueOf(paramMap.get("ActionName")));
// 调用portService的getERPEmployeeWageData方法并返回结果
return AjaxResult.success(portService.getERPEmployeeWageData(paramDto));
}
@ -63,10 +75,15 @@ public class ERPPortController extends BaseController {
*/
@PostMapping("/getERPLatestSalaryData")
public AjaxResult getERPLatestSalaryData(@RequestBody Map paramMap) {
// 创建ERPParamDto对象
ERPParamDto paramDto = new ERPParamDto();
// 设置AppCode
paramDto.setAppCode(String.valueOf(paramMap.get("AppCode")));
// 设置Controller
paramDto.setController(String.valueOf(paramMap.get("Controller")));
// 设置ActionName
paramDto.setActionName(String.valueOf(paramMap.get("ActionName")));
// 调用portService的getERPLatestSalaryData方法并返回结果
return AjaxResult.success(portService.getERPLatestSalaryData(paramDto));
}

@ -86,23 +86,34 @@ public class ERPPortServiceImpl implements IERPPortService {
*/
@Override
public List<BaseStaffInfo> getERPEmployeeWageData(ERPParamDto paramDto) {
// 定义一个返回的员工信息列表
List<BaseStaffInfo> resultList = new ArrayList<>();
// 定义一个请求参数
String requestParam = null;
// 定义一个接口返回结果
String result = null;
try {
// 创建ObjectMapper实例 对象转JSON字符串
ObjectMapper objectMapper = new ObjectMapper();
// 设置对象转换为JSON字符串的命名策略
objectMapper.setPropertyNamingStrategy(PropertyNamingStrategy.UPPER_CAMEL_CASE);
// 将ERPParamDto对象转换为JSON字符串
requestParam = objectMapper.writeValueAsString(paramDto);
// 调用接口获取返回结果
result = ApiUtils.sendERPHttpPost(ERPConstants.ERP_URL, requestParam);
// 处理接口返回消息
ObjectMapper resultMapper = new ObjectMapper();
// 将 JSON 字符串转换为 Java 对象
HashMap hashMap = resultMapper.readValue(result, HashMap.class);
// 获取返回数据
HashMap returnData = (HashMap)hashMap.get("ReturnData");
// 获取数据列表
List<HashMap<String, String>> dataList = (List<HashMap<String, String>>)returnData.get("data");
// 遍历数据列表
for (HashMap<String, String> data : dataList) {
// 将数据插入员工信息表
BaseStaffInfo baseStaffInfo = staffInfoService.insertStaffByERP(data);
// 将员工信息添加到返回列表中
resultList.add(baseStaffInfo);
}
logger.warn("获取员工工资系数成功:" + requestParam + "|" + result);
@ -152,17 +163,24 @@ public class ERPPortServiceImpl implements IERPPortService {
return latestSalary;
}
/**
/**
*
* @param recordStaffSalary
* @return
* ERP
* @param recordStaffSalary RecordStaffSalary
* @return ERPObjectId
*/
@Override
public String addSalaryBreakdown(RecordStaffSalary recordStaffSalary) {
String objectId = null;//ERP返回数据的ObjectId
@Override
public String addSalaryBreakdown(RecordStaffSalary recordStaffSalary) {
// ERP返回数据的ObjectId用于唯一标识新增的记录
String objectId = null;
// 用于存储发送给ERP系统的请求参数的字符串
String requestParam = null;
// ERP系统返回的结果
String result = null;
// 创建一个ERPStaffSalary对象用于准备发送给ERP系统的请求数据
ERPStaffSalary erpStaffSalary = new ERPStaffSalary();
// 设置ERP系统请求的参数
erpStaffSalary.setAppCode(ERPConstants.addSalaryAppCode);
erpStaffSalary.setController(ERPConstants.addSalaryController);
erpStaffSalary.setActionName(ERPConstants.addSalaryActionName);
@ -173,12 +191,17 @@ public class ERPPortServiceImpl implements IERPPortService {
erpStaffSalary.setRevenueClass(recordStaffSalary.getRevenueClass());
erpStaffSalary.setRevenueAmount(recordStaffSalary.getRevenueAmount());
erpStaffSalary.setRevenueReason(recordStaffSalary.getRevenueReason());
try {
// 创建ObjectMapper实例 对象转JSON字符串
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.setPropertyNamingStrategy(PropertyNamingStrategy.UPPER_CAMEL_CASE);
// 将erpStaffSalary对象转换为JSON字符串以便发送给ERP系统
requestParam = objectMapper.writeValueAsString(erpStaffSalary);
// result = ApiUtils.sendERPHttpPost(ERPConstants.ERP_URL, requestParam);
// 使用API工具类发送HTTP POST请求到ERP系统这里代码已省略
// result = ApiUtils.sendERPHttpPost(ERPConstants.ERP_URL, requestParam);
// 模拟ERP系统返回的结果
result = "{\n" +
"\t\"Successful\": true,\n" +
"\t\"ErrorMessage\": null,\n" +
@ -192,18 +215,22 @@ public class ERPPortServiceImpl implements IERPPortService {
"\t},\n" +
"\t\"DataType\": 0\n" +
"}";
// 处理接口返回消息
ObjectMapper resultMapper = new ObjectMapper();
// 将 JSON 字符串转换为 Java 对象
HashMap hashMap = resultMapper.readValue(result, HashMap.class);
HashMap returnData = (HashMap)hashMap.get("ReturnData");
HashMap<String, Object> data = (HashMap<String, Object>)returnData.get("data");
// 提取并返回ObjectId
objectId = String.valueOf(data.get("ObjectId"));
} catch (Exception e) {
// 记录异常信息,包括请求参数、结果和异常详情
logger.warn("新增【薪资明细】异常:" + requestParam + "|" + result + "|" + e);
}
// 返回ERP系统生成的ObjectId
return objectId;
}
}
}

@ -14,13 +14,15 @@ import cn.hutool.http.HttpResponse;
public class ApiUtils {
/**
* POSTjson
* @param apiUrl
* @param jsonData
* @return
/**
* ERPPOSTJSON
* ERPJSON
*
* @param apiUrl ERPAPI
* @param jsonData JSON
* @return ERP
*/
public static String sendERPHttpPost(String apiUrl, String jsonData) {
public static String sendERPHttpPost(String apiUrl, String jsonData) {
try {
// 构建POST请求
HttpRequest request = HttpRequest.post(apiUrl)
@ -28,7 +30,7 @@ public class ApiUtils {
.header("EngineSecret", ERPConstants.EngineSecret)
.body(jsonData) // 设置JSON格式的请求体
.contentType("application/json") // 设置Content-Type为application/json
.setConnectionTimeout(1000 * 60 * 10) // 设置请求连接超时时间
.setConnectionTimeout(1000 * 60 * 10) // 设置请求连接超时时间为10分钟
;
// 发送POST请求
@ -40,6 +42,5 @@ public class ApiUtils {
// 捕获异常并重新抛出自定义异常
throw new RuntimeException("Failed to send ERP HTTP POST request: " + e.getMessage(), e);
}
}
}
}

@ -48,28 +48,40 @@ public class BaseProcessInfoServiceImpl implements IBaseProcessInfoService {
*/
@Override
public List<BaseProcessInfo> selectBaseProcessInfoList(BaseProcessInfo baseProcessInfo) {
// 查询工序信息列表
List<BaseProcessInfo> processList = baseProcessInfoMapper.selectBaseProcessInfoList(baseProcessInfo);
// 查询产线信息列表
BaseProductLine productLine = new BaseProductLine();
productLine.setProductLineType("2");
List<BaseProductLine> stationList = baseProductLineMapper.selectBaseProductLineList(productLine);
// 遍历工序信息列表
for (BaseProcessInfo processInfo : processList) {
// 获取工位编码
String stationCodes = processInfo.getStationCodes();
// 如果工位编码为空,跳过此次循环
if (StringUtils.isEmpty(stationCodes)) {
continue;
}
// 将工位编码以逗号分割成数组
String[] stationCodeList = stationCodes.split(",");
// 遍历工位编码数组
for (String stationCode : stationCodeList) {
// 过滤出工位编码相同的产线信息
List<BaseProductLine> baseProductLines = stationList.stream().filter(e -> Objects.equals(e.getProductLineCode(), stationCode)).collect(Collectors.toList());
// 如果过滤出的产线信息不为空,获取产线名称,并设置到工序信息中
if (baseProductLines.size() > 0) {
String productLineName = baseProductLines.get(0).getProductLineName();
// 如果工序信息的工位名称称为空,将当前产线名称设置到工序信息中
if (StringUtils.isEmpty(processInfo.getStationNames())) {
processInfo.setStationNames(productLineName);
} else {
// 如果工序信息的工位名称不为空,将当前产线名称以逗号分割拼接到工序信息的工位名称中
processInfo.setStationNames(processInfo.getStationNames() + "," + productLineName);
}
}
}
}
// 返回工序信息列表
return processList;
}

@ -47,21 +47,31 @@ public class BaseStaffInfoServiceImpl implements IBaseStaffInfoService {
*/
@Override
public List<BaseStaffInfo> selectBaseStaffInfoList(BaseStaffInfo baseStaffInfo) {
// 查询员工信息
List<BaseStaffInfo> baseStaffInfos = baseStaffInfoMapper.selectBaseStaffInfoList(baseStaffInfo);
// 查询员工团队信息
List<BaseTeamMembers> teamMembers = baseTeamMembersMapper.selectBaseTeamMembersList(new BaseTeamMembers());
// 遍历员工信息
for (BaseStaffInfo staffInfo : baseStaffInfos) {
// 如果员工信息中存在团队编码
if (StringUtils.isNotEmpty(staffInfo.getTeamCode())){
// 遍历员工团队信息
for (BaseTeamMembers teamMember : teamMembers) {
// 如果员工信息中的团队编码包含员工团队信息中的团队编码
if (staffInfo.getTeamCode().contains(teamMember.getTeamCode())){
// 如果员工信息中的团队名称为空
if (StringUtils.isEmpty(staffInfo.getTeamName())){
// 将员工团队信息中的团队名称赋值给员工信息
staffInfo.setTeamName(teamMember.getTeamName());
} else {
// 将员工团队信息中的团队名称拼接到员工信息中的团队名称后面
staffInfo.setTeamName(staffInfo.getTeamName() + "," + teamMember.getTeamName());
}
}
}
}
}
// 返回员工信息
return baseStaffInfos;
}

@ -53,17 +53,25 @@ public class ProdBomInfoServiceImpl implements IProdBomInfoService {
*/
@Override
public List<ProdBomInfo> selectProductionBomTreeList(ProdBomInfo prodBomInfo) {
// 创建一个用于存储ProdBomInfo对象的列表
List<ProdBomInfo> prodBomInfoList = new ArrayList<>();
// 根据objId查询ProdBomInfo对象
ProdBomInfo info = prodBomInfoMapper.selectProdBomInfoByObjId(prodBomInfo.getObjId());
// 将查询到的ProdBomInfo对象添加到prodBomInfoList中
prodBomInfoList.add(info);
try {
// 创建一个新的ProdBomInfo对象
ProdBomInfo bomInfo = new ProdBomInfo();
// 设置bomInfo的ancestors属性为info的objId
bomInfo.setAncestors(info.getObjId().toString());
// 根据bomInfo的ancestors属性查询ProdBomInfo列表
List<ProdBomInfo> infos = prodBomInfoMapper.selectProdBomInfoList(bomInfo);
// 将查询到的ProdBomInfo列表添加到prodBomInfoList中
prodBomInfoList.addAll(infos);
} catch (Exception e) {
e.printStackTrace();
}
// 返回prodBomInfoList
return prodBomInfoList;
}
@ -75,17 +83,24 @@ public class ProdBomInfoServiceImpl implements IProdBomInfoService {
*/
@Override
public int insertProdBomInfo(ProdBomInfo prodBomInfo) {
// 根据物料编码查询生产BOM
List<ProdBomInfo> baseBomInfos = prodBomInfoMapper.selectProdBomInfoList(prodBomInfo);
// 如果查询结果大于0则抛出异常
if (baseBomInfos.size() > 0) {
throw new BaseException("该物料BOM" + prodBomInfo.getMaterialCode() + "已存在!");
}
// 根据父ID查询生产BOM
ProdBomInfo info = prodBomInfoMapper.selectProdBomInfoByObjId(prodBomInfo.getParentId());
// 如果查询结果为空,则设置 ancestors 为 parentId
if (StringUtils.isNull(info)) {
prodBomInfo.setAncestors(prodBomInfo.getParentId().toString());
} else {
// 否则设置 ancestors 为父ID的ancestors加上parentId
prodBomInfo.setAncestors(info.getAncestors() + "," + prodBomInfo.getParentId());
}
// 设置创建时间
prodBomInfo.setCreateTime(DateUtils.getNowDate());
// 插入生产BOM
return prodBomInfoMapper.insertProdBomInfo(prodBomInfo);
}

Loading…
Cancel
Save