同步字段定时任务

main
liuliang 7 days ago
parent 55390106ef
commit 6b53f1239a

@ -4,4 +4,6 @@
<dubbo:service ref="UpdateGlzzygidAction_jcl" interface="com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface" group="UpdateGlzzygidAction_jcl" /> <dubbo:service ref="UpdateGlzzygidAction_jcl" interface="com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface" group="UpdateGlzzygidAction_jcl" />
<dubbo:service ref="updateEmployeeAgeGlSlInfo_jcl" interface="com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface" group="updateEmployeeAgeGlSlInfo_jcl" /> <dubbo:service ref="updateEmployeeAgeGlSlInfo_jcl" interface="com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface" group="updateEmployeeAgeGlSlInfo_jcl" />
<dubbo:service ref="synchronousFieldInitialization_jcl" interface="com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface" group="synchronousFieldInitialization_jcl" />
<dubbo:service ref="synchronousFieldByEmployee_jcl" interface="com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface" group="synchronousFieldByEmployee_jcl" />
</beans> </beans>

@ -1,6 +0,0 @@
Manifest-Version: 1.0
weaver-ecode-seconddev-id: com.weaver.secondev-jcl-hrmorganization
Implementation-Title: jcl-hrmorganization
Implementation-Version: 1.0.0
Implementation-Vendor-Id: com.weaver.secondev

