add mold record

plp
chenshuichuan 2 years ago
parent 5b86719c7c
commit 16a12628eb

@ -1,36 +1,31 @@
package cn.iocoder.yudao.module.erp.controller.admin.mold; package cn.iocoder.yudao.module.erp.controller.admin.mold;
import cn.iocoder.yudao.module.erp.dal.dataobject.mold.MoldBrandProductDO; import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
import org.springframework.web.bind.annotation.*; import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import java.util.*;
import java.io.IOException;
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;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
import cn.iocoder.yudao.module.erp.controller.admin.mold.vo.*; import cn.iocoder.yudao.module.erp.controller.admin.mold.vo.*;
import cn.iocoder.yudao.module.erp.dal.dataobject.mold.MoldBrandDO; import cn.iocoder.yudao.module.erp.dal.dataobject.mold.MoldBrandDO;
import cn.iocoder.yudao.module.erp.dal.dataobject.mold.MoldBrandProductDO;
import cn.iocoder.yudao.module.erp.dal.dataobject.mold.MoldDO; import cn.iocoder.yudao.module.erp.dal.dataobject.mold.MoldDO;
import cn.iocoder.yudao.module.erp.service.mold.MoldBrandService; import cn.iocoder.yudao.module.erp.service.mold.MoldBrandService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid; import javax.validation.Valid;
import java.io.IOException;
import java.util.List;
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Tag(name = "管理后台 - 模具型号") @Tag(name = "管理后台 - 模具型号")
@RestController @RestController
@ -73,7 +68,12 @@ public class MoldBrandController {
MoldBrandDO moldBrand = moldBrandService.getMoldBrand(id); MoldBrandDO moldBrand = moldBrandService.getMoldBrand(id);
return success(BeanUtils.toBean(moldBrand, MoldBrandRespVO.class)); return success(BeanUtils.toBean(moldBrand, MoldBrandRespVO.class));
} }
@GetMapping("/getBrandList")
@Operation(summary = "获得模具型号列表")
public CommonResult<List<MoldBrandDO>> getBrandList(MoldBrandPageReqVO pageReqVO) {
List<MoldBrandDO> brandDOList = moldBrandService.selectBy(pageReqVO);
return success(brandDOList);
}
@GetMapping("/page") @GetMapping("/page")
@Operation(summary = "获得模具型号分页") @Operation(summary = "获得模具型号分页")
@PreAuthorize("@ss.hasPermission('erp:mold-brand:query')") @PreAuthorize("@ss.hasPermission('erp:mold-brand:query')")
@ -95,7 +95,12 @@ public class MoldBrandController {
} }
// ==================== 子表(模具) ==================== // ==================== 子表(模具) ====================
@GetMapping("/getMoldList")
@Operation(summary = "获得模具型号")
public CommonResult<List<MoldDO>> getMoldList(MoldDO moldDO) {
List<MoldDO> doList = moldBrandService.selectBy(moldDO);
return success(doList);
}
@GetMapping("/mold/page") @GetMapping("/mold/page")
@Operation(summary = "获得模具分页") @Operation(summary = "获得模具分页")
@Parameter(name = "brandId", description = "型号id") @Parameter(name = "brandId", description = "型号id")

