|
@@ -1,18 +1,16 @@
|
|
|
package cn.ezhizao.project.business.deduct.controller;
|
|
|
|
|
|
-import java.math.BigDecimal;
|
|
|
-import java.math.RoundingMode;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.stream.Collectors;
|
|
|
-import javax.annotation.Resource;
|
|
|
-import javax.servlet.http.HttpServletResponse;
|
|
|
-
|
|
|
-import cn.ezhizao.common.utils.DateUtils;
|
|
|
+import cn.ezhizao.common.utils.poi.ExcelMultipleSheetsUtil;
|
|
|
+import cn.ezhizao.common.utils.poi.ExcelUtil;
|
|
|
+import cn.ezhizao.framework.aspectj.lang.annotation.Log;
|
|
|
+import cn.ezhizao.framework.aspectj.lang.enums.BusinessType;
|
|
|
+import cn.ezhizao.framework.web.controller.BaseController;
|
|
|
+import cn.ezhizao.framework.web.domain.AjaxResult;
|
|
|
+import cn.ezhizao.framework.web.page.TableDataInfo;
|
|
|
import cn.ezhizao.project.business.company.domain.BizCompany;
|
|
|
import cn.ezhizao.project.business.company.service.IBizCompanyService;
|
|
|
+import cn.ezhizao.project.business.deduct.domain.BizDeduct;
|
|
|
+import cn.ezhizao.project.business.deduct.service.IBizDeductService;
|
|
|
import cn.ezhizao.project.business.deposit.domain.BizDeposit;
|
|
|
import cn.ezhizao.project.business.deposit.service.IBizDepositService;
|
|
|
import cn.ezhizao.project.business.entrust.domain.BizEntrust;
|
|
@@ -27,9 +25,7 @@ import cn.ezhizao.project.business.keepAccounts.domain.BizFinancialKeepAccountDe
|
|
|
import cn.ezhizao.project.business.keepAccounts.service.IBizFinancialKeepAccountDetailService;
|
|
|
import cn.ezhizao.project.business.socialSecurity.domain.BizSocialSecurityConfirmDetail;
|
|
|
import cn.ezhizao.project.business.socialSecurity.service.IBizSocialSecurityConfirmDetailService;
|
|
|
-import cn.ezhizao.project.business.statementAccount.domain.BizStatementAccount;
|
|
|
-import cn.ezhizao.project.business.statementAccount.domain.BizStatementAccountLoop;
|
|
|
-import cn.ezhizao.project.business.statementAccount.domain.BizStatementAccountOnce;
|
|
|
+import cn.ezhizao.project.business.statementAccount.domain.*;
|
|
|
import cn.ezhizao.project.business.statementAccount.service.IBizStatementAccountLoopService;
|
|
|
import cn.ezhizao.project.business.statementAccount.service.IBizStatementAccountOnceService;
|
|
|
import cn.ezhizao.project.business.statementAccount.service.IBizStatementAccountService;
|
|
@@ -45,22 +41,15 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.PutMapping;
|
|
|
-import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
-import org.springframework.web.bind.annotation.PathVariable;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
-import cn.ezhizao.framework.aspectj.lang.annotation.Log;
|
|
|
-import cn.ezhizao.framework.aspectj.lang.enums.BusinessType;
|
|
|
-import cn.ezhizao.project.business.deduct.domain.BizDeduct;
|
|
|
-import cn.ezhizao.project.business.deduct.service.IBizDeductService;
|
|
|
-import cn.ezhizao.framework.web.controller.BaseController;
|
|
|
-import cn.ezhizao.framework.web.domain.AjaxResult;
|
|
|
-import cn.ezhizao.common.utils.poi.ExcelUtil;
|
|
|
-import cn.ezhizao.framework.web.page.TableDataInfo;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 扣款记录Controller
|
|
@@ -132,8 +121,8 @@ public class BizDeductController extends BaseController {
|
|
|
startOrderBy();
|
|
|
List<BizDeduct> list = bizDeductService.getList(bizDeduct);
|
|
|
list.forEach(item -> {
|
|
|
- item.setContactMsg(item.getYear()+"年"+item.getMonth()+"月");
|
|
|
- switch (item.getStatus()){
|
|
|
+ item.setContactMsg(item.getYear() + "年" + item.getMonth() + "月");
|
|
|
+ switch (item.getStatus()) {
|
|
|
case 0:
|
|
|
item.setStatusName("已提交");
|
|
|
break;
|
|
@@ -164,7 +153,7 @@ public class BizDeductController extends BaseController {
|
|
|
BizDeduct deduct = bizDeductService.getList(conditions).stream().findFirst().orElse(null);
|
|
|
if (deduct != null) {
|
|
|
BizEntrustOrder order = bizEntrustOrderService.getById(deduct.getEntrustOrderId());
|
|
|
- if(order==null){
|
|
|
+ if (order == null) {
|
|
|
return error("未查到该委托单号,请检查是否存在,或联系管理员。");
|
|
|
}
|
|
|
deduct.setEntrustOrderStatus(order.getStatus());
|
|
@@ -195,7 +184,8 @@ public class BizDeductController extends BaseController {
|
|
|
BizDeduct bizDeduct = this.abstractVoid(conditions);
|
|
|
return success(bizDeduct);
|
|
|
}
|
|
|
- BizDeduct abstractVoid ( BizDeduct conditions){
|
|
|
+
|
|
|
+ BizDeduct abstractVoid(BizDeduct conditions) {
|
|
|
BizDeduct bizDeduct = new BizDeduct();
|
|
|
bizDeduct.setEntrustOrderId(conditions.getEntrustOrderId());
|
|
|
bizDeduct.setMonth(DateTime.of(conditions.getStartMonth()).toString("MM"));
|
|
@@ -208,7 +198,7 @@ public class BizDeductController extends BaseController {
|
|
|
entrustCondition.setId(conditions.getEntrustOrderId());
|
|
|
BizEntrustOrder bizEntrustOrder = bizEntrustOrderService.getList(entrustCondition).stream().findFirst().orElse(null);
|
|
|
if (bizEntrustOrder == null) {
|
|
|
- new RuntimeException("委托单不存在");
|
|
|
+ new RuntimeException("委托单不存在");
|
|
|
}
|
|
|
// 结算订单号
|
|
|
bizDeduct.setFormNo(bizEntrustOrder.getFormNo());
|
|
@@ -237,8 +227,25 @@ public class BizDeductController extends BaseController {
|
|
|
List<BizEntrust> loopEntrust = entrustService.getList(entrustLoopCondition);
|
|
|
List<BizStatementAccountLoop> loops = new ArrayList<>();
|
|
|
BizFinancialKeepAccountDetail keepAccountCondition = new BizFinancialKeepAccountDetail();
|
|
|
- keepAccountCondition.setStartMonth(DateTime.of(conditions.getStartMonth()).toSqlDate());
|
|
|
- keepAccountCondition.setEndMonth(DateTime.of(conditions.getEndMonth()).toSqlDate());
|
|
|
+ Date startMonth = conditions.getStartMonth();
|
|
|
+ Date endMonth = conditions.getEndMonth();
|
|
|
+ // 创建一个 Calendar 对象,并设置为 startMonth 的时间
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ Calendar calendar2 = Calendar.getInstance();
|
|
|
+ calendar.setTime(startMonth);
|
|
|
+ calendar2.setTime(endMonth);
|
|
|
+ // 将 Calendar 对象的月份减 1
|
|
|
+ calendar.add(Calendar.MONTH, -1);
|
|
|
+ calendar2.add(Calendar.MONTH, -1);
|
|
|
+ // 得到修改后的日期
|
|
|
+ Date oneMonthAgo = calendar.getTime();
|
|
|
+ Date oneMonthAgo2 = calendar2.getTime();
|
|
|
+ // 如果需要将 oneMonthAgo 转换成 java.sql.Date,可以这样做:
|
|
|
+ java.sql.Date sqlDate = new java.sql.Date(oneMonthAgo.getTime());
|
|
|
+ java.sql.Date sqlDate2 = new java.sql.Date(oneMonthAgo2.getTime());
|
|
|
+
|
|
|
+ keepAccountCondition.setStartMonth(sqlDate);
|
|
|
+ keepAccountCondition.setEndMonth(sqlDate2);
|
|
|
List<BizFinancialKeepAccountDetail> keepAccountDetails = keepAccountDetailService.getList(keepAccountCondition);
|
|
|
BizHousingFundConfirmDetail housingFundCondition = new BizHousingFundConfirmDetail();
|
|
|
housingFundCondition.setStartMonth(DateTime.of(conditions.getStartMonth()).toSqlDate());
|
|
@@ -337,9 +344,9 @@ public class BizDeductController extends BaseController {
|
|
|
Map<Long, List<BizCompany>> company = companyService.list(new LambdaQueryWrapper<BizCompany>().eq(BizCompany::getIsZero, 1)).stream().collect(Collectors.groupingBy(BizCompany::getId));
|
|
|
for (BizStatementAccountLoop bizStatementAccountLoop : loops) {
|
|
|
List<BizCompany> bizCompanyList = company.get(bizStatementAccountLoop.getCompanyId());
|
|
|
- if (!CollectionUtils.isEmpty(bizCompanyList)){
|
|
|
+ if (!CollectionUtils.isEmpty(bizCompanyList)) {
|
|
|
bizStatementAccountLoop.setIsZero(bizCompanyList.get(0).getIsZero());
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
bizStatementAccountLoop.setIsZero(0);
|
|
|
}
|
|
|
}
|
|
@@ -357,6 +364,7 @@ public class BizDeductController extends BaseController {
|
|
|
bizDeduct.setRemainAmount(bizDeduct.getPrevRemainAmount().subtract(deduct));
|
|
|
return bizDeduct;
|
|
|
}
|
|
|
+
|
|
|
private List<BizStatementAccount> getStatementAccount(List<BizStatementAccountOnce> onceList, List<BizStatementAccountLoop> loops, BizDeduct bizDeduct) {
|
|
|
List<BizStatementAccount> accounts = new ArrayList<>();
|
|
|
BizEntrustPrice priceCondition = new BizEntrustPrice();
|
|
@@ -692,7 +700,7 @@ public class BizDeductController extends BaseController {
|
|
|
BigDecimal amount = bizDeduct.getAmount();
|
|
|
int index = 0;
|
|
|
while (amount.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
- if(deposits.isEmpty()){
|
|
|
+ if (deposits.isEmpty()) {
|
|
|
return error("扣款失败,余额不足。");
|
|
|
}
|
|
|
BigDecimal money = new BigDecimal(0);
|
|
@@ -700,7 +708,7 @@ public class BizDeductController extends BaseController {
|
|
|
for (BizDeposit d : deposits) {
|
|
|
money = money.add(d.getRemainAmount());
|
|
|
}
|
|
|
- if(money.compareTo(amount)<0){
|
|
|
+ if (money.compareTo(amount) < 0) {
|
|
|
return error("扣款失败,余额不足。");
|
|
|
}
|
|
|
|
|
@@ -742,4 +750,107 @@ public class BizDeductController extends BaseController {
|
|
|
boolean status = bizDeductService.updateById(bizDeduct);
|
|
|
return toAjax(status);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ @Log(title = "合同导出", businessType = BusinessType.EXPORT)
|
|
|
+ @PostMapping("/exportAccountStatement")
|
|
|
+ public void exportAccountStatement(HttpServletResponse response, BizDeduct bizDeduct) throws Exception {
|
|
|
+ BizDeduct bizDeduct1 = this.abstractVoid(bizDeduct);
|
|
|
+ Map<String, Object> result = new LinkedHashMap <>();
|
|
|
+ List<BizStatementAccount> collect = bizDeduct1.getCollect();
|
|
|
+ List<BizStatementAccountLoop> loopList = bizDeduct1.getLoopList();
|
|
|
+ List<BizStatementAccountOnce> onceList = bizDeduct1.getOnceList();
|
|
|
+ List<BizStatementAccountExport> list1 = new ArrayList();
|
|
|
+ List<BizStatementAccountLoopExport> list2 = new ArrayList();
|
|
|
+ List<BizStatementAccountOnceExport> list3 = new ArrayList();
|
|
|
+ if (!collect.isEmpty()) {
|
|
|
+ for (BizStatementAccount bizStatementAccount : collect) {
|
|
|
+ BizStatementAccountExport bizStatementAccountExport = new BizStatementAccountExport();
|
|
|
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM");
|
|
|
+ Date startMonth = bizDeduct.getStartMonth();
|
|
|
+ Date endMonth = bizDeduct.getEndMonth();
|
|
|
+ String yearMonthS = dateFormat.format(startMonth);
|
|
|
+ String yearMonthE = dateFormat.format(endMonth);
|
|
|
+ bizStatementAccountExport.setYearMonth(yearMonthS + "~" + yearMonthE);
|
|
|
+ if (bizStatementAccount.getTaskType().equals("代理记账")) {
|
|
|
+ bizStatementAccountExport.setTaskType(bizStatementAccount.getTaskType());
|
|
|
+ bizStatementAccountExport.setTaskTypeDetail(bizStatementAccount.getAnnualIncome());
|
|
|
+ } else if (bizStatementAccount.getTaskType().equals("社保代缴") ||
|
|
|
+ bizStatementAccount.getTaskType().equals("公积金代缴")) {
|
|
|
+ if (bizStatementAccount.getHaveChanged() == 1) {
|
|
|
+ bizStatementAccountExport.setTaskType(bizStatementAccount.getTaskType() + "有变化");
|
|
|
+ bizStatementAccountExport.setTaskTypeDetail("有变化");
|
|
|
+ } else {
|
|
|
+ bizStatementAccountExport.setTaskType(bizStatementAccount.getTaskType());
|
|
|
+ bizStatementAccountExport.setTaskTypeDetail("无变化");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ bizStatementAccountExport.setTaskType(bizStatementAccount.getTaskType());
|
|
|
+ }
|
|
|
+ bizStatementAccountExport.setCompanyNum(bizStatementAccount.getCompanyNum());
|
|
|
+ bizStatementAccountExport.setPrice(bizStatementAccount.getPrice());
|
|
|
+ bizStatementAccountExport.setAmount(bizStatementAccount.getAmount());
|
|
|
+ bizStatementAccountExport.setDiscountPrice(bizStatementAccount.getDiscountPrice());
|
|
|
+ bizStatementAccountExport.setDiscountAmount(bizStatementAccount.getDiscountAmount());
|
|
|
+ bizStatementAccountExport.setFreeAmount(bizStatementAccount.getFreeAmount());
|
|
|
+ bizStatementAccountExport.setActuallyAmount(bizStatementAccount.getActuallyAmount());
|
|
|
+ bizStatementAccountExport.setDescription(bizDeduct1.getDescription());
|
|
|
+ list1.add(bizStatementAccountExport);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!loopList.isEmpty()) {
|
|
|
+ for (BizStatementAccountLoop bizStatementAccountLoop : loopList) {
|
|
|
+ BizStatementAccountLoopExport bizStatementAccountLoopExport = new BizStatementAccountLoopExport();
|
|
|
+ bizStatementAccountLoopExport.setWorkMonth(bizStatementAccountLoop.getWorkMonth());
|
|
|
+ bizStatementAccountLoopExport.setCompanyName(bizStatementAccountLoop.getCompanyName());
|
|
|
+ bizStatementAccountLoopExport.setSocialCreditCode(bizStatementAccountLoop.getSocialCreditCode());
|
|
|
+ bizStatementAccountLoopExport.setAddress(bizStatementAccountLoop.getProvince() + bizStatementAccountLoop.getCity() + bizStatementAccountLoop.getDistrict());
|
|
|
+ bizStatementAccountLoopExport.setAnnualIncome(bizStatementAccountLoop.getAnnualIncome());
|
|
|
+ bizStatementAccountLoopExport.setIsTax(bizStatementAccountLoop.getIsTax() == 1 ? "是" : "否");
|
|
|
+ bizStatementAccountLoopExport.setIsSocialSecurity(bizStatementAccountLoop.getIsSocialSecurity() == 1 ? "是" : "否");
|
|
|
+ bizStatementAccountLoopExport.setIsHousingFund(bizStatementAccountLoop.getIsHousingFund() == 1 ? "是" : "否");
|
|
|
+ bizStatementAccountLoopExport.setTaxType(bizStatementAccountLoop.getTaxType());
|
|
|
+ bizStatementAccountLoopExport.setCollectionMethod(bizStatementAccountLoop.getCollectionMethod());
|
|
|
+ bizStatementAccountLoopExport.setIsZero(bizStatementAccountLoop.getIsZero() == 1 ? "是" : "否");
|
|
|
+ bizStatementAccountLoopExport.setActuallyAnnualIncome(bizStatementAccountLoop.getActuallyAnnualIncome());
|
|
|
+ bizStatementAccountLoopExport.setChangedSocialSecurity(bizStatementAccountLoop.getChangedSocialSecurity() == 1 ? "是" : "否");
|
|
|
+ bizStatementAccountLoopExport.setChangedHousingFund(bizStatementAccountLoop.getChangedHousingFund() == 1 ? "是" : "否");
|
|
|
+ bizStatementAccountLoopExport.setCumulativeIncome(bizStatementAccountLoop.getCumulativeIncome());
|
|
|
+ list2.add(bizStatementAccountLoopExport);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!onceList.isEmpty()) {
|
|
|
+ for (BizStatementAccountOnce bizStatementAccountOnce : onceList) {
|
|
|
+ BizStatementAccountOnceExport bizStatementAccountOnceExport = new BizStatementAccountOnceExport();
|
|
|
+ bizStatementAccountOnceExport.setCompanyName(bizStatementAccountOnce.getCompanyName());
|
|
|
+ bizStatementAccountOnceExport.setAddress(bizStatementAccountOnce.getProvince() + bizStatementAccountOnce.getCity() + bizStatementAccountOnce.getDistrict());
|
|
|
+ bizStatementAccountOnceExport.setTask(bizStatementAccountOnce.getTaskTypeName() + bizStatementAccountOnce.getTaskTypeDetailName());
|
|
|
+ bizStatementAccountOnceExport.setEntrustDate(bizStatementAccountOnce.getEntrustDate());
|
|
|
+ bizStatementAccountOnceExport.setFinishedDate(bizStatementAccountOnce.getFinishedDate());
|
|
|
+ bizStatementAccountOnceExport.setAmount(bizStatementAccountOnce.getAmount());
|
|
|
+ bizStatementAccountOnceExport.setDescription(bizStatementAccountOnce.getDescription());
|
|
|
+ list3.add(bizStatementAccountOnceExport);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ BizStatementAccountOnceExport bizStatementAccountOnceExport = new BizStatementAccountOnceExport();
|
|
|
+ bizStatementAccountOnceExport.setCompanyName(null);
|
|
|
+ bizStatementAccountOnceExport.setAddress(null);
|
|
|
+ bizStatementAccountOnceExport.setTask(null);
|
|
|
+ bizStatementAccountOnceExport.setEntrustDate(null);
|
|
|
+ bizStatementAccountOnceExport.setFinishedDate(null);
|
|
|
+ bizStatementAccountOnceExport.setAmount(null);
|
|
|
+ bizStatementAccountOnceExport.setDescription(null);
|
|
|
+ list3.add(bizStatementAccountOnceExport);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ result.put("汇总", list1);
|
|
|
+ result.put("循环任务", list2);
|
|
|
+ result.put("工商任务", list3);
|
|
|
+ String contactCompany = "(" + bizDeduct1.getContactCompany() + "-" + bizDeduct1.getFormNo() + ")";
|
|
|
+
|
|
|
+ ExcelMultipleSheetsUtil.excelMultipleSheets(result, "对账单导出" + contactCompany, ".xlsx", response);
|
|
|
+ }
|
|
|
+
|
|
|
}
|