Browse Source

fix: 设备助手代码优化

zhongwei
haungxing 2 months ago
parent
commit
7fc34083ff
  1. 5
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/scheduled/DeviceLedgerScheduledTask.java
  2. 3
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/feign/OperAccessTaskClient.java
  3. 6
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/feign/TicketInfoClient.java

5
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/scheduled/DeviceLedgerScheduledTask.java

@ -60,7 +60,10 @@ public class DeviceLedgerScheduledTask {
// 取出数据ID 删除数据 // 取出数据ID 删除数据
JSONObject queryJson = JSONObject.parseObject(JSON.toJSONString(searchResult.getData())); JSONObject queryJson = JSONObject.parseObject(JSON.toJSONString(searchResult.getData()));
JSONArray data = Optional.ofNullable(queryJson).map(json -> json.getJSONObject("Get")) JSONArray data = Optional.ofNullable(queryJson).map(json -> json.getJSONObject("Get"))
.map(json -> json.getJSONArray(ScheduledConstant.DEVICE_LEDGER_CLASS_NAME)).orElse(null); .map(jsonObject -> {
Optional<String> tableName = jsonObject.keySet().stream().filter(key -> key.contains(ScheduledConstant.DEVICE_LEDGER_CLASS_NAME)).findFirst();
return tableName.isPresent() ? jsonObject.getJSONArray(tableName.get()) : null;
}).orElse(null);
if(Func.isNotEmpty(data)) { if(Func.isNotEmpty(data)) {
List<String> ids = data.stream().map(item -> { List<String> ids = data.stream().map(item -> {
JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(item)); JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(item));

3
hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/feign/OperAccessTaskClient.java

@ -131,7 +131,8 @@ public class OperAccessTaskClient implements IOperAccessTaskClient, IAccessTaskC
// 确保日期格式一致 // 确保日期格式一致
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
String formattedDate = sdf.format(task.getPlanStartTime()); String formattedDate = sdf.format(task.getPlanStartTime());
String overview = String.format(overviewTemplate, task.getCreateUserName(), formattedDate, task.getEmName(), task.getActHours(), details); Integer actHour = Optional.ofNullable(task.getActHours()).orElse(0);
String overview = String.format(overviewTemplate, task.getCreateUserName(), formattedDate, task.getEmName(), actHour, details);
return overview; return overview;
}).filter(Func::isNotEmpty).collect(Collectors.toList()); }).filter(Func::isNotEmpty).collect(Collectors.toList());
return R.data(overviewList); return R.data(overviewList);

6
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/feign/TicketInfoClient.java

@ -25,6 +25,8 @@ import org.springblade.core.mp.base.BaseEntity;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.*; import org.springblade.core.tool.utils.*;
import org.springblade.flow.core.feign.IFlowClient; import org.springblade.flow.core.feign.IFlowClient;
import org.springblade.system.user.cache.UserCache;
import org.springblade.system.user.entity.User;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -37,6 +39,7 @@ import java.time.format.DateTimeFormatter;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask; import java.util.concurrent.FutureTask;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -303,7 +306,8 @@ public class TicketInfoClient implements ITicketInfoClient {
if(Func.isNotEmpty(workTicketList)) { if(Func.isNotEmpty(workTicketList)) {
List<String> overviewList = workTicketList.stream().map(workTicketInfo -> { List<String> overviewList = workTicketList.stream().map(workTicketInfo -> {
String startTime = workTicketInfo.getPlanStartTime().format(DateUtil.DATETIME_FORMATTER); String startTime = workTicketInfo.getPlanStartTime().format(DateUtil.DATETIME_FORMATTER);
return String.format(overviewTemplate, workTicketInfo.getCreateUserName(), startTime, workTicketInfo.getEmName(), workTicketInfo.getWorkContent()); String createUserName = Optional.ofNullable(workTicketInfo.getCreateUser()).map(UserCache::getUser).map(User::getName).orElse("");
return String.format(overviewTemplate, createUserName, startTime, workTicketInfo.getEmName(), workTicketInfo.getWorkContent());
}).collect(Collectors.toList()); }).collect(Collectors.toList());
return R.data(overviewList); return R.data(overviewList);
} }

Loading…
Cancel
Save