no message
parent
c3dcafc53f
commit
7a418eda87
|
|
@ -24,11 +24,11 @@ import org.springframework.data.jpa.repository.Query;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @author shenyinan
|
||||
* @website https://eladmin.vip
|
||||
* @date 2024-02-21
|
||||
**/
|
||||
public interface BigItemRepository extends JpaRepository<BigItem, Long>, JpaSpecificationExecutor<BigItem> {
|
||||
@Query(value = "SELECT i FROM BigItem i WHERE i.code = ?1 and i.name=?2", nativeQuery = false)
|
||||
List<BigItem> findRepeat(String completeCode, String completeName);
|
||||
@Query(value = "SELECT i FROM BigItem i WHERE i.code = ?1 ")
|
||||
BigItem findByBigItemCode(String completeCode);
|
||||
}
|
||||
|
|
@ -23,11 +23,11 @@ import org.springframework.data.jpa.repository.Query;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @author houjianlan
|
||||
* @website https://eladmin.vip
|
||||
* @date 2023-08-16
|
||||
**/
|
||||
public interface ItemRepository extends JpaRepository<Item, Long>, JpaSpecificationExecutor<Item> {
|
||||
@Query(value = "SELECT i FROM Item i WHERE i.code = ?1 and i.name=?2", nativeQuery = false)
|
||||
List<Item> findRepeat(String code, String name);
|
||||
@Query(value = "FROM Item i WHERE i.code = ?1 ")
|
||||
Item findByItemCode(String code);
|
||||
}
|
||||
|
|
@ -23,12 +23,18 @@ import org.springframework.data.jpa.repository.Query;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @author huojin
|
||||
* @website https://eladmin.vip
|
||||
* @date 2024-06-06
|
||||
**/
|
||||
public interface GdRepository extends JpaRepository<Gd, Long>, JpaSpecificationExecutor<Gd> {
|
||||
/** 查询重复数据*/
|
||||
@Query(value = "SELECT g FROM Gd g WHERE g.code=?1 and g.name=?2 and g.station=?3 ", nativeQuery = false)
|
||||
List<Gd> findRepeat(String code, String name, String station);
|
||||
/**
|
||||
* 查询gd列表
|
||||
* @param code
|
||||
* @param name
|
||||
* @param station
|
||||
* @return
|
||||
*/
|
||||
@Query(value = " FROM Gd g WHERE g.code=?1 and g.name=?2 and g.station=?3 ")
|
||||
Gd findByGdList(String code, String name, String station);
|
||||
}
|
||||
|
|
@ -57,17 +57,17 @@ public class MesController {
|
|||
@AnonymousAccess
|
||||
public ResponseEntity<Object> yclbl(@Validated @RequestBody Yclbl yclbl) {
|
||||
/* 添加工单单头*/
|
||||
Gd gd = gdService.save(yclbl.getOrderNo(), yclbl.getTaskCode(), yclbl.getStation());
|
||||
Gd gd = gdService.createGd(yclbl.getOrderNo(), yclbl.getTaskCode(), yclbl.getStation());
|
||||
if (yclbl.getBlzc() != null) {
|
||||
String orderType = BaseStatus.GD_TYPE_CT;
|
||||
Set<ZcData> blzc = yclbl.getBlzc();
|
||||
for (ZcData zcData : blzc) {
|
||||
/* 验证成套 物料*/
|
||||
BigItem bigItem = verifiedBigItem(zcData.getCompleteCode(), zcData.getCompleteName());
|
||||
BigItem bigItem = verifiedBigItem(zcData.getCompleteCode());
|
||||
Set<ItemDate> itemDates = zcData.getBlzcmx();
|
||||
for (ItemDate itemDate : itemDates) {
|
||||
/* 验证单品 物料*/
|
||||
Item item = verifiedItem(itemDate.getItemCode(), itemDate.getItemName());
|
||||
Item item = verifiedItem(itemDate.getItemCode());
|
||||
/* 验证BOM*/
|
||||
BigBom bigBom = verifiedBigBom(bigItem, item, itemDate.getItemQty());
|
||||
/* 添加工单明细*/
|
||||
|
|
@ -80,7 +80,7 @@ public class MesController {
|
|||
Set<ItemDate> itemDateList = yclbl.getBlzcmx();
|
||||
for (ItemDate itemDate : itemDateList) {
|
||||
/* 验证单品物料*/
|
||||
Item item = verifiedItem(itemDate.getItemCode(), itemDate.getItemName());
|
||||
Item item = verifiedItem(itemDate.getItemCode());
|
||||
/* 添加工单明细*/
|
||||
GdDetail gdDetail = gdDetailService.save(itemDate.getLineNo(), gd, orderType, null, null, item, itemDate.getItemQty(), itemDate.getItemQty());
|
||||
}
|
||||
|
|
@ -156,21 +156,21 @@ public class MesController {
|
|||
/**
|
||||
* 验证成套物料
|
||||
*/
|
||||
private BigItem verifiedBigItem(String completeCode, String completeName) {
|
||||
List<BigItem> bigItemList = bigItemRepository.findRepeat(completeCode, completeName);
|
||||
if (bigItemList.size() > 0) {
|
||||
return bigItemList.get(0);
|
||||
} else {
|
||||
private BigItem verifiedBigItem(String completeCode) {
|
||||
BigItem bigItem = bigItemRepository.findByBigItemCode(completeCode);
|
||||
if (bigItem == null) {
|
||||
throw new BadRequestException(HttpStatus.INTERNAL_SERVER_ERROR, "未维护成套物料" + completeCode);
|
||||
} else {
|
||||
return bigItem;
|
||||
}
|
||||
}
|
||||
|
||||
private Item verifiedItem(String itemCode, String itemName) {
|
||||
List<Item> itemList = itemRepository.findRepeat(itemCode, itemName);
|
||||
if (itemList.size() > 0) {
|
||||
return itemList.get(0);
|
||||
} else {
|
||||
private Item verifiedItem(String itemCode) {
|
||||
Item item = itemRepository.findByItemCode(itemCode);
|
||||
if (item == null) {
|
||||
throw new BadRequestException(HttpStatus.INTERNAL_SERVER_ERROR, "未维护单品物料" + itemCode);
|
||||
} else {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
package com.youchain.businessdata.service;
|
||||
|
||||
import com.youchain.RequestData.Yclbl;
|
||||
import com.youchain.businessdata.domain.Gd;
|
||||
import com.youchain.businessdata.service.dto.GdDto;
|
||||
import com.youchain.businessdata.service.dto.GdQueryCriteria;
|
||||
|
|
@ -81,8 +82,14 @@ public interface GdService {
|
|||
*/
|
||||
void download(List<GdDto> all, HttpServletResponse response) throws IOException;
|
||||
|
||||
Gd save(String orderNo, String taskCode, String station);
|
||||
Gd createGd(String orderNo, String taskCode, String station);
|
||||
|
||||
/** 根据工单,申城出库明细*/
|
||||
void addPickDetail(Gd gd);
|
||||
|
||||
/**
|
||||
* 原材料备料
|
||||
* @param yclbl 原材料备料
|
||||
*/
|
||||
void materialBL(Yclbl yclbl);
|
||||
}
|
||||
|
|
@ -15,7 +15,14 @@
|
|||
*/
|
||||
package com.youchain.businessdata.service.impl;
|
||||
|
||||
import com.youchain.RequestData.ItemDate;
|
||||
import com.youchain.RequestData.Yclbl;
|
||||
import com.youchain.RequestData.ZcData;
|
||||
import com.youchain.basicdata.domain.BigItem;
|
||||
import com.youchain.basicdata.domain.Item;
|
||||
import com.youchain.basicdata.domain.Point;
|
||||
import com.youchain.basicdata.repository.BigItemRepository;
|
||||
import com.youchain.basicdata.repository.ItemRepository;
|
||||
import com.youchain.basicdata.repository.PointRepository;
|
||||
import com.youchain.businessdata.domain.Gd;
|
||||
import com.youchain.businessdata.domain.GdDetail;
|
||||
|
|
@ -24,7 +31,7 @@ import com.youchain.businessdata.repository.GdDetailRepository;
|
|||
import com.youchain.businessdata.repository.PickRepository;
|
||||
import com.youchain.businessdata.service.PickDetailService;
|
||||
import com.youchain.businessdata.service.PickService;
|
||||
import com.youchain.modules.system.domain.Dept;
|
||||
import com.youchain.exception.BadRequestException;
|
||||
import com.youchain.modules.system.service.DeptService;
|
||||
import com.youchain.utils.*;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
|
@ -33,6 +40,7 @@ import com.youchain.businessdata.service.GdService;
|
|||
import com.youchain.businessdata.service.dto.GdDto;
|
||||
import com.youchain.businessdata.service.dto.GdQueryCriteria;
|
||||
import com.youchain.businessdata.service.mapstruct.GdMapper;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.data.domain.Page;
|
||||
|
|
@ -43,9 +51,9 @@ import java.io.IOException;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @author huojin
|
||||
* @website https://eladmin.vip
|
||||
* @description 服务实现
|
||||
* @author huojin
|
||||
* @date 2024-06-06
|
||||
**/
|
||||
@Service
|
||||
|
|
@ -54,12 +62,15 @@ public class GdServiceImpl implements GdService {
|
|||
|
||||
private final GdRepository gdRepository;
|
||||
private final GdDetailRepository gdDetailRepository;
|
||||
private final BigItemRepository bigItemRepository;
|
||||
private final ItemRepository itemRepository;
|
||||
private final PickService pickService;
|
||||
private final PickRepository pickRepository;
|
||||
private final PointRepository pointRepository;
|
||||
private final PickDetailService pickDetailService;
|
||||
private final DeptService deptService;
|
||||
private final GdMapper gdMapper;
|
||||
private final RedisObjectUtils redisObjectUtils;
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryAll(GdQueryCriteria criteria, Pageable pageable) {
|
||||
|
|
@ -121,11 +132,8 @@ public class GdServiceImpl implements GdService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Gd save(String orderNo, String taskCode, String station) {
|
||||
List<Gd> gdList=gdRepository.findRepeat(orderNo,taskCode,station);
|
||||
if (gdList.size()>0){
|
||||
return gdList.get(0);
|
||||
}else {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Gd createGd(String orderNo, String taskCode, String station) {
|
||||
Gd gd = new Gd();
|
||||
gd.setCode(orderNo);
|
||||
gd.setName(taskCode);
|
||||
|
|
@ -135,7 +143,6 @@ public class GdServiceImpl implements GdService {
|
|||
gdRepository.save(gd);
|
||||
return gd;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPickDetail(Gd gd) {
|
||||
|
|
@ -166,4 +173,65 @@ public class GdServiceImpl implements GdService {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void materialBL(Yclbl yclbl) {
|
||||
|
||||
validateGd(yclbl);//验证参数有效性
|
||||
Gd gd = gdRepository.findByGdList(yclbl.getOrderNo(), yclbl.getTaskCode(), yclbl.getStation());//查询备料工单是否存在
|
||||
if (gd != null) {
|
||||
throw new IllegalArgumentException(yclbl.getOrderNo() + "备料工单已存在!");
|
||||
}
|
||||
this.createGd(yclbl.getOrderNo(), yclbl.getTaskCode(), yclbl.getStation());//创建备料工单
|
||||
|
||||
//添加备料明细
|
||||
if (!yclbl.getBlzc().isEmpty()) {
|
||||
String orderType = BaseStatus.GD_TYPE_CT;
|
||||
Set<ZcData> blzc = yclbl.getBlzc();
|
||||
for (ZcData zcData : blzc) {
|
||||
BigItem bigItem = validateBigItem(zcData.getCompleteCode());//验证成品是否存在
|
||||
Set<ItemDate> itemDates = zcData.getBlzcmx();
|
||||
for (ItemDate itemDate : itemDates) {
|
||||
Item item = validateItem(itemDate.getItemCode());//验证单品是否存在
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void validateGd(Yclbl yclbl) {
|
||||
if (StringUtils.isEmpty(yclbl.getOrderNo())) {
|
||||
throw new IllegalArgumentException("工单号不能为空!");
|
||||
}
|
||||
if (StringUtils.isEmpty(yclbl.getTaskCode())) {
|
||||
throw new IllegalArgumentException("任务号不能为空!");
|
||||
}
|
||||
if (StringUtils.isEmpty(yclbl.getStation())) {
|
||||
throw new IllegalArgumentException("需求工位不能为空!");
|
||||
}
|
||||
if (yclbl.getBlzc().isEmpty() && yclbl.getBlzcmx().isEmpty()) {
|
||||
throw new IllegalArgumentException("成品明细和单品明细不能为空!");
|
||||
}
|
||||
|
||||
if (!yclbl.getBlzc().isEmpty()) {
|
||||
for (ZcData zcData : yclbl.getBlzc()) {
|
||||
if (zcData.getBlzcmx().isEmpty()) {
|
||||
throw new IllegalArgumentException("成品明细里面的单品明细不能为空!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private BigItem validateBigItem(String completeCode) {
|
||||
BigItem bigItem = redisObjectUtils.getObjectFromCache(completeCode, () -> bigItemRepository.findByBigItemCode(completeCode), completeCode + "成品物料不存在,请维护!");
|
||||
return bigItem;
|
||||
}
|
||||
|
||||
private Item validateItem(String itemCode) {
|
||||
Item item = redisObjectUtils.getObjectFromCache(itemCode, () -> itemRepository.findByItemCode(itemCode), itemCode + "单品物料不存在,请维护!");
|
||||
return item;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue