|
@@ -0,0 +1,121 @@
|
|
|
+package cn.cslg.pas.service.business;
|
|
|
+
|
|
|
+import cn.cslg.pas.common.dto.MergePersonQueryDTO;
|
|
|
+import cn.cslg.pas.common.model.cronModel.PersonnelVO;
|
|
|
+import cn.cslg.pas.common.model.cronModel.Records;
|
|
|
+import cn.cslg.pas.common.utils.CacheUtils;
|
|
|
+import cn.cslg.pas.common.utils.LoginUtils;
|
|
|
+import cn.cslg.pas.common.vo.business.MergePersonIdVO;
|
|
|
+import cn.cslg.pas.common.vo.business.MergePersonQueryVO;
|
|
|
+import cn.cslg.pas.common.vo.business.MergePersonVO;
|
|
|
+import cn.cslg.pas.domain.BaseEntity;
|
|
|
+import cn.cslg.pas.domain.business.FollowUp;
|
|
|
+import cn.cslg.pas.domain.business.MergePerson;
|
|
|
+import cn.cslg.pas.exception.UnLoginException;
|
|
|
+import cn.cslg.pas.mapper.MergePersonMapper;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import cn.hutool.core.util.PageUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.github.pagehelper.PageHelper;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Propagation;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @Author xiexiang
|
|
|
+ * @Date 2024/01/02
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@Service
|
|
|
+public class MergePersonService extends ServiceImpl<MergePersonMapper, MergePerson> {
|
|
|
+ @Autowired
|
|
|
+ private CacheUtils cacheUtils;
|
|
|
+ @Autowired
|
|
|
+ private LoginUtils loginUtils;
|
|
|
+ @Autowired
|
|
|
+ private MergePersonMapper mergePersonMapper;
|
|
|
+
|
|
|
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
|
|
|
+ public Integer mergePerson(MergePersonVO vo) {
|
|
|
+ //获取登陆人信息 用于设置创建人
|
|
|
+ PersonnelVO personnelVO = new PersonnelVO();
|
|
|
+ try {
|
|
|
+ personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new UnLoginException("未登录");
|
|
|
+ }
|
|
|
+ MergePerson person = new MergePerson();
|
|
|
+ BeanUtils.copyProperties(vo, person);
|
|
|
+ person.setCreateId(personnelVO.getId());
|
|
|
+ person.setCreateTime(new Date());
|
|
|
+ person.insert();
|
|
|
+ //todo 关联相关专利
|
|
|
+
|
|
|
+ return person.getId();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
|
|
|
+ public Integer updateMergePerson(MergePersonVO vo) {
|
|
|
+ //获取登陆人信息 用于设置创建人
|
|
|
+ PersonnelVO personnelVO = new PersonnelVO();
|
|
|
+ try {
|
|
|
+ personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new UnLoginException("未登录");
|
|
|
+ }
|
|
|
+ MergePerson person = this.getById(vo.getId());
|
|
|
+ if (ObjectUtil.isNotEmpty(person)) {
|
|
|
+ BeanUtils.copyProperties(vo, person);
|
|
|
+ person.setCreateId(personnelVO.getId());
|
|
|
+ person.setCreateTime(new Date());
|
|
|
+ person.updateById();
|
|
|
+ //todo 关联相关专利
|
|
|
+ } else {
|
|
|
+ person = new MergePerson();
|
|
|
+ }
|
|
|
+ return person.getId();
|
|
|
+ }
|
|
|
+
|
|
|
+ public Records selectMergePersonList(MergePersonQueryVO vo) {
|
|
|
+ List<MergePersonQueryDTO> list = new ArrayList<>();
|
|
|
+ IPage<MergePerson> page = new Page<>(vo.getPageNum(), vo.getPageSize());
|
|
|
+ LambdaQueryWrapper<MergePerson> wrapper = new LambdaQueryWrapper<MergePerson>()
|
|
|
+ .eq(StringUtils.isNotEmpty(vo.getCountry()), MergePerson::getCountry, vo.getCountry())
|
|
|
+ .like(StringUtils.isNotEmpty(vo.getName()), MergePerson::getName, vo.getName());
|
|
|
+ IPage<MergePerson> record = mergePersonMapper.selectPage(page, wrapper);
|
|
|
+ for (MergePerson person : record.getRecords()) {
|
|
|
+ MergePersonQueryDTO dto = new MergePersonQueryDTO();
|
|
|
+ dto.setId(person.getId());
|
|
|
+ dto.setName(person.getName());
|
|
|
+ dto.setAddress(person.getAddress());
|
|
|
+ dto.setCountry(person.getCountry());
|
|
|
+ dto.setRemark(person.getRemark());
|
|
|
+ dto.setCreateTime(person.getCreateTime());
|
|
|
+ list.add(dto);
|
|
|
+ }
|
|
|
+ Records records = new Records();
|
|
|
+ records.setCurrent(record.getCurrent());
|
|
|
+ records.setSize(record.getSize());
|
|
|
+ records.setData(list);
|
|
|
+ records.setTotal(record.getTotal());
|
|
|
+ return records;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Integer delMergePerson(MergePersonIdVO vo) {
|
|
|
+ LambdaQueryWrapper<MergePerson> wrapper = new LambdaQueryWrapper<MergePerson>()
|
|
|
+ .eq(BaseEntity::getId, vo.getId());
|
|
|
+ this.remove(wrapper);
|
|
|
+ return vo.getId();
|
|
|
+ }
|
|
|
+}
|