|  | @@ -1,14 +1,26 @@
 | 
	
		
			
				|  |  |  package com.ruoyi.warehouseBusiness.service.impl;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +import com.alibaba.fastjson.JSONArray;
 | 
	
		
			
				|  |  | +import com.alibaba.fastjson.JSONObject;
 | 
	
		
			
				|  |  | +import com.ruoyi.common.core.domain.AjaxResult;
 | 
	
		
			
				|  |  | +import com.ruoyi.common.core.domain.model.LoginUser;
 | 
	
		
			
				|  |  |  import com.ruoyi.common.utils.DateUtils;
 | 
	
		
			
				|  |  | +import com.ruoyi.common.utils.StringUtils;
 | 
	
		
			
				|  |  | +import com.ruoyi.warehouseBusiness.domain.BillnoDel;
 | 
	
		
			
				|  |  |  import com.ruoyi.warehouseBusiness.domain.TWarehouseAgreement;
 | 
	
		
			
				|  |  | +import com.ruoyi.warehouseBusiness.domain.TWarehouseAgreementitems;
 | 
	
		
			
				|  |  | +import com.ruoyi.warehouseBusiness.domain.TWarehouseBills;
 | 
	
		
			
				|  |  | +import com.ruoyi.warehouseBusiness.mapper.BillnoDelMapper;
 | 
	
		
			
				|  |  |  import com.ruoyi.warehouseBusiness.mapper.TWarehouseAgreementMapper;
 | 
	
		
			
				|  |  | +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 java.util.Date;
 | 
	
		
			
				|  |  |  import java.util.List;
 | 
	
		
			
				|  |  | +import java.util.Map;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /**
 | 
	
		
			
				|  |  |   * 仓储费Service业务层处理
 | 
	
	
		
			
				|  | @@ -21,6 +33,15 @@ public class TWarehouseAgreementServiceImpl implements ITWarehouseAgreementServi
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private TWarehouseAgreementMapper tWarehouseAgreementMapper;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private TWarehouseAgreementitemsMapper tWarehouseAgreementitemsMapper;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private BillnoSerialServiceImpl billnoSerialServiceImpl;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private BillnoDelMapper billnoDelMapper;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 查询仓储费
 | 
	
		
			
				|  |  |       *
 | 
	
	
		
			
				|  | @@ -39,20 +60,61 @@ public class TWarehouseAgreementServiceImpl implements ITWarehouseAgreementServi
 | 
	
		
			
				|  |  |       * @return 仓储费
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  | -    public List<TWarehouseAgreement> selectTWarehouseAgreementList(TWarehouseAgreement tWarehouseAgreement) {
 | 
	
		
			
				|  |  | -        return tWarehouseAgreementMapper.selectTWarehouseAgreementList(tWarehouseAgreement);
 | 
	
		
			
				|  |  | +    public List<Map<String, Object>> selectTWarehouseAgreementList1(TWarehouseAgreement tWarehouseAgreement) {
 | 
	
		
			
				|  |  | +        return tWarehouseAgreementMapper.selectTWarehouseAgreementList1(tWarehouseAgreement);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  | -     * 新增仓储费
 | 
	
		
			
				|  |  | +     * 查询仓储费列表
 | 
	
		
			
				|  |  |       *
 | 
	
		
			
				|  |  |       * @param tWarehouseAgreement 仓储费
 | 
	
		
			
				|  |  | -     * @return 结果
 | 
	
		
			
				|  |  | +     * @return 仓储费
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    public List<TWarehouseAgreement> selectTWarehouseAgreementList(TWarehouseAgreement tWarehouseAgreement) {
 | 
	
		
			
				|  |  | +        return tWarehouseAgreementMapper.selectTWarehouseAgreementList(tWarehouseAgreement);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     *  新增
 | 
	
		
			
				|  |  | +     * @param agreement
 | 
	
		
			
				|  |  | +     * @param agreementitems
 | 
	
		
			
				|  |  | +     * @param loginUser
 | 
	
		
			
				|  |  | +     * @return
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  | -    public int insertTWarehouseAgreement(TWarehouseAgreement tWarehouseAgreement) {
 | 
	
		
			
				|  |  | -        tWarehouseAgreement.setCreateTime(DateUtils.getNowDate());
 | 
	
		
			
				|  |  | -        return tWarehouseAgreementMapper.insertTWarehouseAgreement(tWarehouseAgreement);
 | 
	
		
			
				|  |  | +    public AjaxResult insertTWarehouseAgreement(String agreement, String agreementitems, LoginUser loginUser) {
 | 
	
		
			
				|  |  | +        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);
 | 
	
		
			
				|  |  | +            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)) {
 | 
	
		
			
				|  |  | +            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);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return AjaxResult.success();
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
	
		
			
				|  | @@ -75,6 +137,16 @@ public class TWarehouseAgreementServiceImpl implements ITWarehouseAgreementServi
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public int deleteTWarehouseAgreementByIds(Long[] fIds) {
 | 
	
		
			
				|  |  | +        // 取出业务编号、 放入 billno_del
 | 
	
		
			
				|  |  | +        for(Long id:fIds){
 | 
	
		
			
				|  |  | +            // 1、查询主表信息
 | 
	
		
			
				|  |  | +            TWarehouseAgreement tWarehouseAgreement =  tWarehouseAgreementMapper.selectTWarehouseAgreementById(id);
 | 
	
		
			
				|  |  | +            // 2、业务编号、客存编号 放入 billno_del
 | 
	
		
			
				|  |  | +            BillnoDel billnoDel =new BillnoDel();
 | 
	
		
			
				|  |  | +            billnoDel.setBillType("WA");
 | 
	
		
			
				|  |  | +            billnoDel.setBillNo(tWarehouseAgreement.getfBillno());
 | 
	
		
			
				|  |  | +            billnoDelMapper.insertBillnoDel(billnoDel);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |          return tWarehouseAgreementMapper.deleteTWarehouseAgreementByIds(fIds);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 |