退料可选需求变更

This commit is contained in:
liang.chao 2024-07-16 19:44:16 +08:00
parent aaa118151a
commit 801ac0807d
5 changed files with 139 additions and 98 deletions

View File

@ -118,13 +118,22 @@ public class BackReceiveController extends BaseController {
@Log(title = "退料接收明细-web", businessType = BusinessType.QUERY) @Log(title = "退料接收明细-web", businessType = BusinessType.QUERY)
@PostMapping("/getReceiveViewWebNum") @PostMapping("/getReceiveViewWebNum")
public AjaxResult getReceiveViewWebNum(@RequestBody BackApplyInfo record) { public AjaxResult getReceiveViewWebNum(@RequestBody BackApplyInfo record) {
List<BackApplyInfo> list = backReceiveService.receiveView(record); int res = 0;
for (BackApplyInfo backApplyInfo : list) { String[] split = record.getTypeId().split(",");
if (Double.valueOf(backApplyInfo.getNum()).intValue() > 0) { for (String s : split) {
return AjaxResult.success(0); record.setModelId(s);
List<BackApplyInfo> list = backReceiveService.receiveView(record);
for (BackApplyInfo backApplyInfo : list) {
if (Double.valueOf(backApplyInfo.getNum()).intValue() != 0) {
res++;
}
} }
} }
return AjaxResult.success(1); if (res > 0) {
return AjaxResult.success(0);
} else {
return AjaxResult.success(1);
}
} }
/** /**

View File

@ -31,6 +31,7 @@ public interface BackReceiveMapper {
* @return List<BackApplyInfo> * @return List<BackApplyInfo>
*/ */
List<BackApplyInfo> receiveView(BackApplyInfo record); List<BackApplyInfo> receiveView(BackApplyInfo record);
List<BackApplyInfo> receiveView2(BackApplyInfo record);
/** /**
* 添加接收数据back_check_details * 添加接收数据back_check_details
@ -207,4 +208,5 @@ public interface BackReceiveMapper {
List<TmTask> getScrapBackMachine(TmTask task); List<TmTask> getScrapBackMachine(TmTask task);
int updateStatus(BackApplyInfo record);
} }

View File

@ -13,8 +13,10 @@ 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 com.bonus.sgzb.common.core.utils.GlobalConstants; import com.bonus.sgzb.common.core.utils.GlobalConstants;
import com.bonus.sgzb.common.core.utils.StringHelper; import com.bonus.sgzb.common.core.utils.StringHelper;
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import com.bonus.sgzb.common.security.utils.SecurityUtils; import com.bonus.sgzb.common.security.utils.SecurityUtils;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -44,7 +46,7 @@ public class BackReceiveServiceImpl implements BackReceiveService {
@Override @Override
public List<BackApplyInfo> getbackReceiveList(BackApplyInfo record) { public List<BackApplyInfo> getbackReceiveList(BackApplyInfo record) {
List<BackApplyInfo> backApplyInfoList = backReceiveMapper.getbackReceiveList(record); List<BackApplyInfo> backApplyInfoList = backReceiveMapper.getbackReceiveList(record);
if (SecurityUtils.getLoginUser().getRoles().contains("admin")){ if (SecurityUtils.getLoginUser().getRoles().contains("admin")) {
return backApplyInfoList; return backApplyInfoList;
} }
List<BackApplyInfo> backApplyInfos = new ArrayList<>(); List<BackApplyInfo> backApplyInfos = new ArrayList<>();
@ -65,32 +67,11 @@ 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.receiveView(record);
//重庆成套设备处理宁夏不用 return backApplyInfoList;
/* int count1 = 0; }
int count2 = 0;
for (BackApplyInfo backApplyInfo : backApplyInfoList) { public List<BackApplyInfo> receiveView2(BackApplyInfo record) {
if ("2".equals(backApplyInfo.getManageType())) { List<BackApplyInfo> backApplyInfoList = backReceiveMapper.receiveView2(record);
List<MachinePart> machineParts = new ArrayList<>();
List<TmTask> typeIds = tmTaskMapper.getMaTypeDetailsByTypeId(backApplyInfo);
typeIds.removeIf(item -> item == null);
for (TmTask typeId : typeIds) {
MachinePart machinePart = tmTaskMapper.getMachineParts(typeId);
machinePart.setParentId(record.getId());
int countMachineByPidAndTid = tmTaskMapper.getCountMachineByPidAndTid(machinePart);
Double machinePartNum = typeId.getPartNum() * Double.parseDouble(backApplyInfo.getPreNum());
count1 += machinePartNum;
count2 += countMachineByPidAndTid;
machinePart.setPartNum(machinePartNum - countMachineByPidAndTid);
machineParts.add(machinePart);
}
backApplyInfo.setMaTypeDetails(machineParts);
if (count1 == count2) {
backApplyInfo.setPartNum(0);
} else {
backApplyInfo.setPartNum((int) Double.parseDouble(backApplyInfo.getPreNum()));
}
}
}*/
return backApplyInfoList; return backApplyInfoList;
} }
@ -114,6 +95,10 @@ public class BackReceiveServiceImpl implements BackReceiveService {
return res; return res;
} }
private int updateStatus(BackApplyInfo record) {
return backReceiveMapper.updateStatus(record);
}
private int updateTaskStatus(int taskId, int i) { private int updateTaskStatus(int taskId, int i) {
int res; int res;
res = backReceiveMapper.updateTaskStatus(taskId, i); res = backReceiveMapper.updateTaskStatus(taskId, i);
@ -165,8 +150,7 @@ public class BackReceiveServiceImpl implements BackReceiveService {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public int endBack(BackApplyInfo record) { public int endBack(BackApplyInfo record) {
int res; int res = 0;
// try {
int taskId = record.getTaskId(); int taskId = record.getTaskId();
//先判断是否已经完成退料了 //先判断是否已经完成退料了
int taskStatus = selectTaskStatus(taskId); int taskStatus = selectTaskStatus(taskId);
@ -174,69 +158,81 @@ public class BackReceiveServiceImpl implements BackReceiveService {
throw new RuntimeException("该退料单已完成退料"); throw new RuntimeException("该退料单已完成退料");
} }
//修改任务状态 //修改任务状态
res = updateTaskStatus(taskId, 40); /* res = updateTaskStatus(taskId, 40);
if (res == 0) { if (res == 0) {
throw new RuntimeException("tm_task修改状态"); throw new RuntimeException("tm_task修改状态");
}*/
record.setId(record.getParentId());
List<BackApplyInfo> list = receiveView2(record);
boolean allZeros = list.stream().allMatch(n -> Double.valueOf(n.getNum()).intValue() == 0);
if (allZeros) {
res = updateTaskStatus(taskId, 40);
} }
//更加退料接收的数据创建下一步流程 //更加退料接收的数据创建下一步流程
//合格的插入入库记录input_apply_details修改库存ma_type,修改机具状态 //合格的插入入库记录input_apply_details修改库存ma_type,修改机具状态
List<BackApplyInfo> hgList = backReceiveMapper.getHgList(record); if (StringUtils.isNotBlank(record.getTypeId())) {
if (hgList != null && hgList.size() > 0) { for (String s : record.getTypeId().split(",")) {
res = insertIad(hgList); record.setTypeId(s);
if (res == 0) { //修改back_apply_details为已退料1
throw new RuntimeException("input_apply_details"); res = updateStatus(record);
} List<BackApplyInfo> hgList = backReceiveMapper.getHgList(record);
// 如果是成套的机具成套机具的库存也要添加 if (hgList != null && hgList.size() > 0) {
List<BackApplyInfo> ctList = backReceiveMapper.getCtList(record); res = insertIad(hgList);
if (res == 0) {
throw new RuntimeException("input_apply_details");
}
// 如果是成套的机具成套机具的库存也要添加
/* List<BackApplyInfo> ctList = backReceiveMapper.getCtList(record);
if (ctList.size() > 0) { if (ctList.size() > 0) {
for (BackApplyInfo backApplyInfo : ctList) { for (BackApplyInfo backApplyInfo : ctList) {
if ("2".equals(backApplyInfo.getManageType())) { if ("2".equals(backApplyInfo.getManageType())) {
backReceiveMapper.updateMt(backApplyInfo); backReceiveMapper.updateMt(backApplyInfo);
} }
} }
} }*/
res = updateMt(hgList); res = updateMt(hgList);
if (res == 0) { if (res == 0) {
throw new RuntimeException("ma_type"); throw new RuntimeException("ma_type");
} }
res = updateMaStatus(hgList); res = updateMaStatus(hgList);
if (res == 0) { if (res == 0) {
throw new RuntimeException("ma_machines"); throw new RuntimeException("ma_machines");
} }
} }
//维修的创建维修任务插入任务协议表 //维修的创建维修任务插入任务协议表
List<BackApplyInfo> wxList = backReceiveMapper.getWxList(record); 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());
//插入协议任务表tm_task_agreement //插入协议任务表tm_task_agreement
res = insertTta(newTaskId, wxList); res = insertTta(newTaskId, wxList);
//插入维修记录表repair_apply_details //插入维修记录表repair_apply_details
res = insertRad(newTaskId, wxList); res = insertRad(newTaskId, wxList);
} }
//待报废的创建报废任务插入任务协议表 //待报废的创建报废任务插入任务协议表
List<BackApplyInfo> bfList = backReceiveMapper.getBfList(record); 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.RETURNED_MATERIALS_TO_BE_SCRAPPED.getCode(), record.getCreateBy()); int newTaskId = insertTt(bfList, TaskTypeEnum.RETURNED_MATERIALS_TO_BE_SCRAPPED.getCode(), record.getCreateBy());
//插入协议任务表tm_task_agreement //插入协议任务表tm_task_agreement
res = insertTta(newTaskId, bfList); res = insertTta(newTaskId, bfList);
//插入维修记录表scrap_apply_details //插入维修记录表scrap_apply_details
res = insertSad(newTaskId, bfList); res = insertSad(newTaskId, bfList);
} }
// 结算功能
List<BackApplyInfo> allList = backReceiveMapper.getAllList(record); List<BackApplyInfo> allList = backReceiveMapper.getAllList(record);
if (allList != null && allList.size() > 0) { if (allList != null && allList.size() > 0) {
res = updateSlt(record, allList); res = updateSlt(record, allList);
if (res == 0) { if (res == 0) {
throw new RuntimeException("该机具未被领料使用"); throw new RuntimeException("该机具未被领料使用");
}
}
} }
} else {
throw new RuntimeException("typeId为空");
} }
// } catch (Exception e) {
// throw new RuntimeException(e.getMessage());
// }
return res; return res;
} }
@ -249,6 +245,11 @@ public class BackReceiveServiceImpl implements BackReceiveService {
} }
} }
@Override
public List<BackApplyInfo> codeQuery(BackApplyInfo record) {
return backReceiveMapper.codeQuery(record);
}
private int updateSlt(BackApplyInfo record, List<BackApplyInfo> hgList) { private int updateSlt(BackApplyInfo record, List<BackApplyInfo> hgList) {
for (BackApplyInfo bean : hgList) { for (BackApplyInfo bean : hgList) {
List<SltAgreementInfo> infoList = backReceiveMapper.getStlInfo(bean); List<SltAgreementInfo> infoList = backReceiveMapper.getStlInfo(bean);
@ -276,11 +277,6 @@ public class BackReceiveServiceImpl implements BackReceiveService {
return 1; return 1;
} }
@Override
public List<BackApplyInfo> codeQuery(BackApplyInfo record) {
return backReceiveMapper.codeQuery(record);
}
@Override @Override
public List<BackApplyInfo> qrcodeQuery(BackApplyInfo record) { public List<BackApplyInfo> qrcodeQuery(BackApplyInfo record) {
return backReceiveMapper.qrcodeQuery(record); return backReceiveMapper.qrcodeQuery(record);

View File

@ -614,6 +614,9 @@
status = '1' status = '1'
where id = #{info.id} where id = #{info.id}
</update> </update>
<update id="updateStatus">
update back_apply_details set back_status = 1 where parent_id = #{parentId} and type_id = #{typeId}
</update>
<delete id="deleteCheckDetails"> <delete id="deleteCheckDetails">
delete from back_check_details where parent_id = #{parentId} and type_id = #{typeId} delete from back_check_details where parent_id = #{parentId} and type_id = #{typeId}
<if test="maId != null and maId != ''"> <if test="maId != null and maId != ''">
@ -658,7 +661,7 @@
LEFT JOIN sys_dic sd ON sd.id = tt.task_status LEFT JOIN sys_dic sd ON sd.id = tt.task_status
LEFT JOIN tm_task tt1 on tt1.task_id = bai.parent_id LEFT JOIN tm_task tt1 on tt1.task_id = bai.parent_id
WHERE WHERE
tt.task_status IN ( 37, 38, 39, 40 ) tt.task_status IN ( 38, 39, 40 )
<if test="keyWord != null and keyWord != ''"> <if test="keyWord != null and keyWord != ''">
and bai.code like concat('%', #{keyWord}, '%') and bai.code like concat('%', #{keyWord}, '%')
</if> </if>
@ -708,6 +711,7 @@
mt2.type_name AS typeName, mt2.type_name AS typeName,
bad.audit_num as preNum, bad.audit_num as preNum,
bad.status as status, bad.status as status,
bad.back_status as backStatus,
IFNULL(bad.audit_num,0)-IFNULL(aa.back_num,0) as num, IFNULL(bad.audit_num,0)-IFNULL(aa.back_num,0) as num,
mt.manage_type as manageType, mt.manage_type as manageType,
CONCAT('NSJJ',mt.`code`,mt.model_code) as `code` CONCAT('NSJJ',mt.`code`,mt.model_code) as `code`
@ -757,7 +761,7 @@
LEFT JOIN back_apply_info bai on bai.id=bcd.parent_id LEFT JOIN back_apply_info bai on bai.id=bcd.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
WHERE WHERE
bcd.parent_id=#{parentId} bcd.parent_id=#{parentId} and bcd.type_id=#{typeId}
and bcd.back_status='1' and bcd.back_status='1'
</select> </select>
@ -777,7 +781,7 @@
LEFT JOIN back_apply_info bai on bai.id=bcd.parent_id LEFT JOIN back_apply_info bai on bai.id=bcd.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
WHERE WHERE
bcd.parent_id=#{parentId} bcd.parent_id=#{parentId} and bcd.type_id=#{typeId}
and bcd.back_status='2' and bcd.back_status='2'
</select> </select>
@ -800,7 +804,7 @@
LEFT JOIN back_apply_info bai on bai.id=bcd.parent_id LEFT JOIN back_apply_info bai on bai.id=bcd.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
WHERE WHERE
bcd.parent_id=#{parentId} bcd.parent_id=#{parentId} and bcd.type_id=#{typeId}
and bcd.back_status='3' and bcd.back_status='3'
</select> </select>
@ -932,7 +936,7 @@
LEFT JOIN back_apply_info bai ON bai.id = bcd.parent_id LEFT JOIN back_apply_info bai ON bai.id = bcd.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
WHERE WHERE
bcd.parent_id = #{parentId} bcd.parent_id = #{parentId} and bcd.type_id=#{typeId}
GROUP By bcd.type_id,bcd.ma_id GROUP By bcd.type_id,bcd.ma_id
</select> </select>
<select id="getBackMachine" resultType="com.bonus.sgzb.app.domain.TmTask"> <select id="getBackMachine" resultType="com.bonus.sgzb.app.domain.TmTask">
@ -1093,5 +1097,41 @@
AND mm.ma_code like concat('%', #{maCode}, '%') AND mm.ma_code like concat('%', #{maCode}, '%')
</if> </if>
</select> </select>
<select id="receiveView2" resultType="com.bonus.sgzb.app.domain.BackApplyInfo">
SELECT
bai.id,
bai.task_id as taskId,
tta.agreement_id as agreementId,
mt.type_id as modelId,
mt2.type_id as typeId,
mt.type_name as typeCode,
mt.unit_name as unitName,
mt2.type_name AS typeName,
bad.audit_num as preNum,
bad.status as status,
bad.back_status as backStatus,
IFNULL(bad.audit_num,0)-IFNULL(aa.back_num,0) as num,
mt.manage_type as manageType,
CONCAT('NSJJ',mt.`code`,mt.model_code) as `code`
FROM
back_apply_details bad
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 ma_type mt on mt.type_id=bad.type_id
LEFT JOIN ma_type mt2 ON mt2.type_id=mt.parent_id
LEFT JOIN (
SELECT
type_id as typeId,
SUM(IFNULL(back_num,0)) as back_num
FROM
back_check_details
WHERE
parent_id=#{id}
GROUP BY type_id
) aa on aa.typeId=bad.type_id
WHERE
bai.id=#{id}
order by bad.create_time
</select>
</mapper> </mapper>

View File

@ -60,12 +60,6 @@ public class BackApplyController extends BaseController {
return AjaxResult.success(ListPagingUtil.paging(pageIndex, pageSize, list)); return AjaxResult.success(ListPagingUtil.paging(pageIndex, pageSize, list));
} }
/* @ApiOperation(value = "退料申请获取当前类型在用量")
@GetMapping("/getUseNumByTypeId")
public AjaxResult getUseNumByTypeId(String typeId) {
return AjaxResult.success(backApplyService.getUseNumByTypeId(typeId));
}*/
@ApiOperation(value = "在用设备类型树") @ApiOperation(value = "在用设备类型树")
@PostMapping("/getUseTypeTree") @PostMapping("/getUseTypeTree")
public AjaxResult getUseTypeTree(@RequestBody BackApplyInfo bean) { public AjaxResult getUseTypeTree(@RequestBody BackApplyInfo bean) {