bug修复
This commit is contained in:
parent
6368a3afb6
commit
a3e2f2c4eb
|
|
@ -647,8 +647,16 @@ public class BackReceiveServiceImpl implements BackReceiveService {
|
|||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
|
||||
Date nowDate = DateUtils.getNowDate();
|
||||
String format = dateFormat.format(nowDate);
|
||||
// 退料报废
|
||||
Integer taskNum = backReceiveMapper.selectTaskNumByMonthWx(nowDate, taskType);
|
||||
|
||||
// 维修报废
|
||||
Integer wxTaskNum = backReceiveMapper.selectTaskNumByMonthWx(nowDate, 21);
|
||||
// 比较taskNum和wxTaskNum的值,取大值
|
||||
if (taskNum != null && wxTaskNum != null) {
|
||||
taskNum = Math.max(taskNum, wxTaskNum);
|
||||
} else if (taskNum == null && wxTaskNum != null) {
|
||||
taskNum = wxTaskNum;
|
||||
}
|
||||
String taskNumStr = "";
|
||||
if (taskNum != null) {
|
||||
// 将字符串转换为整数
|
||||
|
|
|
|||
|
|
@ -1243,16 +1243,22 @@ public class TmTaskServiceImpl implements TmTaskService {
|
|||
}
|
||||
// 修改任务关联的协议
|
||||
this.updateAgreementByTask(tmTask);
|
||||
// 分公司审核
|
||||
tmTask.setTaskStatus(30);
|
||||
res = tmTaskMapper.updateTmTaskAuditStatus(tmTask);
|
||||
if (res == 0) {
|
||||
throw new RuntimeException("修改任务状态异常");
|
||||
}
|
||||
//先删除leaseApplyDetail
|
||||
res = deletePreDetailData(tmTask);
|
||||
if (res == 0) {
|
||||
throw new RuntimeException("删除leaseApplyDetail异常");
|
||||
}
|
||||
//再删除leaseApplyInfo
|
||||
res = deletePreData(tmTask);
|
||||
/*res = deletePreData(tmTask);
|
||||
if (res == 0) {
|
||||
throw new RuntimeException("删除leaseApplyInfo异常");
|
||||
}
|
||||
}*/
|
||||
// 先查询lease apply info,根据task id,company id,不存在则插入,领料任务,领料单号,领料人,联系电话,备注,存在则不插入
|
||||
res = insertNewData(tmTask);
|
||||
if (res == 0) {
|
||||
|
|
@ -1318,7 +1324,15 @@ public class TmTaskServiceImpl implements TmTaskService {
|
|||
|
||||
private int insertNewData(TmTask task) {
|
||||
int res = 0;
|
||||
LeaseApplyInfo leaseApplyInfo1 = task.getLeaseApplyInfo();
|
||||
// 修改lease_apply_info表信息
|
||||
LeaseApplyInfo record = task.getLeaseApplyInfo();
|
||||
record.setUpdateBy(task.getUserId());
|
||||
record.setUpdateTime(new Date());
|
||||
// 根据taskId查询id
|
||||
LeaseApplyInfo leaseApplyInfo = leaseApplyInfoMapper.selectByTaskIdAndCompId(String.valueOf(task.getTaskId()), task.getCompanyId());
|
||||
record.setId(leaseApplyInfo.getId());
|
||||
res = leaseApplyInfoMapper.updateByPrimaryKeySelective(record);
|
||||
/*LeaseApplyInfo leaseApplyInfo1 = task.getLeaseApplyInfo();
|
||||
String leasePerson = "";
|
||||
String remark = "";
|
||||
String phone = "";
|
||||
|
|
@ -1359,7 +1373,7 @@ public class TmTaskServiceImpl implements TmTaskService {
|
|||
res = leaseApplyInfoMapper.insert(leaseApplyInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
@ -1407,23 +1421,17 @@ public class TmTaskServiceImpl implements TmTaskService {
|
|||
private int insertNewDetailData(TmTask task) {
|
||||
int res = 0;
|
||||
List<LeaseApplyDetails> leaseApplyDetails = task.getLeaseApplyDetails();
|
||||
Long taskId = task.getTaskId();
|
||||
if (CollUtil.isNotEmpty(leaseApplyDetails)) {
|
||||
for (LeaseApplyDetails leaseApplyDetail : leaseApplyDetails) {
|
||||
LeaseApplyInfo leaseApplyInfos = new LeaseApplyInfo();
|
||||
/*LeaseApplyInfo leaseApplyInfos = new LeaseApplyInfo();
|
||||
if (leaseApplyDetail.getCompanyId() == null) {
|
||||
leaseApplyInfos = leaseApplyInfoMapper.selectByTaskIdAndCompIdCq(String.valueOf(taskId));
|
||||
} else {
|
||||
leaseApplyInfos = leaseApplyInfoMapper.selectByTaskIdAndCompId(String.valueOf(taskId), leaseApplyDetail.getCompanyId());
|
||||
}
|
||||
Integer id = leaseApplyInfos.getId();
|
||||
if (leaseApplyDetail.getCompanyId() == null && leaseApplyInfos.getCompanyId() == null) {
|
||||
leaseApplyDetail.setParenntId(id);
|
||||
Integer id = leaseApplyInfos.getId();*/
|
||||
leaseApplyDetail.setCreateBy(task.getUserId());
|
||||
res = leaseApplyDetailsMapper.insert(leaseApplyDetail);
|
||||
} else if (leaseApplyDetail.getCompanyId().equals(leaseApplyInfos.getCompanyId())) {
|
||||
leaseApplyDetail.setParenntId(id);
|
||||
res = leaseApplyDetailsMapper.insert(leaseApplyDetail);
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
|
|
|
|||
|
|
@ -126,4 +126,9 @@ public class RepairApplyRecord implements Serializable {
|
|||
*/
|
||||
@ApiModelProperty(value = "损坏照片id")
|
||||
private String fileIds;
|
||||
|
||||
/**
|
||||
* 维修记录id
|
||||
*/
|
||||
private Long recordId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,4 +95,9 @@ public class RepairPartDetails {
|
|||
private Long repairer;
|
||||
@ApiModelProperty(value = "维修数量")
|
||||
private int repairNum;
|
||||
|
||||
/**
|
||||
* 维修记录id
|
||||
*/
|
||||
private Long recordId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -122,6 +122,38 @@ public class RepairServiceImpl implements RepairService {
|
|||
default:
|
||||
break;
|
||||
}
|
||||
if (partList != null && partList.size() > 0) {
|
||||
if (nbType.equals(bean.getRepairType())) {
|
||||
for (RepairPartDetails partDetails : partList) {
|
||||
if (partDetails.getPartId() != null) {
|
||||
if (partDetails.getPartCost() == null || partDetails.getPartCost().isEmpty()) {
|
||||
partDetails.setPartCost("0");
|
||||
}
|
||||
bean.setPartPrice(new BigDecimal(partDetails.getPartCost()));
|
||||
partNum += partDetails.getPartNum();
|
||||
bean.setRepairContent(partDetails.getRepairContent());
|
||||
bean.setPartType(partDetails.getPartType());
|
||||
}
|
||||
}
|
||||
bean.setPartNum(partNum);
|
||||
}
|
||||
if (fcType.equals(bean.getRepairType())) {
|
||||
bean.setPartName(partList.get(0).getPartName());
|
||||
bean.setPartType(partList.get(0).getPartType());
|
||||
bean.setRepairContent(partList.get(0).getRepairContent());
|
||||
if (partList.get(0).getSupplierId() == null) {
|
||||
throw new ServiceException("请选择返厂厂家");
|
||||
} else {
|
||||
bean.setSupplierId(partList.get(0).getSupplierId());
|
||||
}
|
||||
bean.setPartPrice(new BigDecimal(partList.get(0).getPartPrice()));
|
||||
bean.setPartNum(partList.get(0).getPartNum());
|
||||
}
|
||||
}
|
||||
int result = mapper.addRecord(bean);
|
||||
if (result <= 0) {
|
||||
throw new ServiceException("维修数据保存失败");
|
||||
}
|
||||
if (partList != null && partList.size() > 0) {
|
||||
if (nbType.equals(bean.getRepairType())) {
|
||||
for (RepairPartDetails partDetails : partList) {
|
||||
|
|
@ -134,6 +166,7 @@ public class RepairServiceImpl implements RepairService {
|
|||
partDetails.setTypeId(bean.getTypeId());
|
||||
partDetails.setCreateBy(loginUser.getUserid());
|
||||
partDetails.setCompanyId(bean.getCompanyId());
|
||||
partDetails.setRecordId(bean.getRecordId());
|
||||
mapper.addPart(partDetails);
|
||||
bean.setPartPrice(new BigDecimal(partDetails.getPartCost()));
|
||||
partNum += partDetails.getPartNum();
|
||||
|
|
@ -180,7 +213,6 @@ public class RepairServiceImpl implements RepairService {
|
|||
mapper.addRepairCost(bean, bsfCosts, bsfPart);
|
||||
}
|
||||
}
|
||||
mapper.addRecord(bean);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
<?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.base.mapper.RepairMapper">
|
||||
<insert id="addRecord">
|
||||
<insert id="addRecord" useGeneratedKeys="true" keyProperty="recordId">
|
||||
insert into repair_apply_record (task_id,ma_id,type_id,repair_num,scrap_num,repair_type,create_by,create_time,repair_content,company_id,scrap_reason,scrap_type,supplier_id,part_num,part_price,part_type,part_name,repairer,file_ids,remark)
|
||||
values (#{taskId},#{maId},#{typeId},#{repairNum},#{scrapNum},#{repairType},#{createBy},now(),#{repairContent},#{companyId},#{scrapReason},#{scrapType},#{supplierId},#{partNum},#{partPrice},#{partType},#{partName},#{repairer},#{fileIds},#{remark});
|
||||
</insert>
|
||||
<insert id="addPart">
|
||||
insert into repair_part_details (task_id,ma_id,type_id,part_id,part_num,part_cost,part_type,create_by,create_time,company_id,repair_content)
|
||||
values (#{taskId},#{maId},#{typeId},#{partId},#{partNum},#{partCost},#{partType},#{createBy},now(),#{companyId},#{repairContent});
|
||||
insert into repair_part_details (task_id,ma_id,type_id,part_id,part_num,part_cost,part_type,create_by,create_time,company_id,repair_content, record_id)
|
||||
values (#{taskId},#{maId},#{typeId},#{partId},#{partNum},#{partCost},#{partType},#{createBy},now(),#{companyId},#{repairContent}, #{recordId});
|
||||
</insert>
|
||||
<insert id="addTask" useGeneratedKeys="true" keyProperty="taskId">
|
||||
insert into tm_task (task_status,task_type,code,create_by,create_time,company_id)
|
||||
|
|
@ -244,9 +244,9 @@
|
|||
|
||||
<select id="getById" resultType="com.bonus.sgzb.base.domain.RepairTaskDetails">
|
||||
select rad.id as id,
|
||||
rad.repair_num as repairNum,
|
||||
rad.repaired_num as repairedNum,
|
||||
rad.scrap_num as scrapNum
|
||||
IFNULL(rad.repair_num, 0) as repairNum,
|
||||
IFNULL(rad.repaired_num, 0) as repairedNum,
|
||||
IFNULL(rad.scrap_num, 0) as scrapNum
|
||||
from repair_apply_details rad
|
||||
where rad.id = #{id}
|
||||
</select>
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import io.swagger.annotations.ApiModelProperty;
|
|||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author c liu
|
||||
|
|
@ -186,4 +187,10 @@ public class RepairRecord implements Serializable {
|
|||
*/
|
||||
@ApiModelProperty(value = "proId")
|
||||
private Integer proId;
|
||||
|
||||
@ApiModelProperty(value = "维修配件集合")
|
||||
private List<RepairRecord> repairPartList;
|
||||
|
||||
@ApiModelProperty(value = "配件id")
|
||||
private Long partId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -140,6 +140,9 @@ public class BackApplyServiceImpl implements BackApplyService {
|
|||
|
||||
@Override
|
||||
public List<BackApplyInfo> getView(BackApplyInfo bean) {
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
List<BackApplyInfo> list = new ArrayList<>();
|
||||
List<Long> longs = new ArrayList<>();
|
||||
Long companyId = SecurityUtils.getLoginUser().getSysUser().getCompanyId();
|
||||
if (StringUtils.isNotEmpty(bean.getBadId())) {
|
||||
String badId = bean.getBadId();
|
||||
|
|
@ -150,8 +153,27 @@ public class BackApplyServiceImpl implements BackApplyService {
|
|||
bean.setCompanyId(companyId.toString());
|
||||
}
|
||||
List<BackApplyInfo> view = backApplyMapper.getView(bean);
|
||||
// 定义需要匹配的角色集合
|
||||
List<String> allowedRoles = Arrays.asList("admin", "em01", "em02", "jjbz", "dm01", "dm07");
|
||||
// 获取当前用户的角色集合
|
||||
Set<String> userRoles = SecurityUtils.getLoginUser().getRoles();
|
||||
if (userRoles != null && allowedRoles.stream().anyMatch(userRoles::contains)) {
|
||||
return view;
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(view)) {
|
||||
for (BackApplyInfo backApplyInfo : view) {
|
||||
if (org.apache.commons.lang3.StringUtils.isNotBlank(backApplyInfo.getUserId())) {
|
||||
List<String> strings = Arrays.asList(backApplyInfo.getUserId().split(","));
|
||||
//转换为long类型
|
||||
longs = strings.stream().map(Long::parseLong).collect(Collectors.toList());
|
||||
}
|
||||
if (longs.contains(userId)) {
|
||||
list.add(backApplyInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BackApplyInfo> getViewByApply(BackApplyInfo bean) {
|
||||
|
|
@ -532,12 +554,12 @@ public class BackApplyServiceImpl implements BackApplyService {
|
|||
));
|
||||
}
|
||||
// 判断3个list是否具备合法性
|
||||
for (Integer key : leaseMap.keySet()) {
|
||||
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(key)) ? 0 : leaseMap.get(key);
|
||||
int leaseNum = Objects.isNull(leaseMap.get(Integer.parseInt(key))) ? 0 : leaseMap.get(Integer.parseInt(key));
|
||||
if (oldBackNum + thisBackNum > leaseNum) {
|
||||
String typeName = backApplyMapper.getTypeName(String.valueOf(key));
|
||||
String typeName = backApplyMapper.getTypeName(key);
|
||||
bean.setTypeName(typeName);
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -165,26 +165,19 @@ public class RepairAuditDetailsServiceImpl implements IRepairAuditDetailsService
|
|||
public List<RepairRecord> getRepairRecord(RepairAuditDetails repairAuditDetails) {
|
||||
RepairAuditDetails bean = repairAuditDetailsMapper.getRepairId(repairAuditDetails);
|
||||
List<RepairRecord> list = repairAuditDetailsMapper.getRepairRecord(bean);
|
||||
List<RepairRecord> infoList = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
// 内部维修数据从repair_part_details查询获取
|
||||
for (RepairRecord info : list) {
|
||||
if ("1".equals(info.getRepairType())) {
|
||||
bean.setId(info.getId());
|
||||
List<RepairRecord> partDetailsList = repairAuditDetailsMapper.getPartDetailsList(bean);
|
||||
if (CollectionUtils.isNotEmpty(partDetailsList)) {
|
||||
for (RepairRecord repairRecord : partDetailsList) {
|
||||
repairRecord.setRepairer(StringUtils.isNotBlank(info.getRepairer()) ? info.getRepairer() : null);
|
||||
repairRecord.setRepairNum(info.getRepairNum());
|
||||
repairRecord.setRepairType(info.getRepairType());
|
||||
}
|
||||
}
|
||||
infoList.addAll(partDetailsList);
|
||||
} else {
|
||||
infoList.add(info);
|
||||
info.setRepairPartList(partDetailsList);
|
||||
}
|
||||
}
|
||||
}
|
||||
return infoList;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -451,7 +444,20 @@ public class RepairAuditDetailsServiceImpl implements IRepairAuditDetailsService
|
|||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
|
||||
Date nowDate = DateUtils.getNowDate();
|
||||
String format = dateFormat.format(nowDate);
|
||||
// 维修待报废
|
||||
String taskNum = taskMapper.selectTaskNumByMonths(nowDate, taskType);
|
||||
// 退料待报废
|
||||
String TlTaskNum = taskMapper.selectTaskNumByMonths(nowDate, 20);
|
||||
// 比较taskNum和TlTaskNum的大小,取大值
|
||||
if (StringHelper.isNotEmpty(taskNum) && StringHelper.isNotEmpty(TlTaskNum)) {
|
||||
int tkNum = Integer.parseInt(taskNum);
|
||||
int TlNum = Integer.parseInt(TlTaskNum);
|
||||
int num = Math.max(tkNum, TlNum);
|
||||
// 将结果转换回字符串格式,并确保结果是四位数,不足四位则在前面补0
|
||||
taskNum = String.valueOf(num);
|
||||
} else if (StringHelper.isEmpty(taskNum) && StringHelper.isNotEmpty(TlTaskNum)) {
|
||||
taskNum = TlTaskNum;
|
||||
}
|
||||
if (StringHelper.isNotEmpty(taskNum)) {
|
||||
// 将字符串转换为整数
|
||||
int num = Integer.parseInt(taskNum);
|
||||
|
|
|
|||
|
|
@ -715,7 +715,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
bagi.agreement_code as agreementCode,
|
||||
bad.pre_num AS preNum,
|
||||
bad.type_id as typeId,
|
||||
bad.audit_num AS num
|
||||
bad.audit_num AS num,
|
||||
mtk.userId as userId
|
||||
FROM
|
||||
back_apply_details bad
|
||||
LEFT JOIN back_apply_info bai ON bai.id = bad.parent_id
|
||||
|
|
@ -729,6 +730,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
LEFT JOIN ma_type mt2 ON mt2.type_id = mt1.parent_id
|
||||
LEFT JOIN ma_type mt3 ON mt3.type_id = mt2.parent_id
|
||||
LEFT JOIN ma_type mt4 ON mt4.type_id = mt3.parent_id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
type_id as typeId,
|
||||
GROUP_CONCAT(user_id) as userId
|
||||
FROM
|
||||
ma_type_keeper
|
||||
GROUP BY type_id
|
||||
) mtk ON mtk.typeId = bad.type_id
|
||||
WHERE
|
||||
bai.task_id = #{taskId}
|
||||
<if test="split != null and split.length > 0">
|
||||
|
|
|
|||
|
|
@ -438,14 +438,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
scrap_reason as scrapReason,
|
||||
scrap_type as scrapType,
|
||||
msi.supplier as supplier,
|
||||
part_num as partNum,
|
||||
part_price as partPrice,
|
||||
repair_content as repairContent,
|
||||
part_type as partType,
|
||||
part_name as partName,
|
||||
file_ids as fileIds,
|
||||
su.nick_name as repairer,
|
||||
rar.remark
|
||||
rar.remark,
|
||||
rar.id as id
|
||||
from repair_apply_record rar
|
||||
left join ma_supplier_info msi on msi.supplier_id = rar.supplier_id
|
||||
left join sys_user su on su.user_id = rar.repairer
|
||||
|
|
@ -469,6 +466,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</select>
|
||||
<select id="getPartDetailsList" resultType="com.bonus.sgzb.material.domain.RepairRecord">
|
||||
SELECT
|
||||
rad.part_id AS partId,
|
||||
rad.repair_content AS repairContent,
|
||||
concat( mpt2.pa_name, '-', mpt1.pa_name, '-', mpt.pa_name ) AS partName,
|
||||
rad.part_num AS partNum,
|
||||
|
|
@ -482,7 +480,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
and mpt1.del_flag = '0'
|
||||
LEFT JOIN ma_part_type mpt2 ON mpt2.pa_id = mpt1.parent_id
|
||||
and mpt2.del_flag = '0'
|
||||
WHERE rad.task_id = #{taskId} and rad.type_id = #{typeId}
|
||||
WHERE (rad.record_id IS NULL OR rad.record_id = #{id})
|
||||
and rad.task_id = #{taskId}
|
||||
and rad.type_id = #{typeId}
|
||||
<if test="maId != null and maId != ''">
|
||||
and rad.ma_id = #{maId}
|
||||
</if>
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
LEFT JOIN ma_type mt2 on mt2.type_id = mt.parent_id
|
||||
LEFT JOIN ma_machine mm on mm.ma_id = sad.ma_id
|
||||
LEFT JOIN sys_user su on su.user_id = sad.audit_by
|
||||
WHERE sad.scrap_source = '2'
|
||||
WHERE sad.scrap_source = '2' and sad.status = '1'
|
||||
<if test="keyWord != null and keyWord != ''">
|
||||
and (unit.unit_name like concat('%',#{keyWord},'%') or
|
||||
lot.lot_name like concat('%',#{keyWord},'%') or
|
||||
|
|
@ -83,7 +83,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
LEFT JOIN ma_type mt2 on mt2.type_id = mt.parent_id
|
||||
LEFT JOIN ma_machine mm on mm.ma_id = sad.ma_id
|
||||
LEFT JOIN sys_user su on su.user_id = sad.audit_by
|
||||
WHERE sad.scrap_source = '1'
|
||||
WHERE sad.scrap_source = '1' and sad.status = '1'
|
||||
<if test="keyWord != null and keyWord != ''">
|
||||
and (unit.unit_name like concat('%',#{keyWord},'%') or
|
||||
lot.lot_name like concat('%',#{keyWord},'%') or
|
||||
|
|
|
|||
|
|
@ -57,8 +57,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
IFNULL( subquery2.backNum, 0 ) AS backNum,
|
||||
CASE
|
||||
|
||||
WHEN IFNULL( subquery1.outNum, 0 ) - IFNULL( subquery2.backNum, 0 ) > 0 THEN
|
||||
IFNULL( subquery1.outNum, 0 ) - IFNULL( subquery2.backNum, 0 ) ELSE 0
|
||||
WHEN IFNULL( subquery1.outNum, 0 ) - IFNULL( subquery2.backNum, 0 ) + IFNULL( subquery3.backNum, 0 ) > 0 THEN
|
||||
IFNULL( subquery1.outNum, 0 ) - IFNULL( subquery2.backNum, 0 ) + IFNULL( subquery3.backNum, 0 ) ELSE 0
|
||||
END AS usNum
|
||||
FROM
|
||||
(
|
||||
|
|
@ -87,10 +87,30 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
LEFT JOIN ma_type mt ON mt.type_id = bcd.type_id
|
||||
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
|
||||
LEFT JOIN ma_machine mm ON mm.ma_id = bcd.ma_id
|
||||
LEFT JOIN back_apply_info ba ON bcd.parent_id = ba.id
|
||||
WHERE bcd.is_finished IS NOT NULL and bcd.is_finished = '1'
|
||||
and ba.back_source = '2'
|
||||
GROUP BY
|
||||
mt.type_id
|
||||
) AS subquery2 ON subquery1.type_id = subquery2.type_id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
mt.type_id,
|
||||
mt2.type_name AS typeName,
|
||||
mt.type_name AS typeModelName,
|
||||
SUM(
|
||||
IFNULL( bcd.back_num, 0 )) backNum
|
||||
FROM
|
||||
back_check_details bcd
|
||||
LEFT JOIN ma_type mt ON mt.type_id = bcd.type_id
|
||||
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
|
||||
LEFT JOIN ma_machine mm ON mm.ma_id = bcd.ma_id
|
||||
LEFT JOIN back_apply_info ba ON bcd.parent_id = ba.id
|
||||
WHERE (bcd.is_finished IS NULL OR bcd.is_finished = '0')
|
||||
and ba.back_source = '1'
|
||||
GROUP BY
|
||||
mt.type_id
|
||||
) AS subquery3 ON subquery3.type_id = subquery2.type_id
|
||||
) AS subquery1 ON mt.type_id = subquery1.type_id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
|
|
|
|||
Loading…
Reference in New Issue