fix mes bug

plp
chenshuichuan 2 years ago
parent 621fceebfa
commit adb9b920e1

@ -146,4 +146,10 @@ public class DateUtils {
return LocalDateTimeUtil.isSameDay(date, LocalDateTime.now().minusDays(1));
}
public static LocalDateTime[] getDateRange(LocalDateTime base){
if(base==null)base = LocalDateTime.now();
LocalDateTime start = LocalDateTime.of(base.getYear(),base.getMonth(),base.getDayOfMonth(),0,0,0);
LocalDateTime end = LocalDateTime.of(base.getYear(),base.getMonth(),base.getDayOfMonth(),23,59,59);
return new LocalDateTime[]{start,end};
}
}

@ -0,0 +1,30 @@
package cn.iocoder.yudao.module.mes.controller.admin.changerecord.vo;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* **/
@Getter
@AllArgsConstructor
public enum ChangeTypeEnum {
("创建"),
("编辑"),
("删除"),
("提交"),
("审核");
private final String value;
// 一个可选的方法,用于根据整数值获取对应的枚举实例
public static ChangeTypeEnum fromValue(String value) {
for (ChangeTypeEnum status : ChangeTypeEnum.values()) {
if (status.value.equals(value)) {
return status;
}
}
throw new IllegalArgumentException("Unknown value: " + value);
}
}

@ -177,10 +177,12 @@ public class FeedingRecordController {
}
}
}
} else {
recordDO.setRecordStatus(FeedingStatusEnum..getValue());
feedingRecordMapper.updateById(recordDO);
}
else {
}
recordDO.setRecordStatus(FeedingStatusEnum..getValue());
feedingRecordMapper.updateById(recordDO);
return success(true);
} else return CommonResult.error(500, "无法获取操作用户!请检查!");
}

