|
@@ -100,6 +100,41 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
|
|
|
@Value("${oss.bucket.name:}")
|
|
|
private String bucket;
|
|
|
|
|
|
+ /**
|
|
|
+ * 费用详情列表(流向,费用名称去重集合)
|
|
|
+ *
|
|
|
+ * @param expenseInfo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<ExpenseInfo> removeRepeatList(ExpenseInfo expenseInfo) {
|
|
|
+ //查询所有费用集合
|
|
|
+ List<ExpenseInfo> expenseInfoList = this.selectList(new EntityWrapper<ExpenseInfo>().eq("delete_flag", "0"));
|
|
|
+ if ("1".equals(expenseInfo.getRemoveRepeatFlag())) {
|
|
|
+ List<ExpenseInfo> expenseInfos = expenseInfoList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(()
|
|
|
+ -> new TreeSet<>(Comparator.comparing(ExpenseInfo -> ExpenseInfo.getWarehouseName() + ExpenseInfo.getContractNo()))), ArrayList::new));
|
|
|
+ return expenseInfos;
|
|
|
+ } else if ("2".equals(expenseInfo.getRemoveRepeatFlag())) {
|
|
|
+ List<ExpenseInfo> expenseInfos = expenseInfoList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(()
|
|
|
+ -> new TreeSet<>(Comparator.comparing(ExpenseInfo::getExpenseName))), ArrayList::new));
|
|
|
+ return expenseInfos;
|
|
|
+ } else if ("3".equals(expenseInfo.getRemoveRepeatFlag())) {
|
|
|
+ List<ExpenseInfo> expenseInfos = expenseInfoList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(()
|
|
|
+ -> new TreeSet<>(Comparator.comparing(ExpenseInfo::getUnallocatedAmount))), ArrayList::new));
|
|
|
+ return expenseInfos;
|
|
|
+ } else {
|
|
|
+ List<ExpenseInfo> expenseInfos = expenseInfoList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(()
|
|
|
+ -> new TreeSet<>(Comparator.comparing(ExpenseInfo::getAgent))), ArrayList::new));
|
|
|
+ return expenseInfos;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 费用详情列表
|
|
|
+ *
|
|
|
+ * @param expenseInfo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
@Override
|
|
|
public Page<ExpenseInfo> selectInfo(ExpenseInfo expenseInfo) {
|
|
|
Map<String, Object> pageView = new HashMap<>();
|
|
@@ -128,6 +163,66 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
|
|
|
pageView.put("endDate", expenseInfo.getEndDate());
|
|
|
pageView.put("businessKeys", businessKeys);
|
|
|
pageView.put("statusSet", statusSet);
|
|
|
+ if (!StringUtils.isEmpty(expenseInfo.getCostNo())) {
|
|
|
+ String str = expenseInfo.getCostNo();
|
|
|
+ boolean str1 = str.contains(",");
|
|
|
+ if (str1) {
|
|
|
+ List<String> numberList = Arrays.asList(str.split(","));
|
|
|
+ pageView.put("numberList", numberList);
|
|
|
+ } else {
|
|
|
+ pageView.put("number", expenseInfo.getCostNo());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(expenseInfo.getPurpose())) {
|
|
|
+ String str = expenseInfo.getPurpose();
|
|
|
+ boolean str1 = str.contains(",");
|
|
|
+ if (str1) {
|
|
|
+ List<String> purposeList = Arrays.asList(str.split(","));
|
|
|
+ pageView.put("purposeList", purposeList);
|
|
|
+ } else {
|
|
|
+ pageView.put("purpose", expenseInfo.getPurpose());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(expenseInfo.getFlowTo())) {
|
|
|
+ String str = expenseInfo.getFlowTo();
|
|
|
+ boolean str1 = str.contains(",");
|
|
|
+ if (str1) {
|
|
|
+ List<String> flowToList = Arrays.asList(str.split(","));
|
|
|
+ pageView.put("flowToList", flowToList);
|
|
|
+ } else {
|
|
|
+ pageView.put("flowTo", expenseInfo.getFlowTo());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(expenseInfo.getExpenseName())) {
|
|
|
+ String str = expenseInfo.getExpenseName();
|
|
|
+ boolean str1 = str.contains(",");
|
|
|
+ if (str1) {
|
|
|
+ List<String> expenseNameList = Arrays.asList(str.split(","));
|
|
|
+ pageView.put("expenseNameList", expenseNameList);
|
|
|
+ } else {
|
|
|
+ pageView.put("expenseName", expenseInfo.getExpenseName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(expenseInfo.getUnallocatedNumber())) {
|
|
|
+ String str = expenseInfo.getUnallocatedNumber();
|
|
|
+ boolean str1 = str.contains(",");
|
|
|
+ if (str1) {
|
|
|
+ List<String> unallocatedAmountList = Arrays.asList(str.split(","));
|
|
|
+ pageView.put("unallocatedAmountList", unallocatedAmountList);
|
|
|
+ } else {
|
|
|
+ pageView.put("unallocatedAmount", expenseInfo.getUnallocatedNumber());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(expenseInfo.getAgent())) {
|
|
|
+ String str = expenseInfo.getAgent();
|
|
|
+ boolean str1 = str.contains(",");
|
|
|
+ if (str1) {
|
|
|
+ List<String> agentList = Arrays.asList(str.split(","));
|
|
|
+ pageView.put("agentList", agentList);
|
|
|
+ } else {
|
|
|
+ pageView.put("agent", expenseInfo.getAgent());
|
|
|
+ }
|
|
|
+ }
|
|
|
// 查询总数
|
|
|
Integer dataCount = baseMapper.getCountByCondition(pageView);
|
|
|
List<ExpenseInfo> dataList = baseMapper.getListByCondition(pageView);
|
|
@@ -140,17 +235,17 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
|
|
|
taskId = jsonObject.getString("taskId");
|
|
|
expenseInfo1.setTaskId(taskId);
|
|
|
}
|
|
|
- List<ExpenseAllocationInfo> expenseAllocationInfos=expenseAllocationInfoService.selectList(new EntityWrapper<ExpenseAllocationInfo>()
|
|
|
- .eq("info_id",expenseInfo1.getId())
|
|
|
- .eq("status","待确认"));
|
|
|
- if (expenseAllocationInfos.size()>0){
|
|
|
+ List<ExpenseAllocationInfo> expenseAllocationInfos = expenseAllocationInfoService.selectList(new EntityWrapper<ExpenseAllocationInfo>()
|
|
|
+ .eq("info_id", expenseInfo1.getId())
|
|
|
+ .eq("status", "待确认"));
|
|
|
+ if (expenseAllocationInfos.size() > 0) {
|
|
|
expenseInfo1.setDistributionStatus(StatusEnum.TO_BE_CONFIRMED.getName());
|
|
|
expenseInfo1.setExpenseAllocationInfoList(expenseAllocationInfos);
|
|
|
}
|
|
|
- List<ExpenseAllocationInfo> expenseAllocationInfoList=expenseAllocationInfoService.selectList(new EntityWrapper<ExpenseAllocationInfo>()
|
|
|
- .eq("info_id",expenseInfo1.getId())
|
|
|
- .eq("status","已驳回"));
|
|
|
- if (expenseAllocationInfoList.size()>0){
|
|
|
+ List<ExpenseAllocationInfo> expenseAllocationInfoList = expenseAllocationInfoService.selectList(new EntityWrapper<ExpenseAllocationInfo>()
|
|
|
+ .eq("info_id", expenseInfo1.getId())
|
|
|
+ .eq("status", "已驳回"));
|
|
|
+ if (expenseAllocationInfoList.size() > 0) {
|
|
|
expenseInfo1.setExpenseAllocationInfoListBH(expenseAllocationInfoList);
|
|
|
}
|
|
|
});
|
|
@@ -163,15 +258,17 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
|
|
|
page.setSize(expenseInfo.getPageSize());
|
|
|
return page;
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 查看
|
|
|
+ *
|
|
|
* @param id
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
public ExpenseInfo getInfo(String id) {
|
|
|
- ExpenseInfo expenseInfo=this.selectById(id);
|
|
|
- if(expenseInfo.getCreateUserId() != null){
|
|
|
+ ExpenseInfo expenseInfo = this.selectById(id);
|
|
|
+ if (expenseInfo.getCreateUserId() != null) {
|
|
|
CommonStaff commonStaff = staffService.getInfo(expenseInfo.getCreateUserId());
|
|
|
expenseInfo.setCreater(commonStaff.getStaffName());
|
|
|
}
|
|
@@ -181,25 +278,23 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
|
|
|
expenseInfo.setTaskId(taskId);
|
|
|
}
|
|
|
//费用分配列表 查看不显示已驳回的数据
|
|
|
- List<ExpenseAllocationInfo> expenseAllocationInfos=expenseAllocationInfoService.selectList(new EntityWrapper<ExpenseAllocationInfo>()
|
|
|
- .eq("info_id",id)
|
|
|
- .ne("status","已驳回"));
|
|
|
+ List<ExpenseAllocationInfo> expenseAllocationInfos = expenseAllocationInfoService.selectList(new EntityWrapper<ExpenseAllocationInfo>()
|
|
|
+ .eq("info_id", id)
|
|
|
+ .ne("status", "已驳回"));
|
|
|
if (!CollectionUtils.isEmpty(expenseAllocationInfos)) {
|
|
|
expenseInfo.setExpenseAllocationInfoList(expenseAllocationInfos);
|
|
|
}
|
|
|
ContractManagementInfo contractManagementInfo = contractManagementInfoService.selectOne(new EntityWrapper<ContractManagementInfo>()
|
|
|
- .eq("contract_no",expenseInfo.getContractNo()));
|
|
|
- if(contractManagementInfo != null){
|
|
|
+ .eq("contract_no", expenseInfo.getContractNo()));
|
|
|
+ if (contractManagementInfo != null) {
|
|
|
expenseInfo.setJointVentureParties(contractManagementInfo.getJointVentureParties());
|
|
|
- }
|
|
|
- else{
|
|
|
+ } else {
|
|
|
WarehouseBaseInfo warehouseBaseInfo = warehouseBaseInfoService.selectOne(new EntityWrapper<WarehouseBaseInfo>()
|
|
|
- .eq("warehouse_name",expenseInfo.getWarehouseName())
|
|
|
- .eq("comp_id",expenseInfo.getCompId()));
|
|
|
- if(warehouseBaseInfo == null){
|
|
|
+ .eq("warehouse_name", expenseInfo.getWarehouseName())
|
|
|
+ .eq("comp_id", expenseInfo.getCompId()));
|
|
|
+ if (warehouseBaseInfo == null) {
|
|
|
|
|
|
- }
|
|
|
- else{
|
|
|
+ } else {
|
|
|
|
|
|
expenseInfo.setJointVentureParties(warehouseBaseInfo.getJointVentureParties());
|
|
|
}
|
|
@@ -209,11 +304,12 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
|
|
|
|
|
|
/**
|
|
|
* 删除
|
|
|
+ *
|
|
|
* @param id
|
|
|
*/
|
|
|
@Override
|
|
|
public void deleteInfo(String id) {
|
|
|
- ExpenseInfo expenseInfo=this.selectById(id);
|
|
|
+ ExpenseInfo expenseInfo = this.selectById(id);
|
|
|
if (expenseInfo != null) {
|
|
|
this.deleteById(expenseInfo.getId());
|
|
|
// 先删除任务
|
|
@@ -225,7 +321,7 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public String addInfo(ExpenseInfo expenseInfo) {
|
|
|
- Integer flag=0;
|
|
|
+ Integer flag = 0;
|
|
|
expenseInfo.setId(IdGenerator.generateUUID());
|
|
|
SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
Integer num = this.expenseCount(expenseInfo) + 1;
|
|
@@ -257,7 +353,7 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
|
|
|
expenseInfo.setCostNo(no);
|
|
|
|
|
|
//收入
|
|
|
- if ("1".equals(expenseInfo.getExpensesType())){
|
|
|
+ if ("1".equals(expenseInfo.getExpensesType())) {
|
|
|
expenseInfo.setStatusFlag(StatusEnum.TO_BE_CONFIRMED.getFlag());
|
|
|
expenseInfo.setStatus(StatusEnum.TO_BE_CONFIRMED.getName());
|
|
|
this.insert(expenseInfo);
|
|
@@ -267,37 +363,36 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
|
|
|
"收款", null, expenseInfo.getRemark());
|
|
|
}
|
|
|
//支出
|
|
|
- else
|
|
|
- {
|
|
|
+ else {
|
|
|
expenseInfo.setStatusFlag(StatusEnum.COST_PAYMENT.getFlag());
|
|
|
expenseInfo.setStatus(StatusEnum.COST_PAYMENT.getName());
|
|
|
//库点费用未分配金额默认等于费用金额
|
|
|
- if(!"1".equals(expenseInfo.getCostType())&&!"1".equals(expenseInfo.getExpensesPurpose())) {
|
|
|
+ if (!"1".equals(expenseInfo.getCostType()) && !"1".equals(expenseInfo.getExpensesPurpose())) {
|
|
|
expenseInfo.setUnallocatedAmount(expenseInfo.getAmountMoney());
|
|
|
}
|
|
|
//合同粮款校验
|
|
|
- if("1".equals(expenseInfo.getCostType())&&"1".equals(expenseInfo.getExpensesPurpose())) {
|
|
|
- ContractManagementInfo contractManagementInfo=contractManagementInfoService.selectOne(new EntityWrapper<ContractManagementInfo>()
|
|
|
- .eq("contract_no",expenseInfo.getContractNo())
|
|
|
- .eq("comp_id",expenseInfo.getCompId()));
|
|
|
- if(contractManagementInfo!=null){
|
|
|
- if (contractManagementInfo.getUnitContractPrice()!=null){
|
|
|
+ if ("1".equals(expenseInfo.getCostType()) && "1".equals(expenseInfo.getExpensesPurpose())) {
|
|
|
+ ContractManagementInfo contractManagementInfo = contractManagementInfoService.selectOne(new EntityWrapper<ContractManagementInfo>()
|
|
|
+ .eq("contract_no", expenseInfo.getContractNo())
|
|
|
+ .eq("comp_id", expenseInfo.getCompId()));
|
|
|
+ if (contractManagementInfo != null) {
|
|
|
+ if (contractManagementInfo.getUnitContractPrice() != null) {
|
|
|
//合同总粮款
|
|
|
- Double grainFund=contractManagementInfo.getUnitContractPrice()*contractManagementInfo.getWeight();
|
|
|
+ Double grainFund = contractManagementInfo.getUnitContractPrice() * contractManagementInfo.getWeight();
|
|
|
//合同已请粮款金额
|
|
|
- Double money=0d;
|
|
|
+ Double money = 0d;
|
|
|
//合同保证金余额+预付款余额
|
|
|
- money=contractManagementInfo.getAccumulatedPrepayment()-contractManagementInfo.getAccumulatedRecovery()-contractManagementInfo.getPrepaidAssigned()+contractManagementInfo.getAccumulatedMargin()-contractManagementInfo.getWithdrawalOfMargin()-contractManagementInfo.getAllocatedMargin();
|
|
|
- List<ExpenseInfo> expenseInfoList=this.selectList(new EntityWrapper<ExpenseInfo>()
|
|
|
- .eq("contract_no",expenseInfo.getContractNo())
|
|
|
- .ne("status","已驳回")
|
|
|
- .eq("comp_id",expenseInfo.getCompId()));
|
|
|
- if (!CollectionUtils.isEmpty(expenseInfoList)){
|
|
|
- money = money+ expenseInfoList.stream().mapToDouble(ExpenseInfo::getAmountMoney).sum();
|
|
|
+ money = contractManagementInfo.getAccumulatedPrepayment() - contractManagementInfo.getAccumulatedRecovery() - contractManagementInfo.getPrepaidAssigned() + contractManagementInfo.getAccumulatedMargin() - contractManagementInfo.getWithdrawalOfMargin() - contractManagementInfo.getAllocatedMargin();
|
|
|
+ List<ExpenseInfo> expenseInfoList = this.selectList(new EntityWrapper<ExpenseInfo>()
|
|
|
+ .eq("contract_no", expenseInfo.getContractNo())
|
|
|
+ .ne("status", "已驳回")
|
|
|
+ .eq("comp_id", expenseInfo.getCompId()));
|
|
|
+ if (!CollectionUtils.isEmpty(expenseInfoList)) {
|
|
|
+ money = money + expenseInfoList.stream().mapToDouble(ExpenseInfo::getAmountMoney).sum();
|
|
|
}
|
|
|
//本次金额加上已请款金额>总粮款时
|
|
|
- if (money+expenseInfo.getAmountMoney()>grainFund){
|
|
|
- flag=1;
|
|
|
+ if (money + expenseInfo.getAmountMoney() > grainFund) {
|
|
|
+ flag = 1;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -343,7 +438,7 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
|
|
|
workflowService.activateInstance(expenseInfo.getWorkflowId(), expenseInfo.getId());
|
|
|
}
|
|
|
}
|
|
|
- if (flag==1){
|
|
|
+ if (flag == 1) {
|
|
|
return "合同请款金额超出总粮款!";
|
|
|
}
|
|
|
return "ok";
|
|
@@ -352,13 +447,13 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public String editInfo(ExpenseInfo expenseInfo) {
|
|
|
- Integer flag=0;
|
|
|
- ExpenseInfo expenseInfo1=this.selectById(expenseInfo.getId());
|
|
|
+ Integer flag = 0;
|
|
|
+ ExpenseInfo expenseInfo1 = this.selectById(expenseInfo.getId());
|
|
|
//确认收款
|
|
|
if ("0".equals(expenseInfo.getFlag())) {
|
|
|
expenseInfo.setStatusFlag(StatusEnum.COST_RECEIVED.getFlag());
|
|
|
expenseInfo.setStatus(StatusEnum.COST_RECEIVED.getName());
|
|
|
- ContractExpensesInfo contractExpensesInfo=new ContractExpensesInfo();
|
|
|
+ ContractExpensesInfo contractExpensesInfo = new ContractExpensesInfo();
|
|
|
contractExpensesInfo.setCompId(expenseInfo1.getCompId());
|
|
|
contractExpensesInfo.setExpensesType("1");
|
|
|
contractExpensesInfo.setExpensesName(expenseInfo1.getExpenseName());
|
|
@@ -366,30 +461,29 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
|
|
|
contractExpensesInfo.setPayDeadline(new Date());
|
|
|
contractExpensesInfo.setExpensesId(expenseInfo1.getId());
|
|
|
contractExpensesInfo.setExpensesPrice(expenseInfo1.getAmountMoney());
|
|
|
- ContractManagementInfo contractManagementInfo=contractManagementInfoService.selectById(expenseInfo1.getContractId());
|
|
|
+ ContractManagementInfo contractManagementInfo = contractManagementInfoService.selectById(expenseInfo1.getContractId());
|
|
|
//保证金也属于粮款
|
|
|
if ("5".equals(expenseInfo1.getCostType())) {
|
|
|
contractExpensesInfo.setGrainType("1");
|
|
|
//累加合同收回保证金
|
|
|
- contractManagementInfo.setWithdrawalOfMargin(contractManagementInfo.getWithdrawalOfMargin()+expenseInfo1.getAmountMoney());
|
|
|
+ contractManagementInfo.setWithdrawalOfMargin(contractManagementInfo.getWithdrawalOfMargin() + expenseInfo1.getAmountMoney());
|
|
|
}
|
|
|
//粮款
|
|
|
else if ("1".equals(expenseInfo1.getCostType())) {
|
|
|
//累加合同收回预付款
|
|
|
- contractManagementInfo.setAccumulatedRecovery(contractManagementInfo.getAccumulatedRecovery()+expenseInfo1.getAmountMoney());
|
|
|
- }
|
|
|
- else {
|
|
|
+ contractManagementInfo.setAccumulatedRecovery(contractManagementInfo.getAccumulatedRecovery() + expenseInfo1.getAmountMoney());
|
|
|
+ } else {
|
|
|
contractExpensesInfo.setGrainType(expenseInfo1.getCostType());
|
|
|
}
|
|
|
contractManagementInfoService.updateById(contractManagementInfo);
|
|
|
//合同费用
|
|
|
- if ("1".equals(expenseInfo1.getExpensesPurpose())){
|
|
|
+ if ("1".equals(expenseInfo1.getExpensesPurpose())) {
|
|
|
contractExpensesInfo.setContractId(expenseInfo1.getContractId());
|
|
|
contractExpensesInfo.setContractNo(expenseInfo1.getContractNo());
|
|
|
contractExpensesInfo.setCostType("1");
|
|
|
}
|
|
|
//库点费用
|
|
|
- else if ("3".equals(expenseInfo1.getExpensesPurpose())){
|
|
|
+ else if ("3".equals(expenseInfo1.getExpensesPurpose())) {
|
|
|
contractExpensesInfo.setWarehouseId(expenseInfo1.getWarehouseId());
|
|
|
contractExpensesInfo.setWarehouseName(expenseInfo1.getWarehouseName());
|
|
|
contractExpensesInfo.setCostType("3");
|
|
@@ -424,28 +518,28 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
|
|
|
}
|
|
|
}
|
|
|
//完成收款
|
|
|
- else if ("1".equals(expenseInfo.getFlag())){
|
|
|
+ else if ("1".equals(expenseInfo.getFlag())) {
|
|
|
expenseInfo.setStatusFlag(StatusEnum.COMPLETED.getFlag());
|
|
|
expenseInfo.setStatus(StatusEnum.COMPLETED.getName());
|
|
|
}
|
|
|
//确认分配
|
|
|
- else if ("2".equals(expenseInfo.getFlag())){
|
|
|
+ else if ("2".equals(expenseInfo.getFlag())) {
|
|
|
expenseInfo.setDistributionStatusFlag("");
|
|
|
expenseInfo.setDistributionStatus("");
|
|
|
//本次分配总金额
|
|
|
- double totalDistribution=0d;
|
|
|
- List<ExpenseAllocationInfo> expenseAllocationInfos=expenseAllocationInfoService.selectList(new EntityWrapper<ExpenseAllocationInfo>()
|
|
|
- .eq("info_id",expenseInfo.getId())
|
|
|
- .eq("status","待确认"));
|
|
|
- if (!CollectionUtils.isEmpty(expenseAllocationInfos)){
|
|
|
+ double totalDistribution = 0d;
|
|
|
+ List<ExpenseAllocationInfo> expenseAllocationInfos = expenseAllocationInfoService.selectList(new EntityWrapper<ExpenseAllocationInfo>()
|
|
|
+ .eq("info_id", expenseInfo.getId())
|
|
|
+ .eq("status", "待确认"));
|
|
|
+ if (!CollectionUtils.isEmpty(expenseAllocationInfos)) {
|
|
|
totalDistribution = (expenseAllocationInfos.stream().mapToDouble(ExpenseAllocationInfo::getDistributionMoney).sum());
|
|
|
- for (ExpenseAllocationInfo expenseAllocationInfo:expenseAllocationInfos){
|
|
|
+ for (ExpenseAllocationInfo expenseAllocationInfo : expenseAllocationInfos) {
|
|
|
expenseAllocationInfo.setStatusFlag(StatusEnum.COST_ADOPTED.getFlag());
|
|
|
expenseAllocationInfo.setStatus(StatusEnum.COST_ADOPTED.getName());
|
|
|
expenseAllocationInfoService.updateById(expenseAllocationInfo);
|
|
|
- WarehousingOrder warehousingOrder=warehousingOrderService.selectById(expenseAllocationInfo.getOrderId());
|
|
|
+ WarehousingOrder warehousingOrder = warehousingOrderService.selectById(expenseAllocationInfo.getOrderId());
|
|
|
//确认分配时影响入库单成本
|
|
|
- warehousingOrder.setAvgCost((warehousingOrder.getAvgCost()*warehousingOrder.getInWarehouseWeight()+expenseAllocationInfo.getDistributionMoney())/warehousingOrder.getInWarehouseWeight());
|
|
|
+ warehousingOrder.setAvgCost((warehousingOrder.getAvgCost() * warehousingOrder.getInWarehouseWeight() + expenseAllocationInfo.getDistributionMoney()) / warehousingOrder.getInWarehouseWeight());
|
|
|
//库点费用
|
|
|
if ("3".equals(expenseInfo1.getExpensesPurpose())) {
|
|
|
ContractExpensesInfo contractExpensesInfo = new ContractExpensesInfo();
|
|
@@ -462,22 +556,21 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
|
|
|
} else {
|
|
|
contractExpensesInfo.setGrainType(expenseInfo1.getCostType());
|
|
|
}
|
|
|
- if (warehousingOrder!=null&&"采购入库".equals(warehousingOrder.getInType())){
|
|
|
- ContractManagementInfo contractManagementInfo=contractManagementInfoService.selectOne(new EntityWrapper<ContractManagementInfo>()
|
|
|
- .eq("contract_no",warehousingOrder.getContractNo())
|
|
|
- .eq("comp_id",warehousingOrder.getCompId()));
|
|
|
- if (contractManagementInfo!=null){
|
|
|
+ if (warehousingOrder != null && "采购入库".equals(warehousingOrder.getInType())) {
|
|
|
+ ContractManagementInfo contractManagementInfo = contractManagementInfoService.selectOne(new EntityWrapper<ContractManagementInfo>()
|
|
|
+ .eq("contract_no", warehousingOrder.getContractNo())
|
|
|
+ .eq("comp_id", warehousingOrder.getCompId()));
|
|
|
+ if (contractManagementInfo != null) {
|
|
|
contractExpensesInfo.setContractId(contractManagementInfo.getId());
|
|
|
contractExpensesInfo.setContractNo(contractManagementInfo.getContractNo());
|
|
|
contractExpensesInfo.setCostType("1");
|
|
|
contractExpensesInfo.setWarehouseName(expenseInfo1.getWarehouseName());
|
|
|
}
|
|
|
- }
|
|
|
- else if(warehousingOrder!=null&&"收购入库".equals(warehousingOrder.getInType())){
|
|
|
- WarehouseBaseInfo warehouseBaseInfo=warehouseBaseInfoService.selectOne(new EntityWrapper<WarehouseBaseInfo>()
|
|
|
- .eq("warehouse_name",warehousingOrder.getWarehouseName())
|
|
|
- .eq("comp_id",warehousingOrder.getCompId()));
|
|
|
- if (warehouseBaseInfo!=null) {
|
|
|
+ } else if (warehousingOrder != null && "收购入库".equals(warehousingOrder.getInType())) {
|
|
|
+ WarehouseBaseInfo warehouseBaseInfo = warehouseBaseInfoService.selectOne(new EntityWrapper<WarehouseBaseInfo>()
|
|
|
+ .eq("warehouse_name", warehousingOrder.getWarehouseName())
|
|
|
+ .eq("comp_id", warehousingOrder.getCompId()));
|
|
|
+ if (warehouseBaseInfo != null) {
|
|
|
contractExpensesInfo.setWarehouseId(warehouseBaseInfo.getId());
|
|
|
contractExpensesInfo.setWarehouseName(warehouseBaseInfo.getWarehouseName());
|
|
|
contractExpensesInfo.setCostType("3");
|
|
@@ -493,19 +586,18 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
|
|
|
}
|
|
|
}
|
|
|
//编辑分配
|
|
|
- else if ("3".equals(expenseInfo.getFlag())){
|
|
|
+ else if ("3".equals(expenseInfo.getFlag())) {
|
|
|
expenseInfo.setDistributionStatusFlag(StatusEnum.TO_BE_CONFIRMED.getFlag());
|
|
|
expenseInfo.setDistributionStatus(StatusEnum.TO_BE_CONFIRMED.getName());
|
|
|
List<ExpenseAllocationInfo> expenseAllocationInfoList = expenseInfo.getExpenseAllocationInfoList();
|
|
|
if (!CollectionUtils.isEmpty(expenseAllocationInfoList)) {
|
|
|
for (ExpenseAllocationInfo expenseAllocationInfo : expenseAllocationInfoList) {
|
|
|
//有id的编辑
|
|
|
- if (expenseAllocationInfo.getId()!=null) {
|
|
|
+ if (expenseAllocationInfo.getId() != null) {
|
|
|
expenseAllocationInfo.setStatusFlag(StatusEnum.TO_BE_CONFIRMED.getFlag());
|
|
|
expenseAllocationInfo.setStatus(StatusEnum.TO_BE_CONFIRMED.getName());
|
|
|
expenseAllocationInfoService.updateById(expenseAllocationInfo);
|
|
|
- }
|
|
|
- else{
|
|
|
+ } else {
|
|
|
expenseAllocationInfo.setId(IdGenerator.generateUUID());
|
|
|
expenseAllocationInfo.setInfoId(expenseInfo.getId());
|
|
|
expenseAllocationInfo.setStatusFlag(StatusEnum.TO_BE_CONFIRMED.getFlag());
|
|
@@ -516,32 +608,32 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
|
|
|
}
|
|
|
}
|
|
|
//主表编辑 flag==4
|
|
|
- else if ("4".equals(expenseInfo.getFlag())){
|
|
|
+ else if ("4".equals(expenseInfo.getFlag())) {
|
|
|
expenseInfo.setStatusFlag(StatusEnum.COST_RECEIVED.getFlag());
|
|
|
expenseInfo.setStatus(StatusEnum.COST_RECEIVED.getName());
|
|
|
//合同粮款校验
|
|
|
- if("1".equals(expenseInfo1.getCostType())&&"1".equals(expenseInfo1.getExpensesPurpose())) {
|
|
|
- ContractManagementInfo contractManagementInfo=contractManagementInfoService.selectOne(new EntityWrapper<ContractManagementInfo>()
|
|
|
- .eq("contract_no",expenseInfo1.getContractNo())
|
|
|
- .eq("comp_id",expenseInfo1.getCompId()));
|
|
|
- if(contractManagementInfo!=null){
|
|
|
- if (contractManagementInfo.getUnitContractPrice()!=null){
|
|
|
+ if ("1".equals(expenseInfo1.getCostType()) && "1".equals(expenseInfo1.getExpensesPurpose())) {
|
|
|
+ ContractManagementInfo contractManagementInfo = contractManagementInfoService.selectOne(new EntityWrapper<ContractManagementInfo>()
|
|
|
+ .eq("contract_no", expenseInfo1.getContractNo())
|
|
|
+ .eq("comp_id", expenseInfo1.getCompId()));
|
|
|
+ if (contractManagementInfo != null) {
|
|
|
+ if (contractManagementInfo.getUnitContractPrice() != null) {
|
|
|
//合同总粮款
|
|
|
- Double grainFund=contractManagementInfo.getUnitContractPrice()*contractManagementInfo.getWeight();
|
|
|
+ Double grainFund = contractManagementInfo.getUnitContractPrice() * contractManagementInfo.getWeight();
|
|
|
//合同已请粮款金额
|
|
|
- Double money=0d;
|
|
|
+ Double money = 0d;
|
|
|
//合同保证金余额+预付款余额
|
|
|
- money=contractManagementInfo.getAccumulatedPrepayment()-contractManagementInfo.getAccumulatedRecovery()-contractManagementInfo.getPrepaidAssigned()+contractManagementInfo.getAccumulatedMargin()-contractManagementInfo.getWithdrawalOfMargin()-contractManagementInfo.getAllocatedMargin();
|
|
|
- List<ExpenseInfo> expenseInfoList=this.selectList(new EntityWrapper<ExpenseInfo>()
|
|
|
- .eq("contract_no",expenseInfo1.getContractNo())
|
|
|
- .ne("status","已驳回")
|
|
|
- .eq("comp_id",expenseInfo1.getCompId()));
|
|
|
- if (!CollectionUtils.isEmpty(expenseInfoList)){
|
|
|
- money = money+ expenseInfoList.stream().mapToDouble(ExpenseInfo::getAmountMoney).sum();
|
|
|
+ money = contractManagementInfo.getAccumulatedPrepayment() - contractManagementInfo.getAccumulatedRecovery() - contractManagementInfo.getPrepaidAssigned() + contractManagementInfo.getAccumulatedMargin() - contractManagementInfo.getWithdrawalOfMargin() - contractManagementInfo.getAllocatedMargin();
|
|
|
+ List<ExpenseInfo> expenseInfoList = this.selectList(new EntityWrapper<ExpenseInfo>()
|
|
|
+ .eq("contract_no", expenseInfo1.getContractNo())
|
|
|
+ .ne("status", "已驳回")
|
|
|
+ .eq("comp_id", expenseInfo1.getCompId()));
|
|
|
+ if (!CollectionUtils.isEmpty(expenseInfoList)) {
|
|
|
+ money = money + expenseInfoList.stream().mapToDouble(ExpenseInfo::getAmountMoney).sum();
|
|
|
}
|
|
|
//本次金额加上已请款金额>总粮款时
|
|
|
- if (money+expenseInfo.getAmountMoney()>grainFund){
|
|
|
- flag=1;
|
|
|
+ if (money + expenseInfo.getAmountMoney() > grainFund) {
|
|
|
+ flag = 1;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -571,14 +663,14 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
|
|
|
}
|
|
|
}
|
|
|
//驳回分配
|
|
|
- else if ("5".equals(expenseInfo.getFlag())){
|
|
|
+ else if ("5".equals(expenseInfo.getFlag())) {
|
|
|
expenseInfo.setDistributionStatusFlag(StatusEnum.REJECTED.getFlag());
|
|
|
expenseInfo.setDistributionStatus(StatusEnum.REJECTED.getName());
|
|
|
- List<ExpenseAllocationInfo> expenseAllocationInfos=expenseAllocationInfoService.selectList(new EntityWrapper<ExpenseAllocationInfo>()
|
|
|
- .eq("info_id",expenseInfo.getId())
|
|
|
- .eq("status","待确认"));
|
|
|
- if (!CollectionUtils.isEmpty(expenseAllocationInfos)){
|
|
|
- for (ExpenseAllocationInfo expenseAllocationInfo:expenseAllocationInfos){
|
|
|
+ List<ExpenseAllocationInfo> expenseAllocationInfos = expenseAllocationInfoService.selectList(new EntityWrapper<ExpenseAllocationInfo>()
|
|
|
+ .eq("info_id", expenseInfo.getId())
|
|
|
+ .eq("status", "待确认"));
|
|
|
+ if (!CollectionUtils.isEmpty(expenseAllocationInfos)) {
|
|
|
+ for (ExpenseAllocationInfo expenseAllocationInfo : expenseAllocationInfos) {
|
|
|
expenseAllocationInfo.setStatusFlag(StatusEnum.REJECTED.getFlag());
|
|
|
expenseAllocationInfo.setStatus(StatusEnum.REJECTED.getName());
|
|
|
expenseAllocationInfoService.updateById(expenseAllocationInfo);
|
|
@@ -592,7 +684,7 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
|
|
|
}
|
|
|
// 主表信息编辑
|
|
|
this.updateById(expenseInfo);
|
|
|
- if (flag==1) {
|
|
|
+ if (flag == 1) {
|
|
|
return "OK";
|
|
|
}
|
|
|
return "OK";
|
|
@@ -600,6 +692,7 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
|
|
|
|
|
|
/**
|
|
|
* 付款
|
|
|
+ *
|
|
|
* @param expenseInfo
|
|
|
* @return
|
|
|
*/
|
|
@@ -610,7 +703,7 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
|
|
|
expenseInfo.setStatus(StatusEnum.COST_PAID.getName());
|
|
|
expenseInfo.setPaymentDate(new Date());
|
|
|
this.updateById(expenseInfo);
|
|
|
- ExpenseInfo expenseInfo1=this.selectById(expenseInfo.getId());
|
|
|
+ ExpenseInfo expenseInfo1 = this.selectById(expenseInfo.getId());
|
|
|
//合同费用
|
|
|
if ("1".equals(expenseInfo1.getExpensesPurpose())) {
|
|
|
ContractExpensesInfo contractExpensesInfo = new ContractExpensesInfo();
|
|
@@ -621,19 +714,18 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
|
|
|
contractExpensesInfo.setPayDeadline(new Date());
|
|
|
contractExpensesInfo.setExpensesId(expenseInfo1.getId());
|
|
|
contractExpensesInfo.setExpensesPrice(expenseInfo1.getAmountMoney());
|
|
|
- ContractManagementInfo contractManagementInfo=contractManagementInfoService.selectById(expenseInfo1.getContractId());
|
|
|
+ ContractManagementInfo contractManagementInfo = contractManagementInfoService.selectById(expenseInfo1.getContractId());
|
|
|
//保证金也属于粮款
|
|
|
if ("5".equals(expenseInfo1.getCostType())) {
|
|
|
contractExpensesInfo.setGrainType("1");
|
|
|
//累加合同累计保证金
|
|
|
- contractManagementInfo.setAccumulatedMargin(contractManagementInfo.getAccumulatedMargin()+expenseInfo.getAmountMoney());
|
|
|
+ contractManagementInfo.setAccumulatedMargin(contractManagementInfo.getAccumulatedMargin() + expenseInfo.getAmountMoney());
|
|
|
}
|
|
|
//粮款
|
|
|
else if ("1".equals(expenseInfo1.getCostType())) {
|
|
|
//累加合同累计预付款
|
|
|
- contractManagementInfo.setAccumulatedPrepayment(contractManagementInfo.getAccumulatedPrepayment()+expenseInfo.getAmountMoney());
|
|
|
- }
|
|
|
- else {
|
|
|
+ contractManagementInfo.setAccumulatedPrepayment(contractManagementInfo.getAccumulatedPrepayment() + expenseInfo.getAmountMoney());
|
|
|
+ } else {
|
|
|
contractExpensesInfo.setGrainType(expenseInfo1.getCostType());
|
|
|
}
|
|
|
contractManagementInfoService.updateById(contractManagementInfo);
|
|
@@ -652,18 +744,19 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
|
|
|
|
|
|
/**
|
|
|
* 删除分配
|
|
|
+ *
|
|
|
* @param id
|
|
|
*/
|
|
|
@Override
|
|
|
public void deleteAllocationInfo(String id) {
|
|
|
- ExpenseInfo expenseInfo=this.selectById(id);
|
|
|
+ ExpenseInfo expenseInfo = this.selectById(id);
|
|
|
expenseInfo.setDistributionStatusFlag("");
|
|
|
expenseInfo.setDistributionStatus("");
|
|
|
- List<ExpenseAllocationInfo> expenseAllocationInfos=expenseAllocationInfoService.selectList(new EntityWrapper<ExpenseAllocationInfo>()
|
|
|
- .eq("info_id",id)
|
|
|
- .ne("status","已通过"));
|
|
|
- if (!CollectionUtils.isEmpty(expenseAllocationInfos)){
|
|
|
- for (ExpenseAllocationInfo expenseAllocationInfo:expenseAllocationInfos){
|
|
|
+ List<ExpenseAllocationInfo> expenseAllocationInfos = expenseAllocationInfoService.selectList(new EntityWrapper<ExpenseAllocationInfo>()
|
|
|
+ .eq("info_id", id)
|
|
|
+ .ne("status", "已通过"));
|
|
|
+ if (!CollectionUtils.isEmpty(expenseAllocationInfos)) {
|
|
|
+ for (ExpenseAllocationInfo expenseAllocationInfo : expenseAllocationInfos) {
|
|
|
expenseAllocationInfoService.deleteInfo(expenseAllocationInfo.getId());
|
|
|
}
|
|
|
}
|
|
@@ -673,17 +766,18 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
|
|
|
@Override
|
|
|
public List<WarehousingOrder> selectWarehousingOrder(String contractNo, String warehouseName, String receiptDocDate) {
|
|
|
Wrapper<WarehousingOrder> warehousingOrderWrapper = new EntityWrapper<>();
|
|
|
- if (contractNo!=null){
|
|
|
+ if (contractNo != null) {
|
|
|
warehousingOrderWrapper.andNew().eq("contract_no", contractNo).or()
|
|
|
.eq("move_task_no", contractNo);
|
|
|
}
|
|
|
- if (warehouseName!=null){
|
|
|
+ if (warehouseName != null) {
|
|
|
warehousingOrderWrapper.andNew().eq("warehouse_name", warehouseName);
|
|
|
}
|
|
|
- if (receiptDocDate!=null){
|
|
|
+ if (receiptDocDate != null) {
|
|
|
warehousingOrderWrapper.andNew().like("issuing_time", receiptDocDate);
|
|
|
}
|
|
|
- warehousingOrderWrapper.ne("in_type","退库").orderBy("update_date");;
|
|
|
+ warehousingOrderWrapper.ne("in_type", "退库").orderBy("update_date");
|
|
|
+ ;
|
|
|
List<WarehousingOrder> warehousingOrderList = warehousingOrderService.selectList(warehousingOrderWrapper);
|
|
|
return warehousingOrderList;
|
|
|
}
|
|
@@ -691,6 +785,7 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
|
|
|
|
|
|
/**
|
|
|
* 费用管理图表
|
|
|
+ *
|
|
|
* @param compId
|
|
|
* @param year
|
|
|
* @return
|
|
@@ -719,6 +814,7 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
|
|
|
|
|
|
/**
|
|
|
* 费用收支一览表
|
|
|
+ *
|
|
|
* @param compId
|
|
|
* @return
|
|
|
*/
|
|
@@ -953,8 +1049,8 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
|
|
|
|
|
|
// 设置列宽
|
|
|
sheet.setColumnWidth(0, 1 * 256 + 184);
|
|
|
- sheet.setColumnWidth(1, "仓库名称".getBytes().length*3*256);
|
|
|
- sheet.setColumnWidth(2, "日期".getBytes().length*2*256);
|
|
|
+ sheet.setColumnWidth(1, "仓库名称".getBytes().length * 3 * 256);
|
|
|
+ sheet.setColumnWidth(2, "日期".getBytes().length * 2 * 256);
|
|
|
sheet.setColumnWidth(3, 12 * 256 + 184);
|
|
|
sheet.setColumnWidth(4, 12 * 256 + 184);
|
|
|
sheet.setColumnWidth(5, 1 * 256 + 184);
|
|
@@ -991,11 +1087,11 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
|
|
|
|
|
|
|
|
|
// 费用分配总数
|
|
|
- List<ExpenseAllocationInfo> expenseAllocationInfos=expenseAllocationInfoService.selectList(new EntityWrapper<ExpenseAllocationInfo>()
|
|
|
- .eq("info_id",expenseInfo.getId())
|
|
|
- .ne("status","已通过"));
|
|
|
+ List<ExpenseAllocationInfo> expenseAllocationInfos = expenseAllocationInfoService.selectList(new EntityWrapper<ExpenseAllocationInfo>()
|
|
|
+ .eq("info_id", expenseInfo.getId())
|
|
|
+ .ne("status", "已通过"));
|
|
|
|
|
|
- HSSFRow rowp = sheet.createRow((int)(rownum));
|
|
|
+ HSSFRow rowp = sheet.createRow((int) (rownum));
|
|
|
rowp.setHeightInPoints(20);
|
|
|
cell = rowp.createCell(1);
|
|
|
cell.setCellStyle(styleDetail);
|
|
@@ -1088,10 +1184,11 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
|
|
|
}
|
|
|
|
|
|
private String addDateOneDay(Date date) {
|
|
|
- SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
sdf.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
|
|
|
return sdf.format(date);
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 判断字符串
|
|
|
*
|
|
@@ -1102,6 +1199,7 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
|
|
|
String exampleOne = example != null ? example : "";
|
|
|
return exampleOne;
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 判断浮点数
|
|
|
*
|
|
@@ -1112,6 +1210,7 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
|
|
|
Float exampleOne = example != null ? example : 0f;
|
|
|
return exampleOne;
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 判断浮点数
|
|
|
*
|
|
@@ -1179,6 +1278,7 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
|
|
|
}
|
|
|
return "ng";
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 后台通过服务器间接传文件
|
|
|
*
|