youhua
This commit is contained in:
		
							parent
							
								
									963e5f0864
								
							
						
					
					
						commit
						1897d56193
					
				| 
						 | 
				
			
			@ -28,6 +28,8 @@ import java.time.format.DateTimeFormatter;
 | 
			
		|||
import java.time.format.DateTimeParseException;
 | 
			
		||||
import java.util.*;
 | 
			
		||||
 | 
			
		||||
import static com.icbc.api.internal.apache.http.h.d.ym;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 实物卡片同步设备定时任务
 | 
			
		||||
 */
 | 
			
		||||
| 
						 | 
				
			
			@ -84,6 +86,9 @@ public class EquipmentCardTaskPlugin extends AbstractTask {
 | 
			
		|||
            DynamicObject eceq_equipment_card = BusinessDataServiceHelper.loadSingle("eceq_equipment_card", new QFilter[]{new QFilter("zcgj_assetnumber", QCP.equals, number)});
 | 
			
		||||
            if (eceq_equipment_card!=null){
 | 
			
		||||
                equipmentcard.set("id",eceq_equipment_card.getLong("id"));
 | 
			
		||||
                equipmentcard.set("number",eceq_equipment_card.getString("number"));//设备编号
 | 
			
		||||
            }else{
 | 
			
		||||
                equipmentcard.set("number",getCodeRule(equipmentcard,"53BT+ZJB86=L"));//设备编号
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            equipmentcard.set("billno",timeText);//单据编号
 | 
			
		||||
| 
						 | 
				
			
			@ -91,7 +96,6 @@ public class EquipmentCardTaskPlugin extends AbstractTask {
 | 
			
		|||
            equipmentcard.set("billstatus","C");//
 | 
			
		||||
            equipmentcard.set("enable","1");//可用
 | 
			
		||||
            equipmentcard.set("property","OWN");//设备性质
 | 
			
		||||
            equipmentcard.set("number",getCodeRule(equipmentcard,"53BT+ZJB86=L"));//设备编号
 | 
			
		||||
            equipmentcard.set("name",assetname);//设备名称
 | 
			
		||||
            equipmentcard.set("modelnum",model);//规格型号
 | 
			
		||||
            equipmentcard.set("indate",realaccountdate);//入库日期
 | 
			
		||||
| 
						 | 
				
			
			@ -142,24 +146,22 @@ public class EquipmentCardTaskPlugin extends AbstractTask {
 | 
			
		|||
            }
 | 
			
		||||
            DynamicObject eceq_equipment = BusinessDataServiceHelper.loadSingle("eceq_equipinfo", new QFilter[]{new QFilter("number", QCP.equals, number)});
 | 
			
		||||
            if (eceq_equipment != null) {
 | 
			
		||||
                SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM"); //设置格式
 | 
			
		||||
                String ym = sd.format(date);
 | 
			
		||||
                DynamicObjectCollection entrys = eceq_equipment.getDynamicObjectCollection("zcgj_entryentity");
 | 
			
		||||
                QFilter qf = new QFilter("realcard.number", QCP.equals, number);
 | 
			
		||||
                if (entrys.size() > 0) {//若分录行数大于0 则取上月的
 | 
			
		||||
                    qf.and(new QFilter("billno", QCP.in, ym));
 | 
			
		||||
                    for (int i = 0; i < entrys.size(); i++) {
 | 
			
		||||
                        DynamicObject entry = entrys.get(i);
 | 
			
		||||
                        String zcgjDebillno = entry.getString("zcgj_debillno");
 | 
			
		||||
                        entrys.removeIf(record -> isLastMonth(zcgjDebillno));//若属于上个月那就删除重新塞入
 | 
			
		||||
                        long billnoid = entry.getLong("zcgj_debillno");
 | 
			
		||||
                        qf.and(new QFilter("id", QCP.not_equals, billnoid));
 | 
			
		||||
//                        entrys.removeIf(record -> isLastMonth(zcgjDebillno));//若属于上个月那就删除重新塞入
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
//                DynamicObjectCollection depresplitdetails = QueryServiceHelper.query("fa_depresplitdetail", "billno,period,splitdept,assentry.costcentrer,assentry.splitamount", new QFilter[]{qf});
 | 
			
		||||
                DynamicObjectCollection depresplitdetails = QueryServiceHelper.query("fa_depresplitdetail", "id,billno,period,splitdept,assentry.costcentrer,assentry.splitamount", new QFilter[]{qf});
 | 
			
		||||
 | 
			
		||||
//                DynamicObject[] depresplitdetails = BusinessDataServiceHelper.load("fa_depresplitdetail", "billno,period,splitdept,assentry.costcentrer,assentry.splitamount", new QFilter[]{qf});
 | 
			
		||||
                DataSet rows = QueryServiceHelper.queryDataSet(this.getClass().getName(), "fa_depresplitdetail", "id,billno,period,splitdept,assentry,assentry.costcentrer,assentry.splitamount",
 | 
			
		||||
                        new QFilter[]{new QFilter("realcard.number", QCP.equals, number)}, "period.number DESC");
 | 
			
		||||
                DynamicObjectCollection depresplitdetails = ORM.create().toPlainDynamicObjectCollection(rows.copy());
 | 
			
		||||
//                DataSet rows = QueryServiceHelper.queryDataSet(this.getClass().getName(), "fa_depresplitdetail", "id,billno,period,splitdept,assentry,assentry.costcentrer,assentry.splitamount",
 | 
			
		||||
//                        new QFilter[]{new QFilter("realcard.number", QCP.equals, number)}, "period.number DESC");
 | 
			
		||||
//                DynamicObjectCollection depresplitdetails = ORM.create().toPlainDynamicObjectCollection(rows.copy());
 | 
			
		||||
                //                // 增强版比较器(自动适配多种日期格式)
 | 
			
		||||
//                for (int i = 0; i < depresplitdetails.size(); i++) {
 | 
			
		||||
//                    DynamicObject item = depresplitdetails.get(i);
 | 
			
		||||
| 
						 | 
				
			
			@ -199,24 +201,28 @@ public class EquipmentCardTaskPlugin extends AbstractTask {
 | 
			
		|||
//                    DynamicObject item = depresplitdetails.get(i);
 | 
			
		||||
//                    log.info("排序前 " + i + ": " + item.getDynamicObject("period").getString("number"));
 | 
			
		||||
//                }
 | 
			
		||||
//                //按字段 menuindex 排序
 | 
			
		||||
//                Collections.sort(depresplitdetails , new Comparator<DynamicObject>(){
 | 
			
		||||
//                    @Override
 | 
			
		||||
//                    public int compare(DynamicObject stu1, DynamicObject stu2) {
 | 
			
		||||
//                        return stu1.getInt("menuindex")-stu2.getInt("menuindex");
 | 
			
		||||
//                    }
 | 
			
		||||
//                });
 | 
			
		||||
                //按字段 menuindex 排序
 | 
			
		||||
                Collections.sort(depresplitdetails , new Comparator<DynamicObject>(){
 | 
			
		||||
                    @Override
 | 
			
		||||
                    public int compare(DynamicObject o1, DynamicObject o2) {
 | 
			
		||||
                        long id1 = o1.getLong("id");
 | 
			
		||||
                        DynamicObject oo1 = BusinessDataServiceHelper.loadSingle("fa_depresplitdetail", new QFilter[]{new QFilter("id", QCP.equals, id1)});
 | 
			
		||||
                        long id2 = o2.getLong("id");
 | 
			
		||||
                        DynamicObject oo2 = BusinessDataServiceHelper.loadSingle("fa_depresplitdetail", new QFilter[]{new QFilter("id", QCP.equals, id2)});
 | 
			
		||||
                        return oo2.getDynamicObject("period").getString("number").compareTo(oo1.getDynamicObject("period").getString("number"));
 | 
			
		||||
                    }
 | 
			
		||||
                });
 | 
			
		||||
                for (DynamicObject depresplitdetail : depresplitdetails) {
 | 
			
		||||
                    long id = depresplitdetail.getLong("id");
 | 
			
		||||
                    DynamicObject loadSingle = BusinessDataServiceHelper.loadSingle("fa_depresplitdetail", new QFilter[]{new QFilter("id", QCP.equals, id)});
 | 
			
		||||
                    String billno = loadSingle.getString("billno");
 | 
			
		||||
//                    String billnoid = loadSingle.getString("billno");
 | 
			
		||||
                    DynamicObject period = loadSingle.getDynamicObject("period");//折旧区间
 | 
			
		||||
                    DynamicObject splitdept = loadSingle.getDynamicObject("splitdept");//使用部门
 | 
			
		||||
                    DynamicObjectCollection assentry = loadSingle.getDynamicObjectCollection("assentry");
 | 
			
		||||
                    DynamicObject costcentrer = assentry.get(0).getDynamicObject("costcentrer");//成本中心
 | 
			
		||||
                    BigDecimal splitamount = assentry.get(0).getBigDecimal("splitamount");//分摊金额
 | 
			
		||||
                    DynamicObject addNew = entrys.addNew();
 | 
			
		||||
                    addNew.set("zcgj_debillno", billno);
 | 
			
		||||
                    addNew.set("zcgj_debillno", id);
 | 
			
		||||
                    addNew.set("zcgj_assperiod", period);
 | 
			
		||||
                    addNew.set("zcgj_headusedept", splitdept);
 | 
			
		||||
                    addNew.set("zcgj_entrybillno", number);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue