diff --git a/weaver/aiyh_pcn/workflow_to_customer/AddCustomer_Action.java b/weaver/aiyh_pcn/workflow_to_customer/AddCustomer_Action.java index 90617bf..c71bba8 100644 --- a/weaver/aiyh_pcn/workflow_to_customer/AddCustomer_Action.java +++ b/weaver/aiyh_pcn/workflow_to_customer/AddCustomer_Action.java @@ -3,6 +3,7 @@ package weaver.aiyh_pcn.workflow_to_customer; import aiyh.utils.zwl.common.ToolUtil; import com.engine.crm.util.CrmCommonUtil; +import com.engine.crm.util.CrmRemindUtil; import org.h2.util.StringUtils; import weaver.aiyh_pcn.workflow_to_customer.config.CRM_Config; import weaver.aiyh_pcn.workflow_to_customer.exception.DataExistsException; @@ -124,6 +125,13 @@ public class AddCustomer_Action extends ToolUtil implements Action { } + /** + * 更新客户 + * + * @param mainResult + * @param configInfoMap + * @param customerId + */ public void updateCustomerModel(MainResult mainResult, Map>> configInfoMap, String customerId) { // 1、更新客户基本信息crm_customerinfo if (Utils.conformSql(configInfoMap, "CRM_CustomerInfo")) { @@ -172,6 +180,12 @@ public class AddCustomer_Action extends ToolUtil implements Action { } } + /** + * 更新客户基本信息 + * + * @param mapList + * @param customerId + */ public void updateCustomerInfo(List> mapList, String customerId) { RecordSet rs = new RecordSet(); // 查询客户表,是否存在该客户,如果存在则对客户信息进行修改,如果不存在则跳过 @@ -183,6 +197,12 @@ public class AddCustomer_Action extends ToolUtil implements Action { } } + /** + * 更新客户基本信息 + * + * @param map + * @param customerId + */ public void updateCustomerInfo(Map map, String customerId) { map.put("lastupdateddate", Utils.getTime("yyyy-MM-dd")); map.put("lastupdatedtime", Utils.getTime("HH:mm:ss")); @@ -192,6 +212,12 @@ public class AddCustomer_Action extends ToolUtil implements Action { .create()); } + /** + * 更新客户联系人 + * + * @param mapList + * @param customerId + */ public void updateCustomerContacter(List> mapList, String customerId) { // 存在BUG,如果批量修改则会出现所有联系人都会被修改为同一个 RecordSet rs = new RecordSet(); @@ -218,6 +244,12 @@ public class AddCustomer_Action extends ToolUtil implements Action { } } + /** + * 更新客户联系人 + * + * @param map + * @param contacter + */ public void updateCustomerContacter(Map map, String contacter) { map.put("lastupdateddate", Utils.getTime("yyyy-MM-dd")); map.put("lastupdatedtime", Utils.getTime("HH:mm:ss")); @@ -227,6 +259,12 @@ public class AddCustomer_Action extends ToolUtil implements Action { .create()); } + /** + * 更新客户联系地址 + * + * @param mapList + * @param customerId + */ public void updateCustomerAddress(List> mapList, String customerId) { // 存在BUG,如果批量修改则会出现所有联系人都会被修改为同一个 RecordSet rs = new RecordSet(); @@ -245,6 +283,12 @@ public class AddCustomer_Action extends ToolUtil implements Action { } } + /** + * 更新客户商机 + * + * @param mapList + * @param customerId + */ public void updateCustomerSellChance(List> mapList, String customerId) { // 存在BUG,如果批量修改则会出现所有联系人都会被修改为同一个 RecordSet rs = new RecordSet(); @@ -263,6 +307,12 @@ public class AddCustomer_Action extends ToolUtil implements Action { } } + /** + * 更新人员虚拟分部信息 + * + * @param mapList + * @param customerId + */ public void updateHrmsubcompanyvirtual(List> mapList, String customerId) { // 存在BUG,如果批量修改则会出现所有联系人都会被修改为同一个 RecordSet rs = new RecordSet(); @@ -284,6 +334,12 @@ public class AddCustomer_Action extends ToolUtil implements Action { } } + /** + * 更新人员虚拟部门信息 + * + * @param mapList + * @param customerId + */ public void updateHrmdepartmentvirtual(List> mapList, String customerId) { // 存在BUG,如果批量修改则会出现所有联系人都会被修改为同一个 RecordSet rs = new RecordSet(); @@ -338,7 +394,7 @@ public class AddCustomer_Action extends ToolUtil implements Action { // TODO 将客户联系信息插入到客户联系表中 this.insertCustomerSellChance(configInfoMap.get("CRM_SellChance"), customer); } -// 5、判断插入虚拟分部信息hrmsubcompanyvirtual +/*// 5、判断插入虚拟分部信息hrmsubcompanyvirtual if (Utils.conformSql(configInfoMap, "hrmsubcompanyvirtual") || this.mainResult.getIsOutUser() == 0) { // TODO 将客户信息插入到虚拟分部信息表中 @@ -353,7 +409,7 @@ public class AddCustomer_Action extends ToolUtil implements Action { this.deprtId = this.insertHrmdepartmentvirtual(configInfoMap.get("hrmdepartmentvirtual"), customer, subId); } else { return; - } + }*/ // 7、判断插入外部人员信息hrmresource if (Utils.conformSql(configInfoMap, "hrmResource") || this.mainResult.getIsOutUser() == 0) { // TODO 将客户插入到外部人员信息表中 @@ -370,7 +426,6 @@ public class AddCustomer_Action extends ToolUtil implements Action { } int finalHrmvId = hrmvId; int finalHrmvId1 = hrmvId; - CustomerInfoComInfo comInfo = new CustomerInfoComInfo(); String queryCompanyId = "select id from HrmCompanyVirtual where companyname like '%客户维度%'"; rs.executeQuery(queryCompanyId); rs.next(); @@ -405,12 +460,12 @@ public class AddCustomer_Action extends ToolUtil implements Action { RecordSet rs = new RecordSet(); String hrmid; // 获取人员id - rs.executeProc("HrmResourceMaxId_Get", ""); - rs.next(); - hrmid = rs.getString(1); +// rs.executeProc("HrmResourceMaxId_Get", ""); +// rs.next(); +// hrmid = rs.getString(1); // 整理数据 item.put("createdate", Utils.getTime("yyyy-MM-dd")); - item.put("id", hrmid); +// item.put("id", hrmid); item.put("createrid", this.request.getRequestManager().getCreater()); if (!item.containsKey("lastname")) { item.put("lastname", customer.get("name")); @@ -419,10 +474,10 @@ public class AddCustomer_Action extends ToolUtil implements Action { item.put("loginid", crmCommonUtil.getPinYin((String) customer.get("name"), 7).get("pinyin")); } if (item.containsKey("seclevel") && Integer.parseInt((String) item.get("seclevel")) > 0) { - item.put("seclevel", -1); + item.put("seclevel", -10); } if (!item.containsKey("seclevel")) { - item.put("seclevel", -1); + item.put("seclevel", -10); } if (!item.containsKey("password")) { item.put("password", Util.getEncrypt((String) crmCommonUtil.getPinYin((String) customer.get("name"), 7).get("pinyin"))); @@ -442,11 +497,11 @@ public class AddCustomer_Action extends ToolUtil implements Action { } if (!item.containsKey("departmentid")) { // customerInfo.getCustomerInfoSubcompanyid(String.valueOf(customer.get("customerId"))) - item.put("departmentid", 0); + item.put("departmentid", deprtId); } if (!item.containsKey("subcompanyid1")) { // customerInfo.getCustomerInfoDepartmentid(String.valueOf(customer.get("customerId"))) - item.put("subcompanyid1", 0); + item.put("subcompanyid1", subId); } if (!item.containsKey("status")) { item.put("status", 1); @@ -455,7 +510,7 @@ public class AddCustomer_Action extends ToolUtil implements Action { item.put("accounttype", 0); } if (!item.containsKey("dsporder")) { - item.put("dsporder", hrmid); +// item.put("dsporder", hrmid); } item.put("ecology_pinyin_search", crmCommonUtil.getPinYin((String) customer.get("name"), 7)); // 查询loginid是否已经存在 @@ -465,10 +520,32 @@ public class AddCustomer_Action extends ToolUtil implements Action { // 存在登录名 throw new LoginIdRepeatException("loginid is repeat,Please re-enter logind!"); } - this.insertHandle("hrmresource", item); + HrmOutInterface hrmOutInterface = new HrmOutInterface(); + Map param = new HashMap<>(); + param.put("crmid", Util.null2String(customer.get("customerId"))); + param.put("lastname", Util.null2String(item.get("lastname"))); + param.put("loginid", Util.null2String(item.get("loginid"))); + param.put("password", Util.null2String(item.get("password"))); + param.put("seclevel", Util.null2String(item.get("seclevel"))); + param.put("mobile", Util.null2String(item.get("mobile"))); + param.put("email", Util.null2String(item.get("email"))); + param.put("isoutmanager", Util.null2s(Util.null2String(item.get("isoutmanager")),"0")); + param.put("wxname", Util.null2String(item.get("wxname"))); + param.put("wxopenid", Util.null2String(item.get("wxopenid"))); + param.put("wxuuid", Util.null2String(item.get("wxuuid"))); + param.put("country", Util.null2String(item.get("country"))); + param.put("province", Util.null2String(item.get("province"))); + param.put("city", Util.null2String(item.get("city"))); + param.put("customfrom", Util.null2String(item.get("customfrom"))); + Map returnObj = hrmOutInterface.createResource4Card(param); + String resourceid = returnObj.get("resourceid"); + String sql = "INSERT INTO CRM_ShareInfo (relateditemid, sharetype, seclevel, sharelevel, crmid, contents, deleted, seclevelMax, jobtitleid, joblevel, scopeid) VALUES (?, '1', '10','1','0',?, '0', '100', ?, '0', ',0,')"; + rs.executeUpdate(sql, customer.get("customerId"), resourceid, resourceid); + +// this.insertHandle("hrmresource", item); if (this.mainResult.getManagerType() == 3) { // 将外部客户的客户经理更新为当前插入的外部用户,方便外部用户参与流程审批 - this.updateHandle("CRM_CustomerInfo", Utils.createMap().uPut("manager", hrmid) + this.updateHandle("CRM_CustomerInfo", Utils.createMap().uPut("manager", resourceid) .uPut("lastupdatedtime", Utils.getTime("HH:mm:ss")) .uPut("lastupdatedtime", Utils.getTime("HH:mm:ss")), PrepSQLWhere.creatPrepWhere() @@ -476,7 +553,6 @@ public class AddCustomer_Action extends ToolUtil implements Action { .create()); } - HrmOutInterface hrmOutInterface = new HrmOutInterface(); CustomerInfoComInfo customerInfo = new CustomerInfoComInfo(); customerInfo.removeCustomerInfoCache(); customerInfo.removeCache(); @@ -485,8 +561,10 @@ public class AddCustomer_Action extends ToolUtil implements Action { (new CustomerSizeComInfo()).removeCache(); (new CustomerStatusComInfo()).removeCache(); customerInfo.addCustomerInfoCache(String.valueOf(customer.get("customerId"))); + CrmRemindUtil crmRemindUtil = new CrmRemindUtil(request.getRequestManager().getUser()); + crmRemindUtil.outResourceAddRemind(Integer.parseInt(resourceid)); // 应该是 - hrmOutInterface.initMatrixDataOutManager(subId, hrmid); +// hrmOutInterface.initMatrixDataOutManager(subId, hrmid); ResourceComInfo resourceComInfo = null; try { @@ -498,26 +576,26 @@ public class AddCustomer_Action extends ToolUtil implements Action { resourceComInfo.removeResourceCache(); resourceComInfo.removeCache(); } - this.insertHrmresourceVirtual(customer, hrmid, subId, deparId); - Map map = new HashMap() {{ - put("relateditemid", Util.null2String(customer.get("customerId"))); - put("sharetype", "1"); - put("seclevel", "10"); - put("sharelevel", "1"); - put("crmid", "0"); - put("contents", hrmid); - put("deleted", "0"); - put("seclevelMax", "100"); - put("jobtitleid", hrmid); - put("joblevel", "0"); - put("scopeid", "0"); - }}; - this.insertHandle("CRM_ShareInfo", map); +// this.insertHrmresourceVirtual(customer, hrmid, subId, deparId); +// Map map = new HashMap() {{ +// put("relateditemid", Util.null2String(customer.get("customerId"))); +// put("sharetype", "1"); +// put("seclevel", "10"); +// put("sharelevel", "1"); +// put("crmid", "0"); +// put("contents", hrmid); +// put("deleted", "0"); +// put("seclevelMax", "100"); +// put("jobtitleid", hrmid); +// put("joblevel", "0"); +// put("scopeid", "0"); +// }}; +// this.insertHandle("CRM_ShareInfo", map); }); } public String insertHrmdepartmentvirtual(List> mapList, Map customer, String subId) { - if (Objects.isNull(mapList) || mapList.size() == 0) { + if (Objects.isNull(mapList) || mapList.isEmpty()) { mapList = new ArrayList<>(); mapList.add(new HashMap<>()); } @@ -567,7 +645,7 @@ public class AddCustomer_Action extends ToolUtil implements Action { } public String insertHrmsubcompanyvirtual(List> mapList, Map customer) { - if (Objects.isNull(mapList) || mapList.size() == 0) { + if (Objects.isNull(mapList) || mapList.isEmpty()) { mapList = new ArrayList<>(); mapList.add(new HashMap<>()); } @@ -816,7 +894,7 @@ public class AddCustomer_Action extends ToolUtil implements Action { item.put("lastupdatedby", this.request.getRequestManager().getCreater()); } if (!item.containsKey("status")) { - item.put("status", 1); + item.put("status", 2); } if (!item.containsKey("language")) { item.put("language", 7); @@ -894,6 +972,7 @@ public class AddCustomer_Action extends ToolUtil implements Action { // TODO 插入客户基本信息 this.insertHandle("CRM_CustomerInfo", mapList); CustomerInfoComInfo customerInfo = new CustomerInfoComInfo(); + customerInfo.removeCustomerInfoCache(); customerInfo.removeCache(); String queryIdSql = "select max(id) from CRM_CustomerInfo where name= ? and manager = ?"; @@ -901,6 +980,7 @@ public class AddCustomer_Action extends ToolUtil implements Action { rs.executeQuery(queryIdSql, cusMap.get("name"), managerId); if (rs.next()) { customerId = rs.getString(1); + customerInfo.addCustomerInfoCache(customerId); if (!"".equals(customerId)) { CustomerModifyLog customerModifyLog = new CustomerModifyLog(); customerModifyLog.modify(customerId, String.valueOf(this.request.getRequestManager().getCreater()), managerId); @@ -937,7 +1017,6 @@ public class AddCustomer_Action extends ToolUtil implements Action { cusMap.put("customerId", customerId); this.customerID = customerId; // @debug -// cusMap.put("customerId", 1); return cusMap; } @@ -958,8 +1037,6 @@ public class AddCustomer_Action extends ToolUtil implements Action { SqlResult sqlResult = BuilderSqlUtil.builderInsertSql(tableName, map); if (!Objects.isNull(sqlResult)) { // TODO 插入数据库数据 -// Console.log(sqlResult.getSqlStr()); -// Console.log(Arrays.toString(sqlResult.getArgs()) + "\n"); this.writeDebuggerLog(sqlResult.getSqlStr()); this.writeDebuggerLog(Arrays.toString(sqlResult.getArgs()) + "\n"); rs.executeUpdate(sqlResult.getSqlStr(), sqlResult.getArgs());