From a677da06a681e91e8c371e5843f652fed97992e6 Mon Sep 17 00:00:00 2001 From: Mlin Date: Thu, 12 Jan 2023 15:17:38 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8A=B1=E5=90=8D=E5=86=8C=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E6=9F=A5=E8=AF=A2=E3=80=81=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E4=BF=9D=E5=AD=9820230112?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resource/JclOrgCustomTemplateMapper.java | 6 +++ .../resource/JclOrgCustomTemplateMapper.xml | 12 +++++ .../service/HrmResourceService.java | 8 ++++ .../service/impl/HrmResourceServiceImpl.java | 47 +++++++++++++++++-- .../web/HrmResourceController.java | 12 +++++ .../wrapper/HrmResourceWrapper.java | 4 ++ 6 files changed, 86 insertions(+), 3 deletions(-) diff --git a/src/com/engine/organization/mapper/resource/JclOrgCustomTemplateMapper.java b/src/com/engine/organization/mapper/resource/JclOrgCustomTemplateMapper.java index 09e48c14..51a566f8 100644 --- a/src/com/engine/organization/mapper/resource/JclOrgCustomTemplateMapper.java +++ b/src/com/engine/organization/mapper/resource/JclOrgCustomTemplateMapper.java @@ -1,7 +1,9 @@ package com.engine.organization.mapper.resource; import com.engine.organization.entity.hrmresource.po.JclOrgCustomTemplatePO; +import org.apache.ibatis.annotations.Param; +import java.util.Collection; import java.util.List; /** @@ -26,4 +28,8 @@ public interface JclOrgCustomTemplateMapper { List listAll(); + List listAllId(); + + int deleteByIds(@Param("ids") Collection ids); + } diff --git a/src/com/engine/organization/mapper/resource/JclOrgCustomTemplateMapper.xml b/src/com/engine/organization/mapper/resource/JclOrgCustomTemplateMapper.xml index 01b27d41..13b9acd4 100644 --- a/src/com/engine/organization/mapper/resource/JclOrgCustomTemplateMapper.xml +++ b/src/com/engine/organization/mapper/resource/JclOrgCustomTemplateMapper.xml @@ -117,4 +117,16 @@ update_time = #{updateTime,jdbcType=DATE} where id = #{id,jdbcType=INTEGER} + + + + + delete from jcl_org_custom_template where id in + + #{id} + + + diff --git a/src/com/engine/organization/service/HrmResourceService.java b/src/com/engine/organization/service/HrmResourceService.java index b337219f..edd0e739 100644 --- a/src/com/engine/organization/service/HrmResourceService.java +++ b/src/com/engine/organization/service/HrmResourceService.java @@ -136,6 +136,14 @@ public interface HrmResourceService { */ Integer saveCustomTemplate(SearchTemplateParam params); + /** + * 批量修改保存定制列模板 + * + * @param params + * @return + */ + Integer updateCustomTemplate(Map params); + /** * 删除定制列模板 * diff --git a/src/com/engine/organization/service/impl/HrmResourceServiceImpl.java b/src/com/engine/organization/service/impl/HrmResourceServiceImpl.java index e66c0972..c3dcd10f 100644 --- a/src/com/engine/organization/service/impl/HrmResourceServiceImpl.java +++ b/src/com/engine/organization/service/impl/HrmResourceServiceImpl.java @@ -17,6 +17,7 @@ import com.engine.organization.entity.company.po.CompPO; import com.engine.organization.entity.department.bo.DepartmentBO; import com.engine.organization.entity.department.po.DepartmentPO; import com.engine.organization.entity.extend.bo.ExtendInfoBO; +import com.engine.organization.entity.extend.param.ExtendInfoParams; import com.engine.organization.entity.extend.po.ExtendInfoPO; import com.engine.organization.entity.hrmresource.bo.HrmRelationBO; import com.engine.organization.entity.hrmresource.param.HrmRelationSaveParam; @@ -34,6 +35,7 @@ import com.engine.organization.entity.searchtree.SearchTreeParams; import com.engine.organization.enums.HrmGroupEnum; import com.engine.organization.mapper.comp.CompMapper; import com.engine.organization.mapper.department.DepartmentMapper; +import com.engine.organization.mapper.extend.ExtMapper; import com.engine.organization.mapper.hrmresource.HrmRelationMapper; import com.engine.organization.mapper.hrmresource.SystemDataMapper; import com.engine.organization.mapper.job.JobMapper; @@ -43,6 +45,7 @@ import com.engine.organization.service.HrmResourceService; import com.engine.organization.util.HasRightUtil; import com.engine.organization.util.MenuBtn; import com.engine.organization.util.OrganizationAssert; +import com.engine.organization.util.OrganizationDateUtil; import com.engine.organization.util.db.DBType; import com.engine.organization.util.db.MapperProxyFactory; import com.engine.organization.util.detach.DetachUtil; @@ -57,6 +60,7 @@ import weaver.general.StringUtil; import weaver.general.Util; import weaver.hrm.definedfield.HrmFieldManager; +import java.time.LocalDateTime; import java.util.*; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; @@ -249,6 +253,40 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic return templatePO.getId(); } + @Override + public Integer updateCustomTemplate(Map params) { + int rowNum = Util.getIntValue((String) params.get("rownum")); + int count = 0; + List allIds = MapperProxyFactory.getProxy(JclOrgCustomTemplateMapper.class).listAllId(); + String currentDate = OrganizationDateUtil.getFormatLocalDate(new java.util.Date()); + for (int i = 0; i < rowNum; i++) { + String recordIndex = "_" + i; + String id = Util.null2String(params.get("id" + recordIndex)); + String name = Util.null2String(params.get("name" + recordIndex)); + JclOrgCustomTemplatePO jclOrgCustomTemplatePO = new JclOrgCustomTemplatePO(); + if (StringUtils.isNotBlank(id)) { + // 更新 + long jclId = Long.parseLong(id); + jclOrgCustomTemplatePO = MapperProxyFactory.getProxy(JclOrgCustomTemplateMapper.class).selectByPrimaryKey(jclId); + jclOrgCustomTemplatePO.setName(name); + jclOrgCustomTemplatePO.setUpdateTime(new java.sql.Date(OrganizationDateUtil.stringToDate(currentDate).getTime())); + count += MapperProxyFactory.getProxy(JclOrgCustomTemplateMapper.class).updateByPrimaryKey(jclOrgCustomTemplatePO); + allIds.remove(jclId); + } else { + //插入 + jclOrgCustomTemplatePO.setName(name); + jclOrgCustomTemplatePO.setCreator(user.getUID()); + jclOrgCustomTemplatePO.setCreateTime(new java.sql.Date(OrganizationDateUtil.stringToDate(currentDate).getTime())); + jclOrgCustomTemplatePO.setUpdateTime(new java.sql.Date(OrganizationDateUtil.stringToDate(currentDate).getTime())); + count += MapperProxyFactory.getProxy(JclOrgCustomTemplateMapper.class).insert(jclOrgCustomTemplatePO); + } + } + if (CollectionUtils.isNotEmpty(allIds)) { + count += MapperProxyFactory.getProxy(JclOrgCustomTemplateMapper.class).deleteByIds(allIds); + } + return count; + } + @Override public void deleteCustomTemplate(Integer id) { getHrmResourceMapper().deleteCustomTemplate(id, user.getUID()); @@ -451,10 +489,13 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic resultMap.put("name", item.getName()); resultMap.put("createTime", item.getCreateTime()); - if (1 == item.getIsused()) { - isUsed.add(index.get()); + if(item.getIsused()!=null){ + + if (1 == item.getIsused()) { + isUsed.add(index.get()); + } + index.getAndIncrement(); } - index.getAndIncrement(); return resultMap; }).collect(Collectors.toList()); diff --git a/src/com/engine/organization/web/HrmResourceController.java b/src/com/engine/organization/web/HrmResourceController.java index c59f267d..e8ea8c7e 100644 --- a/src/com/engine/organization/web/HrmResourceController.java +++ b/src/com/engine/organization/web/HrmResourceController.java @@ -332,5 +332,17 @@ public class HrmResourceController { } } + @Path("/updateCustomTemplate") + @Produces(MediaType.APPLICATION_JSON) + public ReturnResult updateCustomTemplate(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + User user = HrmUserVarify.getUser(request, response); + Map map = ParamUtil.request2Map(request); + Integer templateId = getHrmResourceWrapper(user).updateCustomTemplate(map); + return ReturnResult.successed(Util.null2String(templateId)); + } catch (Exception e) { + return ReturnResult.exceptionHandle(e); + } + } } diff --git a/src/com/engine/organization/wrapper/HrmResourceWrapper.java b/src/com/engine/organization/wrapper/HrmResourceWrapper.java index 091de226..f2e4bfe4 100644 --- a/src/com/engine/organization/wrapper/HrmResourceWrapper.java +++ b/src/com/engine/organization/wrapper/HrmResourceWrapper.java @@ -96,6 +96,10 @@ public class HrmResourceWrapper extends OrganizationWrapper { return getHrmResourceService(user).saveCustomTemplate(params); } + public Integer updateCustomTemplate(Map params) { + return getHrmResourceService(user).updateCustomTemplate(params); + } + public void deleteCustomTemplate(Integer id) { getHrmResourceService(user).deleteCustomTemplate(id); }