From 2998d5d53a5a3cbf04b45770a4e15cc8b2ee0fcd Mon Sep 17 00:00:00 2001 From: syruan <1555146157@163.com> Date: Fri, 15 Dec 2023 21:04:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=AD=E4=BD=8D=E9=AA=8C=E8=AF=81=E7=A0=81?= =?UTF-8?q?=E7=94=9F=E6=88=90=E6=96=B9=E5=BC=8F=E9=87=8D=E5=86=99=EF=BC=8C?= =?UTF-8?q?BUG=E5=86=B2=E7=AA=81=E8=A7=A3=E5=86=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/api/domain/LeaseApplyDetails.java | 1 + .../bonus/sgzb/base/api/domain/MaType.java | 13 +- .../sgzb/system/api/RemoteUserService.java | 2 +- .../sgzb/auth/controller/TokenController.java | 39 ++-- .../sgzb/auth/service/SysLoginService.java | 12 +- .../base/controller/MaMachineController.java | 16 +- .../base/controller/MaTypeController.java | 168 +++++++++++++----- .../com/bonus/sgzb/base/domain/MaHouse.java | 11 ++ .../bonus/sgzb/base/domain/vo/TreeSelect.java | 25 +++ .../sgzb/base/mapper/MaMachineMapper.java | 4 + .../bonus/sgzb/base/mapper/MaTypeMapper.java | 15 +- .../bonus/sgzb/base/service/ITypeService.java | 2 +- .../base/service/impl/MaTypeServiceImpl.java | 7 +- .../resources/mapper/base/MaMachineMapper.xml | 77 +++++++- .../mapper/base/MaMachineTypeMapper.xml | 58 ++++-- .../system/controller/SysUserController.java | 3 +- .../service/impl/SysSmsServiceImpl.java | 63 +++++-- 17 files changed, 404 insertions(+), 112 deletions(-) diff --git a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/LeaseApplyDetails.java b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/LeaseApplyDetails.java index d5b48827..2ee0457f 100644 --- a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/LeaseApplyDetails.java +++ b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/LeaseApplyDetails.java @@ -19,6 +19,7 @@ import lombok.Data; @ApiModel(description = "领料任务详细表lease_apply_details") @Data public class LeaseApplyDetails implements Serializable { + @ApiModelProperty(value = "") private Integer id; diff --git a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/MaType.java b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/MaType.java index 2fbb7324..14cc2b8d 100644 --- a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/MaType.java +++ b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/MaType.java @@ -50,6 +50,9 @@ public class MaType extends BaseEntity { @ApiModelProperty(value = "租赁单价") private String leasePrice; + @ApiModelProperty(value = "外部价格") + private String rentPrice; + /** 原价 */ @ApiModelProperty(value = "原价") private String buyPrice; @@ -120,7 +123,7 @@ public class MaType extends BaseEntity { /** 图片路径 */ @ApiModelProperty(value = "图片路径") - private String photoUrl; + private String photoUrl = "https://zlpt-1259760603.cos.ap-nanjing.myqcloud.com/zhcc/bg2.jpg"; /** 文档名称 */ @ApiModelProperty(value = "文档名称") @@ -233,6 +236,14 @@ public class MaType extends BaseEntity { return payPrice; } + public String getRentPrice() { + return rentPrice; + } + + public void setRentPrice(String rentPrice) { + this.rentPrice = rentPrice; + } + public void setPayPrice(String payPrice) { this.payPrice = payPrice; } diff --git a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/system/api/RemoteUserService.java b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/system/api/RemoteUserService.java index edfe6245..32a0a95c 100644 --- a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/system/api/RemoteUserService.java +++ b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/system/api/RemoteUserService.java @@ -42,7 +42,7 @@ public interface RemoteUserService /** * 发送短信 */ - @PostMapping("/sms/sendCode") + @PostMapping("/sms/codeLogin") public R sendCode(@RequestParam("phone") String phone); /** diff --git a/sgzb-auth/src/main/java/com/bonus/sgzb/auth/controller/TokenController.java b/sgzb-auth/src/main/java/com/bonus/sgzb/auth/controller/TokenController.java index 334295bd..402104d5 100644 --- a/sgzb-auth/src/main/java/com/bonus/sgzb/auth/controller/TokenController.java +++ b/sgzb-auth/src/main/java/com/bonus/sgzb/auth/controller/TokenController.java @@ -1,7 +1,9 @@ package com.bonus.sgzb.auth.controller; +import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; +import com.bonus.sgzb.system.api.RemoteUserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import com.bonus.sgzb.auth.form.LoginBody; @@ -15,6 +17,8 @@ import com.bonus.sgzb.common.security.service.TokenService; import com.bonus.sgzb.common.security.utils.SecurityUtils; import com.bonus.sgzb.system.api.model.LoginUser; +import java.util.Map; + /** * token 控制 * @@ -29,6 +33,9 @@ public class TokenController @Autowired private SysLoginService sysLoginService; + @Resource + private RemoteUserService remoteUserService; + @PostMapping("login") public R login(@RequestBody LoginBody form) { // 用户登录 @@ -39,28 +46,27 @@ public class TokenController @PostMapping("sendCode") public R sendCode(@RequestBody LoginBody form) { - // 用户登录 - LoginUser userInfo = sysLoginService.loginCode(form.getPhone(), form.getCode()); - // 获取登录token - return R.ok(tokenService.createToken(userInfo)); + R sendState = remoteUserService.sendCode(form.getPhone()); + return sendState; } @PostMapping("checkCode") public R checkCode(@RequestBody LoginBody form) { // 校验验证码 - boolean result = sysLoginService.checkCode(form.getPhone(), form.getCode()); - if (result) { - return R.ok(null, "验证码正确"); + LoginUser loginUser = sysLoginService.loginCode(form.getPhone(), form.getCode()); + if (StringUtils.isNotNull(loginUser)) { + // 创建token + Map tokenMap = tokenService.createToken(loginUser); + return R.ok(loginUser); + } else { + return R.fail(null, "验证码错误"); } - return R.fail("短信验证码错误"); } @DeleteMapping("logout") - public R logout(HttpServletRequest request) - { + public R logout(HttpServletRequest request) { String token = SecurityUtils.getToken(request); - if (StringUtils.isNotEmpty(token)) - { + if (StringUtils.isNotEmpty(token)) { String username = JwtUtils.getUserName(token); // 删除用户缓存记录 AuthUtil.logoutByToken(token); @@ -71,11 +77,9 @@ public class TokenController } @PostMapping("refresh") - public R refresh(HttpServletRequest request) - { + public R refresh(HttpServletRequest request) { LoginUser loginUser = tokenService.getLoginUser(request); - if (StringUtils.isNotNull(loginUser)) - { + if (StringUtils.isNotNull(loginUser)) { // 刷新令牌有效期 tokenService.refreshToken(loginUser); return R.ok(); @@ -84,8 +88,7 @@ public class TokenController } @PostMapping("register") - public R register(@RequestBody RegisterBody registerBody) - { + public R register(@RequestBody RegisterBody registerBody) { // 用户注册 sysLoginService.register(registerBody.getUsername(), registerBody.getPassword()); return R.ok(); diff --git a/sgzb-auth/src/main/java/com/bonus/sgzb/auth/service/SysLoginService.java b/sgzb-auth/src/main/java/com/bonus/sgzb/auth/service/SysLoginService.java index ab61cd26..555a343b 100644 --- a/sgzb-auth/src/main/java/com/bonus/sgzb/auth/service/SysLoginService.java +++ b/sgzb-auth/src/main/java/com/bonus/sgzb/auth/service/SysLoginService.java @@ -70,26 +70,22 @@ public class SysLoginService // 查询用户信息 R userResult = remoteUserService.getUserInfo(username, SecurityConstants.INNER); - if (StringUtils.isNull(userResult) || StringUtils.isNull(userResult.getData())) - { + if (StringUtils.isNull(userResult) || StringUtils.isNull(userResult.getData())) { recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "登录用户不存在"); throw new ServiceException("登录用户:" + username + " 不存在"); } - if (R.FAIL == userResult.getCode()) - { + if (R.FAIL == userResult.getCode()) { throw new ServiceException(userResult.getMsg()); } LoginUser userInfo = userResult.getData(); SysUser user = userResult.getData().getSysUser(); - if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) - { + if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) { recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "对不起,您的账号已被删除"); throw new ServiceException("对不起,您的账号:" + username + " 已被删除"); } - if (UserStatus.DISABLE.getCode().equals(user.getStatus())) - { + if (UserStatus.DISABLE.getCode().equals(user.getStatus())) { recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户已停用,请联系管理员"); throw new ServiceException("对不起,您的账号:" + username + " 已停用"); } diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/controller/MaMachineController.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/controller/MaMachineController.java index da6d7667..ffaeb008 100644 --- a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/controller/MaMachineController.java +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/controller/MaMachineController.java @@ -1,6 +1,7 @@ package com.bonus.sgzb.base.controller; import com.bonus.sgzb.base.api.domain.MaMachine; +import com.bonus.sgzb.base.mapper.MaMachineMapper; import com.bonus.sgzb.base.service.MaMachineService; import com.bonus.sgzb.common.core.web.controller.BaseController; import com.bonus.sgzb.common.core.web.domain.AjaxResult; @@ -26,18 +27,29 @@ public class MaMachineController extends BaseController { @Autowired private MaMachineService maMachineService; + @Autowired + private MaMachineMapper maMachineMapper; + + @Log(title = "根据条件查询机具设备", businessType = BusinessType.QUERY) + @GetMapping("/getMaMachineList") + public AjaxResult getMaMachineList(MaMachine maMachine) { + List list = maMachineMapper.getMaMachineList(maMachine); + return success(list); + } + + /** * 根据条件进行查询机具设备管理 */ @ApiOperation(value = "根据条件进行查询机具设备管理") @GetMapping("/getMachine") - public TableDataInfo getMaMachine(MaMachine maMachine) - { + public TableDataInfo getMaMachine(MaMachine maMachine) { startPage(); List list = maMachineService.getMaMachine(maMachine); return getDataTable(list); } + /** * 新增机具设备管理 */ diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/controller/MaTypeController.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/controller/MaTypeController.java index c585075c..e6420235 100644 --- a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/controller/MaTypeController.java +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/controller/MaTypeController.java @@ -1,9 +1,13 @@ package com.bonus.sgzb.base.controller; import com.bonus.sgzb.base.api.domain.MaType; +import com.bonus.sgzb.base.domain.vo.TreeSelect; +import com.bonus.sgzb.base.mapper.MaTypeMapper; import com.bonus.sgzb.base.service.ITypeService; +import com.bonus.sgzb.common.core.constant.HttpStatus; import com.bonus.sgzb.common.core.web.controller.BaseController; import com.bonus.sgzb.common.core.web.domain.AjaxResult; +import com.bonus.sgzb.common.core.web.page.TableDataInfo; import com.bonus.sgzb.common.log.annotation.Log; import com.bonus.sgzb.common.log.enums.BusinessType; import io.swagger.annotations.Api; @@ -11,7 +15,10 @@ import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import javax.annotation.Resource; import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; /** * 工机具类型管理控制层 @@ -24,6 +31,9 @@ public class MaTypeController extends BaseController { @Autowired private ITypeService iTypeService; + @Resource + private MaTypeMapper maTypeMapper; + /** * 根据类型名称查询类型 @@ -31,55 +41,133 @@ public class MaTypeController extends BaseController { */ @ApiOperation(value = "根据类型名称查询类型") @GetMapping("/getMaTypeList") - public AjaxResult getMaTypeList(String typeName){ - return AjaxResult.success(iTypeService.getMaTypeList(typeName)); - + public AjaxResult getMaTypeList(@RequestParam(required = false, defaultValue = "", value = "typeName") String typeName, @RequestParam(required = false, defaultValue = "", value = "parentId") String parentId){ + List maTypeList = iTypeService.getMaTypeList(typeName, parentId); + return AjaxResult.success(maTypeList); } - - @ApiOperation(value = "工器具类型") - @GetMapping("/equipmentType") - public AjaxResult equipmentType(@RequestParam(required = false) Long typeId, - @RequestParam(required = false) String typeName){ - List listByMaType = iTypeService.getEquipmentType(typeId,typeName); - return success(listByMaType); + @ApiOperation(value = "获取机具设备的具体规格") + @GetMapping(value = "/selectMaTypeTreeByLevel") + public AjaxResult selectMaTypeTreeByLevel(@RequestParam(value = "typeId") String typeId) { + List maTypeList = maTypeMapper.selectMaTypeTreeByLevel(typeId); + return AjaxResult.success(maTypeList); } + /** + * 获取规格层级为3的设备列表 + * @return 结果 + */ + @ApiOperation(value = "获取规格层级的设备列表") + @GetMapping("/selectMaTypeListByLevelIndex") + public AjaxResult selectMaTypeListByLevelIndex(@RequestParam(value = "level", required = false) Integer level, @RequestParam(value = "type") Integer type, @RequestParam(value = "parentId", required = false) Integer parentId){ + if (type == null) { return AjaxResult.error("参数错误,类型不能为空"); } + if (type == 0) { + // 查询全部机具类型 + if (level == 0 || level == 1) { + // 查询全部等级、一级 + List treeSelectList = iTypeService.buildDeptTreeSelect(maTypeMapper.selectMaTypeListByLevelNotFour(null)); + return AjaxResult.success(treeSelectList); + } + if (level == 2) { + // 查询二级 + return AjaxResult.success(maTypeMapper.selectMaTypeListByLevelNotFour(parentId.toString())); + // List treeSelectList = iTypeService.buildDeptTreeSelect(maTypeMapper.selectMaTypeListByLevelNotFour(parentId.toString())); + // + // // 遍历剔除不符合的三级规格 + // for (TreeSelect treeSelect : treeSelectList) { + // List children = treeSelect.getChildren(); + // if (children != null) { + // for (TreeSelect child : children) { + // List grandChildren = child.getChildren(); + // if (grandChildren!= null) { + // grandChildren.removeIf(obj -> !Objects.equals(obj.getParentId(), Long.valueOf(parentId))); + // } + // } + // } + // } + // return AjaxResult.success(treeSelectList); + } + } + if (type == 1) { + // 查询施工机具 + List treeSelectList; + if (level != 2) { + treeSelectList = iTypeService.buildDeptTreeSelect(maTypeMapper.selectMaTypeListByLevelNotFour(null)); + return AjaxResult.success(treeSelectList.stream().filter(item -> Objects.equals(item.getId(), 1L)).collect(Collectors.toList())); + } else { + return AjaxResult.success(maTypeMapper.selectMaTypeListByLevelNotFour(parentId.toString())); + // treeSelectList = iTypeService.buildDeptTreeSelect(maTypeMapper.selectMaTypeListByLevelNotFour(parentId.toString())); + // // 先过滤出施工机具 + // treeSelectList = treeSelectList.stream().filter(item -> Objects.equals(item.getId(), 1L)).collect(Collectors.toList()); + // // 再过滤出不符合的三级规格 + // if (!treeSelectList.isEmpty()) { + // for (TreeSelect treeSelect : treeSelectList) { + // List children = treeSelect.getChildren(); + // if (children != null) { + // for (TreeSelect child : children) { + // List grandChildren = child.getChildren(); + // if (grandChildren != null) { + // grandChildren.removeIf(obj -> !Objects.equals(obj.getParentId(), Long.valueOf(parentId))); + // } + // + // } + // } + // } + // } + // return AjaxResult.success(treeSelectList); + } + } + if (type == 2) { + List treeSelectList = iTypeService.buildDeptTreeSelect(maTypeMapper.selectMaTypeListByLevelNotFour(null)); + treeSelectList = treeSelectList.stream().filter(item -> Objects.equals(item.getId(), 2L)).collect(Collectors.toList()); + // 查询安全工器具 + if (level == 2) { + return AjaxResult.success(maTypeMapper.selectMaTypeListByLevelNotFour(parentId.toString())); + // if (!treeSelectList.isEmpty()) { + // for (TreeSelect treeSelect : treeSelectList) { + // List children = treeSelect.getChildren(); + // if (children != null) { + // for (TreeSelect child : children) { + // List grandChildren = child.getChildren(); + // if (grandChildren != null) { + // grandChildren.removeIf(obj -> !Objects.equals(obj.getParentId(), Long.valueOf(parentId))); + // } + // } + // } + // } + // } + } + return AjaxResult.success(treeSelectList); + } + return AjaxResult.success(maTypeMapper.selectMaTypeListByLevelNotFour(null)); + } + + /** + * 根据左列表类型id查询右表格 + * @param typeId + * @return + */ @ApiOperation(value = "根据左列表类型id查询右表格") @GetMapping("/getListByMaType") - public AjaxResult getListByMaType(@RequestParam(required = false) Long typeId, - @RequestParam(required = false) String typeName){ - List listByMaType = iTypeService.getListByParentId(typeId,typeName); - return success(listByMaType); + public TableDataInfo getListByMaType(@RequestParam(required = false) Long typeId, + @RequestParam(required = false) String typeName, + @RequestParam(required = false) Integer pageSize, + @RequestParam(required = false) Integer pageNum){ + if(typeId==null){ + return null; + } + List listByMaType = iTypeService.getListByMaType(typeId, typeName); + TableDataInfo rspData = new TableDataInfo(); + rspData.setTotal(listByMaType.size()); + rspData.setCode(HttpStatus.SUCCESS); + listByMaType = listByMaType.stream().skip((long) (pageNum - 1) * pageSize).limit(pageSize).collect(Collectors.toList()); + rspData.setRows(listByMaType); + rspData.setMsg("查询成功"); + + return rspData; } - -// /** -// * 根据左列表类型id查询右表格 -// * @param typeId -// * @return -// */ -// @ApiOperation(value = "根据左列表类型id查询右表格") -// @GetMapping("/getListByMaType") -// public TableDataInfo getListByMaType(@RequestParam(required = false) Long typeId, -// @RequestParam(required = false) String typeName, -// @RequestParam(required = false) Integer pageSize, -// @RequestParam(required = false) Integer pageNum){ -// if(typeId==null){ -// return null; -// } -// List listByMaType = iTypeService.getListByMaType(typeId, typeName); -// TableDataInfo rspData = new TableDataInfo(); -// rspData.setTotal(listByMaType.size()); -// rspData.setCode(HttpStatus.SUCCESS); -// listByMaType = listByMaType.stream().skip((long) (pageNum - 1) * pageSize).limit(pageSize).collect(Collectors.toList()); -// rspData.setRows(listByMaType); -// rspData.setMsg("查询成功"); -// -// return rspData; -// } - /** * 获取机具类型管理ma_type详细信息 */ diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/domain/MaHouse.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/domain/MaHouse.java index 8a392e21..48dc07e0 100644 --- a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/domain/MaHouse.java +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/domain/MaHouse.java @@ -16,6 +16,9 @@ public class MaHouse extends BaseEntity { @ApiModelProperty(value= "仓库ID") private Long houseId; + @ApiModelProperty(value= "等级") + private Integer level; + /** 工程项目名称 */ @ApiModelProperty(value="工程项目名称") private String houseName; @@ -75,6 +78,14 @@ public class MaHouse extends BaseEntity { /** 子部门 */ private List children = new ArrayList(); + public Integer getLevel() { + return level; + } + + public void setLevel(Integer level) { + this.level = level; + } + public Long getHouseId() { return houseId; } diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/domain/vo/TreeSelect.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/domain/vo/TreeSelect.java index 26cd98d0..19b66438 100644 --- a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/domain/vo/TreeSelect.java +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/domain/vo/TreeSelect.java @@ -23,6 +23,10 @@ public class TreeSelect implements Serializable /** 节点名称 */ private String label; + private Integer level; + + private Long parentId; + /** 子节点 */ @JsonInclude(JsonInclude.Include.NON_EMPTY) private List children; @@ -34,6 +38,7 @@ public class TreeSelect implements Serializable public TreeSelect(MaHouse maHouse) { + this.level = maHouse.getLevel(); this.id = maHouse.getDeptId(); this.label = maHouse.getHouseName(); this.children = maHouse.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList()); @@ -41,11 +46,23 @@ public class TreeSelect implements Serializable public TreeSelect(MaType maType) { + this.parentId = maType.getParentId(); + this.level = Integer.valueOf(maType.getLevel()); this.id = maType.getTypeId(); this.label = maType.getTypeName(); this.children = maType.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList()); } + + public Long getParentId() { + return parentId; + } + + public void setParentId(Long parentId) { + this.parentId = parentId; + } + + public Long getId() { return id; @@ -56,6 +73,14 @@ public class TreeSelect implements Serializable this.id = id; } + public Integer getLevel() { + return level; + } + + public void setLevel(Integer level) { + this.level = level; + } + public String getLabel() { return label; diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/mapper/MaMachineMapper.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/mapper/MaMachineMapper.java index 54396bdb..06e8e3bb 100644 --- a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/mapper/MaMachineMapper.java +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/mapper/MaMachineMapper.java @@ -1,12 +1,16 @@ package com.bonus.sgzb.base.mapper; import com.bonus.sgzb.base.api.domain.MaMachine; +import org.apache.ibatis.annotations.Mapper; import java.util.List; +@Mapper public interface MaMachineMapper { public List getMaMachine(MaMachine maMachine); + public List getMaMachineList(MaMachine maMachine); + public int maMachineAdd(MaMachine maMachine); public int remove(Long[] maIds); diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/mapper/MaTypeMapper.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/mapper/MaTypeMapper.java index 57344634..3762224e 100644 --- a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/mapper/MaTypeMapper.java +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/mapper/MaTypeMapper.java @@ -1,21 +1,22 @@ package com.bonus.sgzb.base.mapper; -import com.bonus.sgzb.base.domain.MaPropSet; import com.bonus.sgzb.base.api.domain.MaType; +import com.bonus.sgzb.base.domain.MaPropSet; import com.bonus.sgzb.base.domain.MaTypeKeeper; import com.bonus.sgzb.base.domain.MaTypeRepair; +import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import java.util.List; /** * 工机具类型管理 数据层 - * + * * @author ruoyi */ +@Mapper public interface MaTypeMapper { - List selectMaTypeList(String typeName); /** @@ -65,8 +66,12 @@ public interface MaTypeMapper { MaType selectTypeByTypeId(long typeId); - List selectMaTypeTree(); + List selectMaTypeTree(String parentId); - List getListByParentId(@Param("typeId") Long typeId, @Param("typeName") String typeName); + List getListByParentId(@org.apache.ibatis.annotations.Param("typeId") Long typeId, @Param("typeName") String typeName); + + List selectMaTypeTreeByLevel(String id); + + List selectMaTypeListByLevelNotFour(String parentId); } \ No newline at end of file diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/service/ITypeService.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/service/ITypeService.java index 3804ac90..2e476f2b 100644 --- a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/service/ITypeService.java +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/service/ITypeService.java @@ -10,7 +10,7 @@ import java.util.List; */ public interface ITypeService { - List getMaTypeList(String typeName); + List getMaTypeList(String typeName, String parentId); List getListByMaType(Long typeId,String typeName); diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/service/impl/MaTypeServiceImpl.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/service/impl/MaTypeServiceImpl.java index 3fd6b784..683ae0df 100644 --- a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/service/impl/MaTypeServiceImpl.java +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/service/impl/MaTypeServiceImpl.java @@ -150,10 +150,11 @@ public class MaTypeServiceImpl implements ITypeService { } @Override - public List getMaTypeList(String typeName) { - List maTypes = maTypeMapper.selectMaTypeTree(); + public List getMaTypeList(String typeName, String parentId) { + List maTypes = maTypeMapper.selectMaTypeTree(parentId); + List treeSelectList = buildDeptTreeSelect(maTypes); //如果没有查询到那么返回空 - return buildDeptTreeSelect(maTypes); + return treeSelectList; } /** diff --git a/sgzb-modules/sgzb-base/src/main/resources/mapper/base/MaMachineMapper.xml b/sgzb-modules/sgzb-base/src/main/resources/mapper/base/MaMachineMapper.xml index 1a1c5291..8372e64b 100644 --- a/sgzb-modules/sgzb-base/src/main/resources/mapper/base/MaMachineMapper.xml +++ b/sgzb-modules/sgzb-base/src/main/resources/mapper/base/MaMachineMapper.xml @@ -116,6 +116,82 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + insert into ma_machine ( type_id, @@ -203,5 +279,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where ma_id = #{maId} - \ No newline at end of file diff --git a/sgzb-modules/sgzb-base/src/main/resources/mapper/base/MaMachineTypeMapper.xml b/sgzb-modules/sgzb-base/src/main/resources/mapper/base/MaMachineTypeMapper.xml index 92ca7f5b..9406ac07 100644 --- a/sgzb-modules/sgzb-base/src/main/resources/mapper/base/MaMachineTypeMapper.xml +++ b/sgzb-modules/sgzb-base/src/main/resources/mapper/base/MaMachineTypeMapper.xml @@ -10,9 +10,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + @@ -32,7 +32,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select type_id, type_name, parent_id, status, num, unit_id, unit_name, manage_type, lease_price, buy_price, pay_price, level, rated_load, test_load, holding_time, warn_num, del_flag, create_by, create_time, remark, company_id + select type_id, type_name, parent_id, status, num, unit_id, manage_type, lease_price, buy_price, pay_price, level, rated_load, test_load, holding_time, warn_num, del_flag, create_by, create_time, remark, company_id from ma_type @@ -44,7 +44,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" status, num, unit_id, - unit_name, manage_type, lease_price, buy_price, @@ -70,7 +69,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{status}, #{num}, #{unitId}, - #{unitName}, #{manageType}, #{leasePrice}, #{buyPrice}, @@ -124,7 +122,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" status = #{status}, num = #{num}, unit_id = #{unitId}, - unit_name = #{unitName}, manage_type = #{manageType}, lease_price = #{leasePrice}, buy_price = #{buyPrice}, @@ -152,8 +149,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select m.type_id, m.type_name, m.parent_id, m.status, m.num, m.unit_id, m.unit_name, m.manage_type, - m.lease_price, m.buy_price, m.pay_price, m.level, m.rated_load, m.test_load, + select m.type_id, m.type_name, m.parent_id, m.status, m.num, m.unit_id, m.manage_type, + m.lease_price, m.rent_price, m.buy_price, m.pay_price, m.level, m.rated_load, m.test_load, m.holding_time, m.warn_num, mtf.file_name photoName, mtf.file_url photoUrl, mtf2.file_name documentName, mtf2.file_url documentUrl, mtk.user_id keeperUserId, su.user_name keeperUserName, mpi.prop_name, m.del_flag, m.create_by, m.create_time, @@ -284,13 +283,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where type_id = #{typeId} - select m.type_id, m.type_name, m.parent_id, m.status, m.num, m.unit_id, m.manage_type, - m.lease_price, m.buy_price, m.pay_price, m.level, m.rated_load, m.test_load, + m.lease_price, m.rent_price, m.buy_price, m.pay_price, m.level, m.rated_load, m.test_load, m.holding_time, m.warn_num, m.del_flag, m.create_by, m.create_time, m.remark, m.company_id from ma_type m - WHERE level != 4 and m.status = '0' + + level != 4 and m.status = '0' + + + + + \ No newline at end of file diff --git a/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/controller/SysUserController.java b/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/controller/SysUserController.java index 45a0155d..b75b5c57 100644 --- a/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/controller/SysUserController.java +++ b/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/controller/SysUserController.java @@ -130,8 +130,7 @@ public class SysUserController extends BaseController */ @InnerAuth @GetMapping("/info/{username}") - public R info(@PathVariable("username") String username) - { + public R info(@PathVariable("username") String username) { SysUser sysUser = userService.selectUserByUserName(username); if (StringUtils.isNull(sysUser)) { diff --git a/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/service/impl/SysSmsServiceImpl.java b/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/service/impl/SysSmsServiceImpl.java index 61075aa6..23feb10f 100644 --- a/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/service/impl/SysSmsServiceImpl.java +++ b/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/service/impl/SysSmsServiceImpl.java @@ -2,6 +2,7 @@ package com.bonus.sgzb.system.service.impl; import cn.hutool.http.HttpRequest; import com.alibaba.druid.util.StringUtils; +import com.bonus.sgzb.common.core.constant.UserConstants; import com.bonus.sgzb.common.core.exception.ServiceException; import com.bonus.sgzb.common.core.web.domain.AjaxResult; import com.bonus.sgzb.common.redis.service.RedisService; @@ -27,9 +28,18 @@ public class SysSmsServiceImpl implements ISysSmsService { @Resource private RedisService redisService; + // 短信url + private static final String url = "http://api.ktsms.cn/sms_token?ddtkey=bonus&secretkey=KtyBns@Admin2023!"; + @Override public AjaxResult sendSms(String phone, String msg) { - return sendCodeByPhone(phone, msg); + if (phone == null || StringUtils.isEmpty(msg)) { + return AjaxResult.error("手机号码或短信内容不能为空"); + } + if (phone.length() != UserConstants.PHONE_DEFAULT_LENGTH_LOGIN) { + return AjaxResult.error("手机号格式不正确"); + } + return sendMsgByPhone(phone, msg); } @Override @@ -39,6 +49,32 @@ public class SysSmsServiceImpl implements ISysSmsService { } + /** + * 发送消息msg到手机 + * @param phone 手机号码 + * @return AjaxResult对象 + */ + private AjaxResult sendMsgByPhone(String phone, String msg) { + // 校验手机号码 + if (phone == null || phone.length() != UserConstants.PHONE_DEFAULT_LENGTH_LOGIN) { + return AjaxResult.error("手机号码不正确"); + } + // 发送短信 + try { + String url = "http://106.ihuyi.com/webservice/sms.php?method=Submit"; + String content = url + "&mobile=" + phone + "&content=【智慧仓储】" + msg + "。"; + String body = HttpRequest.post(content).execute(false).body(); + System.out.println("发送手机号码:" + phone + ",内容:" + msg + ",返回结果:" + body); + if (body == null || !body.contains("ok")) { + return AjaxResult.error("发送失败"); + } + return success("发送手机号码:" + phone + ",内容:" + msg + ",返回结果:" + body); + } catch (Exception e) { + return AjaxResult.error("发送失败:" + e.getMessage()); + } + } + + /** * 发送验证码到手机 * @param phone 手机号码 @@ -46,21 +82,20 @@ public class SysSmsServiceImpl implements ISysSmsService { */ private AjaxResult sendCodeByPhone(String phone, String msg) { // 校验手机号码 - if (phone == null || phone.length() != 11) { - return AjaxResult.error("手机号码不正确"); + if (phone == null || phone.length() != UserConstants.PHONE_DEFAULT_LENGTH_LOGIN) { + return AjaxResult.error("手机号格式错误,请输入11位数字号码"); } String code = getSixBitCode(); // 校验验证码 - if (code.length() != 6) { - return AjaxResult.error("验证码格式不正确"); + if (code.length() != UserConstants.CODE_MIN_LENGTH_LOGIN) { + return AjaxResult.error("验证码格式不正确,生成错误!请联系后台管理员"); } // 发送短信 try { - String url = "http://api.ktsms.cn/sms_token?ddtkey=bonus&secretkey=KtyBns@Admin2023!"; String content = url + "&mobile=" + phone + "&content=【智慧仓储】您正在进行短信验证,验证码:" + code + ",请在5分钟内完成验证。"; String body = HttpRequest.post(content).execute(false).body(); System.out.println("发送短信:" + phone + ",验证码:" + code + ",返回结果:" + body); - if (body == null || !body.contains("success")) { + if (body == null || !body.contains("ok")) { return AjaxResult.error("发送失败"); } // 存储验证码至Redis中,键值为:code_15588886157 , 有效期5,时间颗粒度为MINUTES:分钟 @@ -94,17 +129,17 @@ public class SysSmsServiceImpl implements ISysSmsService { } } + public static void main(String[] args) { + System.out.println(getSixBitCode()); + } + /** * 随机生成6位验证码 */ - private String getSixBitCode() { + private static String getSixBitCode() { //随机数 - StringBuilder sb = new StringBuilder(); - Random rand = new Random(); - for (int i = 0; i < 6; i++) { - sb.append(rand.nextInt(10)); - } - return sb.toString(); + Random random = new Random(); + return String.valueOf(random.nextInt(900000) + 100000); }