@ -1,13 +1,13 @@
package cn.iocoder.yudao.module.erp.dal.mysql.mold; package cn.iocoder.yudao.module.erp.dal.mysql.mold;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.erp.controller.admin.mold.vo.MoldBrandPageReqVO;
import cn.iocoder.yudao.module.erp.dal.dataobject.mold.MoldBrandDO; import cn.iocoder.yudao.module.erp.dal.dataobject.mold.MoldBrandDO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.erp.controller.admin.mold.vo.*;
import java.util.List;
/** /**
* Mapper * Mapper
@ -32,5 +32,19 @@ public interface MoldBrandMapper extends BaseMapperX<MoldBrandDO> {
.betweenIfPresent(MoldBrandDO::getCreateTime, reqVO.getCreateTime()) .betweenIfPresent(MoldBrandDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(MoldBrandDO::getId)); .orderByDesc(MoldBrandDO::getId));
} }
default List<MoldBrandDO> selectBy(MoldBrandPageReqVO reqVO) {
return selectList(new LambdaQueryWrapperX<MoldBrandDO>()
.eqIfPresent(MoldBrandDO::getCode, reqVO.getCode())
.likeIfPresent(MoldBrandDO::getName, reqVO.getName())
.eqIfPresent(MoldBrandDO::getMoldType, reqVO.getMoldType())
.eqIfPresent(MoldBrandDO::getProductId, reqVO.getProductId())
.eqIfPresent(MoldBrandDO::getUseTime, reqVO.getUseTime())
.eqIfPresent(MoldBrandDO::getMaintainType, reqVO.getMaintainType())
.eqIfPresent(MoldBrandDO::getMaintainTime, reqVO.getMaintainTime())
.eqIfPresent(MoldBrandDO::getMoldSize, reqVO.getMoldSize())
.eqIfPresent(MoldBrandDO::getRemark, reqVO.getRemark())
.eqIfPresent(MoldBrandDO::getIsEnable, reqVO.getIsEnable())
.betweenIfPresent(MoldBrandDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(MoldBrandDO::getId));
}
} }

@ -1,14 +1,14 @@
package cn.iocoder.yudao.module.erp.dal.mysql.mold; package cn.iocoder.yudao.module.erp.dal.mysql.mold;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam; import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.erp.dal.dataobject.mold.MoldDO; import cn.iocoder.yudao.module.erp.dal.dataobject.mold.MoldDO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/** /**
* Mapper * Mapper
* *
@ -26,5 +26,11 @@ public interface MoldMapper extends BaseMapperX<MoldDO> {
default int deleteByBrandId(Long brandId) { default int deleteByBrandId(Long brandId) {
return delete(MoldDO::getBrandId, brandId); return delete(MoldDO::getBrandId, brandId);
} }
default List<MoldDO> selectBy(MoldDO reqVO) {
return selectList(new LambdaQueryWrapperX<MoldDO>()
.eqIfPresent(MoldDO::getCode, reqVO.getCode())
.likeIfPresent(MoldDO::getName, reqVO.getName())
.eq(MoldDO::getBrandId, reqVO.getBrandId())
.orderByDesc(MoldDO::getId));
}
} }

@ -1,14 +1,19 @@
package cn.iocoder.yudao.module.erp.service.mold; package cn.iocoder.yudao.module.erp.service.mold;
import java.util.*; import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.iocoder.yudao.module.erp.controller.admin.mold.vo.*; import cn.iocoder.yudao.module.erp.controller.admin.mold.vo.*;
import cn.iocoder.yudao.module.erp.dal.dataobject.mold.MoldBrandDO; import cn.iocoder.yudao.module.erp.dal.dataobject.mold.MoldBrandDO;
import cn.iocoder.yudao.module.erp.dal.dataobject.mold.MoldBrandProductDO; import cn.iocoder.yudao.module.erp.dal.dataobject.mold.MoldBrandProductDO;
import cn.iocoder.yudao.module.erp.dal.dataobject.mold.MoldDO; import cn.iocoder.yudao.module.erp.dal.dataobject.mold.MoldDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import javax.validation.Valid; import javax.validation.Valid;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** /**
* Service * Service
@ -46,7 +51,7 @@ public interface MoldBrandService {
* @return * @return
*/ */
MoldBrandDO getMoldBrand(Long id); MoldBrandDO getMoldBrand(Long id);
List<MoldBrandDO> selectBy(MoldBrandPageReqVO reqVO);
/** /**
* *
* *
@ -54,7 +59,13 @@ public interface MoldBrandService {
* @return * @return
*/ */
PageResult<MoldBrandRespVO> getMoldBrandPage(MoldBrandPageReqVO pageReqVO); PageResult<MoldBrandRespVO> getMoldBrandPage(MoldBrandPageReqVO pageReqVO);
default Map<Long, MoldBrandDO> getMap(Collection<Long> ids) {
if (CollUtil.isEmpty(ids)) {
return new HashMap<>();
}
return CollectionUtils.convertMap(getList(ids), MoldBrandDO::getId);
}
List<MoldBrandDO> getList(Collection<Long> ids);
// ==================== 子表(模具) ==================== // ==================== 子表(模具) ====================
/** /**
@ -95,7 +106,7 @@ public interface MoldBrandService {
* @return * @return
*/ */
MoldDO getMold(Long id); MoldDO getMold(Long id);
List<MoldDO> selectBy(MoldDO reqVO);
// ==================== 子表(模具产品) ==================== // ==================== 子表(模具产品) ====================
/** /**

@ -1,32 +1,30 @@
package cn.iocoder.yudao.module.erp.service.mold; package cn.iocoder.yudao.module.erp.service.mold;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.collection.MapUtils; import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO; import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.erp.controller.admin.mold.vo.*;
import cn.iocoder.yudao.module.erp.dal.dataobject.mold.MoldBrandDO;
import cn.iocoder.yudao.module.erp.dal.dataobject.mold.MoldBrandProductDO; import cn.iocoder.yudao.module.erp.dal.dataobject.mold.MoldBrandProductDO;
import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductCategoryDO; import cn.iocoder.yudao.module.erp.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.erp.dal.dataobject.product.ErpProductUnitDO; import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductUnitDO;
import cn.iocoder.yudao.module.erp.dal.mysql.mold.MoldBrandMapper;
import cn.iocoder.yudao.module.erp.dal.mysql.mold.MoldBrandProductMapper; import cn.iocoder.yudao.module.erp.dal.mysql.mold.MoldBrandProductMapper;
import cn.iocoder.yudao.module.erp.dal.mysql.mold.MoldMapper;
import cn.iocoder.yudao.module.erp.service.product.ErpProductService; import cn.iocoder.yudao.module.erp.service.product.ErpProductService;
import cn.iocoder.yudao.module.erp.service.product.ErpProductUnitService; import cn.iocoder.yudao.module.erp.service.product.ErpProductUnitService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import java.util.*;
import cn.iocoder.yudao.module.erp.controller.admin.mold.vo.*;
import cn.iocoder.yudao.module.erp.dal.dataobject.mold.MoldBrandDO;
import cn.iocoder.yudao.module.erp.dal.dataobject.mold.MoldDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.erp.dal.mysql.mold.MoldBrandMapper;
import cn.iocoder.yudao.module.erp.dal.mysql.mold.MoldMapper;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
@ -89,7 +87,10 @@ public class MoldBrandServiceImpl implements MoldBrandService {
public MoldBrandDO getMoldBrand(Long id) { public MoldBrandDO getMoldBrand(Long id) {
return moldBrandMapper.selectById(id); return moldBrandMapper.selectById(id);
} }
@Override
public List<MoldBrandDO> selectBy(MoldBrandPageReqVO reqVO){
return moldBrandMapper.selectBy(reqVO);
}
@Override @Override
public PageResult<MoldBrandRespVO> getMoldBrandPage(MoldBrandPageReqVO pageReqVO) { public PageResult<MoldBrandRespVO> getMoldBrandPage(MoldBrandPageReqVO pageReqVO) {
PageResult<MoldBrandDO> pageResult = moldBrandMapper.selectPage(pageReqVO); PageResult<MoldBrandDO> pageResult = moldBrandMapper.selectPage(pageReqVO);
@ -106,6 +107,10 @@ public class MoldBrandServiceImpl implements MoldBrandService {
product -> item.setProductName(product.getName())); product -> item.setProductName(product.getName()));
}); });
} }
@Override
public List<MoldBrandDO> getList(Collection<Long> ids) {
return moldBrandMapper.selectBatchIds(ids);
}
// ==================== 子表(模具) ==================== // ==================== 子表(模具) ====================
@Override @Override
@ -151,7 +156,10 @@ public class MoldBrandServiceImpl implements MoldBrandService {
public MoldDO getMold(Long id) { public MoldDO getMold(Long id) {
return moldMapper.selectById(id); return moldMapper.selectById(id);
} }
@Override
public List<MoldDO> selectBy(MoldDO reqVO){
return moldMapper.selectBy(reqVO);
}
private void validateMoldExists(Long id) { private void validateMoldExists(Long id) {
if (moldMapper.selectById(id) == null) { if (moldMapper.selectById(id) == null) {
throw exception(MOLD_NOT_EXISTS); throw exception(MOLD_NOT_EXISTS);

@ -1,11 +1,17 @@
package cn.iocoder.yudao.module.erp.service.mold; package cn.iocoder.yudao.module.erp.service.mold;
import java.util.*; import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.module.erp.controller.admin.mold.vo.*;
import cn.iocoder.yudao.module.erp.dal.dataobject.mold.MoldDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.iocoder.yudao.module.erp.controller.admin.mold.vo.MoldPageReqVO;
import cn.iocoder.yudao.module.erp.controller.admin.mold.vo.MoldSaveReqVO;
import cn.iocoder.yudao.module.erp.dal.dataobject.mold.MoldDO;
import javax.validation.Valid; import javax.validation.Valid;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** /**
* Service * Service
@ -51,5 +57,11 @@ public interface MoldService {
* @return * @return
*/ */
PageResult<MoldDO> getMoldPage(MoldPageReqVO pageReqVO); PageResult<MoldDO> getMoldPage(MoldPageReqVO pageReqVO);
List<MoldDO> getList(Collection<Long> ids);
default Map<Long, MoldDO> getMap(Collection<Long> ids) {
if (CollUtil.isEmpty(ids)) {
return new HashMap<>();
}
return CollectionUtils.convertMap(getList(ids), MoldDO::getId);
}
} }

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.erp.service.mold; package cn.iocoder.yudao.module.erp.service.mold;
import cn.iocoder.yudao.module.erp.dal.dataobject.mold.MoldBrandDO;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -71,5 +72,8 @@ public class MoldServiceImpl implements MoldService {
public PageResult<MoldDO> getMoldPage(MoldPageReqVO pageReqVO) { public PageResult<MoldDO> getMoldPage(MoldPageReqVO pageReqVO) {
return moldMapper.selectPage(pageReqVO, pageReqVO.getBrandId()); return moldMapper.selectPage(pageReqVO, pageReqVO.getBrandId());
} }
@Override
public List<MoldDO> getList(Collection<Long> ids) {
return moldMapper.selectBatchIds(ids);
}
} }

