Browse Source

二线出岛放行业务修改

wenjinbiao 2 months ago
parent
commit
34d477812e

+ 6 - 0
snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/qyoutwarehouse/entity/QyOutWarehouse.java

@@ -11,6 +11,7 @@
  * 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
  */
 package vip.xiaonuo.biz.modular.qyoutwarehouse.entity;
+import com.alibaba.excel.annotation.ExcelIgnore;
 import com.alibaba.excel.annotation.ExcelProperty;
 import com.alibaba.excel.annotation.write.style.ColumnWidth;
 import com.baomidou.mybatisplus.annotation.*;
@@ -320,4 +321,9 @@ public class QyOutWarehouse {
     @ExcelProperty(index = 47,value = "更新人")
     @TableField(fill = FieldFill.UPDATE)
     private Date updateUser;
+
+    @Schema(description = "账册类型")
+    @ColumnWidth(12)
+    @ExcelIgnore
+    private String accountType;
 }

+ 8 - 0
snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/qyrecordproduct/entity/QyRecordProduct.java

@@ -11,6 +11,7 @@
  * 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
  */
 package vip.xiaonuo.biz.modular.qyrecordproduct.entity;
+import com.alibaba.excel.annotation.ExcelIgnore;
 import com.alibaba.excel.annotation.ExcelProperty;
 import com.alibaba.excel.annotation.write.style.ColumnWidth;
 import com.baomidou.mybatisplus.annotation.*;
@@ -155,4 +156,11 @@ public class QyRecordProduct {
     @ColumnWidth(12)
     @ExcelProperty(index = 20,value = "备注")
     private String remark;
+
+
+    /** 库存数量 */
+    @Schema(description = "库存数量")
+    @ColumnWidth(12)
+    @ExcelIgnore
+    private String kcNumber;
 }

+ 2 - 0
snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/qysecondlinehzdproduct/param/QySecondlineHzdProductAddParam.java

@@ -215,4 +215,6 @@ public class QySecondlineHzdProductAddParam {
     @Schema(description = "修改标志")
     private String xgbz;
 
+    private String index;
+
 }

+ 166 - 1
snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/qysecondlinehzdtz/service/impl/QySecondlineHzdTzServiceImpl.java

@@ -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();
     }
+
+
+
 }

+ 20 - 14
snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/qysecondlinewarehouse/entity/QySecondlineWarehouse.java

@@ -86,91 +86,97 @@ public class QySecondlineWarehouse {
     @ExcelProperty(index = 8,value = "记账数量")
     private String accountNumber;
 
+    /** 记账数量 */
+    @Schema(description = "库存数量")
+    @ColumnWidth(12)
+    @ExcelProperty(index = 9,value = "库存数量")
+    private String kcNumber;
+
     /** 法定计量单位 */
     @Schema(description = "法定计量单位")
     @ColumnWidth(12)
-    @ExcelProperty(index = 9,value = "法定计量单位")
+    @ExcelProperty(index = 10,value = "法定计量单位")
     private String measurementUnit;
 
     /** 二线出岛申请单号 */
     @Schema(description = "二线出岛申请单号")
     @ColumnWidth(12)
-    @ExcelProperty(index = 10,value = "二线出岛申请单号")
+    @ExcelProperty(index = 11,value = "二线出岛申请单号")
     private String secondlineOutislandNumber;
 
     /** 出库单号 */
     @Schema(description = "出库单号")
     @ColumnWidth(12)
-    @ExcelProperty(index = 11,value = "出库单号")
+    @ExcelProperty(index = 12,value = "出库单号")
     private String warehouseNumber;
 
     /** 出库日期 */
     @Schema(description = "出库日期")
     @ColumnWidth(12)
-    @ExcelProperty(index = 12,value = "出库日期")
+    @ExcelProperty(index = 13,value = "出库日期")
     private Date warehouseTime;
 
     /** 记账日期 */
     @Schema(description = "记账日期")
     @ColumnWidth(12)
-    @ExcelProperty(index = 13,value = "记账日期")
+    @ExcelProperty(index = 14,value = "记账日期")
     private Date accountTime;
 
     /** 备注 */
     @Schema(description = "备注")
     @ColumnWidth(12)
-    @ExcelProperty(index = 14,value = "备注")
+    @ExcelProperty(index = 15,value = "备注")
     private String remark;
 
     /** 创建时间 */
     @Schema(description = "创建时间")
     @ColumnWidth(12)
-    @ExcelProperty(index = 15,value = "创建时间")
+    @ExcelProperty(index = 16,value = "创建时间")
     @TableField(fill = FieldFill.INSERT)
     private Date createTime;
 
     /** 创建人 */
     @Schema(description = "创建人")
     @ColumnWidth(12)
-    @ExcelProperty(index = 16,value = "创建人")
+    @ExcelProperty(index = 17,value = "创建人")
     @TableField(fill = FieldFill.INSERT)
     private String createUser;
 
     /** 更新时间 */
     @Schema(description = "更新时间")
     @ColumnWidth(12)
-    @ExcelProperty(index = 17,value = "更新时间")
+    @ExcelProperty(index = 18,value = "更新时间")
     @TableField(fill = FieldFill.UPDATE)
     private Date updateTime;
 
     /** 更新人 */
     @Schema(description = "更新人")
     @ColumnWidth(12)
-    @ExcelProperty(index = 18,value = "更新人")
+    @ExcelProperty(index = 19,value = "更新人")
     @TableField(fill = FieldFill.UPDATE)
     private Date updateUser;
 
     /** 文件路径 */
     @Schema(description = "文件路径")
     @ColumnWidth(12)
-    @ExcelProperty(index = 19,value = "文件路径")
+    @ExcelProperty(index = 20,value = "文件路径")
     private String fileUrl;
 
     /** 制单人 */
     @Schema(description = "制单人")
     @ColumnWidth(12)
-    @ExcelProperty(index = 20,value = "制单人")
+    @ExcelProperty(index = 21,value = "制单人")
     private String creator;
 
     /** 规格 */
     @Schema(description = "规格")
     @ColumnWidth(12)
-    @ExcelProperty(index = 21,value = "规格")
+    @ExcelProperty(index = 22,value = "规格")
     private String specs;
 
     /** 单价 */
     @Schema(description = "单价")
     @ColumnWidth(12)
-    @ExcelProperty(index = 22,value = "单价")
+    @ExcelProperty(index = 23,value = "单价")
     private String unitPrice;
 }