This commit is contained in:
parent
29940b3575
commit
15895c528e
|
|
@ -19,7 +19,13 @@ import com.bonus.common.security.utils.SecurityUtils;
|
|||
import com.bonus.material.back.domain.*;
|
||||
import com.bonus.material.back.domain.vo.*;
|
||||
import com.bonus.common.biz.domain.BmFileInfo;
|
||||
import com.bonus.material.basic.domain.BmAgreementInfo;
|
||||
import com.bonus.material.basic.domain.BmUnit;
|
||||
import com.bonus.material.basic.mapper.BmAgreementInfoMapper;
|
||||
import com.bonus.material.basic.mapper.BmFileInfoMapper;
|
||||
import com.bonus.material.clz.domain.back.MaterialBackApplyDetails;
|
||||
import com.bonus.material.clz.domain.back.MaterialBackApplyInfo;
|
||||
import com.bonus.material.clz.mapper.MaterialBackInfoMapper;
|
||||
import com.bonus.material.common.domain.dto.SelectDto;
|
||||
import com.bonus.material.common.domain.vo.AgreementVo;
|
||||
import com.bonus.material.common.mapper.SelectMapper;
|
||||
|
|
@ -77,6 +83,12 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
|||
@Resource
|
||||
private LeaseApplyInfoMapper leaseApplyInfoMapper;
|
||||
|
||||
@Resource
|
||||
private MaterialBackInfoMapper materialBackInfoMapper;
|
||||
|
||||
@Resource
|
||||
private BmAgreementInfoMapper bmAgreementInfoMapper;
|
||||
|
||||
/**
|
||||
* 查询退料任务 - 性能优化版
|
||||
*
|
||||
|
|
@ -849,9 +861,12 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
|||
bmFileInfo.setModelId(details.getId());
|
||||
bmFileInfo.setTaskId(taskId);
|
||||
bmFileInfo.setTaskType(3);
|
||||
List<BmFileInfo> bmFileInfos = bmFileInfoMapper.selectBmFileInfoList(bmFileInfo);
|
||||
if (CollectionUtils.isNotEmpty(bmFileInfos)) {
|
||||
result += bmFileInfoMapper.deleteBmFileInfoByBizInfo(bmFileInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -870,9 +885,12 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
|||
bmFileInfo.setModelId(maCodeVo.getMaId());
|
||||
bmFileInfo.setTaskId(taskId);
|
||||
bmFileInfo.setTaskType(3);
|
||||
List<BmFileInfo> bmFileInfos = bmFileInfoMapper.selectBmFileInfoList(bmFileInfo);
|
||||
if (CollectionUtils.isNotEmpty(bmFileInfos)) {
|
||||
result += bmFileInfoMapper.deleteBmFileInfoByBizInfo(bmFileInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -959,7 +977,13 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
|||
} else {
|
||||
return AjaxResult.error("退料物资为空,无法进行提交");
|
||||
}
|
||||
// 设置更新信息
|
||||
// 判断是否为班组退料,将退料同步材料站
|
||||
boolean isClz = false;
|
||||
/*BmUnit unit = taskMapper.selectBmUnitInfo(backApplyInfo);
|
||||
if (unit != null && unit.getTypeId() == 1731L) {
|
||||
isClz = true;
|
||||
}*/
|
||||
// 设置更新信息,
|
||||
backApplyInfo.setUpdateBy(SecurityUtils.getLoginUser().getSysUser().getNickName());
|
||||
backApplyInfo.setUpdateTime(DateUtils.getNowDate());
|
||||
backApplyInfo.setTaskStatus(BackTaskStatusEnum.BACK_TASK_IN_FINISHED.getStatus());
|
||||
|
|
@ -977,6 +1001,55 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
|||
Long newTaskId = insertTt(SecurityUtils.getLoginUser().getSysUser().getNickName(), backApplyInfo.getRemark(), backApplyInfo.getTaskId());
|
||||
// 插入协议任务表
|
||||
result += insertTta(newTaskId, applyInfoList);
|
||||
MaterialBackApplyInfo materialBackApplyInfo = new MaterialBackApplyInfo();
|
||||
BmAgreementInfo bmAgreementInfo = new BmAgreementInfo();
|
||||
bmAgreementInfo.setUnitId(backApplyInfo.getUnitId());
|
||||
bmAgreementInfo.setProjectId(backApplyInfo.getProId());
|
||||
BmAgreementInfo info = bmAgreementInfoMapper.queryByTeamIdAndProjectIdCl(bmAgreementInfo);
|
||||
if (isClz) {
|
||||
int thisMonthMaxOrder = taskMapper.getMonthMaxOrderByDate(DateUtils.getCurrentYear(), DateUtils.getCurrentMonth(), TmTaskTypeEnum.TM_TASK_MATERIAL_BACK.getTaskTypeId());
|
||||
String code = genderClzTaskCode(thisMonthMaxOrder);
|
||||
TmTask tmTask = new TmTask(null, TmTaskTypeEnum.TM_TASK_MATERIAL_BACK.getTaskTypeId(),
|
||||
BackTaskStatusEnum.BACK_TASK_IN_FINISHED.getStatus(), null, thisMonthMaxOrder + 1, code);
|
||||
tmTask.setCreateTime(DateUtils.getNowDate());
|
||||
String createBy = SecurityUtils.getLoginUser().getSysUser().getNickName();
|
||||
tmTask.setCreateBy(createBy);
|
||||
materialBackApplyInfo.setCode(code);
|
||||
materialBackApplyInfo.setCreateBy(createBy);
|
||||
materialBackApplyInfo.setCreateTime(DateUtils.getNowDate());
|
||||
// 保存退料信息到 tm_task 表中
|
||||
result += taskMapper.insertTmTask(tmTask);
|
||||
if (result > 0) {
|
||||
TmTaskAgreement tmTaskAgreement = new TmTaskAgreement(tmTask.getTaskId(), info.getAgreementId());
|
||||
tmTaskAgreement.setCreateTime(DateUtils.getNowDate());
|
||||
tmTaskAgreement.setCreateBy(createBy);
|
||||
taskAgreementMapper.insertTmTaskAgreement(tmTaskAgreement);
|
||||
materialBackApplyInfo.setTaskId(tmTask.getTaskId());
|
||||
materialBackApplyInfo.setBackStyle("2");
|
||||
materialBackApplyInfo.setStatus("2");
|
||||
BackApplyInfo backApplyInfo1 = backApplyInfoMapper.selectBackApplyInfoById(backApplyInfo.getId());
|
||||
if (backApplyInfo1 != null) {
|
||||
materialBackApplyInfo.setBackPerson(StringUtils.isNotBlank(backApplyInfo1.getBackPerson()) ? backApplyInfo1.getBackPerson() : "");
|
||||
materialBackApplyInfo.setPhone(StringUtils.isNotBlank(backApplyInfo1.getPhone()) ? backApplyInfo1.getPhone() : "");
|
||||
}
|
||||
result += materialBackInfoMapper.insertBackApplyInfo(materialBackApplyInfo);
|
||||
if (CollectionUtils.isNotEmpty(applyDetails)) {
|
||||
for (BackApplyDetails applyInfo : applyDetails) {
|
||||
MaterialBackApplyDetails details = new MaterialBackApplyDetails();
|
||||
details.setCode(code);
|
||||
details.setParentId(materialBackApplyInfo.getId());
|
||||
details.setPreNum(applyInfo.getPreNum());
|
||||
details.setAuditNum(applyInfo.getPreNum());
|
||||
details.setStatus(String.valueOf(BackTaskStatusEnum.BACK_TASK_NO_FINISHED.getStatus()));
|
||||
details.setCreateBy(createBy);
|
||||
details.setCreateTime(DateUtils.getNowDate());
|
||||
details.setTypeId(applyInfo.getTypeId());
|
||||
// 保存退料详情
|
||||
result += materialBackInfoMapper.insertBackApplyDetails(details);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (String typeId : typeIdList) {
|
||||
// 查询待维修的机具设备
|
||||
backApplyInfo.setTypeId(typeId);
|
||||
|
|
@ -992,6 +1065,25 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
|||
if (res == 0) {
|
||||
throw new RuntimeException("该机具未被领料使用");
|
||||
}
|
||||
if (isClz) {
|
||||
for (BackApplyInfo applyInfo : allList) {
|
||||
applyInfo.setAgreementId(info.getAgreementId());
|
||||
MaterialBackApplyDetails details = new MaterialBackApplyDetails();
|
||||
details.setParentId(materialBackApplyInfo.getId());
|
||||
details.setTypeId(Long.parseLong(typeId));
|
||||
details.setCreateBy(SecurityUtils.getLoginUser().getSysUser().getNickName());
|
||||
details.setCreateTime(DateUtils.getNowDate());
|
||||
details.setPreNum(applyInfo.getBackNum());
|
||||
details.setStatus("0");
|
||||
details.setMaId(applyInfo.getMaId() != null ? applyInfo.getMaId() : null);
|
||||
details.setIsFinished(1);
|
||||
result += materialBackInfoMapper.insertCheckDetails(details);
|
||||
}
|
||||
res = updateSlt4BeanClz(materialBackApplyInfo, allList);
|
||||
if (res == 0) {
|
||||
throw new RuntimeException("同步材料站结算出错");
|
||||
}
|
||||
}
|
||||
}
|
||||
// 完成退料部分,更新 back_check_details
|
||||
finishBackCheckDetails(backApplyInfo);
|
||||
|
|
@ -1006,6 +1098,56 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
|||
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMsg());
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成材料站退料任务单号
|
||||
* @param thisMonthMaxOrder
|
||||
* @return
|
||||
*/
|
||||
private String genderClzTaskCode(int thisMonthMaxOrder) {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Date nowDate = DateUtils.getNowDate();
|
||||
String format = dateFormat.format(nowDate);
|
||||
String result = format.replace("-", "");
|
||||
return MaterialConstants.BACK_MATERIAL_TASK_TYPE_LABEL + result + String.format("-%03d", thisMonthMaxOrder + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步材料站结算
|
||||
* @param record
|
||||
* @param allList
|
||||
* @return
|
||||
*/
|
||||
private int updateSlt4BeanClz(MaterialBackApplyInfo record, List<BackApplyInfo> allList) {
|
||||
for (BackApplyInfo bean : allList) {
|
||||
MaterialBackApplyInfo materialBackApplyInfo = new MaterialBackApplyInfo();
|
||||
materialBackApplyInfo.setAgreementId(bean.getAgreementId());
|
||||
materialBackApplyInfo.setTypeId(bean.getTypeId());
|
||||
materialBackApplyInfo.setMaId(bean.getMaId() != null ? bean.getMaId() : null);
|
||||
List<SltAgreementInfo> infoList = materialBackInfoMapper.getStlInfo(materialBackApplyInfo);
|
||||
if (infoList.size() > 0) {
|
||||
BigDecimal backNum = bean.getBackNum();
|
||||
for (SltAgreementInfo info : infoList) {
|
||||
BigDecimal num = info.getBackNum();
|
||||
if (backNum.compareTo(num) == 0) {
|
||||
materialBackInfoMapper.updateStlInfo(info, record);
|
||||
break;
|
||||
} else if (backNum.compareTo(num) > 0) {
|
||||
backNum = backNum.subtract(num);
|
||||
materialBackInfoMapper.updateStlInfo(info, record);
|
||||
} else {
|
||||
BigDecimal many = num.subtract(backNum);
|
||||
materialBackInfoMapper.updateStlInfoTwo(info, record, backNum);
|
||||
materialBackInfoMapper.insStlInfoTwo(info, many);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑打印状态
|
||||
* @param id
|
||||
|
|
@ -1292,6 +1434,11 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
|||
if (CollectionUtils.isNotEmpty(maCodeVoList)) {
|
||||
result += deleteBmFileInfoForCodes(maCodeVoList, backApplyInfo.getId());
|
||||
}
|
||||
// 查询back_check_details中是否还有数据,如果没有,删除back_apply_details
|
||||
List<BackApplyDetails> list = backApplyInfoMapper.selectBackApplyDetailsList(backApplyDetails);
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
result += backApplyInfoMapper.deleteBackApplyDetailsById(backApplyDetails);
|
||||
}
|
||||
if (result > 0) {
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -680,7 +680,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="status != null">`status` = #{status},</if>
|
||||
<if test="directId != null">direct_id = #{directId},</if>
|
||||
<if test="printStatus != null">print_status = #{printStatus},</if>
|
||||
<if test="material_man != null and material_man != ''">material_man = #{materialMan},</if>
|
||||
<if test="materialMan != null and materialMan != ''">material_man = #{materialMan},</if>
|
||||
<if test="confirmTime != null and confirmTime != ''">confirm_time = #{confirmTime},</if>
|
||||
<if test="isConfirm != null">is_confirm = #{isConfirm},</if>
|
||||
<if test="confirmRemark != null and confirmRemark != ''">confirm_remark = #{confirmRemark},</if>
|
||||
|
|
|
|||
Loading…
Reference in New Issue