@ -71,7 +71,6 @@ public class MachineComponentController {
@GetMapping("/list") @GetMapping("/list")
@Operation(summary = "获得机台列表") @Operation(summary = "获得机台列表")
@PreAuthorize("@ss.hasPermission('mes:machine-component:query')")
public CommonResult<List<MachineComponentRespVO>> getMachineComponentList(@Valid MachineComponentListReqVO listReqVO) { public CommonResult<List<MachineComponentRespVO>> getMachineComponentList(@Valid MachineComponentListReqVO listReqVO) {
List<MachineComponentDO> list = machineComponentService.getMachineComponentList(listReqVO); List<MachineComponentDO> list = machineComponentService.getMachineComponentList(listReqVO);
return success(BeanUtils.toBean(list, MachineComponentRespVO.class)); return success(BeanUtils.toBean(list, MachineComponentRespVO.class));
@ -98,5 +97,4 @@ public class MachineComponentController {
ExcelUtils.write(response, "机台.xls", "数据", MachineComponentRespVO.class, ExcelUtils.write(response, "机台.xls", "数据", MachineComponentRespVO.class,
BeanUtils.toBean(list, MachineComponentRespVO.class)); BeanUtils.toBean(list, MachineComponentRespVO.class));
} }
} }

@ -75,7 +75,8 @@ public class MoldRecordController {
@PreAuthorize("@ss.hasPermission('mes:mold-record:query')") @PreAuthorize("@ss.hasPermission('mes:mold-record:query')")
public CommonResult<PageResult<MoldRecordRespVO>> getMoldRecordPage(@Valid MoldRecordPageReqVO pageReqVO) { public CommonResult<PageResult<MoldRecordRespVO>> getMoldRecordPage(@Valid MoldRecordPageReqVO pageReqVO) {
PageResult<MoldRecordDO> pageResult = moldRecordService.getMoldRecordPage(pageReqVO); PageResult<MoldRecordDO> pageResult = moldRecordService.getMoldRecordPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, MoldRecordRespVO.class)); List<MoldRecordRespVO> list = moldRecordService.buildVOList(pageResult.getList());
return success(new PageResult<>(list,pageResult.getTotal()));
} }
@GetMapping("/export-excel") @GetMapping("/export-excel")
@ -86,9 +87,10 @@ public class MoldRecordController {
HttpServletResponse response) throws IOException { HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<MoldRecordDO> list = moldRecordService.getMoldRecordPage(pageReqVO).getList(); List<MoldRecordDO> list = moldRecordService.getMoldRecordPage(pageReqVO).getList();
// 导出 Excel // 导出 Excel
ExcelUtils.write(response, "模具维保.xls", "数据", MoldRecordRespVO.class, ExcelUtils.write(response, "模具维保.xls", "数据", MoldRecordRespVO.class,
BeanUtils.toBean(list, MoldRecordRespVO.class)); moldRecordService.buildVOList(list));
} }
// ==================== 子表(模具维保明细) ==================== // ==================== 子表(模具维保明细) ====================
@ -101,4 +103,12 @@ public class MoldRecordController {
return success(moldRecordService.getMoldRecordSubjectDetailListByRecordId(recordId)); return success(moldRecordService.getMoldRecordSubjectDetailListByRecordId(recordId));
} }
@GetMapping("/updateStatus")
@Operation(summary = "更新模具维保状态")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('mes:mold-record:update')")
public CommonResult<MoldRecordRespVO> updateStatus(@RequestParam("id") Long id, @RequestParam("status")String status) {
MoldRecordDO moldRecord = moldRecordService.getMoldRecord(id);
return success(BeanUtils.toBean(moldRecord, MoldRecordRespVO.class));
}
} }

