|
@@ -0,0 +1,452 @@
|
|
|
|
+package com.yh.saas.plugin.yiliangyiyun.service.impl;
|
|
|
|
+
|
|
|
|
+import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.plugins.Page;
|
|
|
|
+import com.google.common.collect.Lists;
|
|
|
|
+import com.winsea.svc.base.base.entity.CommonCompany;
|
|
|
|
+import com.winsea.svc.base.base.service.ICommonCompanyService;
|
|
|
|
+import com.winsea.svc.base.security.util.AuthSecurityUtils;
|
|
|
|
+import com.yh.saas.common.support.util.IdGenerator;
|
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.constant.StatusEnum;
|
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.entity.*;
|
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.exception.YException;
|
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.exception.YExceptionEnum;
|
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.mapper.CargoTitleDetailsMapper;
|
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.service.*;
|
|
|
|
+import com.baomidou.mybatisplus.service.impl.ServiceImpl;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
|
+
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
|
+import java.util.*;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * <p>
|
|
|
|
+ * 记录货权明细信息 服务实现类
|
|
|
|
+ * </p>
|
|
|
|
+ *
|
|
|
|
+ * @author Gdc
|
|
|
|
+ * @since 2023-02-13
|
|
|
|
+ */
|
|
|
|
+@Service
|
|
|
|
+public class CargoTitleDetailsServiceImpl extends ServiceImpl<CargoTitleDetailsMapper, CargoTitleDetails> implements ICargoTitleDetailsService {
|
|
|
|
+ @Autowired
|
|
|
|
+ private ICommonCompanyService commonCompanyService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ICargoPositionDetailsService cargoPositionDetailsService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IWarehousingOrderService warehousingOrderService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IContractManagementInfoService contractManagementInfoService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IWarehouseInOutInfoService warehouseInOutInfoService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IWarehouseInOutDetailService warehouseInOutDetailService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IWarehousePositionStorageInfoService warehousePositionStorageInfoService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ICommonSysParameterService commonSysParameterService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IStockSaleReceiptReportService stockSaleReceiptReportService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IStockPurchaseReceiptReportService stockPurchaseReceiptReportService;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 转出
|
|
|
|
+ * @param cargoTitleDetails
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ public String addInfo(CargoTitleDetails cargoTitleDetails) {
|
|
|
|
+ cargoTitleDetails.setId(IdGenerator.generateUUID());
|
|
|
|
+ cargoTitleDetails.setCompId(cargoTitleDetails.getCompId());
|
|
|
|
+ cargoTitleDetails.setAgent(AuthSecurityUtils.getStaffById(AuthSecurityUtils.getCurrentUserId()).getStaffName());
|
|
|
|
+ CommonCompany commonCompany1 = commonCompanyService.selectById(cargoTitleDetails.getCompId());
|
|
|
|
+ if(commonCompany1 != null){
|
|
|
|
+ cargoTitleDetails.setCustomer(commonCompany1.getCompName());
|
|
|
|
+ }
|
|
|
|
+ cargoTitleDetails.setSendCompId(cargoTitleDetails.getCompId());
|
|
|
|
+ cargoTitleDetails.setTransferFlag("1");
|
|
|
|
+ cargoTitleDetails.setStatus(StatusEnum.TO_BE_RECEIVE.getName());
|
|
|
|
+ cargoTitleDetails.setStatusFlag(StatusEnum.TO_BE_RECEIVE.getFlag());
|
|
|
|
+ //易粮易运客户
|
|
|
|
+ if ("1".equals(cargoTitleDetails.getSystemIdentification())){
|
|
|
|
+ CommonCompany commonCompany = commonCompanyService.selectOne(new EntityWrapper<CommonCompany>()
|
|
|
|
+ .eq("comp_name", cargoTitleDetails.getReceiveCompName()));
|
|
|
|
+ if(commonCompany != null){
|
|
|
|
+ cargoTitleDetails.setReceiveCompId(commonCompany.getCompId());
|
|
|
|
+ }
|
|
|
|
+ else{
|
|
|
|
+ throw new YException(YExceptionEnum.COMP_NAME_ERROR);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
|
+ Integer num=this.cargoCount(cargoTitleDetails.getCompId())+1;
|
|
|
|
+ String newNo="";
|
|
|
|
+ //一位数
|
|
|
|
+ if (num < 10) {
|
|
|
|
+ newNo="000" + num;
|
|
|
|
+ }
|
|
|
|
+ //两位数
|
|
|
|
+ else if (num < 100) {
|
|
|
|
+ newNo="00" + num;
|
|
|
|
+ }
|
|
|
|
+ //三位数
|
|
|
|
+ else if (num < 1000) {
|
|
|
|
+ newNo="0" + num;
|
|
|
|
+ }
|
|
|
|
+ //四位数
|
|
|
|
+ else if (num < 10000) {
|
|
|
|
+ newNo=String.valueOf(num);
|
|
|
|
+ }
|
|
|
|
+ String transferOutNo = "HQZC"+df.format(new Date())+newNo;
|
|
|
|
+ String relationReceiveNo = "HQJS"+df.format(new Date())+newNo;
|
|
|
|
+ cargoTitleDetails.setTransferOutNo(transferOutNo);
|
|
|
|
+ cargoTitleDetails.setRelationReceiveNo(relationReceiveNo);
|
|
|
|
+ List<WarehousingOrder> warehousingOrderList = cargoTitleDetails.getWarehousingOrderList();
|
|
|
|
+ if (!CollectionUtils.isEmpty(warehousingOrderList)){
|
|
|
|
+ for (WarehousingOrder warehousingOrder:warehousingOrderList){
|
|
|
|
+ //转出重量
|
|
|
|
+ warehousingOrder.setTransferOutWeight(warehousingOrder.getSurplusWeight());
|
|
|
|
+ warehousingOrder.setSurplusWeight(0d);
|
|
|
|
+ warehousingOrder.setTransferOutNo(transferOutNo);
|
|
|
|
+ if("1".equals(cargoTitleDetails.getRedeemFlag())){
|
|
|
|
+ warehousingOrder.setRedeemFlag("赎");
|
|
|
|
+ }
|
|
|
|
+ warehousingOrderService.updateById(warehousingOrder);
|
|
|
|
+ }
|
|
|
|
+ ContractManagementInfo contractManagementInfo=contractManagementInfoService.selectOne(new EntityWrapper<ContractManagementInfo>()
|
|
|
|
+ .eq("comp_id",cargoTitleDetails.getCompId())
|
|
|
|
+ .eq("contract_no",warehousingOrderList.get(0).getContractNo()));
|
|
|
|
+ if (contractManagementInfo!=null){
|
|
|
|
+ //接收公司
|
|
|
|
+ contractManagementInfo.setReceivingCompany(cargoTitleDetails.getReceiveCompName());
|
|
|
|
+ contractManagementInfo.setCumulativeTransfer(contractManagementInfo.getCumulativeTransfer()+cargoTitleDetails.getTransferOutWeight());
|
|
|
|
+ //赎回累计预计赎回量
|
|
|
|
+ if("1".equals(cargoTitleDetails.getRedeemFlag())){
|
|
|
|
+ contractManagementInfo.setExpectedRedemption(contractManagementInfo.getExpectedRedemption()+cargoTitleDetails.getTransferOutWeight());
|
|
|
|
+ }
|
|
|
|
+ contractManagementInfoService.updateById(contractManagementInfo);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ List<CargoPositionDetails> cargoPositionDetailsList = cargoTitleDetails.getCargoPositionDetailsList();
|
|
|
|
+ if (!CollectionUtils.isEmpty(cargoPositionDetailsList)){
|
|
|
|
+ for (CargoPositionDetails cargoPositionDetails:cargoPositionDetailsList){
|
|
|
|
+ cargoPositionDetails.setId(IdGenerator.generateUUID());
|
|
|
|
+ cargoPositionDetails.setInfoId(cargoTitleDetails.getId());
|
|
|
|
+ cargoPositionDetailsService.insert(cargoPositionDetails);
|
|
|
|
+ WarehousePositionStorageInfo warehousePositionStorageInfo = warehousePositionStorageInfoService.selectOne(new EntityWrapper<WarehousePositionStorageInfo>()
|
|
|
|
+ .eq("position_id", cargoPositionDetails.getPositionId())
|
|
|
|
+ .eq("goods_name", warehousingOrderList.get(0).getGoodsName()));
|
|
|
|
+ if (warehousePositionStorageInfo != null) {
|
|
|
|
+ if (cargoPositionDetails.getWeight() <= warehousePositionStorageInfo.getStorage()) {
|
|
|
|
+ // 更新库存量
|
|
|
|
+ warehousePositionStorageInfo.setStorage(warehousePositionStorageInfo.getStorage() - cargoPositionDetails.getWeight());
|
|
|
|
+ warehousePositionStorageInfoService.updateById(warehousePositionStorageInfo);
|
|
|
|
+ WarehouseInOutInfo warehouseInOutInfo = new WarehouseInOutInfo();
|
|
|
|
+ warehouseInOutInfo.setId(IdGenerator.generateUUID());
|
|
|
|
+ warehouseInOutInfo.setBaseId(warehousingOrderList.get(0).getBaseId());
|
|
|
|
+ warehouseInOutInfo.setWarehouseName(cargoTitleDetails.getWarehouseName());
|
|
|
|
+ warehouseInOutInfo.setPositionId(cargoPositionDetails.getPositionId());
|
|
|
|
+ warehouseInOutInfo.setBinNumber(cargoPositionDetails.getBinNumber());
|
|
|
|
+ warehouseInOutInfo.setInOutFlag("1");
|
|
|
|
+ warehouseInOutInfo.setGoodsName(cargoTitleDetails.getGoodsName());
|
|
|
|
+ CommonSysParameter commonSysParameter = commonSysParameterService.selectOne(new EntityWrapper<CommonSysParameter>().eq("const_id", "CON2").eq("const_value", cargoTitleDetails.getGoodsName()));
|
|
|
|
+ warehouseInOutInfo.setGoodsNameKey(commonSysParameter.getConstKey());
|
|
|
|
+ warehouseInOutInfo.setNetWeight(cargoPositionDetails.getWeight());
|
|
|
|
+ warehouseInOutInfo.setAgent(AuthSecurityUtils.getStaffById(AuthSecurityUtils.getCurrentUserId()).getStaffName());
|
|
|
|
+ warehouseInOutInfo.setStatusFlag(StatusEnum.SUBMITTED.getFlag());
|
|
|
|
+ warehouseInOutInfo.setStatus(StatusEnum.SUBMITTED.getName());
|
|
|
|
+ warehouseInOutInfo.setInOutDate(new Date());
|
|
|
|
+ warehouseInOutInfo.setInOutType("货权转出");
|
|
|
|
+ warehouseInOutInfo.setContractNo(cargoTitleDetails.getOutContractNo());
|
|
|
|
+ warehouseInOutInfoService.insert(warehouseInOutInfo);
|
|
|
|
+ WarehouseInOutDetail warehouseInOutDetail = new WarehouseInOutDetail();
|
|
|
|
+ warehouseInOutDetail.setInfoId(warehouseInOutInfo.getId());
|
|
|
|
+ warehouseInOutDetail.setId(IdGenerator.generateUUID());
|
|
|
|
+ warehouseInOutDetailService.insert(warehouseInOutDetail);
|
|
|
|
+ //现货销售出库报表
|
|
|
|
+ StockSaleReceiptReport stockSaleReceiptReport = new StockSaleReceiptReport();
|
|
|
|
+ stockSaleReceiptReport.setId(IdGenerator.generateUUID());
|
|
|
|
+ stockSaleReceiptReport.setWarehouseRecordId(warehouseInOutInfo.getId());
|
|
|
|
+ stockSaleReceiptReport.setCompId(cargoTitleDetails.getCompId());
|
|
|
|
+ stockSaleReceiptReport.setContractNo(warehouseInOutInfo.getContractNo());
|
|
|
|
+ stockSaleReceiptReport.setWarehouseName(warehouseInOutInfo.getWarehouseName());
|
|
|
|
+ stockSaleReceiptReport.setNetWeight(warehouseInOutInfo.getNetWeight());
|
|
|
|
+ stockSaleReceiptReport.setDeliveryDate(warehouseInOutInfo.getInOutDate());
|
|
|
|
+ stockSaleReceiptReport.setStatusFlag(StatusEnum.TO_BE_RECEIVED.getFlag());
|
|
|
|
+ stockSaleReceiptReport.setStatus(StatusEnum.TO_BE_RECEIVED.getName());
|
|
|
|
+ stockSaleReceiptReport.setSettlementWeight(stockSaleReceiptReport.getNetWeight());
|
|
|
|
+ stockSaleReceiptReportService.insert(stockSaleReceiptReport);
|
|
|
|
+ }
|
|
|
|
+ //所选仓位库存不足
|
|
|
|
+ else {
|
|
|
|
+ throw new YException(YExceptionEnum.CONVERSION_NO_ERROR);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //所选仓位暂无储存量
|
|
|
|
+ else {
|
|
|
|
+ throw new YException(YExceptionEnum.POSITIONSTORAGE_NO_ERROR);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ this.insert(cargoTitleDetails);
|
|
|
|
+ return "ok";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 货权明细列表
|
|
|
|
+ * @param cargoTitleDetails
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public Page<CargoTitleDetails> selectInfo(CargoTitleDetails cargoTitleDetails) {
|
|
|
|
+ Map<String, Object> pageView = new HashMap<>();
|
|
|
|
+ pageView.put("startRecord", (cargoTitleDetails.getCurrentPage() - 1)
|
|
|
|
+ * cargoTitleDetails.getPageSize());
|
|
|
|
+ //公司id
|
|
|
|
+ pageView.put("compId",cargoTitleDetails.getCompId());
|
|
|
|
+ pageView.put("startDate",cargoTitleDetails.getStartDate());
|
|
|
|
+ pageView.put("endDate",cargoTitleDetails.getEndDate());
|
|
|
|
+ pageView.put("searchKeyWord",cargoTitleDetails.getSearchKeyWord());
|
|
|
|
+ pageView.put("searchType", cargoTitleDetails.getSearchType());
|
|
|
|
+ pageView.put("pageSize",cargoTitleDetails.getPageSize());
|
|
|
|
+ pageView.put("currentPage",cargoTitleDetails.getCurrentPage());
|
|
|
|
+ // 查询货权明细总数
|
|
|
|
+ Integer dataCount = baseMapper.getCountByCondition(pageView);
|
|
|
|
+ List<CargoTitleDetails> dataList = baseMapper.getListByCondition(pageView);
|
|
|
|
+ if (!CollectionUtils.isEmpty(dataList)){
|
|
|
|
+ for (CargoTitleDetails cargoTitleDetails1:dataList){
|
|
|
|
+ List<CargoPositionDetails> cargoPositionDetailsList=cargoPositionDetailsService.selectList(new EntityWrapper<CargoPositionDetails>()
|
|
|
|
+ .eq("info_id",cargoTitleDetails1.getId()));
|
|
|
|
+ cargoTitleDetails1.setCargoPositionDetailsList(cargoPositionDetailsList);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ Page<CargoTitleDetails> page = new Page<>();
|
|
|
|
+ page.setRecords(dataList == null ? Lists.newArrayList() : dataList);
|
|
|
|
+ page.setTotal(dataCount == null ? 0 : dataCount);
|
|
|
|
+ page.setCurrent(cargoTitleDetails.getCurrentPage());
|
|
|
|
+ page.setSize(cargoTitleDetails.getPageSize());
|
|
|
|
+ return page;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 客户操作记录列表
|
|
|
|
+ * @param cargoTitleDetails
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public Page<CargoTitleDetails> selectCusActionInfo(CargoTitleDetails cargoTitleDetails) {
|
|
|
|
+ Map<String, Object> pageView = new HashMap<>();
|
|
|
|
+ pageView.put("startRecord", (cargoTitleDetails.getCurrentPage() - 1)
|
|
|
|
+ * cargoTitleDetails.getPageSize());
|
|
|
|
+ //公司id
|
|
|
|
+ pageView.put("compId",cargoTitleDetails.getCompId());
|
|
|
|
+ pageView.put("startDate",cargoTitleDetails.getStartDate());
|
|
|
|
+ pageView.put("endDate",cargoTitleDetails.getEndDate());
|
|
|
|
+ pageView.put("searchType",cargoTitleDetails.getSearchType());
|
|
|
|
+ pageView.put("searchKeyWord",cargoTitleDetails.getSearchKeyWord());
|
|
|
|
+ pageView.put("pageSize",cargoTitleDetails.getPageSize());
|
|
|
|
+ pageView.put("currentPage",cargoTitleDetails.getCurrentPage());
|
|
|
|
+ Integer dataCount = baseMapper.getActionCountByCondition(pageView);
|
|
|
|
+ List<CargoTitleDetails> dataList = baseMapper.getActionListByCondition(pageView);
|
|
|
|
+ Page<CargoTitleDetails> page = new Page<>();
|
|
|
|
+ page.setRecords(dataList == null ? Lists.newArrayList() : dataList);
|
|
|
|
+ page.setTotal(dataCount == null ? 0 : dataCount);
|
|
|
|
+ page.setCurrent(cargoTitleDetails.getCurrentPage());
|
|
|
|
+ page.setSize(cargoTitleDetails.getPageSize());
|
|
|
|
+ return page;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Integer cargoCount(String compId) {
|
|
|
|
+ //当天零点
|
|
|
|
+ SimpleDateFormat now = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
|
|
|
|
+ Calendar c = Calendar.getInstance();
|
|
|
|
+ c.setTime(new Date());
|
|
|
|
+ c.add(Calendar.YEAR, 0);
|
|
|
|
+ Date y = c.getTime();
|
|
|
|
+ String year = now.format(y);
|
|
|
|
+ Integer count = this.selectCount(new EntityWrapper<CargoTitleDetails>()
|
|
|
|
+ .eq("comp_id", compId)
|
|
|
|
+ .ge("create_date", year));
|
|
|
|
+ return count;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 拒收
|
|
|
|
+ * @param id
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public String rejection(String id) {
|
|
|
|
+ CargoTitleDetails cargoTitleDetails=this.selectById(id);
|
|
|
|
+ cargoTitleDetails.setStatus(StatusEnum.ALREADY_REJECTED.getName());
|
|
|
|
+ cargoTitleDetails.setStatusFlag(StatusEnum.ALREADY_REJECTED.getFlag());
|
|
|
|
+ this.updateById(cargoTitleDetails);
|
|
|
|
+ return "ok";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 货权转入
|
|
|
|
+ * @param cargoTitleDetails
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ public String toChangeInto(CargoTitleDetails cargoTitleDetails) {
|
|
|
|
+ cargoTitleDetails.setId(IdGenerator.generateUUID());
|
|
|
|
+ cargoTitleDetails.setCompId(cargoTitleDetails.getCompId());
|
|
|
|
+ cargoTitleDetails.setAgent(AuthSecurityUtils.getStaffById(AuthSecurityUtils.getCurrentUserId()).getStaffName());
|
|
|
|
+ if (!"不关联".equals(cargoTitleDetails.getRelationReceiveNo())) {
|
|
|
|
+ CargoTitleDetails cargoTitleDetails1=this.selectOne(new EntityWrapper<CargoTitleDetails>()
|
|
|
|
+ .eq("receive_comp_id",cargoTitleDetails.getCompId())
|
|
|
|
+ .eq("relation_receive_no",cargoTitleDetails.getRelationReceiveNo()));
|
|
|
|
+ if (cargoTitleDetails1!=null){
|
|
|
|
+ //状态改为已接收
|
|
|
|
+ cargoTitleDetails1.setStatus(StatusEnum.ALREADT_RECEIVED.getName());
|
|
|
|
+ cargoTitleDetails1.setStatusFlag(StatusEnum.ALREADT_RECEIVED.getFlag());
|
|
|
|
+ this.updateById(cargoTitleDetails1);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ cargoTitleDetails.setTransferFlag("2");
|
|
|
|
+ SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
|
+ Integer num=this.cargoCount(cargoTitleDetails.getCompId())+1;
|
|
|
|
+ String newNo="";
|
|
|
|
+ //一位数
|
|
|
|
+ if (num < 10) {
|
|
|
|
+ newNo="000" + num;
|
|
|
|
+ }
|
|
|
|
+ //两位数
|
|
|
|
+ else if (num < 100) {
|
|
|
|
+ newNo="00" + num;
|
|
|
|
+ }
|
|
|
|
+ //三位数
|
|
|
|
+ else if (num < 1000) {
|
|
|
|
+ newNo="0" + num;
|
|
|
|
+ }
|
|
|
|
+ //四位数
|
|
|
|
+ else if (num < 10000) {
|
|
|
|
+ newNo=String.valueOf(num);
|
|
|
|
+ }
|
|
|
|
+ String transferOutNo = "HQZR"+df.format(new Date())+newNo;
|
|
|
|
+ cargoTitleDetails.setTransferOutNo(transferOutNo);
|
|
|
|
+ //货权赎回
|
|
|
|
+ if (cargoTitleDetails.getRedeemContractNo()!=null){
|
|
|
|
+ ContractManagementInfo contractManagementInfo=contractManagementInfoService.selectOne(new EntityWrapper<ContractManagementInfo>()
|
|
|
|
+ .eq("comp_id",cargoTitleDetails.getCompId())
|
|
|
|
+ .eq("contract_no",cargoTitleDetails.getRedeemContractNo()));
|
|
|
|
+ if (contractManagementInfo!=null){
|
|
|
|
+ contractManagementInfo.setRedeemed(contractManagementInfo.getRedeemed()+cargoTitleDetails.getTransferOutWeight());
|
|
|
|
+ contractManagementInfoService.updateById(contractManagementInfo);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ List<CargoPositionDetails> cargoPositionDetailsList = cargoTitleDetails.getCargoPositionDetailsList();
|
|
|
|
+ if (!CollectionUtils.isEmpty(cargoPositionDetailsList)){
|
|
|
|
+ for (CargoPositionDetails cargoPositionDetails:cargoPositionDetailsList){
|
|
|
|
+ cargoPositionDetails.setId(IdGenerator.generateUUID());
|
|
|
|
+ cargoPositionDetails.setInfoId(cargoTitleDetails.getId());
|
|
|
|
+ cargoPositionDetailsService.insert(cargoPositionDetails);
|
|
|
|
+ WarehouseInOutInfo warehouseInOutInfo = new WarehouseInOutInfo();
|
|
|
|
+ warehouseInOutInfo.setId(IdGenerator.generateUUID());
|
|
|
|
+ warehouseInOutInfo.setBaseId(cargoTitleDetails.getBaseId());
|
|
|
|
+ warehouseInOutInfo.setWarehouseName(cargoTitleDetails.getWarehouseName());
|
|
|
|
+ warehouseInOutInfo.setPositionId(cargoPositionDetails.getPositionId());
|
|
|
|
+ warehouseInOutInfo.setBinNumber(cargoPositionDetails.getBinNumber());
|
|
|
|
+ warehouseInOutInfo.setInOutFlag("2");
|
|
|
|
+ warehouseInOutInfo.setGoodsName(cargoTitleDetails.getGoodsName());
|
|
|
|
+ CommonSysParameter commonSysParameter = commonSysParameterService.selectOne(new EntityWrapper<CommonSysParameter>().eq("const_id", "CON2").eq("const_value", cargoTitleDetails.getGoodsName()));
|
|
|
|
+ warehouseInOutInfo.setGoodsNameKey(commonSysParameter.getConstKey());
|
|
|
|
+ warehouseInOutInfo.setNetWeight(cargoPositionDetails.getWeight());
|
|
|
|
+ warehouseInOutInfo.setAgent(AuthSecurityUtils.getStaffById(AuthSecurityUtils.getCurrentUserId()).getStaffName());
|
|
|
|
+ warehouseInOutInfo.setStatusFlag(StatusEnum.SUBMITTED.getFlag());
|
|
|
|
+ warehouseInOutInfo.setStatus(StatusEnum.SUBMITTED.getName());
|
|
|
|
+ warehouseInOutInfo.setInOutDate(new Date());
|
|
|
|
+ warehouseInOutInfo.setInOutType("货权转入");
|
|
|
|
+ warehouseInOutInfo.setContractNo(cargoTitleDetails.getOutContractNo());
|
|
|
|
+ warehouseInOutInfoService.insert(warehouseInOutInfo);
|
|
|
|
+ WarehouseInOutDetail warehouseInOutDetail = new WarehouseInOutDetail();
|
|
|
|
+ warehouseInOutDetail.setInfoId(warehouseInOutInfo.getId());
|
|
|
|
+ warehouseInOutDetail.setId(IdGenerator.generateUUID());
|
|
|
|
+ warehouseInOutDetailService.insert(warehouseInOutDetail);
|
|
|
|
+ WarehousePositionStorageInfo warehousePositionStorageInfo = warehousePositionStorageInfoService.selectOne(new EntityWrapper<WarehousePositionStorageInfo>()
|
|
|
|
+ .eq("position_id", cargoPositionDetails.getPositionId())
|
|
|
|
+ .eq("goods_name", cargoTitleDetails.getGoodsName()));
|
|
|
|
+ if (warehousePositionStorageInfo != null) {
|
|
|
|
+ warehousePositionStorageInfo.setStorage(warehousePositionStorageInfo.getStorage() + cargoPositionDetails.getWeight());
|
|
|
|
+ warehousePositionStorageInfoService.updateById(warehousePositionStorageInfo);
|
|
|
|
+ } else {
|
|
|
|
+ WarehousePositionStorageInfo warehousePositionStorageInfo1 = new WarehousePositionStorageInfo();
|
|
|
|
+ warehousePositionStorageInfo1.setId(IdGenerator.generateUUID());
|
|
|
|
+ warehousePositionStorageInfo1.setPositionId(cargoPositionDetails.getPositionId());
|
|
|
|
+ warehousePositionStorageInfo1.setBinNumber(cargoPositionDetails.getBinNumber());
|
|
|
|
+ warehousePositionStorageInfo1.setGoodsNameKey(commonSysParameter.getConstKey());
|
|
|
|
+ warehousePositionStorageInfo1.setGoodsName(cargoTitleDetails.getGoodsName());
|
|
|
|
+ warehousePositionStorageInfo1.setStorage(cargoPositionDetails.getWeight());
|
|
|
|
+ warehousePositionStorageInfoService.insert(warehousePositionStorageInfo1);
|
|
|
|
+ }
|
|
|
|
+ //现货采购入库报表
|
|
|
|
+ StockPurchaseReceiptReport stockPurchaseReceiptReport = new StockPurchaseReceiptReport();
|
|
|
|
+ stockPurchaseReceiptReport.setId(IdGenerator.generateUUID());
|
|
|
|
+ stockPurchaseReceiptReport.setCompId(cargoTitleDetails.getCompId());
|
|
|
|
+ stockPurchaseReceiptReport.setWarehouseRecordId(warehouseInOutInfo.getId());
|
|
|
|
+ stockPurchaseReceiptReport.setContractNo(warehouseInOutInfo.getContractNo());
|
|
|
|
+ stockPurchaseReceiptReport.setWarehouseName(warehouseInOutInfo.getWarehouseName());
|
|
|
|
+ stockPurchaseReceiptReport.setNetWeight(warehouseInOutInfo.getNetWeight());
|
|
|
|
+ stockPurchaseReceiptReport.setWarehousingDate(warehouseInOutInfo.getInOutDate());
|
|
|
|
+ stockPurchaseReceiptReport.setSettlementWeight(warehouseInOutInfo.getNetWeight());
|
|
|
|
+ stockPurchaseReceiptReport.setStatusFlag(StatusEnum.NOT_COLLECTION_PAY.getFlag());
|
|
|
|
+ stockPurchaseReceiptReport.setStatus(StatusEnum.NOT_COLLECTION_PAY.getName());
|
|
|
|
+ stockPurchaseReceiptReportService.insert(stockPurchaseReceiptReport);
|
|
|
|
+ WarehousingOrder warehousingOrder = new WarehousingOrder();
|
|
|
|
+ warehousingOrder.setId(IdGenerator.generateUUID());
|
|
|
|
+ warehousingOrder.setCompId(cargoTitleDetails.getCompId());
|
|
|
|
+ warehousingOrder.setBaseId(cargoTitleDetails.getBaseId());
|
|
|
|
+ warehousingOrder.setContractNo(cargoTitleDetails.getOutContractNo());
|
|
|
|
+ warehousingOrder.setWarehouseName(cargoTitleDetails.getWarehouseName());
|
|
|
|
+ warehousingOrder.setInType("货转");
|
|
|
|
+ warehousingOrder.setGoodsName(cargoTitleDetails.getGoodsName());
|
|
|
|
+ warehousingOrder.setGoodsSource(cargoTitleDetails.getOutContractNo());
|
|
|
|
+ warehousingOrder.setInWarehouseWeight(cargoTitleDetails.getTransferOutWeight());
|
|
|
|
+ warehousingOrder.setAvgCost(cargoTitleDetails.getAvgCost());
|
|
|
|
+ warehousingOrder.setCustomer(cargoTitleDetails.getCustomer());
|
|
|
|
+ warehousingOrder.setSurplusWeight(cargoTitleDetails.getTransferOutWeight());
|
|
|
|
+ warehousingOrder.setAmountNotPayable(cargoTitleDetails.getAmountNotPayable());
|
|
|
|
+ warehousingOrder.setGrainFund(cargoTitleDetails.getAmountNotPayable());
|
|
|
|
+ warehousingOrder.setIssuingTime(new Date());
|
|
|
|
+ warehousingOrderService.insert(warehousingOrder);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ this.insert(cargoTitleDetails);
|
|
|
|
+ return "ok";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 修改赎回状态
|
|
|
|
+ * @param cargoTitleDetails
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public String editStatus(CargoTitleDetails cargoTitleDetails) {
|
|
|
|
+ List<WarehousingOrder> warehousingOrderList=cargoTitleDetails.getWarehousingOrderList();
|
|
|
|
+ if (!CollectionUtils.isEmpty(warehousingOrderList)) {
|
|
|
|
+ for (WarehousingOrder warehousingOrder:warehousingOrderList){
|
|
|
|
+ warehousingOrder.setRedeemFlag("");
|
|
|
|
+ warehousingOrderService.updateById(warehousingOrder);
|
|
|
|
+ ContractManagementInfo contractManagementInfo=contractManagementInfoService.selectOne(new EntityWrapper<ContractManagementInfo>()
|
|
|
|
+ .eq("comp_id",warehousingOrder.getCompId())
|
|
|
|
+ .eq("contract_no",warehousingOrder.getContractNo()));
|
|
|
|
+ if (contractManagementInfo!=null){
|
|
|
|
+ //修改合同预计赎回量
|
|
|
|
+ contractManagementInfo.setExpectedRedemption(contractManagementInfo.getExpectedRedemption()-warehousingOrder.getTransferOutWeight());
|
|
|
|
+ contractManagementInfoService.updateById(contractManagementInfo);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return "ok";
|
|
|
|
+ }
|
|
|
|
+}
|