From 83c548d3dba59aaed9b52b5d413c6912a87d2efc Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期日, 16 六月 2024 15:50:14 +0800
Subject: [PATCH] #
---
zy-asrs-common/src/main/java/com/zy/asrs/common/openapi/service/impl/ApiServiceImpl.java | 300 +++++++++++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 279 insertions(+), 21 deletions(-)
diff --git a/zy-asrs-common/src/main/java/com/zy/asrs/common/openapi/service/impl/ApiServiceImpl.java b/zy-asrs-common/src/main/java/com/zy/asrs/common/openapi/service/impl/ApiServiceImpl.java
index 5f1a4da..13b0042 100644
--- a/zy-asrs-common/src/main/java/com/zy/asrs/common/openapi/service/impl/ApiServiceImpl.java
+++ b/zy-asrs-common/src/main/java/com/zy/asrs/common/openapi/service/impl/ApiServiceImpl.java
@@ -2,7 +2,8 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zy.asrs.common.domain.dto.DetlDto;
-import com.zy.asrs.common.openapi.entity.param.GenerateOrderPakInParam;
+import com.zy.asrs.common.openapi.entity.dto.OrderListDto;
+import com.zy.asrs.common.openapi.entity.param.*;
import com.zy.asrs.common.openapi.service.ApiService;
import com.zy.asrs.common.wms.entity.*;
import com.zy.asrs.common.wms.service.*;
@@ -12,6 +13,7 @@
import com.zy.asrs.framework.exception.CoolException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
@@ -23,15 +25,17 @@
@Autowired
private OrderService orderService;
@Autowired
+ private OrderDetlService orderDetlService;
+ @Autowired
private DocTypeService docTypeService;
@Autowired
private SnowflakeIdWorker snowflakeIdWorker;
@Autowired
private MatService matService;
@Autowired
- private OrderDetlService orderDetlService;
+ private OrderSettleService orderSettleService;
@Autowired
- private WaitPakinService waitPakinService;
+ private TagService tagService;
@Override
public void generateOrderPakIn(GenerateOrderPakInParam param) {
@@ -85,28 +89,20 @@
if (!orderService.save(order)) {
throw new CoolException("鐢熸垚鍗曟嵁涓绘。澶辫触锛岃鑱旂郴绠$悊鍛�");
}
- // 鍗曟嵁鏄庣粏妗�
- List<DetlDto> list = new ArrayList<>();
- List<DetlDto> orderDetails = param.getOrderDetails();
- for (DetlDto detail : orderDetails) {
- DetlDto dto = new DetlDto(detail.getMatnr(), detail.getBatch(), detail.getAnfme());
- if (DetlDto.has(list, dto)) {
- DetlDto detlDto = DetlDto.find(list, dto.getMatnr(), dto.getBatch());
- assert detlDto != null;
- detlDto.setAnfme(detlDto.getAnfme() + detail.getAnfme());
- } else {
- list.add(dto);
- }
- }
- for (DetlDto detlDto : list) {
- Mat mat = matService.getOne(new LambdaQueryWrapper<Mat>().eq(Mat::getMatnr, detlDto.getMatnr()).eq(Mat::getHostId, param.getHostId()));
+ List<GenerateOrderMatParam> mats = param.getMats();
+ for (GenerateOrderMatParam matParam : mats) {
+ Mat mat = matService.getOne(new LambdaQueryWrapper<Mat>().eq(Mat::getMatnr, matParam.getMatnr()).eq(Mat::getHostId, param.getHostId()));
if (Cools.isEmpty(mat)) {
- throw new CoolException(detlDto.getMatnr() + "缂栧彿鍟嗗搧妫�绱㈠け璐ワ紝璇峰厛娣诲姞鍟嗗搧");
+ throw new CoolException(matParam.getMatnr() + "缂栧彿鍟嗗搧妫�绱㈠け璐ワ紝璇峰厛娣诲姞鍟嗗搧");
}
OrderDetl orderDetl = new OrderDetl();
orderDetl.sync(mat);
- orderDetl.setBatch(detlDto.getBatch());
- orderDetl.setAnfme(detlDto.getAnfme());
+ orderDetl.setBatch(matParam.getBatch());
+ orderDetl.setAnfme(matParam.getAnfme());
+ orderDetl.setUnit(matParam.getUnit());
+ orderDetl.setThreeCode(matParam.getWarehouse());//浠撳簱鍙�
+ orderDetl.setSupp(matParam.getOrigin());//鏉ユ簮鍗曞彿
+ orderDetl.setSuppCode(matParam.getOriginNo());//鏉ユ簮搴忓彿
orderDetl.setOrderId(order.getId());
orderDetl.setOrderNo(order.getOrderNo());
orderDetl.setCreateBy(9527L);
@@ -122,8 +118,270 @@
}
@Override
+ public void generateOrderPakOut(GenerateOrderPakOutParam param) {
+ Order order = orderService.selectByNo(param.getOrderNo(), param.getHostId());
+ // 濡傛灉鍗曟嵁涓嶅瓨鍦ㄥ垯娣诲姞锛涘鏋滃崟鎹瓨鍦紝浣滀笟涓棤娉曚慨鏀癸紝鍙嶄箣鍒欎慨鏀瑰崟鎹�
+ if (!Cools.isEmpty(order)) {
+ if (order.getSettle() > 1L) {
+ throw new CoolException(param.getOrderNo() + "姝e湪鍑哄簱锛屾棤娉曚慨鏀瑰崟鎹�");
+ }
+ orderService.removeById(order.getId());
+ }
+ DocType docType = docTypeService.getOne(new LambdaQueryWrapper<DocType>().eq(DocType::getDocId, param.getOrderType()));
+ if (docType == null) {
+ throw new CoolException("璁㈠崟绫诲瀷涓嶅瓨鍦�");
+ }
+ Date now = new Date();
+ // 鍗曟嵁涓绘。
+ order = new Order(
+ String.valueOf(snowflakeIdWorker.nextId()), // 缂栧彿[闈炵┖]
+ param.getOrderNo(), // 璁㈠崟缂栧彿
+ DateUtils.convert(now), // 鍗曟嵁鏃ユ湡
+ docType.getDocId(), // 鍗曟嵁绫诲瀷
+ null, // 椤圭洰缂栧彿
+ null, //
+ null, // 璋冩嫧椤圭洰缂栧彿
+ null, // 鍒濆绁ㄦ嵁鍙�
+ null, // 绁ㄦ嵁鍙�
+ null, // 瀹㈡埛缂栧彿
+ null, // 瀹㈡埛
+ null, // 鑱旂郴鏂瑰紡
+ null, // 鎿嶄綔浜哄憳
+ null, // 鍚堣閲戦
+ null, // 浼樻儬鐜�
+ null, // 浼樻儬閲戦
+ null, // 閿�鍞垨閲囪喘璐圭敤鍚堣
+ null, // 瀹炰粯閲戦
+ null, // 浠樻绫诲瀷
+ null, // 涓氬姟鍛�
+ null, // 缁撶畻澶╂暟
+ null, // 閭垂鏀粯绫诲瀷
+ null, // 閭垂
+ null, // 浠樻鏃堕棿
+ null, // 鍙戣揣鏃堕棿
+ null, // 鐗╂祦鍚嶇О
+ null, // 鐗╂祦鍗曞彿
+ 1L, // 璁㈠崟鐘舵��
+ 1, // 鐘舵��
+ 9527L, // 娣诲姞浜哄憳
+ now, // 娣诲姞鏃堕棿
+ 9527L, // 淇敼浜哄憳
+ now, // 淇敼鏃堕棿
+ null, // 澶囨敞
+ param.getHostId() //浠撳簱ID
+ );
+ if (!orderService.save(order)) {
+ throw new CoolException("鐢熸垚鍗曟嵁涓绘。澶辫触锛岃鑱旂郴绠$悊鍛�");
+ }
+ List<GenerateOrderMatParam> mats = param.getMats();
+ for (GenerateOrderMatParam matParam : mats) {
+ Mat mat = matService.getOne(new LambdaQueryWrapper<Mat>().eq(Mat::getMatnr, matParam.getMatnr()).eq(Mat::getHostId, param.getHostId()));
+ if (Cools.isEmpty(mat)) {
+ throw new CoolException(matParam.getMatnr() + "缂栧彿鍟嗗搧妫�绱㈠け璐ワ紝璇峰厛娣诲姞鍟嗗搧");
+ }
+ OrderDetl orderDetl = new OrderDetl();
+ orderDetl.sync(mat);
+ orderDetl.setBatch(matParam.getBatch());
+ orderDetl.setAnfme(matParam.getAnfme());
+ orderDetl.setOrderId(order.getId());
+ orderDetl.setOrderNo(order.getOrderNo());
+ orderDetl.setCreateBy(9527L);
+ orderDetl.setCreateTime(now);
+ orderDetl.setUpdateBy(9527L);
+ orderDetl.setUpdateTime(now);
+ orderDetl.setStatus(1);
+ orderDetl.setQty(0.0D);
+ orderDetl.setHostId(param.getHostId());
+ if (!orderDetlService.save(orderDetl)) {
+ throw new CoolException("鐢熸垚鍗曟嵁鏄庣粏澶辫触锛岃鑱旂郴绠$悊鍛�");
+ }
+ }
+ }
+
+ @Override
public List<DocType> getOrderType() {
List<DocType> list = docTypeService.list();
return list;
}
+
+ @Override
+ public List<OrderSettle> getOrderStatus() {
+ return orderSettleService.list();
+ }
+
+ @Override
+ public List<OrderListDto> getOrderList(OrderListParam param, Long hostId) {
+ ArrayList<OrderListDto> listDtos = new ArrayList<>();
+ LambdaQueryWrapper<Order> wrapper = new LambdaQueryWrapper<Order>().eq(Order::getHostId, hostId);
+ if (!Cools.isEmpty(param)) {
+ if (!Cools.isEmpty(param.getOrderType())) {
+ wrapper.eq(Order::getDocType, param.getOrderType());
+ }
+ if (!Cools.isEmpty(param.getOrderNo())) {
+ wrapper.eq(Order::getOrderNo, param.getOrderNo());
+ }
+ if (!Cools.isEmpty(param.getStatus())) {
+ wrapper.eq(Order::getStatus, param.getStatus());
+ }
+ }
+ List<Order> list = orderService.list(wrapper);
+ for (Order order : list) {
+ List<OrderDetl> orderDetls = orderDetlService.list(new LambdaQueryWrapper<OrderDetl>().eq(OrderDetl::getHostId, hostId).eq(OrderDetl::getOrderId, order.getId()));
+ OrderListDto dto = new OrderListDto();
+ dto.setOrder(order);
+ dto.setOrderDetls(orderDetls);
+ listDtos.add(dto);
+ }
+ return listDtos;
+ }
+
+ @Override
+ @Transactional
+ public int createMat(CreateMatParam param) {
+ int count = 0;
+ Long hostId = param.getHostId();
+ for (MatParam matParam : param.getMats()) {
+ //鑾峰彇鍒嗙被
+ Tag tag = tagService.getTag(matParam.getFirstTag(), matParam.getSecondTag(), hostId);
+
+ matService.remove(new LambdaQueryWrapper<Mat>()
+ .eq(Mat::getMatnr, matParam.getMatnr())
+ .eq(Mat::getHostId, hostId));
+ Mat mat = new Mat();
+ mat.setMatnr(matParam.getMatnr());//鐗╂枡鍙�
+ mat.setHostId(hostId);//浠撳簱ID
+ mat.setTagId(tag.getId());//鍒嗙被ID
+ if (!Cools.isEmpty(matParam.getShopCategory())) {
+ Tag shopTag = tagService.getOne(new LambdaQueryWrapper<Tag>()
+ .eq(Tag::getName, matParam.getShopCategory())
+ .eq(Tag::getHostId, hostId));
+ if (shopTag == null) {
+ //鍟嗗搧鍒嗙被涓虹┖锛屽垱寤哄晢鍝佸垎绫�
+ shopTag = new Tag();
+ shopTag.setName(matParam.getShopCategory());
+ shopTag.setParentId(tag.getId());
+ shopTag.setStatus(1);
+ shopTag.setHostId(hostId);
+ shopTag.setCreateTime(new Date());
+ shopTag.setUpdateTime(new Date());
+ tagService.save(shopTag);
+ }
+ mat.setTagId(shopTag.getId());//鍒嗙被ID
+ }
+
+ if (!Cools.isEmpty(matParam.getMaktx())) {
+ mat.setMaktx(matParam.getMaktx());
+ }
+ if (!Cools.isEmpty(matParam.getMaktx())) {
+ mat.setMaktx(matParam.getMaktx());
+ }
+ if (!Cools.isEmpty(matParam.getName())) {
+ mat.setName(matParam.getName());
+ }
+ if (!Cools.isEmpty(matParam.getSpecs())) {
+ mat.setSpecs(matParam.getSpecs());
+ }
+ if (!Cools.isEmpty(matParam.getMemo())) {
+ mat.setMemo(matParam.getMemo());
+ }
+ if (!Cools.isEmpty(matParam.getStatus())) {
+ mat.setStatus(matParam.getStatus());
+ }else {
+ mat.setStatus(1);
+ }
+
+ if (!Cools.isEmpty(matParam.getMainHost())) {
+ mat.setMainHost(matParam.getMainHost());
+ }
+ if (!Cools.isEmpty(matParam.getMainSource())) {
+ mat.setMainSource(matParam.getMainSource());
+ }
+ if (!Cools.isEmpty(matParam.getBarcode())) {
+ mat.setBarcode(matParam.getBarcode());
+ }
+ if (!Cools.isEmpty(matParam.getCyclePickCode())) {
+ mat.setCyclePickCode(matParam.getCyclePickCode());
+ }
+ if (!Cools.isEmpty(matParam.getLocationStock())) {
+ mat.setLocationStock(matParam.getLocationStock());
+ }
+ if (!Cools.isEmpty(matParam.getMaterial())) {
+ mat.setMaterial(matParam.getMaterial());
+ }
+ if (!Cools.isEmpty(matParam.getModel())) {
+ mat.setModel(matParam.getModel());
+ }
+ if (!Cools.isEmpty(matParam.getDecrees())) {
+ mat.setDecrees(matParam.getDecrees());
+ }
+ if (!Cools.isEmpty(matParam.getWeight())) {
+ mat.setWeight(matParam.getWeight());
+ }
+ if (!Cools.isEmpty(matParam.getImgNum())) {
+ mat.setImgNum(matParam.getImgNum());
+ }
+ if (!Cools.isEmpty(matParam.getPurchasingUnits())) {
+ mat.setPurchasingUnits(matParam.getPurchasingUnits());
+ }
+ if (!Cools.isEmpty(matParam.getProcessNumber())) {
+ mat.setProcessNumber(matParam.getProcessNumber());
+ }
+ if (!Cools.isEmpty(matParam.getBom())) {
+ mat.setBom(matParam.getBom());
+ }
+ if (!Cools.isEmpty(matParam.getSafeNum())) {
+ mat.setSafeNum(matParam.getSafeNum());
+ }
+ if (!Cools.isEmpty(matParam.getMiniCount())) {
+ mat.setMiniCount(matParam.getMiniCount());
+ }
+ if (!Cools.isEmpty(matParam.getReplenishmentNum())) {
+ mat.setReplenishmentNum(matParam.getReplenishmentNum());
+ }
+ if (!Cools.isEmpty(matParam.getTmp1())) {
+ mat.setTmp1(matParam.getTmp1());
+ }
+ if (!Cools.isEmpty(matParam.getTmp2())) {
+ mat.setTmp2(matParam.getTmp2());
+ }
+ if (!Cools.isEmpty(matParam.getTmp3())) {
+ mat.setTmp3(matParam.getTmp3());
+ }
+ if (!Cools.isEmpty(matParam.getRestockDemand())) {
+ mat.setRestockDemand(matParam.getRestockDemand());
+ }
+ if (!Cools.isEmpty(matParam.getLapse())) {
+ mat.setLapse(matParam.getLapse());
+ }
+ if (!Cools.isEmpty(matParam.getShortcuts())) {
+ mat.setShortcuts(matParam.getShortcuts());
+ }
+ if (!Cools.isEmpty(matParam.getUnits())) {
+ mat.setUnits(matParam.getUnits());
+ }
+ if (!Cools.isEmpty(matParam.getLength())) {
+ mat.setLength(matParam.getLength());
+ }
+ if (!Cools.isEmpty(matParam.getWidth())) {
+ mat.setWidth(matParam.getWidth());
+ }
+ if (!Cools.isEmpty(matParam.getHeight())) {
+ mat.setHeight(matParam.getHeight());
+ }
+ if (!Cools.isEmpty(matParam.getAccountingClass())) {
+ mat.setAccountingClass(matParam.getAccountingClass());
+ }
+ if (!Cools.isEmpty(matParam.getBatch())) {
+ mat.setBatch(matParam.getBatch());
+ }
+ if (!Cools.isEmpty(matParam.getInventoryAccount())) {
+ mat.setInventoryAccount(matParam.getInventoryAccount());
+ }
+
+ if (matService.save(mat)) {
+ count++;
+ }
+ }
+ return count;
+ }
}
--
Gitblit v1.9.1