@ -25,24 +25,38 @@ public class MoldRecordRespVO {
private String flowCode; private String flowCode;
@Schema(description = "模具型号ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "17427") @Schema(description = "模具型号ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "17427")
@ExcelProperty("模具型号ID")
private Long brandId; private Long brandId;
@Schema(description = "模具型号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17427")
@ExcelProperty("模具型号")
private String brandName;
@Schema(description = "规格", requiredMode = Schema.RequiredMode.REQUIRED, example = "17427")
@ExcelProperty("规格")
private String brandType;
@Schema(description = "模具ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "21232") @Schema(description = "模具ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "21232")
@ExcelProperty("模具ID")
private Long moldId; private Long moldId;
@Schema(description = "模具", requiredMode = Schema.RequiredMode.REQUIRED, example = "21232")
@ExcelProperty("模具")
private String moldName;
@Schema(description = "前模具ID", example = "23487") @Schema(description = "前模具ID", example = "23487")
@ExcelProperty("前模具ID")
private Long oldMoldId; private Long oldMoldId;
@Schema(description = "前模具", example = "23487")
@ExcelProperty("前模具")
private String oldMoldName;
@Schema(description = "机台ID", example = "1825") @Schema(description = "机台ID", example = "1825")
@ExcelProperty("机台ID") @ExcelProperty("机台ID")
private Long machineId; private Long machineId;
@Schema(description = "机台", example = "1825")
@ExcelProperty("机台")
private String machineName;
@Schema(description = "负责人ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "27306") @Schema(description = "负责人ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "27306")
@ExcelProperty("负责人ID")
private Long userId; private Long userId;
@Schema(description = "负责人", requiredMode = Schema.RequiredMode.REQUIRED, example = "27306")
@ExcelProperty("负责人")
private String userName;
@Schema(description = "单据类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") @Schema(description = "单据类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@ExcelProperty(value = "单据类型", converter = DictConvert.class) @ExcelProperty(value = "单据类型", converter = DictConvert.class)

@ -43,11 +43,9 @@ public class MoldRecordSaveReqVO {
private String recordType; private String recordType;
@Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@NotEmpty(message = "状态不能为空")
private String recordStatus; private String recordStatus;
@Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜") @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜")
@NotEmpty(message = "备注不能为空")
private String remark; private String remark;
@Schema(description = "模具维保明细列表") @Schema(description = "模具维保明细列表")

@ -89,5 +89,10 @@ public class MoldRecordSubjectController {
ExcelUtils.write(response, "维保项目.xls", "数据", MoldRecordSubjectRespVO.class, ExcelUtils.write(response, "维保项目.xls", "数据", MoldRecordSubjectRespVO.class,
BeanUtils.toBean(list, MoldRecordSubjectRespVO.class)); BeanUtils.toBean(list, MoldRecordSubjectRespVO.class));
} }
@GetMapping("/getList")
@Operation(summary = "获得维保项目列表")
public CommonResult<List<MoldRecordSubjectDO>> getList(MoldRecordSubjectPageReqVO pageReqVO) {
List<MoldRecordSubjectDO> list = moldRecordSubjectService.selectBy(pageReqVO);
return success(list);
}
} }

