|  | @@ -1,25 +1,21 @@
 | 
	
		
			
				|  |  |  package org.jeecg.modules.cost.service.impl;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -import org.jeecg.modules.cost.entity.SyCostAllocation;
 | 
	
		
			
				|  |  | -import org.jeecg.modules.cost.entity.SyCostAllocationAccident;
 | 
	
		
			
				|  |  | -import org.jeecg.modules.cost.entity.SyCostAllocationCostpay;
 | 
	
		
			
				|  |  | -import org.jeecg.modules.cost.entity.SyCostAllocationFabric;
 | 
	
		
			
				|  |  | -import org.jeecg.modules.cost.entity.SyCostAllocationIngredient;
 | 
	
		
			
				|  |  | -import org.jeecg.modules.cost.entity.SyCostAllocationShipdetail;
 | 
	
		
			
				|  |  | -import org.jeecg.modules.cost.mapper.SyCostAllocationAccidentMapper;
 | 
	
		
			
				|  |  | -import org.jeecg.modules.cost.mapper.SyCostAllocationCostpayMapper;
 | 
	
		
			
				|  |  | -import org.jeecg.modules.cost.mapper.SyCostAllocationFabricMapper;
 | 
	
		
			
				|  |  | -import org.jeecg.modules.cost.mapper.SyCostAllocationIngredientMapper;
 | 
	
		
			
				|  |  | -import org.jeecg.modules.cost.mapper.SyCostAllocationShipdetailMapper;
 | 
	
		
			
				|  |  | -import org.jeecg.modules.cost.mapper.SyCostAllocationMapper;
 | 
	
		
			
				|  |  | -import org.jeecg.modules.cost.service.ISyCostAllocationService;
 | 
	
		
			
				|  |  | -import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  | +import com.alibaba.fastjson.JSONObject;
 | 
	
		
			
				|  |  | +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 | 
	
		
			
				|  |  |  import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 | 
	
		
			
				|  |  | +import org.jeecg.common.exception.JeecgBootException;
 | 
	
		
			
				|  |  | +import org.jeecg.modules.cost.entity.*;
 | 
	
		
			
				|  |  | +import org.jeecg.modules.cost.mapper.*;
 | 
	
		
			
				|  |  | +import org.jeecg.modules.cost.service.*;
 | 
	
		
			
				|  |  |  import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  | +import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  |  import org.springframework.transaction.annotation.Transactional;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  import java.io.Serializable;
 | 
	
		
			
				|  |  | -import java.util.List;
 | 
	
		
			
				|  |  | +import java.util.ArrayList;
 | 
	
		
			
				|  |  |  import java.util.Collection;
 | 
	
		
			
				|  |  | +import java.util.List;
 | 
	
		
			
				|  |  | +import java.util.stream.Collectors;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /**
 | 
	
		
			
				|  |  |   * @Description: 成本分配主表
 | 
	
	
		
			
				|  | @@ -30,112 +26,180 @@ import java.util.Collection;
 | 
	
		
			
				|  |  |  @Service
 | 
	
		
			
				|  |  |  public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMapper, SyCostAllocation> implements ISyCostAllocationService {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	@Autowired
 | 
	
		
			
				|  |  | -	private SyCostAllocationMapper syCostAllocationMapper;
 | 
	
		
			
				|  |  | -	@Autowired
 | 
	
		
			
				|  |  | -	private SyCostAllocationAccidentMapper syCostAllocationAccidentMapper;
 | 
	
		
			
				|  |  | -	@Autowired
 | 
	
		
			
				|  |  | -	private SyCostAllocationCostpayMapper syCostAllocationCostpayMapper;
 | 
	
		
			
				|  |  | -	@Autowired
 | 
	
		
			
				|  |  | -	private SyCostAllocationFabricMapper syCostAllocationFabricMapper;
 | 
	
		
			
				|  |  | -	@Autowired
 | 
	
		
			
				|  |  | -	private SyCostAllocationIngredientMapper syCostAllocationIngredientMapper;
 | 
	
		
			
				|  |  | -	@Autowired
 | 
	
		
			
				|  |  | -	private SyCostAllocationShipdetailMapper syCostAllocationShipdetailMapper;
 | 
	
		
			
				|  |  | -	
 | 
	
		
			
				|  |  | -	@Override
 | 
	
		
			
				|  |  | -	@Transactional
 | 
	
		
			
				|  |  | -	public void saveMain(SyCostAllocation syCostAllocation, List<SyCostAllocationAccident> syCostAllocationAccidentList,List<SyCostAllocationCostpay> syCostAllocationCostpayList,List<SyCostAllocationFabric> syCostAllocationFabricList,List<SyCostAllocationIngredient> syCostAllocationIngredientList,List<SyCostAllocationShipdetail> syCostAllocationShipdetailList) {
 | 
	
		
			
				|  |  | -		syCostAllocationMapper.insert(syCostAllocation);
 | 
	
		
			
				|  |  | -		for(SyCostAllocationAccident entity:syCostAllocationAccidentList) {
 | 
	
		
			
				|  |  | -			//外键设置
 | 
	
		
			
				|  |  | -			entity.setSyCostAllocationId(syCostAllocation.getId());
 | 
	
		
			
				|  |  | -			syCostAllocationAccidentMapper.insert(entity);
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | -		for(SyCostAllocationCostpay entity:syCostAllocationCostpayList) {
 | 
	
		
			
				|  |  | -			//外键设置
 | 
	
		
			
				|  |  | -			entity.setSyCostAllocationId(syCostAllocation.getId());
 | 
	
		
			
				|  |  | -			syCostAllocationCostpayMapper.insert(entity);
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | -		for(SyCostAllocationFabric entity:syCostAllocationFabricList) {
 | 
	
		
			
				|  |  | -			//外键设置
 | 
	
		
			
				|  |  | -			entity.setSyCostAllocationId(syCostAllocation.getId());
 | 
	
		
			
				|  |  | -			syCostAllocationFabricMapper.insert(entity);
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | -		for(SyCostAllocationIngredient entity:syCostAllocationIngredientList) {
 | 
	
		
			
				|  |  | -			//外键设置
 | 
	
		
			
				|  |  | -			entity.setSyCostAllocationId(syCostAllocation.getId());
 | 
	
		
			
				|  |  | -			syCostAllocationIngredientMapper.insert(entity);
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | -		for(SyCostAllocationShipdetail entity:syCostAllocationShipdetailList) {
 | 
	
		
			
				|  |  | -			//外键设置
 | 
	
		
			
				|  |  | -			entity.setSyCostAllocationId(syCostAllocation.getId());
 | 
	
		
			
				|  |  | -			syCostAllocationShipdetailMapper.insert(entity);
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | -	}
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private SyCostAllocationMapper syCostAllocationMapper;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private SyCostAllocationAccidentMapper syCostAllocationAccidentMapper;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private SyCostAllocationCostpayMapper syCostAllocationCostpayMapper;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private SyCostAllocationFabricMapper syCostAllocationFabricMapper;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private SyCostAllocationIngredientMapper syCostAllocationIngredientMapper;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private SyCostAllocationShipdetailMapper syCostAllocationShipdetailMapper;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private ISyCostAllocationService syCostAllocationService;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private ISyCostAllocationAccidentService syCostAllocationAccidentService;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private ISyCostAllocationCostpayService syCostAllocationCostpayService;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private ISyCostAllocationFabricService syCostAllocationFabricService;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private ISyCostAllocationIngredientService syCostAllocationIngredientService;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private ISyCostAllocationShipdetailService syCostAllocationShipdetailService;
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    @Transactional
 | 
	
		
			
				|  |  | +    public void saveMain(SyCostAllocation syCostAllocation, List<SyCostAllocationAccident> syCostAllocationAccidentList,List<SyCostAllocationCostpay> syCostAllocationCostpayList,List<SyCostAllocationFabric> syCostAllocationFabricList,List<SyCostAllocationIngredient> syCostAllocationIngredientList,List<SyCostAllocationShipdetail> syCostAllocationShipdetailList) {
 | 
	
		
			
				|  |  | +        syCostAllocationMapper.insert(syCostAllocation);
 | 
	
		
			
				|  |  | +        for(SyCostAllocationAccident entity:syCostAllocationAccidentList) {
 | 
	
		
			
				|  |  | +            //外键设置
 | 
	
		
			
				|  |  | +            entity.setSyCostAllocationId(syCostAllocation.getId());
 | 
	
		
			
				|  |  | +            syCostAllocationAccidentMapper.insert(entity);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        for(SyCostAllocationCostpay entity:syCostAllocationCostpayList) {
 | 
	
		
			
				|  |  | +            //外键设置
 | 
	
		
			
				|  |  | +            entity.setSyCostAllocationId(syCostAllocation.getId());
 | 
	
		
			
				|  |  | +            syCostAllocationCostpayMapper.insert(entity);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        for(SyCostAllocationFabric entity:syCostAllocationFabricList) {
 | 
	
		
			
				|  |  | +            //外键设置
 | 
	
		
			
				|  |  | +            entity.setSyCostAllocationId(syCostAllocation.getId());
 | 
	
		
			
				|  |  | +            syCostAllocationFabricMapper.insert(entity);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        for(SyCostAllocationIngredient entity:syCostAllocationIngredientList) {
 | 
	
		
			
				|  |  | +            //外键设置
 | 
	
		
			
				|  |  | +            entity.setSyCostAllocationId(syCostAllocation.getId());
 | 
	
		
			
				|  |  | +            syCostAllocationIngredientMapper.insert(entity);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        for(SyCostAllocationShipdetail entity:syCostAllocationShipdetailList) {
 | 
	
		
			
				|  |  | +            //外键设置
 | 
	
		
			
				|  |  | +            entity.setSyCostAllocationId(syCostAllocation.getId());
 | 
	
		
			
				|  |  | +            syCostAllocationShipdetailMapper.insert(entity);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    @Transactional
 | 
	
		
			
				|  |  | +    public void updateMain(SyCostAllocation syCostAllocation,List<SyCostAllocationAccident> syCostAllocationAccidentList,List<SyCostAllocationCostpay> syCostAllocationCostpayList,List<SyCostAllocationFabric> syCostAllocationFabricList,List<SyCostAllocationIngredient> syCostAllocationIngredientList,List<SyCostAllocationShipdetail> syCostAllocationShipdetailList) {
 | 
	
		
			
				|  |  | +        syCostAllocationMapper.updateById(syCostAllocation);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        //1.先删除子表数据
 | 
	
		
			
				|  |  | +        syCostAllocationAccidentMapper.deleteByMainId(syCostAllocation.getId());
 | 
	
		
			
				|  |  | +        syCostAllocationCostpayMapper.deleteByMainId(syCostAllocation.getId());
 | 
	
		
			
				|  |  | +        syCostAllocationFabricMapper.deleteByMainId(syCostAllocation.getId());
 | 
	
		
			
				|  |  | +        syCostAllocationIngredientMapper.deleteByMainId(syCostAllocation.getId());
 | 
	
		
			
				|  |  | +        syCostAllocationShipdetailMapper.deleteByMainId(syCostAllocation.getId());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        //2.子表数据重新插入
 | 
	
		
			
				|  |  | +        for(SyCostAllocationAccident entity:syCostAllocationAccidentList) {
 | 
	
		
			
				|  |  | +            //外键设置
 | 
	
		
			
				|  |  | +            entity.setSyCostAllocationId(syCostAllocation.getId());
 | 
	
		
			
				|  |  | +            syCostAllocationAccidentMapper.insert(entity);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        for(SyCostAllocationCostpay entity:syCostAllocationCostpayList) {
 | 
	
		
			
				|  |  | +            //外键设置
 | 
	
		
			
				|  |  | +            entity.setSyCostAllocationId(syCostAllocation.getId());
 | 
	
		
			
				|  |  | +            syCostAllocationCostpayMapper.insert(entity);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        for(SyCostAllocationFabric entity:syCostAllocationFabricList) {
 | 
	
		
			
				|  |  | +            //外键设置
 | 
	
		
			
				|  |  | +            entity.setSyCostAllocationId(syCostAllocation.getId());
 | 
	
		
			
				|  |  | +            syCostAllocationFabricMapper.insert(entity);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        for(SyCostAllocationIngredient entity:syCostAllocationIngredientList) {
 | 
	
		
			
				|  |  | +            //外键设置
 | 
	
		
			
				|  |  | +            entity.setSyCostAllocationId(syCostAllocation.getId());
 | 
	
		
			
				|  |  | +            syCostAllocationIngredientMapper.insert(entity);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        for(SyCostAllocationShipdetail entity:syCostAllocationShipdetailList) {
 | 
	
		
			
				|  |  | +            //外键设置
 | 
	
		
			
				|  |  | +            entity.setSyCostAllocationId(syCostAllocation.getId());
 | 
	
		
			
				|  |  | +            syCostAllocationShipdetailMapper.insert(entity);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    @Transactional
 | 
	
		
			
				|  |  | +    public void delMain(String id) {
 | 
	
		
			
				|  |  | +        syCostAllocationAccidentMapper.deleteByMainId(id);
 | 
	
		
			
				|  |  | +        syCostAllocationCostpayMapper.deleteByMainId(id);
 | 
	
		
			
				|  |  | +        syCostAllocationFabricMapper.deleteByMainId(id);
 | 
	
		
			
				|  |  | +        syCostAllocationIngredientMapper.deleteByMainId(id);
 | 
	
		
			
				|  |  | +        syCostAllocationShipdetailMapper.deleteByMainId(id);
 | 
	
		
			
				|  |  | +        syCostAllocationMapper.deleteById(id);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    @Transactional
 | 
	
		
			
				|  |  | +    public void delBatchMain(Collection<? extends Serializable> idList) {
 | 
	
		
			
				|  |  | +        for(Serializable id:idList) {
 | 
	
		
			
				|  |  | +            syCostAllocationAccidentMapper.deleteByMainId(id.toString());
 | 
	
		
			
				|  |  | +            syCostAllocationCostpayMapper.deleteByMainId(id.toString());
 | 
	
		
			
				|  |  | +            syCostAllocationFabricMapper.deleteByMainId(id.toString());
 | 
	
		
			
				|  |  | +            syCostAllocationIngredientMapper.deleteByMainId(id.toString());
 | 
	
		
			
				|  |  | +            syCostAllocationShipdetailMapper.deleteByMainId(id.toString());
 | 
	
		
			
				|  |  | +            syCostAllocationMapper.deleteById(id);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    public SyCostAllocation queryByPlanNum(String plannum, String type) {
 | 
	
		
			
				|  |  | +        SyCostAllocation syCostAllocation=new SyCostAllocation();
 | 
	
		
			
				|  |  | +        if(type.equals("query")){
 | 
	
		
			
				|  |  | +            QueryWrapper<SyCostAllocation> listQueryWrapper = new QueryWrapper<>();
 | 
	
		
			
				|  |  | +            listQueryWrapper.eq("plan_num", plannum).eq("del_flag", 0);
 | 
	
		
			
				|  |  | +            List<SyCostAllocation> list = syCostAllocationService.list(listQueryWrapper);
 | 
	
		
			
				|  |  | +            if (list.size() != 1) {
 | 
	
		
			
				|  |  | +                throw new JeecgBootException("数据查询有误,请联系管理员确认!");
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            syCostAllocation = list.get(0);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            //事故单
 | 
	
		
			
				|  |  | +            QueryWrapper<SyCostAllocationAccident> list1QueryWrapper = new QueryWrapper<>();
 | 
	
		
			
				|  |  | +            list1QueryWrapper.in("sy_cost_allocation_id", syCostAllocation.getId()).eq("del_flag", 0);
 | 
	
		
			
				|  |  | +            List<SyCostAllocationAccident> list1 = syCostAllocationAccidentService.list(list1QueryWrapper);
 | 
	
		
			
				|  |  | +            syCostAllocation.setSyCostAllocationAccidentList(list1);
 | 
	
		
			
				|  |  | +            //费用支出
 | 
	
		
			
				|  |  | +            QueryWrapper<SyCostAllocationCostpay> list2QueryWrapper = new QueryWrapper<>();
 | 
	
		
			
				|  |  | +            list2QueryWrapper.in("sy_cost_allocation_id", syCostAllocation.getId()).eq("del_flag", 0);
 | 
	
		
			
				|  |  | +            List<SyCostAllocationCostpay> list2 = syCostAllocationCostpayService.list(list2QueryWrapper);
 | 
	
		
			
				|  |  | +            syCostAllocation.setSyCostAllocationCostpayList(list2);
 | 
	
		
			
				|  |  | +            //面料
 | 
	
		
			
				|  |  | +            QueryWrapper<SyCostAllocationFabric> list3QueryWrapper = new QueryWrapper<>();
 | 
	
		
			
				|  |  | +            list3QueryWrapper.in("sy_cost_allocation_id", syCostAllocation.getId()).eq("del_flag", 0);
 | 
	
		
			
				|  |  | +            List<SyCostAllocationFabric> list3 = syCostAllocationFabricService.list(list3QueryWrapper);
 | 
	
		
			
				|  |  | +            //辅料
 | 
	
		
			
				|  |  | +            QueryWrapper<SyCostAllocationIngredient> list4QueryWrapper = new QueryWrapper<>();
 | 
	
		
			
				|  |  | +            list4QueryWrapper.in("sy_cost_allocation_id", syCostAllocation.getId()).eq("del_flag", 0);
 | 
	
		
			
				|  |  | +            List<SyCostAllocationIngredient> list4 = syCostAllocationIngredientService.list(list4QueryWrapper);
 | 
	
		
			
				|  |  | +            //发运明细
 | 
	
		
			
				|  |  | +            QueryWrapper<SyCostAllocationShipdetail> list5QueryWrapper = new QueryWrapper<>();
 | 
	
		
			
				|  |  | +            list5QueryWrapper.in("sy_cost_allocation_id", syCostAllocation.getId()).eq("del_flag", 0);
 | 
	
		
			
				|  |  | +            List<SyCostAllocationShipdetail> list5 = syCostAllocationShipdetailService.list(list5QueryWrapper);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            List<JSONObject> processUnitList=new ArrayList<>();//子表数据_加工单位集合
 | 
	
		
			
				|  |  | +            //获取主表加工单位,拆分获取对应数据
 | 
	
		
			
				|  |  | +            String[] processUnit=syCostAllocation.getProcessUnit().split(",");
 | 
	
		
			
				|  |  | +            for(int i=0;i<processUnit.length;i++){
 | 
	
		
			
				|  |  | +                String unit=processUnit[i];
 | 
	
		
			
				|  |  | +                JSONObject jSONObject=new JSONObject();
 | 
	
		
			
				|  |  | +                List<SyCostAllocationFabric> list3b = list3.stream().filter(t -> t.getProcessUnit().equals(unit)).collect(Collectors.toList());
 | 
	
		
			
				|  |  | +                List<SyCostAllocationIngredient> list4b = list4.stream().filter(t -> t.getProcessUnit().equals(unit)).collect(Collectors.toList());
 | 
	
		
			
				|  |  | +                List<SyCostAllocationShipdetail> list5b = list5.stream().filter(t -> t.getProcessUnit().equals(unit)).collect(Collectors.toList());
 | 
	
		
			
				|  |  | +                jSONObject.put("syCostAllocationFabricList", list3b);
 | 
	
		
			
				|  |  | +                jSONObject.put("syCostAllocationIngredientList",list4b);
 | 
	
		
			
				|  |  | +                jSONObject.put("syCostAllocationShipdetailList",list5b);
 | 
	
		
			
				|  |  | +                processUnitList.add(jSONObject);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            syCostAllocation.setProcessUnitList(processUnitList);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	@Override
 | 
	
		
			
				|  |  | -	@Transactional
 | 
	
		
			
				|  |  | -	public void updateMain(SyCostAllocation syCostAllocation,List<SyCostAllocationAccident> syCostAllocationAccidentList,List<SyCostAllocationCostpay> syCostAllocationCostpayList,List<SyCostAllocationFabric> syCostAllocationFabricList,List<SyCostAllocationIngredient> syCostAllocationIngredientList,List<SyCostAllocationShipdetail> syCostAllocationShipdetailList) {
 | 
	
		
			
				|  |  | -		syCostAllocationMapper.updateById(syCostAllocation);
 | 
	
		
			
				|  |  | -		
 | 
	
		
			
				|  |  | -		//1.先删除子表数据
 | 
	
		
			
				|  |  | -		syCostAllocationAccidentMapper.deleteByMainId(syCostAllocation.getId());
 | 
	
		
			
				|  |  | -		syCostAllocationCostpayMapper.deleteByMainId(syCostAllocation.getId());
 | 
	
		
			
				|  |  | -		syCostAllocationFabricMapper.deleteByMainId(syCostAllocation.getId());
 | 
	
		
			
				|  |  | -		syCostAllocationIngredientMapper.deleteByMainId(syCostAllocation.getId());
 | 
	
		
			
				|  |  | -		syCostAllocationShipdetailMapper.deleteByMainId(syCostAllocation.getId());
 | 
	
		
			
				|  |  | -		
 | 
	
		
			
				|  |  | -		//2.子表数据重新插入
 | 
	
		
			
				|  |  | -		for(SyCostAllocationAccident entity:syCostAllocationAccidentList) {
 | 
	
		
			
				|  |  | -			//外键设置
 | 
	
		
			
				|  |  | -			entity.setSyCostAllocationId(syCostAllocation.getId());
 | 
	
		
			
				|  |  | -			syCostAllocationAccidentMapper.insert(entity);
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | -		for(SyCostAllocationCostpay entity:syCostAllocationCostpayList) {
 | 
	
		
			
				|  |  | -			//外键设置
 | 
	
		
			
				|  |  | -			entity.setSyCostAllocationId(syCostAllocation.getId());
 | 
	
		
			
				|  |  | -			syCostAllocationCostpayMapper.insert(entity);
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | -		for(SyCostAllocationFabric entity:syCostAllocationFabricList) {
 | 
	
		
			
				|  |  | -			//外键设置
 | 
	
		
			
				|  |  | -			entity.setSyCostAllocationId(syCostAllocation.getId());
 | 
	
		
			
				|  |  | -			syCostAllocationFabricMapper.insert(entity);
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | -		for(SyCostAllocationIngredient entity:syCostAllocationIngredientList) {
 | 
	
		
			
				|  |  | -			//外键设置
 | 
	
		
			
				|  |  | -			entity.setSyCostAllocationId(syCostAllocation.getId());
 | 
	
		
			
				|  |  | -			syCostAllocationIngredientMapper.insert(entity);
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | -		for(SyCostAllocationShipdetail entity:syCostAllocationShipdetailList) {
 | 
	
		
			
				|  |  | -			//外键设置
 | 
	
		
			
				|  |  | -			entity.setSyCostAllocationId(syCostAllocation.getId());
 | 
	
		
			
				|  |  | -			syCostAllocationShipdetailMapper.insert(entity);
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | -	}
 | 
	
		
			
				|  |  | +        }else if(type.equals("add")){
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	@Override
 | 
	
		
			
				|  |  | -	@Transactional
 | 
	
		
			
				|  |  | -	public void delMain(String id) {
 | 
	
		
			
				|  |  | -		syCostAllocationAccidentMapper.deleteByMainId(id);
 | 
	
		
			
				|  |  | -		syCostAllocationCostpayMapper.deleteByMainId(id);
 | 
	
		
			
				|  |  | -		syCostAllocationFabricMapper.deleteByMainId(id);
 | 
	
		
			
				|  |  | -		syCostAllocationIngredientMapper.deleteByMainId(id);
 | 
	
		
			
				|  |  | -		syCostAllocationShipdetailMapper.deleteByMainId(id);
 | 
	
		
			
				|  |  | -		syCostAllocationMapper.deleteById(id);
 | 
	
		
			
				|  |  | -	}
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return syCostAllocation;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	@Override
 | 
	
		
			
				|  |  | -	@Transactional
 | 
	
		
			
				|  |  | -	public void delBatchMain(Collection<? extends Serializable> idList) {
 | 
	
		
			
				|  |  | -		for(Serializable id:idList) {
 | 
	
		
			
				|  |  | -			syCostAllocationAccidentMapper.deleteByMainId(id.toString());
 | 
	
		
			
				|  |  | -			syCostAllocationCostpayMapper.deleteByMainId(id.toString());
 | 
	
		
			
				|  |  | -			syCostAllocationFabricMapper.deleteByMainId(id.toString());
 | 
	
		
			
				|  |  | -			syCostAllocationIngredientMapper.deleteByMainId(id.toString());
 | 
	
		
			
				|  |  | -			syCostAllocationShipdetailMapper.deleteByMainId(id.toString());
 | 
	
		
			
				|  |  | -			syCostAllocationMapper.deleteById(id);
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | -	}
 | 
	
		
			
				|  |  | -	
 | 
	
		
			
				|  |  |  }
 |