基础报工-班组

highway
A0010407 1 year ago
parent 9771ab2ff3
commit e4b4118504

@ -2,6 +2,8 @@ package com.op.wms.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.op.wms.domain.BaseTeamUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;

@ -0,0 +1,109 @@
package com.op.wms.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.op.common.log.annotation.Log;
import com.op.common.log.enums.BusinessType;
import com.op.common.security.annotation.RequiresPermissions;
import com.op.wms.domain.BaseTeamUser;
import com.op.wms.service.IBaseTeamUserService;
import com.op.common.core.web.controller.BaseController;
import com.op.common.core.web.domain.AjaxResult;
import com.op.common.core.utils.poi.ExcelUtil;
import com.op.common.core.web.page.TableDataInfo;
/**
* Controller
*
* @author Open Platform
* @date 2023-08-29
*/
@RestController
@RequestMapping("/teamUser")
public class BaseTeamUserController extends BaseController {
@Autowired
private IBaseTeamUserService baseTeamUserService;
/**
*
*/
@RequiresPermissions("wms:teamUser:list")
@GetMapping("/list")
public TableDataInfo list(BaseTeamUser baseTeamUser) {
startPage();
List<BaseTeamUser> list = baseTeamUserService.selectBaseTeamUserList(baseTeamUser);
return getDataTable(list);
}
/**
*
*/
@RequiresPermissions("wms:teamUser:listTeamMembers")
@GetMapping("/listTeamMembers")
public TableDataInfo listTeamMembers(BaseTeamUser baseTeamUser) {
startPage();
List<BaseTeamUser> list = baseTeamUserService.selectTeamMembers(baseTeamUser);
return getDataTable(list);
}
/**
*
*/
@RequiresPermissions("wms:teamUser:export")
@Log(title = "班组人员", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, BaseTeamUser baseTeamUser) {
List<BaseTeamUser> list = baseTeamUserService.selectBaseTeamUserList(baseTeamUser);
ExcelUtil<BaseTeamUser> util = new ExcelUtil<BaseTeamUser>(BaseTeamUser.class);
util.exportExcel(response, list, "班组人员数据");
}
/**
*
*/
@RequiresPermissions("wms:teamUser:query")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") String id) {
return success(baseTeamUserService.selectBaseTeamUserById(id));
}
/**
*
*/
@RequiresPermissions("wms:teamUser:add")
@Log(title = "班组人员", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody BaseTeamUser baseTeamUser) {
return toAjax(baseTeamUserService.insertBaseTeamUser(baseTeamUser));
}
/**
*
*/
@RequiresPermissions("wms:teamUser:edit")
@Log(title = "班组人员", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody BaseTeamUser baseTeamUser) {
return toAjax(baseTeamUserService.updateBaseTeamUser(baseTeamUser));
}
/**
*
*/
@RequiresPermissions("wms:teamUser:remove")
@Log(title = "班组人员", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable String[] ids) {
return toAjax(baseTeamUserService.deleteBaseTeamUserByIds(ids));
}
}

