|
|
|
@ -1,8 +1,14 @@
|
|
|
|
package cn.iocoder.yudao.module.mes.controller.admin.deviceledger;
|
|
|
|
package cn.iocoder.yudao.module.mes.controller.admin.deviceledger;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
|
|
|
|
import cn.iocoder.yudao.module.common.dal.dataobject.mold.MoldDO;
|
|
|
|
import cn.iocoder.yudao.module.common.dal.dataobject.mold.MoldDO;
|
|
|
|
import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO;
|
|
|
|
import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO;
|
|
|
|
import cn.iocoder.yudao.module.mes.controller.admin.deviceledger.utils.ResumeNameUtils;
|
|
|
|
import cn.iocoder.yudao.module.mes.controller.admin.deviceledger.utils.ResumeNameUtils;
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.module.mes.controller.admin.plan.vo.PlanRespVO;
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.dataobject.organization.OrganizationDO;
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.dataobject.plan.PlanDO;
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.mysql.deviceledger.DeviceLedgerMapper;
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.module.mes.service.organization.OrganizationService;
|
|
|
|
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
|
|
|
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
|
|
|
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
|
|
|
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
|
|
|
import com.alibaba.excel.util.StringUtils;
|
|
|
|
import com.alibaba.excel.util.StringUtils;
|
|
|
|
@ -22,6 +28,7 @@ import java.time.format.DateTimeFormatter;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.*;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
|
@ -33,6 +40,7 @@ import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
|
|
|
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
|
|
|
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
|
|
|
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
|
|
|
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
|
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
|
|
|
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.module.mes.controller.admin.deviceledger.vo.*;
|
|
|
|
import cn.iocoder.yudao.module.mes.controller.admin.deviceledger.vo.*;
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.dataobject.deviceledger.DeviceLedgerDO;
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.dataobject.deviceledger.DeviceLedgerDO;
|
|
|
|
@ -47,6 +55,9 @@ public class DeviceLedgerController {
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private DeviceLedgerService deviceLedgerService;
|
|
|
|
private DeviceLedgerService deviceLedgerService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
private OrganizationService organizationService;
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private AdminUserApi adminUserApi;
|
|
|
|
private AdminUserApi adminUserApi;
|
|
|
|
|
|
|
|
|
|
|
|
@ -87,9 +98,8 @@ public class DeviceLedgerController {
|
|
|
|
@PreAuthorize("@ss.hasPermission('mes:device-ledger:query')")
|
|
|
|
@PreAuthorize("@ss.hasPermission('mes:device-ledger:query')")
|
|
|
|
public CommonResult<DeviceLedgerRespVO> getDeviceLedger(@RequestParam("id") Long id) {
|
|
|
|
public CommonResult<DeviceLedgerRespVO> getDeviceLedger(@RequestParam("id") Long id) {
|
|
|
|
DeviceLedgerDO deviceLedger = deviceLedgerService.getDeviceLedger(id);
|
|
|
|
DeviceLedgerDO deviceLedger = deviceLedgerService.getDeviceLedger(id);
|
|
|
|
|
|
|
|
|
|
|
|
DeviceLedgerRespVO respVO = BeanUtils.toBean(deviceLedger, DeviceLedgerRespVO.class);
|
|
|
|
DeviceLedgerRespVO respVO = BeanUtils.toBean(deviceLedger, DeviceLedgerRespVO.class);
|
|
|
|
|
|
|
|
respVO.setCreatorName(adminUserApi.getUser(Long.valueOf(deviceLedger.getCreator())).getNickname());
|
|
|
|
if (StringUtils.isNotBlank(respVO.getDeviceManager())) {
|
|
|
|
if (StringUtils.isNotBlank(respVO.getDeviceManager())) {
|
|
|
|
String[] userIds = respVO.getDeviceManager().split(",");
|
|
|
|
String[] userIds = respVO.getDeviceManager().split(",");
|
|
|
|
StringBuilder names = new StringBuilder();
|
|
|
|
StringBuilder names = new StringBuilder();
|
|
|
|
@ -112,6 +122,33 @@ public class DeviceLedgerController {
|
|
|
|
@PreAuthorize("@ss.hasPermission('mes:device-ledger:query')")
|
|
|
|
@PreAuthorize("@ss.hasPermission('mes:device-ledger:query')")
|
|
|
|
public CommonResult<PageResult<?>> getDeviceLedgerPage(@Valid DeviceLedgerPageReqVO pageReqVO) {
|
|
|
|
public CommonResult<PageResult<?>> getDeviceLedgerPage(@Valid DeviceLedgerPageReqVO pageReqVO) {
|
|
|
|
PageResult<DeviceLedgerDO> pageResult = deviceLedgerService.getDeviceLedgerPage(pageReqVO);
|
|
|
|
PageResult<DeviceLedgerDO> pageResult = deviceLedgerService.getDeviceLedgerPage(pageReqVO);
|
|
|
|
|
|
|
|
Set<Long> workshopIds = pageResult.getList().stream()
|
|
|
|
|
|
|
|
.map(DeviceLedgerDO::getWorkshop)
|
|
|
|
|
|
|
|
.filter(StringUtils::isNotBlank) // 使用StringUtils或手动判断
|
|
|
|
|
|
|
|
.flatMap(workshop -> {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
return Stream.of(Long.valueOf(workshop.trim()));
|
|
|
|
|
|
|
|
} catch (NumberFormatException e) {
|
|
|
|
|
|
|
|
return Stream.empty(); // 转换失败时返回空流,相当于跳过
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
.collect(Collectors.toSet());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<Long, OrganizationDO> organizationMap = organizationService.getMap(workshopIds);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 4. 设置 workshopName
|
|
|
|
|
|
|
|
for (DeviceLedgerDO item : pageResult.getList()) {
|
|
|
|
|
|
|
|
if (item.getWorkshop() != null) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
Long workshopId = Long.parseLong(item.getWorkshop().trim());
|
|
|
|
|
|
|
|
OrganizationDO org = organizationMap.get(workshopId);
|
|
|
|
|
|
|
|
if (org != null) {
|
|
|
|
|
|
|
|
item.setWorkshopName(org.getName());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (NumberFormatException e) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
return success(ResumeNameUtils.buildPageCreatorName(BeanUtils.toBean(pageResult, DeviceLedgerRespVO.class)));
|
|
|
|
return success(ResumeNameUtils.buildPageCreatorName(BeanUtils.toBean(pageResult, DeviceLedgerRespVO.class)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -123,6 +160,17 @@ public class DeviceLedgerController {
|
|
|
|
return success(deviceLedgerDOList);
|
|
|
|
return success(deviceLedgerDOList);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/noUsedlist")
|
|
|
|
|
|
|
|
@Operation(summary = "获得未关联设备台账列表")
|
|
|
|
|
|
|
|
@PreAuthorize("@ss.hasPermission('mes:device-ledger:query')")
|
|
|
|
|
|
|
|
public CommonResult<List<DeviceLedgerDO>> getDeviceLedgerListByNoUsed() {
|
|
|
|
|
|
|
|
List<DeviceLedgerDO> deviceLedgerDOList = deviceLedgerService.getDeviceLedgerList();
|
|
|
|
|
|
|
|
deviceLedgerDOList.removeIf(device ->
|
|
|
|
|
|
|
|
device.getWorkshop() != null
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
return success(deviceLedgerDOList);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/export-excel")
|
|
|
|
@GetMapping("/export-excel")
|
|
|
|
@Operation(summary = "导出设备台账 Excel")
|
|
|
|
@Operation(summary = "导出设备台账 Excel")
|
|
|
|
|