no message
parent
c3dcafc53f
commit
7a418eda87
|
|
@ -1,18 +1,18 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2019-2020 Zheng Jie
|
* Copyright 2019-2020 Zheng Jie
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.youchain.basicdata.repository;
|
package com.youchain.basicdata.repository;
|
||||||
|
|
||||||
import com.youchain.basicdata.domain.BigItem;
|
import com.youchain.basicdata.domain.BigItem;
|
||||||
|
|
@ -24,11 +24,11 @@ import org.springframework.data.jpa.repository.Query;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @website https://eladmin.vip
|
* @author shenyinan
|
||||||
* @author shenyinan
|
* @website https://eladmin.vip
|
||||||
* @date 2024-02-21
|
* @date 2024-02-21
|
||||||
**/
|
**/
|
||||||
public interface BigItemRepository extends JpaRepository<BigItem, Long>, JpaSpecificationExecutor<BigItem> {
|
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)
|
@Query(value = "SELECT i FROM BigItem i WHERE i.code = ?1 ")
|
||||||
List<BigItem> findRepeat(String completeCode, String completeName);
|
BigItem findByBigItemCode(String completeCode);
|
||||||
}
|
}
|
||||||
|
|
@ -1,18 +1,18 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2019-2020 Zheng Jie
|
* Copyright 2019-2020 Zheng Jie
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.youchain.basicdata.repository;
|
package com.youchain.basicdata.repository;
|
||||||
|
|
||||||
import com.youchain.basicdata.domain.Item;
|
import com.youchain.basicdata.domain.Item;
|
||||||
|
|
@ -23,11 +23,11 @@ import org.springframework.data.jpa.repository.Query;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @website https://eladmin.vip
|
* @author houjianlan
|
||||||
* @author houjianlan
|
* @website https://eladmin.vip
|
||||||
* @date 2023-08-16
|
* @date 2023-08-16
|
||||||
**/
|
**/
|
||||||
public interface ItemRepository extends JpaRepository<Item, Long>, JpaSpecificationExecutor<Item> {
|
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)
|
@Query(value = "FROM Item i WHERE i.code = ?1 ")
|
||||||
List<Item> findRepeat(String code, String name);
|
Item findByItemCode(String code);
|
||||||
}
|
}
|
||||||
|
|
@ -1,18 +1,18 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2019-2020 Zheng Jie
|
* Copyright 2019-2020 Zheng Jie
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.youchain.businessdata.repository;
|
package com.youchain.businessdata.repository;
|
||||||
|
|
||||||
import com.youchain.businessdata.domain.Gd;
|
import com.youchain.businessdata.domain.Gd;
|
||||||
|
|
@ -23,12 +23,18 @@ import org.springframework.data.jpa.repository.Query;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @website https://eladmin.vip
|
* @author huojin
|
||||||
* @author huojin
|
* @website https://eladmin.vip
|
||||||
* @date 2024-06-06
|
* @date 2024-06-06
|
||||||
**/
|
**/
|
||||||
public interface GdRepository extends JpaRepository<Gd, Long>, JpaSpecificationExecutor<Gd> {
|
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)
|
* 查询gd列表
|
||||||
List<Gd> findRepeat(String code, String name, String station);
|
* @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
|
@AnonymousAccess
|
||||||
public ResponseEntity<Object> yclbl(@Validated @RequestBody Yclbl yclbl) {
|
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) {
|
if (yclbl.getBlzc() != null) {
|
||||||
String orderType = BaseStatus.GD_TYPE_CT;
|
String orderType = BaseStatus.GD_TYPE_CT;
|
||||||
Set<ZcData> blzc = yclbl.getBlzc();
|
Set<ZcData> blzc = yclbl.getBlzc();
|
||||||
for (ZcData zcData : blzc) {
|
for (ZcData zcData : blzc) {
|
||||||
/* 验证成套 物料*/
|
/* 验证成套 物料*/
|
||||||
BigItem bigItem = verifiedBigItem(zcData.getCompleteCode(), zcData.getCompleteName());
|
BigItem bigItem = verifiedBigItem(zcData.getCompleteCode());
|
||||||
Set<ItemDate> itemDates = zcData.getBlzcmx();
|
Set<ItemDate> itemDates = zcData.getBlzcmx();
|
||||||
for (ItemDate itemDate : itemDates) {
|
for (ItemDate itemDate : itemDates) {
|
||||||
/* 验证单品 物料*/
|
/* 验证单品 物料*/
|
||||||
Item item = verifiedItem(itemDate.getItemCode(), itemDate.getItemName());
|
Item item = verifiedItem(itemDate.getItemCode());
|
||||||
/* 验证BOM*/
|
/* 验证BOM*/
|
||||||
BigBom bigBom = verifiedBigBom(bigItem, item, itemDate.getItemQty());
|
BigBom bigBom = verifiedBigBom(bigItem, item, itemDate.getItemQty());
|
||||||
/* 添加工单明细*/
|
/* 添加工单明细*/
|
||||||
|
|
@ -80,7 +80,7 @@ public class MesController {
|
||||||
Set<ItemDate> itemDateList = yclbl.getBlzcmx();
|
Set<ItemDate> itemDateList = yclbl.getBlzcmx();
|
||||||
for (ItemDate itemDate : itemDateList) {
|
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());
|
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) {
|
private BigItem verifiedBigItem(String completeCode) {
|
||||||
List<BigItem> bigItemList = bigItemRepository.findRepeat(completeCode, completeName);
|
BigItem bigItem = bigItemRepository.findByBigItemCode(completeCode);
|
||||||
if (bigItemList.size() > 0) {
|
if (bigItem == null) {
|
||||||
return bigItemList.get(0);
|
|
||||||
} else {
|
|
||||||
throw new BadRequestException(HttpStatus.INTERNAL_SERVER_ERROR, "未维护成套物料" + completeCode);
|
throw new BadRequestException(HttpStatus.INTERNAL_SERVER_ERROR, "未维护成套物料" + completeCode);
|
||||||
|
} else {
|
||||||
|
return bigItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Item verifiedItem(String itemCode, String itemName) {
|
private Item verifiedItem(String itemCode) {
|
||||||
List<Item> itemList = itemRepository.findRepeat(itemCode, itemName);
|
Item item = itemRepository.findByItemCode(itemCode);
|
||||||
if (itemList.size() > 0) {
|
if (item == null) {
|
||||||
return itemList.get(0);
|
|
||||||
} else {
|
|
||||||
throw new BadRequestException(HttpStatus.INTERNAL_SERVER_ERROR, "未维护单品物料" + itemCode);
|
throw new BadRequestException(HttpStatus.INTERNAL_SERVER_ERROR, "未维护单品物料" + itemCode);
|
||||||
|
} else {
|
||||||
|
return item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@
|
||||||
*/
|
*/
|
||||||
package com.youchain.businessdata.service;
|
package com.youchain.businessdata.service;
|
||||||
|
|
||||||
|
import com.youchain.RequestData.Yclbl;
|
||||||
import com.youchain.businessdata.domain.Gd;
|
import com.youchain.businessdata.domain.Gd;
|
||||||
import com.youchain.businessdata.service.dto.GdDto;
|
import com.youchain.businessdata.service.dto.GdDto;
|
||||||
import com.youchain.businessdata.service.dto.GdQueryCriteria;
|
import com.youchain.businessdata.service.dto.GdQueryCriteria;
|
||||||
|
|
@ -81,8 +82,14 @@ public interface GdService {
|
||||||
*/
|
*/
|
||||||
void download(List<GdDto> all, HttpServletResponse response) throws IOException;
|
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);
|
void addPickDetail(Gd gd);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 原材料备料
|
||||||
|
* @param yclbl 原材料备料
|
||||||
|
*/
|
||||||
|
void materialBL(Yclbl yclbl);
|
||||||
}
|
}
|
||||||
|
|
@ -1,21 +1,28 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2019-2020 Zheng Jie
|
* Copyright 2019-2020 Zheng Jie
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.youchain.businessdata.service.impl;
|
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.domain.Point;
|
||||||
|
import com.youchain.basicdata.repository.BigItemRepository;
|
||||||
|
import com.youchain.basicdata.repository.ItemRepository;
|
||||||
import com.youchain.basicdata.repository.PointRepository;
|
import com.youchain.basicdata.repository.PointRepository;
|
||||||
import com.youchain.businessdata.domain.Gd;
|
import com.youchain.businessdata.domain.Gd;
|
||||||
import com.youchain.businessdata.domain.GdDetail;
|
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.repository.PickRepository;
|
||||||
import com.youchain.businessdata.service.PickDetailService;
|
import com.youchain.businessdata.service.PickDetailService;
|
||||||
import com.youchain.businessdata.service.PickService;
|
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.modules.system.service.DeptService;
|
||||||
import com.youchain.utils.*;
|
import com.youchain.utils.*;
|
||||||
import lombok.RequiredArgsConstructor;
|
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.GdDto;
|
||||||
import com.youchain.businessdata.service.dto.GdQueryCriteria;
|
import com.youchain.businessdata.service.dto.GdQueryCriteria;
|
||||||
import com.youchain.businessdata.service.mapstruct.GdMapper;
|
import com.youchain.businessdata.service.mapstruct.GdMapper;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
|
|
@ -43,40 +51,43 @@ import java.io.IOException;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @website https://eladmin.vip
|
* @author huojin
|
||||||
* @description 服务实现
|
* @website https://eladmin.vip
|
||||||
* @author huojin
|
* @description 服务实现
|
||||||
* @date 2024-06-06
|
* @date 2024-06-06
|
||||||
**/
|
**/
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class GdServiceImpl implements GdService {
|
public class GdServiceImpl implements GdService {
|
||||||
|
|
||||||
private final GdRepository gdRepository;
|
private final GdRepository gdRepository;
|
||||||
private final GdDetailRepository gdDetailRepository;
|
private final GdDetailRepository gdDetailRepository;
|
||||||
|
private final BigItemRepository bigItemRepository;
|
||||||
|
private final ItemRepository itemRepository;
|
||||||
private final PickService pickService;
|
private final PickService pickService;
|
||||||
private final PickRepository pickRepository;
|
private final PickRepository pickRepository;
|
||||||
private final PointRepository pointRepository;
|
private final PointRepository pointRepository;
|
||||||
private final PickDetailService pickDetailService;
|
private final PickDetailService pickDetailService;
|
||||||
private final DeptService deptService;
|
private final DeptService deptService;
|
||||||
private final GdMapper gdMapper;
|
private final GdMapper gdMapper;
|
||||||
|
private final RedisObjectUtils redisObjectUtils;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String,Object> queryAll(GdQueryCriteria criteria, Pageable pageable){
|
public Map<String, Object> queryAll(GdQueryCriteria criteria, Pageable pageable) {
|
||||||
Page<Gd> page = gdRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
Page<Gd> page = gdRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable);
|
||||||
return PageUtil.toPage(page.map(gdMapper::toDto));
|
return PageUtil.toPage(page.map(gdMapper::toDto));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<GdDto> queryAll(GdQueryCriteria criteria){
|
public List<GdDto> queryAll(GdQueryCriteria criteria) {
|
||||||
return gdMapper.toDto(gdRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
|
return gdMapper.toDto(gdRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public GdDto findById(Long id) {
|
public GdDto findById(Long id) {
|
||||||
Gd gd = gdRepository.findById(id).orElseGet(Gd::new);
|
Gd gd = gdRepository.findById(id).orElseGet(Gd::new);
|
||||||
ValidationUtil.isNull(gd.getId(),"Gd","id",id);
|
ValidationUtil.isNull(gd.getId(), "Gd", "id", id);
|
||||||
return gdMapper.toDto(gd);
|
return gdMapper.toDto(gd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -90,7 +101,7 @@ public class GdServiceImpl implements GdService {
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void update(Gd resources) {
|
public void update(Gd resources) {
|
||||||
Gd gd = gdRepository.findById(resources.getId()).orElseGet(Gd::new);
|
Gd gd = gdRepository.findById(resources.getId()).orElseGet(Gd::new);
|
||||||
ValidationUtil.isNull( gd.getId(),"Gd","id",resources.getId());
|
ValidationUtil.isNull(gd.getId(), "Gd", "id", resources.getId());
|
||||||
gd.copy(resources);
|
gd.copy(resources);
|
||||||
gdRepository.save(gd);
|
gdRepository.save(gd);
|
||||||
}
|
}
|
||||||
|
|
@ -106,7 +117,7 @@ public class GdServiceImpl implements GdService {
|
||||||
public void download(List<GdDto> all, HttpServletResponse response) throws IOException {
|
public void download(List<GdDto> all, HttpServletResponse response) throws IOException {
|
||||||
List<Map<String, Object>> list = new ArrayList<>();
|
List<Map<String, Object>> list = new ArrayList<>();
|
||||||
for (GdDto gd : all) {
|
for (GdDto gd : all) {
|
||||||
Map<String,Object> map = new LinkedHashMap<>();
|
Map<String, Object> map = new LinkedHashMap<>();
|
||||||
map.put("创建人", gd.getCreateBy());
|
map.put("创建人", gd.getCreateBy());
|
||||||
map.put("修改人", gd.getUpdateBy());
|
map.put("修改人", gd.getUpdateBy());
|
||||||
map.put("创建时间", gd.getCreateTime());
|
map.put("创建时间", gd.getCreateTime());
|
||||||
|
|
@ -121,49 +132,106 @@ public class GdServiceImpl implements GdService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Gd save(String orderNo, String taskCode, String station) {
|
@Transactional(rollbackFor = Exception.class)
|
||||||
List<Gd> gdList=gdRepository.findRepeat(orderNo,taskCode,station);
|
public Gd createGd(String orderNo, String taskCode, String station) {
|
||||||
if (gdList.size()>0){
|
Gd gd = new Gd();
|
||||||
return gdList.get(0);
|
gd.setCode(orderNo);
|
||||||
}else {
|
gd.setName(taskCode);
|
||||||
Gd gd=new Gd();
|
gd.setStation(station);
|
||||||
gd.setCode(orderNo);
|
gd.setStatus(BizStatus.OPEN);
|
||||||
gd.setName(taskCode);
|
gd.setDept(deptService.isDept());
|
||||||
gd.setStation(station);
|
gdRepository.save(gd);
|
||||||
gd.setStatus(BizStatus.OPEN);
|
return gd;
|
||||||
gd.setDept(deptService.isDept());
|
|
||||||
gdRepository.save(gd);
|
|
||||||
return gd;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addPickDetail(Gd gd) {
|
public void addPickDetail(Gd gd) {
|
||||||
int no=1;// 序号
|
int no = 1;// 序号
|
||||||
while (true){
|
while (true) {
|
||||||
List<GdDetail> gdDetailList=gdDetailRepository.findByGdAndQty(gd.getId());
|
List<GdDetail> gdDetailList = gdDetailRepository.findByGdAndQty(gd.getId());
|
||||||
if (gdDetailList.size()<1){
|
if (gdDetailList.size() < 1) {
|
||||||
break;
|
break;
|
||||||
}else {
|
} else {
|
||||||
List<Integer> arr=new ArrayList<Integer>();//已分配过的行号
|
List<Integer> arr = new ArrayList<Integer>();//已分配过的行号
|
||||||
for (GdDetail gdDetail : gdDetailList) {
|
for (GdDetail gdDetail : gdDetailList) {
|
||||||
/*本次循环已拆分过 工单明细行*/
|
/*本次循环已拆分过 工单明细行*/
|
||||||
if (arr.contains(gdDetail.getLineNo())){
|
if (arr.contains(gdDetail.getLineNo())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/*生成出库单*/
|
/*生成出库单*/
|
||||||
Pick pick = pickService.save(gdDetail, no);
|
Pick pick = pickService.save(gdDetail, no);
|
||||||
/* 去重*/
|
/* 去重*/
|
||||||
arr.add(gdDetail.getLineNo());
|
arr.add(gdDetail.getLineNo());
|
||||||
no=no+1;
|
no = no + 1;
|
||||||
/*生成出库明细*/
|
/*生成出库明细*/
|
||||||
pickDetailService.save(pick);
|
pickDetailService.save(pick);
|
||||||
/*添加 默认目标备料点位*/
|
/*添加 默认目标备料点位*/
|
||||||
Point point=pointRepository.getById(2195l);
|
Point point = pointRepository.getById(2195l);
|
||||||
pick.setPoint(point);
|
pick.setPoint(point);
|
||||||
pickRepository.save(pick);
|
pickRepository.save(pick);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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