bug修复
This commit is contained in:
parent
4b1f4c2cb1
commit
7c891101c6
|
|
@ -218,6 +218,9 @@ public class BackApplyController extends BaseController {
|
|||
if (CollUtil.isEmpty(record.getBackApplyDetails())) {
|
||||
return AjaxResult.error("退料设备明细为空,请重新选择后上传!");
|
||||
}
|
||||
if (!backApplyService.isBackApplyNumberCorrect(record)) {
|
||||
return AjaxResult.error("机具:" + record.getTypeName() + "已申请退料数量加上本次退料申请数量,超过领料出库数量,请重新确认!");
|
||||
}
|
||||
backApplyService.updateBackInfo(record.getParentId(),record.getCompanyId());
|
||||
for (BackApplyInfo backApplyInfo : record.getBackApplyDetails()) {
|
||||
backApplyInfo.setParentId(record.getParentId());
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.bonus.sgzb.app.mapper;
|
||||
|
||||
import com.bonus.sgzb.app.domain.LeaseApplyDetails;
|
||||
import com.bonus.sgzb.base.api.domain.BackApplyInfo;
|
||||
import com.bonus.sgzb.app.domain.BmAgreementInfo;
|
||||
import com.bonus.sgzb.base.api.domain.MachinePart;
|
||||
|
|
@ -62,4 +63,25 @@ public interface BackApplyAppMapper {
|
|||
MachinePart getMachineParts(TmTask typeId);
|
||||
|
||||
void updateBackInfo(@Param("parentId") Integer parentId,@Param("companyId") String companyId);
|
||||
|
||||
/**
|
||||
* 查看该协议已建立退料数据
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
List<BackApplyInfo> getBackApplyDetailsTypeCount(BackApplyInfo bean);
|
||||
|
||||
/**
|
||||
* 查看领料出库数据
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
List<LeaseApplyDetails> getLeaseApplyDetailsTypeCount(BackApplyInfo bean);
|
||||
|
||||
/**
|
||||
* 获取退料类型名称
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
String getTypeName(String key);
|
||||
}
|
||||
|
|
@ -114,4 +114,11 @@ public interface BackApplyService {
|
|||
int refuse(BackApplyInfo record);
|
||||
|
||||
void updateBackInfo(Integer parentId,String companyId);
|
||||
|
||||
/**
|
||||
* 退料申请数量校验
|
||||
* @param record
|
||||
* @return
|
||||
*/
|
||||
boolean isBackApplyNumberCorrect(BackApplyInfo record);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.bonus.sgzb.app.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.bonus.sgzb.app.domain.LeaseApplyDetails;
|
||||
import com.bonus.sgzb.base.api.domain.BackApplyInfo;
|
||||
import com.bonus.sgzb.app.domain.BmAgreementInfo;
|
||||
import com.bonus.sgzb.base.api.domain.MachinePart;
|
||||
|
|
@ -9,12 +10,12 @@ import com.bonus.sgzb.app.mapper.BackApplyAppMapper;
|
|||
import com.bonus.sgzb.app.service.BackApplyService;
|
||||
import com.bonus.sgzb.common.core.utils.StringUtils;
|
||||
import com.bonus.sgzb.common.security.utils.SecurityUtils;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author hay
|
||||
|
|
@ -208,4 +209,63 @@ public class BackApplyServiceImpl implements BackApplyService {
|
|||
backApplyMapper.updateBackInfo(parentId,companyId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 退料申请数量校验
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean isBackApplyNumberCorrect(BackApplyInfo bean) {
|
||||
// 已建退料数据
|
||||
Map<String, Integer> oldBackMap = new HashMap<>();
|
||||
// 已领出库数据
|
||||
Map<Integer, Integer> leaseMap = new HashMap<>();
|
||||
// 本次退料数据
|
||||
Map<String, Integer> thisBackMap = new HashMap<>();
|
||||
// 查看该协议已建立退料数据
|
||||
List<BackApplyInfo> oldBackTypes = backApplyMapper.getBackApplyDetailsTypeCount(bean);
|
||||
if (CollectionUtils.isNotEmpty(oldBackTypes)) {
|
||||
oldBackMap = oldBackTypes.stream().collect(Collectors.groupingBy(BackApplyInfo::getTypeId,
|
||||
Collectors.summingInt(BackApplyInfo::getBackNum)));
|
||||
}
|
||||
// 查看领料出库数据
|
||||
List<LeaseApplyDetails> leaseTypes = backApplyMapper.getLeaseApplyDetailsTypeCount(bean);
|
||||
if (CollectionUtils.isNotEmpty(leaseTypes)) {
|
||||
leaseMap = leaseTypes.stream()
|
||||
.collect(Collectors.groupingBy(
|
||||
LeaseApplyDetails::getTypeId,
|
||||
Collectors.mapping(
|
||||
LeaseApplyDetails::getAlNum,
|
||||
Collectors.collectingAndThen(
|
||||
Collectors.summingDouble(Double::doubleValue),
|
||||
Double::intValue
|
||||
)
|
||||
)
|
||||
));
|
||||
}
|
||||
// 本次退料数据
|
||||
if (CollectionUtils.isNotEmpty(bean.getBackApplyDetails())) {
|
||||
thisBackMap = bean.getBackApplyDetails().stream()
|
||||
.collect(Collectors.groupingBy(
|
||||
BackApplyInfo::getTypeId,
|
||||
Collectors.mapping(
|
||||
info -> (int) Double.parseDouble(info.getPreNum()),
|
||||
Collectors.summingInt(Integer::intValue)
|
||||
)
|
||||
));
|
||||
}
|
||||
// 判断3个list是否具备合法性
|
||||
for (String key : thisBackMap.keySet()) {
|
||||
int oldBackNum = Objects.isNull(oldBackMap.get(String.valueOf(key))) ? 0 : oldBackMap.get(String.valueOf(key));
|
||||
int thisBackNum = Objects.isNull(thisBackMap.get(String.valueOf(key))) ? 0 : thisBackMap.get(String.valueOf(key));
|
||||
int leaseNum = Objects.isNull(leaseMap.get(Integer.parseInt(key))) ? 0 : leaseMap.get(Integer.parseInt(key));
|
||||
if (oldBackNum + thisBackNum > leaseNum) {
|
||||
String typeName = backApplyMapper.getTypeName(key);
|
||||
bean.setTypeName(typeName);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -540,5 +540,32 @@
|
|||
mt.type_id = #{typeId}
|
||||
</select>
|
||||
|
||||
<select id="getBackApplyDetailsTypeCount" resultType="com.bonus.sgzb.base.api.domain.BackApplyInfo">
|
||||
select bad.type_id as typeId, sum(bad.audit_num) as backNum
|
||||
from back_apply_details bad
|
||||
LEFT join back_apply_info bai on bai.id = bad.parent_id
|
||||
LEFT join tm_task tt on bai.task_id = tt.task_id
|
||||
LEFT join tm_task_agreement tta on tta.task_id = tt.task_id
|
||||
where tta.agreement_id = #{agreementId}
|
||||
group by bad.type_id
|
||||
</select>
|
||||
|
||||
<select id="getLeaseApplyDetailsTypeCount" resultType="com.bonus.sgzb.app.domain.LeaseApplyDetails">
|
||||
select lad.type_id as typeId, IFNULL(sum(lad.al_num),0) as alNum
|
||||
from lease_apply_details lad
|
||||
LEFT join lease_apply_info lai on lai.id = lad.parennt_id
|
||||
LEFT join tm_task tt on lai.task_id = tt.task_id
|
||||
LEFT join tm_task_agreement tta on tta.task_id = tt.task_id
|
||||
where tta.agreement_id = #{agreementId} and lad.`status` = '2'
|
||||
group by lad.type_id
|
||||
</select>
|
||||
|
||||
<select id="getTypeName" resultType="java.lang.String">
|
||||
select concat(mt2.type_name,'/',mt.type_name) as typeName
|
||||
from ma_type mt
|
||||
left join ma_type mt2 on mt2.type_id = mt.parent_id
|
||||
where mt.type_id = #{typeId}
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
|
@ -655,7 +655,7 @@
|
|||
GROUP_CONCAT( DISTINCT mt1.type_id ) AS modelId,
|
||||
GROUP_CONCAT( bai.company_id ) AS companyId,
|
||||
GROUP_CONCAT(bad.id) as badId,
|
||||
GROUP_CONCAT( mt2.type_name, '' ) AS typeName
|
||||
GROUP_CONCAT( DISTINCT mt2.type_name, '' ) AS typeName
|
||||
FROM
|
||||
back_apply_info bai
|
||||
LEFT JOIN back_apply_details bad ON bad.parent_id = bai.id
|
||||
|
|
|
|||
|
|
@ -1,32 +1,26 @@
|
|||
package com.bonus.sgzb.material.service.impl;
|
||||
|
||||
import com.bonus.sgzb.common.core.enums.TaskStatusEnum;
|
||||
import com.bonus.sgzb.common.core.utils.DateUtils;
|
||||
import com.alibaba.nacos.common.utils.CollectionUtils;
|
||||
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.sgzb.material.domain.AgreementInfo;
|
||||
import com.bonus.sgzb.common.security.utils.SecurityUtils;
|
||||
import com.bonus.sgzb.material.domain.BmNoticeInfo;
|
||||
import com.bonus.sgzb.material.domain.TmTask;
|
||||
import com.bonus.sgzb.material.domain.ToDoBean;
|
||||
import com.bonus.sgzb.material.exception.ExceptionDict;
|
||||
import com.bonus.sgzb.material.mapper.AgreementInfoMapper;
|
||||
import com.bonus.sgzb.material.mapper.PurchaseCheckDetailsMapper;
|
||||
import com.bonus.sgzb.material.mapper.PurchaseCheckInfoMapper;
|
||||
import com.bonus.sgzb.material.mapper.ToDoMapper;
|
||||
import com.bonus.sgzb.material.service.AgreementInfoService;
|
||||
import com.bonus.sgzb.material.service.ToDoService;
|
||||
import com.bonus.sgzb.material.vo.GlobalContants;
|
||||
import com.bonus.sgzb.material.vo.NoticeInfoVO;
|
||||
import com.bonus.sgzb.system.api.RemoteUserService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import com.bonus.sgzb.common.core.exception.ServiceException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Author 阮世耀
|
||||
|
|
@ -37,6 +31,13 @@ import java.util.List;
|
|||
@Slf4j
|
||||
public class ToDoServiceImpl implements ToDoService {
|
||||
|
||||
private final static String STRING_EM01 = "em01";
|
||||
private final static String STRING_EM02 = "em02";
|
||||
private final static String STRING_DM01 = "dm01";
|
||||
private final static String STRING_DM02 = "dm02";
|
||||
private final static String STRING_SGB = "sgb";
|
||||
private final static String STRING_FGS = "fgs";
|
||||
|
||||
@Resource
|
||||
private ToDoMapper toDoMapper;
|
||||
|
||||
|
|
@ -48,7 +49,55 @@ public class ToDoServiceImpl implements ToDoService {
|
|||
|
||||
@Override
|
||||
public List<ToDoBean> getToDoList(ToDoBean bean) {
|
||||
return toDoMapper.getToDoList(bean);
|
||||
Set<String> roles = SecurityUtils.getLoginUser().getRoles();
|
||||
Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId();
|
||||
List<ToDoBean> toDoList = toDoMapper.getToDoList(bean);
|
||||
if (!CollectionUtils.isEmpty(toDoList)) {
|
||||
// 将toDoList集合中领料任务过滤出来,即taskTypeId为29的数据
|
||||
List<ToDoBean> collect = toDoList.stream().filter(toDoBean -> "29".equals(toDoBean.getTaskTypeId()))
|
||||
.collect(Collectors.toList());
|
||||
// 机具经理、副经理
|
||||
if (roles.contains(STRING_EM01) || roles.contains(STRING_EM02)) {
|
||||
List<ToDoBean> toDoBeanArrayList = new ArrayList<>();
|
||||
for (ToDoBean toDoBean : collect) {
|
||||
if (deptId.equals(toDoBean.getDeptId()) && "30".equals(toDoBean.getTaskStatus())) {
|
||||
toDoBeanArrayList.add(toDoBean);
|
||||
} else if ("32".equals(toDoBean.getTaskStatus()) && toDoBean.getCompanyId() == 101) {
|
||||
toDoBeanArrayList.add(toDoBean);
|
||||
}
|
||||
}
|
||||
return toDoBeanArrayList;
|
||||
// 施管部
|
||||
} else if (roles.contains(STRING_SGB)) {
|
||||
// 将collect集合中taskStatus为31的数据过滤出来
|
||||
return collect.stream().filter(toDoBean -> "31".equals(toDoBean.getTaskStatus())).collect(Collectors.toList());
|
||||
// 调试经理
|
||||
} else if (roles.contains(STRING_DM01)) {
|
||||
List<ToDoBean> beanList = new ArrayList<>();
|
||||
for (ToDoBean toDoBean : collect) {
|
||||
if (deptId.equals(toDoBean.getDeptId()) && "30".equals(toDoBean.getTaskStatus())) {
|
||||
beanList.add(toDoBean);
|
||||
} else if ("32".equals(toDoBean.getTaskStatus()) && toDoBean.getCompanyId() == 102) {
|
||||
beanList.add(toDoBean);
|
||||
}
|
||||
}
|
||||
return beanList;
|
||||
// 各分公司经理
|
||||
} else if (roles.contains(STRING_FGS)) {
|
||||
// 将collect集合中taskStatus为30的数据过滤出来,并且collect集合中的deptId不为101或者102
|
||||
return collect.stream().filter(toDoBean -> "30".equals(toDoBean.getTaskStatus()) &&
|
||||
deptId.equals(toDoBean.getDeptId())).collect(Collectors.toList());
|
||||
} else if (roles.contains(STRING_DM02)) {
|
||||
List<ToDoBean> beans = new ArrayList<>();
|
||||
for (ToDoBean toDoBean : collect) {
|
||||
if ("32".equals(toDoBean.getTaskStatus()) && toDoBean.getCompanyId() == 102) {
|
||||
beans.add(toDoBean);
|
||||
}
|
||||
}
|
||||
return beans;
|
||||
}
|
||||
}
|
||||
return toDoList;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -584,7 +584,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
tt.task_status as taskStatus,
|
||||
tta.agreement_id as agreementId,
|
||||
GROUP_CONCAT(DISTINCT bad.type_id) as typeId,
|
||||
GROUP_CONCAT(mt2.type_name) AS typeName,
|
||||
GROUP_CONCAT(DISTINCT mt2.type_name) AS typeName,
|
||||
GROUP_CONCAT(bad.status) AS status
|
||||
FROM
|
||||
back_apply_info bai
|
||||
|
|
@ -993,7 +993,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
tt1.code as forecastWasteCode,
|
||||
GROUP_CONCAT(bai.company_id) as companyId,
|
||||
GROUP_CONCAT(DISTINCT mt2.type_id) as typeId,
|
||||
GROUP_CONCAT(mt2.type_name) AS typeName,
|
||||
GROUP_CONCAT(DISTINCT mt2.type_name) AS typeName,
|
||||
GROUP_CONCAT(bad.status) AS status
|
||||
FROM
|
||||
back_apply_info bai
|
||||
|
|
|
|||
Loading…
Reference in New Issue