新火炬后端单体项目初始化代码
cuijian
2025-06-28 b231e345300e34c9c918cbd7e2db44d334eb4937
供应商管理、线边库管理、产线人员绑定
已添加1个文件
已修改11个文件
214 ■■■■■ 文件已修改
src/main/java/org/jeecg/modules/base/controller/LineSideWarehouseController.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/base/controller/SupplierController.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/base/entity/LineSideWarehouse.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/base/entity/ShiftGroup.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/base/entity/UserFactory.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/base/model/FactoryTreeModel.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/system/controller/SysUserController.java 96 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/system/mapper/SysUserMapper.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/system/mapper/xml/SysUserMapper.xml 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/system/service/ISysUserService.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/system/vo/SysUserFactoryVO.java 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/base/controller/LineSideWarehouseController.java
@@ -10,9 +10,11 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.base.entity.LineSideWarehouse;
import org.jeecg.modules.base.entity.Supplier;
import org.jeecg.modules.base.service.ILineSideWarehouseService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -174,4 +176,18 @@
        return super.importExcel(request, response, LineSideWarehouse.class);
    }
     @AutoLog(value = "线边库-启用&禁用")
     @ApiOperation(value = "线边库-启用&禁用", notes = "线边库-启用&禁用")
     @PutMapping(value = "/active")
     public Result<?> active(@RequestParam(name = "id", required = true) String id) {
         LineSideWarehouse lineSideWarehouse = lineSideWarehouseService.getById(id);
         if (CommonConstant.STATUS_1.equals(lineSideWarehouse.getWarehouseStatus())) {
             lineSideWarehouse.setWarehouseStatus(CommonConstant.STATUS_0);
         } else {
             lineSideWarehouse.setWarehouseStatus(CommonConstant.STATUS_1);
         }
         lineSideWarehouseService.updateById(lineSideWarehouse);
         return Result.ok("操作成功!");
     }
}
src/main/java/org/jeecg/modules/base/controller/SupplierController.java
@@ -10,6 +10,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.base.entity.Supplier;
@@ -83,6 +84,7 @@
    //@RequiresPermissions("org.jeecg.modules:base_supplier:add")
    @PostMapping(value = "/add")
    public Result<String> add(@RequestBody Supplier supplier) {
        supplier.setSupplierStatus(CommonConstant.STATUS_1);
        supplierService.save(supplier);
        return Result.OK("添加成功!");
    }
@@ -174,4 +176,19 @@
        return super.importExcel(request, response, Supplier.class);
    }
     @AutoLog(value = "供应商-启用&禁用")
     @ApiOperation(value = "供应商-启用&禁用", notes = "供应商-启用&禁用")
     @PutMapping(value = "/active")
     public Result<?> active(@RequestParam(name = "id", required = true) String id) {
         Supplier supplier = supplierService.getById(id);
         if (CommonConstant.STATUS_1.equals(supplier.getSupplierStatus())) {
             supplier.setSupplierStatus(CommonConstant.STATUS_0);
         } else {
             supplier.setSupplierStatus(CommonConstant.STATUS_1);
         }
         supplierService.updateById(supplier);
         return Result.ok("操作成功!");
     }
}
src/main/java/org/jeecg/modules/base/entity/LineSideWarehouse.java
@@ -10,6 +10,7 @@
import com.baomidou.mybatisplus.annotation.TableLogic;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.jeecg.common.constant.CommonConstant;
import org.springframework.format.annotation.DateTimeFormat;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.jeecg.common.aspect.annotation.Dict;
@@ -56,7 +57,7 @@
    @Excel(name = "删除标记", width = 15)
    @ApiModelProperty(value = "删除标记")
    @TableLogic
    private Integer delFlag;
    private Integer delFlag = CommonConstant.DEL_FLAG_0;
    /**仓库编码*/
    @Excel(name = "仓库编码", width = 15)
    @ApiModelProperty(value = "仓库编码")
@@ -65,8 +66,13 @@
    @Excel(name = "仓库名称", width = 15)
    @ApiModelProperty(value = "仓库名称")
    private String warehouseName;
    /**仓库状态*/
    @Excel(name = "仓库状态", width = 15)
    @ApiModelProperty(value = "仓库状态")
    private String warehouseStatus;
    /**工厂/产线ID*/
    @Excel(name = "工厂/产线ID", width = 15)
    @ApiModelProperty(value = "工厂/产线ID")
    @Dict(dictTable = "base_factory", dicCode = "id", dicText = "factory_name")
    private String factoryId;
}
src/main/java/org/jeecg/modules/base/entity/ShiftGroup.java
@@ -69,6 +69,7 @@
    /**班组长*/
    @Excel(name = "班组长", width = 15)
    @ApiModelProperty(value = "班组长")
    @Dict(dictTable = "sys_user", dicCode = "id", dicText = "realname")
    private String groupManager;
    /**状态*/
    @Excel(name = "状态", width = 15)
