|
|
|
@ -4,12 +4,23 @@ import com.google.common.collect.Lists;
|
|
|
|
|
import com.google.common.collect.Maps;
|
|
|
|
|
import com.google.gson.Gson;
|
|
|
|
|
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.enums.auth.FormAuthenticationEnum;
|
|
|
|
|
import com.weaver.common.form.exception.FormException;
|
|
|
|
|
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.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.service.IdGeneratorService;
|
|
|
|
|
import com.weaver.common.i18n.label.SystemEnv;
|
|
|
|
|
import com.weaver.form.controller.FormBaseController;
|
|
|
|
|
import com.weaver.form.controller.manage.FormFieldManageController;
|
|
|
|
|
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.teams.domain.user.SimpleEmployee;
|
|
|
|
|
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.stereotype.Service;
|
|
|
|
|
import org.springframework.util.StopWatch;
|
|
|
|
|
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.Map;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
@ -45,6 +62,8 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic
|
|
|
|
|
private IdGeneratorService idGeneratorService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private FormFieldManageController fieldManageController;
|
|
|
|
|
@Autowired
|
|
|
|
|
private FormAuthenticationService formAuthenticationService;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
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=?";
|
|
|
|
|
List<Map<String, Object>> dataList = databaseUtils.getSqlList(sql,CommonUtils.getParamList(employee_form_id));
|
|
|
|
|
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){
|
|
|
|
|
errorMessage.add("员工信息表"+result.getMsg());
|
|
|
|
|
}
|
|
|
|
@ -229,14 +248,14 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic
|
|
|
|
|
//保存人力资源-基本信息
|
|
|
|
|
Map<String, Object> customParam = Maps.newHashMap();
|
|
|
|
|
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){
|
|
|
|
|
errorMessage.add("人力资源基本信息自定义表"+result2.getMsg());
|
|
|
|
|
}
|
|
|
|
|
//保存人力资源-个人信息
|
|
|
|
|
Map<String, Object> customParam2 = Maps.newHashMap();
|
|
|
|
|
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){
|
|
|
|
|
errorMessage.add("人力资源个人信息自定义表"+result3.getMsg());
|
|
|
|
|
}
|
|
|
|
@ -310,14 +329,14 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic
|
|
|
|
|
//保存人力资源-基本信息
|
|
|
|
|
Map<String, Object> customParam = Maps.newHashMap();
|
|
|
|
|
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){
|
|
|
|
|
errorMessage.add("基本信息表"+result2.getMsg());
|
|
|
|
|
}
|
|
|
|
|
//保存人力资源-个人信息
|
|
|
|
|
Map<String, Object> customParam2 = Maps.newHashMap();
|
|
|
|
|
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){
|
|
|
|
|
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=?";
|
|
|
|
|
List<Map<String, Object>> dataList = databaseUtils.getSqlList(sql,CommonUtils.getParamList(employee_form_id));
|
|
|
|
|
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){
|
|
|
|
|
errorMessage.add("员工信息表"+result.getMsg());
|
|
|
|
|
}
|
|
|
|
@ -394,12 +413,38 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
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);
|
|
|
|
|
WeaResult<Map<String, Object>> result = fieldManageController.getFormFieldList(entity);
|
|
|
|
|
List<Map<Object, Object>> fieldList = ((FormFieldManageService)fieldManageController.getRealService(module.name(), "FormFieldManageService", FormFieldManageService.class)).getFormFieldJsonByFormId(entity, employee);
|
|
|
|
|
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();
|
|
|
|
|
log.error("getFieldList :[{}]",gson.toJson(result));
|
|
|
|
|
Map<String, Object> resultMap = result.getData();
|
|
|
|
|
log.error("getFieldList :[{}]",gson.toJson(wearesult));
|
|
|
|
|
Map<String, Object> resultMap = wearesult.getData();
|
|
|
|
|
return (List<Map<Object, Object>>)resultMap.get("data");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -409,8 +454,84 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic
|
|
|
|
|
* @param entity
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public WeaResult<Map<String, Object>> batchSaveFormField(FormFieldManageParam entity) {
|
|
|
|
|
return fieldManageController.batchSaveFormField(entity);
|
|
|
|
|
public WeaResult<Map<String, Object>> batchSaveFormField(FormFieldManageParam entity,SimpleEmployee employee) {
|
|
|
|
|
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){
|
|
|
|
@ -499,7 +620,7 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic
|
|
|
|
|
* 批量保存
|
|
|
|
|
* @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();
|
|
|
|
|
saveEmployeeEntity.setFormId(Long.valueOf(formid));
|
|
|
|
|
saveEmployeeEntity.setModule(moduleSource);
|
|
|
|
@ -532,7 +653,7 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic
|
|
|
|
|
saveEmployeeEntity.setIds(ids);
|
|
|
|
|
saveEmployeeEntity.setForms(forms);
|
|
|
|
|
saveEmployeeEntity.setCustomParam(customParam);
|
|
|
|
|
WeaResult<Map<String, Object>>result = batchSaveFormField(saveEmployeeEntity);
|
|
|
|
|
WeaResult<Map<String, Object>>result = batchSaveFormField(saveEmployeeEntity,employee);
|
|
|
|
|
Gson gson = new Gson();
|
|
|
|
|
log.error("batchSaveInformation result :[{}]",gson.toJson(result));
|
|
|
|
|
return result;
|
|
|
|
|