Compare commits

...

12 Commits

5 changed files with 88 additions and 45 deletions

View File

@ -284,7 +284,21 @@ public class BackApplyInfo extends BaseEntity {
/** /**
* 已完成的退料数量 * 已完成的退料数量
*/ */
private String finishedBackNum; private float finishedBackNum;
/**
* 未完成的退料数量
*/
private float inCompletedBackNum;
/**
* 此协议号最大剩余退料数 (前台显示 slt_agreement_info 表减去 back_check_details)
*/
private float maxBackNum;
/**
* 此协议号最大剩余退料数 (后台计算,只查 slt_agreement_info )
*/
private float maxBackNumBackend;
@ApiModelProperty(value = "详情id和数量") @ApiModelProperty(value = "详情id和数量")
private String detailsIdByNum; private String detailsIdByNum;

View File

@ -190,7 +190,7 @@ public class BackReceiveController extends BaseController {
} }
} }
@Log(title = "退料接收-结束任务", businessType = BusinessType.MATERIAL) //@Log(title = "退料接收-结束任务", businessType = BusinessType.MATERIAL)
@PreventRepeatSubmit @PreventRepeatSubmit
@PostMapping("endBack") @PostMapping("endBack")
public AjaxResult endBack(@RequestBody BackApplyInfo record) { public AjaxResult endBack(@RequestBody BackApplyInfo record) {
@ -199,7 +199,7 @@ public class BackReceiveController extends BaseController {
if (res > 0) { if (res > 0) {
return AjaxResult.success("接收成功"); return AjaxResult.success("接收成功");
} else { } else {
return AjaxResult.error("接收失败"); return AjaxResult.error("未接收到数据");
} }
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);

View File

@ -30,9 +30,9 @@ public interface BackReceiveMapper {
* @param record 查询条件 * @param record 查询条件
* @return List<BackApplyInfo> * @return List<BackApplyInfo>
*/ */
List<BackApplyInfo> receiveView(BackApplyInfo record); List<BackApplyInfo> receiveView4FrontEnd(BackApplyInfo record);
List<BackApplyInfo> receiveView2(BackApplyInfo record); List<BackApplyInfo> receiveView4Backend(BackApplyInfo record);
/** /**
* 添加接收数据back_check_details * 添加接收数据back_check_details

View File

@ -13,6 +13,7 @@ import com.bonus.sgzb.common.core.enums.TaskTypeEnum;
import com.bonus.sgzb.common.core.utils.DateUtils; import com.bonus.sgzb.common.core.utils.DateUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
@ -43,7 +44,7 @@ public class BackReceiveServiceImpl implements BackReceiveService {
@Override @Override
public List<BackApplyInfo> receiveView(BackApplyInfo record) { public List<BackApplyInfo> receiveView(BackApplyInfo record) {
List<BackApplyInfo> backApplyInfoList = backReceiveMapper.receiveView(record); List<BackApplyInfo> backApplyInfoList = backReceiveMapper.receiveView4FrontEnd(record);
int count1 = 0; int count1 = 0;
int count2 = 0; int count2 = 0;
for (BackApplyInfo backApplyInfo : backApplyInfoList) { for (BackApplyInfo backApplyInfo : backApplyInfoList) {
@ -150,6 +151,7 @@ public class BackReceiveServiceImpl implements BackReceiveService {
int res = 0; int res = 0;
// try { // try {
int taskId = record.getTaskId(); int taskId = record.getTaskId();
int maxBackNumBackEnd = 0;
int passNum = 0; int passNum = 0;
int maintenanceNum = 0; int maintenanceNum = 0;
int scrapNum = 0; int scrapNum = 0;
@ -167,7 +169,33 @@ public class BackReceiveServiceImpl implements BackReceiveService {
throw new RuntimeException("该退料单已完成退料"); throw new RuntimeException("该退料单已完成退料");
} }
//修改任务状态 //修改任务状态
List<BackApplyInfo> list = backReceiveMapper.receiveView2(record); List<BackApplyInfo> list = backReceiveMapper.receiveView4Backend(record);
if (!CollectionUtils.isEmpty(list)) {
for (BackApplyInfo backApplyInfo : list) {
maxBackNumBackEnd += (int) backApplyInfo.getMaxBackNumBackend();
}
}
List<BackApplyInfo> hgList = backReceiveMapper.getHgList(record);
if (hgList != null && hgList.size() > 0) {
for (BackApplyInfo bi : hgList) {
passNum += bi.getBackNum();
}
}
List<BackApplyInfo> wxList = backReceiveMapper.getWxList(record);
if (wxList != null && wxList.size() > 0) {
for (BackApplyInfo bi : wxList) {
maintenanceNum += bi.getBackNum();
}
}
List<BackApplyInfo> bfList = backReceiveMapper.getBfList(record);
if (bfList != null && bfList.size() > 0) {
for (BackApplyInfo bi : bfList) {
scrapNum += bi.getBackNum();
}
}
if (maxBackNumBackEnd < passNum + maintenanceNum + scrapNum) {
throw new RuntimeException("提交退料数量大于最大退料数,可能您的退料已被别人退掉了");
}
boolean allZeros = list.stream().allMatch(n -> Double.valueOf(n.getNum()).intValue() == 0); boolean allZeros = list.stream().allMatch(n -> Double.valueOf(n.getNum()).intValue() == 0);
if (allZeros) { if (allZeros) {
res = updateTaskStatus(taskId, 40); res = updateTaskStatus(taskId, 40);
@ -177,7 +205,6 @@ public class BackReceiveServiceImpl implements BackReceiveService {
} }
//更加退料接收的数据创建下一步流程 //更加退料接收的数据创建下一步流程
//合格的插入入库记录input_apply_details修改库存ma_type,修改机具状态 //合格的插入入库记录input_apply_details修改库存ma_type,修改机具状态
List<BackApplyInfo> hgList = backReceiveMapper.getHgList(record);
if (hgList != null && hgList.size() > 0) { if (hgList != null && hgList.size() > 0) {
res = insertIad(hgList); res = insertIad(hgList);
if (res == 0) { if (res == 0) {
@ -200,12 +227,8 @@ public class BackReceiveServiceImpl implements BackReceiveService {
if (res == 0) { if (res == 0) {
throw new RuntimeException("ma_machines"); throw new RuntimeException("ma_machines");
} }
for (BackApplyInfo bi : hgList) {
passNum += bi.getBackNum();
}
} }
//维修的创建维修任务插入任务协议表 //维修的创建维修任务插入任务协议表
List<BackApplyInfo> wxList = backReceiveMapper.getWxList(record);
if (wxList != null && wxList.size() > 0) { if (wxList != null && wxList.size() > 0) {
//插入任务表tm_task //插入任务表tm_task
int newTaskId = insertTt(wxList, TaskTypeEnum.MAINTENANCE_TASK.getCode(), record.getCreateBy()); int newTaskId = insertTt(wxList, TaskTypeEnum.MAINTENANCE_TASK.getCode(), record.getCreateBy());
@ -213,13 +236,8 @@ public class BackReceiveServiceImpl implements BackReceiveService {
res = insertTta(newTaskId, wxList); res = insertTta(newTaskId, wxList);
//插入维修记录表repair_apply_details //插入维修记录表repair_apply_details
res = insertRad(newTaskId, wxList); res = insertRad(newTaskId, wxList);
for (BackApplyInfo bi : wxList) {
maintenanceNum += bi.getBackNum();
}
} }
//待报废的创建报废任务插入任务协议表 //待报废的创建报废任务插入任务协议表
List<BackApplyInfo> bfList = backReceiveMapper.getBfList(record);
if (bfList != null && bfList.size() > 0) { if (bfList != null && bfList.size() > 0) {
//插入任务表tm_task //插入任务表tm_task
int newTaskId = insertTt(bfList, TaskTypeEnum.SCRAP_TASK.getCode(), record.getCreateBy()); int newTaskId = insertTt(bfList, TaskTypeEnum.SCRAP_TASK.getCode(), record.getCreateBy());
@ -227,9 +245,6 @@ public class BackReceiveServiceImpl implements BackReceiveService {
res = insertTta(newTaskId, bfList); res = insertTta(newTaskId, bfList);
//插入维修记录表scrap_apply_details //插入维修记录表scrap_apply_details
res = insertSad(newTaskId, bfList); res = insertSad(newTaskId, bfList);
for (BackApplyInfo bi : bfList) {
scrapNum += bi.getBackNum();
}
} }
List<BackApplyInfo> allList = backReceiveMapper.getAllList(record); List<BackApplyInfo> allList = backReceiveMapper.getAllList(record);

View File

@ -659,10 +659,11 @@
bai.create_time DESC bai.create_time DESC
</select> </select>
<select id="receiveView" resultType="com.bonus.sgzb.base.api.domain.BackApplyInfo"> <select id="receiveView4FrontEnd" resultType="com.bonus.sgzb.base.api.domain.BackApplyInfo">
SELECT SELECT
bai.id, bai.id,
bai.task_id as taskId, bai.task_id as taskId,
bai.back_person as backPerson,
tta.agreement_id as agreementId, tta.agreement_id as agreementId,
mt.type_id as modelId, mt.type_id as modelId,
mt2.type_id as typeId, mt2.type_id as typeId,
@ -672,15 +673,22 @@
bad.pre_num as preNum, bad.pre_num as preNum,
bad.audit_num as auditNum, bad.audit_num as auditNum,
bad.status as status, bad.status as status,
IFNULL(bad.audit_num,0)-IFNULL(aa.back_num,0) as num, CASE WHEN ((IFNULL(sai.num, 0)-IFNULL(aa.back_num,0)) > (bad.audit_num-IFNULL(bb.finished_back_num,0)-IFNULL(aa.back_num,0)))
THEN (bad.audit_num-IFNULL(bb.finished_back_num,0)-IFNULL(aa.back_num,0))
ELSE
(CASE WHEN (IFNULL(sai.num, 0)-IFNULL(aa.back_num,0)) &lt; 0 THEN 0 ELSE (IFNULL(sai.num, 0)-IFNULL(aa.back_num,0)) END)
END as max_back_num,
IFNULL(aa.back_num,0) as in_completed_back_num,
IFNULL(bb.finished_back_num, 0) as finished_back_num,
mt.manage_type as manageType, mt.manage_type as manageType,
bb.finished_back_num,
mtk.user_id, mtk.user_id,
CONCAT('NSJJ',mt.`code`,mt.model_code) as `code` CONCAT('NSJJ',mt.`code`,mt.model_code) as `code`
FROM FROM
back_apply_details bad back_apply_details bad
LEFT JOIN back_apply_info bai on bai.id=bad.parent_id LEFT JOIN back_apply_info bai on bai.id=bad.parent_id
LEFT JOIN tm_task_agreement tta on tta.task_id=bai.task_id LEFT JOIN tm_task_agreement tta on tta.task_id=bai.task_id
LEFT JOIN (select agreement_id,type_id, sum(IFNULL(num, 0)) as num from slt_agreement_info where status=0
group by agreement_id,type_id) sai on tta.agreement_id=sai.agreement_id and sai.type_id=bad.type_id
LEFT JOIN ma_type mt on mt.type_id=bad.type_id LEFT JOIN ma_type mt on mt.type_id=bad.type_id
LEFT JOIN ma_type mt2 ON mt2.type_id=mt.parent_id LEFT JOIN ma_type mt2 ON mt2.type_id=mt.parent_id
LEFT JOIN ma_type_keeper mtk on mt.type_id=mtk.type_id LEFT JOIN ma_type_keeper mtk on mt.type_id=mtk.type_id
@ -691,7 +699,7 @@
FROM FROM
back_check_details back_check_details
WHERE WHERE
parent_id=#{id} parent_id=#{id} and is_finished is null
GROUP BY type_id GROUP BY type_id
) aa on aa.typeId=bad.type_id ) aa on aa.typeId=bad.type_id
LEFT JOIN ( LEFT JOIN (
@ -714,7 +722,7 @@
</if> </if>
</select> </select>
<select id="receiveView2" resultType="com.bonus.sgzb.base.api.domain.BackApplyInfo"> <select id="receiveView4Backend" resultType="com.bonus.sgzb.base.api.domain.BackApplyInfo">
SELECT SELECT
bai.id, bai.id,
bai.task_id as taskId, bai.task_id as taskId,
@ -727,38 +735,44 @@
bad.pre_num as preNum, bad.pre_num as preNum,
bad.audit_num as auditNum, bad.audit_num as auditNum,
bad.status as status, bad.status as status,
IFNULL(bad.audit_num,0)-IFNULL(aa.back_num,0) as num, CASE WHEN ((IFNULL(sai.num, 0)-IFNULL(aa.back_num,0)) > (bad.audit_num-IFNULL(bb.finished_back_num,0)-IFNULL(aa.back_num,0)))
THEN (bad.audit_num-IFNULL(bb.finished_back_num,0)-IFNULL(aa.back_num,0))
ELSE
(CASE WHEN (IFNULL(sai.num, 0)-IFNULL(aa.back_num,0)) &lt; 0 THEN 0 ELSE (IFNULL(sai.num, 0)-IFNULL(aa.back_num,0)) END)
END as num,
IFNULL(sai.num, 0) as max_back_num_backend,
mt.manage_type as manageType, mt.manage_type as manageType,
bb.finished_back_num,
mtk.user_id, mtk.user_id,
CONCAT('NSJJ',mt.`code`,mt.model_code) as `code` CONCAT('NSJJ',mt.`code`,mt.model_code) as `code`
FROM FROM
back_apply_details bad back_apply_details bad
LEFT JOIN back_apply_info bai on bai.id=bad.parent_id LEFT JOIN back_apply_info bai on bai.id=bad.parent_id
LEFT JOIN tm_task_agreement tta on tta.task_id=bai.task_id LEFT JOIN tm_task_agreement tta on tta.task_id=bai.task_id
LEFT JOIN (select agreement_id,type_id, sum(IFNULL(num, 0)) as num from slt_agreement_info where status=0
group by agreement_id,type_id) sai on tta.agreement_id=sai.agreement_id and sai.type_id=bad.type_id
LEFT JOIN ma_type mt on mt.type_id=bad.type_id LEFT JOIN ma_type mt on mt.type_id=bad.type_id
LEFT JOIN ma_type mt2 ON mt2.type_id=mt.parent_id LEFT JOIN ma_type mt2 ON mt2.type_id=mt.parent_id
LEFT JOIN ma_type_keeper mtk on mt.type_id=mtk.type_id LEFT JOIN ma_type_keeper mtk on mt.type_id=mtk.type_id
LEFT JOIN ( LEFT JOIN (
SELECT SELECT
type_id as typeId, type_id as typeId,
SUM(IFNULL(back_num,0)) as back_num SUM(IFNULL(back_num,0)) as back_num
FROM FROM
back_check_details back_check_details
WHERE WHERE
parent_id=#{parentId} parent_id=#{parentId} and is_finished is null
GROUP BY type_id GROUP BY type_id
) aa on aa.typeId=bad.type_id ) aa on aa.typeId=bad.type_id
LEFT JOIN ( LEFT JOIN (
SELECT SELECT
type_id as typeId, type_id as typeId,
SUM(IFNULL(back_num,0)) as finished_back_num SUM(IFNULL(back_num,0)) as finished_back_num
FROM FROM
back_check_details back_check_details
WHERE WHERE
parent_id=#{parentId} and is_finished = 1 parent_id=#{id} and is_finished = 1
GROUP BY type_id GROUP BY type_id
) bb on bb.typeId=bad.type_id ) bb on bb.typeId=bad.type_id
WHERE WHERE
bai.id=#{parentId} bai.id=#{parentId}
<if test="typeId != null and typeId != ''"> <if test="typeId != null and typeId != ''">