bms修改
This commit is contained in:
+81
@@ -17,6 +17,7 @@ import com.mhd.bms.domain.billManage.service.BillManageDomainService;
|
||||
import com.mhd.bms.domain.billOperationLog.repository.todo.BillOperationLogDO;
|
||||
import com.mhd.bms.domain.billOperationLog.service.BillOperationLogDomainService;
|
||||
import com.mhd.bms.domain.billingStatement.entity.BillingStatement;
|
||||
import com.mhd.bms.domain.billingStatement.repository.po.BillingStatementPO;
|
||||
import com.mhd.bms.domain.billingStatement.service.BillingStatementDomainService;
|
||||
import com.mhd.bms.domain.ncLog.entity.NcLog;
|
||||
import com.mhd.bms.domain.ncLog.repository.mapper.NcLogMapper;
|
||||
@@ -384,6 +385,86 @@ public class BillManageApplicationService {
|
||||
return flag && flagTwo && three;
|
||||
}
|
||||
|
||||
/**
|
||||
* 复制账单
|
||||
*/
|
||||
@Transactional
|
||||
public Boolean copyBill(BillManageDTO billManageDTO) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (ObjectUtil.isNull(loginUser)) {
|
||||
throw new DigitalLogisticsException(UserError.TIMEOUT);
|
||||
}
|
||||
if (billManageDTO.getBillManageId() == null) {
|
||||
throw new ServiceException("原账单id不能为空");
|
||||
}
|
||||
// 1. 获取原账单信息
|
||||
BillManagePO originalBill = billManageDomainService.getInfo(billManageDTO.getBillManageId());
|
||||
if (null == originalBill) {
|
||||
throw new ServiceException("原账单信息未找到");
|
||||
}
|
||||
// 2. 获取原账单明细
|
||||
List<BillDetailPO> originalDetails = billDetailDomainService.getDetailsByBillManageId(billManageDTO.getBillManageId());
|
||||
if (originalDetails == null || originalDetails.isEmpty()) {
|
||||
throw new ServiceException("原账单明细为空,无法复制");
|
||||
}
|
||||
// 3. 创建新账单,除账单编号外完全复制原账单
|
||||
String newBillNumber = OrderSequence.getOrderCode("ZD");
|
||||
BillManage newBill = new BillManage();
|
||||
BeanUtils.copyProperties(originalBill, newBill);
|
||||
newBill.setBillManageId(null);
|
||||
newBill.setBillNumber(newBillNumber);
|
||||
newBill.setCreateBy(loginUser.getUserPo().getUserId());
|
||||
newBill.setCreateByName(loginUser.getUserPo().getUserName());
|
||||
newBill.setCreateTime(new Date());
|
||||
newBill.setUpdateBy(loginUser.getUserPo().getUserId());
|
||||
newBill.setUpdateByName(loginUser.getUserPo().getUserName());
|
||||
newBill.setUpdateTime(new Date());
|
||||
newBill.setDelFlag(1);
|
||||
// 保存新账单
|
||||
boolean flag = billManageDomainService.saveEntity(newBill);
|
||||
if (!flag) {
|
||||
throw new ServiceException("复制账单失败,请重试");
|
||||
}
|
||||
// 4. 复制账单明细
|
||||
List<BillDetail> newDetailList = new ArrayList<>();
|
||||
for (BillDetailPO originalDetail : originalDetails) {
|
||||
BillDetail newDetail = new BillDetail();
|
||||
BeanUtils.copyProperties(originalDetail, newDetail);
|
||||
newDetail.setBillDetailId(null);
|
||||
newDetail.setBillManageId(newBill.getBillManageId());
|
||||
newDetail.setBillNumber(newBillNumber);
|
||||
newDetail.setCreateBy(loginUser.getUserPo().getUserId());
|
||||
newDetail.setCreateByName(loginUser.getUserPo().getUserName());
|
||||
newDetail.setCreateTime(new Date());
|
||||
newDetailList.add(newDetail);
|
||||
}
|
||||
Boolean flagTwo = billDetailDomainService.insertBatch(newDetailList);
|
||||
// 5. 复制计费流水(billing_statement)
|
||||
List<BillingStatementPO> originalStatements = billingStatementDomainService.getDetailsByManageId(billManageDTO.getBillManageId());
|
||||
boolean flagThree = true;
|
||||
if (originalStatements != null && !originalStatements.isEmpty()) {
|
||||
List<BillingStatement> newStatementList = new ArrayList<>();
|
||||
for (BillingStatementPO originalStatement : originalStatements) {
|
||||
BillingStatement newStatement = new BillingStatement();
|
||||
BeanUtils.copyProperties(originalStatement, newStatement);
|
||||
newStatement.setBillingStatementId(null);
|
||||
newStatement.setBillManageId(newBill.getBillManageId());
|
||||
newStatement.setCreateBy(loginUser.getUserPo().getUserId());
|
||||
newStatement.setCreateByName(loginUser.getUserPo().getUserName());
|
||||
newStatement.setCreateTime(new Date());
|
||||
newStatementList.add(newStatement);
|
||||
}
|
||||
flagThree = billingStatementDomainService.saveEntityBatch(newStatementList);
|
||||
}
|
||||
// 6. 保存操作日志
|
||||
BillOperationLogDO billOperationLogDO = new BillOperationLogDO();
|
||||
billOperationLogDO.setBillManageId(newBill.getBillManageId());
|
||||
billOperationLogDO.setOperationInfo(StringUtils.format(BillLogsConstants.copy_bill_text, originalBill.getBillNumber(), newBillNumber));
|
||||
billOperationLogDO.setOperationType(1);
|
||||
boolean three = billOperationLogDomainService.saveBillOperationLog(billOperationLogDO);
|
||||
return flag && flagTwo && flagThree && three;
|
||||
}
|
||||
|
||||
/**
|
||||
* 应收账单-客户确认
|
||||
*/
|
||||
|
||||
+7
@@ -94,6 +94,13 @@ public class BillManageDomainService {
|
||||
return billManageService.insert(billManageDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 直接保存账单管理实体
|
||||
*/
|
||||
public boolean saveEntity(BillManage billManage) {
|
||||
return billManageService.save(billManage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改账单管理
|
||||
*/
|
||||
|
||||
+7
@@ -119,6 +119,13 @@ public class BillingStatementDomainService {
|
||||
return billingStatementService.getInfo(billingStatementId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量保存计费流水实体
|
||||
*/
|
||||
public boolean saveEntityBatch(List<BillingStatement> list) {
|
||||
return billingStatementService.saveBatch(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量审核
|
||||
*/
|
||||
|
||||
@@ -96,4 +96,12 @@ public class BillLogsConstants
|
||||
public static final String payment_bill_text = "付款单号:{},付款金额:{}元";
|
||||
|
||||
|
||||
/**
|
||||
* 复制账单
|
||||
* 原账单编号:{},新账单编号:{}
|
||||
*/
|
||||
public static final String copy_bill_title = "复制账单";
|
||||
public static final String copy_bill_text = "原账单编号:{},新账单编号:{}";
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -229,6 +229,22 @@ public class BillManageApi extends BaseController{
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("复制账单")
|
||||
@PostMapping("/copyBill")
|
||||
public AjaxResult copyBill(@RequestBody BillManageDTO billManageDTO)
|
||||
{
|
||||
if(billManageDTO.getBillManageId() == null){
|
||||
throw new ServiceException("原账单id不能为空");
|
||||
}
|
||||
try {
|
||||
Boolean result = billManageApplicationService.copyBill(billManageDTO);
|
||||
return toAjax(result);
|
||||
}catch (Exception e){
|
||||
return AjaxResult.error("复制账单失败:"+e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("应收账单-客户确认")
|
||||
@PostMapping("/customerConfirmation")
|
||||
public AjaxResult customerConfirmation(@RequestBody BillManageDTO billManageDTO)
|
||||
|
||||
Reference in New Issue
Block a user