@ -1,13 +1,13 @@
package cn.iocoder.yudao.module.mes.dal.mysql.moldrecordsubject; package cn.iocoder.yudao.module.mes.dal.mysql.moldrecordsubject;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.mes.controller.admin.moldrecordsubject.vo.MoldRecordSubjectPageReqVO;
import cn.iocoder.yudao.module.mes.dal.dataobject.moldrecordsubject.MoldRecordSubjectDO; import cn.iocoder.yudao.module.mes.dal.dataobject.moldrecordsubject.MoldRecordSubjectDO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.mes.controller.admin.moldrecordsubject.vo.*;
import java.util.List;
/** /**
* Mapper * Mapper
@ -23,5 +23,10 @@ public interface MoldRecordSubjectMapper extends BaseMapperX<MoldRecordSubjectDO
.eqIfPresent(MoldRecordSubjectDO::getExpect, reqVO.getExpect()) .eqIfPresent(MoldRecordSubjectDO::getExpect, reqVO.getExpect())
.orderByDesc(MoldRecordSubjectDO::getId)); .orderByDesc(MoldRecordSubjectDO::getId));
} }
default List<MoldRecordSubjectDO> selectBy(MoldRecordSubjectPageReqVO reqVO) {
return selectList(new LambdaQueryWrapperX<MoldRecordSubjectDO>()
.eqIfPresent(MoldRecordSubjectDO::getSubject, reqVO.getSubject())
.eqIfPresent(MoldRecordSubjectDO::getExpect, reqVO.getExpect())
.orderByDesc(MoldRecordSubjectDO::getId));
}
} }

@ -26,6 +26,7 @@ public class MesNoRedisDAO {
* {@link cn.iocoder.yudao.module.erp.dal.dataobject.mold.MoldDO} * {@link cn.iocoder.yudao.module.erp.dal.dataobject.mold.MoldDO}
*/ */
public static final String MOLD_NO_PREFIX = "MUJU-"; public static final String MOLD_NO_PREFIX = "MUJU-";
public static final String MOLD_RECORD_NO_PREFIX = "MR-";
/** /**
* {@link cn.iocoder.yudao.module.mes.dal.dataobject.task.TaskDO} * {@link cn.iocoder.yudao.module.mes.dal.dataobject.task.TaskDO}
*/ */

