|  | @@ -7,6 +7,8 @@ import java.util.List;
 | 
	
		
			
				|  |  |  import java.util.Map;
 | 
	
		
			
				|  |  |  import java.util.Set;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +import com.czb.sap.sdk.tools.StringUtils;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  import kd.bos.context.RequestContext;
 | 
	
		
			
				|  |  |  import kd.bos.dataentity.OperateOption;
 | 
	
		
			
				|  |  |  import kd.bos.dataentity.entity.DynamicObject;
 | 
	
	
		
			
				|  | @@ -43,30 +45,47 @@ public class PurContractHaveNotJGSDTask extends AbstractTask {
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          
 | 
	
		
			
				|  |  |          if (!xshtids.isEmpty()) {
 | 
	
		
			
				|  |  | +        	Map<String,String> xsht2cghtbillno = new HashMap<>();
 | 
	
		
			
				|  |  |          	Map<String,Set<String>> xsht2cght = new HashMap<>();
 | 
	
		
			
				|  |  |              QFilter qcght = new QFilter("billstatus", QCP.equals, "C");
 | 
	
		
			
				|  |  |              qcght.and("nckd_refbillfield", QCP.in, xshtids);
 | 
	
		
			
				|  |  | -            qcght.and("nckd_combofield",QCP.not_equals,"A");
 | 
	
		
			
				|  |  | +            List<String> cghtbillnos = new ArrayList<>();
 | 
	
		
			
				|  |  | +            DynamicObjectCollection cghts = QueryServiceHelper.query("conm_purcontract","id,billno,nckd_refbillfield", qcght.toArray(), "");
 | 
	
		
			
				|  |  | +            for(DynamicObject cght : cghts) {
 | 
	
		
			
				|  |  | +            	String billno = cght.getString("billno");
 | 
	
		
			
				|  |  | +            	DynamicObject xshtbill = cght.getDynamicObject("nckd_refbillfield");
 | 
	
		
			
				|  |  | +            	String xshtbillno = xshtbill.getString("billno");
 | 
	
		
			
				|  |  | +            	xsht2cghtbillno.put(xshtbillno, billno);
 | 
	
		
			
				|  |  | +            	cghtbillnos.add(billno);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            DynamicObjectCollection cghts = QueryServiceHelper.query("conm_xpurcontract","id,billno,nckd_refbillfield", qcght.toArray(), "");
 | 
	
		
			
				|  |  | -            if(!cghts.isEmpty()){
 | 
	
		
			
				|  |  | -                for (DynamicObject saleData : collections) {
 | 
	
		
			
				|  |  | -                    String billno = saleData.getString("billno");//采购合同编号
 | 
	
		
			
				|  |  | -                    DynamicObject srcxsht = saleData.getDynamicObject("nckd_refbillfield");
 | 
	
		
			
				|  |  | -                    String xshtbillno = srcxsht.getString("billno");
 | 
	
		
			
				|  |  | -                    Set<String> cghtinfo = xsht2cght.get(xshtbillno);
 | 
	
		
			
				|  |  | -                    if(cghtinfo == null) {
 | 
	
		
			
				|  |  | -                    	cghtinfo = new HashSet<>();
 | 
	
		
			
				|  |  | -                    	cghtinfo.add(billno);
 | 
	
		
			
				|  |  | -                    	xsht2cght.put(xshtbillno, cghtinfo);
 | 
	
		
			
				|  |  | -                    }else {
 | 
	
		
			
				|  |  | -                    	cghtinfo.add(billno);
 | 
	
		
			
				|  |  | +            if(!cghtbillnos.isEmpty()) {
 | 
	
		
			
				|  |  | +            	QFilter qcghtbg = new QFilter("billstatus", QCP.equals, "C");
 | 
	
		
			
				|  |  | +            	qcghtbg.and("billno", QCP.in, cghtbillnos);
 | 
	
		
			
				|  |  | +            	qcghtbg.and("nckd_combofield",QCP.equals,"A");
 | 
	
		
			
				|  |  | +                DynamicObjectCollection cghtbgs = QueryServiceHelper.query("conm_xpurcontract","id,billno,nckd_refbillfield", qcghtbg.toArray(), "");
 | 
	
		
			
				|  |  | +                if(!cghtbgs.isEmpty()){
 | 
	
		
			
				|  |  | +                    for (DynamicObject cghtbg : cghtbgs) {
 | 
	
		
			
				|  |  | +                        String billno = cghtbg.getString("billno");//采购合同编号
 | 
	
		
			
				|  |  | +                        cghtbillnos.remove(billno);
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -            
 | 
	
		
			
				|  |  | -            if(!xsht2cght.isEmpty()) {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            if(!cghtbillnos.isEmpty()) {
 | 
	
		
			
				|  |  |              	StringBuffer bf = new StringBuffer();
 | 
	
		
			
				|  |  | +            	for(String cghtbillno : cghtbillnos) {
 | 
	
		
			
				|  |  | +            		String xshtbillno = xsht2cghtbillno.get(cghtbillno);
 | 
	
		
			
				|  |  | +            		Set<String> cgs = xsht2cght.get(xshtbillno);
 | 
	
		
			
				|  |  | +            		if(cgs == null) {
 | 
	
		
			
				|  |  | +            			cgs = new HashSet<>();
 | 
	
		
			
				|  |  | +            			cgs.add(cghtbillno);
 | 
	
		
			
				|  |  | +            			xsht2cght.put(xshtbillno, cgs);
 | 
	
		
			
				|  |  | +            		}else {
 | 
	
		
			
				|  |  | +            			cgs.add(cghtbillno);
 | 
	
		
			
				|  |  | +            		}
 | 
	
		
			
				|  |  | +            	}
 | 
	
		
			
				|  |  | +            	
 | 
	
		
			
				|  |  |              	for(String xsht : xsht2cght.keySet()) {
 | 
	
		
			
				|  |  |              		Set<String> cght = xsht2cght.get(xsht);
 | 
	
		
			
				|  |  |              		String tm = "以下采购合同(来源于销售合同:" + xsht + ")未进行价格审定";
 | 
	
	
		
			
				|  | @@ -75,7 +94,10 @@ public class PurContractHaveNotJGSDTask extends AbstractTask {
 | 
	
		
			
				|  |  |              		bf.append(cght.toString());
 | 
	
		
			
				|  |  |              		bf.append(System.lineSeparator());
 | 
	
		
			
				|  |  |              	}
 | 
	
		
			
				|  |  | -            	this.buildBGYJD(bf.toString());
 | 
	
		
			
				|  |  | +            	
 | 
	
		
			
				|  |  | +            	if(StringUtils.isNotBlank(bf.toString())) {
 | 
	
		
			
				|  |  | +            		this.buildBGYJD(bf.toString());
 | 
	
		
			
				|  |  | +            	}
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 |