领料接口优化
This commit is contained in:
parent
e6bbc44f9b
commit
59febbed55
|
|
@ -14,7 +14,8 @@ public enum TmTaskTypeEnum {
|
|||
TM_TASK_SCRAP(6, "报废任务"),
|
||||
TM_TASK_SETTLEMENT(7, "结算任务"),
|
||||
TM_TASK_CHECK(8, "检验任务"),
|
||||
TM_TASK_FACTORY_MANAGEMENT(9, "物资厂家管理任务");
|
||||
TM_TASK_FACTORY_MANAGEMENT(9, "物资厂家管理任务"),
|
||||
TM_TASK_AGREEMENT_MANAGEMENT(10, "新增协议任务");
|
||||
|
||||
private final Integer taskTypeId;
|
||||
private final String taskTypeName;
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ public class BmAgreementInfoController extends BaseController
|
|||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody BmAgreementInfo bmAgreementInfo)
|
||||
{
|
||||
return toAjax(bmAgreementInfoService.updateBmAgreementInfo(bmAgreementInfo));
|
||||
return bmAgreementInfoService.updateBmAgreementInfo(bmAgreementInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ public interface IBmAgreementInfoService
|
|||
* @param bmAgreementInfo 协议管理
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateBmAgreementInfo(BmAgreementInfo bmAgreementInfo);
|
||||
public AjaxResult updateBmAgreementInfo(BmAgreementInfo bmAgreementInfo);
|
||||
|
||||
/**
|
||||
* 批量删除协议管理
|
||||
|
|
|
|||
|
|
@ -5,10 +5,12 @@ import java.util.Date;
|
|||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import com.bonus.common.biz.constant.MaterialConstants;
|
||||
import com.bonus.common.biz.enums.TmTaskTypeEnum;
|
||||
import com.bonus.common.core.exception.ServiceException;
|
||||
import com.bonus.common.core.utils.DateUtils;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.common.security.utils.SecurityUtils;
|
||||
import com.bonus.material.basic.domain.BmFileInfo;
|
||||
import com.bonus.material.basic.mapper.BmFileInfoMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
|
@ -16,7 +18,6 @@ import com.bonus.material.basic.mapper.BmAgreementInfoMapper;
|
|||
import com.bonus.material.basic.domain.BmAgreementInfo;
|
||||
import com.bonus.material.basic.service.IBmAgreementInfoService;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
|
|
@ -43,7 +44,13 @@ public class BmAgreementInfoServiceImpl implements IBmAgreementInfoService
|
|||
@Override
|
||||
public BmAgreementInfo selectBmAgreementInfoByAgreementId(Long agreementId)
|
||||
{
|
||||
return bmAgreementInfoMapper.selectBmAgreementInfoByAgreementId(agreementId);
|
||||
BmAgreementInfo bmAgreementInfo = bmAgreementInfoMapper.selectBmAgreementInfoByAgreementId(agreementId);
|
||||
BmFileInfo bmFileInfo = new BmFileInfo();
|
||||
bmFileInfo.setModelId(bmAgreementInfo.getAgreementId());
|
||||
bmFileInfo.setTaskType(TmTaskTypeEnum.TM_TASK_FACTORY_MANAGEMENT.getTaskTypeId());
|
||||
List<BmFileInfo> fileInfos = bmFileInfoMapper.selectBmFileInfoList(bmFileInfo);
|
||||
bmAgreementInfo.setBmFileInfos(fileInfos);
|
||||
return bmAgreementInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -105,10 +112,6 @@ public class BmAgreementInfoServiceImpl implements IBmAgreementInfoService
|
|||
return MaterialConstants.AGREEMENT_PREFIX + result + String.format("-%04d", num);
|
||||
}
|
||||
|
||||
// public static void main(String[] args) {
|
||||
// System.out.println(String.format("-%05d", 555));
|
||||
// }
|
||||
|
||||
/**
|
||||
* 修改协议管理
|
||||
*
|
||||
|
|
@ -116,10 +119,29 @@ public class BmAgreementInfoServiceImpl implements IBmAgreementInfoService
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateBmAgreementInfo(BmAgreementInfo bmAgreementInfo)
|
||||
public AjaxResult updateBmAgreementInfo(BmAgreementInfo bmAgreementInfo)
|
||||
{
|
||||
bmAgreementInfo.setUpdateTime(DateUtils.getNowDate());
|
||||
return bmAgreementInfoMapper.updateBmAgreementInfo(bmAgreementInfo);
|
||||
int count = bmAgreementInfoMapper.updateBmAgreementInfo(bmAgreementInfo);
|
||||
if (count > 0) {
|
||||
BmFileInfo bmFileInfoToDelete = new BmFileInfo();
|
||||
bmFileInfoToDelete.setModelId(bmAgreementInfo.getAgreementId());
|
||||
bmFileInfoToDelete.setTaskType(TmTaskTypeEnum.TM_TASK_AGREEMENT_MANAGEMENT.getTaskTypeId());
|
||||
bmFileInfoMapper.deleteBmFileInfoByBizInfo(bmFileInfoToDelete);
|
||||
if (CollectionUtils.isEmpty(bmAgreementInfo.getBmFileInfos())) {
|
||||
return AjaxResult.success("修改任务成功,无营业执照附件");
|
||||
}
|
||||
AtomicBoolean addFileInfoResult = new AtomicBoolean(false);
|
||||
bmAgreementInfo.getBmFileInfos().forEach(bmFileInfo -> {
|
||||
bmFileInfo.setModelId(bmAgreementInfo.getAgreementId());
|
||||
bmFileInfo.setCreateTime(DateUtils.getNowDate());
|
||||
addFileInfoResult.set(bmFileInfoMapper.insertBmFileInfo(bmFileInfo) > 0);
|
||||
});
|
||||
return addFileInfoResult.get() ? AjaxResult.success("修改任务成功") : AjaxResult.error("修改任务失败,附件表插入0条");
|
||||
} else {
|
||||
AjaxResult.error("无协议被修改");
|
||||
}
|
||||
return AjaxResult.success("修改协议成功");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue