Merge branch 'dev-nx' of http://192.168.0.56:3000/bonus/devicesmgt into dev-nx

This commit is contained in:
BianLzhaoMin 2024-06-27 11:54:50 +08:00
commit 5f68d7194a
17 changed files with 343 additions and 148 deletions

View File

@ -1,6 +1,8 @@
package com.bonus.sgzb.system.api;
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import com.bonus.sgzb.system.api.domain.SysUser;
import com.bonus.sgzb.system.api.domain.UrgentProcessingUser;
import com.bonus.sgzb.system.api.factory.RemoteUserFallbackFactory;
import com.bonus.sgzb.system.api.model.LoginUser;
import org.springframework.cloud.openfeign.FeignClient;
@ -84,4 +86,13 @@ public interface RemoteUserService
*/
@GetMapping("/user/getUserList")
public R<List<SysUser>> getUserList(@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
/**
* 通过任务状态获取下一级审批人的信息
*
* @param urgentProcessingUser
* @return
*/
@PostMapping("/urgentProcessingUser")
public AjaxResult urgentProcessingUser(@RequestBody UrgentProcessingUser urgentProcessingUser);
}

View File

@ -1,4 +1,4 @@
package com.bonus.sgzb.system.domain.po;
package com.bonus.sgzb.system.api.domain;
import lombok.Data;

View File

