From 42c271470a749100a393e7702589bbb4ac72fca6 Mon Sep 17 00:00:00 2001 From: zhenggl Date: Fri, 28 Apr 2023 20:51:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=91=98=E5=B7=A5=E5=85=A5=E8=81=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/infra/common/enums/OptionEnums.java | 24 ++++++ .../infra/dto/{order => staff}/StaffDTO.java | 11 +-- .../athena/app/infra/entity/StaffEntity.java | 6 +- .../athena/app/infra/mapper/StaffMapper.xml | 58 ++++++++++++++ .../app/infra/repository/StaffRepository.java | 7 ++ .../athena/app/provider/StaffEAIService.java | 11 +-- .../provider/impl/StaffEAIServiceImpl.java | 4 - .../service/staff/StaffCreateEAIService.java | 26 +++--- .../app/service/staff/StaffGetEAIService.java | 79 +++++++++++++++---- .../service/staff/StaffQueryEAIService.java | 42 ---------- .../service/staff/StaffUpdateEAIService.java | 44 +++++++++-- .../athena/app/service/staff/StaffUtil.java | 3 +- 12 files changed, 213 insertions(+), 102 deletions(-) create mode 100644 demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/common/enums/OptionEnums.java rename demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/dto/{order => staff}/StaffDTO.java (79%) create mode 100644 demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/mapper/StaffMapper.xml delete mode 100644 demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/staff/StaffQueryEAIService.java diff --git a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/common/enums/OptionEnums.java b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/common/enums/OptionEnums.java new file mode 100644 index 0000000..8c55266 --- /dev/null +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/common/enums/OptionEnums.java @@ -0,0 +1,24 @@ +package com.digiwin.athena.app.infra.common.enums; + +/** + * @Auther: zhenggl + * @Date: 2023/4/28 + */ +public enum OptionEnums { + //任务卡 + TASK("task"), + //界面 + BASIC("basic"), + //流程 + FLOW("flow"); + + private final String value; + + OptionEnums(String value) { + this.value = value; + } + + public String getValue() { + return value; + } +} diff --git a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/dto/order/StaffDTO.java b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/dto/staff/StaffDTO.java similarity index 79% rename from demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/dto/order/StaffDTO.java rename to demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/dto/staff/StaffDTO.java index c1cf70a..e70936c 100644 --- a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/dto/order/StaffDTO.java +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/dto/staff/StaffDTO.java @@ -1,4 +1,4 @@ -package com.digiwin.athena.app.infra.dto.order; +package com.digiwin.athena.app.infra.dto.staff; import com.google.gson.annotations.SerializedName; import lombok.AllArgsConstructor; @@ -38,7 +38,7 @@ public class StaffDTO /** 手机号码 */ @SerializedName("mobile_no") - private Long mobileNo; + private String mobileNo; /** 电子邮件 */ @SerializedName("email") @@ -61,13 +61,10 @@ public class StaffDTO @SerializedName("timestamp") private String timestamp; - //==========冗余============== - @SerializedName("register_personnel_id") - public Long registerPersonnelId; - public StaffDTO(String employeeNo, Long registerPersonnelId) { + public StaffDTO(String employeeNo, Long id) { this.employeeNo = employeeNo; - this.registerPersonnelId = registerPersonnelId; + this.id = id; } } diff --git a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/entity/StaffEntity.java b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/entity/StaffEntity.java index ea7d5ff..0c2fa2e 100644 --- a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/entity/StaffEntity.java +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/entity/StaffEntity.java @@ -42,7 +42,7 @@ public class StaffEntity extends BaseMgrEntity /** 手机号码 */ @SerializedName("mobile_no") - private Long mobileNo; + private String mobileNo; /** 电子邮件 */ @SerializedName("email") @@ -50,11 +50,11 @@ public class StaffEntity extends BaseMgrEntity /** 状态 */ @SerializedName("status") - private Integer status; + private Integer status = 1; /** 数据状态 */ @SerializedName("tab_status") - private Integer tabStatus; + private Integer tabStatus = 0; /** 报道日期 */ @SerializedName("register_date") diff --git a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/mapper/StaffMapper.xml b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/mapper/StaffMapper.xml new file mode 100644 index 0000000..5ca9738 --- /dev/null +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/mapper/StaffMapper.xml @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + select id, employee_no, employee_name, en_employee_name, mobile_no, email, status, tab_status, register_date, tenantsid, tenant_id, create_by, create_date, modified_by, modified_date, version, deleted, timestamp from ca_cim_staff + + + + + + update ca_cim_staff + + employee_no = #{item.employeeNo}, + employee_name = #{item.employeeName}, + en_employee_name = #{item.enEmployeeName}, + mobile_no = #{item.mobileNo}, + email = #{item.email}, + + where id = #{item.id} and `tenantsid`=#{tenantSid} + + + + + + update ca_cim_staff + + status = #{item.status}, + tab_status = #{item.tabStatus}, + + where id = #{item.id} and `tenantsid`=#{tenantSid} + + + + diff --git a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/repository/StaffRepository.java b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/repository/StaffRepository.java index 321d132..d7a95f1 100644 --- a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/repository/StaffRepository.java +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/repository/StaffRepository.java @@ -3,10 +3,17 @@ package com.digiwin.athena.app.infra.repository; import com.digiwin.athena.app.infra.entity.StaffEntity; import com.digiwin.athena.opt.persistence.repository.BaseRepository; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * @Auther: zhenggl * @Date: 2023/4/28 */ public interface StaffRepository extends BaseRepository { + + public void updateStaffList(@Param("list")List list,@Param("tenantsid") Long tenantsid); + + public void updateStatusAndDate(@Param("list")List list,@Param("tenantsid") Long tenantsid); } diff --git a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/provider/StaffEAIService.java b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/provider/StaffEAIService.java index 5fa1639..36ee95f 100644 --- a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/provider/StaffEAIService.java +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/provider/StaffEAIService.java @@ -1,5 +1,6 @@ package com.digiwin.athena.app.provider; +import com.digiwin.app.service.AllowAnonymous; import com.digiwin.app.service.DWEAIResult; import com.digiwin.app.service.DWService; import com.digiwin.app.service.eai.EAIService; @@ -33,15 +34,6 @@ public interface StaffEAIService extends DWService { @EAIService(id = StaffUtil.DEMO_WAIT_REGISTER_PERSONNEL_INFO_GET) DWEAIResult get(Map headers, String messageBody) throws Exception; - /** - * 新人报道查询 - * @param headers - * @param messageBody - * @return - * @throws Exception - */ - @EAIService(id = StaffUtil.DEMO_WAIT_REGISTER_PERSONNEL_INFO_QUERY) - DWEAIResult query(Map headers, String messageBody) throws Exception; /** * 新人报道创建 @@ -51,5 +43,6 @@ public interface StaffEAIService extends DWService { * @throws Exception */ @EAIService(id = StaffUtil.DEMO_WAIT_REGISTER_PERSONNEL_INFO_CREATE) + @AllowAnonymous DWEAIResult create(Map headers, String messageBody) throws Exception; } diff --git a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/provider/impl/StaffEAIServiceImpl.java b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/provider/impl/StaffEAIServiceImpl.java index 688db87..cab39a4 100644 --- a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/provider/impl/StaffEAIServiceImpl.java +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/provider/impl/StaffEAIServiceImpl.java @@ -28,10 +28,6 @@ public class StaffEAIServiceImpl implements StaffEAIService { return eaiServiceContext.execute(StaffUtil.DEMO_WAIT_REGISTER_PERSONNEL_INFO_GET,headers,messageBody); } - @Override - public DWEAIResult query(Map headers, String messageBody) throws Exception { - return eaiServiceContext.execute(StaffUtil.DEMO_WAIT_REGISTER_PERSONNEL_INFO_QUERY,headers,messageBody); - } @Override public DWEAIResult create(Map headers, String messageBody) throws Exception { diff --git a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/staff/StaffCreateEAIService.java b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/staff/StaffCreateEAIService.java index eca98fd..5f5d0a3 100644 --- a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/staff/StaffCreateEAIService.java +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/staff/StaffCreateEAIService.java @@ -5,13 +5,16 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.digiwin.app.container.exceptions.DWRuntimeException; import com.digiwin.app.service.DWEAIResult; import com.digiwin.athena.app.infra.common.utils.BeanCopyUtil; -import com.digiwin.athena.app.infra.dto.order.StaffDTO; +import com.digiwin.athena.app.infra.dto.staff.StaffDTO; import com.digiwin.athena.app.infra.entity.StaffEntity; import com.digiwin.athena.app.infra.repository.StaffRepository; import com.digiwin.athena.app.infra.service.StaffService; import com.digiwin.athena.opt.common.eai.EAIRequest; import com.digiwin.athena.opt.common.eai.EAIUtil; import com.digiwin.athena.opt.common.eai.service.AbsEAIService; +import lombok.extern.log4j.Log4j2; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import javax.annotation.Resource; @@ -23,6 +26,8 @@ import java.util.stream.Collectors; * @Auther: zhenggl * @Date: 2023/4/28 */ +@Service +@Log4j2 public class StaffCreateEAIService extends AbsEAIService { @Resource @@ -37,31 +42,24 @@ public class StaffCreateEAIService extends AbsEAIService { } @Override + @Transactional(rollbackFor = Exception.class) public DWEAIResult execute(Map headers, String messageBody) throws Exception { //反序列化字段 EAIRequest request = new EAIRequest(messageBody); List staffList = request.getObject("wait_register_personnel", StaffUtil.LIST_DTO_STAFF); //判断编号跟邮箱是否存在 LambdaQueryWrapper lmq = new LambdaQueryWrapper<>(); - lmq.or(queryWrapperInner -> { - for (StaffDTO staffDTO : staffList) { - queryWrapperInner.or( - wrapper->wrapper - .eq(StaffEntity::getEmployeeNo,staffDTO.getEmployeeNo()) - ); - queryWrapperInner.or( - wrapper->wrapper - .eq(StaffEntity::getEmail,staffDTO.getEmail()) - ); - } - }); + List employeeNoList = staffList.stream().map(StaffDTO::getEmployeeNo).collect(Collectors.toList()); + List emailList = staffList.stream().map(StaffDTO::getEmail).collect(Collectors.toList()); + lmq.in(StaffEntity::getEmployeeNo,employeeNoList); + lmq.or().in(StaffEntity::getEmail,emailList); List staffEntities = staffRepository.selectList(lmq); if (!CollectionUtils.isEmpty(staffEntities)){ throw new DWRuntimeException("员工编号或邮箱重复"); } List staffEntityList = BeanCopyUtil.copyList(staffList, StaffEntity.class); staffService.saveBatch(staffEntityList); - List collect = staffEntities.stream().map(item -> new StaffDTO(item.getEmployeeNo(), item.getId())).collect(Collectors.toList()); + List collect = staffEntityList.stream().map(item -> new StaffDTO(item.getEmployeeNo(), item.getId())).collect(Collectors.toList()); return EAIUtil.buildEAIResult(new JSONObject().fluentPut("wait_register_personnel",collect)); } } diff --git a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/staff/StaffGetEAIService.java b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/staff/StaffGetEAIService.java index 0aee092..f03e649 100644 --- a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/staff/StaffGetEAIService.java +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/staff/StaffGetEAIService.java @@ -4,17 +4,24 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.digiwin.app.service.DWEAIResult; +import com.digiwin.athena.app.infra.common.enums.OptionEnums; import com.digiwin.athena.app.infra.common.enums.TabStatusEnums; +import com.digiwin.athena.app.infra.dto.staff.StaffDTO; import com.digiwin.athena.app.infra.entity.StaffEntity; import com.digiwin.athena.app.infra.repository.StaffRepository; import com.digiwin.athena.app.infra.service.StaffService; +import com.digiwin.athena.opt.common.eai.EAIRequest; import com.digiwin.athena.opt.common.eai.EAIUtil; import com.digiwin.athena.opt.common.eai.service.AbsEAIService; import com.digiwin.athena.opt.common.security.SecurityUtil; +import lombok.extern.log4j.Log4j2; +import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; +import org.springframework.util.StringUtils; import javax.annotation.Resource; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -23,6 +30,8 @@ import java.util.stream.Collectors; * @Auther: zhenggl * @Date: 2023/4/28 */ +@Service +@Log4j2 public class StaffGetEAIService extends AbsEAIService { @Resource @@ -39,22 +48,62 @@ public class StaffGetEAIService extends AbsEAIService { @Override @Transactional(rollbackFor = Exception.class) public DWEAIResult execute(Map headers, String messageBody) throws Exception { - //查询所有tab_status=0的数据然后把他们全部修改为1 - LambdaQueryWrapper lmq = new LambdaQueryWrapper<>(); - lmq.eq(StaffEntity::getTenantSid, SecurityUtil.getUserProfile().getTenantSid()); - lmq.eq(StaffEntity::getTabStatus, TabStatusEnums.NOSET.getValue()); - List staffEntities = staffRepository.selectList(lmq); - if (!CollectionUtils.isEmpty(staffEntities)){ - List idList = staffEntities.stream().map(StaffEntity::getId).collect(Collectors.toList()); - LambdaUpdateWrapper lmu = new LambdaUpdateWrapper<>(); - lmu.set(StaffEntity::getTabStatus,TabStatusEnums.PENDING); - lmu.in(StaffEntity::getId,idList); - staffService.update(lmu); - //修改查询到的参数 - staffEntities.forEach(item ->{ - item.setTabStatus(TabStatusEnums.PENDING.getValue()); + //反序列化字段 + EAIRequest request = new EAIRequest(messageBody); + String option = request.getObject("option", String.class); + //为空走侦测逻辑 + if (StringUtils.isEmpty(option)) { + //查询所有tab_status=0的数据然后把他们全部修改为1 + LambdaQueryWrapper lmq = new LambdaQueryWrapper<>(); + lmq.eq(StaffEntity::getTenantSid, SecurityUtil.getUserProfile().getTenantSid()); + lmq.eq(StaffEntity::getTabStatus, TabStatusEnums.NOSET.getValue()); + List staffEntities = staffRepository.selectList(lmq); + if (!CollectionUtils.isEmpty(staffEntities)) { + List idList = staffEntities.stream().map(StaffEntity::getId).collect(Collectors.toList()); + LambdaUpdateWrapper lmu = new LambdaUpdateWrapper<>(); + lmu.set(StaffEntity::getTabStatus, TabStatusEnums.PENDING); + lmu.in(StaffEntity::getId, idList); + staffService.update(lmu); + //修改查询到的参数 + staffEntities.forEach(item -> { + item.setTabStatus(TabStatusEnums.PENDING.getValue()); + }); + } + return EAIUtil.buildEAIResult(new JSONObject().fluentPut("wait_register_personnel", staffEntities)); + } else if (OptionEnums.TASK.equals(option)) { + List staffDTOS = request.getObject("wait_register_personnel", StaffUtil.LIST_DTO_STAFF); + LambdaQueryWrapper lmq = new LambdaQueryWrapper<>(); + lmq.eq(StaffEntity::getTenantSid, SecurityUtil.getUserProfile().getTenantSid()); + lmq.and(queryWrapperInner -> { + for (StaffDTO staffDTO : staffDTOS) { + queryWrapperInner.or( + wrapper -> wrapper + .eq(!StringUtils.isEmpty(staffDTO.getTabStatus()), StaffEntity::getTabStatus, staffDTO.getTabStatus()) + .eq(!StringUtils.isEmpty(staffDTO.getId()), StaffEntity::getId, staffDTO.getId()) + ); + } }); + List staffEntities = staffRepository.selectList(lmq); + return EAIUtil.buildEAIResult(new JSONObject().fluentPut("wait_register_personnel", staffEntities)); + } else if (OptionEnums.BASIC.equals(option)) { + List staffDTOS = request.getObject("wait_register_personnel", StaffUtil.LIST_DTO_STAFF); + LambdaQueryWrapper lmq = new LambdaQueryWrapper<>(); + lmq.eq(StaffEntity::getTenantSid, SecurityUtil.getUserProfile().getTenantSid()); + lmq.and(queryWrapperInner -> { + for (StaffDTO staffDTO : staffDTOS) { + queryWrapperInner.or( + wrapper -> wrapper + .eq(!StringUtils.isEmpty(staffDTO.getEmployeeNo()), StaffEntity::getEmployeeNo, staffDTO.getEmployeeNo()) + .eq(!StringUtils.isEmpty(staffDTO.getEmployeeName()), StaffEntity::getEmployeeName, staffDTO.getEmployeeName()) + .eq(!StringUtils.isEmpty(staffDTO.getEnEmployeeName()), StaffEntity::getEnEmployeeName, staffDTO.getEnEmployeeName()) + .eq(!StringUtils.isEmpty(staffDTO.getEmail()), StaffEntity::getEmail, staffDTO.getEmail()) + .eq(!StringUtils.isEmpty(staffDTO.getMobileNo()), StaffEntity::getMobileNo, staffDTO.getMobileNo()) + ); + } + }); + List staffEntities = staffRepository.selectList(lmq); + return EAIUtil.buildEAIResult(new JSONObject().fluentPut("wait_register_personnel", staffEntities)); } - return EAIUtil.buildEAIResult(new JSONObject().fluentPut("wait_register_personnel",staffEntities)); + return EAIUtil.buildEAIResult(new HashMap<>()); } } diff --git a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/staff/StaffQueryEAIService.java b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/staff/StaffQueryEAIService.java deleted file mode 100644 index ee4ffd6..0000000 --- a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/staff/StaffQueryEAIService.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.digiwin.athena.app.service.staff; - -import com.alibaba.fastjson.JSONObject; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.digiwin.app.service.DWEAIResult; -import com.digiwin.athena.app.infra.common.enums.TabStatusEnums; -import com.digiwin.athena.app.infra.dto.order.StaffDTO; -import com.digiwin.athena.app.infra.entity.StaffEntity; -import com.digiwin.athena.app.infra.repository.StaffRepository; -import com.digiwin.athena.opt.common.eai.EAIRequest; -import com.digiwin.athena.opt.common.eai.EAIUtil; -import com.digiwin.athena.opt.common.eai.service.AbsEAIService; -import com.digiwin.athena.opt.common.security.SecurityUtil; - - -import javax.annotation.Resource; -import java.util.List; -import java.util.Map; - -/** - * @Auther: zhenggl - * @Date: 2023/4/28 - */ -public class StaffQueryEAIService extends AbsEAIService { - - @Resource - private StaffRepository staffRepository; - - @Override - public String getServiceName() { - return StaffUtil.DEMO_WAIT_REGISTER_PERSONNEL_INFO_QUERY; - } - - @Override - public DWEAIResult execute(Map headers, String messageBody) throws Exception { - LambdaQueryWrapper lmq = new LambdaQueryWrapper<>(); - lmq.eq(StaffEntity::getTenantSid, SecurityUtil.getUserProfile().getTenantSid()); - lmq.eq(StaffEntity::getTabStatus, TabStatusEnums.NOSET.getValue()); - List staffEntities = staffRepository.selectList(lmq); - return EAIUtil.buildEAIResult(new JSONObject().fluentPut("wait_register_personnel",staffEntities)); - } -} diff --git a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/staff/StaffUpdateEAIService.java b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/staff/StaffUpdateEAIService.java index b2dda3d..56bd70f 100644 --- a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/staff/StaffUpdateEAIService.java +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/staff/StaffUpdateEAIService.java @@ -2,27 +2,40 @@ package com.digiwin.athena.app.service.staff; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.digiwin.app.service.DWEAIResult; -import com.digiwin.athena.app.infra.common.enums.TabStatusEnums; +import com.digiwin.athena.app.infra.common.enums.OptionEnums; +import com.digiwin.athena.app.infra.common.enums.StatusEnums; +import com.digiwin.athena.app.infra.common.utils.BeanCopyUtil; +import com.digiwin.athena.app.infra.dto.staff.StaffDTO; import com.digiwin.athena.app.infra.entity.StaffEntity; +import com.digiwin.athena.app.infra.repository.StaffRepository; import com.digiwin.athena.app.infra.service.StaffService; import com.digiwin.athena.opt.common.eai.EAIRequest; import com.digiwin.athena.opt.common.eai.EAIUtil; import com.digiwin.athena.opt.common.eai.service.AbsEAIService; +import com.digiwin.athena.opt.common.security.SecurityUtil; +import lombok.extern.log4j.Log4j2; +import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; +import org.springframework.util.StringUtils; 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; /** * @Auther: zhenggl * @Date: 2023/4/28 */ +@Service +@Log4j2 public class StaffUpdateEAIService extends AbsEAIService { + @Resource + private StaffRepository staffRepository; + @Resource private StaffService staffService; @@ -35,13 +48,32 @@ public class StaffUpdateEAIService extends AbsEAIService { public DWEAIResult execute(Map headers, String messageBody) throws Exception { //反序列化字段 EAIRequest request = new EAIRequest(messageBody); - List staffList = request.getObject("wait_register_personnel", new ArrayList().getClass()); - if (!CollectionUtils.isEmpty(staffList)){ + String option = request.getObject("option", String.class); + List staffList = request.getObject("wait_register_personnel", StaffUtil.LIST_DTO_STAFF); + //界面 + if (OptionEnums.BASIC.getValue().equals(option)){ + if (!CollectionUtils.isEmpty(staffList)){ + List staffEntities = BeanCopyUtil.copyList(staffList, StaffEntity.class); + //区分是否有id没有则新增 + Map> collect = staffEntities.stream().collect(Collectors.groupingBy(item -> StringUtils.isEmpty(item.getId()))); + List insert = collect.get(true); + staffService.saveBatch(insert); + List update = collect.get(false); + staffRepository.updateStaffList(update, SecurityUtil.getUserProfile().getTenantSid()); + } + }else if (OptionEnums.TASK.getValue().equals(option)){ + if (!CollectionUtils.isEmpty(staffList)){ + List staffEntities = BeanCopyUtil.copyList(staffList, StaffEntity.class); + staffRepository.updateStatusAndDate(staffEntities,SecurityUtil.getUserProfile().getTenantSid()); + } + }else if (OptionEnums.FLOW.getValue().equals(option)){ + List idList = staffList.stream().map(StaffDTO::getId).collect(Collectors.toList()); LambdaUpdateWrapper lmu = new LambdaUpdateWrapper<>(); - lmu.set(StaffEntity::getTabStatus, TabStatusEnums.COMPLETED.getValue()); - lmu.in(StaffEntity::getId,staffList); + lmu.set(StaffEntity::getStatus, StatusEnums.REPORTED.getValue()); + lmu.in(StaffEntity::getId,idList); staffService.update(lmu); } + return EAIUtil.buildEAIResult(new HashMap<>()); } } diff --git a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/staff/StaffUtil.java b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/staff/StaffUtil.java index ccbc564..2cbb944 100644 --- a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/staff/StaffUtil.java +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/staff/StaffUtil.java @@ -1,7 +1,7 @@ package com.digiwin.athena.app.service.staff; import com.alibaba.fastjson.TypeReference; -import com.digiwin.athena.app.infra.dto.order.StaffDTO; +import com.digiwin.athena.app.infra.dto.staff.StaffDTO; import java.util.List; @@ -20,7 +20,6 @@ public class StaffUtil { public static final String DEMO_WAIT_REGISTER_PERSONNEL_INFO_CREATE = "demo.wait.register.personnel.info.create"; public static final String DEMO_WAIT_REGISTER_PERSONNEL_INFO_UPDATE = "demo.wait.register.personnel.info.update"; public static final String DEMO_WAIT_REGISTER_PERSONNEL_INFO_GET = "demo.wait.register.personnel.info.get"; - public static final String DEMO_WAIT_REGISTER_PERSONNEL_INFO_QUERY = "demo.wait.register.personnel.info.query"; public static final TypeReference> LIST_DTO_STAFF = new TypeReference>() { };