@ -20,7 +20,7 @@ public class SynchronousFieldByEmployee implements EsbServerlessRpcRemoteInterfa
EmployeeInformationService employeeInformationService; EmployeeInformationService employeeInformationService;
@Override @Override
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) { public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
List<String> errorList = employeeInformationService.synchronousFieldByEmployee(new SimpleEmployee()); List<String> errorList = employeeInformationService.synchronousFieldByEmployee(new SimpleEmployee(1L));
if (errorList.size() > 0){ if (errorList.size() > 0){
return WeaResult.fail(errorList.toString(),true); return WeaResult.fail(errorList.toString(),true);

@ -20,7 +20,7 @@ public class SynchronousFieldInitialization implements EsbServerlessRpcRemoteIn
EmployeeInformationService employeeInformationService; EmployeeInformationService employeeInformationService;
@Override @Override
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) { public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
List<String> errorList = employeeInformationService.synchronousField(new SimpleEmployee()); List<String> errorList = employeeInformationService.synchronousField(new SimpleEmployee(1L));
if (errorList.size() > 0){ if (errorList.size() > 0){
return WeaResult.fail(errorList.toString(),true); return WeaResult.fail(errorList.toString(),true);

@ -4,12 +4,23 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.weaver.common.base.entity.result.WeaResult; import com.weaver.common.base.entity.result.WeaResult;
import com.weaver.common.base.enumeration.result.WeaResultCodeEnum;
import com.weaver.common.form.auth.FormAuthenticationService;
import com.weaver.common.form.context.FormContext;
import com.weaver.common.form.context.FormContextParam;
import com.weaver.common.form.dto.auth.FormAuthenticationDto;
import com.weaver.common.form.dto.form.FormTableDto; import com.weaver.common.form.dto.form.FormTableDto;
import com.weaver.common.form.enums.auth.FormAuthenticationEnum;
import com.weaver.common.form.exception.FormException;
import com.weaver.common.form.fieldmanage.service.FormFieldManageService; import com.weaver.common.form.fieldmanage.service.FormFieldManageService;
import com.weaver.common.form.metadata.Form;
import com.weaver.common.form.metadata.ModuleSource; import com.weaver.common.form.metadata.ModuleSource;
import com.weaver.common.form.param.FieldManageParam; import com.weaver.common.form.param.FieldManageParam;
import com.weaver.common.form.param.auth.FormAuthenticationParam;
import com.weaver.common.form.param.field.FormFieldParam;
import com.weaver.common.form.physical.enums.FormTableType; import com.weaver.common.form.physical.enums.FormTableType;
import com.weaver.common.form.service.IdGeneratorService; import com.weaver.common.form.service.IdGeneratorService;
import com.weaver.common.i18n.label.SystemEnv;
import com.weaver.form.controller.FormBaseController; import com.weaver.form.controller.FormBaseController;
import com.weaver.form.controller.manage.FormFieldManageController; import com.weaver.form.controller.manage.FormFieldManageController;
import com.weaver.form.entity.FormFieldManageParam; import com.weaver.form.entity.FormFieldManageParam;
@ -22,10 +33,16 @@ import com.weaver.seconddev.jcl.organization.util.Constants;
import com.weaver.seconddev.jcl.organization.util.DatabaseUtils; import com.weaver.seconddev.jcl.organization.util.DatabaseUtils;
import com.weaver.teams.domain.user.SimpleEmployee; import com.weaver.teams.domain.user.SimpleEmployee;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.StopWatch;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -45,6 +62,8 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic
private IdGeneratorService idGeneratorService; private IdGeneratorService idGeneratorService;
@Autowired @Autowired
private FormFieldManageController fieldManageController; private FormFieldManageController fieldManageController;
@Autowired
private FormAuthenticationService formAuthenticationService;
@Override @Override
public List<Map<String, Object>> getInformation(Employee employee) { public List<Map<String, Object>> getInformation(Employee employee) {
@ -221,7 +240,7 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic
sql = "select b.id formtableid,a.* from sub_form a left join form_table b on a.id=b.form_id where a.form_id=?"; sql = "select b.id formtableid,a.* from sub_form a left join form_table b on a.id=b.form_id where a.form_id=?";
List<Map<String, Object>> dataList = databaseUtils.getSqlList(sql,CommonUtils.getParamList(employee_form_id)); List<Map<String, Object>> dataList = databaseUtils.getSqlList(sql,CommonUtils.getParamList(employee_form_id));
List<String> errorMessage = Lists.newArrayList(); List<String> errorMessage = Lists.newArrayList();
WeaResult<Map<String, Object>> result = batchSaveInformation(employee_form_id,employeeFieldList,dataList,ModuleSource.ebuilderform,null,null); WeaResult<Map<String, Object>> result = batchSaveInformation(employee_form_id,employeeFieldList,dataList,ModuleSource.ebuilderform,null,null,employee);
if (result.getCode() != 200){ if (result.getCode() != 200){
errorMessage.add("员工信息表"+result.getMsg()); errorMessage.add("员工信息表"+result.getMsg());
} }
@ -229,14 +248,14 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic
//保存人力资源-基本信息 //保存人力资源-基本信息
Map<String, Object> customParam = Maps.newHashMap(); Map<String, Object> customParam = Maps.newHashMap();
customParam.put("formId",personCustomfieldFormid); customParam.put("formId",personCustomfieldFormid);
WeaResult<Map<String, Object>> result2 = batchSaveInformation(personCustomfieldFormid,personCustomFieldList,null,ModuleSource.hrm,customParam,null); WeaResult<Map<String, Object>> result2 = batchSaveInformation(personCustomfieldFormid,personCustomFieldList,null,ModuleSource.hrm,customParam,null,employee);
if (result2.getCode() != 200){ if (result2.getCode() != 200){
errorMessage.add("人力资源基本信息自定义表"+result2.getMsg()); errorMessage.add("人力资源基本信息自定义表"+result2.getMsg());
} }
//保存人力资源-个人信息 //保存人力资源-个人信息
Map<String, Object> customParam2 = Maps.newHashMap(); Map<String, Object> customParam2 = Maps.newHashMap();
customParam2.put("apiModule","hr"); customParam2.put("apiModule","hr");
WeaResult<Map<String, Object>> result3 = batchSaveInformation(personInfCustomFormid,personInfCustomFieldList,null,ModuleSource.hruserinfo,customParam2,null); WeaResult<Map<String, Object>> result3 = batchSaveInformation(personInfCustomFormid,personInfCustomFieldList,null,ModuleSource.hruserinfo,customParam2,null,employee);
if (result3.getCode() != 200){ if (result3.getCode() != 200){
errorMessage.add("人力资源个人信息自定义表"+result3.getMsg()); errorMessage.add("人力资源个人信息自定义表"+result3.getMsg());
} }
@ -310,14 +329,14 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic
//保存人力资源-基本信息 //保存人力资源-基本信息
Map<String, Object> customParam = Maps.newHashMap(); Map<String, Object> customParam = Maps.newHashMap();
customParam.put("formId",personCustomfieldFormid); customParam.put("formId",personCustomfieldFormid);
WeaResult<Map<String, Object>> result2 = batchSaveInformation(personCustomfieldFormid,personCustomFieldList,null,ModuleSource.hrm,customParam,personCustomids); WeaResult<Map<String, Object>> result2 = batchSaveInformation(personCustomfieldFormid,personCustomFieldList,null,ModuleSource.hrm,customParam,personCustomids,employee);
if (result2.getCode() != 200){ if (result2.getCode() != 200){
errorMessage.add("基本信息表"+result2.getMsg()); errorMessage.add("基本信息表"+result2.getMsg());
} }
//保存人力资源-个人信息 //保存人力资源-个人信息
Map<String, Object> customParam2 = Maps.newHashMap(); Map<String, Object> customParam2 = Maps.newHashMap();
customParam2.put("apiModule","hr"); customParam2.put("apiModule","hr");
WeaResult<Map<String, Object>> result3 = batchSaveInformation(personInfCustomFormid,personInfCustomFieldList,null,ModuleSource.hruserinfo,customParam2,personInfCustomIds); WeaResult<Map<String, Object>> result3 = batchSaveInformation(personInfCustomFormid,personInfCustomFieldList,null,ModuleSource.hruserinfo,customParam2,personInfCustomIds,employee);
if (result3.getCode() != 200){ if (result3.getCode() != 200){
errorMessage.add("个人信息表"+result3.getMsg()); errorMessage.add("个人信息表"+result3.getMsg());
} }
@ -384,7 +403,7 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic
sql = "select b.id formtableid,a.* from sub_form a left join form_table b on a.id=b.form_id where a.form_id=?"; sql = "select b.id formtableid,a.* from sub_form a left join form_table b on a.id=b.form_id where a.form_id=?";
List<Map<String, Object>> dataList = databaseUtils.getSqlList(sql,CommonUtils.getParamList(employee_form_id)); List<Map<String, Object>> dataList = databaseUtils.getSqlList(sql,CommonUtils.getParamList(employee_form_id));
List<String> errorMessage = Lists.newArrayList(); List<String> errorMessage = Lists.newArrayList();
WeaResult<Map<String, Object>> result = batchSaveInformation(employee_form_id,employeeFieldList,dataList,ModuleSource.ebuilderform,null,deleteIds); WeaResult<Map<String, Object>> result = batchSaveInformation(employee_form_id,employeeFieldList,dataList,ModuleSource.ebuilderform,null,deleteIds,employee);
if (result.getCode() != 200){ if (result.getCode() != 200){
errorMessage.add("员工信息表"+result.getMsg()); errorMessage.add("员工信息表"+result.getMsg());
} }
@ -394,12 +413,38 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic
@Override @Override
public List<Map<Object, Object>> getFieldList(FieldManageParam entity,SimpleEmployee employee) { public List<Map<Object, Object>> getFieldList(FieldManageParam entity,SimpleEmployee employee) {
HashMap result = new HashMap(6);
WeaResult<Map<String, Object>> wearesult =null;
try {
ModuleSource module = entity.getModule();
Long formId = entity.getFormId();
if (formId == null) {
result.put("actionMsg", SystemEnv.getHtmlLabelName(181389L, "formId不能为空。"));
wearesult = WeaResult.fail(result.toString(), true);
} else {
WeaResult<FormAuthenticationDto> authentication = formAuthenticationService.authentication(new FormAuthenticationParam(module, entity.getFormId(), FormAuthenticationEnum.FORM_FIELD_MANAGE_SELECT_LIST, (Map)null), employee);
if (!authentication.isStatus()) {
wearesult = WeaResult.fail(authentication.getMsg(), true);
} else {
if (entity.getNeedI18N() == null) {
entity.setNeedI18N(true);
}
// List<Map<Object, Object>> fieldList = (CommonUtils.getRealService(module.name(), "FormFieldManageService", FormFieldManageService.class)).getFormFieldJsonByFormId(entity, employee); List<Map<Object, Object>> fieldList = ((FormFieldManageService)fieldManageController.getRealService(module.name(), "FormFieldManageService", FormFieldManageService.class)).getFormFieldJsonByFormId(entity, employee);
WeaResult<Map<String, Object>> result = fieldManageController.getFormFieldList(entity); result.put("data", fieldList);
wearesult = WeaResult.success(result);
}
}
} catch (FormException var8) {
log.error("getFormFieldList 异常:", var8);
wearesult = WeaResult.fail(SystemEnv.getHtmlLabelName(181391L, "获取批量编辑字段列表失败:") + var8.getMessage(), true);
} catch (Exception var9) {
log.error("getFormFieldList 异常2", var9);
wearesult = WeaResult.fail(SystemEnv.getHtmlLabelName(181391L, "获取批量编辑字段列表失败:") + var9.getMessage(), true);
}
Gson gson = new Gson(); Gson gson = new Gson();
log.error("getFieldList :[{}]",gson.toJson(result)); log.error("getFieldList :[{}]",gson.toJson(wearesult));
Map<String, Object> resultMap = result.getData(); Map<String, Object> resultMap = wearesult.getData();
return (List<Map<Object, Object>>)resultMap.get("data"); return (List<Map<Object, Object>>)resultMap.get("data");
} }
@ -409,8 +454,84 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic
* @param entity * @param entity
* @return * @return
*/ */
public WeaResult<Map<String, Object>> batchSaveFormField(FormFieldManageParam entity) { public WeaResult<Map<String, Object>> batchSaveFormField(FormFieldManageParam entity,SimpleEmployee employee) {
return fieldManageController.batchSaveFormField(entity); HashMap result = new HashMap(16);
WeaResult<Map<String, Object>> weaResult = null;
try {
ModuleSource module = entity.getModule();
List<String> formFields = entity.getJsonObjList();
StopWatch stopWatch = new StopWatch();
Long formId = entity.getFormId();
if (formId == null) {
result.put("actionMsg", SystemEnv.getHtmlLabelName(181369L, "数据不能为空。"));
return WeaResult.fail(result.toString(), true);
} else {
stopWatch.start(" batchSaveFormField controller start 0 ");
WeaResult<FormAuthenticationDto> authentication = this.formAuthenticationService.authentication(new FormAuthenticationParam(module, entity.getFormId(), FormAuthenticationEnum.FORM_FIELD_MANAGE_UPDATE, entity.getCustomParam()), employee);
stopWatch.stop();
if (!authentication.isStatus()) {
return WeaResult.fail(authentication.getMsg(), true);
} else {
FormContextParam formContextParam = FormContext.get(formId);
formContextParam.setCostTime(new HashMap());
if (entity.getNeedOldData() != null && entity.getNeedOldData()) {
formContextParam.setNeedOldData(true);
}
stopWatch.start(" batchSaveFormField controller start 1 ");
FormFieldManageService realService = (FormFieldManageService)fieldManageController.getRealService(module.name(), "FormFieldManageService", FormFieldManageService.class);
stopWatch.stop();
stopWatch.start(" batchSaveFormField controller start 2 batchSaveSubForm ");
if (CollectionUtils.isNotEmpty(entity.getForms()) || CollectionUtils.isNotEmpty(entity.getDelSubFormIds())) {
realService.batchSaveSubForm(entity.getForms(), entity.getDelSubFormIds(), formId, entity.getCustomParam(), employee);
}
stopWatch.stop();
stopWatch.start(" batchSaveFormField controller start 3 deleteFormTable");
if (CollectionUtils.isNotEmpty(entity.getDelFormTableIdList())) {
realService.deleteFormTable(entity.getDelFormTableIdList(), employee);
}
stopWatch.stop();
stopWatch.start(" batchSaveFormField controller start 4 batchUpdateFormTable");
if (CollectionUtils.isNotEmpty(entity.getFormTableList())) {
Map<String, Object> customParam = entity.getCustomParam();
if (MapUtils.isEmpty((Map)customParam)) {
customParam = new HashMap();
}
((Map)customParam).put("module", module);
realService.batchUpdateFormTable(entity.getFormTableList(), new Form(formId), (Map)customParam, employee);
}
stopWatch.stop();
stopWatch.start(" batchSaveFormField controller start 5 batchDeleteFormField");
if (CollectionUtils.isNotEmpty(entity.getIds())) {
realService.batchDeleteFormField(entity.getIds(), employee);
}
stopWatch.stop();
stopWatch.start(" batchSaveFormField controller start 6 batchDeleteFormField");
if (CollectionUtils.isNotEmpty(formFields)) {
realService.batchUpdateFromFieldNew(new FormFieldParam(module.name(), formFields, new ArrayList(), entity.getCustomParam()), employee);
}
stopWatch.stop();
result.put("formFields", formFields);
Map<String, String> costTime = formContextParam.getCostTime();
costTime.put(" batchSaveFormField controller ", stopWatch.prettyPrint().replaceAll("\n", "|"));
result.put("costTime", costTime);
return WeaResult.success(result);
}
}
} catch (FormException var12) {
log.error("batchSaveFormFieldNew 异常:", var12);
return WeaResult.fail(WeaResultCodeEnum.ERROR.getCode(), SystemEnv.getHtmlLabelName(181358L, "批量保存字段失败:") + var12.getMessage(), var12.data, true);
} catch (Exception var13) {
log.error("batchSaveFormFieldNew 异常2", var13);
return WeaResult.fail(SystemEnv.getHtmlLabelName(181358L, "批量保存字段失败:") + var13.getMessage(), false);
}
} }
public List<String> getJsonObjList(List<Map<Object, Object>> list){ public List<String> getJsonObjList(List<Map<Object, Object>> list){
@ -499,7 +620,7 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic
* *
* @return * @return
*/ */
public WeaResult<Map<String, Object>> batchSaveInformation(String formid,List<Map<Object, Object>> formFieldList,List<Map<String, Object>> detailFormList,ModuleSource moduleSource,Map<String, Object> customParam,List<Long> ids){ public WeaResult<Map<String, Object>> batchSaveInformation(String formid,List<Map<Object, Object>> formFieldList,List<Map<String, Object>> detailFormList,ModuleSource moduleSource,Map<String, Object> customParam,List<Long> ids,SimpleEmployee employee){
FormFieldManageParam saveEmployeeEntity = new FormFieldManageParam(); FormFieldManageParam saveEmployeeEntity = new FormFieldManageParam();
saveEmployeeEntity.setFormId(Long.valueOf(formid)); saveEmployeeEntity.setFormId(Long.valueOf(formid));
saveEmployeeEntity.setModule(moduleSource); saveEmployeeEntity.setModule(moduleSource);
@ -532,7 +653,7 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic
saveEmployeeEntity.setIds(ids); saveEmployeeEntity.setIds(ids);
saveEmployeeEntity.setForms(forms); saveEmployeeEntity.setForms(forms);
saveEmployeeEntity.setCustomParam(customParam); saveEmployeeEntity.setCustomParam(customParam);
WeaResult<Map<String, Object>>result = batchSaveFormField(saveEmployeeEntity); WeaResult<Map<String, Object>>result = batchSaveFormField(saveEmployeeEntity,employee);
Gson gson = new Gson(); Gson gson = new Gson();
log.error("batchSaveInformation result :[{}]",gson.toJson(result)); log.error("batchSaveInformation result :[{}]",gson.toJson(result));
return result; return result;

Loading…
Cancel
Save