@ -1,6 +1,8 @@
package com.op.wms.domain;
import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
@ -113,6 +115,26 @@ public class BaseTeamT extends BaseEntity {
@Excel(name = "班组类型")
private String teamType;
private List<String> rightData;
public void setRightData(List<String> rightData) {
this.rightData = rightData;
}
public List<String> getRightData() {
return rightData;
}
private List<BaseTeamUser> selectedData;
public void setSelectedData(List<BaseTeamUser> selectedData) {
this.selectedData = selectedData;
}
public List<BaseTeamUser> getSelectedData() {
return selectedData;
}
public void setTeamType(String teamType) {
this.teamType = teamType;
}

@ -0,0 +1,86 @@
package com.op.wms.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.op.common.core.annotation.Excel;
import com.op.common.core.web.domain.BaseEntity;
/**
* base_team_user
*
* @author Open Platform
* @date 2023-08-29
*/
public class BaseTeamUser extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 主键 */
private String id;
/** 班组id */
@Excel(name = "班组id")
private String teamId;
/** 班组编码 */
@Excel(name = "班组编码")
private String teamCode;
/** 人员id */
@Excel(name = "人员id")
private String userId;
/** 人员名字 */
@Excel(name = "人员名字")
private String userName;
public void setId(String id) {
this.id = id;
}
public String getId() {
return id;
}
public void setTeamId(String teamId) {
this.teamId = teamId;
}
public String getTeamId() {
return teamId;
}
public void setTeamCode(String teamCode) {
this.teamCode = teamCode;
}
public String getTeamCode() {
return teamCode;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getUserId() {
return userId;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getUserName() {
return userName;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("teamId", getTeamId())
.append("teamCode", getTeamCode())
.append("userId", getUserId())
.append("userName", getUserName())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.toString();
}
}

@ -2,7 +2,9 @@ package com.op.wms.mapper;
import java.util.List;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.op.wms.domain.BaseTeamT;
import com.op.wms.domain.BaseTeamUser;
/**
* Mapper
@ -41,6 +43,7 @@ public interface BaseTeamTMapper {
* @param baseTeamT
* @return
*/
@DS("#header.poolName")
public int updateBaseTeamT(BaseTeamT baseTeamT);
/**

@ -0,0 +1,71 @@
package com.op.wms.mapper;
import java.util.List;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.op.wms.domain.BaseTeamUser;
/**
* Mapper
*
* @author Open Platform
* @date 2023-08-29
*/
public interface BaseTeamUserMapper {
/**
*
*
* @param id
* @return
*/
public BaseTeamUser selectBaseTeamUserById(String id);
/**
*
*
* @param baseTeamUser
* @return
*/
public List<BaseTeamUser> selectBaseTeamUserList(BaseTeamUser baseTeamUser);
/**
*
*
* @param baseTeamUser
* @return
*/
public int insertBaseTeamUser(BaseTeamUser baseTeamUser);
/**
*
*
* @param baseTeamUser
* @return
*/
public int updateBaseTeamUser(BaseTeamUser baseTeamUser);
/**
*
*
* @param id
* @return
*/
public int deleteBaseTeamUserById(String id);
/**
*
*
* @param ids
* @return
*/
public int deleteBaseTeamUserByIds(String[] ids);
//查询人员
public List<BaseTeamUser> selectTeamMembers(BaseTeamUser baseTeamUser);
//查询人员对应名字
public List<String> selectTeamMembersIds(BaseTeamUser baseTeamUser);
//查询人员ID
public String selectId(BaseTeamUser baseTeamUser);
}

@ -2,6 +2,7 @@ package com.op.wms.service;
import java.util.List;
import com.op.wms.domain.BaseTeamT;
import com.op.wms.domain.BaseTeamUser;
/**
* Service

@ -0,0 +1,62 @@
package com.op.wms.service;
import java.util.List;
import com.op.wms.domain.BaseTeamUser;
/**
* Service
*
* @author Open Platform
* @date 2023-08-29
*/
public interface IBaseTeamUserService {
/**
*
*
* @param id
* @return
*/
public BaseTeamUser selectBaseTeamUserById(String id);
/**
*
*
* @param baseTeamUser
* @return
*/
public List<BaseTeamUser> selectBaseTeamUserList(BaseTeamUser baseTeamUser);
/**
*
*
* @param baseTeamUser
* @return
*/
public int insertBaseTeamUser(BaseTeamUser baseTeamUser);
/**
*
*
* @param baseTeamUser
* @return
*/
public int updateBaseTeamUser(BaseTeamUser baseTeamUser);
/**
*
*
* @param ids
* @return
*/
public int deleteBaseTeamUserByIds(String[] ids);
/**
*
*
* @param id
* @return
*/
public int deleteBaseTeamUserById(String id);
public List<BaseTeamUser> selectTeamMembers(BaseTeamUser baseTeamUser);
}

@ -1,10 +1,14 @@
package com.op.wms.service.impl;
import java.util.ArrayList;
import java.util.List;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.op.common.core.utils.DateUtils;
import com.op.common.core.utils.uuid.IdUtils;
import com.op.common.security.utils.SecurityUtils;
import com.op.wms.domain.BaseTeamUser;
import com.op.wms.mapper.BaseTeamUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.op.wms.mapper.BaseTeamTMapper;
@ -22,6 +26,9 @@ public class BaseTeamTServiceImpl implements IBaseTeamTService {
@Autowired
private BaseTeamTMapper baseTeamTMapper;
@Autowired
private BaseTeamUserMapper baseTeamUserMapper;
/**
*
*
@ -31,7 +38,12 @@ public class BaseTeamTServiceImpl implements IBaseTeamTService {
@Override
@DS("#header.poolName")
public BaseTeamT selectBaseTeamTByTeamId(String teamId) {
return baseTeamTMapper.selectBaseTeamTByTeamId(teamId);
BaseTeamUser baseTeamUser = new BaseTeamUser();
baseTeamUser.setTeamId(teamId);
List<BaseTeamUser> baseTeamUser1 = baseTeamUserMapper.selectBaseTeamUserList(baseTeamUser);
BaseTeamT baseTeamT = baseTeamTMapper.selectBaseTeamTByTeamId(teamId);
baseTeamT.setSelectedData(baseTeamUser1);
return baseTeamT;
}
/**
@ -71,6 +83,30 @@ public class BaseTeamTServiceImpl implements IBaseTeamTService {
public int updateBaseTeamT(BaseTeamT baseTeamT) {
baseTeamT.setLastUpdateDate(DateUtils.getNowDate());
baseTeamT.setLastUpdateBy(SecurityUtils.getUsername());
for(int i = 0;i<baseTeamT.getRightData().size();i++){
BaseTeamUser baseTeamUser = new BaseTeamUser();
baseTeamUser.setTeamId(baseTeamT.getTeamId());
baseTeamUser.setTeamCode(baseTeamT.getTeamCode());
List<String> list = new ArrayList<>();
list = baseTeamT.getRightData();
String userId = list.get(i);
baseTeamUser.setUserId(userId);
BaseTeamUser baseTeamUser1 = new BaseTeamUser();
List<String> members = baseTeamUserMapper.selectTeamMembersIds(baseTeamUser1);
boolean bool = members.contains(userId);
if(bool == true){
//倒查id
String id = baseTeamUserMapper.selectId(baseTeamUser);
baseTeamUser.setUpdateTime(DateUtils.getNowDate());
baseTeamUser.setUpdateBy(SecurityUtils.getUsername());
baseTeamUserMapper.updateBaseTeamUser(baseTeamUser);
}else{
baseTeamUser.setCreateBy(SecurityUtils.getUsername());
baseTeamUser.setCreateTime(DateUtils.getNowDate());
baseTeamUser.setId(IdUtils.fastSimpleUUID());
baseTeamUserMapper.insertBaseTeamUser(baseTeamUser);
}
}
return baseTeamTMapper.updateBaseTeamT(baseTeamT);
}

@ -0,0 +1,103 @@
package com.op.wms.service.impl;
import java.util.List;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.op.common.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.op.wms.mapper.BaseTeamUserMapper;
import com.op.wms.domain.BaseTeamUser;
import com.op.wms.service.IBaseTeamUserService;
/**
* Service
*
* @author Open Platform
* @date 2023-08-29
*/
@Service
public class BaseTeamUserServiceImpl implements IBaseTeamUserService {
@Autowired
private BaseTeamUserMapper baseTeamUserMapper;
/**
*
*
* @param id
* @return
*/
@Override
public BaseTeamUser selectBaseTeamUserById(String id) {
return baseTeamUserMapper.selectBaseTeamUserById(id);
}
/**
*
*
* @param baseTeamUser
* @return
*/
@Override
public List<BaseTeamUser> selectBaseTeamUserList(BaseTeamUser baseTeamUser) {
return baseTeamUserMapper.selectBaseTeamUserList(baseTeamUser);
}
/**
*
*
* @param baseTeamUser
* @return
*/
@Override
public int insertBaseTeamUser(BaseTeamUser baseTeamUser) {
baseTeamUser.setCreateTime(DateUtils.getNowDate());
return baseTeamUserMapper.insertBaseTeamUser(baseTeamUser);
}
/**
*
*
* @param baseTeamUser
* @return
*/
@Override
public int updateBaseTeamUser(BaseTeamUser baseTeamUser) {
baseTeamUser.setUpdateTime(DateUtils.getNowDate());
return baseTeamUserMapper.updateBaseTeamUser(baseTeamUser);
}
/**
*
*
* @param ids
* @return
*/
@Override
public int deleteBaseTeamUserByIds(String[] ids) {
return baseTeamUserMapper.deleteBaseTeamUserByIds(ids);
}
/**
*
*
* @param id
* @return
*/
@Override
public int deleteBaseTeamUserById(String id) {
return baseTeamUserMapper.deleteBaseTeamUserById(id);
}
/**
*
*
* @param baseTeamUser
* @return
*/
@Override
@DS("#master")
public List<BaseTeamUser> selectTeamMembers(BaseTeamUser baseTeamUser){
return baseTeamUserMapper.selectTeamMembers(baseTeamUser);
}
}

@ -0,0 +1,113 @@
<?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.op.wms.mapper.BaseTeamUserMapper">
<resultMap type="BaseTeamUser" id="BaseTeamUserResult">
<result property="id" column="id" />
<result property="teamId" column="team_id" />
<result property="teamCode" column="team_code" />
<result property="userId" column="user_id" />
<result property="userName" column="user_name" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectBaseTeamUserVo">
select id, team_id, team_code, user_id, user_name, create_by, create_time, update_by, update_time from base_team_user
</sql>
<select id="selectBaseTeamUserList" parameterType="BaseTeamUser" resultMap="BaseTeamUserResult">
<include refid="selectBaseTeamUserVo"/>
<where>
<if test="teamId != null and teamId != ''"> and team_id = #{teamId}</if>
<if test="teamCode != null and teamCode != ''"> and team_code = #{teamCode}</if>
<if test="userId != null and userId != ''"> and user_id = #{userId}</if>
<if test="userName != null and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>
</where>
</select>
<select id="selectBaseTeamUserById" parameterType="String" resultMap="BaseTeamUserResult">
<include refid="selectBaseTeamUserVo"/>
where id = #{id}
</select>
<insert id="insertBaseTeamUser" parameterType="BaseTeamUser">
insert into base_team_user
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="teamId != null and teamId != ''">team_id,</if>
<if test="teamCode != null">team_code,</if>
<if test="userId != null">user_id,</if>
<if test="userName != null">user_name,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="teamId != null and teamId != ''">#{teamId},</if>
<if test="teamCode != null">#{teamCode},</if>
<if test="userId != null">#{userId},</if>
<if test="userName != null">#{userName},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateBaseTeamUser" parameterType="BaseTeamUser">
update base_team_user
<trim prefix="SET" suffixOverrides=",">
<if test="teamId != null and teamId != ''">team_id = #{teamId},</if>
<if test="teamCode != null">team_code = #{teamCode},</if>
<if test="userId != null">user_id = #{userId},</if>
<if test="userName != null">user_name = #{userName},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteBaseTeamUserById" parameterType="String">
delete from base_team_user where id = #{id}
</delete>
<delete id="deleteBaseTeamUserByIds" parameterType="String">
delete from base_team_user where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="selectTeamMembers" parameterType="BaseTeamUser" resultMap="BaseTeamUserResult">
select user_id,user_name
from sys_user
</select>
<select id="selectTeamMembersNameById" parameterType="BaseTeamUser" resultType="java.lang.String">
select user_name
from sys_user su
where su.id = #{id}
</select>
<select id="selectTeamMembersIds" parameterType="BaseTeamUser" resultType="java.lang.String">
select user_id
from base_team_user
</select>
<select id="selectId" parameterType="BaseTeamUser" resultType="java.lang.String">
select id
from base_team_user
where user_id = #{userId}
and team_id = #{teamId}
</select>
</mapper>
Loading…
Cancel
Save