逻辑优化,魔法值抽取,NULL异常处理,冗余装箱去除
This commit is contained in:
parent
911af8e99d
commit
45d26cf0d4
|
|
@ -2,7 +2,6 @@ package com.bonus.sgzb.app.controller;
|
|||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.bonus.sgzb.app.domain.LeaseApplyDetails;
|
||||
import com.bonus.sgzb.app.domain.LeaseApplyInfo;
|
||||
import com.bonus.sgzb.app.domain.TmTask;
|
||||
|
|
@ -22,7 +21,6 @@ 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 io.swagger.annotations.ApiOperation;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
|
@ -62,6 +60,8 @@ public class TmTaskController extends BaseController {
|
|||
|
||||
@Autowired
|
||||
private LeaseUserBookService leaseUserBookService;
|
||||
|
||||
private final static String STRING_ADMIN = "admin";
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -293,24 +293,22 @@ public class TmTaskController extends BaseController {
|
|||
return AjaxResult.error("参数错误");
|
||||
}
|
||||
Set<String> roles = SecurityUtils.getLoginUser().getRoles();
|
||||
List<TmTask> leaseAuditList = new ArrayList<>();
|
||||
if (souceBy == 1) {
|
||||
if (roles.contains("admin")) {
|
||||
List<TmTask> leaseAuditList;
|
||||
if (souceBy != null && souceBy == 1) {
|
||||
if (roles.contains(STRING_ADMIN)) {
|
||||
leaseAuditList = tmTaskService.getLeaseAuditList(task);
|
||||
return AjaxResult.success(getDataTable(leaseAuditList));
|
||||
} else {
|
||||
leaseAuditList = tmTaskService.getLeaseAuditListByPeople(task);
|
||||
return AjaxResult.success(getDataTable(leaseAuditList));
|
||||
}
|
||||
return AjaxResult.success(getDataTable(leaseAuditList));
|
||||
}
|
||||
startPage();
|
||||
if (roles.contains("admin")) {
|
||||
if (roles.contains(STRING_ADMIN)) {
|
||||
leaseAuditList = tmTaskService.getLeaseAuditList(task);
|
||||
return AjaxResult.success(getDataTable(leaseAuditList));
|
||||
} else {
|
||||
leaseAuditList = tmTaskService.getLeaseAuditListByPeople(task);
|
||||
return AjaxResult.success(getDataTable(leaseAuditList));
|
||||
}
|
||||
return AjaxResult.success(getDataTable(leaseAuditList));
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -327,8 +325,8 @@ public class TmTaskController extends BaseController {
|
|||
if (StringUtils.isNull(task)) {
|
||||
return AjaxResult.error("参数错误");
|
||||
}
|
||||
List<TmTask> leaseAuditList = new ArrayList<>();
|
||||
if (souceBy == 1) {
|
||||
List<TmTask> leaseAuditList;
|
||||
if (souceBy != null && souceBy == 1) {
|
||||
leaseAuditList = tmTaskService.getLeaseAuditManageList(task);
|
||||
return AjaxResult.success(leaseAuditList);
|
||||
}
|
||||
|
|
@ -351,7 +349,7 @@ public class TmTaskController extends BaseController {
|
|||
Set<String> roles = SecurityUtils.getLoginUser().getRoles();
|
||||
// 领料申请导出
|
||||
if (task.getTypes() == 1) {
|
||||
if (roles.contains("admin")) {
|
||||
if (roles.contains(STRING_ADMIN)) {
|
||||
leaseAuditList = tmTaskService.getLeaseAuditList(task);
|
||||
} else {
|
||||
leaseAuditList = tmTaskService.getLeaseAuditListByPeople(task);
|
||||
|
|
@ -381,7 +379,7 @@ public class TmTaskController extends BaseController {
|
|||
return AjaxResult.error("参数错误");
|
||||
}
|
||||
if (StringUtils.isNotBlank(role)) {
|
||||
if (role.contains("admin")) {
|
||||
if (role.contains(STRING_ADMIN)) {
|
||||
//如果是管理员可以看到所有的审核列表
|
||||
List<TmTask> leaseAuditList = tmTaskService.getLeaseAuditListByAdmin(task);
|
||||
return AjaxResult.success(getDataTable(leaseAuditList));
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package com.bonus.sgzb.app.service.impl;
|
|||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.bonus.sgzb.app.domain.LeaseApplyDetails;
|
||||
import com.bonus.sgzb.app.domain.LeaseApplyInfo;
|
||||
import com.bonus.sgzb.app.mapper.LeaseApplyDetailsMapper;
|
||||
import com.bonus.sgzb.app.mapper.LeaseOutDetailsMapper;
|
||||
import com.bonus.sgzb.app.service.LeaseOutDetailsService;
|
||||
|
|
@ -128,7 +127,7 @@ public class LeaseOutDetailsServiceImpl implements LeaseOutDetailsService {
|
|||
if (StringUtils.isNull(record)) {
|
||||
return AjaxResult.error("领料出库失败,请检查参数是否填写完整!");
|
||||
}
|
||||
if (!(Objects.equals(Integer.valueOf(0), record.getMaId()) || record.getMaId() == null)) {
|
||||
if (!(Objects.equals(0, record.getMaId()) || record.getMaId() == null)) {
|
||||
String status = leaseOutDetailsMapper.getMachineStatus(record);
|
||||
if (!maStatus.equals(status)) {
|
||||
return AjaxResult.error("领料出库失败,该设备不是在库状态!");
|
||||
|
|
@ -152,8 +151,6 @@ public class LeaseOutDetailsServiceImpl implements LeaseOutDetailsService {
|
|||
if (updateLeaseApplyDetailsOutNum > 0) {
|
||||
if (insertSelectiveNum > 0) {
|
||||
if (updateMaTypeStockNum > 0) {
|
||||
// if (updateMaMachineStatus > 0) {
|
||||
// if (insertAgreementInfo > 0) {
|
||||
List<LeaseApplyDetails> leaseApplyDetailsList = leaseApplyDetailsMapper.getByParentId(record.getParentId());
|
||||
int i = 0;
|
||||
for (LeaseApplyDetails bean : leaseApplyDetailsList) {
|
||||
|
|
@ -168,16 +165,7 @@ public class LeaseOutDetailsServiceImpl implements LeaseOutDetailsService {
|
|||
leaseOutDetailsMapper.updateTaskStatus(taskId, 34);
|
||||
}
|
||||
int j = insSltInfo(taskId, record);
|
||||
if (j > 0) {
|
||||
return AjaxResult.success("领料出库成功!");
|
||||
} else {
|
||||
return AjaxResult.error("出库失败,更新设备规格库存数量时出错!");
|
||||
}
|
||||
|
||||
// }
|
||||
// return AjaxResult.error("领料出库失败,插入任务协议信息错误!");
|
||||
// }
|
||||
// return AjaxResult.error("领料出库失败,最后更新设备状态错误!");
|
||||
return j > 0 ? AjaxResult.success("领料出库成功!") : AjaxResult.error("领料出库失败,更新设备规格库存数量时出错!");
|
||||
}
|
||||
return AjaxResult.error("出库失败,更新设备规格库存数量时出错!");
|
||||
}
|
||||
|
|
@ -200,9 +188,9 @@ public class LeaseOutDetailsServiceImpl implements LeaseOutDetailsService {
|
|||
if (StringUtils.isEmpty(protocol)) {
|
||||
ma.setFinalPrice(ma.getLeasePrice());
|
||||
} else {
|
||||
if (protocol.equals("1")) {
|
||||
if ("1".equals(protocol)) {
|
||||
ma.setFinalPrice(ma.getLeasePrice());
|
||||
} else if (protocol.equals("2")) {
|
||||
} else if ("2".equals(protocol)) {
|
||||
ma.setFinalPrice(ma.getRentPrice());
|
||||
} else {
|
||||
ma.setFinalPrice(ma.getLeasePrice());
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
package com.bonus.sgzb.app.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.bonus.sgzb.app.domain.LeaseApplyDetails;
|
||||
import com.bonus.sgzb.app.domain.LeaseApplyInfo;
|
||||
import com.bonus.sgzb.app.domain.TmTask;
|
||||
import com.bonus.sgzb.app.domain.TmTaskDto;
|
||||
import com.bonus.sgzb.app.mapper.LeaseApplyDetailsMapper;
|
||||
import com.bonus.sgzb.app.mapper.LeaseApplyInfoMapper;
|
||||
import com.bonus.sgzb.app.mapper.TmTaskMapper;
|
||||
|
|
@ -15,7 +12,7 @@ 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 net.sf.jsqlparser.expression.TryCastExpression;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
|
@ -25,7 +22,6 @@ import java.util.ArrayList;
|
|||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
|
@ -37,6 +33,7 @@ import java.util.stream.Collectors;
|
|||
*/
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class TmTaskServiceImpl implements TmTaskService {
|
||||
|
||||
@Resource
|
||||
|
|
@ -232,7 +229,7 @@ public class TmTaskServiceImpl implements TmTaskService {
|
|||
List<LeaseApplyDetails> leaseApplyDetails = tmTaskMapper.getLeaseApplyDetails(leaseApplyInfo);
|
||||
if (leaseApplyDetails != null && !leaseApplyDetails.isEmpty()) {
|
||||
for (LeaseApplyDetails leaseApplyDetail : leaseApplyDetails) {
|
||||
if (leaseApplyDetail != null) {
|
||||
if (leaseApplyDetail != null && leaseApplyDetail.getPreNum() != null) {
|
||||
// 统计预领数量
|
||||
count += leaseApplyDetail.getPreNum();
|
||||
}
|
||||
|
|
@ -358,7 +355,7 @@ public class TmTaskServiceImpl implements TmTaskService {
|
|||
List<LeaseApplyDetails> leaseApplyDetails = tmTaskMapper.getLeaseApplyManageDetails(leaseApplyInfo);
|
||||
if (leaseApplyDetails != null && !leaseApplyDetails.isEmpty()) {
|
||||
for (LeaseApplyDetails leaseApplyDetail : leaseApplyDetails) {
|
||||
if (leaseApplyDetail != null) {
|
||||
if (leaseApplyDetail != null && leaseApplyDetail.getPreNum() != null) {
|
||||
// 统计预领数量
|
||||
count += leaseApplyDetail.getPreNum();
|
||||
}
|
||||
|
|
@ -382,7 +379,7 @@ public class TmTaskServiceImpl implements TmTaskService {
|
|||
List<LeaseApplyDetails> leaseApplyDetails = tmTaskMapper.getLeaseApplyManageDetails(leaseApplyInfo);
|
||||
if (leaseApplyDetails != null && !leaseApplyDetails.isEmpty()) {
|
||||
for (LeaseApplyDetails leaseApplyDetail : leaseApplyDetails) {
|
||||
if (leaseApplyDetail != null) {
|
||||
if (leaseApplyDetail != null && leaseApplyDetail.getPreNum() != null) {
|
||||
// 统计预领数量
|
||||
count += leaseApplyDetail.getPreNum();
|
||||
}
|
||||
|
|
@ -731,6 +728,7 @@ public class TmTaskServiceImpl implements TmTaskService {
|
|||
throw new RuntimeException("insertNewDetailData异常");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
return res;
|
||||
|
|
@ -775,11 +773,8 @@ public class TmTaskServiceImpl implements TmTaskService {
|
|||
res = leaseApplyInfoMapper.insert(leaseApplyInfo);
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
} else {
|
||||
return res;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
private int insertNewDetailData(TmTask task) {
|
||||
|
|
@ -790,15 +785,13 @@ public class TmTaskServiceImpl implements TmTaskService {
|
|||
for (LeaseApplyDetails leaseApplyDetail : leaseApplyDetails) {
|
||||
LeaseApplyInfo leaseApplyInfos = leaseApplyInfoMapper.selectByTaskIdAndCompId(String.valueOf(taskId), String.valueOf(leaseApplyDetail.getCompanyId()));
|
||||
Integer id = leaseApplyInfos.getId();
|
||||
if (leaseApplyDetail.getCompanyId() == leaseApplyInfos.getCompanyId()) {
|
||||
if (leaseApplyDetail.getCompanyId().equals(leaseApplyInfos.getCompanyId())) {
|
||||
leaseApplyDetail.setParenntId(id);
|
||||
res = leaseApplyDetailsMapper.insert(leaseApplyDetail);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
} else {
|
||||
return res;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
private int deletePreData(TmTask task) {
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
|
||||
<select id="selectOperLogList" parameterType="com.bonus.sgzb.system.api.domain.SysOperLog" resultMap="SysOperLogResult">
|
||||
select sol.oper_id, sol.title, sol.business_type, sol.method, sol.request_method, sol.operator_type, sol.oper_name, su.nick_name, sol.dept_name, sol.oper_url, sol.oper_ip, sol.oper_param, sol.json_result, sol.status, sol.error_msg, sol.oper_time, sol.cost_time
|
||||
from sys_oper_log sol left join sys_user su on sol.oper_name = su.user_name where 1=1
|
||||
from sys_oper_log sol left join sys_user su on sol.oper_name = su.user_name
|
||||
<where>
|
||||
<if test="operIp != null and operIp != ''">
|
||||
AND sol.oper_ip like concat('%', #{operIp}, '%')
|
||||
|
|
|
|||
Loading…
Reference in New Issue