|  | @@ -4,6 +4,8 @@ package com.ruoyi.warehouseBusiness.service.impl;
 | 
	
		
			
				|  |  |  import cn.hutool.core.collection.CollUtil;
 | 
	
		
			
				|  |  |  import com.alibaba.fastjson.JSONArray;
 | 
	
		
			
				|  |  |  import com.alibaba.fastjson.JSONObject;
 | 
	
		
			
				|  |  | +import com.ruoyi.approvalFlow.domain.AuditItems;
 | 
	
		
			
				|  |  | +import com.ruoyi.approvalFlow.service.impl.AuditItemsServiceImpl;
 | 
	
		
			
				|  |  |  import com.ruoyi.basicData.domain.TCorps;
 | 
	
		
			
				|  |  |  import com.ruoyi.basicData.domain.TFees;
 | 
	
		
			
				|  |  |  import com.ruoyi.basicData.domain.TGoods;
 | 
	
	
		
			
				|  | @@ -15,6 +17,8 @@ import com.ruoyi.common.core.domain.entity.SysUser;
 | 
	
		
			
				|  |  |  import com.ruoyi.common.core.domain.model.LoginUser;
 | 
	
		
			
				|  |  |  import com.ruoyi.common.utils.DateUtils;
 | 
	
		
			
				|  |  |  import com.ruoyi.common.utils.StringUtils;
 | 
	
		
			
				|  |  | +import com.ruoyi.system.domain.SysConfig;
 | 
	
		
			
				|  |  | +import com.ruoyi.system.mapper.SysConfigMapper;
 | 
	
		
			
				|  |  |  import com.ruoyi.system.mapper.SysDeptMapper;
 | 
	
		
			
				|  |  |  import com.ruoyi.warehouseBusiness.domain.BillnoDel;
 | 
	
		
			
				|  |  |  import com.ruoyi.warehouseBusiness.domain.TWarehouseAgreement;
 | 
	
	
		
			
				|  | @@ -25,6 +29,8 @@ import com.ruoyi.warehouseBusiness.mapper.TWarehouseAgreementitemsMapper;
 | 
	
		
			
				|  |  |  import com.ruoyi.warehouseBusiness.service.ITWarehouseAgreementService;
 | 
	
		
			
				|  |  |  import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  |  import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  | +import org.springframework.transaction.annotation.Transactional;
 | 
	
		
			
				|  |  | +import org.springframework.transaction.interceptor.TransactionAspectSupport;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import java.math.BigDecimal;
 | 
	
		
			
				|  |  |  import java.util.*;
 | 
	
	
		
			
				|  | @@ -61,6 +67,12 @@ public class TWarehouseAgreementServiceImpl implements ITWarehouseAgreementServi
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private SysDeptMapper sysDeptMapper;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private SysConfigMapper sysConfigMapper;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private AuditItemsServiceImpl auditItemsService;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 查询仓储费
 | 
	
	
		
			
				|  | @@ -187,7 +199,7 @@ public class TWarehouseAgreementServiceImpl implements ITWarehouseAgreementServi
 | 
	
		
			
				|  |  |              tWarehouseAgreementitemsMapper.deleteByFPid(fPid);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          //  从表添加
 | 
	
		
			
				|  |  | -        if (StringUtils.isNotNull(agreementitems)) {
 | 
	
		
			
				|  |  | +        if (StringUtils.isNotNull(agreementitems) && !"[]".equals(agreementitems)) {
 | 
	
		
			
				|  |  |              JSONArray jsonDrArray = JSONArray.parseArray(agreementitems);
 | 
	
		
			
				|  |  |              List<TWarehouseAgreementitems> tWarehouseAgreementitemsList = JSONObject.parseArray(jsonDrArray.toJSONString(), TWarehouseAgreementitems.class);
 | 
	
		
			
				|  |  |              for (TWarehouseAgreementitems tWarehouseAgreementitems : tWarehouseAgreementitemsList) {
 | 
	
	
		
			
				|  | @@ -201,6 +213,93 @@ public class TWarehouseAgreementServiceImpl implements ITWarehouseAgreementServi
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  | +     *   仓储费请核
 | 
	
		
			
				|  |  | +     * @param agreement
 | 
	
		
			
				|  |  | +     * @param agreementitems
 | 
	
		
			
				|  |  | +     * @param loginUser
 | 
	
		
			
				|  |  | +     * @param fFeetypeid
 | 
	
		
			
				|  |  | +     * @return
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    @Transactional
 | 
	
		
			
				|  |  | +    public AjaxResult tWarehouseAgreementSubmit(String agreement, String agreementitems, LoginUser loginUser, int fFeetypeid) {
 | 
	
		
			
				|  |  | +        Long fPid = null;
 | 
	
		
			
				|  |  | +        TWarehouseAgreement tWarehouseAgreement = JSONArray.parseObject(agreement, TWarehouseAgreement.class);
 | 
	
		
			
				|  |  | +        if(StringUtils.isNull(tWarehouseAgreement.getfId())){
 | 
	
		
			
				|  |  | +            // 如果是新数据
 | 
	
		
			
				|  |  | +            tWarehouseAgreement.setCreateBy(loginUser.getUser().getUserName());
 | 
	
		
			
				|  |  | +            // 业务编码
 | 
	
		
			
				|  |  | +            String billNo = billnoSerialServiceImpl.getBillNo("WA", new Date());
 | 
	
		
			
				|  |  | +            tWarehouseAgreement.setfBillno(billNo);
 | 
	
		
			
				|  |  | +            tWarehouseAgreement.setCreateBy(loginUser.getUser().getUserName());
 | 
	
		
			
				|  |  | +            tWarehouseAgreement.setfDeptid(loginUser.getUser().getDeptId());
 | 
	
		
			
				|  |  | +            tWarehouseAgreement.setfFeetypeid((long) fFeetypeid);
 | 
	
		
			
				|  |  | +            tWarehouseAgreementMapper.insertTWarehouseAgreement(tWarehouseAgreement);
 | 
	
		
			
				|  |  | +            fPid = tWarehouseAgreement.getfId();
 | 
	
		
			
				|  |  | +        }else{
 | 
	
		
			
				|  |  | +            fPid = tWarehouseAgreement.getfId();
 | 
	
		
			
				|  |  | +            tWarehouseAgreement.setUpdateBy(loginUser.getUser().getUserName());
 | 
	
		
			
				|  |  | +            tWarehouseAgreement.setUpdateTime(new Date());
 | 
	
		
			
				|  |  | +            tWarehouseAgreementMapper.updateTWarehouseAgreement(tWarehouseAgreement);
 | 
	
		
			
				|  |  | +            tWarehouseAgreementitemsMapper.deleteByFPid(fPid);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        //  从表添加
 | 
	
		
			
				|  |  | +        if (StringUtils.isNotNull(agreementitems) && !"[]".equals(agreementitems)) {
 | 
	
		
			
				|  |  | +            JSONArray jsonDrArray = JSONArray.parseArray(agreementitems);
 | 
	
		
			
				|  |  | +            List<TWarehouseAgreementitems> tWarehouseAgreementitemsList = JSONObject.parseArray(jsonDrArray.toJSONString(), TWarehouseAgreementitems.class);
 | 
	
		
			
				|  |  | +            for (TWarehouseAgreementitems tWarehouseAgreementitems : tWarehouseAgreementitemsList) {
 | 
	
		
			
				|  |  | +                tWarehouseAgreementitems.setfPid(fPid);
 | 
	
		
			
				|  |  | +                tWarehouseAgreementitems.setCreateBy(loginUser.getUser().getUserName());
 | 
	
		
			
				|  |  | +                tWarehouseAgreementitems.setCreateTime(new Date());
 | 
	
		
			
				|  |  | +                tWarehouseAgreementitemsMapper.insertTWarehouseAgreementitems(tWarehouseAgreementitems);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        // 这里加个判断取系统参数来确定是否需要启用审批流
 | 
	
		
			
				|  |  | +        String key = "";
 | 
	
		
			
				|  |  | +        boolean isApprove = false;
 | 
	
		
			
				|  |  | +        long actId = 0L;
 | 
	
		
			
				|  |  | +        if (fFeetypeid==0) {
 | 
	
		
			
				|  |  | +            actId = 310L;
 | 
	
		
			
				|  |  | +            key = "warehouse.storage.ApprovalFlow";
 | 
	
		
			
				|  |  | +        } else if (fFeetypeid==1) {
 | 
	
		
			
				|  |  | +            actId = 320L;
 | 
	
		
			
				|  |  | +            key = "warehouse.task.ApprovalFlow";
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        SysConfig sysConfig = sysConfigMapper.checkConfigKeyUnique(key);
 | 
	
		
			
				|  |  | +        if (StringUtils.isNull(sysConfig)) {
 | 
	
		
			
				|  |  | +            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
 | 
	
		
			
				|  |  | +            return AjaxResult.error("系统参数异常,未找到开启审批流参数");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if ("0".equals(sysConfig.getConfigValue())) {
 | 
	
		
			
				|  |  | +            isApprove = true;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (isApprove) {
 | 
	
		
			
				|  |  | +            AuditItems auditItems = new AuditItems();
 | 
	
		
			
				|  |  | +            auditItems.setLevelId(0L);
 | 
	
		
			
				|  |  | +            auditItems.setBillId(fPid);
 | 
	
		
			
				|  |  | +            auditItems.setActId(actId);
 | 
	
		
			
				|  |  | +            auditItems.setIffinalItem("F");
 | 
	
		
			
				|  |  | +            auditItems.setBillNo(tWarehouseAgreement.getfBillno());
 | 
	
		
			
				|  |  | +            // 存储业务类型(业务类型)
 | 
	
		
			
				|  |  | +            auditItems.setRefno2(String.valueOf(tWarehouseAgreement.getfFeetypeid()));
 | 
	
		
			
				|  |  | +            auditItems.setSendUserId(loginUser.getUser().getUserId());
 | 
	
		
			
				|  |  | +            auditItems.setSendName(loginUser.getUsername());
 | 
	
		
			
				|  |  | +            auditItems.setSendTime(new Date());
 | 
	
		
			
				|  |  | +            auditItems.setAuditUserId(loginUser.getUser().getUserId());
 | 
	
		
			
				|  |  | +            auditItems.setAuditItem(new Date());
 | 
	
		
			
				|  |  | +            auditItems.setAuditMsg("提交");
 | 
	
		
			
				|  |  | +            auditItems.setAuditStatus("O");
 | 
	
		
			
				|  |  | +            AjaxResult approvalFlow = auditItemsService.createApprovalFlow(auditItems);
 | 
	
		
			
				|  |  | +            Long code = Long.valueOf(String.valueOf(approvalFlow.get("code"))).longValue();
 | 
	
		
			
				|  |  | +            if (code.equals(500L)) {
 | 
	
		
			
				|  |  | +                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            return approvalFlow;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return null;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  |       * 修改仓储费
 | 
	
		
			
				|  |  |       *
 | 
	
		
			
				|  |  |       * @param tWarehouseAgreement 仓储费
 |