|
@@ -4,17 +4,23 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
import org.jeecg.common.exception.JeecgBootException;
|
|
|
+import org.jeecg.modules.cuspCode.entity.CuspCustomerProfile;
|
|
|
+import org.jeecg.modules.cuspCode.entity.CuspSupplierProfile;
|
|
|
+import org.jeecg.modules.cuspCode.mapper.CuspCustomerProfileMapper;
|
|
|
+import org.jeecg.modules.cuspCode.mapper.CuspSupplierProfileMapper;
|
|
|
import org.jeecg.modules.storeCode.entity.*;
|
|
|
import org.jeecg.modules.storeCode.entity.StoreConsignmentIn;
|
|
|
import org.jeecg.modules.storeCode.mapper.StoreConsignmentInDetailsMapper;
|
|
|
import org.jeecg.modules.storeCode.mapper.StoreConsignmentInShipMapper;
|
|
|
import org.jeecg.modules.storeCode.mapper.StoreConsignmentInMapper;
|
|
|
import org.jeecg.modules.storeCode.service.IStoreConsignmentInService;
|
|
|
+import org.jeecg.modules.storeCode.service.IStoreOnhandService;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import java.io.Serializable;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
@@ -35,21 +41,44 @@ public class StoreConsignmentInServiceImpl extends ServiceImpl<StoreConsignmentI
|
|
|
private StoreConsignmentInDetailsMapper storeConsignmentInDetailsMapper;
|
|
|
@Autowired
|
|
|
private StoreConsignmentInShipMapper storeConsignmentInShipMapper;
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private CuspCustomerProfileMapper cuspCustomerProfileMapper;
|
|
|
+ @Autowired
|
|
|
+ private CuspSupplierProfileMapper cuspSupplierProfileMapper;
|
|
|
+ @Autowired
|
|
|
+ private IStoreOnhandService storeOnhandService;
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void saveMain(StoreConsignmentIn storeConsignmentIn, List<StoreConsignmentInDetails> storeConsignmentInDetailsList,List<StoreConsignmentInShip> storeConsignmentInShipList) {
|
|
|
+
|
|
|
+ String cos = storeConsignmentIn.getCustomer();
|
|
|
+
|
|
|
+ CuspCustomerProfile ent = cuspCustomerProfileMapper.selectById(cos);
|
|
|
+ if(ent != null){
|
|
|
+ storeConsignmentIn.setCustomerName(ent.getName());
|
|
|
+ }
|
|
|
storeConsignmentInMapper.insert(storeConsignmentIn);
|
|
|
if(storeConsignmentInDetailsList!=null && storeConsignmentInDetailsList.size()>0) {
|
|
|
for(StoreConsignmentInDetails entity:storeConsignmentInDetailsList) {
|
|
|
+
|
|
|
+ String sup = entity.getSupplier();
|
|
|
+ if(StringUtils.isNotBlank(sup)){
|
|
|
+ CuspSupplierProfile supplierProfile = cuspSupplierProfileMapper.selectById(sup);
|
|
|
+ entity.setSupplierName(supplierProfile.getName());
|
|
|
+ }
|
|
|
//外键设置
|
|
|
+ entity.setId(null);
|
|
|
entity.setHeadId(storeConsignmentIn.getId());
|
|
|
storeConsignmentInDetailsMapper.insert(entity);
|
|
|
}
|
|
|
}
|
|
|
if(storeConsignmentInShipList!=null && storeConsignmentInShipList.size()>0) {
|
|
|
for(StoreConsignmentInShip entity:storeConsignmentInShipList) {
|
|
|
+
|
|
|
//外键设置
|
|
|
+ entity.setId(null);
|
|
|
entity.setHeadId(storeConsignmentIn.getId());
|
|
|
storeConsignmentInShipMapper.insert(entity);
|
|
|
}
|
|
@@ -59,6 +88,12 @@ public class StoreConsignmentInServiceImpl extends ServiceImpl<StoreConsignmentI
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void updateMain(StoreConsignmentIn storeConsignmentIn,List<StoreConsignmentInDetails> storeConsignmentInDetailsList,List<StoreConsignmentInShip> storeConsignmentInShipList) {
|
|
|
+ String cos = storeConsignmentIn.getCustomer();
|
|
|
+
|
|
|
+ CuspCustomerProfile ent = cuspCustomerProfileMapper.selectById(cos);
|
|
|
+ if(ent != null){
|
|
|
+ storeConsignmentIn.setCustomerName(ent.getName());
|
|
|
+ }
|
|
|
storeConsignmentInMapper.updateById(storeConsignmentIn);
|
|
|
|
|
|
//1.先删除子表数据
|
|
@@ -68,7 +103,13 @@ public class StoreConsignmentInServiceImpl extends ServiceImpl<StoreConsignmentI
|
|
|
//2.子表数据重新插入
|
|
|
if(storeConsignmentInDetailsList!=null && storeConsignmentInDetailsList.size()>0) {
|
|
|
for(StoreConsignmentInDetails entity:storeConsignmentInDetailsList) {
|
|
|
+ String sup = entity.getSupplier();
|
|
|
+ if(StringUtils.isNotBlank(sup)){
|
|
|
+ CuspSupplierProfile supplierProfile = cuspSupplierProfileMapper.selectById(sup);
|
|
|
+ entity.setSupplierName(supplierProfile.getName());
|
|
|
+ }
|
|
|
//外键设置
|
|
|
+ entity.setId(null);
|
|
|
entity.setHeadId(storeConsignmentIn.getId());
|
|
|
storeConsignmentInDetailsMapper.insert(entity);
|
|
|
}
|
|
@@ -76,6 +117,7 @@ public class StoreConsignmentInServiceImpl extends ServiceImpl<StoreConsignmentI
|
|
|
if(storeConsignmentInShipList!=null && storeConsignmentInShipList.size()>0) {
|
|
|
for(StoreConsignmentInShip entity:storeConsignmentInShipList) {
|
|
|
//外键设置
|
|
|
+ entity.setId(null);
|
|
|
entity.setHeadId(storeConsignmentIn.getId());
|
|
|
storeConsignmentInShipMapper.insert(entity);
|
|
|
}
|
|
@@ -143,7 +185,7 @@ public class StoreConsignmentInServiceImpl extends ServiceImpl<StoreConsignmentI
|
|
|
try {
|
|
|
|
|
|
//执行入库操作
|
|
|
- String result = "true";//actionIn(list, true);
|
|
|
+ String result = actionIn(list, true);
|
|
|
|
|
|
if ("true".equals(result)) {
|
|
|
|
|
@@ -165,6 +207,77 @@ public class StoreConsignmentInServiceImpl extends ServiceImpl<StoreConsignmentI
|
|
|
}
|
|
|
|
|
|
|
|
|
+ //执行入库操作
|
|
|
+ //type true增加库存 false减少库存
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public String actionIn(List<StoreConsignmentIn> list,boolean type) {
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ for (StoreConsignmentIn o : list) {
|
|
|
+
|
|
|
+ List<StoreConsignmentInDetails> entList = storeConsignmentInDetailsMapper.selectByMainId(o.getId());
|
|
|
+
|
|
|
+ for (StoreConsignmentInDetails ent : entList) {
|
|
|
+
|
|
|
+ BigDecimal stockInQuantity = ent.getQuantity();
|
|
|
+
|
|
|
+ if(stockInQuantity == null || stockInQuantity.equals(BigDecimal.ZERO)){
|
|
|
+ throw new JeecgBootException(o.getBillCode()+ "产品:" + ent.getProductCode() + "入库数量不能为空或为0!");
|
|
|
+ }
|
|
|
+
|
|
|
+ StoreOnhand storeOnhand = new StoreOnhand();
|
|
|
+
|
|
|
+ storeOnhand.setCustomer(o.getCustomer());//客户
|
|
|
+ storeOnhand.setCustomerName(o.getCustomerName());//客户
|
|
|
+ storeOnhand.setWarehouse(o.getWarehouse());//仓库
|
|
|
+// storeOnhand.setWarehouseName();//仓库名称
|
|
|
+ storeOnhand.setGoodsAllocation(o.getGoodsAllocation());//货位
|
|
|
+ storeOnhand.setProject(o.getProject());//项目
|
|
|
+ storeOnhand.setProjectName(o.getProjectName());//项目
|
|
|
+ storeOnhand.setSupplier(ent.getSupplier());//供应商
|
|
|
+ storeOnhand.setSupplierName(ent.getSupplierName());//供应商
|
|
|
+ storeOnhand.setProductionClass(ent.getProductClass());//产品分类
|
|
|
+ storeOnhand.setProductionClassName(ent.getProductClass());//产品分类
|
|
|
+// storeOnhand.setMaker(o.getMaker());//厂家
|
|
|
+
|
|
|
+ storeOnhand.setProductId(ent.getProductId());//产品
|
|
|
+ storeOnhand.setProductCode(ent.getProductCode());//产品
|
|
|
+ storeOnhand.setChineseName(ent.getChineseName());//产品
|
|
|
+ storeOnhand.setEnglishName(ent.getEnglishName());//产品
|
|
|
+ storeOnhand.setSpecifications(ent.getSpecifications());//规格
|
|
|
+ storeOnhand.setModel(ent.getModel());//型号
|
|
|
+ storeOnhand.setPartno(ent.getPartno());//备件号
|
|
|
+ storeOnhand.setDrawingno(ent.getDrawingno());//图号
|
|
|
+// storeOnhand.setOrderno(ent.setOrderno());//
|
|
|
+// storeOnhand.setFactory(ent.getFactory());//厂家
|
|
|
+ storeOnhand.setQualityGrade(ent.getQualityGrade());//质量等级
|
|
|
+ storeOnhand.setQuantity(stockInQuantity);//入库数量
|
|
|
+ storeOnhand.setInitialQuantity(stockInQuantity);//初始数量
|
|
|
+ storeOnhand.setSourceId(ent.getId());//记录来源id
|
|
|
+ storeOnhand.setSourceCode(o.getBillCode());//记录来源code
|
|
|
+ storeOnhand.setStoreDate(o.getBillDate());//记录来源单据入库日期
|
|
|
+ storeOnhand.setType("寄存代发");//业务类型(采购入库/其他入库/寄存代发)
|
|
|
+
|
|
|
+ if(type){
|
|
|
+
|
|
|
+ //增加库存
|
|
|
+ storeOnhandService.addStore(storeOnhand, "寄存代发");
|
|
|
+ }else{
|
|
|
+ //减少库存
|
|
|
+ storeOnhandService.deleteStore(storeOnhand, "寄存代发");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new JeecgBootException(e.getMessage());
|
|
|
+// return e.getMessage();
|
|
|
+ }
|
|
|
+
|
|
|
+ return "true";
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Result<String> returnSubmitBatch(String ids) {
|
|
@@ -201,7 +314,7 @@ public class StoreConsignmentInServiceImpl extends ServiceImpl<StoreConsignmentI
|
|
|
try {
|
|
|
|
|
|
//执行入库操作
|
|
|
- String result = "true";//actionIn(list, false);
|
|
|
+ String result = actionIn(list, false);
|
|
|
|
|
|
if ("true".equals(result)) {
|
|
|
|