diff --git a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/common/enums/StatusEnums.java b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/common/enums/StatusEnums.java new file mode 100644 index 0000000..2191e4c --- /dev/null +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/common/enums/StatusEnums.java @@ -0,0 +1,26 @@ +package com.digiwin.athena.app.infra.common.enums; + +/** + * @Auther: zhenggl + * @Date: 2023/4/28 + */ +public enum StatusEnums { + + + //待报道 + TOBEREPORTED(1), + //已完成 + REPORTED(2), + //未报道 + NOSHOW(3); + + private final Integer value; + + StatusEnums(Integer value) { + this.value = value; + } + + public Integer getValue() { + return value; + } +} diff --git a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/common/enums/TabStatusEnums.java b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/common/enums/TabStatusEnums.java new file mode 100644 index 0000000..15be41b --- /dev/null +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/common/enums/TabStatusEnums.java @@ -0,0 +1,25 @@ +package com.digiwin.athena.app.infra.common.enums; + +/** + * @Auther: zhenggl + * @Date: 2023/4/28 + */ +public enum TabStatusEnums { + //未设定 + NOSET(0), + //待处理 + PENDING(1), + //已完成 + COMPLETED(2); + + private final Integer value; + + TabStatusEnums(Integer value) { + this.value = value; + } + + public Integer getValue() { + return value; + } + +} diff --git a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/common/utils/BeanCopyUtil.java b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/common/utils/BeanCopyUtil.java new file mode 100644 index 0000000..52ad492 --- /dev/null +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/common/utils/BeanCopyUtil.java @@ -0,0 +1,66 @@ +package com.digiwin.athena.app.infra.common.utils; + +import com.digiwin.app.container.exceptions.DWRuntimeException; +import net.sf.cglib.beans.BeanCopier; +import net.sf.cglib.beans.BeanMap; +import org.springframework.objenesis.ObjenesisStd; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +public final class BeanCopyUtil { + private BeanCopyUtil() { + } + + private static ThreadLocal objenesisStdThreadLocal = ThreadLocal.withInitial(ObjenesisStd::new); + private static ConcurrentHashMap, ConcurrentHashMap, BeanCopier>> cache = new ConcurrentHashMap<>(); + + + public static T copy(Object source, Class target) { + return copy(source, objenesisStdThreadLocal.get().newInstance(target)); + } + + public static T copy(Object source, T target) { + BeanCopier beanCopier = getCacheBeanCopier(source.getClass(), target.getClass()); + beanCopier.copy(source, target, null); + return target; + } + + public static List copyList(List sources, Class target) { + if (sources.isEmpty()) { + return Collections.emptyList(); + } + + ArrayList list = new ArrayList<>(sources.size()); + ObjenesisStd objenesisStd = objenesisStdThreadLocal.get(); + for (Object source : sources) { + if (source == null) { + throw new DWRuntimeException("转换异常"); + } + T newInstance = objenesisStd.newInstance(target); + BeanCopier beanCopier = getCacheBeanCopier(source.getClass(), target); + beanCopier.copy(source, newInstance, null); + list.add(newInstance); + } + return list; + } + + public static T mapToBean(Map source, Class target) { + T bean = objenesisStdThreadLocal.get().newInstance(target); + BeanMap beanMap = BeanMap.create(bean); + beanMap.putAll(source); + return bean; + } + + public static Map beanToMap(T source) { + return BeanMap.create(source); + } + + private static BeanCopier getCacheBeanCopier(Class source, Class target) { + ConcurrentHashMap, BeanCopier> copierConcurrentHashMap = cache.computeIfAbsent(source, aClass -> new ConcurrentHashMap<>(16)); + return copierConcurrentHashMap.computeIfAbsent(target, aClass -> BeanCopier.create(source, target, false)); + } +} diff --git a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/common/utils/TransferUtil.java b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/common/utils/TransferUtil.java new file mode 100644 index 0000000..e6d7d35 --- /dev/null +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/common/utils/TransferUtil.java @@ -0,0 +1,105 @@ +package com.digiwin.athena.app.infra.common.utils; + +import com.alibaba.fastjson.JSONObject; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.JavaType; +import com.fasterxml.jackson.databind.ObjectMapper; +import lombok.extern.log4j.Log4j; +import org.apache.commons.collections.MapUtils; +import org.apache.commons.lang3.StringUtils; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @Author: xieps + * @Date: 2023/3/21 13:49 + * @Version 1.0 + * @Description + */ +@Log4j +public class TransferUtil { + + + public static final ObjectMapper objectMapper = new ObjectMapper(); + + + public static List string2List(String messageBody, Class clazz, String key) { + // 获取请求参数 + JSONObject parameter = TransferUtil.getAthenaParameter(messageBody); + return TransferUtil.convertString2List(parameter.toJSONString(), key, clazz); + } + + /** + * String 转model List + * @param param + * @param key + * @param clazz + * @param + * @return + */ + public static List convertString2List(String param, String key, Class clazz) { + Map paramMap = str2Map(param); + return getMapTs(paramMap, key, clazz); + } + + + + + /** + * String 转 map + * + * @param param + * @return + * @throws Exception + */ + public static Map str2Map(String param) { + if (StringUtils.isEmpty(param)) { + return new HashMap<>(); + } + try { + return objectMapper.readValue(param, new TypeReference>() { + }); + } catch (IOException e) { + log.error(e.getMessage()); + return new HashMap<>(); + } + } + + + /** + * map 取 model list + * + * @param map + * @return + * @throws Exception + */ + public static List getMapTs(Map map, String key, Class clazz) { + if (!MapUtils.isEmpty(map)) { + Object obj = map.get(key); + if (obj != null) { + ObjectMapper mapper = new ObjectMapper(); + try { + String objStr = mapper.writeValueAsString(obj); + JavaType type = mapper.getTypeFactory().constructCollectionType(List.class, clazz); + return mapper.readValue(objStr, type); + } catch (Exception ex) { + log.error(ex.getMessage()); + return new ArrayList<>(); + } + } + } + return new ArrayList<>(); + } + + + public static JSONObject getAthenaParameter(String messageBody){ + JSONObject stdData = JSONObject.parseObject(messageBody).getJSONObject("std_data"); + JSONObject parameter = stdData.getJSONObject("parameter"); + return parameter; + } + +} 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/order/StaffDTO.java new file mode 100644 index 0000000..c1cf70a --- /dev/null +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/dto/order/StaffDTO.java @@ -0,0 +1,73 @@ +package com.digiwin.athena.app.infra.dto.order; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * 人资报道对象 ca_cim_staff + * + * @author zhenggl + * @date 2023-04-28 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class StaffDTO +{ + + @SerializedName("id") + private Long id; + + /** 员工编号 */ + @SerializedName("employee_no") + private String employeeNo; + + /** 员工名称 */ + @SerializedName("employee_name") + private String employeeName; + + /** 员工英文名称 */ + @SerializedName("en_employee_name") + private String enEmployeeName; + + /** 手机号码 */ + @SerializedName("mobile_no") + private Long mobileNo; + + /** 电子邮件 */ + @SerializedName("email") + private String email; + + /** 状态 */ + @SerializedName("status") + private Integer status = 1; + + /** 数据状态 */ + @SerializedName("tab_status") + private Integer tabStatus = 0; + + /** 报道日期 */ + @SerializedName("register_date") + private Date registerDate; + + + /** 时间戳 */ + @SerializedName("timestamp") + private String timestamp; + + //==========冗余============== + @SerializedName("register_personnel_id") + public Long registerPersonnelId; + + + public StaffDTO(String employeeNo, Long registerPersonnelId) { + this.employeeNo = employeeNo; + this.registerPersonnelId = registerPersonnelId; + } +} 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 new file mode 100644 index 0000000..ea7d5ff --- /dev/null +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/entity/StaffEntity.java @@ -0,0 +1,69 @@ +package com.digiwin.athena.app.infra.entity; + +import java.util.Date; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.digiwin.athena.opt.persistence.domain.BaseMgrEntity; +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 人资报道对象 ca_cim_staff + * + * @author zhenggl + * @date 2023-04-28 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +@TableName(value = "ca_cim_staff", autoResultMap = true) +public class StaffEntity extends BaseMgrEntity +{ + private static final long serialVersionUID = 1L; + + /** $column.columnComment */ + private Long id; + + /** 员工编号 */ + @SerializedName("employee_no") + private String employeeNo; + + /** 员工名称 */ + @SerializedName("employee_name") + private String employeeName; + + /** 员工英文名称 */ + @SerializedName("en_employee_name") + private String enEmployeeName; + + /** 手机号码 */ + @SerializedName("mobile_no") + private Long mobileNo; + + /** 电子邮件 */ + @SerializedName("email") + private String email; + + /** 状态 */ + @SerializedName("status") + private Integer status; + + /** 数据状态 */ + @SerializedName("tab_status") + private Integer tabStatus; + + /** 报道日期 */ + @SerializedName("register_date") + private Date registerDate; + + + /** 时间戳 */ + @SerializedName("timestamp") + private String timestamp; + + +} 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 new file mode 100644 index 0000000..321d132 --- /dev/null +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/repository/StaffRepository.java @@ -0,0 +1,12 @@ +package com.digiwin.athena.app.infra.repository; + + +import com.digiwin.athena.app.infra.entity.StaffEntity; +import com.digiwin.athena.opt.persistence.repository.BaseRepository; + +/** + * @Auther: zhenggl + * @Date: 2023/4/28 + */ +public interface StaffRepository extends BaseRepository { +} diff --git a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/service/StaffService.java b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/service/StaffService.java new file mode 100644 index 0000000..bc6192e --- /dev/null +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/service/StaffService.java @@ -0,0 +1,7 @@ +package com.digiwin.athena.app.infra.service; + +import com.digiwin.athena.app.infra.entity.StaffEntity; +import com.digiwin.athena.opt.persistence.service.IBaseService; + +public interface StaffService extends IBaseService { +} diff --git a/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/service/impl/StaffServiceImpl.java b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/service/impl/StaffServiceImpl.java new file mode 100644 index 0000000..58c7eaa --- /dev/null +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/infra/service/impl/StaffServiceImpl.java @@ -0,0 +1,16 @@ +package com.digiwin.athena.app.infra.service.impl; + +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.persistence.service.impl.AbsBaseService; +import org.springframework.stereotype.Service; + +/** + * @author zhenggl + * create: 2023-04-28 + * Description: + */ +@Service +public class StaffServiceImpl extends AbsBaseService implements StaffService { +} 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 new file mode 100644 index 0000000..5fa1639 --- /dev/null +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/provider/StaffEAIService.java @@ -0,0 +1,55 @@ +package com.digiwin.athena.app.provider; + +import com.digiwin.app.service.DWEAIResult; +import com.digiwin.app.service.DWService; +import com.digiwin.app.service.eai.EAIService; +import com.digiwin.athena.app.service.staff.StaffUtil; + +import java.util.Map; + +/** + * @Auther: zhenggl + * @Date: 2023/4/28 + */ +public interface StaffEAIService extends DWService { + + /** + * 新人报道修改 + * @param headers + * @param messageBody + * @return + * @throws Exception + */ + @EAIService(id = StaffUtil.DEMO_WAIT_REGISTER_PERSONNEL_INFO_UPDATE) + DWEAIResult update(Map headers, String messageBody) throws Exception; + + /** + * 新人报道侦测 + * @param headers + * @param messageBody + * @return + * @throws Exception + */ + @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; + + /** + * 新人报道创建 + * @param headers + * @param messageBody + * @return + * @throws Exception + */ + @EAIService(id = StaffUtil.DEMO_WAIT_REGISTER_PERSONNEL_INFO_CREATE) + 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 new file mode 100644 index 0000000..688db87 --- /dev/null +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/provider/impl/StaffEAIServiceImpl.java @@ -0,0 +1,40 @@ +package com.digiwin.athena.app.provider.impl; + + +import com.digiwin.app.service.DWEAIResult; +import com.digiwin.athena.app.provider.StaffEAIService; +import com.digiwin.athena.app.service.staff.StaffUtil; +import com.digiwin.athena.opt.common.eai.service.EAIServiceContext; + +import javax.annotation.Resource; +import java.util.Map; + +/** + * @Auther: zhenggl + * @Date: 2023/4/28 + */ +public class StaffEAIServiceImpl implements StaffEAIService { + + @Resource + private EAIServiceContext eaiServiceContext; + + @Override + public DWEAIResult update(Map headers, String messageBody) throws Exception { + return eaiServiceContext.execute(StaffUtil.DEMO_WAIT_REGISTER_PERSONNEL_INFO_UPDATE,headers,messageBody); + } + + @Override + public DWEAIResult get(Map headers, String messageBody) throws Exception { + 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 { + return eaiServiceContext.execute(StaffUtil.DEMO_WAIT_REGISTER_PERSONNEL_INFO_CREATE,headers,messageBody); + } +} 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 new file mode 100644 index 0000000..80e844c --- /dev/null +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/staff/StaffCreateEAIService.java @@ -0,0 +1,69 @@ +package com.digiwin.athena.app.service.staff; + +import com.alibaba.fastjson.JSONObject; +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.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 org.springframework.util.CollectionUtils; + +import javax.annotation.Resource; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * @Auther: zhenggl + * @Date: 2023/4/28 + */ +public class StaffCreateEAIService extends AbsEAIService { + + @Resource + private StaffRepository staffRepository; + + @Resource + private StaffService staffService; + + @Override + public String getServiceName() { + return StaffUtil.DEMO_WAIT_REGISTER_PERSONNEL_INFO_CREATE; + } + + @Override + 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 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()); + 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 new file mode 100644 index 0000000..0aee092 --- /dev/null +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/staff/StaffGetEAIService.java @@ -0,0 +1,60 @@ +package com.digiwin.athena.app.service.staff; + +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.TabStatusEnums; +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.EAIUtil; +import com.digiwin.athena.opt.common.eai.service.AbsEAIService; +import com.digiwin.athena.opt.common.security.SecurityUtil; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; + +import javax.annotation.Resource; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * @Auther: zhenggl + * @Date: 2023/4/28 + */ +public class StaffGetEAIService extends AbsEAIService { + + @Resource + private StaffRepository staffRepository; + + @Resource + private StaffService staffService; + + @Override + public String getServiceName() { + return StaffUtil.DEMO_WAIT_REGISTER_PERSONNEL_INFO_GET; + } + + @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()); + }); + } + 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/StaffQueryEAIService.java b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/staff/StaffQueryEAIService.java new file mode 100644 index 0000000..ee4ffd6 --- /dev/null +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/staff/StaffQueryEAIService.java @@ -0,0 +1,42 @@ +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 new file mode 100644 index 0000000..b2dda3d --- /dev/null +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/staff/StaffUpdateEAIService.java @@ -0,0 +1,47 @@ +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.entity.StaffEntity; +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 org.springframework.util.CollectionUtils; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +/** + * @Auther: zhenggl + * @Date: 2023/4/28 + */ +public class StaffUpdateEAIService extends AbsEAIService { + + @Resource + private StaffService staffService; + + @Override + public String getServiceName() { + return StaffUtil.DEMO_WAIT_REGISTER_PERSONNEL_INFO_UPDATE; + } + + @Override + 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)){ + LambdaUpdateWrapper lmu = new LambdaUpdateWrapper<>(); + lmu.set(StaffEntity::getTabStatus, TabStatusEnums.COMPLETED.getValue()); + lmu.in(StaffEntity::getId,staffList); + 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 new file mode 100644 index 0000000..ccbc564 --- /dev/null +++ b/demo-athenaopt_backend/develop/src/main/java/com/digiwin/athena/app/service/staff/StaffUtil.java @@ -0,0 +1,27 @@ +package com.digiwin.athena.app.service.staff; + +import com.alibaba.fastjson.TypeReference; +import com.digiwin.athena.app.infra.dto.order.StaffDTO; + +import java.util.List; + +/** + * @Auther: zhenggl + * @Date: 2023/4/28 + */ +public class StaffUtil { + /** + * 新人报道增改查 + * @Author zhenggl + * @Param + * @return + * @Throw + */ + 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>() { + }; +}