领料出库接口提交

This commit is contained in:
syruan 2023-12-17 18:01:20 +08:00
parent e78e49f297
commit d73fe10073
16 changed files with 832 additions and 53 deletions

View File

@ -2,9 +2,10 @@ package com.bonus.sgzb.base.api.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
* Description:
@ -20,6 +21,8 @@ import lombok.Data;
@Data
public class LeaseApplyDetails implements Serializable {
private static final long serialVersionUID = 2227217051604273598L;
@ApiModelProperty(value = "")
private Integer id;
@ -47,10 +50,14 @@ public class LeaseApplyDetails implements Serializable {
@ApiModelProperty(value = "已领数量")
private Double alNum;
/** 审批数量 */
@ApiModelProperty(value = "审批数量")
private Double auditNum;
/**
* 状态待审批进行中已出库
*/
@ApiModelProperty(value = "状态(待审批,进行中,已出库)")
@ApiModelProperty(value = "状态(0待审批,1进行中,2已出库)")
private String status;
/**
@ -84,10 +91,9 @@ public class LeaseApplyDetails implements Serializable {
private String remark;
/**
* 数据所属组织
* 设备所属类型
*/
@ApiModelProperty(value = "数据所属组织")
private Integer companyId;
private static final long serialVersionUID = 1L;
}

View File

@ -2,9 +2,11 @@ package com.bonus.sgzb.base.api.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
import java.util.List;
/**
* Description:
@ -20,6 +22,8 @@ import lombok.Data;
@Data
public class LeaseApplyInfo implements Serializable {
private static final long serialVersionUID = 4429196890466663037L;
@ApiModelProperty(value = "id")
private Integer id;
@ -53,6 +57,10 @@ public class LeaseApplyInfo implements Serializable {
@ApiModelProperty(value = "11级审批22级审批")
private String type;
/** 机具规格详情列表 */
@ApiModelProperty(value = "机具规格详情列表")
private List<LeaseApplyDetails> leaseApplyDetails;
/**
* 公司审批人
*/
@ -89,6 +97,18 @@ public class LeaseApplyInfo implements Serializable {
@ApiModelProperty(value = "分管审批备注")
private String deptAuditRemark;
/**
* 机具分公司审批人
*/
@ApiModelProperty(value = "机具分公司审批人")
private String directAuditBy;
/**
* 机具分公司审批时间
*/
@ApiModelProperty(value = "机具分公司审批时间")
private String directAuditTime;
/**
* 创建者
*/
@ -120,10 +140,9 @@ public class LeaseApplyInfo implements Serializable {
private String remark;
/**
* 数据所属组织
* 设备数据所属组织类型
*/
@ApiModelProperty(value = "数据所属组织")
@ApiModelProperty(value = "设备数据所属组织类型")
private Integer companyId;
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,79 @@
package com.bonus.sgzb.base.api.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 领料出库详情表
* @TableName lease_out_details
* @Version 1.0
* @Author 阮世耀
* @Since 2023-12-17
*/
@ApiModel(description = "领料出库详情表", value = "LeaseOutDetails")
@Data
public class LeaseOutDetails implements Serializable {
private static final long serialVersionUID = 2040328845027085291L;
@ApiModelProperty(value = "id")
private Integer id;
/** 任务ID */
@ApiModelProperty(value = "任务ID")
private Integer parentId;
/** 规格ID */
@ApiModelProperty(value = "规格ID")
private Integer typeId;
/** 规格名称 */
@ApiModelProperty(value = "规格名称")
private String typeName;
/** maId */
@ApiModelProperty(value = "maId")
private Integer maId;
/** 协议ID */
@ApiModelProperty(value = "协议ID")
private String agreementId;
/** 预领料数 */
@ApiModelProperty(value = "预领料数")
private Double outNum;
/** 出库类型 */
@ApiModelProperty(value = "出库类型")
private String outType;
/** 创建者 */
@ApiModelProperty(value = "创建者")
private String createBy;
/** 创建时间 */
@ApiModelProperty(value = "创建时间")
private Date createTime;
/** 更新者 */
@ApiModelProperty(value = "更新者")
private String updateBy;
/** 更新时间 */
@ApiModelProperty(value = "更新时间")
private Date updateTime;
/** 备注 */
@ApiModelProperty(value = "备注")
private String remark;
/** 数据所属组织 */
@ApiModelProperty(value = "数据所属组织")
private Integer companyId;
}

View File

@ -2,12 +2,12 @@ package com.bonus.sgzb.base.api.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import lombok.Data;
/**
* Description: 任务表tm_task
* @Author 阮世耀
@ -32,13 +32,13 @@ public class TmTask implements Serializable {
/**
* 任务类型(定义数据字典)
*/
@ApiModelProperty(value="任务类型(定义数据字典)")
@ApiModelProperty(value="任务类型(数据字典)")
private Integer taskType;
/**
* 任务状态(定义数据字典)
*/
@ApiModelProperty(value="任务状态(定义数据字典)")
@ApiModelProperty(value="任务状态(数据字典)")
private Integer taskStatus;
/**
@ -89,6 +89,12 @@ public class TmTask implements Serializable {
@ApiModelProperty(value="领料任务实体")
private LeaseApplyInfo leaseApplyInfo;
/**
* 领料任务实体集合
*/
@ApiModelProperty(value="领料任务实体集合")
private List<LeaseApplyInfo> leaseApplyInfoList;
/**
* 领料任务详情集合
*/

View File

@ -1,7 +1,5 @@
package com.bonus.sgzb.auth.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.bonus.sgzb.common.core.constant.CacheConstants;
import com.bonus.sgzb.common.core.constant.Constants;
import com.bonus.sgzb.common.core.constant.SecurityConstants;
@ -17,6 +15,8 @@ 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.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
@ -159,6 +159,35 @@ public class SysLoginService
}
}
/**
* 根据手机号码重置密码判断Redis中是否有验证码如果有则通过验证并删除key
* @param phone 手机号码
* @param password 密码
* @param code 验证码
*/
private void resetPassword(String phone, String code, Long userId, String password) {
if (password.length() < UserConstants.PASSWORD_MIN_LENGTH || password.length() > UserConstants.PASSWORD_MAX_LENGTH) {
throw new ServiceException("密码长度必须在6到19个字符之间");
}
if (code.length() != UserConstants.CODE_MIN_LENGTH_LOGIN) {
throw new ServiceException("验证码长度需为6位");
}
if (phone.length() != UserConstants.PHONE_DEFAULT_LENGTH_LOGIN) {
throw new ServiceException("手机号码长度不在指定范围");
}
if (remoteUserService.checkCode(phone, code).getCode() != Constants.SUCCESS) {
throw new ServiceException("对不起,您输入的验证码:" + code + " 不存在,请输入有效的验证码");
} else {
// 已验证过的验证码需要清除
redisService.deleteObject("code_" + phone);
// 执行重置密码操作
SysUser user = new SysUser();
user.setUserId(userId);
user.setPassword(SecurityUtils.encryptPassword(password));
}
}
private void isBlackIp(String phone) {
String blackStr = Convert.toStr(redisService.getCacheObject(CacheConstants.SYS_LOGIN_BLACKIPLIST));
if (IpUtils.isMatchedIp(blackStr, IpUtils.getIpAddr()))

View File

@ -0,0 +1,44 @@
package com.bonus.sgzb.app.controller;
import com.bonus.sgzb.app.service.LeaseOutDetailsService;
import com.bonus.sgzb.base.api.domain.LeaseOutDetails;
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 org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
/**
* Description: 任务领料出库详情表控制器
*
* @Author 阮世耀
* @Create 2023/12/17 15:48
* @Version 1.0
*/
@RestController
@RequestMapping("/leaseOutDetails")
public class LeaseOutDetailsController extends BaseController {
@Resource
private LeaseOutDetailsService leaseOutDetailsService;
@Log(title = "获取领料出库详情表", businessType = BusinessType.QUERY)
@GetMapping("/getLeaseList")
public TableDataInfo getLeaseList(@RequestParam(value ="taskId", required = false, defaultValue = "") String taskId){
return getDataTable(leaseOutDetailsService.selectListByParentId(taskId));
}
/**
* 领料出库对库存处理
* @param record 出库内容
*/
@Log(title = "领料出库", businessType = BusinessType.UPDATE)
@PostMapping("/submitOut")
public AjaxResult submitOut(@RequestBody LeaseOutDetails record){
return leaseOutDetailsService.submitOut(record);
}
}

View File

@ -1,12 +1,14 @@
package com.bonus.sgzb.app.controller;
import cn.hutool.core.collection.CollUtil;
import com.bonus.sgzb.base.api.domain.LeaseApplyDetails;
import com.bonus.sgzb.base.api.domain.LeaseApplyInfo;
import com.bonus.sgzb.base.api.domain.TmTask;
import com.bonus.sgzb.app.service.LeaseApplyDetailsService;
import com.bonus.sgzb.app.service.LeaseApplyInfoService;
import com.bonus.sgzb.app.service.TmTaskService;
import com.bonus.sgzb.base.api.domain.LeaseApplyDetails;
import com.bonus.sgzb.base.api.domain.LeaseApplyInfo;
import com.bonus.sgzb.base.api.domain.TmTask;
import com.bonus.sgzb.common.core.utils.StringUtils;
import com.bonus.sgzb.common.core.web.controller.BaseController;
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import com.bonus.sgzb.common.log.annotation.Log;
import com.bonus.sgzb.common.log.enums.BusinessType;
@ -22,7 +24,7 @@ import java.util.List;
*/
@RestController
@RequestMapping("/tm_task")
public class TmTaskController {
public class TmTaskController extends BaseController {
/**
* 服务对象
@ -36,12 +38,25 @@ public class TmTaskController {
@Resource
private LeaseApplyDetailsService leaseApplyDetailsService; // 领料申请明细表Service
/**
* 领料审核分公司分管机具分公司统一接口
* @param task 审核信息
* @return 结果
*/
@Log(title = "领料审核", businessType = BusinessType.UPDATE)
@PostMapping("auditLeaseByCompany")
public AjaxResult auditLeaseByCompany(@RequestBody TmTask task) {
return toAjax(tmTaskService.updateLeaseTaskAuditInfo(task));
}
/**
* 往来单位提交工程领用机具信息
*
* @return 结果
*/
@Log(title = "任务表", businessType = BusinessType.INSERT)
@Log(title = "往来单位提交领料申请", businessType = BusinessType.INSERT)
@PostMapping("submitLeaseApply")
public AjaxResult submitLeaseApply(@RequestBody TmTask task) {
if (StringUtils.isNull(task)) {
@ -105,6 +120,90 @@ public class TmTaskController {
}
/**
* 机具分公司直接创建领料申请
* @param task 任务信息
* @return 结果
*/
@Log(title = "机具分公司创建领料申请", businessType = BusinessType.INSERT)
@PostMapping("directLeaseApply")
public AjaxResult directLeaseApply(@RequestBody TmTask task) {
if (StringUtils.isNull(task)) {
return AjaxResult.error("参数错误");
}
try {
// 创建任务
boolean addTaskResult = tmTaskService.insertSelective(task) > 0;
if (addTaskResult && task.getLeaseApplyInfo() != null) {
if (CollUtil.isNotEmpty(task.getLeaseApplyDetails())) {
return AjaxResult.error("领料设备明细为空,请重新选择后上传!");
}
if (StringUtils.isNull(task.getLeaseApplyInfo())) {
return AjaxResult.error("领料任务信息为空,请重新选择后上传!");
}
// 获取任务编号
String taskId = task.getId();
// 根据设备所属分公司拆分集合
List<List<LeaseApplyDetails>> deviceByCompanyList = CollUtil.group(task.getLeaseApplyDetails(), LeaseApplyDetails::getCompanyId);
// 对拆分后的集合进行遍历
for (List<LeaseApplyDetails> leaseApplyDetailsList : deviceByCompanyList) {
// 判断拆分后的集合内是否有数据
if (CollUtil.isNotEmpty(leaseApplyDetailsList)) {
// 对领料任务表的对象做数据处理
LeaseApplyInfo leaseApplyInfo = task.getLeaseApplyInfo();
leaseApplyInfo.setCode(tmTaskService.genderLeaseCode()); // 创建领料单号
leaseApplyInfo.setTaskId(Integer.valueOf(taskId)); // 设置任务ID
leaseApplyInfo.setCompanyId(leaseApplyDetailsList.get(0).getCompanyId()); // 设置设备所属分公司,用于交给哪家审核
leaseApplyInfo.setType("1"); // 设置审批层级先固定2层后期根据接口传入Type区分来源设定
// 创建领料任务返回领料任务编号
boolean addLeaseTaskResult = leaseApplyInfoService.genderLeaseCode(leaseApplyInfo) > 0;
// 领料任务创建完成进行领料任务明细插入
if (addLeaseTaskResult) {
// 领料任务编号
Integer leaseTaskId = leaseApplyInfo.getId();
if (StringUtils.isNotNull(leaseTaskId)) {
// 插入领料任务明细
boolean addLeaseTaskDetailsResult = leaseApplyDetailsService.batchInsert(leaseApplyDetailsList) > 0;
if (addLeaseTaskDetailsResult) {
System.out.println("领料任务创建成功");
} else {
System.out.println("领料任务创建成功,但领料任务明细插入失败");
}
}
} else {
return AjaxResult.error("创建领料任务失败,或领料明细为空");
}
}
}
if (StringUtils.isEmpty(taskId)) { return AjaxResult.error("任务编号为空,创建失败"); }
} else {
return AjaxResult.error("创建任务失败");
}
return AjaxResult.success("任务创建成功,已完成");
} catch (Exception e) {
return AjaxResult.error("创建任务失败," + e.getMessage());
}
}
/**
* 查询机具领料审核列表
* @param task 筛选条件
* @return 列表
*/
@Log(title = "查询机具领料审核列表", businessType = BusinessType.QUERY)
@GetMapping(value = "getLeaseAuditList")
public AjaxResult getLeaseAuditList(TmTask task) {
if (StringUtils.isNull(task)) {
return AjaxResult.error("参数错误");
}
List<TmTask> leaseAuditList = tmTaskService.getLeaseAuditList(task);
return AjaxResult.success(getDataTable(leaseAuditList));
}
/**
* 通过主键查询单条数据
*

View File

@ -0,0 +1,49 @@
package com.bonus.sgzb.app.mapper;
import com.bonus.sgzb.base.api.domain.LeaseOutDetails;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* Description:
*
* @Author 阮世耀
* @Create 2023/12/17 15:10
* @Version 1.0
*/
@Mapper
public interface LeaseOutDetailsMapper {
/** 查询出库详情 */
List<LeaseOutDetails> selectListByParentId(String parentId);
/**
* 修改 lease_apply_details 领料任务详细表的已领数量
*/
int updateLeaseApplyDetailsOutNum(@Param("record") LeaseOutDetails leaseOutDetails);
/** 插入领料出库详细表 */
int insert(LeaseOutDetails record);
/** 插入领料出库详情表 -- 根据字段选择注入 */
int insertSelective(LeaseOutDetails record);
/**
* 减少 (ma_type 设备规格表)的库存数量
*/
int updateMaTypeStockNum(@Param("record") LeaseOutDetails leaseOutDetails);
/**
* 修改机具设备(ma_machine表)的状态为在用
*/
int updateMaMachineStatus(@Param("record") LeaseOutDetails leaseOutDetails);
/**
* 插入(tm_task_agreement 任务协议表)协议信息
*/
int insertAgreementInfo(@Param("record") LeaseOutDetails leaseOutDetails);
}

View File

@ -1,10 +1,13 @@
package com.bonus.sgzb.app.mapper;
import com.bonus.sgzb.base.api.domain.LeaseApplyDetails;
import com.bonus.sgzb.base.api.domain.LeaseApplyInfo;
import com.bonus.sgzb.base.api.domain.TmTask;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* Description:
* @Author 阮世耀
@ -14,6 +17,27 @@ import org.apache.ibatis.annotations.Param;
@Mapper
public interface TmTaskMapper {
/**
* 获取领料审核列表 by TmTask
* @param record 筛选条件
* @return TmTask列表
*/
List<TmTask> getAuditListByLeaseTmTask(TmTask record);
List<LeaseApplyInfo> getAuditListByLeaseInfo(@Param("record") TmTask record);
List<LeaseApplyDetails> getLeaseApplyDetails(@Param("record") LeaseApplyInfo record);
/** 更新TmTask审批状态 */
int updateTmTaskAuditStatus(@Param("record") TmTask record);
/** 更新LeaseApplyInfo审批信息 */
int updateLeaseApplyInfoAuditInfo(@Param("record") LeaseApplyInfo record);
/** 更新leaseApplyDetails审批信息 */
int updateLeaseApplyDetailsAuditInfo(@Param("record") LeaseApplyDetails record);
int deleteByPrimaryKey(Long taskId);
int insert(TmTask record);

View File

@ -0,0 +1,20 @@
package com.bonus.sgzb.app.service;
import com.bonus.sgzb.base.api.domain.LeaseOutDetails;
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import java.util.List;
/**
* Description: 领料出库详情表Service接口
*
* @Author 阮世耀
* @Create 2023/12/17 15:06
* @Version 1.0
*/
public interface LeaseOutDetailsService {
List<LeaseOutDetails> selectListByParentId(String parentId);
AjaxResult submitOut(LeaseOutDetails record);
}

View File

@ -1,8 +1,9 @@
package com.bonus.sgzb.app.service;
import java.util.List;
import com.bonus.sgzb.base.api.domain.TmTask;
import java.util.List;
/**
* Description: 任务表Task
* @Author 阮世耀
@ -12,6 +13,11 @@ import com.bonus.sgzb.base.api.domain.TmTask;
public interface TmTaskService{
List<TmTask> getLeaseAuditList(TmTask record);
/** 领料任务审核状态 */
int updateLeaseTaskAuditInfo(TmTask record);
String genderLeaseCode();
int deleteByPrimaryKey(Long taskId);

View File

@ -0,0 +1,80 @@
package com.bonus.sgzb.app.service.impl;
import com.bonus.sgzb.app.mapper.LeaseOutDetailsMapper;
import com.bonus.sgzb.app.service.LeaseOutDetailsService;
import com.bonus.sgzb.base.api.domain.LeaseOutDetails;
import com.bonus.sgzb.common.core.utils.StringUtils;
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
* Description: 领料出库详情接口实现类
*
* @Author 阮世耀
* @Create 2023/12/17 15:06
* @Version 1.0
*/
@Service(value = "LeaseOutDetailsService")
public class LeaseOutDetailsServiceImpl implements LeaseOutDetailsService {
@Resource
private LeaseOutDetailsMapper leaseOutDetailsMapper;
/**
* 根据任务id查询出库数据
* @param parentId 任务id
* @return 出库数据集合
*/
@Override
public List<LeaseOutDetails> selectListByParentId(String parentId) {
return leaseOutDetailsMapper.selectListByParentId(parentId);
}
/**
* 领料出库处理
* @param record 出库对象
* @return 结果
*/
@Override
public AjaxResult submitOut(LeaseOutDetails record) {
if (StringUtils.isNull(record)) {
return AjaxResult.error("领料出库失败,请检查参数是否填写完整!");
}
// 首先更新领料任务详情表的领料数及状态
int updateLeaseApplyDetailsOutNum = leaseOutDetailsMapper.updateLeaseApplyDetailsOutNum(record);
// 插入领料出库明细表
int insertSelectiveNum = leaseOutDetailsMapper.insertSelective(record);
// 减少 (ma_type 设备规格表)的库存数量
int updateMaTypeStockNum = leaseOutDetailsMapper.updateMaTypeStockNum(record);
// 更新 (ma_machine 设备表)的状态
int updateMaMachineStatus = leaseOutDetailsMapper.updateMaMachineStatus(record);
// 插入(tm_task_agreement 任务协议表)协议信息
int insertAgreementInfo = leaseOutDetailsMapper.insertAgreementInfo(record);
// 进行状态判断
if (updateLeaseApplyDetailsOutNum > 0) {
if (insertSelectiveNum > 0) {
if (updateMaTypeStockNum > 0) {
if (updateMaMachineStatus > 0) {
if (insertAgreementInfo > 0) {
return AjaxResult.success("领料出库成功!");
}
return AjaxResult.error("领料出库失败,插入任务协议信息错误!");
}
return AjaxResult.error("领料出库失败,最后更新设备状态错误!");
}
return AjaxResult.error("出库失败,更新设备规格库存数量时出错!");
}
return AjaxResult.error("出库失败,插入领料出库明细错误!");
}
return AjaxResult.error("出库操作失败,更新领料数量及状态时出错!");
}
}

View File

@ -1,12 +1,18 @@
package com.bonus.sgzb.app.service.impl;
import com.bonus.sgzb.common.core.utils.DateUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import com.bonus.sgzb.base.api.domain.TmTask;
import cn.hutool.core.collection.CollUtil;
import com.bonus.sgzb.app.mapper.TmTaskMapper;
import com.bonus.sgzb.app.service.TmTaskService;
import com.bonus.sgzb.base.api.domain.LeaseApplyDetails;
import com.bonus.sgzb.base.api.domain.LeaseApplyInfo;
import com.bonus.sgzb.base.api.domain.TmTask;
import com.bonus.sgzb.common.core.utils.DateUtils;
import com.bonus.sgzb.common.core.utils.StringUtils;
import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
* Description:
* @Author 阮世耀
@ -20,9 +26,74 @@ public class TmTaskServiceImpl implements TmTaskService{
@Resource
private TmTaskMapper tmTaskMapper;
/**
* 获取审核列表
*/
@Override
public List<TmTask> getLeaseAuditList(TmTask record) {
List<TmTask> tmTaskList = tmTaskMapper.getAuditListByLeaseTmTask(record);
for (TmTask tmTask : tmTaskList) {
if (tmTask != null) {
// 去查询任务分单表
List<LeaseApplyInfo> auditListByLeaseInfo = tmTaskMapper.getAuditListByLeaseInfo(tmTask);
if (auditListByLeaseInfo != null && !auditListByLeaseInfo.isEmpty()) {
// 对领料任务集合查询具体详情
for (LeaseApplyInfo leaseApplyInfo : auditListByLeaseInfo) {
if (leaseApplyInfo != null) {
// 去查询领料任务详情表
List<LeaseApplyDetails> leaseApplyDetails = tmTaskMapper.getLeaseApplyDetails(leaseApplyInfo);
if (leaseApplyDetails != null && !leaseApplyDetails.isEmpty()) {
// 塞入领料任务详情集合
leaseApplyInfo.setLeaseApplyDetails(leaseApplyDetails);
}
}
}
// 存入领料任务实体集合
tmTask.setLeaseApplyInfoList(auditListByLeaseInfo);
}
}
}
return tmTaskList;
}
/**
* 领料任务审核状态
*
* @param record 审核数据及信息
*/
@Override
public int updateLeaseTaskAuditInfo(TmTask record) {
int result = 0;
if (StringUtils.isNotNull(record)) {
// 先审核任务表
result += tmTaskMapper.updateTmTaskAuditStatus(record);
// 再审核领料任务信息表
if (CollUtil.isNotEmpty(record.getLeaseApplyInfoList())) {
for (LeaseApplyInfo leaseApplyInfo : record.getLeaseApplyInfoList()) {
if (leaseApplyInfo != null) {
result += tmTaskMapper.updateLeaseApplyInfoAuditInfo(leaseApplyInfo);
// 再审核领料任务详情表
if (CollUtil.isNotEmpty(leaseApplyInfo.getLeaseApplyDetails())) {
for (LeaseApplyDetails leaseApplyDetails : leaseApplyInfo.getLeaseApplyDetails()) {
if (StringUtils.isNotNull(leaseApplyDetails)) {
result += tmTaskMapper.updateLeaseApplyDetailsAuditInfo(leaseApplyDetails);
}
}
}
}
}
}
} else {
return 0;
}
return result;
}
@Override
public String genderLeaseCode() {
String code = "001";
//String code = "0001";
// 先生成随机4位字符后期根据数据库当月最大CODE值+1
String code = RandomStringUtils.randomAlphanumeric(4);
return "L" + DateUtils.getDate() + "-" + code;
}

View File

@ -0,0 +1,166 @@
<?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.bonus.sgzb.app.mapper.LeaseOutDetailsMapper">
<select id="selectListByParentId" resultType="com.bonus.sgzb.base.api.domain.LeaseOutDetails">
SELECT
lod.id,lod.parent_id,lod.type_id,lod.ma_id,lod.out_num,lod.out_type,lod.create_by,
lod.create_time,lod.update_by,lod.update_time,lod.remark,lod.company_id
FROM
lease_out_details lod
<where>
<if test="_parameter != null and _parameter != '' ">
lod.parent_id = #{parentId}
</if>
</where>
</select>
<update id="updateLeaseApplyDetailsOutNum">
UPDATE
lease_apply_details
SET
al_num = al_num + 1,
<if test="record.updateBy != null and record.updateBy!= '' ">
update_by = #{record.updateBy},
</if>
update_time = now(),
status = '2'
WHERE
parennt_id = #{record.parentId} and type_id = #{record.typeId}
</update>
<insert id="insert">
insert into lease_out_details(parent_id,type_id,ma_id,out_num,out_type,create_by,create_time,update_by,update_time,remark,company_id)
values(#{parentId},#{typeId},#{maId},#{outNum},#{outType},#{createBy},now(),#{updateBy},now(),#{remark},#{companyId})
</insert>
<insert id="insertSelective">
insert into lease_out_details
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="parentId!= null">
parent_id,
</if>
<if test="typeId!= null">
type_id,
</if>
<if test="maId!= null">
ma_id,
</if>
<if test="outNum!= null">
out_num,
</if>
<if test="outType!= null">
out_type,
</if>
<if test="createBy!= null">
create_by,
</if>
<if test="updateBy!= null">
update_by,
</if>
<if test="remark!= null">
remark,
</if>
<if test="companyId!= null">
company_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="parentId!= null">
#{parentId},
</if>
<if test="typeId!= null">
#{typeId},
</if>
<if test="maId!= null">
#{maId},
</if>
<if test="outNum!= null">
#{outNum},
</if>
<if test="outType!= null">
#{outType},
</if>
<if test="createBy!= null">
#{createBy},
</if>
<if test="updateBy!= null">
#{updateBy},
</if>
<if test="remark!= null">
#{remark},
</if>
<if test="companyId!= null">
#{companyId},
</if>
</trim>
</insert>
<update id="updateMaTypeStockNum">
UPDATE
ma_type
SET
num = num - #{record.outNum}
WHERE
type_id = #{record.typeId}
</update>
<update id="updateMaMachineStatus">
UPDATE
ma_machine
SET
ma_status = '16'
<where>
type_id = #{record.typeId}
<if test="record.maId != null and record.maId != ''">
and ma_id = #{record.maId}
</if>
</where>
</update>
<insert id="insertAgreementInfo">
insert into tm_task_agreement
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="record.parentId != null">
task_id,
</if>
<if test="record.agreementId!= null">
agreement_id,
</if>
<if test="record.createBy!= null">
create_by,
</if>
<if test="record.updateBy!= null">
update_by,
</if>
<if test="record.remark!= null">
remark,
</if>
<if test="record.companyId!= null">
company_id,
</if>
create_time
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="record.parentId != null">
#{record.parentId},
</if>
<if test="record.agreementId != null">
#{record.typeId},
</if>
<if test="record.createBy != null">
#{record.createBy},
</if>
<if test="record.updateBy != null">
#{record.updateBy},
</if>
<if test="record.remark != null">
#{record.remark},
</if>
<if test="record.companyId != null">
#{record.companyId},
</if>
now()
</trim>
</insert>
</mapper>

View File

@ -447,4 +447,78 @@
</trim>
</insert>
<select id="getAuditListByLeaseTmTask" resultType="com.bonus.sgzb.base.api.domain.TmTask">
SELECT tt.* FROM tm_task tt WHERE tt.task_type = '29'
</select>
<select id="getAuditListByLeaseInfo" resultType="com.bonus.sgzb.base.api.domain.LeaseApplyInfo">
SELECT
lai.*
FROM
lease_apply_info lai
WHERE
lai.task_id = #{record.taskId} AND lai.`code` = #{record.code}
</select>
<select id="getLeaseApplyDetails" resultType="com.bonus.sgzb.base.api.domain.LeaseApplyDetails">
SELECT
lad.*
FROM
lease_apply_details lad
WHERE
lad.parennt_id = #{record.taskId} AND lad.company_id = #{record.companyId}
</select>
<update id="updateTmTaskAuditStatus">
UPDATE tm_task SET task_status = #{record.taskStatus} WHERE task_id = #{record.taskId}
</update>
<update id="updateLeaseApplyInfoAuditInfo">
UPDATE
lease_apply_info
set
<trim suffixOverrides=",">
<if test="record.companyAuditBy != null and record.companyAuditBy != ''">
company_audit_by = #{record.companyAuditBy},
company_audit_time = #{record.companyAuditTime},
company_audit_remark = #{record.companyAuditRemark},
</if>
<if test="record.deptAuditBy != null and record.deptAuditBy != ''">
dept_audit_by = #{record.companyAuditBy},
dept_audit_time = #{record.companyAuditTime},
dept_audit_remark = #{record.companyAuditRemark},
</if>
<if test="record.directAuditBy != null and record.directAuditBy != ''">
direct_audit_by = #{record.directAuditBy},
direct_audit_time = #{record.directAuditTime}
</if>
</trim>
WHERE
task_id = #{record.taskId}
</update>
<update id="updateLeaseApplyDetailsAuditInfo">
update
lease_apply_details
set
<trim suffixOverrides=",">
<if test="record.auditNum != null and record.auditNum != '' ">
audit_num = #{record.auditNum},
</if>
<if test="record.alNum != null and record.alNum != '' ">
al_num = #{record.alNum},
</if>
<if test="record.status!= null and record.status!= '' ">
status = #{record.status},
</if>
<if test="record.updateBy != null and record.updateBy != '' ">
update_by = #{record.updateBy},
</if>
<if test="record.updateTime!= null and record.updateTime != '' ">
update_time = #{record.updateTime}
</if>
</trim>
where
parennt_id = #{record.parenntId}
</update>
</mapper>

View File

@ -1,30 +1,10 @@
package com.bonus.sgzb.system.controller;
import java.io.IOException;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import com.bonus.sgzb.common.core.constant.Constants;
import com.bonus.sgzb.common.core.constant.SecurityConstants;
import com.bonus.sgzb.common.core.exception.ServiceException;
import com.bonus.sgzb.system.api.RemoteUserService;
import com.bonus.sgzb.system.service.*;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import com.bonus.sgzb.common.core.constant.UserConstants;
import com.bonus.sgzb.common.core.domain.R;
import com.bonus.sgzb.common.core.exception.ServiceException;
import com.bonus.sgzb.common.core.utils.StringUtils;
import com.bonus.sgzb.common.core.utils.poi.ExcelUtil;
import com.bonus.sgzb.common.core.web.controller.BaseController;
@ -35,10 +15,24 @@ import com.bonus.sgzb.common.log.enums.BusinessType;
import com.bonus.sgzb.common.security.annotation.InnerAuth;
import com.bonus.sgzb.common.security.annotation.RequiresPermissions;
import com.bonus.sgzb.common.security.utils.SecurityUtils;
import com.bonus.sgzb.system.api.RemoteUserService;
import com.bonus.sgzb.system.api.domain.SysDept;
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.service.*;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**
* 用户信息
@ -292,12 +286,25 @@ public class SysUserController extends BaseController
* 根据手机验证码重制密码
*/
@RequiresPermissions("system:user:edit")
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
@Log(title = "根据手机验证码重制密码", businessType = BusinessType.UPDATE)
@PutMapping("/resetPwdByCode")
public AjaxResult resetPwdByCode(String phone, String code, String password) {
if (StringUtils.isEmpty(phone) || StringUtils.isEmpty(code) || StringUtils.isEmpty(password)) {
return AjaxResult.error("参数错误");
public AjaxResult resetPwdByCode(String phone, Long userId, String code, String password) {
if (StringUtils.isEmpty(phone) || StringUtils.isEmpty(code) || StringUtils.isEmpty(password) || userId == null) {
return AjaxResult.error("参数不能为空");
}
if (password.length() < UserConstants.PASSWORD_MIN_LENGTH || password.length() > UserConstants.PASSWORD_MAX_LENGTH) {
throw new ServiceException("密码长度必须在6到19个字符之间");
}
if (code.length() != UserConstants.CODE_MIN_LENGTH_LOGIN) {
throw new ServiceException("验证码长度需为6位");
}
if (phone.length() != UserConstants.PHONE_DEFAULT_LENGTH_LOGIN) {
throw new ServiceException("手机号码长度不在指定范围");
}
if (remoteUserService.checkCode(phone, code).getCode() != Constants.SUCCESS) {
throw new ServiceException("对不起,您输入的验证码:" + code + " 不存在,请重新输入有效的验证码");
}
if (smsService.checkCode(phone, code)) {
// 查询用户信息
R<LoginUser> userResult = remoteUserService.getUserInfoByPhone(phone, SecurityConstants.INNER);