fix:添加子模具压网时间

main
HuangHuiKang 2 weeks ago
parent ce82871a5f
commit 7f0a1f8852

@ -102,4 +102,16 @@ public class MoldRespVO {
@ExcelProperty("附件地址") @ExcelProperty("附件地址")
private String fileUrl; private String fileUrl;
@Schema(description = "压网时间")
@ExcelProperty("压网时间")
private LocalDateTime pressureNetTime;
@Schema(description = "压网天数")
@ExcelProperty("压网天数")
private Long pressureNetDays;
} }

@ -190,6 +190,7 @@ public interface ErrorCodeConstants {
ErrorCode MOLD_BRAND_CODE_EMPTY = new ErrorCode(1_003_000_007, "模具品牌编码不能为空"); ErrorCode MOLD_BRAND_CODE_EMPTY = new ErrorCode(1_003_000_007, "模具品牌编码不能为空");
// ========== 模具组相关 1_112_000 ========== // ========== 模具组相关 1_112_000 ==========
ErrorCode MOLD_SET_NOT_EXISTS = new ErrorCode(1_112_001, "模具组不存在"); ErrorCode MOLD_SET_NOT_EXISTS = new ErrorCode(1_112_001, "模具组不存在");
ErrorCode MOLD_PRESSURE_NET_RECORD_NOT_EXISTS = new ErrorCode(1_112_002, "子模具压网记录不存在");
ErrorCode MOLD_SET_CODE_EMPTY = new ErrorCode(1_003_000_005, "模具组编码不能为空"); ErrorCode MOLD_SET_CODE_EMPTY = new ErrorCode(1_003_000_005, "模具组编码不能为空");

@ -0,0 +1,98 @@
package cn.iocoder.yudao.module.erp.controller.admin.mold;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.module.erp.controller.admin.mold.vo.MoldPressureNetRecordPageReqVO;
import cn.iocoder.yudao.module.erp.controller.admin.mold.vo.MoldPressureNetRecordRespVO;
import cn.iocoder.yudao.module.erp.controller.admin.mold.vo.MoldPressureNetRecordSaveReqVO;
import cn.iocoder.yudao.module.erp.dal.dataobject.mold.MoldPressureNetRecordDO;
import cn.iocoder.yudao.module.erp.service.mold.MoldPressureNetRecordService;
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.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
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;
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
@Tag(name = "管理后台 - 子模具压网记录")
@RestController
@RequestMapping("/erp/mold-pressure-net-record")
@Validated
public class MoldPressureNetRecordController {
@Resource
private MoldPressureNetRecordService moldPressureNetRecordService;
@PostMapping("/create")
@Operation(summary = "创建子模具压网记录")
@PreAuthorize("@ss.hasPermission('erp:mold-brand:create')")
public CommonResult<Long> createMoldPressureNetRecord(@Valid @RequestBody MoldPressureNetRecordSaveReqVO createReqVO) {
return success(moldPressureNetRecordService.createMoldPressureNetRecord(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新子模具压网记录")
@PreAuthorize("@ss.hasPermission('erp:mold-brand:update')")
public CommonResult<Boolean> updateMoldPressureNetRecord(@Valid @RequestBody MoldPressureNetRecordSaveReqVO updateReqVO) {
moldPressureNetRecordService.updateMoldPressureNetRecord(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除子模具压网记录")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('erp:mold-brand:delete')")
public CommonResult<Boolean> deleteMoldPressureNetRecord(@RequestParam("id") Long id) {
moldPressureNetRecordService.deleteMoldPressureNetRecord(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得子模具压网记录")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('erp:mold-brand:query')")
public CommonResult<MoldPressureNetRecordRespVO> getMoldPressureNetRecord(@RequestParam("id") Long id) {
MoldPressureNetRecordDO record = moldPressureNetRecordService.getMoldPressureNetRecord(id);
return success(BeanUtils.toBean(record, MoldPressureNetRecordRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得子模具压网记录分页")
@PreAuthorize("@ss.hasPermission('erp:mold-brand:query')")
public CommonResult<PageResult<MoldPressureNetRecordRespVO>> getMoldPressureNetRecordPage(@Valid MoldPressureNetRecordPageReqVO pageReqVO) {
PageResult<MoldPressureNetRecordDO> pageResult = moldPressureNetRecordService.getMoldPressureNetRecordPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, MoldPressureNetRecordRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出子模具压网记录 Excel")
@PreAuthorize("@ss.hasPermission('erp:mold-brand:query')")
@ApiAccessLog(operateType = EXPORT)
public void exportMoldPressureNetRecordExcel(@Valid MoldPressureNetRecordPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<MoldPressureNetRecordDO> list = moldPressureNetRecordService.getMoldPressureNetRecordPage(pageReqVO).getList();
ExcelUtils.write(response, "子模具压网记录.xls", "数据", MoldPressureNetRecordRespVO.class,
BeanUtils.toBean(list, MoldPressureNetRecordRespVO.class));
}
}

@ -0,0 +1,42 @@
package cn.iocoder.yudao.module.erp.controller.admin.mold.vo;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 子模具压网记录分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class MoldPressureNetRecordPageReqVO extends PageParam {
@Schema(description = "模具组ID", example = "1")
private Long moldBrandId;
@Schema(description = "模具组名称", example = "A组")
private String moldBrandName;
@Schema(description = "子模具ID", example = "1")
private Long moldId;
@Schema(description = "子模具名称", example = "子模具A")
private String moldName;
@Schema(description = "压网时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] pressureNetTime;
@Schema(description = "备注", example = "备注")
private String remark;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

@ -0,0 +1,49 @@
package cn.iocoder.yudao.module.erp.controller.admin.mold.vo;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 子模具压网记录 Response VO")
@Data
@ExcelIgnoreUnannotated
public class MoldPressureNetRecordRespVO {
@Schema(description = "ID", example = "1")
@ExcelProperty("ID")
private Long id;
@Schema(description = "模具组ID", example = "1")
@ExcelProperty("模具组ID")
private Long moldBrandId;
@Schema(description = "模具组名称", example = "A组")
@ExcelProperty("模具组名称")
private String moldBrandName;
@Schema(description = "子模具ID", example = "1")
@ExcelProperty("子模具ID")
private Long moldId;
@Schema(description = "子模具名称", example = "子模具A")
@ExcelProperty("子模具名称")
private String moldName;
@Schema(description = "压网时间")
@ExcelProperty("压网时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime pressureNetTime;
@Schema(description = "备注", example = "备注")
@ExcelProperty("备注")
private String remark;
@Schema(description = "创建时间")
private LocalDateTime createTime;
}

@ -0,0 +1,36 @@
package cn.iocoder.yudao.module.erp.controller.admin.mold.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 子模具压网记录新增/修改 Request VO")
@Data
public class MoldPressureNetRecordSaveReqVO {
@Schema(description = "ID", example = "1")
private Long id;
@Schema(description = "模具组ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "模具组ID不能为空")
private Long moldBrandId;
@Schema(description = "模具组名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "A组")
private String moldBrandName;
@Schema(description = "子模具ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "子模具ID不能为空")
private Long moldId;
@Schema(description = "子模具名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "子模具A")
private String moldName;
@Schema(description = "压网时间", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "压网时间不能为空")
private LocalDateTime pressureNetTime;
@Schema(description = "备注", example = "备注")
private String remark;
}

@ -85,4 +85,13 @@ public class MoldRespVO {
@ExcelProperty("附件地址") @ExcelProperty("附件地址")
private String fileUrl; private String fileUrl;
} @Schema(description = "压网时间")
@ExcelProperty("压网时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime pressureNetTime;
@Schema(description = "压网天数", example = "5")
@ExcelProperty("压网天数")
private Long pressureNetDays;
}

@ -0,0 +1,43 @@
package cn.iocoder.yudao.module.erp.dal.dataobject.mold;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import java.time.LocalDateTime;
/**
* DO
*/
@TableName("erp_mold_pressure_net_record")
@KeySequence("erp_mold_pressure_net_record_seq")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class MoldPressureNetRecordDO extends BaseDO {
@TableId
private Long id;
private Long moldBrandId;
private String moldBrandName;
private Long moldId;
private String moldName;
private LocalDateTime pressureNetTime;
private String remark;
}

@ -0,0 +1,42 @@
package cn.iocoder.yudao.module.erp.dal.mysql.mold;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
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.MoldPressureNetRecordPageReqVO;
import cn.iocoder.yudao.module.erp.dal.dataobject.mold.MoldPressureNetRecordDO;
import org.apache.ibatis.annotations.Mapper;
import java.util.Collection;
import java.util.List;
@Mapper
public interface MoldPressureNetRecordMapper extends BaseMapperX<MoldPressureNetRecordDO> {
default PageResult<MoldPressureNetRecordDO> selectPage(MoldPressureNetRecordPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<MoldPressureNetRecordDO>()
.eqIfPresent(MoldPressureNetRecordDO::getMoldBrandId, reqVO.getMoldBrandId())
.likeIfPresent(MoldPressureNetRecordDO::getMoldBrandName, reqVO.getMoldBrandName())
.eqIfPresent(MoldPressureNetRecordDO::getMoldId, reqVO.getMoldId())
.likeIfPresent(MoldPressureNetRecordDO::getMoldName, reqVO.getMoldName())
.betweenIfPresent(MoldPressureNetRecordDO::getPressureNetTime, reqVO.getPressureNetTime())
.likeIfPresent(MoldPressureNetRecordDO::getRemark, reqVO.getRemark())
.betweenIfPresent(MoldPressureNetRecordDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(MoldPressureNetRecordDO::getPressureNetTime)
.orderByDesc(MoldPressureNetRecordDO::getId));
}
default List<MoldPressureNetRecordDO> selectListByMoldIds(Collection<Long> moldIds) {
return selectList(new LambdaQueryWrapperX<MoldPressureNetRecordDO>()
.inIfPresent(MoldPressureNetRecordDO::getMoldId, moldIds)
.orderByDesc(MoldPressureNetRecordDO::getPressureNetTime)
.orderByDesc(MoldPressureNetRecordDO::getId));
}
default List<MoldPressureNetRecordDO> selectListByMoldBrandIds(Collection<Long> moldBrandIds) {
return selectList(new LambdaQueryWrapperX<MoldPressureNetRecordDO>()
.inIfPresent(MoldPressureNetRecordDO::getMoldBrandId, moldBrandIds)
.orderByDesc(MoldPressureNetRecordDO::getPressureNetTime)
.orderByDesc(MoldPressureNetRecordDO::getId));
}
}

@ -198,4 +198,14 @@ public interface MoldBrandService {
void regenerateCode(Long id, String code) throws UnsupportedEncodingException; void regenerateCode(Long id, String code) throws UnsupportedEncodingException;
List<MoldBrandDO> validMoldList(Set<Long> longs); List<MoldBrandDO> validMoldList(Set<Long> longs);
default Map<Long, MoldBrandDO> getMoldVOMap(Collection<Long> ids) {
if(ids.isEmpty())return new HashMap<>();
return convertMap(getMoldVOList(ids), MoldBrandDO::getId);
}
List<MoldBrandDO> getMoldVOList(Collection<Long> ids);
} }

@ -50,6 +50,9 @@ import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -87,6 +90,8 @@ public class MoldBrandServiceImpl implements MoldBrandService {
private QrcodeRecordService qrcodeService; private QrcodeRecordService qrcodeService;
@Resource @Resource
private MoldOperateQueryMapper moldOperateQueryMapper; private MoldOperateQueryMapper moldOperateQueryMapper;
@Resource
private cn.iocoder.yudao.module.erp.dal.mysql.mold.MoldPressureNetRecordMapper moldPressureNetRecordMapper;
@Autowired @Autowired
private AutoCodeUtil autoCodeUtil; private AutoCodeUtil autoCodeUtil;
@ -453,11 +458,31 @@ public class MoldBrandServiceImpl implements MoldBrandService {
} }
Map<Long, ErpProductUnitDO> unitMap = productUnitService.getProductUnitMap( Map<Long, ErpProductUnitDO> unitMap = productUnitService.getProductUnitMap(
convertSet(list, MoldDO::getUnitId)); convertSet(list, MoldDO::getUnitId));
Map<Long, LocalDateTime> latestPressureNetTimeMap = buildLatestPressureNetTimeMap(convertSet(list, MoldDO::getId));
return BeanUtils.toBean(list, MoldRespVO.class, product -> { return BeanUtils.toBean(list, MoldRespVO.class, product -> {
MapUtils.findAndThen(unitMap, product.getUnitId(), MapUtils.findAndThen(unitMap, product.getUnitId(),
unit -> product.setUnitName(unit.getName())); unit -> product.setUnitName(unit.getName()));
LocalDateTime pressureNetTime = latestPressureNetTimeMap.get(product.getId());
product.setPressureNetTime(pressureNetTime);
if (pressureNetTime != null) {
product.setPressureNetDays(ChronoUnit.DAYS.between(pressureNetTime.toLocalDate(), LocalDate.now()));
}
}); });
} }
private Map<Long, LocalDateTime> buildLatestPressureNetTimeMap(Set<Long> moldIds) {
if (CollUtil.isEmpty(moldIds)) {
return Collections.emptyMap();
}
List<cn.iocoder.yudao.module.erp.dal.dataobject.mold.MoldPressureNetRecordDO> records = moldPressureNetRecordMapper.selectListByMoldIds(moldIds);
Map<Long, LocalDateTime> result = new HashMap<>();
for (cn.iocoder.yudao.module.erp.dal.dataobject.mold.MoldPressureNetRecordDO record : records) {
if (record.getMoldId() != null && !result.containsKey(record.getMoldId())) {
result.put(record.getMoldId(), record.getPressureNetTime());
}
}
return result;
}
@Override @Override
public Long createMold(MoldSaveReqVO createReqVO) throws UnsupportedEncodingException { public Long createMold(MoldSaveReqVO createReqVO) throws UnsupportedEncodingException {
String Code = createReqVO.getCode(); String Code = createReqVO.getCode();
@ -768,6 +793,15 @@ public class MoldBrandServiceImpl implements MoldBrandService {
return moldBrandMapper.selectBatchIds(ids); return moldBrandMapper.selectBatchIds(ids);
} }
@Override
public List<MoldBrandDO> getMoldVOList(Collection<Long> ids) {
if (CollUtil.isEmpty(ids)) {
return Collections.emptyList();
}
List<MoldBrandDO> list = moldBrandMapper.selectBatchIds(ids);
return list;
}
/** /**
* *
*/ */

@ -0,0 +1,28 @@
package cn.iocoder.yudao.module.erp.service.mold;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.erp.controller.admin.mold.vo.MoldPressureNetRecordPageReqVO;
import cn.iocoder.yudao.module.erp.controller.admin.mold.vo.MoldPressureNetRecordSaveReqVO;
import cn.iocoder.yudao.module.erp.dal.dataobject.mold.MoldPressureNetRecordDO;
import javax.validation.Valid;
import java.time.LocalDateTime;
import java.util.Collection;
import java.util.Map;
public interface MoldPressureNetRecordService {
Long createMoldPressureNetRecord(@Valid MoldPressureNetRecordSaveReqVO createReqVO);
void updateMoldPressureNetRecord(@Valid MoldPressureNetRecordSaveReqVO updateReqVO);
void deleteMoldPressureNetRecord(Long id);
MoldPressureNetRecordDO getMoldPressureNetRecord(Long id);
PageResult<MoldPressureNetRecordDO> getMoldPressureNetRecordPage(MoldPressureNetRecordPageReqVO pageReqVO);
Map<Long, LocalDateTime> getLatestPressureNetTimeMapByMoldIds(Collection<Long> moldIds);
Map<Long, LocalDateTime> getLatestPressureNetTimeMapByMoldBrandIds(Collection<Long> moldBrandIds);
}

@ -0,0 +1,126 @@
package cn.iocoder.yudao.module.erp.service.mold;
import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.common.dal.dataobject.mold.MoldBrandDO;
import cn.iocoder.yudao.module.common.dal.dataobject.mold.MoldDO;
import cn.iocoder.yudao.module.common.dal.mysql.mold.MoldBrandMapper;
import cn.iocoder.yudao.module.common.dal.mysql.mold.MoldMapper;
import cn.iocoder.yudao.module.erp.controller.admin.mold.vo.MoldPressureNetRecordPageReqVO;
import cn.iocoder.yudao.module.erp.controller.admin.mold.vo.MoldPressureNetRecordSaveReqVO;
import cn.iocoder.yudao.module.erp.dal.dataobject.mold.MoldPressureNetRecordDO;
import cn.iocoder.yudao.module.erp.dal.mysql.mold.MoldPressureNetRecordMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.MOLD_NOT_EXISTS;
import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.MOLD_PRESSURE_NET_RECORD_NOT_EXISTS;
import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.MOLD_SET_NOT_EXISTS;
@Service
@Validated
public class MoldPressureNetRecordServiceImpl implements MoldPressureNetRecordService {
@Resource
private MoldPressureNetRecordMapper moldPressureNetRecordMapper;
@Resource
private MoldBrandMapper moldBrandMapper;
@Resource
private MoldMapper moldMapper;
@Override
@Transactional(rollbackFor = Exception.class)
public Long createMoldPressureNetRecord(MoldPressureNetRecordSaveReqVO createReqVO) {
MoldPressureNetRecordDO record = BeanUtils.toBean(createReqVO, MoldPressureNetRecordDO.class);
fillMoldInfo(record);
moldPressureNetRecordMapper.insert(record);
return record.getId();
}
@Override
@Transactional(rollbackFor = Exception.class)
public void updateMoldPressureNetRecord(MoldPressureNetRecordSaveReqVO updateReqVO) {
validateMoldPressureNetRecordExists(updateReqVO.getId());
MoldPressureNetRecordDO updateObj = BeanUtils.toBean(updateReqVO, MoldPressureNetRecordDO.class);
fillMoldInfo(updateObj);
moldPressureNetRecordMapper.updateById(updateObj);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteMoldPressureNetRecord(Long id) {
validateMoldPressureNetRecordExists(id);
moldPressureNetRecordMapper.deleteById(id);
}
@Override
public MoldPressureNetRecordDO getMoldPressureNetRecord(Long id) {
return moldPressureNetRecordMapper.selectById(id);
}
@Override
public PageResult<MoldPressureNetRecordDO> getMoldPressureNetRecordPage(MoldPressureNetRecordPageReqVO pageReqVO) {
return moldPressureNetRecordMapper.selectPage(pageReqVO);
}
@Override
public Map<Long, LocalDateTime> getLatestPressureNetTimeMapByMoldIds(Collection<Long> moldIds) {
if (CollUtil.isEmpty(moldIds)) {
return Collections.emptyMap();
}
List<MoldPressureNetRecordDO> records = moldPressureNetRecordMapper.selectListByMoldIds(moldIds);
return buildLatestTimeMap(records, true);
}
@Override
public Map<Long, LocalDateTime> getLatestPressureNetTimeMapByMoldBrandIds(Collection<Long> moldBrandIds) {
if (CollUtil.isEmpty(moldBrandIds)) {
return Collections.emptyMap();
}
List<MoldPressureNetRecordDO> records = moldPressureNetRecordMapper.selectListByMoldBrandIds(moldBrandIds);
return buildLatestTimeMap(records, false);
}
private Map<Long, LocalDateTime> buildLatestTimeMap(List<MoldPressureNetRecordDO> records, boolean byMoldId) {
Map<Long, LocalDateTime> result = new LinkedHashMap<>();
for (MoldPressureNetRecordDO record : records) {
Long key = byMoldId ? record.getMoldId() : record.getMoldBrandId();
if (key != null && !result.containsKey(key)) {
result.put(key, record.getPressureNetTime());
}
}
return result;
}
private void fillMoldInfo(MoldPressureNetRecordDO record) {
MoldDO mold = moldMapper.selectById(record.getMoldId());
if (mold == null) {
throw exception(MOLD_NOT_EXISTS);
}
Long moldBrandId = mold.getBrandId() != null ? mold.getBrandId() : record.getMoldBrandId();
MoldBrandDO moldBrand = moldBrandMapper.selectById(moldBrandId);
if (moldBrand == null) {
throw exception(MOLD_SET_NOT_EXISTS);
}
record.setMoldBrandId(moldBrand.getId());
record.setMoldBrandName(moldBrand.getName());
record.setMoldName(mold.getName());
}
private void validateMoldPressureNetRecordExists(Long id) {
if (moldPressureNetRecordMapper.selectById(id) == null) {
throw exception(MOLD_PRESSURE_NET_RECORD_NOT_EXISTS);
}
}
}
Loading…
Cancel
Save