@ -4,6 +4,7 @@ import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
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.date.DateUtils;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.module.mes.controller.admin.organization.vo.OrganizationListReqVO;
@ -31,7 +32,6 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@ -121,8 +121,7 @@ public class OrgWorkerController {
@Operation(summary = "获得工位安排")
public CommonResult<List<OrganizationDO>> getPersonal(@Valid ProduceReportDetailSaveReqVO reqVO) {
OrgWorkerPageReqVO pageReqVO = new OrgWorkerPageReqVO().setOrgType(reqVO.getOrgType()).setGroupType(reqVO.getGroupType());
LocalDateTime[] localDateTimes = {reqVO.getReportDate(),reqVO.getReportDate()};
pageReqVO.setWorkDate(localDateTimes);
pageReqVO.setWorkDate(DateUtils.getDateRange(reqVO.getReportDate()));
Long userId = getLoginUserId();
pageReqVO.setWorkerId(userId);
@ -136,8 +135,7 @@ public class OrgWorkerController {
@Operation(summary = "获得工位安排")
public CommonResult<List<OrganizationDO>> getOtherPersonal(@Valid ProduceReportDetailSaveReqVO reqVO) {
OrgWorkerPageReqVO pageReqVO = new OrgWorkerPageReqVO().setOrgType(reqVO.getOrgType()).setGroupType(reqVO.getGroupType());
LocalDateTime[] localDateTimes = {reqVO.getReportDate(),reqVO.getReportDate()};
pageReqVO.setWorkDate(localDateTimes);
pageReqVO.setWorkDate(DateUtils.getDateRange(reqVO.getReportDate()));
List<OrgWorkerDO> orgWorkers = orgWorkerService.getOrgWorkerByReportResVo(pageReqVO);
List<Long> ids = orgWorkers.stream().map(OrgWorkerDO::getOrgId).collect(Collectors.toList());
@ -164,23 +162,13 @@ public class OrgWorkerController {
@Operation(summary = "获得用户列表")
public CommonResult<List<AdminUserRespDTO>> getOtherPersonalUser(@Valid ProduceReportDetailSaveReqVO reqVO) {
OrgWorkerPageReqVO pageReqVO = new OrgWorkerPageReqVO().setOrgType(reqVO.getOrgType()).setGroupType(reqVO.getGroupType());
LocalDateTime[] localDateTimes = {reqVO.getReportDate(),reqVO.getReportDate()};
pageReqVO.setWorkDate(localDateTimes);
pageReqVO.setWorkDate(DateUtils.getDateRange(reqVO.getReportDate()));
pageReqVO.setWorkerId(reqVO.getUserId());
OrganizationListReqVO listReqVO = new OrganizationListReqVO().setOrgType(reqVO.getOrgType());
List<OrganizationDO> orgList = organizationService.getOrganizationList(listReqVO);
List<Long> orgIds = orgList.stream().map(OrganizationDO::getId).collect(Collectors.toList());
pageReqVO.setOrgIds(orgIds);
// Long userId = getLoginUserId();
// List<WorkTeamDetailDO> detailDOList = workTeamService.getUserWorkTeamDetail(userId, WorkTeamUserRoleEnum.组长.getValue());
// //组长的话把这些组的工人列表都查上,其他人所有人都查
// List<Long> workTeamIds =null;
// if(detailDOList!=null && detailDOList.size()>0){
// workTeamIds = detailDOList.stream().map(WorkTeamDetailDO::getWorkTeamId).collect(Collectors.toList());
// }
// List<WorkTeamDetailDO> workTeamDetailDOS = workTeamService.getDetailByWorkTeamIds(workTeamIds);
// Set<Long> idsSet = convertSet(workTeamDetailDOS, WorkTeamDetailDO::getUserId);
List<OrgWorkerDO> list = orgWorkerService.getOrgWorkerByReportResVo(pageReqVO);
List<Long> ids = list.stream().map(OrgWorkerDO::getWorkerId).collect(Collectors.toList());
@ -193,9 +181,7 @@ public class OrgWorkerController {
@Operation(summary = "获得工位安排")
public CommonResult<List<OrgWorkerRespVO>> getOrgWorkerRespVO(@Valid ProduceReportDetailSaveReqVO reqVO) {
OrgWorkerPageReqVO pageReqVO = new OrgWorkerPageReqVO().setOrgType(reqVO.getOrgType()).setGroupType(reqVO.getGroupType());
LocalDateTime[] localDateTimes = {reqVO.getReportDate(),reqVO.getReportDate()};
pageReqVO.setWorkDate(localDateTimes);
pageReqVO.setWorkDate(DateUtils.getDateRange(reqVO.getReportDate()));
Long userId = getLoginUserId();
pageReqVO.setWorkerId(userId);
List<OrgWorkerDO> orgWorkers = orgWorkerService.getOrgWorkerByReportResVo(pageReqVO);
@ -206,8 +192,7 @@ public class OrgWorkerController {
@Operation(summary = "获得工位安排")
public CommonResult<List<OrgWorkerRespVO>> getOtherOrgWorkerRespVO(@Valid ProduceReportDetailSaveReqVO reqVO) {
OrgWorkerPageReqVO pageReqVO = new OrgWorkerPageReqVO().setOrgType(reqVO.getOrgType()).setGroupType(reqVO.getGroupType());
LocalDateTime[] localDateTimes = {reqVO.getReportDate(),reqVO.getReportDate()};
pageReqVO.setWorkDate(localDateTimes);
pageReqVO.setWorkDate(DateUtils.getDateRange(reqVO.getReportDate()));
pageReqVO.setWorkerId(reqVO.getUserId());
Long userId = getLoginUserId();

@ -51,6 +51,9 @@ public class ProduceReportDetailController {
@Operation(summary = "更新生产报工明细")
//@PreAuthorize("@ss.hasPermission('mes:produce-report-detail:update')")
public CommonResult<Boolean> updateProduceReportDetail(@Valid @RequestBody ProduceReportDetailSaveReqVO updateReqVO) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDateTime localDateTime = LocalDateTime.parse(updateReqVO.getReportDateString(), formatter);
updateReqVO.setReportDate(localDateTime);
produceReportDetailService.updateProduceReportDetail(updateReqVO);
return success(true);
}

@ -63,7 +63,7 @@ public class ProduceReportDetailSaveReqVO {
private LocalDateTime reportDate;
@Schema(description = "计件时间")
private String reportTime;
private BigDecimal reportTime;
@Schema(description = "报工状态", example = "1")
private Integer reportStatus;

@ -1,12 +1,21 @@
package cn.iocoder.yudao.module.mes.controller.admin.producereportplan;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.mes.controller.admin.producereportplan.vo.ReportPlanSummaryRespVO;
import cn.iocoder.yudao.module.mes.service.workreportplan.WorkReportPlanService;
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.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
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 java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Tag(name = "管理后台 - 报工分配计划")
@RestController
@ -17,6 +26,13 @@ public class ReportPlanViewController {
@Resource
private WorkReportPlanService workReportPlanService;
@GetMapping("/getPlanProgress")
@Operation(summary = "获得计划进度")
@Parameter(name = "id", description = "计划id", required = true, example = "1024")
public CommonResult<List<ReportPlanSummaryRespVO>> getPlanProgress(@RequestParam("id") Long id) {
ReportPlanSummaryRespVO respVO = new ReportPlanSummaryRespVO();
respVO.setPlanId(id);
List<ReportPlanSummaryRespVO> planSummaryDOS = workReportPlanService.getPlanSummary( respVO);
return success(planSummaryDOS);
}
}

@ -0,0 +1,49 @@
package cn.iocoder.yudao.module.mes.controller.admin.producereportplan.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 java.math.BigDecimal;
@Schema(description = "管理后台 - 报工分配计划 Response VO")
@Data
@ExcelIgnoreUnannotated
public class ReportPlanSummaryRespVO {
@Schema(description = "计划id", example = "30035")
private Long planId;
@Schema(description = "计划id", example = "30035")
@ExcelProperty("计划")
private String planCode;
@Schema(description = "产品ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "14517")
private Long productId;
@Schema(description = "产品", requiredMode = Schema.RequiredMode.REQUIRED, example = "14517")
@ExcelProperty("产品")
private String productName;
@Schema(description = "成品数量")
@ExcelProperty("成品数量")
private BigDecimal totalQualityNumber;
@Schema(description = "废品数量")
@ExcelProperty("废品数量")
private BigDecimal totalWasteNumber;
@Schema(description = "计件时间")
@ExcelProperty("计件时间")
private BigDecimal reportTimeSummary;
@Schema(description = "总时长")
@ExcelProperty("总时长")
private BigDecimal totalTimeSummary;
@Schema(description = "工序类型")
@ExcelProperty("工序类型")
private String orgType;
}

@ -4,6 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageParam;
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.mes.controller.admin.producereportplan.vo.ReportPlanSummaryRespVO;
import cn.iocoder.yudao.module.mes.dal.dataobject.workreportplan.ReportPlanSummaryDO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.apache.ibatis.annotations.Mapper;
@ -27,12 +28,11 @@ public interface ReportPlanSummaryMapper extends BaseMapperX<ReportPlanSummaryDO
return selectPage(param,wrapper );
}
//查询计划某工序已经报工的总数
default List<ReportPlanSummaryDO> selectList(ReportPlanSummaryDO reqVO) {
default List<ReportPlanSummaryDO> selectList(ReportPlanSummaryRespVO respVO) {
LambdaQueryWrapper<ReportPlanSummaryDO> wrapper = new LambdaQueryWrapperX<ReportPlanSummaryDO>()
.eqIfPresent(ReportPlanSummaryDO::getPlanId, reqVO.getPlanId())
.eqIfPresent(ReportPlanSummaryDO::getProductId, reqVO.getProductId())
.eqIfPresent(ReportPlanSummaryDO::getOrgType, reqVO.getOrgType())
.eqIfPresent(ReportPlanSummaryDO::getPlanId, respVO.getPlanId())
.eqIfPresent(ReportPlanSummaryDO::getProductId, respVO.getProductId())
.eqIfPresent(ReportPlanSummaryDO::getOrgType, respVO.getOrgType())
.orderByDesc(ReportPlanSummaryDO::getOrgType);
List<ReportPlanSummaryDO> list = selectList(wrapper);
return list;

@ -1,11 +1,11 @@
package cn.iocoder.yudao.module.mes.service.changerecord;
import java.util.*;
import javax.validation.*;
import cn.iocoder.yudao.module.mes.controller.admin.changerecord.vo.*;
import cn.iocoder.yudao.module.mes.dal.dataobject.changerecord.ProduceReportChangeRecordDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.module.mes.controller.admin.changerecord.vo.ProduceReportChangeRecordPageReqVO;
import cn.iocoder.yudao.module.mes.controller.admin.changerecord.vo.ProduceReportChangeRecordSaveReqVO;
import cn.iocoder.yudao.module.mes.dal.dataobject.changerecord.ProduceReportChangeRecordDO;
import javax.validation.Valid;
/**
* Service
@ -51,5 +51,5 @@ public interface ProduceReportChangeRecordService {
* @return
*/
PageResult<ProduceReportChangeRecordDO> getProduceReportChangeRecordPage(ProduceReportChangeRecordPageReqVO pageReqVO);
int saveChange(Long reportId,String beforeString, String afterString, String changeType);
}

@ -1,21 +1,18 @@
package cn.iocoder.yudao.module.mes.service.changerecord;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import cn.iocoder.yudao.module.mes.controller.admin.changerecord.vo.*;
import cn.iocoder.yudao.module.mes.dal.dataobject.changerecord.ProduceReportChangeRecordDO;
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.mes.controller.admin.changerecord.vo.ProduceReportChangeRecordPageReqVO;
import cn.iocoder.yudao.module.mes.controller.admin.changerecord.vo.ProduceReportChangeRecordSaveReqVO;
import cn.iocoder.yudao.module.mes.dal.dataobject.changerecord.ProduceReportChangeRecordDO;
import cn.iocoder.yudao.module.mes.dal.mysql.changerecord.ProduceReportChangeRecordMapper;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*;
import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.PRODUCE_REPORT_CHANGE_RECORD_NOT_EXISTS;
/**
* Service
@ -71,4 +68,14 @@ public class ProduceReportChangeRecordServiceImpl implements ProduceReportChange
return produceReportChangeRecordMapper.selectPage(pageReqVO);
}
@Override
public int saveChange(Long reportId,String beforeString, String afterString, String changeType) {
ProduceReportChangeRecordDO recordDO = new ProduceReportChangeRecordDO();
recordDO.setReportId(reportId);
recordDO.setBeforeChange(beforeString);
recordDO.setAfterChange(afterString);
recordDO.setChangeType(changeType);
return produceReportChangeRecordMapper.insert(recordDO);
}
}

@ -414,7 +414,7 @@ public class FeedingRecordServiceImpl implements FeedingRecordService {
//分配给计划
FeedingRecordPlanDO recordPlanDO = new FeedingRecordPlanDO()
.setPlanId(plan.getId())
.setItemId(plan.getProductId())
.setItemId(detail.getItemId())
.setRecordId(detail.getRecordId()).setUserId(user.getId()).setUnitId(detail.getUnitId())
.setRecordDetailId(detail.getId()).setFeedingTime(detail.getFeedingTime())
.setWeight(detail.getWeight());

@ -24,6 +24,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@ -149,7 +150,8 @@ public class ItemRequisitionServiceImpl implements ItemRequisitionService {
product -> item.setProductName(product.getName()));
MapUtils.findAndThen(unitMap, item.getUnitId(),
unit -> item.setUnitName(unit.getName()));
item.setFinishNumber(recordPlanService.selectSumBy(planId, item.getProductId()));
BigDecimal finish = recordPlanService.selectSumBy(planId, item.getProductId());
item.setFinishNumber(finish);
});
}

@ -6,6 +6,7 @@ import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO;
import cn.iocoder.yudao.module.erp.service.product.ErpProductService;
import cn.iocoder.yudao.module.mes.controller.admin.changerecord.vo.ChangeTypeEnum;
import cn.iocoder.yudao.module.mes.controller.admin.plan.vo.PlanStatusEnum;
import cn.iocoder.yudao.module.mes.controller.admin.producereport.vo.ProduceReportDetailPageReqVO;
import cn.iocoder.yudao.module.mes.controller.admin.producereport.vo.ProduceReportDetailRespVO;
@ -16,6 +17,7 @@ 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.dataobject.producereport.ProduceReportDetailDO;
import cn.iocoder.yudao.module.mes.dal.mysql.producereport.ProduceReportDetailMapper;
import cn.iocoder.yudao.module.mes.service.changerecord.ProduceReportChangeRecordService;
import cn.iocoder.yudao.module.mes.service.organization.OrganizationService;
import cn.iocoder.yudao.module.mes.service.plan.PlanService;
import cn.iocoder.yudao.module.mes.service.workreportplan.WorkReportPlanService;
@ -47,13 +49,18 @@ public class ProduceReportDetailServiceImpl implements ProduceReportDetailServic
@Resource
private ProduceReportDetailMapper produceReportDetailMapper;
@Resource
private ProduceReportChangeRecordService recordService;
@Override
@Transactional
public Long createProduceReportDetail(ProduceReportDetailSaveReqVO createReqVO) {
createReqVO.setReportStatus(ReportStatusEnum.稿.getValue());
// 插入
ProduceReportDetailDO produceReportDetail = BeanUtils.toBean(createReqVO, ProduceReportDetailDO.class);
produceReportDetailMapper.insert(produceReportDetail);
recordService.saveChange(produceReportDetail.getId(),"", produceReportDetail.toString()
, ChangeTypeEnum..getValue());
// 返回
return produceReportDetail.getId();
}
@ -63,14 +70,33 @@ public class ProduceReportDetailServiceImpl implements ProduceReportDetailServic
// 校验存在
validateProduceReportDetailExists(updateReqVO.getId());
// 更新
ProduceReportDetailDO updateObj = BeanUtils.toBean(updateReqVO, ProduceReportDetailDO.class);
//ProduceReportDetailDO updateObj = BeanUtils.toBean(updateReqVO, ProduceReportDetailDO.class);
ProduceReportDetailDO updateObj = produceReportDetailMapper.selectById(updateReqVO.getId());
String before = updateObj.toString();
updateObj.setProductId(updateReqVO.getProductId());
updateObj.setQualityNumber(updateReqVO.getQualityNumber());
updateObj.setQualityRate(updateReqVO.getQualityRate());
updateObj.setWasteNumber(updateReqVO.getWasteNumber());
updateObj.setWasteReason(updateReqVO.getWasteReason());
updateObj.setTotalNumber(updateReqVO.getTotalNumber());
updateObj.setRemark(updateReqVO.getRemark());
updateObj.setReportTime(updateReqVO.getReportTime());
updateObj.setTotalTime(updateReqVO.getTotalTime());
recordService.saveChange(updateObj.getId(),before, updateObj.toString()
, ChangeTypeEnum..getValue());
produceReportDetailMapper.updateById(updateObj);
}
@Override
public void deleteProduceReportDetail(Long id) {
// 校验存在
validateProduceReportDetailExists(id);
//validateProduceReportDetailExists(id);
ProduceReportDetailDO detailDO = produceReportDetailMapper.selectById(id);
if ( detailDO== null) {
throw exception(PRODUCE_REPORT_DETAIL_NOT_EXISTS);
}
recordService.saveChange(id,detailDO.toString(), ""
, ChangeTypeEnum..getValue());
// 删除
produceReportDetailMapper.deleteById(id);
}
@ -136,9 +162,16 @@ public class ProduceReportDetailServiceImpl implements ProduceReportDetailServic
public void updateStatus(Long id, Integer status) {
ProduceReportDetailDO reportDetailDO = produceReportDetailMapper.selectById(id);
reportDetailDO.setReportStatus(status);
String before = reportDetailDO.toString();
produceReportDetailMapper.updateById(reportDetailDO);
if(status.equals(ReportStatusEnum..getValue())){
recordService.saveChange(reportDetailDO.getId(),before, reportDetailDO.toString()
, ChangeTypeEnum..getValue());
}
if(status.equals(ReportStatusEnum..getValue())){
recordService.saveChange(reportDetailDO.getId(),before, reportDetailDO.toString()
, ChangeTypeEnum..getValue());
//分配给开工中的计划
List<Integer> statusList = new ArrayList<>();
statusList.add(PlanStatusEnum..getValue());

@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.mes.service.workreportplan;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.mes.controller.admin.producereportplan.vo.*;
import cn.iocoder.yudao.module.mes.dal.dataobject.workreportplan.ReportPlanSummaryDO;
import cn.iocoder.yudao.module.mes.dal.dataobject.workreportplan.ReportPlanViewDO;
import cn.iocoder.yudao.module.mes.dal.dataobject.workreportplan.WorkReportPlanDO;
@ -60,4 +61,7 @@ public interface WorkReportPlanService {
public List<ReportPlanViewDO> getReportPlanViewList();
public PageResult<ReportPlanViewRespVO> getReportPlanViewPage(ReportPlanViewReqVO reqVO);
List<ReportPlanViewRespVO> buildViewList(List<ReportPlanViewDO> list);
List<ReportPlanSummaryRespVO> getPlanSummary(ReportPlanSummaryRespVO respVO);
List<ReportPlanSummaryRespVO> buildSummaryList(List<ReportPlanSummaryDO> list);
}

@ -8,8 +8,10 @@ import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO;
import cn.iocoder.yudao.module.erp.service.product.ErpProductService;
import cn.iocoder.yudao.module.mes.controller.admin.producereportplan.vo.*;
import cn.iocoder.yudao.module.mes.dal.dataobject.plan.PlanDO;
import cn.iocoder.yudao.module.mes.dal.dataobject.workreportplan.ReportPlanSummaryDO;
import cn.iocoder.yudao.module.mes.dal.dataobject.workreportplan.ReportPlanViewDO;
import cn.iocoder.yudao.module.mes.dal.dataobject.workreportplan.WorkReportPlanDO;
import cn.iocoder.yudao.module.mes.dal.mysql.workreportplan.ReportPlanSummaryMapper;
import cn.iocoder.yudao.module.mes.dal.mysql.workreportplan.ReportPlanViewMapper;
import cn.iocoder.yudao.module.mes.dal.mysql.workreportplan.WorkReportPlanMapper;
import cn.iocoder.yudao.module.mes.service.plan.PlanService;
@ -43,6 +45,8 @@ public class WorkReportPlanServiceImpl implements WorkReportPlanService {
private ErpProductService productService;
@Resource
private PlanService planService;
@Resource
private ReportPlanSummaryMapper planSummaryMapper;
@Override
public Long createWorkReportPlan(WorkReportPlanSaveReqVO createReqVO) {
// 插入
@ -135,4 +139,29 @@ public class WorkReportPlanServiceImpl implements WorkReportPlanService {
});
}
@Override
public List<ReportPlanSummaryRespVO> getPlanSummary(ReportPlanSummaryRespVO respVO){
List<ReportPlanSummaryDO> list = planSummaryMapper.selectList(respVO);
return buildSummaryList(list);
}
@Override
public List<ReportPlanSummaryRespVO> buildSummaryList(List<ReportPlanSummaryDO> list) {
if (CollUtil.isEmpty(list)) {
return Collections.emptyList();
}
Map<Long, ErpProductDO> map = productService.getProductMap(
convertSet(list, ReportPlanSummaryDO::getProductId));
Map<Long, PlanDO> planMap = planService.getPlanMap(
convertSet(list, ReportPlanSummaryDO::getPlanId));
return BeanUtils.toBean(list, ReportPlanSummaryRespVO.class, item -> {
MapUtils.findAndThen(map, item.getProductId(),
product -> item.setProductName(product.getName()));
MapUtils.findAndThen(planMap, item.getPlanId(),
plan -> item.setPlanCode(plan.getCode()));
});
}
}
Loading…
Cancel
Save