Browse Source

定时任务优化

lyr 2 weeks ago
parent
commit
3ffb2266ec

+ 45 - 6
hr/hr/src/client/nc/ui/hr/plugin/HrLaborcostcopyPlugin.java

@@ -3,6 +3,7 @@ package nc.ui.hr.plugin;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
+import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 
@@ -10,7 +11,6 @@ import nc.bs.dao.BaseDAO;
 import nc.bs.framework.common.InvocationInfoProxy;
 import nc.bs.framework.common.NCLocator;
 import nc.bs.hr.plugin.GetDataUtil;
-import nc.bs.logging.Logger;
 import nc.bs.pub.pa.PreAlertObject;
 import nc.bs.pub.taskcenter.BgWorkingContext;
 import nc.bs.pub.taskcenter.IBackgroundWorkPlugin;
@@ -112,9 +112,13 @@ public class HrLaborcostcopyPlugin implements IBackgroundWorkPlugin {
 			}
 
 			List<Map<String, String>> listCostMap1 = null;
+			
+			List<Map<String, String>> listCostMap2 = null;
+			
 			if (date != null && !"null".equals(date)) {
 				try {
-					listCostMap1 = getLaborost1(date);// 人力成本备份数据
+					listCostMap2 = getLaborost1(date);// 人力成本备份数据
+					listCostMap1=getNewListCostMap(listCostMap2,mapsl,orgnamemap);
 				} catch (Exception e) {
 					e.getStackTrace();
 					
@@ -134,7 +138,7 @@ public class HrLaborcostcopyPlugin implements IBackgroundWorkPlugin {
 			List<String> orglist = new ArrayList<String>();
 			for (Map<String, String> map : listCostMap1) {
 				String wa_org = map.get("wa_org");
-				if (wa_org != null && !"null".equals(wa_org) && !wa_org.equals("0001A81000000017KY0F") && !wa_org.equals("0001A81000000069I9K9")) {
+				if (wa_org != null && !"null".equals(wa_org) ) {
 					if (!orglist.contains(wa_org))
 						orglist.add(wa_org);
 				}
@@ -148,7 +152,7 @@ public class HrLaborcostcopyPlugin implements IBackgroundWorkPlugin {
 				ReceivableBillVO receivableBillVO = new ReceivableBillVO();
 				// 赋值主表数据
 				String pk_org = waorg;
-				receivableBillVO.setDef11("人力成本备份薪资发放公司#" + pk_org + "#" + date2);
+				receivableBillVO.setDef11("人力成本备份薪资发放公司+#" + pk_org + "#" + date2);
 				String pk_org_v = getPkorgv(pk_org);
 				receivableBillVO.setPk_group(pk_group);
 				receivableBillVO.setPk_org(pk_org);// 应收财务组织
@@ -240,7 +244,7 @@ public class HrLaborcostcopyPlugin implements IBackgroundWorkPlugin {
 						receivableBillItemVO.setDef26(GetDataUtil.getDefdocPK("S00009", "08", "代垫费用"));// 收款摘要:S00009代垫费用
 						receivableBillItemVO.setDef29(GetDataUtil.getDefdocPKByName("YS001", "人工成本结算--" + wa_typeMemoMap.get(wa_type)));// 收款业务性质:人工成本结算
 						receivableBillItemVO.setDef15(GetDataUtil.getDefdocPK("其他合同(财务专用)", "01", "其他合同(财务专用)"));// 经营合同名称
-						receivableBillItemVO.setDef16("其他合同(财务专用)");// 合同编号-----
+						receivableBillItemVO.setDef16("其他合同(财务专用)");// 合同编号
 						receivableBillItemVO.setDef10(year + month + "人力成本备份" + workercode + name);// 备注
 						receivableBillItemVO.setCustomer(getCustomerPKByName(cost_orgname));// 客户
 //						receivableBillItemVO.setOrdercubasdoc(getCustomerPKByName(cost_orgname));// 订单客户
@@ -624,7 +628,7 @@ public class HrLaborcostcopyPlugin implements IBackgroundWorkPlugin {
 		for (int i = 0; i < listMap.size(); i++) {
 			orgList = new ArrayList<String>();
 			Map<String, String> codeMap = listMap.get(i);
-			String name = codeMap.get("name");
+			String name = codeMap.get("name");//成本归属公司
 			String memo = codeMap.get("memo");
 			String[] smemo = memo.split(",");
 			for (String org : smemo) {
@@ -674,5 +678,40 @@ public class HrLaborcostcopyPlugin implements IBackgroundWorkPlugin {
 		}
 		return pk_customer;
 	}
+	
+	/**
+	 * 排除薪资发放公司与成本归属公司相同、排除TH03对应关系的公司数据
+	 * @param listCostMap
+	 * @param maps
+	 * @param orgnamemap
+	 * @return
+	 */
+	private List<Map<String, String>> getNewListCostMap(List<Map<String, String>> listCostMap,Map<String, List<String>> maps,Map<String, String> orgnamemap){
+		List<Map<String, String>> listCostMapNew=new LinkedList<Map<String, String>>();
+		for(Map<String, String> map :listCostMap){
+			String wa_org = map.get("wa_org");
+			String cost_org = map.get("cost_org");
+			String cost_orgname = orgnamemap.get(cost_org);
+			String wa_orgname = orgnamemap.get(wa_org);
+			boolean flag=true;
+			if(wa_orgname.equals(cost_orgname)){
+				flag=false;
+			}else{
+				if (maps != null && maps.size() > 0) {
+					List<String> orgNameList = maps.get(cost_orgname);
+					if (orgNameList != null && orgNameList.size() > 0) {
+						if (orgNameList.contains(wa_orgname)) {
+							flag=false;
+						}
+					}
+				}
+			}
+			if(flag){
+				listCostMapNew.add(map);
+			}
+		}
+		return listCostMapNew;
+		
+	}
 
 }

+ 68 - 23
hr/hr/src/client/nc/ui/hr/plugin/HrLaborcostcopycbPlugin.java

@@ -3,6 +3,7 @@ package nc.ui.hr.plugin;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
+import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 
@@ -11,7 +12,6 @@ import nc.bs.dao.BaseDAO;
 import nc.bs.framework.common.InvocationInfoProxy;
 import nc.bs.framework.common.NCLocator;
 import nc.bs.hr.plugin.GetDataUtil;
-import nc.bs.logging.Logger;
 import nc.bs.pub.pa.PreAlertObject;
 import nc.bs.pub.taskcenter.BgWorkingContext;
 import nc.bs.pub.taskcenter.IBackgroundWorkPlugin;
@@ -35,6 +35,7 @@ import nc.vo.pubapp.pattern.exception.ExceptionUtils;
 import nc.vo.pubapp.pflow.PfUserObject;
 
 public class HrLaborcostcopycbPlugin implements IBackgroundWorkPlugin{
+
 	static BaseDAO baseDao;
 
 	public static BaseDAO getBaseDAO() {
@@ -111,11 +112,16 @@ public class HrLaborcostcopycbPlugin implements IBackgroundWorkPlugin{
 			}
 
 			List<Map<String, String>> listCostMap1 = null;
+			
+			List<Map<String, String>> listCostMap2 = null;
+			
 			if (date != null && !"null".equals(date)) {
 				try {
-					listCostMap1 = getLaborost1(date);// 人力成本备份数据
+					listCostMap2 = getLaborost1(date);// 人力成本备份数据
+					listCostMap1=getNewListCostMap(listCostMap2,mapsl,orgnamemap);
 				} catch (Exception e) {
 					e.getStackTrace();
+					
 					NcLog.info("手工传日期查询人力成本备份数据异常" + e.getMessage());
 					ExceptionUtils.wrappBusinessException(e.getMessage());
 				}
@@ -131,23 +137,22 @@ public class HrLaborcostcopycbPlugin implements IBackgroundWorkPlugin{
 
 			List<String> orglist = new ArrayList<String>();
 			for (Map<String, String> map : listCostMap1) {
-				String cost_org = map.get("cost_org");
-				//if (cost_org != null && !"null".equals(cost_org) && !cost_org.equals("0001A81000000017KY0F") && !cost_org.equals("0001A81000000069I9K9")) {
-				if (cost_org != null && !"null".equals(cost_org)) {
-					if (!orglist.contains(cost_org))
-						orglist.add(cost_org);
+				String wa_org = map.get("wa_org");
+				if (wa_org != null && !"null".equals(wa_org) ) {
+					if (!orglist.contains(wa_org))
+						orglist.add(wa_org);
 				}
 			}
 
 			for (int j = 0; j < orglist.size(); j++) {
 				try {
-				String costorg = orglist.get(j);
+				String waorg = orglist.get(j);
 				UFDouble debitamounttotal = new UFDouble();
 				AggReceivableBillVO aggReceivableBillVO = new AggReceivableBillVO();
 				ReceivableBillVO receivableBillVO = new ReceivableBillVO();
 				// 赋值主表数据
-				String pk_org = costorg;
-				receivableBillVO.setDef11("人力成本备份成本归属公司#" + pk_org + "#" + date2);
+				String pk_org = waorg;
+				receivableBillVO.setDef11("人力成本备份薪资发放公司-#" + pk_org + "#" + date2);
 				String pk_org_v = getPkorgv(pk_org);
 				receivableBillVO.setPk_group(pk_group);
 				receivableBillVO.setPk_org(pk_org);// 应收财务组织
@@ -187,7 +192,7 @@ public class HrLaborcostcopycbPlugin implements IBackgroundWorkPlugin{
 				receivableBillVO.setIsreded(UFBoolean.FALSE);// 是否红冲过
 
 				List<ReceivableBillItemVO> listItemVO = new ArrayList<ReceivableBillItemVO>();
-				String pk_supplier = pk_suppliermap.get(orgnamemap.get(costorg));// 供应商主键
+				String pk_supplier = pk_suppliermap.get(orgnamemap.get(waorg));// 供应商主键
 				if (pk_supplier == null) {
 					pk_supplier = pk_suppliermap.get("上海天华建筑设计有限公司");
 				}
@@ -217,9 +222,9 @@ public class HrLaborcostcopycbPlugin implements IBackgroundWorkPlugin{
 					String cost_orgname = orgnamemap.get(cost_org);
 					String wa_orgname = orgnamemap.get(wa_org);
 					if (mapsl != null && mapsl.size() > 0) {
-						List<String> orgNameList = mapsl.get(wa_orgname);
+						List<String> orgNameList = mapsl.get(cost_orgname);
 						if (orgNameList != null && orgNameList.size() > 0) {
-							if (orgNameList.contains(cost_orgname)) {
+							if (orgNameList.contains(wa_orgname)) {
 								islssued = "否";
 							}
 						}
@@ -227,9 +232,10 @@ public class HrLaborcostcopycbPlugin implements IBackgroundWorkPlugin{
 					Object decimalmny = map.get("decimalmny");
 					UFDouble total = new UFDouble(decimalmny.toString());
 					Double dtotal = -total.toDouble();
+					debitamounttotal = debitamounttotal.add(dtotal);
+					
 					UFDouble fstotal = new UFDouble(dtotal);
-					debitamounttotal = debitamounttotal.add(fstotal);
-					if (costorg.equals(cost_org)) {
+					if (waorg.equals(wa_org)) {
 						// 赋值子表数据
 						receivableBillItemVO.setPk_org(pk_org);
 						receivableBillItemVO.setPk_org_v(pk_org_v);
@@ -239,9 +245,9 @@ public class HrLaborcostcopycbPlugin implements IBackgroundWorkPlugin{
 						receivableBillItemVO.setDef26(GetDataUtil.getDefdocPK("S00009", "08", "代垫费用"));// 收款摘要:S00009代垫费用
 						receivableBillItemVO.setDef29(GetDataUtil.getDefdocPKByName("YS001", "人工成本结算--" + wa_typeMemoMap.get(wa_type)));// 收款业务性质:人工成本结算
 						receivableBillItemVO.setDef15(GetDataUtil.getDefdocPK("其他合同(财务专用)", "01", "其他合同(财务专用)"));// 经营合同名称
-						receivableBillItemVO.setDef16("其他合同(财务专用)");// 合同编号-----
-						receivableBillItemVO.setDef10(year + month + "人力成本备份cb" + workercode + name);// 备注
-						receivableBillItemVO.setCustomer(getCustomerPKByName(wa_orgname));// 客户
+						receivableBillItemVO.setDef16("其他合同(财务专用)");// 合同编号
+						receivableBillItemVO.setDef10(year + month + "人力成本备份" + workercode + name);// 备注
+						receivableBillItemVO.setCustomer(getCustomerPKByName(cost_orgname));// 客户
 //						receivableBillItemVO.setOrdercubasdoc(getCustomerPKByName(cost_orgname));// 订单客户
 						receivableBillItemVO.setTaxcodeid(GetDataUtil.getTaxcodePK("10"));// 税码
 						receivableBillItemVO.setTaxrate(new UFDouble(0));// 税率
@@ -272,8 +278,13 @@ public class HrLaborcostcopycbPlugin implements IBackgroundWorkPlugin{
 						receivableBillItemVO.setBuysellflag(1);// 购销类型:1国内销售
 //						receivableBillItemVO.setProject("PM201601130001");// 项目:其他
 						receivableBillItemVO.setPk_billtype("F0");// 单据类型编码
-						receivableBillItemVO.setPk_deptid(pk_deptMap.get(cost_org));// 部门
-						receivableBillItemVO.setPk_deptid_v(pk_deptMap.get(cost_org));// 部门
+						if ("是".equals(islssued)) {
+							receivableBillItemVO.setPk_deptid(pk_deptMap.get(wa_org));// 部门
+							receivableBillItemVO.setPk_deptid_v(pk_deptMap.get(wa_org));// 部门
+						} else {
+							receivableBillItemVO.setPk_deptid(cost_dept);// 部门
+							receivableBillItemVO.setPk_deptid_v(cost_dept);// 部门
+						}
 						receivableBillItemVO.setPk_tradetype(pk_tradetype);// 应收类型code:内部应收单(含代垫费用)
 						receivableBillItemVO.setPk_tradetypeid(pk_billtypeid);// 应收类型id
 						receivableBillItemVO.setQuantity_bal(new UFDouble(1));// 数量余额
@@ -285,7 +296,7 @@ public class HrLaborcostcopycbPlugin implements IBackgroundWorkPlugin{
 						receivableBillItemVO.setSett_org_v(pk_org);// 结算财务组织版本
 						receivableBillItemVO.setTriatradeflag(UFBoolean.FALSE);// 三角贸易区
 						receivableBillItemVO.setSettlecurr(pk_currtype);// 收款币种
-						receivableBillItemVO.setSettlemoney(total);// 收款金额
+						receivableBillItemVO.setSettlemoney(fstotal);// 收款金额
 						listItemVO.add(receivableBillItemVO);
 						m++;
 					}
@@ -618,7 +629,7 @@ public class HrLaborcostcopycbPlugin implements IBackgroundWorkPlugin{
 		for (int i = 0; i < listMap.size(); i++) {
 			orgList = new ArrayList<String>();
 			Map<String, String> codeMap = listMap.get(i);
-			String name = codeMap.get("name");
+			String name = codeMap.get("name");//成本归属公司
 			String memo = codeMap.get("memo");
 			String[] smemo = memo.split(",");
 			for (String org : smemo) {
@@ -669,5 +680,39 @@ public class HrLaborcostcopycbPlugin implements IBackgroundWorkPlugin{
 		return pk_customer;
 	}
 	
+	/**
+	 * 排除薪资发放公司与成本归属公司相同、排除TH03对应关系的公司数据
+	 * @param listCostMap
+	 * @param maps
+	 * @param orgnamemap
+	 * @return
+	 */
+	private List<Map<String, String>> getNewListCostMap(List<Map<String, String>> listCostMap,Map<String, List<String>> maps,Map<String, String> orgnamemap){
+		List<Map<String, String>> listCostMapNew=new LinkedList<Map<String, String>>();
+		for(Map<String, String> map :listCostMap){
+			String wa_org = map.get("wa_org");
+			String cost_org = map.get("cost_org");
+			String cost_orgname = orgnamemap.get(cost_org);
+			String wa_orgname = orgnamemap.get(wa_org);
+			boolean flag=true;
+			if(wa_orgname.equals(cost_orgname)){
+				flag=false;
+			}else{
+				if (maps != null && maps.size() > 0) {
+					List<String> orgNameList = maps.get(cost_orgname);
+					if (orgNameList != null && orgNameList.size() > 0) {
+						if (orgNameList.contains(wa_orgname)) {
+							flag=false;
+						}
+					}
+				}
+			}
+			if(flag){
+				listCostMapNew.add(map);
+			}
+		}
+		return listCostMapNew;
+		
+	}
 
-}
+}