@@ -77,10 +78,12 @@
    /**班次ID*/
    @Excel(name = "班次ID", width = 15)
    @ApiModelProperty(value = "班次ID")
    @Dict(dictTable = "base_shift", dicCode = "id", dicText = "shift_name")
    private String shiftId;
    /**工厂/车间/产线ID*/
    @Excel(name = "工厂/车间/产线ID", width = 15)
    @ApiModelProperty(value = "工厂/车间/产线ID")
    @Dict(dictTable = "base_factory", dicCode = "id", dicText = "factory_name")
    private String factoryId;
    /**备注*/
    @Excel(name = "备注", width = 15)
src/main/java/org/jeecg/modules/base/entity/UserFactory.java
@@ -53,7 +53,7 @@
    @ApiModelProperty(value = "工厂/车间/产线ID")
    private String factoryId;
    public UserFactory(String id, String factoryId) {
    public UserFactory(String factoryId, String id) {
        this.userId = id;
        this.factoryId = factoryId;
    }
src/main/java/org/jeecg/modules/base/model/FactoryTreeModel.java
@@ -58,6 +58,8 @@
    private String factoryCode;
    private String factoryCategory;
    private String remark;
    private Integer delFlag;
@@ -100,5 +102,6 @@
        this.updateBy = factory.getUpdateBy();
        this.updateTime = factory.getUpdateTime();
        this.mdcFlag = factory.getMdcFlag();
        this.factoryCategory = factory.getFactoryCategory();
    }
}
src/main/java/org/jeecg/modules/system/controller/SysUserController.java
@@ -25,6 +25,7 @@
import org.jeecg.common.system.util.JwtUtil;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.*;
import org.jeecg.modules.base.entity.UserFactory;
import org.jeecg.modules.base.entity.UserGroup;
import org.jeecg.modules.base.service.BaseCommonService;
import org.jeecg.modules.base.service.IUserFactoryService;
@@ -35,6 +36,7 @@
import org.jeecg.modules.system.model.SysUserSysDepartModel;
import org.jeecg.modules.system.service.*;
import org.jeecg.modules.system.vo.SysDepartUsersVO;
import org.jeecg.modules.system.vo.SysUserFactoryVO;
import org.jeecg.modules.system.vo.SysUserGroupVO;
import org.jeecg.modules.system.vo.SysUserRoleVO;
import org.jeecgframework.poi.excel.ExcelImportUtil;
@@ -1690,4 +1692,98 @@
        return result;
    }
    @RequestMapping(value = "/userFactoryList", method = RequestMethod.GET)
    public Result<IPage<SysUser>> userFactoryList(@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {
        Result<IPage<SysUser>> result = new Result<IPage<SysUser>>();
        Page<SysUser> page = new Page<SysUser>(pageNo, pageSize);
        String factoryId = req.getParameter("factoryId");
        String username = req.getParameter("username");
        IPage<SysUser> pageList = sysUserService.getUserByFactoryId(page, factoryId, username);
        result.setSuccess(true);
        result.setResult(pageList);
        return result;
    }
    /**
     * ç»™æŒ‡å®šäº§çº¿æ·»åŠ äººå‘˜
     *
     * @param
     * @return
     */
    //@RequiresRoles({"admin"})
    @RequestMapping(value = "/addBaseUserFactory", method = RequestMethod.POST)
    public Result<String> addBaseUserFactory(@RequestBody SysUserFactoryVO sysUserFactoryVO) {
        Result<String> result = new Result<String>();
        try {
            String factoryId = sysUserFactoryVO.getFactoryId();
            for (String userId : sysUserFactoryVO.getUserIdList()) {
                UserFactory userFactory = new UserFactory(factoryId,userId);
                QueryWrapper<UserFactory> queryWrapper = new QueryWrapper<UserFactory>();
                queryWrapper.eq("factory_id", factoryId).eq("user_id", userId);
                UserFactory one = userFactoryService.getOne(queryWrapper);
                if (one == null) {
                    userFactoryService.save(userFactory);
                }
            }
            result.setMessage("添加成功!");
            result.setSuccess(true);
            return result;
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            result.setSuccess(false);
            result.setMessage("出错了: " + e.getMessage());
            return result;
        }
    }
    /**
     * åˆ é™¤æŒ‡å®šäº§çº¿çš„人员关系
     *
     * @param
     * @return
     */
    //@RequiresRoles({"admin"})
    @RequestMapping(value = "/deleteUserFactory", method = RequestMethod.DELETE)
    public Result<UserFactory> deleteUserFactory(@RequestParam(name = "factoryId") String factoryId,
                                             @RequestParam(name = "userId", required = true) String userId
    ) {
        Result<UserFactory> result = new Result<UserFactory>();
        try {
            QueryWrapper<UserFactory> queryWrapper = new QueryWrapper<UserFactory>();
            queryWrapper.eq("factory_id", factoryId).eq("user_id", userId);
            userFactoryService.remove(queryWrapper);
            result.success("删除成功!");
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            result.error500("删除失败!");
        }
        return result;
    }
    /**
     * æ‰¹é‡åˆ é™¤æŒ‡å®šäº§çº¿çš„人员关系
     *
     * @param
     * @return
     */
    //@RequiresRoles({"admin"})
    @RequestMapping(value = "/deleteUserFactoryBatch", method = RequestMethod.DELETE)
    public Result<UserFactory> deleteUserFactoryBatch(
            @RequestParam(name = "factoryId") String factoryId,
            @RequestParam(name = "userIds", required = true) String userIds) {
        Result<UserFactory> result = new Result<UserFactory>();
        try {
            QueryWrapper<UserFactory> queryWrapper = new QueryWrapper<UserFactory>();
            queryWrapper.eq("factory_id", factoryId).in("user_id", Arrays.asList(userIds.split(",")));
            userFactoryService.remove(queryWrapper);
            result.success("删除成功!");
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            result.error500("删除失败!");
        }
        return result;
    }
}
src/main/java/org/jeecg/modules/system/mapper/SysUserMapper.java
@@ -197,4 +197,13 @@
     * @return
     */
    IPage<SysUser> getUserByGroupId(Page page, @Param("groupId") String groupId, @Param("username") String username);
    /**
     * æ ¹æ®äº§çº¿Id查询用户信息
     * @param page
     * @param factoryId äº§çº¿id
     * @param username ç”¨æˆ·ç™»å½•账户
     * @return
     */
    IPage<SysUser> getUserByFactoryId(Page page, @Param("factoryId") String factoryId, @Param("username") String username);
}
src/main/java/org/jeecg/modules/system/mapper/xml/SysUserMapper.xml
@@ -236,4 +236,12 @@
            and username = #{username}
        </if>
    </select>
    <!-- æ ¹æ®äº§çº¿Id查询 -->
    <select id="getUserByFactoryId" resultType="org.jeecg.modules.system.entity.SysUser">
        select * from sys_user where del_flag = 0 and id in (select user_id from base_user_factory where factory_id=#{factoryId})
        <if test="username!=null and username!=''">
            and username = #{username}
        </if>
    </select>
</mapper>
src/main/java/org/jeecg/modules/system/service/ISysUserService.java
@@ -354,4 +354,13 @@
     * @return
     */
    IPage<SysUser> getUserByGroupId(Page<SysUser> page, String groupId, String username);
    /**
     * æ ¹æ®äº§çº¿Id查询
     * @param page
     * @param factoryId äº§çº¿id
     * @param username ç”¨æˆ·è´¦æˆ·åç§°
     * @return
     */
    IPage<SysUser> getUserByFactoryId(Page<SysUser> page, String factoryId, String username);
}
src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java
@@ -818,4 +818,16 @@
    public IPage<SysUser> getUserByGroupId(Page<SysUser> page, String groupId, String username) {
        return userMapper.getUserByGroupId(page,groupId,username);
    }
    /**
     * æ ¹æ®äº§çº¿Id查询
     * @param page
     * @param factoryId ç­ç»„id
     * @param username ç”¨æˆ·è´¦æˆ·åç§°
     * @return
     */
    @Override
    public IPage<SysUser> getUserByFactoryId(Page<SysUser> page, String factoryId, String username) {
        return userMapper.getUserByFactoryId(page,factoryId,username);
    }
}
src/main/java/org/jeecg/modules/system/vo/SysUserFactoryVO.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,31 @@
package org.jeecg.modules.system.vo;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
 * @Description: äº§çº¿äººå‘˜vo
 * @author: jeecg-boot
 */
@Data
public class SysUserFactoryVO implements Serializable{
    private static final long serialVersionUID = 1L;
    /**产线id*/
    private String factoryId;
    /**对应的用户id集合*/
    private List<String> userIdList;
    public SysUserFactoryVO() {
        super();
    }
    public SysUserFactoryVO(String factoryId, List<String> userIdList) {
        super();
        this.factoryId = factoryId;
        this.userIdList = userIdList;
    }
}