@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.mes.service.moldrecord;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.mes.controller.admin.moldrecord.vo.MoldRecordPageReqVO; import cn.iocoder.yudao.module.mes.controller.admin.moldrecord.vo.MoldRecordPageReqVO;
import cn.iocoder.yudao.module.mes.controller.admin.moldrecord.vo.MoldRecordRespVO;
import cn.iocoder.yudao.module.mes.controller.admin.moldrecord.vo.MoldRecordSaveReqVO; import cn.iocoder.yudao.module.mes.controller.admin.moldrecord.vo.MoldRecordSaveReqVO;
import cn.iocoder.yudao.module.mes.dal.dataobject.moldrecord.MoldRecordDO; import cn.iocoder.yudao.module.mes.dal.dataobject.moldrecord.MoldRecordDO;
import cn.iocoder.yudao.module.mes.dal.dataobject.moldrecord.MoldRecordSubjectDetailDO; import cn.iocoder.yudao.module.mes.dal.dataobject.moldrecord.MoldRecordSubjectDetailDO;
@ -53,7 +54,7 @@ public interface MoldRecordService {
* @return * @return
*/ */
PageResult<MoldRecordDO> getMoldRecordPage(MoldRecordPageReqVO pageReqVO); PageResult<MoldRecordDO> getMoldRecordPage(MoldRecordPageReqVO pageReqVO);
List<MoldRecordRespVO> buildVOList(List<MoldRecordDO> list);
// ==================== 子表(模具维保明细) ==================== // ==================== 子表(模具维保明细) ====================
/** /**

@ -1,21 +1,40 @@
package cn.iocoder.yudao.module.mes.service.moldrecord; package cn.iocoder.yudao.module.mes.service.moldrecord;
import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.erp.dal.dataobject.mold.MoldBrandDO;
import cn.iocoder.yudao.module.erp.dal.dataobject.mold.MoldDO;
import cn.iocoder.yudao.module.erp.service.mold.MoldBrandService;
import cn.iocoder.yudao.module.erp.service.mold.MoldService;
import cn.iocoder.yudao.module.mes.controller.admin.moldrecord.vo.MoldRecordPageReqVO; import cn.iocoder.yudao.module.mes.controller.admin.moldrecord.vo.MoldRecordPageReqVO;
import cn.iocoder.yudao.module.mes.controller.admin.moldrecord.vo.MoldRecordRespVO;
import cn.iocoder.yudao.module.mes.controller.admin.moldrecord.vo.MoldRecordSaveReqVO; import cn.iocoder.yudao.module.mes.controller.admin.moldrecord.vo.MoldRecordSaveReqVO;
import cn.iocoder.yudao.module.mes.controller.admin.plan.vo.PlanRespVO;
import cn.iocoder.yudao.module.mes.dal.dataobject.machine.MachineComponentDO;
import cn.iocoder.yudao.module.mes.dal.dataobject.moldrecord.MoldRecordDO; import cn.iocoder.yudao.module.mes.dal.dataobject.moldrecord.MoldRecordDO;
import cn.iocoder.yudao.module.mes.dal.dataobject.moldrecord.MoldRecordSubjectDetailDO; import cn.iocoder.yudao.module.mes.dal.dataobject.moldrecord.MoldRecordSubjectDetailDO;
import cn.iocoder.yudao.module.mes.dal.dataobject.plan.PlanDO;
import cn.iocoder.yudao.module.mes.dal.dataobject.task.TaskDO;
import cn.iocoder.yudao.module.mes.dal.mysql.moldrecord.MoldRecordMapper; import cn.iocoder.yudao.module.mes.dal.mysql.moldrecord.MoldRecordMapper;
import cn.iocoder.yudao.module.mes.dal.mysql.moldrecord.MoldRecordSubjectDetailMapper; import cn.iocoder.yudao.module.mes.dal.mysql.moldrecord.MoldRecordSubjectDetailMapper;
import cn.iocoder.yudao.module.mes.dal.redis.no.MesNoRedisDAO;
import cn.iocoder.yudao.module.mes.service.machine.MachineComponentService;
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.MOLD_RECORD_NOT_EXISTS; import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.MOLD_RECORD_NOT_EXISTS;
/** /**
@ -31,16 +50,24 @@ public class MoldRecordServiceImpl implements MoldRecordService {
private MoldRecordMapper moldRecordMapper; private MoldRecordMapper moldRecordMapper;
@Resource @Resource
private MoldRecordSubjectDetailMapper moldRecordSubjectDetailMapper; private MoldRecordSubjectDetailMapper moldRecordSubjectDetailMapper;
@Resource
private MesNoRedisDAO noRedisDAO;
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Long createMoldRecord(MoldRecordSaveReqVO createReqVO) { public Long createMoldRecord(MoldRecordSaveReqVO createReqVO) {
// 插入 // 插入
MoldRecordDO moldRecord = BeanUtils.toBean(createReqVO, MoldRecordDO.class); MoldRecordDO moldRecord = BeanUtils.toBean(createReqVO, MoldRecordDO.class);
moldRecord.setRecordStatus("草稿");
if (StringUtils.isEmpty(moldRecord.getCode())) {
String no = noRedisDAO.generate3(MesNoRedisDAO.MOLD_RECORD_NO_PREFIX);
moldRecord.setCode(no);
}
moldRecordMapper.insert(moldRecord); moldRecordMapper.insert(moldRecord);
// 插入子表 // 插入子表
createMoldRecordSubjectDetailList(moldRecord.getId(), createReqVO.getMoldRecordSubjectDetails()); if(createReqVO.getMoldRecordSubjectDetails()!=null && createReqVO.getMoldRecordSubjectDetails().size()>0)
createMoldRecordSubjectDetailList(moldRecord.getId(), createReqVO.getMoldRecordSubjectDetails());
// 返回 // 返回
return moldRecord.getId(); return moldRecord.getId();
} }
@ -85,7 +112,45 @@ public class MoldRecordServiceImpl implements MoldRecordService {
public PageResult<MoldRecordDO> getMoldRecordPage(MoldRecordPageReqVO pageReqVO) { public PageResult<MoldRecordDO> getMoldRecordPage(MoldRecordPageReqVO pageReqVO) {
return moldRecordMapper.selectPage(pageReqVO); return moldRecordMapper.selectPage(pageReqVO);
} }
@Resource
private AdminUserService userService;
@Resource
private MoldBrandService moldBrandService;
@Resource
private MoldService moldService;
@Resource
private MachineComponentService machineComponentService;
@Override
public List<MoldRecordRespVO> buildVOList(List<MoldRecordDO> list) {
if (CollUtil.isEmpty(list)) {
return Collections.emptyList();
}
Map<Long, AdminUserDO> userMap = userService.getUserMap(
convertSet(list, MoldRecordDO::getUserId));
Map<Long, MoldBrandDO> brandMap = moldBrandService.getMap(
convertSet(list, MoldRecordDO::getBrandId));
Map<Long, MoldDO> moldMap = moldService.getMap(
convertSet(list, MoldRecordDO::getMoldId));
Map<Long, MachineComponentDO> machineMap = machineComponentService.getMap(
convertSet(list, MoldRecordDO::getMachineId));
return BeanUtils.toBean(list, MoldRecordRespVO.class, item -> {
MapUtils.findAndThen(userMap, item.getUserId(),
user -> item.setUserName(user.getNickname()));
MapUtils.findAndThen(brandMap, item.getBrandId(),
brand -> item.setBrandName(brand.getName()).setBrandType(brand.getMoldType()));
MapUtils.findAndThen(moldMap, item.getMoldId(),
mold -> item.setMoldName(mold.getName()));
MapUtils.findAndThen(machineMap, item.getMachineId(),
ma -> item.setMachineName(ma.getName()));
});
}
// ==================== 子表(模具维保明细) ==================== // ==================== 子表(模具维保明细) ====================
@Override @Override

@ -6,6 +6,7 @@ import cn.iocoder.yudao.module.mes.controller.admin.moldrecordsubject.vo.MoldRec
import cn.iocoder.yudao.module.mes.dal.dataobject.moldrecordsubject.MoldRecordSubjectDO; import cn.iocoder.yudao.module.mes.dal.dataobject.moldrecordsubject.MoldRecordSubjectDO;
import javax.validation.Valid; import javax.validation.Valid;
import java.util.List;
/** /**
* Service * Service
@ -51,5 +52,5 @@ public interface MoldRecordSubjectService {
* @return * @return
*/ */
PageResult<MoldRecordSubjectDO> getMoldRecordSubjectPage(MoldRecordSubjectPageReqVO pageReqVO); PageResult<MoldRecordSubjectDO> getMoldRecordSubjectPage(MoldRecordSubjectPageReqVO pageReqVO);
List<MoldRecordSubjectDO> selectBy(MoldRecordSubjectPageReqVO reqVO);
} }

@ -11,6 +11,8 @@ import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.MOLD_RECORD_SUBJECT_NOT_EXISTS; import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.MOLD_RECORD_SUBJECT_NOT_EXISTS;
@ -67,5 +69,8 @@ public class MoldRecordSubjectServiceImpl implements MoldRecordSubjectService {
public PageResult<MoldRecordSubjectDO> getMoldRecordSubjectPage(MoldRecordSubjectPageReqVO pageReqVO) { public PageResult<MoldRecordSubjectDO> getMoldRecordSubjectPage(MoldRecordSubjectPageReqVO pageReqVO) {
return moldRecordSubjectMapper.selectPage(pageReqVO); return moldRecordSubjectMapper.selectPage(pageReqVO);
} }
@Override
public List<MoldRecordSubjectDO> selectBy(MoldRecordSubjectPageReqVO reqVO){
return moldRecordSubjectMapper.selectBy(reqVO);
}
} }
Loading…
Cancel
Save