Browse Source

修改保存复制人的逻辑

dev_power_axis
YUJT 3 years ago
parent
commit
85058348a8
  1. 5
      epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/axis/PowerAxisLeaderDTO.java
  2. 2
      epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/controller/PowerAxisLeaderController.java
  3. 49
      epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/service/impl/PowerAxisLeaderServiceImpl.java

5
epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/axis/PowerAxisLeaderDTO.java

@ -56,6 +56,11 @@ public class PowerAxisLeaderDTO implements Serializable {
*/
private String avatar;
/**
* 类别编码
*/
private String categoryCode;
/**
* 删除标识 0.未删除 1.已删除
*/

2
epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/controller/PowerAxisLeaderController.java

@ -12,10 +12,8 @@ import com.epmet.commons.tools.validator.group.AddGroup;
import com.epmet.commons.tools.validator.group.DefaultGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.plugin.power.dto.axis.PowerAxisLeaderDTO;
import com.epmet.plugin.power.dto.axis.form.PowerAxisStructLeaderFormDTO;
import com.epmet.plugin.power.dto.axis.result.PowerAxisSLeaderResultDTO;
import com.epmet.plugin.power.dto.axis.result.PowerAxisSimpleListDTO;
import com.epmet.plugin.power.modules.axis.dao.PowerAxisStructLeaderDao;
import com.epmet.plugin.power.modules.axis.excel.PowerAxisLeaderExcel;
import com.epmet.plugin.power.modules.axis.service.PowerAxisLeaderService;
import com.epmet.plugin.power.modules.axis.service.PowerAxisStructLeaderService;

49
epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/service/impl/PowerAxisLeaderServiceImpl.java

@ -1,5 +1,6 @@
package com.epmet.plugin.power.modules.axis.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
@ -13,6 +14,7 @@ import com.epmet.plugin.power.dto.axis.result.PowerAxisSimpleListDTO;
import com.epmet.plugin.power.modules.axis.dao.PowerAxisLeaderDao;
import com.epmet.plugin.power.modules.axis.dao.PowerAxisStructLeaderDao;
import com.epmet.plugin.power.modules.axis.entity.PowerAxisLeaderEntity;
import com.epmet.plugin.power.modules.axis.entity.PowerAxisStructEntity;
import com.epmet.plugin.power.modules.axis.entity.PowerAxisStructLeaderEntity;
import com.epmet.plugin.power.modules.axis.service.PowerAxisLeaderService;
import org.apache.commons.lang3.StringUtils;
@ -26,7 +28,7 @@ import java.util.List;
import java.util.Map;
/**
* 动力主轴领导人
* 动力主轴领导人
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-04-18
@ -53,8 +55,8 @@ public class PowerAxisLeaderServiceImpl extends BaseServiceImpl<PowerAxisLeaderD
return ConvertUtils.sourceToTarget(entityList, PowerAxisLeaderDTO.class);
}
private QueryWrapper<PowerAxisLeaderEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get(FieldConstant.ID_HUMP);
private QueryWrapper<PowerAxisLeaderEntity> getWrapper(Map<String, Object> params) {
String id = (String) params.get(FieldConstant.ID_HUMP);
QueryWrapper<PowerAxisLeaderEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id);
@ -73,12 +75,10 @@ public class PowerAxisLeaderServiceImpl extends BaseServiceImpl<PowerAxisLeaderD
public void save(PowerAxisLeaderDTO dto) {
PowerAxisLeaderEntity entity = ConvertUtils.sourceToTarget(dto, PowerAxisLeaderEntity.class);
boolean i = insert(entity);
if(i){
PowerAxisStructLeaderEntity leaderEntity = new PowerAxisStructLeaderEntity();
leaderEntity.setCustomerId(dto.getCustomerId());
leaderEntity.setLeaderId(entity.getId());
leaderEntity.setStructReferenceId(dto.getStructReferenceId());
powerAxisStructLeaderDao.insert(leaderEntity);
if (i) {
addStructLeaderRelation(
dto.getCustomerId(), dto.getStructReferenceId(), entity.getId(), dto.getCategoryCode()
);
}
}
@ -88,12 +88,11 @@ public class PowerAxisLeaderServiceImpl extends BaseServiceImpl<PowerAxisLeaderD
PowerAxisLeaderEntity entity = ConvertUtils.sourceToTarget(dto, PowerAxisLeaderEntity.class);
boolean i = updateById(entity);
if (i) {
// todo 关联表,先删除(by structReferenceId),再插入
PowerAxisStructLeaderEntity leaderEntity = new PowerAxisStructLeaderEntity();
leaderEntity.setLeaderId(entity.getId());
leaderEntity.setStructReferenceId(dto.getStructReferenceId());
leaderEntity.setCustomerId(dto.getCustomerId());
powerAxisStructLeaderDao.updateById(leaderEntity);
// 关联表,先删除(by structReferenceId),再插入
delStructLeaderRelation(dto.getCustomerId(), dto.getStructReferenceId());
addStructLeaderRelation(
dto.getCustomerId(), dto.getStructReferenceId(), entity.getId(), dto.getCategoryCode()
);
}
}
@ -106,15 +105,27 @@ public class PowerAxisLeaderServiceImpl extends BaseServiceImpl<PowerAxisLeaderD
@Override
public List<PowerAxisSimpleListDTO> getSimpleList(List<String> ids) {
List<PowerAxisSimpleListDTO> list = baseDao.getSimpleList(ids);
return list;
return baseDao.getSimpleList(ids);
}
@Override
public PowerAxisLeaderDetailResultDTO getLeaderDetail(PowerAxisLeaderDetailFormDTO form) {
PowerAxisLeaderDetailResultDTO dto = baseDao.getLeaderDetail(form);
return dto;
return baseDao.getLeaderDetail(form);
}
private void delStructLeaderRelation(String customerId, String structId) {
LambdaQueryWrapper<PowerAxisStructLeaderEntity> lqw = new LambdaQueryWrapper<>();
lqw.eq(PowerAxisStructLeaderEntity::getStructReferenceId, structId)
.eq(PowerAxisStructLeaderEntity::getCustomerId, customerId);
powerAxisStructLeaderDao.delete(lqw);
}
private void addStructLeaderRelation(String customerId, String structId, String leaderId, String categoryCode) {
PowerAxisStructLeaderEntity structLeader = new PowerAxisStructLeaderEntity();
structLeader.setCustomerId(customerId);
structLeader.setLeaderId(leaderId);
structLeader.setStructReferenceId(structId);
structLeader.setCategoryCode(categoryCode);
powerAxisStructLeaderDao.insert(structLeader);
}
}
Loading…
Cancel
Save