@ -5,8 +5,8 @@ import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.PhoneUtil;
import com.bonus.sgzb.app.domain.*;
import com.bonus.sgzb.app.service.*;
import com.bonus.sgzb.base.api.domain.MaType;
import com.bonus.sgzb.base.service.ITypeService;
import com.bonus.sgzb.common.core.enums.TaskStatusEnum;
import com.bonus.sgzb.common.core.utils.ListPagingUtil;
import com.bonus.sgzb.common.core.utils.ServletUtils;
import com.bonus.sgzb.common.core.utils.StringUtils;
@ -17,17 +17,20 @@ 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 com.bonus.sgzb.common.security.utils.SecurityUtils;
import com.bonus.sgzb.system.api.RemoteUserService;
import com.bonus.sgzb.system.api.domain.SysUser;
import com.bonus.sgzb.system.api.domain.UrgentProcessingUser;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import static com.bonus.sgzb.common.core.web.page.TableSupport.PAGE_NUM;
import static com.bonus.sgzb.common.core.web.page.TableSupport.PAGE_SIZE;
@ -39,6 +42,7 @@ import static com.bonus.sgzb.common.core.web.page.TableSupport.PAGE_SIZE;
*/
@RestController
@RequestMapping("/tm_task")
@Slf4j
public class TmTaskController extends BaseController {
/**
@ -62,6 +66,9 @@ public class TmTaskController extends BaseController {
@Resource
private ITypeService iTypeService;
@Resource
private RemoteUserService remoteUserService;
/**
* 领料审核通过分公司分管机具分公司统一接口
@ -263,6 +270,37 @@ public class TmTaskController extends BaseController {
} else {
return AjaxResult.error("创建任务失败");
}
UrgentProcessingUser urgentProcessingUser = new UrgentProcessingUser();
urgentProcessingUser.setCompanyId(Long.valueOf(task.getCompanyId()));
urgentProcessingUser.setTaskTypeId(task.getTaskType());
urgentProcessingUser.setDeptId(SecurityUtils.getLoginUser().getSysUser().getDeptId());
switch (task.getTaskStatus()) {
case 30:
urgentProcessingUser.setTaskStatus(TaskStatusEnum.STAY_BRANCH_AUDIT.getInfo());
break;
case 31:
urgentProcessingUser.setTaskStatus(TaskStatusEnum.STAY_RESPONSIBLE_DEPARTMENT_AUDIT.getInfo());
break;
case 32:
urgentProcessingUser.setTaskStatus(TaskStatusEnum.STAY_INTERNAL_AUDIT.getInfo());
break;
}
AjaxResult ajaxResult = remoteUserService.urgentProcessingUser(urgentProcessingUser);
if (ajaxResult.isSuccess()) {
List<SysUser> userList = (List<SysUser>) ajaxResult.get("data");
String message ="尊敬的用户,宁夏智慧仓储管理系统提醒您:您有一个领料单号为:"+ code +"的领料申请待处理,请及时查看";
if (CollectionUtils.isNotEmpty(userList)) {
for (SysUser sysUser : userList) {
if (StringUtils.isNotBlank(sysUser.getPhonenumber())) {
try {
remoteUserService.send(sysUser.getPhonenumber(), message);
} catch (Exception e) {
log.info("手机号为:{}, 发送短信失败", sysUser.getPhonenumber());
}
}
}
}
}
return AjaxResult.success("任务创建成功");
} catch (Exception e) {
return AjaxResult.error("创建任务失败," + e.getCause().toString() + "," + e.getMessage());

View File

@ -13,12 +13,16 @@ import com.bonus.sgzb.base.api.domain.BmFlowRecord;
import com.bonus.sgzb.base.api.domain.BmFlowRelation;
import com.bonus.sgzb.common.core.constant.Constants;
import com.bonus.sgzb.common.core.domain.R;
import com.bonus.sgzb.common.core.enums.TaskStatusEnum;
import com.bonus.sgzb.common.core.utils.DateUtils;
import com.bonus.sgzb.common.core.utils.StringUtils;
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import com.bonus.sgzb.common.security.utils.SecurityUtils;
import com.bonus.sgzb.system.api.RemoteUserService;
import com.bonus.sgzb.system.api.domain.SysUser;
import com.bonus.sgzb.system.api.domain.UrgentProcessingUser;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -191,6 +195,7 @@ public class TmTaskServiceImpl implements TmTaskService {
}
}
}
sendMessageToLeader(record);
} else {
// 先审核任务表
result += tmTaskMapper.updateTmTaskAuditStatus(record);
@ -214,6 +219,7 @@ public class TmTaskServiceImpl implements TmTaskService {
}
}
}
sendMessageToLeader(record);
}
} else {
return 0;
@ -222,6 +228,45 @@ public class TmTaskServiceImpl implements TmTaskService {
}
/**
* 领料申请审批逐级发送短信通知相关人员审核方法抽取
* @param record
*/
private void sendMessageToLeader(TmTask record) {
UrgentProcessingUser urgentProcessingUser = new UrgentProcessingUser();
urgentProcessingUser.setCompanyId(Long.valueOf(record.getCompanyId()));
urgentProcessingUser.setDeptId(SecurityUtils.getLoginUser().getSysUser().getDeptId());
urgentProcessingUser.setTaskTypeId(record.getTaskType());
switch (record.getTaskStatus()) {
case 30:
urgentProcessingUser.setTaskStatus(TaskStatusEnum.STAY_BRANCH_AUDIT.getInfo());
break;
case 31:
urgentProcessingUser.setTaskStatus(TaskStatusEnum.STAY_RESPONSIBLE_DEPARTMENT_AUDIT.getInfo());
break;
case 32:
urgentProcessingUser.setTaskStatus(TaskStatusEnum.STAY_INTERNAL_AUDIT.getInfo());
break;
}
AjaxResult ajaxResult = remoteUserService.urgentProcessingUser(urgentProcessingUser);
if (ajaxResult.isSuccess()) {
List<SysUser> userList = (List<SysUser>) ajaxResult.get("data");
log.info("查询到待发送短信人员信息为:{}", userList);
String message ="尊敬的用户,宁夏智慧仓储管理系统提醒您:您有一个领料单号为:"+ record.getCode() +"的领料申请待处理,请及时查看";
if (CollectionUtils.isNotEmpty(userList)) {
for (SysUser sysUser : userList) {
if (StringUtils.isNotBlank(sysUser.getPhonenumber())) {
try {
remoteUserService.send(sysUser.getPhonenumber(), message);
} catch (Exception e) {
log.info("手机号为:{}, 发送短信失败", sysUser.getPhonenumber());
}
}
}
}
}
}
private void smsNotification(LeaseApplyDetails details, String code) {
TmTask tmTask = new TmTask();
tmTask.setId(details.getParenntId().toString());

View File

@ -45,10 +45,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="getMaUserList" resultType="com.bonus.sgzb.base.domain.MaintenanceGang">
SELECT su.user_id as userId, su.nick_name as userName FROM `sys_user` su
LEFT JOIN sys_user_role sur ON su.user_id = sur.user_id
SELECT DISTINCT
su.user_id AS userId,
su.nick_name AS userName
FROM
`sys_user` su
LEFT JOIN sys_user_role sur ON su.user_id = sur.user_id
LEFT JOIN sys_role sr ON sr.role_id = sur.role_id
WHERE sr.role_id = '102' AND su.del_flag = '0'
WHERE
sr.role_id in (133,134)
AND su.del_flag = '0'
<if test="userName != null and userName != ''">
AND su.nick_name like concat('%', #{userName}, '%')
</if>

View File

@ -4,10 +4,13 @@ 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.material.config.PageResultVo;
import com.bonus.sgzb.material.domain.LeaseApplyDetails;
import com.bonus.sgzb.material.domain.MaWholeSetDto;
import com.bonus.sgzb.material.domain.MaWholeTreeVo;
import com.bonus.sgzb.material.domain.MaWholeVo;
import com.bonus.sgzb.material.service.MaWholeSetService;
import com.bonus.sgzb.material.vo.ScrapApplyDetailsVO;
import com.github.pagehelper.PageHelper;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
@ -35,8 +38,7 @@ public class MaWholeSetController extends BaseController {
*/
@ApiOperation("新增整套抱杆管理")
@PostMapping("/addOrUpdate")
public AjaxResult addOrUpdate(@ApiParam(value = "添加信息", required = true)
@RequestBody MaWholeSetDto dto) {
public AjaxResult addOrUpdate(@ApiParam(value = "添加信息", required = true) @RequestBody MaWholeSetDto dto) {
if (dto.getId() != null) {
log.info("修改整套抱杆管理:{}", dto);
return maWholeSetService.update(dto);
@ -51,11 +53,11 @@ public class MaWholeSetController extends BaseController {
* @return
*/
@ApiOperation("查询整套抱杆管理")
@PostMapping("/selectList")
public AjaxResult selectList(@ApiParam(value = "查询信息") @RequestBody MaWholeSetDto dto) {
log.info("查询整套抱杆管理:{}", dto);
PageResultVo<MaWholeVo> result = maWholeSetService.selectList(dto);
return AjaxResult.success(result);
@GetMapping("/selectList")
public TableDataInfo selectList(MaWholeSetDto dto) {
PageHelper.startPage(dto.getPageNum() == 0 ? 1 : dto.getPageNum(), dto.getPageSize());
List<MaWholeVo> maWholeVos = maWholeSetService.selectList(dto);
return getDataTable(maWholeVos);
}
/**
@ -64,12 +66,11 @@ public class MaWholeSetController extends BaseController {
* @return
*/
@ApiOperation("查询整套抱杆明细")
@PostMapping("/selectListById")
public TableDataInfo selectListById(@ApiParam(value = "查询信息") @RequestBody MaWholeSetDto dto) {
log.info("查询整套抱杆明细:{}", dto);
@GetMapping("/selectListById")
public AjaxResult selectListById(MaWholeSetDto dto) {
startPage();
List<MaWholeVo> list = maWholeSetService.selectListById(dto);
return getDataTable(list);
return AjaxResult.success(getDataTable(list));
}
/**
@ -96,4 +97,18 @@ public class MaWholeSetController extends BaseController {
log.info("根据id删除整套抱杆{}", dto);
return maWholeSetService.deleteById(dto);
}
/**
* 查询整套抱杆明细
* @param wholeTypeName
* @return
*/
@ApiOperation("领料申请查询成套抱杆设备")
@GetMapping("/selectListByWholeTypeName")
public AjaxResult selectListByWholeTypeName(String wholeTypeName) {
List<LeaseApplyDetails> list = maWholeSetService.selectListByWholeTypeName(wholeTypeName);
return AjaxResult.success(list);
}
}

View File

@ -42,6 +42,11 @@ public class LeaseApplyDetails implements Serializable {
*/
@ApiModelProperty(value = "机具Id")
private Integer maId;
/**
* 配件数量
*/
@ApiModelProperty(value = "配件数量")
private Integer partNum;
/**
* 类型名称

View File

@ -24,16 +24,30 @@ public class MaWhole {
private Integer id;
/** 父级ID */
@ApiModelProperty(value = "父级ID")
@ApiModelProperty(value = "父级类型ID")
private Integer parentId;
/** 父级ID */
@ApiModelProperty(value = "类型ID")
private Integer typeId;
@ApiModelProperty(value = "数量")
private Integer deviceNum;
/** 配套数量 */
@ApiModelProperty(value = "配套数量")
private Integer totalNum;
/** 设备id */
@ApiModelProperty(value = "设备id")
private Integer deviceTypeId;
/** 设备类型 */
@ApiModelProperty(value = "设备类型1主体设备 2配套设备")
private Integer ascriptionType;
/** 配套名称 */
@ApiModelProperty(value = "配套名称")
private String wholeTypeName;
/** 配套名称 */
@ApiModelProperty(value = "所属公司")
private String companyId;
/** 创建时间 */
@ApiModelProperty(value = "创建时间")

View File

@ -36,9 +36,22 @@ public class MaWholeSetDto {
/** 关键字 */
@ApiModelProperty(value = "关键字")
private String keyWord;
/** 配套名称 */
@ApiModelProperty(value = "配套名称")
private String wholeTypeName;
/** 关键字 */
@ApiModelProperty(value = "所属公司")
private String companyId;
/** 关键字 */
@ApiModelProperty(value = "创建人")
private Integer createBy;
@ApiModelProperty(value = "开始时间")
private String startTime;
@ApiModelProperty(value = "结束时间")
private String endTime;
/** 表单对象集合 */
@ApiModelProperty(value = "表单对象集合")
private List<MaWhole> wholeList;
private List<MaWhole> deviceInfo;
}

View File

@ -1,10 +1,13 @@
package com.bonus.sgzb.material.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
/**
* 整套抱杆最外层表单vo
* @Author ma_sh
@ -18,10 +21,25 @@ public class MaWholeVo {
/** 主键ID */
@ApiModelProperty(value = "主键ID")
private Integer id;
/** 主键ID */
@ApiModelProperty(value = "设备类型1主体设备 2配套设备")
private Integer ascriptionType;
/** 设备id */
@ApiModelProperty(value = "设备id")
private Integer deviceTypeId;
/** 设备id */
@ApiModelProperty(value = "设备数量")
private Integer deviceNum;
/** 机具名称 */
@ApiModelProperty(value = "机具名称")
private String typeName;
/** 机具名称 */
@ApiModelProperty(value = "配套设备类型")
private String deviceAscription;
/** 机具名称 */
@ApiModelProperty(value = "机具名称")
private String deviceType;
/** 规格型号 */
@ApiModelProperty(value = "规格型号")
@ -30,8 +48,15 @@ public class MaWholeVo {
/** 配套名称 */
@ApiModelProperty(value = "配套名称")
private String wholeTypeName;
/** 创建人 */
@ApiModelProperty(value = "创建人")
private String nickName;
/** 创建日期 */
@ApiModelProperty(value = "创建日期")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
/** 套装所需配件数量 */
@ApiModelProperty(value = "套装所需配件数量")
@ApiModelProperty(value = "套装所需配件种类数量")
private Integer totalNum;
}

View File

@ -1,10 +1,7 @@
package com.bonus.sgzb.material.mapper;
import com.bonus.sgzb.base.api.domain.MaType;
import com.bonus.sgzb.material.domain.MaWhole;
import com.bonus.sgzb.material.domain.MaWholeSetDto;
import com.bonus.sgzb.material.domain.MaWholeVo;
import com.bonus.sgzb.material.domain.TreeSelectId;
import com.bonus.sgzb.material.domain.*;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -24,11 +21,11 @@ public interface MaWholeSetMapper {
int insert(@Param("wholeList") List<MaWhole> wholeList);
/**
* 根据parentId查询去重
* @param parentId
* 根据selectByWholeTypeName查询
* @param wholeTypeName
* @return
*/
int selectByParentId(@Param("parentId") Integer parentId);
int selectByWholeTypeName(String wholeTypeName);
/**
* 查询整套抱杆管理
@ -46,10 +43,10 @@ public interface MaWholeSetMapper {
/**
* 根据id删除
* @param id
* @param
* @return
*/
int deleteById(@Param("id") Integer id);
int deleteById(MaWholeSetDto dto);
/**
* 根据id去ma_whole_set表中查询typeid
@ -78,4 +75,6 @@ public interface MaWholeSetMapper {
* @return
*/
List<TreeSelectId> selectId(@Param("typeId") List<Integer> typeId);
List<LeaseApplyDetails> selectListByWholeTypeName(String wholeTypeName);
}

View File

@ -2,6 +2,7 @@ package com.bonus.sgzb.material.service;
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import com.bonus.sgzb.material.config.PageResultVo;
import com.bonus.sgzb.material.domain.LeaseApplyDetails;
import com.bonus.sgzb.material.domain.MaWholeSetDto;
import com.bonus.sgzb.material.domain.MaWholeTreeVo;
import com.bonus.sgzb.material.domain.MaWholeVo;
@ -27,7 +28,7 @@ public interface MaWholeSetService {
* @param dto
* @return
*/
PageResultVo<MaWholeVo> selectList(MaWholeSetDto dto);
List<MaWholeVo> selectList(MaWholeSetDto dto);
/**
* 查询整套抱杆明细
@ -56,4 +57,6 @@ public interface MaWholeSetService {
* @return
*/
MaWholeTreeVo selectListTree(Integer id);
List<LeaseApplyDetails> selectListByWholeTypeName(String wholeTypeName);
}

View File

@ -18,6 +18,7 @@ import java.util.List;
/**
* 整套抱杆操作实现层
*
* @Author ma_sh
* @create 2024/4/15 17:17
*/
@ -30,6 +31,7 @@ public class MaWholeSetServiceImpl implements MaWholeSetService {
/**
* 新增整套抱杆管理
*
* @param dto
* @return
*/
@ -39,54 +41,52 @@ public class MaWholeSetServiceImpl implements MaWholeSetService {
if (dto == null) {
return AjaxResult.error("参数不能为空!!!");
}
if (dto.getParentId() == null) {
return AjaxResult.error("父级id不能为空");
//先查询是否有重复的配套名称
if (selectByWholeTypeName(dto.getWholeTypeName()) > 0) {
return AjaxResult.error("成套名称已存在");
}
int count = selectByParentId(dto.getParentId());
if (count != 0) {
return AjaxResult.error("该物品类型已经绑定相关配件,无法再次绑定,请重新选择!!!");
}
if (CollectionUtils.isNotEmpty(dto.getWholeList())) {
for (MaWhole maWhole : dto.getWholeList()) {
if (CollectionUtils.isNotEmpty(dto.getDeviceInfo())) {
for (MaWhole maWhole : dto.getDeviceInfo()) {
maWhole.setCreateBy(dto.getCreateBy());
maWhole.setCompanyId(dto.getCompanyId());
maWhole.setTypeId(maWhole.getDeviceTypeId());
maWhole.setTotalNum(maWhole.getDeviceNum());
maWhole.setWholeTypeName(dto.getWholeTypeName());
maWhole.setParentId(dto.getParentId());
}
}
int res = 0;
try {
res = insertMaWholeSet(dto.getWholeList());
if (res == 0) {
log.error("insertMaWholeSet方法插入异常");
throw new RuntimeException("insertMaWholeSet方法插入异常");
int res = 0;
try {
res = insertMaWholeSet(dto.getDeviceInfo());
if (res == 0) {
log.error("insertMaWholeSet方法插入异常");
throw new RuntimeException("insertMaWholeSet方法插入异常");
}
} catch (Exception e) {
log.error("新增计划管理异常:{}", e.getMessage());
return AjaxResult.error(ExceptionEnum.SAVE_TO_DATABASE.getCode(), ExceptionEnum.SAVE_TO_DATABASE.getMsg());
}
} catch (Exception e) {
log.error("新增计划管理异常:{}",e.getMessage());
return AjaxResult.error(ExceptionEnum.SAVE_TO_DATABASE.getCode(), ExceptionEnum.SAVE_TO_DATABASE.getMsg());
return AjaxResult.success("新增成功", res);
} else {
return AjaxResult.error("请选择主/配套设备");
}
return AjaxResult.success("新增成功", res);
}
/**
* 查询整套抱杆管理
*
* @param dto
* @return
*/
@Override
public PageResultVo<MaWholeVo> selectList(MaWholeSetDto dto) {
List<MaWholeVo> list = mapper.selectList(dto);
PageHelper.startPage(dto.getPageNum() == 0 ? 1 : dto.getPageNum(), dto.getPageSize());
PageResultVo pageResult = new PageResultVo();
// 分页信息
PageInfo<MaWholeVo> pageInfo = new PageInfo<>(list);
pageResult.setTotalCount(pageInfo.getTotal());
pageResult.setTotalPageCount(pageInfo.getPages());
pageResult.setResult(list);
pageResult.setPageNum(dto.getPageNum());
pageResult.setPageSize(dto.getPageSize());
return pageResult;
public List<MaWholeVo> selectList(MaWholeSetDto dto) {
return mapper.selectList(dto);
}
/**
* 查询整套抱杆明细
*
* @param dto
* @return
*/
@ -97,23 +97,24 @@ public class MaWholeSetServiceImpl implements MaWholeSetService {
/**
* 根据id删除
*
* @param dto
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public AjaxResult deleteById(MaWholeSetDto dto) {
if (dto.getId() == null) {
if (dto == null) {
return AjaxResult.error("删除标识id为空无法进行删除");
}
int res = 0;
try {
res = deleteMaWhole(dto.getId());
res = deleteMaWhole(dto);
if (res == 0) {
throw new RuntimeException("删除失败");
}
} catch (Exception e) {
log.error("删除异常:{}",e.getMessage());
log.error("删除异常:{}", e.getMessage());
return AjaxResult.error(ExceptionEnum.DELETE_TO_DATABASE.getCode(), ExceptionEnum.DELETE_TO_DATABASE.getMsg());
}
return AjaxResult.success("删除成功", res);
@ -121,15 +122,17 @@ public class MaWholeSetServiceImpl implements MaWholeSetService {
/**
* 根据id删除整套配件信息
* @param id
*
* @param
* @return
*/
private int deleteMaWhole(Integer id) {
return mapper.deleteById(id);
private int deleteMaWhole(MaWholeSetDto dto) {
return mapper.deleteById(dto);
}
/**
* 修改整套抱杆管理
*
* @param dto
* @return
*/
@ -137,36 +140,40 @@ public class MaWholeSetServiceImpl implements MaWholeSetService {
@Transactional(rollbackFor = Exception.class)
public AjaxResult update(MaWholeSetDto dto) {
log.info("修改整套抱杆管理传参:{}", dto);
int count = selectByParentId(dto.getParentId());
if (!dto.getId().equals(dto.getParentId()) && count != 0) {
return AjaxResult.error("该物品类型已经配套相关配件,无法再次绑定,请重新提交修改!!!");
}
if (CollectionUtils.isNotEmpty(dto.getWholeList())) {
for (MaWhole maWhole : dto.getWholeList()) {
if (CollectionUtils.isNotEmpty(dto.getDeviceInfo())) {
for (MaWhole maWhole : dto.getDeviceInfo()) {
maWhole.setCreateBy(dto.getCreateBy());
maWhole.setCompanyId(dto.getCompanyId());
maWhole.setTypeId(maWhole.getDeviceTypeId());
maWhole.setTotalNum(maWhole.getDeviceNum());
maWhole.setWholeTypeName(dto.getWholeTypeName());
maWhole.setParentId(dto.getParentId());
}
}
int res = 0;
try {
res = deleteMaWhole(dto.getId());
if (res == 0) {
log.error("deleteById方法删除异常");
throw new RuntimeException("deleteById方法删除异常");
int res = 0;
try {
deleteMaWhole(dto);
res = insertMaWholeSet(dto.getDeviceInfo());
if (res == 0) {
log.error("insertMaWholeSet方法插入异常");
throw new RuntimeException("insertMaWholeSet方法插入异常");
}
/* int count = selectByWholeTypeName(dto.getWholeTypeName());
if (count > 1) {
throw new RuntimeException("配套名称已重复,请重新输入");
}*/
} catch (Exception e) {
e.printStackTrace();
return AjaxResult.error(ExceptionEnum.UPDATE_TO_DATABASE.getCode(), ExceptionEnum.UPDATE_TO_DATABASE.getMsg());
}
res = insertMaWholeSet(dto.getWholeList());
if (res == 0) {
log.error("insertMaWholeSet方法插入异常");
throw new RuntimeException("insertMaWholeSet方法插入异常");
}
} catch (Exception e) {
e.printStackTrace();
return AjaxResult.error(ExceptionEnum.UPDATE_TO_DATABASE.getCode(), ExceptionEnum.UPDATE_TO_DATABASE.getMsg());
return AjaxResult.success("修改成功", res);
} else {
return AjaxResult.error("请选择主/配套设备");
}
return AjaxResult.success("修改成功", res);
}
/**
* 修改时查询整套抱杆明细
*
* @param id
* @return
*/
@ -186,19 +193,28 @@ public class MaWholeSetServiceImpl implements MaWholeSetService {
return treeVo;
}
@Override
public List<LeaseApplyDetails> selectListByWholeTypeName(String wholeTypeName) {
return mapper.selectListByWholeTypeName(wholeTypeName);
}
/**
* 方法提取新增ma_whole_set表
*
* @param wholeList
* @return
*/
private int insertMaWholeSet(List<MaWhole> wholeList) { return mapper.insert(wholeList); }
private int insertMaWholeSet(List<MaWhole> wholeList) {
return mapper.insert(wholeList);
}
/**
* 根据parentId查询去重
* @param parentId
* 根据WholeTypeName查询
*
* @param wholeTypeName
* @return
*/
private int selectByParentId(Integer parentId) {
return mapper.selectByParentId(parentId);
private int selectByWholeTypeName(String wholeTypeName) {
return mapper.selectByWholeTypeName(wholeTypeName);
}
}

View File

@ -41,44 +41,30 @@
<insert id="insert">
<foreach item="item" index="index" collection="wholeList" separator=";">
insert into ma_whole_set
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="item.id != null">type_id,</if>
<if test="item.parentId != null">parent_id,</if>
<if test="item.totalNum != null">part_num,</if>
<if test="item.wholeTypeName != null">whole_type_name,</if>
<if test="item.createBy != null">create_by,</if>
<if test="item.createTime != null">create_time,</if>
status
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="item.id != null">#{item.id},</if>
<if test="item.parentId != null">#{item.parentId},</if>
<if test="item.totalNum != null">#{item.totalNum},</if>
<if test="item.wholeTypeName != null">#{item.wholeTypeName},</if>
<if test="item.createBy != null">#{item.createBy},</if>
<if test="item.createTime != null">#{item.createTime},</if>
1
</trim>
insert into ma_whole_set (type_id,parent_id,part_num,whole_type_name,create_by,ascription_type,create_time,status,company_id)
values(#{item.typeId},#{item.parentId},#{item.totalNum},#{item.wholeTypeName},#{item.createBy},#{item.ascriptionType}, now(),1,#{item.companyId})
</foreach>
</insert>
<delete id="deleteById" parameterType="java.lang.Integer">
<delete id="deleteById">
delete from ma_whole_set
where parent_id = #{id}
where parent_id = #{id} and whole_type_name = #{wholeTypeName}
</delete>
<select id="selectByParentId" resultType="java.lang.Integer">
<select id="selectByWholeTypeName" resultType="java.lang.Integer">
select COUNT(*) from ma_whole_set
where parent_id = #{parentId}
where whole_type_name = #{wholeTypeName}
</select>
<select id="selectList" resultType="com.bonus.sgzb.material.domain.MaWholeVo">
SELECT
mws.parent_id AS id,
mws.whole_type_name AS wholeTypeName,
mws.create_time AS createTime,
SUM(CASE WHEN mws.ascription_type = 2 THEN 1 ELSE 0 END) AS totalNum,
mt2.type_name AS typeName,
mt.type_name AS typeModelName,
SUM(mws.part_num) AS totalNum
su.nick_name AS nickName
FROM ma_whole_set mws
JOIN sys_user su ON su.user_id = mws.create_by
JOIN ma_type mt ON mws.parent_id = mt.type_id
JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
JOIN ma_type mt3 ON mt3.type_id = mt2.parent_id
@ -86,20 +72,28 @@
WHERE
mt.`status` = '0'
AND mt.del_flag = '0'
<if test="keyWord != null and keyWord != ''">
and (
mt2.type_name like concat('%', #{keyWord}, '%') or
mt.type_name like concat('%', #{keyWord}, '%')
)
AND mws.company_id = #{companyId}
<if test="wholeTypeName != null and wholeTypeName != ''">
and mws.whole_type_name like concat('%', #{wholeTypeName}, '%')
</if>
GROUP BY mws.parent_id
<if test="parentId != null and parentId != ''">
and mws.parent_id = #{parentId}
</if>
<if test="startTime != null and startTime != '' and endTime != null and endTime != '' ">
and mws.create_time BETWEEN CONCAT(#{startTime}, ' 00:00:00') AND CONCAT(#{endTime}, ' 23:59:59')
</if>
GROUP BY mws.parent_id,mws.whole_type_name
</select>
<select id="selectListById" resultType="com.bonus.sgzb.material.domain.MaWholeVo">
SELECT
mws.parent_id AS id,
mt.type_id as deviceTypeId,
mt2.type_name AS typeName,
mt.type_name AS typeModelName,
mws.part_num AS totalNum
mt.type_name AS deviceType,
mws.whole_type_name as wholeTypeName,
case when mws.ascription_type = 1 then '主体设备' else '配套设备' end as deviceAscription,
mws.ascription_type as ascriptionType,
mws.part_num AS deviceNum
FROM
ma_whole_set mws
JOIN ma_type mt ON mws.type_id = mt.type_id
@ -107,15 +101,8 @@
JOIN ma_type mt3 ON mt3.type_id = mt2.parent_id
JOIN ma_type mt4 ON mt4.type_id = mt3.parent_id
WHERE
<if test="id != null and id != ''">
mws.parent_id = #{id}
</if>
<if test="keyWord != null and keyWord != ''">
and (
mt2.type_name like concat('%', #{keyWord}, '%') or
mt.type_name like concat('%', #{keyWord}, '%')
)
</if>
mws.parent_id = #{id} AND
mws.whole_type_name = #{wholeTypeName}
</select>
<select id="selectTypeTree" resultType="com.bonus.sgzb.material.domain.TreeSelectId">
@ -176,5 +163,28 @@
#{item}
</foreach>
</select>
<select id="selectListByWholeTypeName" resultType="com.bonus.sgzb.material.domain.LeaseApplyDetails">
SELECT
mt.unit_name unitName,
mt.type_id typeId,
mt.num,
mt.type_name typeModelName,
mt2.type_name typeName,
mws2.part_num partNum
FROM
ma_type mt
LEFT JOIN ma_type mt2 ON mt.parent_id = mt2.type_id
LEFT JOIN ma_whole_set mws2 ON mws2.type_id = mt.type_id
AND mws2.whole_type_name = #{wholeTypeName}
WHERE
mt.type_id IN (
SELECT
mws.type_id
FROM
ma_whole_set mws
WHERE
mws.whole_type_name = #{wholeTypeName})
AND mt.`status` = '0'
AND mt.del_flag = '0'
</select>
</mapper>

View File

@ -21,7 +21,7 @@ import com.bonus.sgzb.system.api.domain.SysRole;
import com.bonus.sgzb.system.api.domain.SysUser;
import com.bonus.sgzb.system.api.model.LoginUser;
import com.bonus.sgzb.system.config.RsaUtil;
import com.bonus.sgzb.system.domain.po.UrgentProcessingUser;
import com.bonus.sgzb.system.api.domain.UrgentProcessingUser;
import com.bonus.sgzb.system.service.*;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;

View File

@ -4,9 +4,8 @@ import java.util.List;
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import com.bonus.sgzb.system.api.domain.SysUser;
import com.bonus.sgzb.system.domain.po.UrgentProcessingUser;
import com.bonus.sgzb.system.api.domain.UrgentProcessingUser;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Component;
/**
* 用户 业务层

View File

@ -1,9 +1,7 @@
package com.bonus.sgzb.system.service.impl;
import com.bonus.sgzb.common.core.constant.UserConstants;
import com.bonus.sgzb.common.core.enums.RoleEnum;
import com.bonus.sgzb.common.core.enums.TaskStatusEnum;
import com.bonus.sgzb.common.core.enums.TaskTypeEnum;
import com.bonus.sgzb.common.core.exception.ServiceException;
import com.bonus.sgzb.common.core.utils.SpringUtils;
import com.bonus.sgzb.common.core.utils.StringUtils;
@ -17,14 +15,13 @@ import com.bonus.sgzb.system.api.domain.SysUser;
import com.bonus.sgzb.system.domain.SysPost;
import com.bonus.sgzb.system.domain.SysUserPost;
import com.bonus.sgzb.system.domain.SysUserRole;
import com.bonus.sgzb.system.domain.po.UrgentProcessingUser;
import com.bonus.sgzb.system.api.domain.UrgentProcessingUser;
import com.bonus.sgzb.system.exception.SystemException;
import com.bonus.sgzb.system.mapper.*;
import com.bonus.sgzb.system.service.ISysConfigService;
import com.bonus.sgzb.system.service.ISysUserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
@ -32,7 +29,6 @@ import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import javax.validation.Validator;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
@ -565,13 +561,13 @@ public class SysUserServiceImpl implements ISysUserService {
@Override
public AjaxResult urgentProcessingUser(UrgentProcessingUser urgentProcessingUser) {
log.info("ToDoServiceImpl urgentProcessingUser {} begin" ,urgentProcessingUser);
List<SysUser> userList = new ArrayList<>();
SysUser sysUser = new SysUser();
sysUser.setDeptId(urgentProcessingUser.getDeptId());
// 验证是否为空
if (urgentProcessingUser == null || urgentProcessingUser.getTaskStatus() == null) {
throw new ServiceException(SystemException.TASK_ID_IS_EMPTY_MSG,SystemException.TASK_ID_IS_EMPTY);
}
List<SysUser> userList = new ArrayList<>();
SysUser sysUser = new SysUser();
sysUser.setDeptId(urgentProcessingUser.getDeptId());
switch (urgentProcessingUser.getTaskTypeId()){
//领料任务
case 29: