|
|
|
@ -4,6 +4,7 @@ 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.collection.MapUtils;
|
|
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.framework.security.core.LoginUser;
|
|
|
|
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.framework.bean.ProductUnitEnum;
|
|
|
|
import cn.iocoder.yudao.module.erp.framework.bean.ProductUnitEnum;
|
|
|
|
@ -15,13 +16,16 @@ import cn.iocoder.yudao.module.mes.controller.admin.stockworkshop.vo.StockWorkSh
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.dataobject.feedingplan.FeedingRecordPlanDO;
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.dataobject.feedingplan.FeedingRecordPlanDO;
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.dataobject.feedingrecord.FeedingRecordDO;
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.dataobject.feedingrecord.FeedingRecordDO;
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.dataobject.feedingrecord.FeedingRecordDetailDO;
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.dataobject.feedingrecord.FeedingRecordDetailDO;
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.dataobject.itemrequisition.ItemRequisitionDO;
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.dataobject.plan.PlanDO;
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.dataobject.plan.PlanDO;
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.dataobject.stockworkshop.StockWorkshopDO;
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.dataobject.stockworkshop.StockWorkshopDO;
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.mysql.feedingplan.FeedingRecordPlanMapper;
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.mysql.feedingplan.FeedingRecordPlanMapper;
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.mysql.feedingrecord.FeedingRecordDetailMapper;
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.mysql.feedingrecord.FeedingRecordDetailMapper;
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.mysql.feedingrecord.FeedingRecordMapper;
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.mysql.feedingrecord.FeedingRecordMapper;
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.mysql.itemrequisition.ItemRequisitionMapper;
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.redis.no.MesNoRedisDAO;
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.redis.no.MesNoRedisDAO;
|
|
|
|
import cn.iocoder.yudao.module.mes.service.feedingplan.FeedingRecordPlanService;
|
|
|
|
import cn.iocoder.yudao.module.mes.service.feedingplan.FeedingRecordPlanService;
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.module.mes.service.itemrequisition.ItemRequisitionService;
|
|
|
|
import cn.iocoder.yudao.module.mes.service.stockworkshop.StockWorkshopService;
|
|
|
|
import cn.iocoder.yudao.module.mes.service.stockworkshop.StockWorkshopService;
|
|
|
|
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
|
|
|
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
|
|
|
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
|
|
|
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
|
|
|
@ -33,6 +37,7 @@ import javax.annotation.Resource;
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
import java.math.MathContext;
|
|
|
|
import java.math.MathContext;
|
|
|
|
import java.math.RoundingMode;
|
|
|
|
import java.math.RoundingMode;
|
|
|
|
|
|
|
|
import java.time.LocalDate;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
|
@ -66,7 +71,10 @@ public class FeedingRecordServiceImpl implements FeedingRecordService {
|
|
|
|
private FeedingRecordPlanMapper recordPlanMapper;
|
|
|
|
private FeedingRecordPlanMapper recordPlanMapper;
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private StockWorkshopService workshopService;
|
|
|
|
private StockWorkshopService workshopService;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
private ItemRequisitionService itemRequisitionService;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
private ItemRequisitionMapper itemRequisitionMapper;
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
@ -307,6 +315,10 @@ public class FeedingRecordServiceImpl implements FeedingRecordService {
|
|
|
|
for (Long itemId : detailDOMap.keySet()) {
|
|
|
|
for (Long itemId : detailDOMap.keySet()) {
|
|
|
|
//原料有未分配数量
|
|
|
|
//原料有未分配数量
|
|
|
|
if (detailDOMap.get(itemId).getWeight().compareTo(BigDecimal.ZERO) <= 0) continue;
|
|
|
|
if (detailDOMap.get(itemId).getWeight().compareTo(BigDecimal.ZERO) <= 0) continue;
|
|
|
|
|
|
|
|
if(!totalPlanNeedItem.containsKey(itemId)){
|
|
|
|
|
|
|
|
System.out.println("~~~~~~~计算出错!~~~~~~");
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
BigDecimal factor = detailDOMap.get(itemId).getWeight().divide(totalPlanNeedItem.get(itemId), mc);
|
|
|
|
BigDecimal factor = detailDOMap.get(itemId).getWeight().divide(totalPlanNeedItem.get(itemId), mc);
|
|
|
|
for (PlanDO plan : planDOList) {
|
|
|
|
for (PlanDO plan : planDOList) {
|
|
|
|
ItemRequisitionDetailRespVO detailRespVO = planItemMap.get(getMapKey(plan.getId(), itemId));
|
|
|
|
ItemRequisitionDetailRespVO detailRespVO = planItemMap.get(getMapKey(plan.getId(), itemId));
|
|
|
|
@ -382,4 +394,39 @@ public class FeedingRecordServiceImpl implements FeedingRecordService {
|
|
|
|
recordDO.getId(), recordDO.getFeedingRecordCode());
|
|
|
|
recordDO.getId(), recordDO.getFeedingRecordCode());
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
|
|
|
public void dealWithOnPlan(PlanDO plan, List<FeedingRecordDetailDO> detailDOList,
|
|
|
|
|
|
|
|
Map<String, ItemRequisitionDetailRespVO> planItemMap, LoginUser user,FeedingRecordDO recordDO){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (FeedingRecordDetailDO detail : detailDOList) {
|
|
|
|
|
|
|
|
//车间仓投料出库
|
|
|
|
|
|
|
|
StockWorkshopDO workshopDO = new StockWorkshopDO()
|
|
|
|
|
|
|
|
.setItemId(detail.getItemId()).setUnitId(detail.getUnitId())
|
|
|
|
|
|
|
|
.setCount(detail.getWeight().multiply(BigDecimal.valueOf(-1)))
|
|
|
|
|
|
|
|
.setCategoryId(1L);
|
|
|
|
|
|
|
|
workshopService.updateStock(workshopDO, StockWorkShopTypeEnum.投料出库.getValue(),
|
|
|
|
|
|
|
|
recordDO.getId(), recordDO.getFeedingRecordCode());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//分配给计划
|
|
|
|
|
|
|
|
FeedingRecordPlanDO recordPlanDO = new FeedingRecordPlanDO()
|
|
|
|
|
|
|
|
.setPlanId(plan.getId())
|
|
|
|
|
|
|
|
.setItemId(plan.getProductId())
|
|
|
|
|
|
|
|
.setRecordId(detail.getRecordId()).setUserId(user.getId()).setUnitId(detail.getUnitId())
|
|
|
|
|
|
|
|
.setRecordDetailId(detail.getId()).setFeedingTime(detail.getFeedingTime())
|
|
|
|
|
|
|
|
.setWeight(detail.getWeight());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
recordPlanMapper.insert(recordPlanDO);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//更新对应投料单投料时间
|
|
|
|
|
|
|
|
ItemRequisitionDO itemRequisitionDO = itemRequisitionService.getItemRequisitionByPlanId(plan.getId());
|
|
|
|
|
|
|
|
if (itemRequisitionDO != null && itemRequisitionDO.getDeliveryDate()==null) {
|
|
|
|
|
|
|
|
itemRequisitionDO.setDeliveryDate(LocalDate.now());
|
|
|
|
|
|
|
|
itemRequisitionMapper.updateById(itemRequisitionDO);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|