package com.engine.recruit.service.impl; import com.alibaba.fastjson.JSON; import com.api.browser.bean.SearchConditionGroup; import com.api.browser.bean.SearchConditionItem; import com.engine.core.impl.Service; import com.engine.recruit.exception.CustomizeRunTimeException; import com.engine.recruit.service.RecruitPositionService; import com.engine.recruit.util.RecruitFormItemUtil; import com.weaver.rpa.sdk.clients.application.resume.ERPAResumeSDKClient; import com.weaver.rpa.sdk.clients.application.resume.entity.ResumeJobDynamicField; import com.weaver.rpa.sdk.clients.core.ERPASDKClients; import org.apache.commons.lang3.StringUtils; import weaver.conn.RecordSet; import weaver.general.Util; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; /** * @author:dxfeng * @createTime: 2023/10/09 * @version: 1.0 */ public class RecruitPositionServiceImpl extends Service implements RecruitPositionService { @Override public Map updatePostInfo(Map param) { Map returnMap = new HashMap<>(); String zpzwfzr = Util.null2String(param.get("zpzwfzr")); String zpxzr = Util.null2String(param.get("zpxzr")); String ids = Util.null2String(param.get("ids")); if (StringUtils.isBlank(ids)) { throw new CustomizeRunTimeException("数据有误,请重试"); } RecordSet rs = new RecordSet(); if (StringUtils.isNotBlank(zpzwfzr)) { rs.executeUpdate(" update uf_jcl_zp_zpzw set zpzwfzr = ? where id in (" + ids + ")", zpzwfzr); } if (StringUtils.isNotBlank(zpxzr)) { rs.executeUpdate(" update uf_jcl_zp_zpzw set zpxzr = ? where id in (" + ids + ")", zpxzr); } return returnMap; } @Override public Map getFormCondition(Map param) { Map apidatas = new HashMap<>(); apidatas.put("hasRight", true); String conditionType = Util.null2String(param.get("conditionType")); String selectValue = Util.null2String(param.get("selectValue")); ERPAResumeSDKClient client = ERPASDKClients.getResumeSDKClient(); ResumeJobDynamicField resumeJobDynamicField = client.getResumeJobDynamicField(); // 获取职位类别表单 if ("positionType".equals(conditionType)) { String dsfqd = Util.null2String(param.get("dsfqd")); getPositionTypeForm(dsfqd, selectValue, apidatas, resumeJobDynamicField); } // 前程无忧-发布城市 if ("job51City".equals(conditionType)) { getJob51CityForm(selectValue, apidatas, resumeJobDynamicField); } return apidatas; } /** * 获取职位类别表单 * * @param selectValue * @param apidatas * @param resumeJobDynamicField */ private void getPositionTypeForm(String dsfqd, String selectValue, Map apidatas, ResumeJobDynamicField resumeJobDynamicField) { String[] split = selectValue.split("#"); Map selectValueMap = new HashMap<>(); for (String s : split) { String[] split1 = s.split(":"); if (split1.length == 2) { selectValueMap.put(split1[0], split1[1]); } } //输入框类 List inputItems = new ArrayList<>(); List addGroups = new ArrayList<>(); if (dsfqd.contains("0")) { List boss_type = (List) resumeJobDynamicField.getBoss_type(); String bossType = convertPositionType(boss_type, selectValueMap.get("BOSS直聘")); SearchConditionItem bossItem = RecruitFormItemUtil.cascaderItem(user, 1, 18, 3, "BOSS直聘", "boss"); bossItem.setRules("required"); bossItem.setViewAttr(3); bossItem.setCompDef(JSON.parseObject(bossType)); inputItems.add(bossItem); } if (dsfqd.contains("4")) { List liepin_type = (List) resumeJobDynamicField.getLiepin_type(); String liepinType = convertPositionType(liepin_type, selectValueMap.get("猎聘")); SearchConditionItem liepinItem = RecruitFormItemUtil.cascaderItem(user, 1, 18, 3, "猎聘", "liepin"); liepinItem.setCompDef(JSON.parseObject(liepinType)); liepinItem.setRules("required"); liepinItem.setViewAttr(3); inputItems.add(liepinItem); } if (dsfqd.contains("3")) { List lagou_type = (List) resumeJobDynamicField.getLagou_type(); String lagouType = convertPositionType(lagou_type, selectValueMap.get("拉勾")); SearchConditionItem lagouItem = RecruitFormItemUtil.cascaderItem(user, 1, 18, 3, "拉勾", "lagou"); lagouItem.setCompDef(JSON.parseObject(lagouType)); lagouItem.setRules("required"); lagouItem.setViewAttr(3); inputItems.add(lagouItem); } if (dsfqd.contains("2")) { List job51_type = (List) resumeJobDynamicField.getJob51_type(); String job51Type = convertPositionType(job51_type, selectValueMap.get("前程无忧")); SearchConditionItem job51Item = RecruitFormItemUtil.cascaderItem(user, 1, 18, 3, "前程无忧", "job51"); job51Item.setCompDef(JSON.parseObject(job51Type)); job51Item.setRules("required"); job51Item.setViewAttr(3); inputItems.add(job51Item); } if (dsfqd.contains("1")) { List zhilian_type = (List) resumeJobDynamicField.getZhilian_type(); String zhilianType = convertPositionType(zhilian_type, selectValueMap.get("智联")); SearchConditionItem zhilianItem = RecruitFormItemUtil.cascaderItem(user, 1, 18, 3, "智联", "zhilian"); zhilianItem.setCompDef(JSON.parseObject(zhilianType)); zhilianItem.setRules("required"); zhilianItem.setViewAttr(3); inputItems.add(zhilianItem); } addGroups.add(new SearchConditionGroup("职位类别", true, inputItems)); apidatas.put("condition", addGroups); } private void getJob51CityForm(String selectValue, Map apidatas, ResumeJobDynamicField resumeJobDynamicField) { String[] split = selectValue.split("#"); Map selectValueMap = new HashMap<>(); for (String s : split) { String[] split1 = s.split(":"); if (split1.length == 2) { selectValueMap.put(split1[0], split1[1]); } } //输入框类 List inputItems = new ArrayList<>(); List addGroups = new ArrayList<>(); List boss_type = (List) resumeJobDynamicField.getBoss_type(); String bossType = convertPositionType(boss_type, selectValueMap.get("BOSS直聘")); SearchConditionItem bossItem = RecruitFormItemUtil.cascaderItem(user, 1, 18, 3, "前程无忧", "job51City"); bossItem.setRules("required"); bossItem.setViewAttr(3); bossItem.setCompDef(JSON.parseObject(bossType)); inputItems.add(bossItem); addGroups.add(new SearchConditionGroup("职位类别", true, inputItems)); apidatas.put("condition", addGroups); } /** * 构建职位类型,级联组件数据 * * @param typeList * @return */ private String convertPositionType(List typeList, String selectValue) { String[] split = Util.null2String(selectValue).split("-"); String first = ""; String second = ""; String third = ""; if (split.length == 3) { first = split[0]; second = split[1]; third = split[2]; } StringBuffer sb = new StringBuffer(); sb.append("{\n" + " type: 'select',\n" + " customProps: {'*':{viewAttr:3,rules:'required'}},\n" + " key: 'one',\n" + //" viewAttr: 3,\n" + " style: {\n" + " 'width': '120px'\n" + " },\n" + " options: [\n"); for (ResumeJobDynamicField.Item item : typeList) { String j_typeId = item.getValue(); String j_typeName = item.getLabel(); sb.append(" {\n" + " key: \"" + j_typeId + "\",\n" + //" selected: false,\n" + " selected: " + first.equals(j_typeName) + ",\n" + " showname: \"" + j_typeName + "\"\n" + " },\n"); } sb.append( " ],\n" + " subChildren: {\n"); for (ResumeJobDynamicField.Item item : typeList) { String j_type = item.getValue(); sb.append(" \"" + j_type + "\": {\n" + " type: 'select',\n" + " key: 'two',\n" + " style: {\n" + " 'width': '120px'\n" + " },\n" + " options: [\n"); List childrenList = (List) item.getChildren(); for (ResumeJobDynamicField.Item child : childrenList) { String j_typeId = child.getValue(); String j_typeName = child.getLabel(); sb.append(" {\n" + " key: \"" + j_typeId + "\",\n" + " selected: false,\n" + " selected: " + second.equals(j_typeName) + ",\n" + " showname: \"" + j_typeName + "\"\n" + " },\n"); } sb.append("],\n subChildren:{\n"); for (ResumeJobDynamicField.Item child : childrenList) { sb.append(" \"" + child.getValue() + "\": {\n"); sb.append("type:'select',\n"); sb.append("key:'three',\n"); sb.append("style:{ 'width': '120px' },\n"); sb.append("options: [\n"); List childChildren = (List) child.getChildren(); for (ResumeJobDynamicField.Item childChild : childChildren) { String j_typeId = childChild.getValue(); String j_typeName = childChild.getLabel(); sb.append(" {\n" + " key: \"" + j_typeId + "\",\n" + //" selected: false,\n" + " selected: " + third.equals(j_typeName) + ",\n" + " showname: \"" + j_typeName + "\"\n" + " },\n"); } sb.append("],\n"); //sb.append("multiple: 'false'\n"); sb.append("},"); } sb.append(" }\n"); sb.append(" } ,\n"); } sb.append(" }\n" + " }"); return sb.toString(); } }