|
@@ -26,10 +26,15 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import vip.xiaonuo.auth.core.pojo.SaBaseClientLoginUser;
|
|
|
import vip.xiaonuo.auth.core.util.StpLoginUserUtil;
|
|
|
+import vip.xiaonuo.biz.modular.qyoutwarehouse.entity.QyOutWarehouse;
|
|
|
+import vip.xiaonuo.biz.modular.qyoutwarehouse.service.QyOutWarehouseService;
|
|
|
import vip.xiaonuo.biz.modular.qyrecardbody.entity.QyRecardBody;
|
|
|
import vip.xiaonuo.biz.modular.qyrecardbody.param.QyRecardBodyIdParam;
|
|
|
import vip.xiaonuo.biz.modular.qyrecardbody.service.QyRecardBodyService;
|
|
|
+import vip.xiaonuo.biz.modular.qyrecord.entity.QyRecord;
|
|
|
+import vip.xiaonuo.biz.modular.qyrecord.service.QyRecordService;
|
|
|
import vip.xiaonuo.biz.modular.qyrecordinfo.entity.BusinessIdGenerator;
|
|
|
import vip.xiaonuo.biz.modular.qyrecordinfo.entity.QyRecordInfo;
|
|
|
import vip.xiaonuo.biz.modular.qyrecordinfo.service.QyRecordInfoService;
|
|
@@ -50,6 +55,8 @@ import vip.xiaonuo.biz.modular.qysecondlinehzdqd.entity.QySecondlineHzdQd;
|
|
|
import vip.xiaonuo.biz.modular.qysecondlinehzdqd.service.QySecondlineHzdQdService;
|
|
|
import vip.xiaonuo.biz.modular.qysecondlinehzdtz.param.*;
|
|
|
import vip.xiaonuo.biz.modular.qysecondlinehzdtz.vo.QySecondlineHzdDetailVo;
|
|
|
+import vip.xiaonuo.biz.modular.qysecondlinewarehouse.entity.QySecondlineWarehouse;
|
|
|
+import vip.xiaonuo.biz.modular.qysecondlinewarehouse.service.QySecondlineWarehouseService;
|
|
|
import vip.xiaonuo.common.enums.CommonSortOrderEnum;
|
|
|
import vip.xiaonuo.common.exception.CommonException;
|
|
|
import vip.xiaonuo.common.page.CommonPageRequest;
|
|
@@ -57,8 +64,10 @@ import vip.xiaonuo.biz.modular.qysecondlinehzdtz.entity.QySecondlineHzdTz;
|
|
|
import vip.xiaonuo.biz.modular.qysecondlinehzdtz.mapper.QySecondlineHzdTzMapper;
|
|
|
import vip.xiaonuo.biz.modular.qysecondlinehzdtz.service.QySecondlineHzdTzService;
|
|
|
|
|
|
+import java.security.SecurityPermission;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.Random;
|
|
|
|
|
|
/**
|
|
|
* 二线核注单台账信息Service接口实现类
|
|
@@ -77,11 +86,15 @@ public class QySecondlineHzdTzServiceImpl extends ServiceImpl<QySecondlineHzdTzM
|
|
|
@Autowired
|
|
|
private QyRecordInfoService qyRecordInfoService;
|
|
|
@Autowired
|
|
|
- private QyRecardBodyService qyRecardBodyService;
|
|
|
+ private QySecondlineWarehouseService qySecondlineWarehouseService;
|
|
|
@Autowired
|
|
|
private QyRecordProductService qyRecordProductService;
|
|
|
@Autowired
|
|
|
private QySecondlineHzdQdService qySecondlineHzdQdService;
|
|
|
+ @Autowired
|
|
|
+ private QyRecordService qyRecordService;
|
|
|
+ @Autowired
|
|
|
+ private QyOutWarehouseService qyOutWarehouseService;
|
|
|
@Override
|
|
|
public Page<QySecondlineHzdTz> page(QySecondlineHzdTzPageParam qySecondlineHzdTzPageParam) {
|
|
|
QueryWrapper<QySecondlineHzdTz> queryWrapper = new QueryWrapper<QySecondlineHzdTz>().checkSqlInjection();
|
|
@@ -159,6 +172,155 @@ public class QySecondlineHzdTzServiceImpl extends ServiceImpl<QySecondlineHzdTzM
|
|
|
qySecondlineHzdTz.setSbsj(new Date());
|
|
|
}
|
|
|
this.save(qySecondlineHzdTz);
|
|
|
+
|
|
|
+ if(ObjectUtil.isNotEmpty(baseInfo.getStatus()) && "3".equals(baseInfo.getStatus())){
|
|
|
+ //生成二线出岛记账
|
|
|
+ this.saveSecondWarehouse(qySecondlineHzdTzBaseParam,qySecondlineHzdTz);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生成二线出岛记账
|
|
|
+ * @param qySecondlineHzdTzBaseParam
|
|
|
+ * @param qySecondlineHzdTz
|
|
|
+ */
|
|
|
+ private void saveSecondWarehouse(QySecondlineHzdTzBaseParam qySecondlineHzdTzBaseParam, QySecondlineHzdTz qySecondlineHzdTz) {
|
|
|
+ List<QySecondlineHzdProductAddParam> productList = qySecondlineHzdTzBaseParam.getProductList();
|
|
|
+ //根据企业编码查询企业信息
|
|
|
+ QueryWrapper<QyRecord> queryWrapper = new QueryWrapper<QyRecord>().checkSqlInjection();
|
|
|
+ queryWrapper.lambda().eq(QyRecord::getCompanyCode, qySecondlineHzdTz.getCompanyCode());
|
|
|
+ QyRecord qyRecord = CollectionUtil.getFirst(qyRecordService.list(queryWrapper));
|
|
|
+
|
|
|
+ if(ObjectUtil.isNotEmpty(productList)){
|
|
|
+ //每个核注商品生成一条记账信息
|
|
|
+ int count = 0;
|
|
|
+ for (QySecondlineHzdProductAddParam p : productList) {
|
|
|
+ count++;
|
|
|
+ QySecondlineWarehouse qySecondlineWarehouse = new QySecondlineWarehouse();
|
|
|
+ qySecondlineWarehouse.setCompanyCode(qySecondlineHzdTz.getCompanyCode());
|
|
|
+ qySecondlineWarehouse.setCompanyName(qyRecord.getCompanyName());
|
|
|
+ qySecondlineWarehouse.setAccountType(qySecondlineHzdTz.getTzNature());
|
|
|
+ qySecondlineWarehouse.setAccountCode(qySecondlineHzdTz.getTzCode());
|
|
|
+ qySecondlineWarehouse.setCommodityCode(p.getProductCode());
|
|
|
+ qySecondlineWarehouse.setCommodityName(p.getProductName());
|
|
|
+ p.setIndex(String.valueOf(count));
|
|
|
+ //默认出库
|
|
|
+ qySecondlineWarehouse.setBusinessType("1");
|
|
|
+ //对应申报数量
|
|
|
+ qySecondlineWarehouse.setAccountNumber(p.getSbNum());
|
|
|
+ //获取商品数量
|
|
|
+ QyRecordProduct qyRecordProduct = qyRecordProductService.getOne(new QueryWrapper<QyRecordProduct>().checkSqlInjection().lambda()
|
|
|
+ .eq(QyRecordProduct::getProductCode, p.getProductCode()).eq(QyRecordProduct::getProductNumber, p.getProductOrderCode()));
|
|
|
+ //原库存数量
|
|
|
+ Integer kuNumber = ObjectUtil.isNotEmpty(qyRecordProduct.getKcNumber()) ? Integer.valueOf(qyRecordProduct.getKcNumber()) :Integer.valueOf(qyRecordProduct.getQuantity());
|
|
|
+ //减去当前申报数量
|
|
|
+ kuNumber = kuNumber - Integer.valueOf(p.getSbNum()) ;
|
|
|
+ //库存小于0就获取重置为0
|
|
|
+ kuNumber = kuNumber < 0 ? 0 : kuNumber;
|
|
|
+ //最新库存数量
|
|
|
+ qySecondlineWarehouse.setKcNumber(String.valueOf(kuNumber));
|
|
|
+
|
|
|
+ qySecondlineWarehouse.setMeasurementUnit(p.getLegalUnit());
|
|
|
+
|
|
|
+ //二线出岛申请单号
|
|
|
+ qySecondlineWarehouse.setSecondlineOutislandNumber(BusinessIdGenerator.generateNumBerUUID(18));
|
|
|
+
|
|
|
+ //出库单号
|
|
|
+ String ckCode = "DOR"+BusinessIdGenerator.generateNumBerUUID(18);
|
|
|
+ qySecondlineWarehouse.setWarehouseNumber(ckCode);
|
|
|
+
|
|
|
+ qySecondlineWarehouse.setWarehouseTime(qySecondlineHzdTz.getSbsj());
|
|
|
+ qySecondlineWarehouse.setAccountTime(qySecondlineHzdTz.getSbsj());
|
|
|
+
|
|
|
+ //制单人
|
|
|
+ qySecondlineWarehouse.setCreator(StpLoginUserUtil.getLoginUser().getName());
|
|
|
+
|
|
|
+ qySecondlineWarehouse.setSpecs(p.getSpecModel());
|
|
|
+ qySecondlineWarehouse.setUnitPrice(p.getRecordPrice());
|
|
|
+
|
|
|
+ qySecondlineWarehouseService.save(qySecondlineWarehouse);
|
|
|
+
|
|
|
+ //生成出库单
|
|
|
+ this.saveQyOutWarehouse(p,qySecondlineHzdTz,qySecondlineWarehouse);
|
|
|
+
|
|
|
+ //更新剩余库存
|
|
|
+ qyRecordProduct.setKcNumber(String.valueOf(kuNumber));
|
|
|
+ qyRecordProductService.updateById(qyRecordProduct);
|
|
|
+ };
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //生成出库单
|
|
|
+ private void saveQyOutWarehouse(QySecondlineHzdProductAddParam product, QySecondlineHzdTz qySecondlineHzdTz, QySecondlineWarehouse qySecondlineWarehouse) {
|
|
|
+ QyOutWarehouse qyOutWarehouse = new QyOutWarehouse();
|
|
|
+ //出库单号
|
|
|
+ qyOutWarehouse.setWarehouseNumber(qySecondlineWarehouse.getWarehouseNumber());
|
|
|
+ qyOutWarehouse.setReOutWarehouseNumber(BusinessIdGenerator.generateNumBerUUID(18));
|
|
|
+ qyOutWarehouse.setStatementCode(BusinessIdGenerator.generateNumBerUUID(18));
|
|
|
+ qyOutWarehouse.setHzCode(qySecondlineHzdTz.getHgHzdCode());
|
|
|
+ qyOutWarehouse.setCompanyCode(qySecondlineWarehouse.getCompanyCode());
|
|
|
+ qyOutWarehouse.setCompanyName(qySecondlineWarehouse.getCompanyName());
|
|
|
+ //默认出库
|
|
|
+ qyOutWarehouse.setOutWarehouseType("1");
|
|
|
+ //TODO 字典
|
|
|
+ qyOutWarehouse.setAccountType(qySecondlineWarehouse.getAccountType());
|
|
|
+ //TODO 字典
|
|
|
+ qyOutWarehouse.setRegulaMethod(qySecondlineHzdTz.getRegulaMethod());
|
|
|
+ //TODO 字典
|
|
|
+ qyOutWarehouse.setBz(product.getCurrency());
|
|
|
+
|
|
|
+ qyOutWarehouse.setQdgDq(CollectionUtil.get(CollectionUtil.toList("中国","英国","美国"), new Random().nextInt(3)));
|
|
|
+
|
|
|
+ qyOutWarehouse.setWarehouseTime(qySecondlineHzdTz.getSbsj());
|
|
|
+
|
|
|
+ qyOutWarehouse.setInport(CollectionUtil.get(CollectionUtil.toList("中国口岸","英国口岸","美国口岸"), new Random().nextInt(3)));
|
|
|
+
|
|
|
+ qyOutWarehouse.setJjgb(qySecondlineHzdTz.getDybgDept());
|
|
|
+
|
|
|
+ //TODO 主管关区代码 默认海口海关
|
|
|
+ qyOutWarehouse.setZggqdm("6400");
|
|
|
+
|
|
|
+ qyOutWarehouse.setBgbz((CollectionUtil.get(CollectionUtil.toList("飞机","火车","轮船"), new Random().nextInt(3))));
|
|
|
+ //TODO 运输方式 字典
|
|
|
+ qyOutWarehouse.setYsfs(qySecondlineHzdTz.getYsfs());
|
|
|
+ qyOutWarehouse.setQgldbj(String.valueOf(new Random().nextInt(1000000)));
|
|
|
+ qyOutWarehouse.setBssp((CollectionUtil.get(CollectionUtil.toList("是","否","其它"), new Random().nextInt(3))));
|
|
|
+ qyOutWarehouse.setYxbgdh(BusinessIdGenerator.generateNumBerUUID(18).substring(8));
|
|
|
+ qyOutWarehouse.setShqymc((CollectionUtil.get(CollectionUtil.toList("哈尔滨开心药业公司","海南金半岛邮箱公司","海南金鼎酒业有限公司"), new Random().nextInt(3))));
|
|
|
+ qyOutWarehouse.setWlbh(product.getProductCode());
|
|
|
+ qyOutWarehouse.setWlmc(product.getProductName());
|
|
|
+ qyOutWarehouse.setVersion("1");
|
|
|
+ qyOutWarehouse.setHzqdxch(product.getIndex());
|
|
|
+ qyOutWarehouse.setJezce(UUID.fastUUID().toString().replaceAll("_",""));
|
|
|
+ qyOutWarehouse.setRecordNum(product.getProductOrderCode());
|
|
|
+ qyOutWarehouse.setRecordName((CollectionUtil.get(CollectionUtil.toList("原材料","辅助品","零件"), new Random().nextInt(3))));
|
|
|
+ //TODO 核注单中没有
|
|
|
+ qyOutWarehouse.setFjcpbz((CollectionUtil.get(CollectionUtil.toList("成品标志1","成品标志2","成品标志3"), new Random().nextInt(3))));
|
|
|
+ //TODO 字典
|
|
|
+ qyOutWarehouse.setGgxh(product.getSpecModel());
|
|
|
+ qyOutWarehouse.setBrandType((CollectionUtil.get(CollectionUtil.toList("华为","苹果","三星"), new Random().nextInt(3))));
|
|
|
+ qyOutWarehouse.setYcgdq((CollectionUtil.get(CollectionUtil.toList("英国","美国","澳大利亚"), new Random().nextInt(3))));
|
|
|
+ qyOutWarehouse.setZzmdg((CollectionUtil.get(CollectionUtil.toList("泰国","法国","巴西"), new Random().nextInt(3))));
|
|
|
+ //出库数量 == 申报数量
|
|
|
+ qyOutWarehouse.setCkNum(product.getSbNum());
|
|
|
+ //TODO 字典
|
|
|
+ qyOutWarehouse.setMeasurementUnit(product.getDeclareUnit());
|
|
|
+ qyOutWarehouse.setUnitPrice(product.getCompanySbPrice());
|
|
|
+ qyOutWarehouse.setFyfdNum(String.valueOf(product.getLegalQuantity()));
|
|
|
+ qyOutWarehouse.setDefdNum(String.valueOf(product.getSecondLegalQuantity()));
|
|
|
+ //TODO 字典
|
|
|
+ qyOutWarehouse.setZmfs(product.getZmMethod());
|
|
|
+ qyOutWarehouse.setHcdm("INRD05017291");
|
|
|
+ qyOutWarehouse.setCwdm("1A01-04-03");
|
|
|
+ qyOutWarehouse.setHwlyType("检验证书");
|
|
|
+ qyOutWarehouse.setHwlyCode(BusinessIdGenerator.generateNumBerUUID(18).substring(8));
|
|
|
+
|
|
|
+ qyOutWarehouse.setRemark(qySecondlineHzdTz.getRemark());
|
|
|
+
|
|
|
+ qyOutWarehouseService.save(qyOutWarehouse);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -377,4 +539,7 @@ public class QySecondlineHzdTzServiceImpl extends ServiceImpl<QySecondlineHzdTzM
|
|
|
public List<QySecondlineHzdQd> hzdQdList(){
|
|
|
return qySecondlineHzdQdService.list();
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|