|
|
|
@ -1,5 +1,7 @@
|
|
|
|
package cn.iocoder.yudao.module.mes.controller.admin.zjitem;
|
|
|
|
package cn.iocoder.yudao.module.mes.controller.admin.zjitem;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductUnitDO;
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.dataobject.deviceledger.DeviceLedgerDO;
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.dataobject.deviceledger.DeviceLedgerDO;
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
|
|
|
|
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
|
|
|
|
@ -20,6 +22,7 @@ import javax.validation.*;
|
|
|
|
import javax.servlet.http.*;
|
|
|
|
import javax.servlet.http.*;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.*;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
@ -37,6 +40,9 @@ import cn.iocoder.yudao.module.mes.controller.admin.zjitem.vo.*;
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.dataobject.zjitem.ZjItemDO;
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.dataobject.zjitem.ZjItemDO;
|
|
|
|
import cn.iocoder.yudao.module.mes.service.zjitem.ZjItemService;
|
|
|
|
import cn.iocoder.yudao.module.mes.service.zjitem.ZjItemService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO;
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.module.erp.service.product.ErpProductUnitService;
|
|
|
|
|
|
|
|
|
|
|
|
@Tag(name = "管理后台 - 质量管理-检验项目")
|
|
|
|
@Tag(name = "管理后台 - 质量管理-检验项目")
|
|
|
|
@RestController
|
|
|
|
@RestController
|
|
|
|
@RequestMapping("/mes/zj-item")
|
|
|
|
@RequestMapping("/mes/zj-item")
|
|
|
|
@ -47,6 +53,8 @@ public class ZjItemController {
|
|
|
|
private ZjItemService zjItemService;
|
|
|
|
private ZjItemService zjItemService;
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private ZjTypeService zjTypeService;
|
|
|
|
private ZjTypeService zjTypeService;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
private ErpProductUnitService productUnitService;
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/create")
|
|
|
|
@PostMapping("/create")
|
|
|
|
@Operation(summary = "创建质量管理-检验项目")
|
|
|
|
@Operation(summary = "创建质量管理-检验项目")
|
|
|
|
@ -88,14 +96,34 @@ public class ZjItemController {
|
|
|
|
PageResult<ZjItemDO> pageResult = zjItemService.getZjItemPage(pageReqVO);
|
|
|
|
PageResult<ZjItemDO> pageResult = zjItemService.getZjItemPage(pageReqVO);
|
|
|
|
return success(new PageResult<>(buildVOList(pageResult.getList()), pageResult.getTotal()));
|
|
|
|
return success(new PageResult<>(buildVOList(pageResult.getList()), pageResult.getTotal()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private List<ZjItemRespVO> buildVOList(List<ZjItemDO> list) {
|
|
|
|
private List<ZjItemRespVO> buildVOList(List<ZjItemDO> list) {
|
|
|
|
if (CollUtil.isEmpty(list)) {
|
|
|
|
if (CollUtil.isEmpty(list)) {
|
|
|
|
return Collections.emptyList();
|
|
|
|
return Collections.emptyList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Map<Long, ZjTypeDO> zjTypeMap = zjTypeService.getZjTypeVOMap(
|
|
|
|
Map<Long, ZjTypeDO> zjTypeMap = zjTypeService.getZjTypeVOMap(
|
|
|
|
convertSet(list, ZjItemDO::getZjType));
|
|
|
|
convertSet(list, ZjItemDO::getZjType));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<ErpProductUnitDO> unitDOList = productUnitService.getProductUnitListByStatus(CommonStatusEnum.ENABLE.getStatus());
|
|
|
|
|
|
|
|
// 转换为 ID -> 名称 的映射(key是单位ID,value是单位名称)
|
|
|
|
|
|
|
|
Map<String, String> unitNameMap = unitDOList.stream()
|
|
|
|
|
|
|
|
.collect(Collectors.toMap(
|
|
|
|
|
|
|
|
unit -> String.valueOf(unit.getId()),
|
|
|
|
|
|
|
|
ErpProductUnitDO::getName,
|
|
|
|
|
|
|
|
(k1, k2) -> k1
|
|
|
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 3. 转换DO到VO,同时赋值两个名称字段
|
|
|
|
return BeanUtils.toBean(list, ZjItemRespVO.class, item -> {
|
|
|
|
return BeanUtils.toBean(list, ZjItemRespVO.class, item -> {
|
|
|
|
|
|
|
|
// 原有:设置质检类型名称
|
|
|
|
MapUtils.findAndThen(zjTypeMap, item.getZjType(), zjType -> item.setZjTypeName(zjType.getName()));
|
|
|
|
MapUtils.findAndThen(zjTypeMap, item.getZjType(), zjType -> item.setZjTypeName(zjType.getName()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 新增:设置单位名称(容错处理:空值/无映射时显示空字符串)
|
|
|
|
|
|
|
|
if (item.getUnit() != null) {
|
|
|
|
|
|
|
|
String unitName = unitNameMap.getOrDefault(item.getUnit(), "");
|
|
|
|
|
|
|
|
item.setUnitName(unitName);
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -115,9 +143,9 @@ public class ZjItemController {
|
|
|
|
HttpServletResponse response) throws IOException {
|
|
|
|
HttpServletResponse response) throws IOException {
|
|
|
|
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
|
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
|
List<ZjItemDO> list = zjItemService.getZjItemPage(pageReqVO).getList();
|
|
|
|
List<ZjItemDO> list = zjItemService.getZjItemPage(pageReqVO).getList();
|
|
|
|
|
|
|
|
List<ZjItemRespVO> voList = buildVOList(list);
|
|
|
|
// 导出 Excel
|
|
|
|
// 导出 Excel
|
|
|
|
ExcelUtils.write(response, "质量管理-检验项目.xls", "数据", ZjItemRespVO.class,
|
|
|
|
ExcelUtils.write(response, "质量管理-检验项目.xls", "数据", ZjItemRespVO.class, voList);
|
|
|
|
BeanUtils.toBean(list, ZjItemRespVO.class));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|