@@ -0,0 +1,166 @@ | |||
package com.hp.user.client.entity; | |||
import java.io.Serializable; | |||
import java.util.Date; | |||
/** | |||
* <p> | |||
* 班组 | |||
* </p> | |||
* | |||
* @author yeqid | |||
* @since 2020-12-04 | |||
*/ | |||
public class ElectricianGroupVO implements Serializable { | |||
private static final long serialVersionUID = 1L; | |||
/** | |||
* 班组id | |||
*/ | |||
private String electricianGroupId; | |||
/** | |||
* 服务商id | |||
*/ | |||
private String serviceProviderId; | |||
/** | |||
* 组名 | |||
*/ | |||
private String groupName; | |||
/** | |||
* 组长 | |||
*/ | |||
private String groupLeader; | |||
private String leaderName; | |||
private String teamMemberName; | |||
/** | |||
* 组员id,多个用逗号隔开 | |||
*/ | |||
private String electricianId; | |||
/** | |||
* 备注 | |||
*/ | |||
private String remaks; | |||
/** | |||
* 更新时间 | |||
*/ | |||
private Date sysUpdateTime; | |||
/** | |||
* 更新者 | |||
*/ | |||
private String sysUpdater; | |||
/** | |||
* 创建时间 | |||
*/ | |||
private Date sysCreateTime; | |||
/** | |||
* 创建者 | |||
*/ | |||
private String sysCreator; | |||
public String getElectricianGroupId() { | |||
return electricianGroupId; | |||
} | |||
public void setElectricianGroupId(String electricianGroupId) { | |||
this.electricianGroupId = electricianGroupId; | |||
} | |||
public String getServiceProviderId() { | |||
return serviceProviderId; | |||
} | |||
public void setServiceProviderId(String serviceProviderId) { | |||
this.serviceProviderId = serviceProviderId; | |||
} | |||
public String getGroupName() { | |||
return groupName; | |||
} | |||
public void setGroupName(String groupName) { | |||
this.groupName = groupName; | |||
} | |||
public String getGroupLeader() { | |||
return groupLeader; | |||
} | |||
public void setGroupLeader(String groupLeader) { | |||
this.groupLeader = groupLeader; | |||
} | |||
public String getRemaks() { | |||
return remaks; | |||
} | |||
public void setRemaks(String remaks) { | |||
this.remaks = remaks; | |||
} | |||
public Date getSysUpdateTime() { | |||
return sysUpdateTime; | |||
} | |||
public void setSysUpdateTime(Date sysUpdateTime) { | |||
this.sysUpdateTime = sysUpdateTime; | |||
} | |||
public String getSysUpdater() { | |||
return sysUpdater; | |||
} | |||
public void setSysUpdater(String sysUpdater) { | |||
this.sysUpdater = sysUpdater; | |||
} | |||
public Date getSysCreateTime() { | |||
return sysCreateTime; | |||
} | |||
public void setSysCreateTime(Date sysCreateTime) { | |||
this.sysCreateTime = sysCreateTime; | |||
} | |||
public String getSysCreator() { | |||
return sysCreator; | |||
} | |||
public void setSysCreator(String sysCreator) { | |||
this.sysCreator = sysCreator; | |||
} | |||
public String getElectricianId() { | |||
return electricianId; | |||
} | |||
public void setElectricianId(String electricianId) { | |||
this.electricianId = electricianId; | |||
} | |||
public String getLeaderName() { | |||
return leaderName; | |||
} | |||
public void setLeaderName(String leaderName) { | |||
this.leaderName = leaderName; | |||
} | |||
public String getTeamMemberName() { | |||
return teamMemberName; | |||
} | |||
public void setTeamMemberName(String teamMemberName) { | |||
this.teamMemberName = teamMemberName; | |||
} | |||
} |
@@ -0,0 +1,46 @@ | |||
package com.hp.user.client.service; | |||
import com.hp.user.client.entity.DataResult; | |||
import com.hp.user.client.entity.ElectricianGroupVO; | |||
import com.hp.user.client.entity.PageQuery; | |||
import com.hp.user.client.entity.PageResult; | |||
import com.hp.user.client.entity.Result; | |||
public interface ElectricianGroupService { | |||
/** | |||
* 添加班组 | |||
* @param electricianGroup 班组信息 | |||
* @return | |||
*/ | |||
public Result createElectricianGroup(ElectricianGroupVO electricianGroup); | |||
/** | |||
* 修改班组 | |||
* @param electricianGroup 班组信息 | |||
* @return | |||
*/ | |||
public Result updateElectricianGroup(ElectricianGroupVO electricianGroup); | |||
/** | |||
* 根据id查询班组信息 | |||
* @param electricianGroupId 班组id | |||
* @return | |||
*/ | |||
public DataResult<ElectricianGroupVO> queryElectricianGroupById(String electricianGroupId); | |||
/** | |||
* 根据条件查询班组 | |||
* @param query 查询条件 | |||
* @return | |||
*/ | |||
public PageResult<ElectricianGroupVO> queryElectricianGroupByQuery(PageQuery query); | |||
/** | |||
* 删除班组 | |||
* @param electricianGroupId 班组id | |||
* @return | |||
*/ | |||
public Result deleteElectricianGroupById(String electricianGroupId); | |||
} |
@@ -36,5 +36,20 @@ public interface ElectricianService { | |||
* @return | |||
*/ | |||
public DataResult<ElectricianVO> queryElectricianById(String electricianId); | |||
/** | |||
* 批量修改电工状态 | |||
* @param electricianIds 电工id | |||
* @param status 状态 | |||
* @return | |||
*/ | |||
public Result updateStatusBatch(String[] electricianIds,Integer status); | |||
/** | |||
* 删除电工 | |||
* @param electricianId 电工id | |||
* @return | |||
*/ | |||
public Result deleteElectricianById(String electricianId); | |||
} |
@@ -68,4 +68,27 @@ public class ElectricianController { | |||
public DataResult<ElectricianVO> queryElectricianById(String electricianId) { | |||
return electricianService.queryElectricianById(electricianId); | |||
} | |||
/** | |||
* 批量修改员工状态 | |||
* @param electricianIds 电工ids | |||
* @param status 电工状态 | |||
* @return | |||
*/ | |||
@RequestMapping("/updateStatusBatch") | |||
@ApiOperation(value = "批量修改员工状态", notes = "批量修改员工状态", httpMethod = "POST") | |||
public Result updateStatusBatch(@RequestBody String[] electricianIds,Integer status) { | |||
return electricianService.updateStatusBatch(electricianIds, status); | |||
} | |||
/** | |||
* 删除电工 | |||
* @param electricianId 电工id | |||
* @return | |||
*/ | |||
@RequestMapping("/deleteElectricianById") | |||
@ApiOperation(value = "删除电工", notes = "删除电工", httpMethod = "POST") | |||
public Result deleteElectricianById(String electricianId) { | |||
return electricianService.deleteElectricianById(electricianId); | |||
} | |||
} |
@@ -0,0 +1,56 @@ | |||
package com.hp.user.service.controller; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.web.bind.annotation.PostMapping; | |||
import org.springframework.web.bind.annotation.RequestBody; | |||
import org.springframework.web.bind.annotation.RequestMapping; | |||
import org.springframework.web.bind.annotation.RestController; | |||
import com.hp.user.client.entity.DataResult; | |||
import com.hp.user.client.entity.ElectricianGroupVO; | |||
import com.hp.user.client.entity.PageQuery; | |||
import com.hp.user.client.entity.PageResult; | |||
import com.hp.user.client.entity.Result; | |||
import com.hp.user.client.service.ElectricianGroupService; | |||
import io.swagger.annotations.Api; | |||
import io.swagger.annotations.ApiOperation; | |||
@Api(tags = "班组") | |||
@RestController | |||
@RequestMapping("/electricianGroup") | |||
public class ElectricianGroupController { | |||
@Autowired | |||
private ElectricianGroupService electricianGroupService; | |||
@PostMapping("/createElectricianGroup") | |||
@ApiOperation(value ="添加班组", notes = "添加班组", httpMethod = "POST") | |||
public Result createElectricianGroup(@RequestBody ElectricianGroupVO electricianGroup) { | |||
return electricianGroupService.createElectricianGroup(electricianGroup); | |||
} | |||
@PostMapping("/updateElectricianGroup") | |||
@ApiOperation(value ="修改班组", notes = "修改班组", httpMethod = "POST") | |||
public Result updateElectricianGroup(@RequestBody ElectricianGroupVO electricianGroup) { | |||
return electricianGroupService.updateElectricianGroup(electricianGroup); | |||
} | |||
@ApiOperation(value ="根据id查询班组信息", notes = "根据id查询班组信息", httpMethod = "POST") | |||
@PostMapping("/queryElectricianGroupById") | |||
public DataResult<ElectricianGroupVO> queryElectricianGroupById(String electricianGroupId) { | |||
return electricianGroupService.queryElectricianGroupById(electricianGroupId); | |||
} | |||
@ApiOperation(value ="根据条件查询班组", notes = "根据条件查询班组", httpMethod = "POST") | |||
@PostMapping("/queryElectricianGroupByQuery") | |||
public PageResult<ElectricianGroupVO> queryElectricianGroupByQuery(@RequestBody PageQuery query) { | |||
return electricianGroupService.queryElectricianGroupByQuery(query); | |||
} | |||
@ApiOperation(value ="根据id删除班组", notes = "根据id删除班组", httpMethod = "POST") | |||
@PostMapping("/deleteElectricianGroupById") | |||
public Result deleteElectricianGroupById(String electricianGroupId) { | |||
return electricianGroupService.deleteElectricianGroupById(electricianGroupId); | |||
} | |||
} |
@@ -0,0 +1,22 @@ | |||
package com.hp.user.service.dao; | |||
import com.hp.user.service.entity.ElectricianElectricianGroup; | |||
import java.util.List; | |||
import org.apache.ibatis.annotations.Param; | |||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
/** | |||
* <p> | |||
* 电工和班组的关系 Mapper 接口 | |||
* </p> | |||
* @author yeqid | |||
* @since 2020-12-04 | |||
*/ | |||
public interface ElectricianElectricianGroupMapper extends BaseMapper<ElectricianElectricianGroup> { | |||
public void insertBatch(@Param("eegList") List<ElectricianElectricianGroup> electricianElectricianGroupList); | |||
} |
@@ -0,0 +1,30 @@ | |||
package com.hp.user.service.dao; | |||
import com.hp.user.service.entity.ElectricianGroup; | |||
import org.apache.ibatis.annotations.Param; | |||
import org.apache.ibatis.annotations.Select; | |||
import com.baomidou.mybatisplus.core.conditions.Wrapper; | |||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
import com.baomidou.mybatisplus.core.toolkit.Constants; | |||
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor; | |||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |||
/** | |||
* <p> | |||
* 班组 Mapper 接口 | |||
* </p> | |||
* | |||
* @author yeqid | |||
* @since 2020-12-04 | |||
*/ | |||
public interface ElectricianGroupMapper extends BaseMapper<ElectricianGroup> { | |||
@Select("select a.*,b.name as leaderName from tb_electrician_group a left join tb_electrician b on (a.group_leader = b.electrician_id) where a.electrician_group_id = #{id}") | |||
public ElectricianGroup queryElectricianGroupById(@Param("id") String electricianGroupId); | |||
@Select("select * from v_electrician_group ${ew.customSqlSegment} ") | |||
public <E> Page<ElectricianGroup> queryElectricianGroupByQuey(E page,@Param(Constants.WRAPPER) Wrapper<ElectricianGroup> queryWrapper); | |||
} |
@@ -91,7 +91,7 @@ public class Electrician implements Serializable { | |||
/** | |||
* 是否删除,0(default)/1:未删除/删除 | |||
*/ | |||
private Boolean sysDeleted; | |||
private Integer sysDeleted; | |||
public Electrician() {} | |||
@@ -0,0 +1,36 @@ | |||
package com.hp.user.service.entity; | |||
import com.baomidou.mybatisplus.annotation.TableName; | |||
import java.io.Serializable; | |||
import lombok.Data; | |||
import lombok.EqualsAndHashCode; | |||
import lombok.experimental.Accessors; | |||
/** | |||
* <p> | |||
* 电工和班组的关系 | |||
* </p> | |||
* | |||
* @author yeqid | |||
* @since 2020-12-04 | |||
*/ | |||
@Data | |||
@EqualsAndHashCode(callSuper = false) | |||
@Accessors(chain = true) | |||
@TableName("r_electrician_electrician_group") | |||
public class ElectricianElectricianGroup implements Serializable { | |||
private static final long serialVersionUID = 1L; | |||
/** | |||
* 班组id | |||
*/ | |||
private String electricianGroupId; | |||
/** | |||
* 电工id | |||
*/ | |||
private String electircianId; | |||
} |
@@ -0,0 +1,83 @@ | |||
package com.hp.user.service.entity; | |||
import com.baomidou.mybatisplus.annotation.TableId; | |||
import com.baomidou.mybatisplus.annotation.TableName; | |||
import java.io.Serializable; | |||
import java.util.Date; | |||
import lombok.Data; | |||
import lombok.EqualsAndHashCode; | |||
import lombok.experimental.Accessors; | |||
/** | |||
* <p> | |||
* 班组 | |||
* </p> | |||
* | |||
* @author yeqid | |||
* @since 2020-12-04 | |||
*/ | |||
@Data | |||
@Accessors(chain = true) | |||
@TableName("tb_electrician_group") | |||
public class ElectricianGroup implements Serializable { | |||
private static final long serialVersionUID = 1L; | |||
/** | |||
* 班组id | |||
*/ | |||
@TableId(value = "electrician_group_id") | |||
private String electricianGroupId; | |||
/** | |||
* 服务商id | |||
*/ | |||
private String serviceProviderId; | |||
/** | |||
* 组名 | |||
*/ | |||
private String groupName; | |||
/** | |||
* 组长 | |||
*/ | |||
private String groupLeader; | |||
/** | |||
* 组长名字 | |||
*/ | |||
private String leaderName; | |||
private String teamMemberName; | |||
private String electricianId; | |||
/** | |||
* 备注 | |||
*/ | |||
private String remaks; | |||
/** | |||
* 更新时间 | |||
*/ | |||
private Date sysUpdateTime; | |||
/** | |||
* 更新者 | |||
*/ | |||
private String sysUpdater; | |||
/** | |||
* 创建时间 | |||
*/ | |||
private Date sysCreateTime; | |||
/** | |||
* 创建者 | |||
*/ | |||
private String sysCreator; | |||
private Integer sysDeleted; | |||
} |
@@ -0,0 +1,231 @@ | |||
package com.hp.user.service.impl; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import org.apache.commons.lang3.StringUtils; | |||
import org.apache.dubbo.common.utils.CollectionUtils; | |||
import org.springframework.beans.BeanUtils; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import org.springframework.transaction.annotation.Transactional; | |||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
import com.baomidou.mybatisplus.core.toolkit.IdWorker; | |||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |||
import com.hp.user.client.entity.DataResult; | |||
import com.hp.user.client.entity.ElectricianGroupVO; | |||
import com.hp.user.client.entity.FuzzyQuery; | |||
import com.hp.user.client.entity.PageQuery; | |||
import com.hp.user.client.entity.PageResult; | |||
import com.hp.user.client.entity.Result; | |||
import com.hp.user.client.service.ElectricianGroupService; | |||
import com.hp.user.service.dao.ElectricianElectricianGroupMapper; | |||
import com.hp.user.service.dao.ElectricianGroupMapper; | |||
import com.hp.user.service.entity.ElectricianElectricianGroup; | |||
import com.hp.user.service.entity.ElectricianGroup; | |||
@Service | |||
public class ElectricianGroupServiceImpl implements ElectricianGroupService{ | |||
@Autowired | |||
private ElectricianGroupMapper electricianGroupMapper; | |||
@Autowired | |||
private ElectricianElectricianGroupMapper electricianElectricianGroupMapper; | |||
@Override | |||
@Transactional | |||
public Result createElectricianGroup(ElectricianGroupVO electricianGroupVO) { | |||
Result result = new Result(); | |||
try { | |||
String electricianId = electricianGroupVO.getElectricianId(); | |||
String serviceProviderId = electricianGroupVO.getServiceProviderId(); | |||
String name = electricianGroupVO.getGroupName(); | |||
String groupLeaderId = electricianGroupVO.getGroupLeader(); | |||
if(StringUtils.isBlank(electricianId)) { | |||
result.setCode("-1"); | |||
result.setMessage("组员Id不能为空!"); | |||
return result; | |||
} | |||
if(StringUtils.isBlank(serviceProviderId)) { | |||
result.setCode("-1"); | |||
result.setMessage("服务商Id不能为空!"); | |||
return result; | |||
} | |||
if(StringUtils.isBlank(name)) { | |||
result.setCode("-1"); | |||
result.setMessage("组名不能为空!"); | |||
return result; | |||
} | |||
if(StringUtils.isBlank(groupLeaderId)) { | |||
result.setCode("-1"); | |||
result.setMessage("组长Id不能为空!"); | |||
return result; | |||
} | |||
ElectricianGroup electricianGroup = new ElectricianGroup(); | |||
String electricianGroupId = IdWorker.getIdStr(); | |||
BeanUtils.copyProperties(electricianGroupVO, electricianGroup); | |||
electricianGroup.setElectricianGroupId(electricianGroupId); | |||
electricianGroupMapper.insert(electricianGroup); | |||
String[] electricianIds = StringUtils.split(electricianId,","); | |||
ElectricianElectricianGroup electricianElectricianGroup; | |||
List<ElectricianElectricianGroup> electricianElectricianGroupList = new ArrayList<>(); | |||
for(String id : electricianIds) { | |||
electricianElectricianGroup = new ElectricianElectricianGroup(); | |||
electricianElectricianGroup.setElectricianGroupId(electricianGroupId); | |||
electricianElectricianGroup.setElectircianId(id); | |||
electricianElectricianGroupList.add(electricianElectricianGroup); | |||
} | |||
// QueryWrapper<ElectricianElectricianGroup> queryWrapper = new QueryWrapper<ElectricianElectricianGroup>(); | |||
// queryWrapper.eq("electrician_group_id", electricianGroupId); | |||
// electricianElectricianGroupMapper.delete(queryWrapper); | |||
electricianElectricianGroupMapper.insertBatch(electricianElectricianGroupList); | |||
}catch(Exception e) { | |||
e.printStackTrace(); | |||
result.setCode("-1"); | |||
result.setMessage("系统内部错误"); | |||
} | |||
return result; | |||
} | |||
@Override | |||
public Result updateElectricianGroup(ElectricianGroupVO electricianGroupVO) { | |||
Result result = new Result(); | |||
try { | |||
String electricianId = electricianGroupVO.getElectricianId(); | |||
String serviceProviderId = electricianGroupVO.getServiceProviderId(); | |||
String name = electricianGroupVO.getGroupName(); | |||
String groupLeaderId = electricianGroupVO.getGroupLeader(); | |||
String electricianGroupId = electricianGroupVO.getElectricianGroupId(); | |||
if(StringUtils.isBlank(electricianGroupId)) { | |||
result.setCode("-1"); | |||
result.setMessage("班组Id不能为空!"); | |||
return result; | |||
} | |||
if(StringUtils.isBlank(electricianId)) { | |||
result.setCode("-1"); | |||
result.setMessage("组员Id不能为空!"); | |||
return result; | |||
} | |||
if(StringUtils.isBlank(serviceProviderId)) { | |||
result.setCode("-1"); | |||
result.setMessage("服务商Id不能为空!"); | |||
return result; | |||
} | |||
if(StringUtils.isBlank(name)) { | |||
result.setCode("-1"); | |||
result.setMessage("组名不能为空!"); | |||
return result; | |||
} | |||
if(StringUtils.isBlank(groupLeaderId)) { | |||
result.setCode("-1"); | |||
result.setMessage("组长Id不能为空!"); | |||
return result; | |||
} | |||
String[] electricianIds = StringUtils.split(electricianId,","); | |||
ElectricianElectricianGroup electricianElectricianGroup; | |||
List<ElectricianElectricianGroup> electricianElectricianGroupList = new ArrayList<>(); | |||
for(String id : electricianIds) { | |||
electricianElectricianGroup = new ElectricianElectricianGroup(); | |||
electricianElectricianGroup.setElectricianGroupId(electricianGroupId); | |||
electricianElectricianGroup.setElectircianId(id); | |||
electricianElectricianGroupList.add(electricianElectricianGroup); | |||
} | |||
QueryWrapper<ElectricianElectricianGroup> queryWrapper = new QueryWrapper<ElectricianElectricianGroup>(); | |||
queryWrapper.eq("electrician_group_id", electricianGroupId); | |||
electricianElectricianGroupMapper.delete(queryWrapper); | |||
ElectricianGroup electricianGroup = new ElectricianGroup(); | |||
BeanUtils.copyProperties(electricianGroupVO, electricianGroup); | |||
electricianGroupMapper.updateById(electricianGroup); | |||
electricianElectricianGroupMapper.insertBatch(electricianElectricianGroupList); | |||
}catch(Exception e) { | |||
result.setCode("-1"); | |||
result.setMessage("系统内部错误"); | |||
} | |||
return result; | |||
} | |||
@Override | |||
public DataResult<ElectricianGroupVO> queryElectricianGroupById(String electricianGroupId) { | |||
DataResult<ElectricianGroupVO> result = new DataResult<ElectricianGroupVO>(); | |||
try { | |||
ElectricianGroup electricianGroup = electricianGroupMapper.queryElectricianGroupById(electricianGroupId); | |||
ElectricianGroupVO electricianGroupVO = null; | |||
if(null != electricianGroup) { | |||
electricianGroupVO = new ElectricianGroupVO(); | |||
BeanUtils.copyProperties(electricianGroup, electricianGroupVO); | |||
} | |||
result.setData(electricianGroupVO); | |||
}catch(Exception e) { | |||
result.setCode("-1"); | |||
result.setMessage("系统内部错误"); | |||
} | |||
return result; | |||
} | |||
@Override | |||
public PageResult<ElectricianGroupVO> queryElectricianGroupByQuery(PageQuery query) { | |||
PageResult<ElectricianGroupVO> result = new PageResult<ElectricianGroupVO>(); | |||
try { | |||
Integer page = query.getPage(); | |||
Integer count = query.getSize(); | |||
if(page == null || page == 0) { | |||
return result; | |||
} | |||
QueryWrapper<ElectricianGroup> queryWrapper = new QueryWrapper<ElectricianGroup>(); | |||
List<FuzzyQuery> fuzzyList = query.getFuzzyList(); | |||
// queryWrapper.eq("sys_deleted", 0); | |||
if(CollectionUtils.isNotEmpty(fuzzyList)) { | |||
for(FuzzyQuery<?> fuzzy : fuzzyList) { | |||
queryWrapper.like(fuzzy.getColumn(), fuzzy.getValue()); | |||
} | |||
} | |||
List<ElectricianGroup> list = null; | |||
Long total = null; | |||
if(page == -1) { | |||
list = electricianGroupMapper.selectList(queryWrapper); | |||
}else { | |||
// Pagination pag1; | |||
// System.out.println(queryWrapper.getCustomSqlSegment()); | |||
Page<ElectricianGroup> electricianPage = electricianGroupMapper.queryElectricianGroupByQuey(new Page<>(page,count), queryWrapper); | |||
// Page<ElectricianGroup> electricianPage = electricianGroupMapper.selectPage(new Page<>(page,count), queryWrapper); | |||
list = electricianPage.getRecords(); | |||
total = electricianPage.getTotal(); | |||
result.setTotal(total); | |||
} | |||
List<ElectricianGroupVO> newList = new ArrayList<>(); | |||
ElectricianGroupVO electricianGroupVO; | |||
for(ElectricianGroup electricianGroup :list) { | |||
electricianGroupVO = new ElectricianGroupVO(); | |||
BeanUtils.copyProperties(electricianGroup, electricianGroupVO); | |||
newList.add(electricianGroupVO); | |||
} | |||
result.setDataList(newList); | |||
}catch(Exception e) { | |||
e.printStackTrace(); | |||
result.setCode("-1"); | |||
result.setMessage("系统内部错误"); | |||
} | |||
return result; | |||
} | |||
@Override | |||
public Result deleteElectricianGroupById(String electricianGroupId) { | |||
Result result = new Result(); | |||
try { | |||
ElectricianGroup electricianGroup = new ElectricianGroup(); | |||
electricianGroup.setElectricianGroupId(electricianGroupId); | |||
electricianGroup.setSysDeleted(1); | |||
electricianGroupMapper.updateById(electricianGroup); | |||
}catch(Exception e) { | |||
e.printStackTrace(); | |||
result.setCode("-1"); | |||
result.setMessage("系统内部错误"); | |||
} | |||
return result; | |||
} | |||
} |
@@ -12,6 +12,7 @@ import org.springframework.stereotype.Service; | |||
import org.springframework.transaction.annotation.Transactional; | |||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; | |||
import com.baomidou.mybatisplus.core.toolkit.IdWorker; | |||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |||
import com.hp.user.client.entity.DataResult; | |||
@@ -42,7 +43,7 @@ public class ElectricianServiceImpl implements ElectricianService{ | |||
try { | |||
String phone = electricianVO.getPhone(); | |||
String name = electricianVO.getName(); | |||
String serviceProviderId = electricianVO.getServiceProviderId(); | |||
if(StringUtils.isBlank(phone)) { | |||
result.setCode("-1"); | |||
result.setMessage("手机号不能为空!"); | |||
@@ -53,6 +54,11 @@ public class ElectricianServiceImpl implements ElectricianService{ | |||
result.setMessage("姓名能为空!"); | |||
return result; | |||
} | |||
if(StringUtils.isBlank(serviceProviderId)) { | |||
result.setCode("-1"); | |||
result.setMessage("服务商ID不能为空!"); | |||
return result; | |||
} | |||
Electrician electrician = new Electrician(); | |||
BeanUtils.copyProperties(electricianVO, electrician); | |||
String electricianId = IdWorker.getIdStr(); | |||
@@ -143,4 +149,38 @@ public class ElectricianServiceImpl implements ElectricianService{ | |||
return result; | |||
} | |||
@Override | |||
public Result updateStatusBatch(String[] electricianIds,Integer status) { | |||
Result result = new Result(); | |||
try { | |||
UpdateWrapper<Electrician> updateWrapper = new UpdateWrapper<Electrician>(); | |||
updateWrapper.in("electrician_id", electricianIds); | |||
Electrician electrician = new Electrician(); | |||
electrician.setStatus(status); | |||
electricianMapper.update(electrician, updateWrapper); | |||
}catch(Exception e) { | |||
result.setCode("-1"); | |||
result.setMessage("系统内部错误"); | |||
} | |||
return result; | |||
} | |||
@Override | |||
public Result deleteElectricianById(String electricianId) { | |||
Result result = new Result(); | |||
try { | |||
UpdateWrapper<Electrician> updateWrapper = new UpdateWrapper<Electrician>(); | |||
updateWrapper.eq("electrician_id", electricianId); | |||
Electrician electrician = new Electrician(); | |||
electrician.setSysDeleted(1); | |||
electricianMapper.update(electrician, updateWrapper); | |||
}catch(Exception e) { | |||
result.setCode("-1"); | |||
result.setMessage("系统内部错误"); | |||
} | |||
return result; | |||
} | |||
} |
@@ -0,0 +1,13 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||
<mapper namespace="com.hp.user.service.dao.ElectricianElectricianGroupMapper"> | |||
<insert id="insertBatch" parameterType="list"> | |||
insert into r_electrician_electrician_group(electrician_group_id,electircian_id) values | |||
<foreach collection="eegList" item="eeg" separator=","> | |||
(#{eeg.electricianGroupId},#{eeg.electircianId}) | |||
</foreach> | |||
</insert> | |||
</mapper> |
@@ -0,0 +1,5 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||
<mapper namespace="com.hp.user.service.dao.ElectricianGroupMapper"> | |||
</mapper> |
@@ -0,0 +1,53 @@ | |||
package com.hp.user.service; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import org.junit.Test; | |||
import org.junit.runner.RunWith; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.boot.test.context.SpringBootTest; | |||
import org.springframework.test.context.junit4.SpringRunner; | |||
import com.alibaba.fastjson.JSONObject; | |||
import com.hp.user.client.entity.ElectricianGroupVO; | |||
import com.hp.user.client.entity.FuzzyQuery; | |||
import com.hp.user.client.entity.PageQuery; | |||
import com.hp.user.client.entity.PageResult; | |||
import com.hp.user.client.service.ElectricianGroupService; | |||
import com.hp.user.client.service.ElectricianService; | |||
@SpringBootTest | |||
@RunWith(SpringRunner.class) | |||
public class ElectricianGroupTest { | |||
@Autowired | |||
private ElectricianGroupService electricianGroupService; | |||
@Autowired | |||
private ElectricianService electricianService; | |||
@Test | |||
public void queryElectricianGroupByQueyTest() { | |||
PageQuery query = new PageQuery(); | |||
// List<FuzzyQuery> list = new ArrayList<>(); | |||
// FuzzyQuery fuzzy = new FuzzyQuery(); | |||
// fuzzy.setColumn("team_member_name"); | |||
// fuzzy.setValue("ts"); | |||
// list.add(fuzzy); | |||
// query.setFuzzyList(list); | |||
query.setPage(1); | |||
query.setSize(4); | |||
PageResult<ElectricianGroupVO> result = electricianGroupService.queryElectricianGroupByQuery(query); | |||
System.out.print(JSONObject.toJSONString(result)); | |||
} | |||
@Test | |||
public void updateStatusBatch() { | |||
String[] ids = new String[]{"1334106189948010498","1334373867325583362"}; | |||
Integer status = 0; | |||
electricianService.updateStatusBatch(ids, status); | |||
} | |||
} |