|
|
|
|
@ -7,6 +7,7 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.controller.admin.changerecord.vo.ChangeTypeEnum;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.controller.admin.producereport.vo.*;
|
|
|
|
|
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.ProduceReportDO;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.dataobject.producereport.ProduceReportDetailDO;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.dataobject.producereport.ViewReportUserDateSummary;
|
|
|
|
|
@ -16,6 +17,7 @@ import cn.iocoder.yudao.module.mes.dal.mysql.producereport.ViewReportUserDateMap
|
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.redis.no.MesNoRedisDAO;
|
|
|
|
|
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.system.api.user.AdminUserApi;
|
|
|
|
|
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
@ -55,6 +57,8 @@ public class ProduceReportServiceImpl implements ProduceReportService {
|
|
|
|
|
@Resource
|
|
|
|
|
private ProduceReportDetailService produceReportDetailService;
|
|
|
|
|
@Resource
|
|
|
|
|
private PlanService planService;
|
|
|
|
|
@Resource
|
|
|
|
|
private MesNoRedisDAO noRedisDAO;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@ -71,8 +75,9 @@ public class ProduceReportServiceImpl implements ProduceReportService {
|
|
|
|
|
produceReportMapper.insert(produceReport);
|
|
|
|
|
|
|
|
|
|
// 插入子表
|
|
|
|
|
if( createReqVO.getProduceReportDetails()!=null&& createReqVO.getProduceReportDetails().size()>0)
|
|
|
|
|
if( createReqVO.getProduceReportDetails()!=null&& createReqVO.getProduceReportDetails().size()>0){
|
|
|
|
|
createProduceReportDetailList( produceReport, createReqVO.getProduceReportDetails());
|
|
|
|
|
}
|
|
|
|
|
// 返回
|
|
|
|
|
return produceReport.getId();
|
|
|
|
|
}
|
|
|
|
|
@ -154,10 +159,16 @@ public class ProduceReportServiceImpl implements ProduceReportService {
|
|
|
|
|
return produceReportDetailService.buildVOList(list);
|
|
|
|
|
}
|
|
|
|
|
private void createProduceReportDetailList(ProduceReportDO reportDO, List<ProduceReportDetailDO> list) {
|
|
|
|
|
Map<Long, PlanDO> map = planService.getPlanMap(convertSet(list, ProduceReportDetailDO::getPlanId));
|
|
|
|
|
|
|
|
|
|
list.forEach(o -> o.setId(null).setReportId(reportDO.getId()).setReportStatus(reportDO.getReportStatus())
|
|
|
|
|
.setReportDate(reportDO.getReportDate()).setGroupType(reportDO.getGroupType())
|
|
|
|
|
.setOrgId(reportDO.getOrgId()).setOrgType(reportDO.getOrgType())
|
|
|
|
|
.setUserId(reportDO.getUserId())
|
|
|
|
|
.setUserId(reportDO.getUserId()).setReportType(reportDO.getReportType())
|
|
|
|
|
.setProductId(map.get(o.getPlanId()).getProductId())
|
|
|
|
|
.setQualityNumber(o.getQualityNumber()==null?BigDecimal.ZERO: o.getQualityNumber())
|
|
|
|
|
.setWasteNumber(o.getWasteNumber()==null?BigDecimal.ZERO: o.getWasteNumber())
|
|
|
|
|
.setTotalNumber(o.getQualityNumber().add(o.getWasteNumber()))
|
|
|
|
|
);
|
|
|
|
|
produceReportDetailMapper.insertBatch(list);
|
|
|
|
|
}
|
|
|
|
|
@ -165,13 +176,9 @@ public class ProduceReportServiceImpl implements ProduceReportService {
|
|
|
|
|
private void updateProduceReportDetailList(ProduceReportDO reportDO, List<ProduceReportDetailDO> list) {
|
|
|
|
|
deleteProduceReportDetailByReportId(reportDO.getId());
|
|
|
|
|
if(list==null ||list.size()==0)return;
|
|
|
|
|
list.forEach(o -> o.setId(null).setReportStatus(reportDO.getReportStatus())
|
|
|
|
|
.setReportDate(reportDO.getReportDate()).setGroupType(reportDO.getGroupType())
|
|
|
|
|
.setOrgId(reportDO.getOrgId()).setOrgType(reportDO.getOrgType())
|
|
|
|
|
.setUserId(reportDO.getUserId())
|
|
|
|
|
.setReportId(reportDO.getId())
|
|
|
|
|
.setUpdater(null).setUpdateTime(null)
|
|
|
|
|
); // 解决更新情况下:1)id 冲突;2)updateTime 不更新
|
|
|
|
|
// list.forEach(o -> o.setId(null)
|
|
|
|
|
// .setUpdater(null).setUpdateTime(null)
|
|
|
|
|
// ); // 解决更新情况下:1)id 冲突;2)updateTime 不更新
|
|
|
|
|
createProduceReportDetailList(reportDO, list);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -192,7 +199,8 @@ public class ProduceReportServiceImpl implements ProduceReportService {
|
|
|
|
|
produceReportChangeRecordService.saveChange(id, "", "", ChangeTypeEnum.审核.getValue());
|
|
|
|
|
List<ProduceReportDetailDO> list = getProduceReportDetailListByReportId(id);
|
|
|
|
|
for (ProduceReportDetailDO detail: list) {
|
|
|
|
|
produceReportDetailService.updateStatus2(detail,status);
|
|
|
|
|
//明细固定分配单个计划
|
|
|
|
|
produceReportDetailService.updateStatus3(detail,status);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|