Compare commits
6 Commits
e53b5715e2
...
acf2a9976f
| Author | SHA1 | Date | |
|---|---|---|---|
| acf2a9976f | |||
| e5615a0068 | |||
| e366c682a2 | |||
| 624ccfb50a | |||
| 8fe015cda7 | |||
| e5850ebf64 |
@@ -0,0 +1,18 @@
|
|||||||
|
package com.seeyon.apps.src_leasebill.config;
|
||||||
|
|
||||||
|
import com.seeyon.aicloud.common.JsonUtils;
|
||||||
|
import com.seeyon.apps.src_leasebill.constant.LeaseBillConstant;
|
||||||
|
import com.seeyon.ctp.common.AppContext;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class FieldDisplayNameQueryService {
|
||||||
|
|
||||||
|
private LeaseBillConfigProvider configProvider = (LeaseBillConfigProvider) AppContext.getBean("leaseBillConfigProvider");
|
||||||
|
|
||||||
|
public String getDisplayName(String fieldName) {
|
||||||
|
String jsonStr = configProvider.getBizConfigByKey(LeaseBillConstant.fieldDisplayMap);
|
||||||
|
Map<String,String> map = (Map<String,String>)JsonUtils.parseObject(jsonStr, Map.class);
|
||||||
|
return map.get(fieldName);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,7 +7,10 @@ public enum LeaseBillConstant {
|
|||||||
annualPaymentTypeOneMapName("年方案一","年缴费方式一取值映射名称"),
|
annualPaymentTypeOneMapName("年方案一","年缴费方式一取值映射名称"),
|
||||||
annualPaymentTypeTwoMapName("年方案二","年缴费方式二取值映射名称"),
|
annualPaymentTypeTwoMapName("年方案二","年缴费方式二取值映射名称"),
|
||||||
assistiveFormNo("ZJZDMX","账单生成辅助表表单编码"),
|
assistiveFormNo("ZJZDMX","账单生成辅助表表单编码"),
|
||||||
loginName("shenxian","辅助表创建人");
|
loginName("shenxian","辅助表创建人"),
|
||||||
|
billAssistiveTableName("账单生成辅助表","账单生成辅助表明细表名称"),
|
||||||
|
fieldDisplayMap("","字段显示名称映射"),
|
||||||
|
;
|
||||||
// u8cUrl("http://ip:port", "U8C地址"),
|
// u8cUrl("http://ip:port", "U8C地址"),
|
||||||
|
|
||||||
LeaseBillConstant(String defaultValue, String description) {
|
LeaseBillConstant(String defaultValue, String description) {
|
||||||
@@ -0,0 +1,261 @@
|
|||||||
|
package com.seeyon.apps.src_leasebill.controller;
|
||||||
|
|
||||||
|
import cn.hutool.log.Log;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.seeyon.apps.common.config.ICstConfigApi;
|
||||||
|
import com.seeyon.apps.common.plugin.vo.ConfigVo;
|
||||||
|
import com.seeyon.apps.src_leasebill.config.FieldDisplayNameQueryService;
|
||||||
|
import com.seeyon.apps.src_leasebill.config.LeaseBillConfigProvider;
|
||||||
|
import com.seeyon.apps.src_leasebill.constant.LeaseBillConstant;
|
||||||
|
import com.seeyon.apps.src_leasebill.dao.ILeaseBillDao;
|
||||||
|
import com.seeyon.apps.src_leasebill.util.DateUtil;
|
||||||
|
import com.seeyon.apps.src_leasebill.util.FormExportUtil;
|
||||||
|
import com.seeyon.apps.src_leasebill.util.LeaseBillUtil;
|
||||||
|
import com.seeyon.ctp.common.AppContext;
|
||||||
|
import com.seeyon.ctp.common.controller.BaseController;
|
||||||
|
import com.seeyon.ctp.util.json.JSONUtil;
|
||||||
|
import com.seeyon.v3x.services.form.FormFactory;
|
||||||
|
import com.seeyon.v3x.services.form.bean.FormExport;
|
||||||
|
import com.seeyon.v3x.services.form.bean.SubordinateFormExport;
|
||||||
|
import com.seeyon.v3x.services.form.bean.ValueExport;
|
||||||
|
import nc.vo.jcom.lang.StringUtil;
|
||||||
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URLDecoder;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 租金账单控制器
|
||||||
|
* 功能:接收前端参数 → 调用账单工具类生成账单 → 保存至表单
|
||||||
|
*/
|
||||||
|
public class LeaseBillController extends BaseController {
|
||||||
|
|
||||||
|
private static final Log log = Log.get(LeaseBillController.class);
|
||||||
|
|
||||||
|
/** 配置提供者 */
|
||||||
|
private final LeaseBillConfigProvider configProvider =
|
||||||
|
(LeaseBillConfigProvider) AppContext.getBean("leaseBillConfigProvider");
|
||||||
|
|
||||||
|
/** 配置API */
|
||||||
|
protected final ICstConfigApi cstConfigApi =
|
||||||
|
(ICstConfigApi) AppContext.getBean("cstConfigApi");
|
||||||
|
|
||||||
|
/** 字段名称查询服务 */
|
||||||
|
private final FieldDisplayNameQueryService fieldDisplayNameQueryService =
|
||||||
|
(FieldDisplayNameQueryService) AppContext.getBean("fieldDisplayNameQueryService");
|
||||||
|
|
||||||
|
/** 表单工厂 */
|
||||||
|
private FormFactory formFactory;
|
||||||
|
|
||||||
|
/** 账单DAO */
|
||||||
|
private ILeaseBillDao leaseBillDao;
|
||||||
|
|
||||||
|
// ======================== 注入 ========================
|
||||||
|
public FormFactory getFormFactory() {
|
||||||
|
if (formFactory == null) {
|
||||||
|
formFactory = (FormFactory) AppContext.getBean("formFactory");
|
||||||
|
}
|
||||||
|
return formFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFormFactory(FormFactory formFactory) {
|
||||||
|
this.formFactory = formFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ILeaseBillDao getLeaseBillDao() {
|
||||||
|
if (leaseBillDao == null) {
|
||||||
|
leaseBillDao = (ILeaseBillDao) AppContext.getBean("leaseBillDao");
|
||||||
|
}
|
||||||
|
return leaseBillDao;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLeaseBillDao(ILeaseBillDao leaseBillDao) {
|
||||||
|
this.leaseBillDao = leaseBillDao;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ======================== 主入口:生成账单 ========================
|
||||||
|
public ModelAndView index(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||||
|
log.info("====== 进入生成账单Ajax方法 ======");
|
||||||
|
|
||||||
|
ConfigVo configVo = getYdctLeaseBillConfig();
|
||||||
|
DateUtil dateUtil = new DateUtil();
|
||||||
|
LeaseBillUtil leaseBillUtil = new LeaseBillUtil();
|
||||||
|
FormExportUtil formExportUtil = new FormExportUtil();
|
||||||
|
|
||||||
|
// 返回结果
|
||||||
|
Map<String, Object> res = new HashMap<>();
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
SimpleDateFormat sdfNo = new SimpleDateFormat("yyyyMMddHHmmsssss");
|
||||||
|
|
||||||
|
request.setCharacterEncoding("UTF-8");
|
||||||
|
response.setCharacterEncoding("UTF-8");
|
||||||
|
|
||||||
|
// ===================== 1. 读取请求体参数 =====================
|
||||||
|
BufferedReader reader = request.getReader();
|
||||||
|
StringBuilder requestBody = new StringBuilder();
|
||||||
|
String line;
|
||||||
|
while ((line = reader.readLine()) != null) {
|
||||||
|
requestBody.append(line);
|
||||||
|
}
|
||||||
|
|
||||||
|
String data = requestBody.toString();
|
||||||
|
String decodedParam = URLDecoder.decode(data, "UTF-8");
|
||||||
|
String[] datas = decodedParam.split("&");
|
||||||
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
for (String paramStr : datas) {
|
||||||
|
String[] params = paramStr.split("=");
|
||||||
|
if (params.length > 1) {
|
||||||
|
jsonObject.put(params[0], params[1]);
|
||||||
|
} else if (params[0].equals("bdid")) {
|
||||||
|
jsonObject.put("bdid", "0");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("前端入参:{}", jsonObject.toString());
|
||||||
|
try {
|
||||||
|
// ===================== 2. 账单编号处理 =====================
|
||||||
|
String bdidValue = jsonObject.getString("bdid");
|
||||||
|
log.info("当前账单编号:{}", bdidValue);
|
||||||
|
|
||||||
|
String code = bdidValue;
|
||||||
|
if ("0".equals(bdidValue)) {
|
||||||
|
// 编号为0 → 新建编号
|
||||||
|
code = sdfNo.format(new Date());
|
||||||
|
log.info("生成新账单编号:{}", code);
|
||||||
|
} else {
|
||||||
|
// 已有编号 → 删除旧数据
|
||||||
|
log.info("删除旧账单数据,编号:{}", bdidValue);
|
||||||
|
List<String> ids = getLeaseBillDao().leaseBillByCode(bdidValue);
|
||||||
|
for (String id : ids) {
|
||||||
|
getLeaseBillDao().deleteBillsByBillId(id);
|
||||||
|
getLeaseBillDao().deleteBillById(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===================== 3. 租赁起止时间 =====================
|
||||||
|
String startDateStr = jsonObject.getString("startDate");
|
||||||
|
String endDateStr = jsonObject.getString("endDate");
|
||||||
|
Date startDate = sdf.parse(startDateStr);
|
||||||
|
Date endDate = sdf.parse(endDateStr);
|
||||||
|
|
||||||
|
// 开始时间
|
||||||
|
Calendar startTime = Calendar.getInstance();
|
||||||
|
startTime.setTime(startDate);
|
||||||
|
|
||||||
|
// 判断是否为月底
|
||||||
|
boolean isMaxDay = false;
|
||||||
|
int currentDay = startTime.get(Calendar.DAY_OF_MONTH);
|
||||||
|
int maxDay = startTime.getActualMaximum(Calendar.DAY_OF_MONTH);
|
||||||
|
if (currentDay == maxDay) {
|
||||||
|
isMaxDay = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 结束时间(+1天,左闭右开)
|
||||||
|
Calendar endTime = Calendar.getInstance();
|
||||||
|
endTime.setTime(endDate);
|
||||||
|
endTime.add(Calendar.DAY_OF_MONTH, 1);
|
||||||
|
|
||||||
|
// ===================== 4. 缴费方式 =====================
|
||||||
|
String jiaofeifs = jsonObject.getString("jiaofeifs");
|
||||||
|
int jfzqNum = dateUtil.getCycleNum(jiaofeifs);
|
||||||
|
String jifeifs = jsonObject.getString("jifeifs");
|
||||||
|
|
||||||
|
log.info("缴费方式:{},周期月数:{},计费方式:{}", jiaofeifs, jfzqNum, jifeifs);
|
||||||
|
|
||||||
|
// ===================== 5. 生成账单 =====================
|
||||||
|
List<Map<String, String>> rents = new ArrayList<>();
|
||||||
|
FormExport formExport = new FormExport();
|
||||||
|
|
||||||
|
if (jfzqNum == 12) {
|
||||||
|
// 年缴 → 判断年缴计算方式
|
||||||
|
String njiaofeifs = jsonObject.getString("njiaofeifs");
|
||||||
|
if (StringUtil.isEmpty(njiaofeifs)) {
|
||||||
|
res.put("success", true);
|
||||||
|
res.put("name", AppContext.currentUserLoginName());
|
||||||
|
res.put("s", "请选择年缴费计算方式");
|
||||||
|
res.put("num", "");
|
||||||
|
render(response, JSONUtil.toJSONString(res));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
String type1 = configProvider.getBizConfigByKey(LeaseBillConstant.annualPaymentTypeOneMapName);
|
||||||
|
String type2 = configProvider.getBizConfigByKey(LeaseBillConstant.annualPaymentTypeTwoMapName);
|
||||||
|
|
||||||
|
if (njiaofeifs.equals(type1)) {
|
||||||
|
log.info("【年缴方式1】按周期年度生成账单");
|
||||||
|
rents = leaseBillUtil.getLeaseBillYear1(startTime, endTime, isMaxDay, jfzqNum, jsonObject, jifeifs);
|
||||||
|
} else if (njiaofeifs.equals(type2)) {
|
||||||
|
log.info("【年缴方式2】按自然年度生成账单");
|
||||||
|
rents = leaseBillUtil.getLeaseBillYear2(startTime, endTime, isMaxDay, jfzqNum, jsonObject, jifeifs);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 月/季/半年/一次性
|
||||||
|
log.info("【标准方式】生成账单");
|
||||||
|
rents = leaseBillUtil.getLeaseBill(startTime, endTime, isMaxDay, jfzqNum, jsonObject, jifeifs);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rents.isEmpty()) {
|
||||||
|
log.info("====== 账单数据为空,无需生成 ======");
|
||||||
|
} else {
|
||||||
|
log.info("====== 共生成 {} 期账单 ======", rents.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===================== 6. 保存到表单 =====================
|
||||||
|
log.info("====== 开始保存账单到表单 ======");
|
||||||
|
List<SubordinateFormExport> detailList = formExportUtil.setSubordinateFormValue(rents);
|
||||||
|
|
||||||
|
Map<String, String> mainData = new HashMap<>();
|
||||||
|
mainData.put(fieldDisplayNameQueryService.getDisplayName("账单编号"), code);
|
||||||
|
|
||||||
|
List<ValueExport> mainFields = formExportUtil.setFormValue(mainData);
|
||||||
|
|
||||||
|
formExport.setSubordinateForms(detailList);
|
||||||
|
formExport.setValues(mainFields);
|
||||||
|
|
||||||
|
String loginName = configProvider.getBizConfigByKey(LeaseBillConstant.loginName);
|
||||||
|
String formNo = configProvider.getBizConfigByKey(LeaseBillConstant.assistiveFormNo);
|
||||||
|
|
||||||
|
getFormFactory().importBusinessFormData(loginName, formNo, formExport, new String[]{});
|
||||||
|
|
||||||
|
// ===================== 7. 返回结果 =====================
|
||||||
|
res.put("success", true);
|
||||||
|
res.put("name", AppContext.currentUserLoginName());
|
||||||
|
res.put("s", "");
|
||||||
|
res.put("num", code);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("生成账单异常", e);
|
||||||
|
e.printStackTrace();
|
||||||
|
res.put("success", false);
|
||||||
|
res.put("s", "生成账单失败:" + e.getMessage());
|
||||||
|
}
|
||||||
|
render(response, JSONUtil.toJSONString(res));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ======================== 输出JSON ========================
|
||||||
|
private void render(HttpServletResponse response, String text) {
|
||||||
|
response.setContentType("application/json;charset=UTF-8");
|
||||||
|
try {
|
||||||
|
response.getWriter().write(text);
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error("输出JSON异常", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ======================== 配置 ========================
|
||||||
|
|
||||||
|
public ConfigVo getYdctLeaseBillConfig() {
|
||||||
|
return cstConfigApi.getConfig(getPluginId());
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPluginId() {
|
||||||
|
return LeaseBillConstant.getPluginId();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.seeyon.apps.src_leasebill.dao.impl;
|
package com.seeyon.apps.src_leasebill.dao.impl;
|
||||||
|
|
||||||
|
import com.seeyon.apps.src_leasebill.config.FieldDisplayNameQueryService;
|
||||||
import com.seeyon.apps.src_leasebill.config.LeaseBillConfigProvider;
|
import com.seeyon.apps.src_leasebill.config.LeaseBillConfigProvider;
|
||||||
import com.seeyon.apps.src_leasebill.constant.LeaseBillConstant;
|
import com.seeyon.apps.src_leasebill.constant.LeaseBillConstant;
|
||||||
import com.seeyon.apps.src_leasebill.dao.ILeaseBillDao;
|
import com.seeyon.apps.src_leasebill.dao.ILeaseBillDao;
|
||||||
@@ -14,21 +15,36 @@ import java.sql.SQLException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 租金账单DAO实现类
|
||||||
|
* 功能:查询、删除账单主表和明细表数据
|
||||||
|
*/
|
||||||
public class LeaseBillDaoImpl implements ILeaseBillDao {
|
public class LeaseBillDaoImpl implements ILeaseBillDao {
|
||||||
|
|
||||||
private LeaseBillConfigProvider configProvider = (LeaseBillConfigProvider) AppContext.getBean("leaseBillConfigProvider");
|
/** 配置提供者 */
|
||||||
|
private final LeaseBillConfigProvider configProvider =
|
||||||
|
(LeaseBillConfigProvider) AppContext.getBean("leaseBillConfigProvider");
|
||||||
|
|
||||||
|
/** 字段名称查询服务 */
|
||||||
|
private final FieldDisplayNameQueryService fieldDisplayNameQueryService =
|
||||||
|
(FieldDisplayNameQueryService) AppContext.getBean("fieldDisplayNameQueryService");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取表单编号
|
||||||
|
*/
|
||||||
private String getFormNo() {
|
private String getFormNo() {
|
||||||
return configProvider.getBizConfigByKey(LeaseBillConstant.assistiveFormNo);
|
return configProvider.getBizConfigByKey(LeaseBillConstant.assistiveFormNo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据账单编号查询账单ID列表
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<String> leaseBillByCode(String code) throws BusinessException, SQLException {
|
public List<String> leaseBillByCode(String code) throws BusinessException, SQLException {
|
||||||
List<String> lists = new ArrayList<String>();
|
List<String> lists = new ArrayList<String>();
|
||||||
TableContext tableContext = FormTableExecutor.master(getFormNo());
|
TableContext tableContext = FormTableExecutor.master(getFormNo());
|
||||||
List<FormWhereCondition> conditions = new ArrayList<FormWhereCondition>();
|
List<FormWhereCondition> conditions = new ArrayList<FormWhereCondition>();
|
||||||
conditions.add(FormWhereCondition.build().display("账单编号").value(code));
|
conditions.add(FormWhereCondition.build().display(fieldDisplayNameQueryService.getDisplayName("账单编号")).value(code));
|
||||||
List<String> queryColumns = new ArrayList<String>();
|
List<String> queryColumns = new ArrayList<String>();
|
||||||
queryColumns.add("ID");
|
queryColumns.add("ID");
|
||||||
List<FormColumn> formColumns = FormTableExecutor.query(tableContext, queryColumns, conditions, false);
|
List<FormColumn> formColumns = FormTableExecutor.query(tableContext, queryColumns, conditions, false);
|
||||||
@@ -38,6 +54,9 @@ public class LeaseBillDaoImpl implements ILeaseBillDao {
|
|||||||
return lists;
|
return lists;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据ID删除账单主表数据
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int deleteBillById(String id) throws BusinessException, SQLException {
|
public int deleteBillById(String id) throws BusinessException, SQLException {
|
||||||
TableContext tableContext = FormTableExecutor.master(getFormNo());
|
TableContext tableContext = FormTableExecutor.master(getFormNo());
|
||||||
@@ -46,9 +65,13 @@ public class LeaseBillDaoImpl implements ILeaseBillDao {
|
|||||||
return FormTableExecutor.delete(tableContext, conditions);
|
return FormTableExecutor.delete(tableContext, conditions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据主表ID删除账单明细表数据
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int deleteBillsByBillId(String formmainId) throws BusinessException, SQLException {
|
public int deleteBillsByBillId(String formmainId) throws BusinessException, SQLException {
|
||||||
TableContext sub = FormTableExecutor.sub(getFormNo(), "账单明细");
|
String tableName = configProvider.getBizConfigByKey(LeaseBillConstant.billAssistiveTableName);
|
||||||
|
TableContext sub = FormTableExecutor.sub(getFormNo(), tableName);
|
||||||
List<FormWhereCondition> conditions = new ArrayList<>();
|
List<FormWhereCondition> conditions = new ArrayList<>();
|
||||||
conditions.add(FormWhereCondition.build().display("formmain_id").value(formmainId));
|
conditions.add(FormWhereCondition.build().display("formmain_id").value(formmainId));
|
||||||
return FormTableExecutor.delete(sub, conditions);
|
return FormTableExecutor.delete(sub, conditions);
|
||||||
@@ -0,0 +1,306 @@
|
|||||||
|
package com.seeyon.apps.src_leasebill.util;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.seeyon.apps.src_leasebill.config.FieldDisplayNameQueryService;
|
||||||
|
import com.seeyon.ctp.common.AppContext;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 租金账单生成工具类
|
||||||
|
* 功能:根据租赁周期、缴费方式、计费方式,自动拆分生成多期租金账单
|
||||||
|
*/
|
||||||
|
public class LeaseBillUtil {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字段名称查询服务(用于获取表单显示名称)
|
||||||
|
*/
|
||||||
|
private final FieldDisplayNameQueryService fieldDisplayNameService =
|
||||||
|
(FieldDisplayNameQueryService) AppContext.getBean("fieldDisplayNameQueryService");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 日期格式化工具:yyyy-MM-dd
|
||||||
|
*/
|
||||||
|
private final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 日期工具类实例
|
||||||
|
*/
|
||||||
|
private final DateUtil dateUtil = new DateUtil();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 金额精度:保留2位小数
|
||||||
|
*/
|
||||||
|
private static final int MONEY_SCALE = 2;
|
||||||
|
|
||||||
|
// ======================== 【1】主方法:生成租金账单(支持一次性/周期) ========================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成租金账单(对外主方法)
|
||||||
|
*
|
||||||
|
* @param startTime 租赁开始时间
|
||||||
|
* @param endTime 租赁结束时间
|
||||||
|
* @param isMonthLastDay 是否每月最后一天
|
||||||
|
* @param payCycleMonths 缴费周期(月):1=月缴,3=季度缴,6=半年缴,12=年缴,99=一次性
|
||||||
|
* @param params 表单参数JSON
|
||||||
|
* @param chargeType 计费方式:面积计费 / 固定租金
|
||||||
|
* @return 每期账单集合(开始日期、结束日期、租费)
|
||||||
|
*/
|
||||||
|
public List<Map<String, String>> getLeaseBill(Calendar startTime, Calendar endTime, boolean isMonthLastDay,
|
||||||
|
int payCycleMonths, JSONObject params, String chargeType) {
|
||||||
|
// ====================== 控制台打印:生成账单入参 ======================
|
||||||
|
System.out.println("======================================");
|
||||||
|
System.out.println("【主方法】生成账单参数开始");
|
||||||
|
System.out.println("租赁开始时间:" + sdf.format(startTime.getTime()));
|
||||||
|
System.out.println("租赁结束时间:" + sdf.format(endTime.getTime()));
|
||||||
|
System.out.println("是否每月最后一天:" + isMonthLastDay);
|
||||||
|
System.out.println("缴费周期(月):" + payCycleMonths);
|
||||||
|
System.out.println("计费方式:" + chargeType);
|
||||||
|
System.out.println("表单参数:" + params.toString());
|
||||||
|
System.out.println("【主方法】生成账单参数结束");
|
||||||
|
System.out.println("======================================");
|
||||||
|
|
||||||
|
List<Map<String, String>> billList = new ArrayList<>();
|
||||||
|
int totalLeaseMonths = dateUtil.betweenMonthByTwoCalendar(startTime, endTime);
|
||||||
|
|
||||||
|
// 一次性缴费
|
||||||
|
if (payCycleMonths == 99) {
|
||||||
|
Map<String, String> bill = createOneTimeBill(startTime, endTime, totalLeaseMonths, params, chargeType);
|
||||||
|
billList.add(bill);
|
||||||
|
return billList;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 周期缴费:月/季/半年
|
||||||
|
return createCycleBills(startTime, endTime, isMonthLastDay, payCycleMonths, params, chargeType);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ======================== 【2】按年周期账单(版本1) ========================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按年生成账单(版本1:按周期月数计算)
|
||||||
|
*/
|
||||||
|
public List<Map<String, String>> getLeaseBillYear1(Calendar startTime, Calendar endTime, boolean isMonthLastDay,
|
||||||
|
int payCycleMonths, JSONObject params, String chargeType) {
|
||||||
|
// ====================== 控制台打印:生成账单入参 ======================
|
||||||
|
System.out.println("======================================");
|
||||||
|
System.out.println("【按年方法1】生成账单参数开始");
|
||||||
|
System.out.println("租赁开始时间:" + sdf.format(startTime.getTime()));
|
||||||
|
System.out.println("租赁结束时间:" + sdf.format(endTime.getTime()));
|
||||||
|
System.out.println("是否每月最后一天:" + isMonthLastDay);
|
||||||
|
System.out.println("缴费周期(月):" + payCycleMonths);
|
||||||
|
System.out.println("计费方式:" + chargeType);
|
||||||
|
System.out.println("表单参数:" + params.toString());
|
||||||
|
System.out.println("【按年方法1】生成账单参数结束");
|
||||||
|
System.out.println("======================================");
|
||||||
|
|
||||||
|
return createCycleBills(startTime, endTime, isMonthLastDay, payCycleMonths, params, chargeType);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ======================== 【3】按自然年切割账单(版本2) ========================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按自然年生成账单(版本2:按自然年12.31切割)
|
||||||
|
*/
|
||||||
|
public List<Map<String, String>> getLeaseBillYear2(Calendar startTime, Calendar endTime, boolean isMonthLastDay,
|
||||||
|
int payCycleMonths, JSONObject params, String chargeType) {
|
||||||
|
// ====================== 控制台打印:生成账单入参 ======================
|
||||||
|
System.out.println("======================================");
|
||||||
|
System.out.println("【按年方法2】生成账单参数开始");
|
||||||
|
System.out.println("租赁开始时间:" + sdf.format(startTime.getTime()));
|
||||||
|
System.out.println("租赁结束时间:" + sdf.format(endTime.getTime()));
|
||||||
|
System.out.println("是否每月最后一天:" + isMonthLastDay);
|
||||||
|
System.out.println("缴费周期(月):" + payCycleMonths);
|
||||||
|
System.out.println("计费方式:" + chargeType);
|
||||||
|
System.out.println("表单参数:" + params.toString());
|
||||||
|
System.out.println("【按年方法2】生成账单参数结束");
|
||||||
|
System.out.println("======================================");
|
||||||
|
|
||||||
|
List<Map<String, String>> billList = new ArrayList<>();
|
||||||
|
int startYear = startTime.get(Calendar.YEAR);
|
||||||
|
int endYear = endTime.get(Calendar.YEAR);
|
||||||
|
int totalYears = endYear - startYear + 1;
|
||||||
|
|
||||||
|
Calendar tempStart = (Calendar) startTime.clone();
|
||||||
|
Calendar yearBaseCal = (Calendar) tempStart.clone();
|
||||||
|
|
||||||
|
for (int i = 0; i < totalYears; i++) {
|
||||||
|
if (!tempStart.before(endTime)) break;
|
||||||
|
|
||||||
|
Map<String, String> bill = new HashMap<>();
|
||||||
|
bill.put(fieldDisplayNameService.getDisplayName("开始日期"), sdf.format(tempStart.getTime()));
|
||||||
|
|
||||||
|
// 设置为当年最后一天:12月31日
|
||||||
|
tempStart.set(Calendar.MONTH, 11);
|
||||||
|
tempStart.set(Calendar.DATE, 31);
|
||||||
|
|
||||||
|
if (tempStart.before(endTime)) {
|
||||||
|
// 当前年度在结束时间之前 → 完整年度账单
|
||||||
|
Calendar nextYearStart = (Calendar) tempStart.clone();
|
||||||
|
nextYearStart.add(Calendar.DATE, 1);
|
||||||
|
|
||||||
|
int monthCount = dateUtil.betweenMonthByTwoCalendar(yearBaseCal, nextYearStart);
|
||||||
|
String rent = calculateRent(monthCount, params, chargeType);
|
||||||
|
|
||||||
|
bill.put(fieldDisplayNameService.getDisplayName("租费"), rent);
|
||||||
|
bill.put(fieldDisplayNameService.getDisplayName("结束日期"), sdf.format(tempStart.getTime()));
|
||||||
|
|
||||||
|
yearBaseCal = (Calendar) tempStart.clone();
|
||||||
|
} else {
|
||||||
|
// 最后一个年度 → 不足一年
|
||||||
|
int monthCount = dateUtil.betweenMonthByTwoCalendar(yearBaseCal, endTime);
|
||||||
|
String rent = calculateRent(monthCount, params, chargeType);
|
||||||
|
|
||||||
|
Calendar realEnd = (Calendar) endTime.clone();
|
||||||
|
realEnd.add(Calendar.DATE, -1);
|
||||||
|
|
||||||
|
bill.put(fieldDisplayNameService.getDisplayName("租费"), rent);
|
||||||
|
bill.put(fieldDisplayNameService.getDisplayName("结束日期"), sdf.format(realEnd.getTime()));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 下一期开始时间 = 当前结束时间 + 1天
|
||||||
|
tempStart.add(Calendar.DATE, 1);
|
||||||
|
|
||||||
|
// 如果是月末模式,设置为当月最后一天
|
||||||
|
if (isMonthLastDay) {
|
||||||
|
tempStart.set(Calendar.DATE, tempStart.getActualMaximum(Calendar.DATE));
|
||||||
|
}
|
||||||
|
|
||||||
|
billList.add(bill);
|
||||||
|
}
|
||||||
|
|
||||||
|
return billList;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ======================== 【核心工具方法】 ========================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建一次性缴费账单
|
||||||
|
*/
|
||||||
|
private Map<String, String> createOneTimeBill(Calendar startTime, Calendar endTime, int totalMonths,
|
||||||
|
JSONObject params, String chargeType) {
|
||||||
|
Map<String, String> bill = new HashMap<>();
|
||||||
|
String rent = calculateRent(totalMonths, params, chargeType);
|
||||||
|
|
||||||
|
bill.put(fieldDisplayNameService.getDisplayName("开始日期"), sdf.format(startTime.getTime()));
|
||||||
|
|
||||||
|
// 结束时间 = 原结束时间 -1天
|
||||||
|
Calendar realEnd = (Calendar) endTime.clone();
|
||||||
|
realEnd.add(Calendar.DATE, -1);
|
||||||
|
bill.put(fieldDisplayNameService.getDisplayName("结束日期"), sdf.format(realEnd.getTime()));
|
||||||
|
|
||||||
|
bill.put(fieldDisplayNameService.getDisplayName("租费"), rent);
|
||||||
|
return bill;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建周期缴费账单(月缴/季度/半年/年缴)
|
||||||
|
*/
|
||||||
|
private List<Map<String, String>> createCycleBills(Calendar startTime, Calendar endTime, boolean isMonthLastDay,
|
||||||
|
int payCycleMonths, JSONObject params, String chargeType) {
|
||||||
|
List<Map<String, String>> billList = new ArrayList<>();
|
||||||
|
int totalLeaseMonths = dateUtil.betweenMonthByTwoCalendar(startTime, endTime);
|
||||||
|
|
||||||
|
// 计算总缴费期数:向上取整
|
||||||
|
int periodCount = totalLeaseMonths / payCycleMonths;
|
||||||
|
if (totalLeaseMonths % payCycleMonths != 0) {
|
||||||
|
periodCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
Calendar tempStart = (Calendar) startTime.clone();
|
||||||
|
|
||||||
|
// 循环生成每一期账单
|
||||||
|
for (int i = 0; i < periodCount; i++) {
|
||||||
|
if (!tempStart.before(endTime)) break;
|
||||||
|
|
||||||
|
Map<String, String> bill = new HashMap<>();
|
||||||
|
bill.put(fieldDisplayNameService.getDisplayName("开始日期"), sdf.format(tempStart.getTime()));
|
||||||
|
|
||||||
|
// 计算本期结束日 = 开始时间 + 周期月数 - 1天
|
||||||
|
Calendar periodEnd = (Calendar) tempStart.clone();
|
||||||
|
periodEnd.add(Calendar.MONTH, payCycleMonths);
|
||||||
|
periodEnd.add(Calendar.DATE, -1);
|
||||||
|
|
||||||
|
if (periodEnd.before(endTime)) {
|
||||||
|
// 正常完整周期
|
||||||
|
String rent = calculateRent(payCycleMonths, params, chargeType);
|
||||||
|
bill.put(fieldDisplayNameService.getDisplayName("租费"), rent);
|
||||||
|
bill.put(fieldDisplayNameService.getDisplayName("结束日期"), sdf.format(periodEnd.getTime()));
|
||||||
|
} else {
|
||||||
|
// 最后一期:不足一个缴费周期
|
||||||
|
int realMonths = dateUtil.betweenMonthByTwoCalendar(tempStart, endTime);
|
||||||
|
String rent = calculateRent(realMonths, params, chargeType);
|
||||||
|
|
||||||
|
Calendar realEnd = (Calendar) endTime.clone();
|
||||||
|
realEnd.add(Calendar.DATE, -1);
|
||||||
|
|
||||||
|
bill.put(fieldDisplayNameService.getDisplayName("租费"), rent);
|
||||||
|
bill.put(fieldDisplayNameService.getDisplayName("结束日期"), sdf.format(realEnd.getTime()));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 下一期开始时间
|
||||||
|
tempStart = (Calendar) periodEnd.clone();
|
||||||
|
tempStart.add(Calendar.DATE, 1);
|
||||||
|
|
||||||
|
// 月末规则处理
|
||||||
|
if (isMonthLastDay) {
|
||||||
|
tempStart.set(Calendar.DATE, tempStart.getActualMaximum(Calendar.DATE));
|
||||||
|
}
|
||||||
|
|
||||||
|
billList.add(bill);
|
||||||
|
}
|
||||||
|
|
||||||
|
return billList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统一租金计算逻辑(抽离重复代码)
|
||||||
|
*
|
||||||
|
* @param months 计费月数
|
||||||
|
* @param params 表单参数
|
||||||
|
* @param chargeType 计费方式
|
||||||
|
* @return 计算后租金金额(保留2位小数)
|
||||||
|
*/
|
||||||
|
private String calculateRent(int months, JSONObject params, String chargeType) {
|
||||||
|
BigDecimal rent = BigDecimal.ZERO;
|
||||||
|
boolean isAreaCharge = "面积计费".equals(chargeType);
|
||||||
|
boolean isFixedRent = "固定租金".equals(chargeType);
|
||||||
|
|
||||||
|
if (isAreaCharge) {
|
||||||
|
// 面积计费:租金 = 面积 × 每平单价
|
||||||
|
BigDecimal area = parseBigDecimal(params.getString("mj"));
|
||||||
|
BigDecimal pricePerArea = parseBigDecimal(params.getString("mjzj"));
|
||||||
|
rent = area.multiply(pricePerArea);
|
||||||
|
} else if (isFixedRent) {
|
||||||
|
// 固定租金:直接取固定金额
|
||||||
|
rent = parseBigDecimal(params.getString("gdzj"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 固定租金不乘月数,其他计费方式 × 月数
|
||||||
|
if (!isFixedRent) {
|
||||||
|
rent = rent.multiply(new BigDecimal(months));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 保留2位小数,四舍五入
|
||||||
|
return rent.setScale(MONEY_SCALE, RoundingMode.HALF_UP).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将字符串解析为BigDecimal,处理逗号分隔符
|
||||||
|
*
|
||||||
|
* @param str 数字字符串(可能包含逗号分隔符)
|
||||||
|
* @return BigDecimal对象
|
||||||
|
*/
|
||||||
|
private BigDecimal parseBigDecimal(String str) {
|
||||||
|
if (str == null || str.trim().isEmpty()) {
|
||||||
|
return BigDecimal.ZERO;
|
||||||
|
}
|
||||||
|
// 移除逗号分隔符
|
||||||
|
String cleanStr = str.replace(",", "").trim();
|
||||||
|
return new BigDecimal(cleanStr);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,4 +2,5 @@
|
|||||||
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
|
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
|
||||||
<beans default-autowire="byName">
|
<beans default-autowire="byName">
|
||||||
<bean id="leaseBillDao" class="com.seeyon.apps.src_leasebill.dao.impl.LeaseBillDaoImpl" />
|
<bean id="leaseBillDao" class="com.seeyon.apps.src_leasebill.dao.impl.LeaseBillDaoImpl" />
|
||||||
|
<bean id="fieldDisplayNameQueryService" class="com.seeyon.apps.src_leasebill.config.FieldDisplayNameQueryService" />
|
||||||
</beans>
|
</beans>
|
||||||
|
Before Width: | Height: | Size: 101 KiB After Width: | Height: | Size: 101 KiB |
@@ -1,299 +0,0 @@
|
|||||||
package com.seeyon.apps.src_leasebill.controller;
|
|
||||||
|
|
||||||
import cn.hutool.log.Log;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.seeyon.aicloud.common.JsonUtils;
|
|
||||||
import com.seeyon.apps.common.config.ICstConfigApi;
|
|
||||||
import com.seeyon.apps.common.plugin.vo.ConfigVo;
|
|
||||||
import com.seeyon.apps.src_leasebill.config.LeaseBillConfigProvider;
|
|
||||||
import com.seeyon.apps.src_leasebill.constant.LeaseBillConstant;
|
|
||||||
import com.seeyon.apps.src_leasebill.dao.ILeaseBillDao;
|
|
||||||
import com.seeyon.apps.src_leasebill.util.DateUtil;
|
|
||||||
import com.seeyon.apps.src_leasebill.util.FormExportUtil;
|
|
||||||
import com.seeyon.apps.src_leasebill.util.LeaseBillUtil;
|
|
||||||
import com.seeyon.ctp.common.AppContext;
|
|
||||||
import com.seeyon.ctp.common.controller.BaseController;
|
|
||||||
import com.seeyon.ctp.util.json.JSONUtil;
|
|
||||||
import com.seeyon.v3x.services.form.FormFactory;
|
|
||||||
import com.seeyon.v3x.services.form.bean.FormExport;
|
|
||||||
import com.seeyon.v3x.services.form.bean.SubordinateFormExport;
|
|
||||||
import com.seeyon.v3x.services.form.bean.ValueExport;
|
|
||||||
import nc.vo.jcom.lang.StringUtil;
|
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URLDecoder;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
public class LeaseBillController extends BaseController {
|
|
||||||
|
|
||||||
private static Log log = Log.get(LeaseBillController.class);
|
|
||||||
private LeaseBillConfigProvider configProvider = (LeaseBillConfigProvider) AppContext.getBean("leaseBillConfigProvider");
|
|
||||||
protected ICstConfigApi cstConfigApi = (ICstConfigApi) AppContext.getBean("cstConfigApi");
|
|
||||||
|
|
||||||
private FormFactory formFactory;
|
|
||||||
|
|
||||||
public FormFactory getFormFactory() {
|
|
||||||
if (formFactory == null) {
|
|
||||||
formFactory = (FormFactory) AppContext.getBean("formFactory");
|
|
||||||
}
|
|
||||||
return formFactory;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFormFactory(FormFactory formFactory) {
|
|
||||||
this.formFactory = formFactory;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ILeaseBillDao leaseBillDao;
|
|
||||||
|
|
||||||
public void setLeaseBillDao(ILeaseBillDao leaseBillDao) {
|
|
||||||
this.leaseBillDao = leaseBillDao;
|
|
||||||
}
|
|
||||||
public ILeaseBillDao getLeaseBillDao() {
|
|
||||||
if (leaseBillDao == null) {
|
|
||||||
leaseBillDao = (ILeaseBillDao) AppContext.getBean("leaseBillDao");
|
|
||||||
}
|
|
||||||
return leaseBillDao;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ModelAndView index(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
|
||||||
System.out.println("进入生成账单ajax方法");
|
|
||||||
|
|
||||||
ConfigVo configVo = getYdctLeaseBillConfig();
|
|
||||||
DateUtil dateUtil = new DateUtil();
|
|
||||||
LeaseBillUtil leaseBillUtil = new LeaseBillUtil();
|
|
||||||
FormExportUtil formExportUtil = new FormExportUtil();
|
|
||||||
|
|
||||||
Map<String, Object> res = new HashMap<>();
|
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
||||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmsssss");
|
|
||||||
|
|
||||||
request.setCharacterEncoding("UTF-8");
|
|
||||||
response.setCharacterEncoding("UTF-8");
|
|
||||||
|
|
||||||
// 读取请求体
|
|
||||||
String requestBody = getRequestBody(request);
|
|
||||||
if (requestBody == null || requestBody.isEmpty()) {
|
|
||||||
System.out.println("【错误】请求体为空,直接返回默认结果");
|
|
||||||
render(response, JSONObject.toJSONString(res));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 解析参数
|
|
||||||
JSONObject jsonObject = parseRequestParams(requestBody);
|
|
||||||
if (jsonObject == null || jsonObject.isEmpty()) {
|
|
||||||
System.out.println("【错误】解析后请求参数为空,返回默认结果");
|
|
||||||
render(response, JSONObject.toJSONString(res));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
System.out.println("入参: " + jsonObject.toString());
|
|
||||||
|
|
||||||
try {
|
|
||||||
// 账单编号
|
|
||||||
String bdidValue = jsonObject.getString("bdid");
|
|
||||||
if (bdidValue == null || bdidValue.trim().isEmpty()) {
|
|
||||||
bdidValue = "0";
|
|
||||||
}
|
|
||||||
System.out.println("当前账单编号为:" + bdidValue);
|
|
||||||
|
|
||||||
String code;
|
|
||||||
if ("0".equals(bdidValue)) {
|
|
||||||
code = simpleDateFormat.format(new Date());
|
|
||||||
System.out.println("自动生成新账单编号:" + code);
|
|
||||||
} else {
|
|
||||||
code = bdidValue;
|
|
||||||
List<String> ids = leaseBillDao.leaseBillByCode(bdidValue);
|
|
||||||
if (ids == null || ids.isEmpty()) {
|
|
||||||
System.out.println("根据账单编号[" + bdidValue + "]未查询到需要删除的旧数据");
|
|
||||||
} else {
|
|
||||||
for (String id : ids) {
|
|
||||||
leaseBillDao.deleteBillsByBillId(id);
|
|
||||||
leaseBillDao.deleteBillById(id);
|
|
||||||
}
|
|
||||||
System.out.println("账单编号[" + bdidValue + "]旧数据删除完成");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 日期
|
|
||||||
String startDateStr = jsonObject.getString("startDate");
|
|
||||||
String endDateStr = jsonObject.getString("endDate");
|
|
||||||
if (startDateStr == null || startDateStr.isEmpty() || endDateStr == null || endDateStr.isEmpty()) {
|
|
||||||
System.out.println("【错误】开始日期或结束日期为空,生成账单失败");
|
|
||||||
res.put("success", false);
|
|
||||||
res.put("s", "开始日期/结束日期不能为空");
|
|
||||||
render(response, JSONObject.toJSONString(res));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
Date startDate = sdf.parse(startDateStr);
|
|
||||||
Date endDate = sdf.parse(endDateStr);
|
|
||||||
|
|
||||||
// 计费面积
|
|
||||||
String jifeifs = jsonObject.getString("jifeifs");
|
|
||||||
if (jifeifs == null || jifeifs.isEmpty()) {
|
|
||||||
System.out.println("【错误】计费面积为空,生成账单失败");
|
|
||||||
res.put("success", false);
|
|
||||||
res.put("s", "计费面积不能为空");
|
|
||||||
render(response, JSONObject.toJSONString(res));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 日期处理
|
|
||||||
Calendar startTime = Calendar.getInstance();
|
|
||||||
startTime.setTime(startDate);
|
|
||||||
boolean isMaxDay = startTime.get(Calendar.DAY_OF_MONTH) == startTime.getActualMaximum(Calendar.DAY_OF_MONTH);
|
|
||||||
|
|
||||||
Calendar endTime = Calendar.getInstance();
|
|
||||||
endTime.setTime(endDate);
|
|
||||||
endTime.add(Calendar.DAY_OF_MONTH, 1);
|
|
||||||
|
|
||||||
// 缴费方式
|
|
||||||
String jiaofeifs = jsonObject.getString("jiaofeifs");
|
|
||||||
int jfzqNum = dateUtil.getCycleNum(jiaofeifs);
|
|
||||||
|
|
||||||
List<Map<String, String>> rents = new ArrayList<>();
|
|
||||||
if (jfzqNum == 12) {
|
|
||||||
String njiaofeifs = jsonObject.getString("njiaofeifs");
|
|
||||||
if (StringUtil.isEmpty(njiaofeifs)) {
|
|
||||||
System.out.println("【错误】年缴费计算方式未选择,终止生成");
|
|
||||||
res.put("success", true);
|
|
||||||
res.put("name", AppContext.currentUserLoginName());
|
|
||||||
res.put("s", "请选择年缴费计算方式");
|
|
||||||
res.put("num", "");
|
|
||||||
render(response, JSONObject.toJSONString(res));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
String type1 = configProvider.getBizConfigByKey(LeaseBillConstant.annualPaymentTypeOneMapName);
|
|
||||||
String type2 = configProvider.getBizConfigByKey(LeaseBillConstant.annualPaymentTypeTwoMapName);
|
|
||||||
if (njiaofeifs.equals(type1)) {
|
|
||||||
System.out.println("正常年度-生成账单数据");
|
|
||||||
rents = leaseBillUtil.getLeaseBillYers1(startTime, endTime, isMaxDay, jfzqNum, jsonObject, jifeifs);
|
|
||||||
} else if (njiaofeifs.equals(type2)) {
|
|
||||||
System.out.println("非正常年度-生成账单数据");
|
|
||||||
rents = leaseBillUtil.getLeaseBillYers2(startTime, endTime, isMaxDay, jfzqNum, jsonObject, jifeifs);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
System.out.println("标准方式生成账单数据");
|
|
||||||
rents = leaseBillUtil.getLeaseBill(startTime, endTime, isMaxDay, jfzqNum, jsonObject, jifeifs);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 租金为空判断
|
|
||||||
if (rents == null || rents.isEmpty()) {
|
|
||||||
System.out.println("【错误】生成账单数据为空,无法继续导入");
|
|
||||||
res.put("success", false);
|
|
||||||
res.put("s", "生成账单明细为空");
|
|
||||||
render(response, JSONObject.toJSONString(res));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 创建档案
|
|
||||||
System.out.println("开始创建档案,账单编号:" + code);
|
|
||||||
List<SubordinateFormExport> subordinateList = formExportUtil.setSubordinateFormValue(rents);
|
|
||||||
|
|
||||||
Map<String, String> billMap = new HashMap<>();
|
|
||||||
billMap.put("账单编号", code);
|
|
||||||
List<ValueExport> valueExports = formExportUtil.setFormValue(billMap);
|
|
||||||
|
|
||||||
FormExport formExport = new FormExport();
|
|
||||||
formExport.setSubordinateForms(subordinateList);
|
|
||||||
formExport.setValues(valueExports);
|
|
||||||
|
|
||||||
String loginName = configProvider.getBizConfigByKey(LeaseBillConstant.loginName);
|
|
||||||
String formNo = configProvider.getBizConfigByKey(LeaseBillConstant.assistiveFormNo);
|
|
||||||
|
|
||||||
getFormFactory().importBusinessFormData(loginName, formNo, formExport, new String[]{});
|
|
||||||
System.out.println("账单[" + code + "]导入表单数据成功");
|
|
||||||
|
|
||||||
// 成功返回
|
|
||||||
res.put("success", true);
|
|
||||||
res.put("name", AppContext.currentUserLoginName());
|
|
||||||
res.put("s", "");
|
|
||||||
res.put("num", code);
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
System.out.println("【异常】生成账单发生异常:" + e.getMessage());
|
|
||||||
e.printStackTrace();
|
|
||||||
res.put("success", false);
|
|
||||||
res.put("s", "系统异常");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 最终 res 为空判断
|
|
||||||
if (res == null || res.isEmpty()) {
|
|
||||||
System.out.println("【严重】最终返回结果 res 为空,返回空JSON");
|
|
||||||
render(response, "{}");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
System.out.println("生成账单完成,返回结果:" + res);
|
|
||||||
render(response, JSONObject.toJSONString(res));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 读取请求体
|
|
||||||
private String getRequestBody(HttpServletRequest request) {
|
|
||||||
BufferedReader reader = null;
|
|
||||||
try {
|
|
||||||
reader = request.getReader();
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
String line;
|
|
||||||
while ((line = reader.readLine()) != null) {
|
|
||||||
sb.append(line);
|
|
||||||
}
|
|
||||||
return sb.toString();
|
|
||||||
} catch (Exception e) {
|
|
||||||
System.out.println("【错误】读取请求体异常");
|
|
||||||
e.printStackTrace();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 解析请求参数
|
|
||||||
private JSONObject parseRequestParams(String requestBody) {
|
|
||||||
JSONObject json = new JSONObject();
|
|
||||||
try {
|
|
||||||
String decoded = URLDecoder.decode(requestBody, "UTF-8");
|
|
||||||
String[] paramsArray = decoded.split("&");
|
|
||||||
for (String param : paramsArray) {
|
|
||||||
String[] kv = param.split("=", 2);
|
|
||||||
if (kv.length == 2) {
|
|
||||||
json.put(kv[0], kv[1]);
|
|
||||||
} else if ("bdid".equals(kv[0])) {
|
|
||||||
json.put("bdid", "0");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
System.out.println("【错误】解析请求参数异常");
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return json;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 给前台渲染json数据
|
|
||||||
* @param response
|
|
||||||
* @param text
|
|
||||||
*/
|
|
||||||
private void render(HttpServletResponse response, String text) {
|
|
||||||
response.setContentType("application/json;charset=UTF-8");
|
|
||||||
try {
|
|
||||||
response.setContentLength(text.getBytes("UTF-8").length);
|
|
||||||
response.getWriter().write(text);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public ConfigVo getYdctLeaseBillConfig() {
|
|
||||||
return cstConfigApi.getConfig(getPluginId());
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPluginId() {
|
|
||||||
return LeaseBillConstant.getPluginId();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,280 +0,0 @@
|
|||||||
package com.seeyon.apps.src_leasebill.util;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
public class LeaseBillUtil {
|
|
||||||
|
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生成租金账单
|
|
||||||
* @param startTime 开始时间
|
|
||||||
* @param endTime 结束时间
|
|
||||||
* @param isMaxDay 是否每月最后一天
|
|
||||||
* @param jfzqNum 缴费周期月
|
|
||||||
* @param jsonObject 请求参数
|
|
||||||
* @param jifeifs 计费方式
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public List<Map<String,String>> getLeaseBill(Calendar startTime, Calendar endTime, boolean isMaxDay, int jfzqNum,
|
|
||||||
JSONObject jsonObject,String jifeifs){
|
|
||||||
List<Map<String,String>> rents = new ArrayList<>();
|
|
||||||
System.out.println("生成账单的参数: " + startTime + ","+ endTime+"," + isMaxDay+"," + jfzqNum +","+ jsonObject.toString() +","+ jifeifs);
|
|
||||||
DateUtil dateUtil = new DateUtil();
|
|
||||||
// 两个日期相差多少月
|
|
||||||
int monthNum = dateUtil.betweenMonthByTwoCalendar(startTime,endTime);
|
|
||||||
if(jfzqNum==99){
|
|
||||||
// 一次性账单生成
|
|
||||||
Map<String,String> rent = new HashMap<>();
|
|
||||||
float zlmjFloat = 0;
|
|
||||||
double zf = 0;
|
|
||||||
if("面积计费".equals(jifeifs)){
|
|
||||||
String mjStr = jsonObject.getString("mj");
|
|
||||||
zlmjFloat = Float.parseFloat(mjStr);
|
|
||||||
String mjzjStr = jsonObject.getString("mjzj");
|
|
||||||
double mjzj = dateUtil.stringToNum(mjzjStr);
|
|
||||||
zf = mjzj*zlmjFloat*monthNum;
|
|
||||||
}else if ("固定租金".equals(jifeifs)){
|
|
||||||
zlmjFloat = 1;
|
|
||||||
String gdzjStr = jsonObject.getString("gdzj");
|
|
||||||
double gdzj = dateUtil.stringToNum(gdzjStr);
|
|
||||||
// zf = gdzj*zlmjFloat*monthNum;
|
|
||||||
zf = gdzj*zlmjFloat;
|
|
||||||
}
|
|
||||||
rent.put("明细-开始日期",sdf.format(startTime.getTime()));
|
|
||||||
endTime.add(Calendar.DATE, -1);
|
|
||||||
rent.put("明细-结束日期",sdf.format(endTime.getTime()));
|
|
||||||
rent.put("明细-租费",zf+"");
|
|
||||||
rents.add(rent);
|
|
||||||
}else{
|
|
||||||
// 月,季,半年,账单生成
|
|
||||||
int termNum = monthNum/jfzqNum;
|
|
||||||
int mo = monthNum%jfzqNum;
|
|
||||||
if(mo!=0){
|
|
||||||
termNum++;
|
|
||||||
}
|
|
||||||
float zlmjFloat = 0;
|
|
||||||
double zf = 0;
|
|
||||||
if("面积计费".equals(jifeifs)){
|
|
||||||
String mjStr = jsonObject.getString("mj");
|
|
||||||
zlmjFloat = Float.parseFloat(mjStr);
|
|
||||||
String mjzjStr = jsonObject.getString("mjzj");
|
|
||||||
double mjzj = dateUtil.stringToNum(mjzjStr);
|
|
||||||
zf = mjzj*zlmjFloat;
|
|
||||||
}else if ("固定租金".equals(jifeifs)){
|
|
||||||
zlmjFloat = 1;
|
|
||||||
String gdzjStr = jsonObject.getString("gdzj");
|
|
||||||
double gdzj = dateUtil.stringToNum(gdzjStr);
|
|
||||||
zf = gdzj*zlmjFloat;
|
|
||||||
}
|
|
||||||
for(int i = 0 ; i < termNum ; i ++) {
|
|
||||||
if (startTime.getTime().getTime() < endTime.getTime().getTime()) {
|
|
||||||
Map<String, String> rentMap = new HashMap<String, String>();
|
|
||||||
// 设置租费时间
|
|
||||||
rentMap.put("明细-开始日期", sdf.format(startTime.getTime()));
|
|
||||||
if (!isMaxDay) {
|
|
||||||
startTime.add(Calendar.MONTH, jfzqNum);
|
|
||||||
startTime.add(Calendar.DAY_OF_MONTH, -1);
|
|
||||||
}else{
|
|
||||||
startTime.add(Calendar.MONTH, jfzqNum);
|
|
||||||
startTime.set(Calendar.DAY_OF_MONTH, startTime.getActualMaximum(Calendar.DAY_OF_MONTH)-1);
|
|
||||||
}
|
|
||||||
if (startTime.getTime().getTime() < endTime.getTime().getTime()) {
|
|
||||||
// rentMap.put("期间月数-租金",jfzqNum+"");
|
|
||||||
// rentMap.put("租费", (zf * jfzqNum) + "");
|
|
||||||
if("面积计费".equals(jifeifs)){
|
|
||||||
rentMap.put("租费", (zf * jfzqNum) + "");
|
|
||||||
}else if ("固定租金".equals(jifeifs)){
|
|
||||||
rentMap.put("明细-租费", (zf * 1) + "");
|
|
||||||
}
|
|
||||||
rentMap.put("明细-结束日期", sdf.format(startTime.getTime()));
|
|
||||||
} else {
|
|
||||||
//两个日期相差多少月
|
|
||||||
startTime.add(Calendar.MONTH, jfzqNum*-1);
|
|
||||||
startTime.add(Calendar.DAY_OF_MONTH, 1);
|
|
||||||
int qijianyueshu = dateUtil.betweenMonthByTwoCalendar(startTime, endTime);
|
|
||||||
// rentMap.put("期间月数-租金",qijianyueshu+"");
|
|
||||||
if("面积计费".equals(jifeifs)){
|
|
||||||
rentMap.put("明细-租费", (zf * qijianyueshu) + "");
|
|
||||||
}else if ("明细-固定租金".equals(jifeifs)){
|
|
||||||
rentMap.put("明细-租费", (zf * 1) + "");
|
|
||||||
}
|
|
||||||
|
|
||||||
endTime.add(Calendar.DAY_OF_MONTH, -1);
|
|
||||||
rentMap.put("明细-结束日期", sdf.format(endTime.getTime()));
|
|
||||||
}
|
|
||||||
startTime.add(Calendar.DAY_OF_MONTH, 1);
|
|
||||||
if (isMaxDay) {
|
|
||||||
startTime.set(Calendar.DAY_OF_MONTH, startTime.getActualMaximum(Calendar.DAY_OF_MONTH));
|
|
||||||
}
|
|
||||||
rents.add(rentMap);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return rents;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生成租金账单
|
|
||||||
* @param startTime 开始时间
|
|
||||||
* @param endTime 结束时间
|
|
||||||
* @param isMaxDay 是否每月最后一天
|
|
||||||
* @param jfzqNum 缴费周期月
|
|
||||||
* @param jsonObject 请求参数
|
|
||||||
* @param jifeifs 计费方式
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public List<Map<String,String>> getLeaseBillYers1(Calendar startTime, Calendar endTime, boolean isMaxDay, int jfzqNum,
|
|
||||||
JSONObject jsonObject,String jifeifs){
|
|
||||||
System.out.println("生成账单的参数: " + startTime + ","+ endTime+"," + isMaxDay+"," + jfzqNum +","+ jsonObject.toString() +","+ jifeifs);
|
|
||||||
List<Map<String,String>> rents = new ArrayList<>();
|
|
||||||
DateUtil dateUtil = new DateUtil();
|
|
||||||
// 两个日期相差多少月
|
|
||||||
int monthNum = dateUtil.betweenMonthByTwoCalendar(startTime,endTime);
|
|
||||||
int termNum = monthNum/jfzqNum;
|
|
||||||
int mo = monthNum%jfzqNum;
|
|
||||||
if(mo!=0){
|
|
||||||
termNum++;
|
|
||||||
}
|
|
||||||
float zlmjFloat = 0;
|
|
||||||
double zf = 0;
|
|
||||||
if("面积计费".equals(jifeifs)){
|
|
||||||
String mjStr = jsonObject.getString("mj");
|
|
||||||
zlmjFloat = Float.parseFloat(mjStr);
|
|
||||||
String mjzjStr = jsonObject.getString("mjzj");
|
|
||||||
double mjzj = dateUtil.stringToNum(mjzjStr);
|
|
||||||
zf = mjzj*zlmjFloat;
|
|
||||||
}else if ("固定租金".equals(jifeifs)){
|
|
||||||
zlmjFloat = 1;
|
|
||||||
String gdzjStr = jsonObject.getString("gdzj");
|
|
||||||
double gdzj = dateUtil.stringToNum(gdzjStr);
|
|
||||||
zf = gdzj*zlmjFloat;
|
|
||||||
}
|
|
||||||
for(int i = 0 ; i < termNum ; i ++) {
|
|
||||||
if (startTime.getTime().getTime() < endTime.getTime().getTime()) {
|
|
||||||
Map<String, String> rentMap = new HashMap<String, String>();
|
|
||||||
// 设置租费时间
|
|
||||||
rentMap.put("明细-开始日期", sdf.format(startTime.getTime()));
|
|
||||||
startTime.add(Calendar.MONTH, jfzqNum);
|
|
||||||
startTime.add(Calendar.DAY_OF_MONTH, -1);
|
|
||||||
if (startTime.getTime().getTime() < endTime.getTime().getTime()) {
|
|
||||||
// rentMap.put("期间月数-租金",jfzqNum+"");
|
|
||||||
// rentMap.put("租费", (zf * jfzqNum) + "");
|
|
||||||
if("固定租金".equals(jifeifs)){
|
|
||||||
rentMap.put("明细-租费", (zf * 1) + "");
|
|
||||||
}else{
|
|
||||||
rentMap.put("明细-租费", (zf * jfzqNum) + "");
|
|
||||||
}
|
|
||||||
rentMap.put("明细-结束日期", sdf.format(startTime.getTime()));
|
|
||||||
} else {
|
|
||||||
//两个日期相差多少月
|
|
||||||
startTime.add(Calendar.MONTH, jfzqNum*-1);
|
|
||||||
startTime.add(Calendar.DAY_OF_MONTH, 1);
|
|
||||||
int qijianyueshu = dateUtil.betweenMonthByTwoCalendar(startTime, endTime);
|
|
||||||
// rentMap.put("期间月数-租金",qijianyueshu+"");
|
|
||||||
// rentMap.put("租费", (zf * qijianyueshu) + "");
|
|
||||||
if("固定租金".equals(jifeifs)){
|
|
||||||
rentMap.put("明细-租费", (zf * 1) + "");
|
|
||||||
}else{
|
|
||||||
rentMap.put("明细-租费", (zf * qijianyueshu) + "");
|
|
||||||
}
|
|
||||||
endTime.add(Calendar.DAY_OF_MONTH, -1);
|
|
||||||
rentMap.put("明细-结束日期", sdf.format(endTime.getTime()));
|
|
||||||
}
|
|
||||||
startTime.add(Calendar.DAY_OF_MONTH, 1);
|
|
||||||
if (isMaxDay) {
|
|
||||||
startTime.set(Calendar.DAY_OF_MONTH, startTime.getActualMaximum(Calendar.DAY_OF_MONTH));
|
|
||||||
}
|
|
||||||
rents.add(rentMap);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return rents;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生成租金账单
|
|
||||||
* @param startTime 开始时间
|
|
||||||
* @param endTime 结束时间
|
|
||||||
* @param isMaxDay 是否每月最后一天
|
|
||||||
* @param jfzqNum 缴费周期月
|
|
||||||
* @param jsonObject 请求参数
|
|
||||||
* @param jifeifs 计费方式
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public List<Map<String,String>> getLeaseBillYers2(Calendar startTime, Calendar endTime, boolean isMaxDay, int jfzqNum,
|
|
||||||
JSONObject jsonObject,String jifeifs){
|
|
||||||
System.out.println("生成账单的参数: " + startTime + ","+ endTime+"," + isMaxDay+"," + jfzqNum +","+ jsonObject.toString() +","+ jifeifs);
|
|
||||||
List<Map<String,String>> rents = new ArrayList<>();
|
|
||||||
DateUtil dateUtil = new DateUtil();
|
|
||||||
// 两个日期相差多少年
|
|
||||||
Calendar calendar = Calendar.getInstance();
|
|
||||||
calendar.setTime(startTime.getTime());
|
|
||||||
int starYear = startTime.get(Calendar.YEAR);
|
|
||||||
int endYear = endTime.get(Calendar.YEAR);
|
|
||||||
int termNum = endYear-starYear+1;
|
|
||||||
float zlmjFloat = 0;
|
|
||||||
double zf = 0;
|
|
||||||
if("面积计费".equals(jifeifs)){
|
|
||||||
String mjStr = jsonObject.getString("mj");
|
|
||||||
zlmjFloat = Float.parseFloat(mjStr);
|
|
||||||
String mjzjStr = jsonObject.getString("mjzj");
|
|
||||||
double mjzj = dateUtil.stringToNum(mjzjStr);
|
|
||||||
zf = mjzj*zlmjFloat;
|
|
||||||
}else if ("固定租金".equals(jifeifs)){
|
|
||||||
zlmjFloat = 1;
|
|
||||||
String gdzjStr = jsonObject.getString("gdzj");
|
|
||||||
double gdzj = dateUtil.stringToNum(gdzjStr);
|
|
||||||
zf = gdzj*zlmjFloat;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int i = 0 ; i < termNum ; i ++) {
|
|
||||||
if (startTime.getTime().getTime() < endTime.getTime().getTime()) {
|
|
||||||
Map<String, String> rentMap = new HashMap<String, String>();
|
|
||||||
// 设置租费时间
|
|
||||||
rentMap.put("开始日期", sdf.format(startTime.getTime()));
|
|
||||||
startTime.set(Calendar.MONTH, 11);
|
|
||||||
startTime.set(Calendar.DATE, 31);
|
|
||||||
if (startTime.getTime().getTime() < endTime.getTime().getTime()) {
|
|
||||||
// rentMap.put("期间月数-租金",jfzqNum+"");
|
|
||||||
startTime.add(Calendar.DAY_OF_MONTH, 1);
|
|
||||||
int qijianyueshu = dateUtil.betweenMonthByTwoCalendar(calendar, startTime);
|
|
||||||
startTime.add(Calendar.DAY_OF_MONTH, -1);
|
|
||||||
// rentMap.put("租费", (zf * qijianyueshu) + "");
|
|
||||||
if ("固定租金".equals(jifeifs)){
|
|
||||||
rentMap.put("明细-租费", (zf * 1) + "");
|
|
||||||
}else{
|
|
||||||
rentMap.put("明细-租费", (zf * qijianyueshu) + "");
|
|
||||||
}
|
|
||||||
rentMap.put("明细-结束日期", sdf.format(startTime.getTime()));
|
|
||||||
calendar.set(Calendar.MONTH, 11);
|
|
||||||
calendar.set(Calendar.DATE, 31);
|
|
||||||
} else {
|
|
||||||
//两个日期相差多少月
|
|
||||||
int qijianyueshu = dateUtil.betweenMonthByTwoCalendar(calendar, endTime);
|
|
||||||
// rentMap.put("期间月数-租金",qijianyueshu+"");
|
|
||||||
// rentMap.put("租费", (zf * qijianyueshu) + "");
|
|
||||||
if ("固定租金".equals(jifeifs)){
|
|
||||||
rentMap.put("明细-租费", (zf * 1) + "");
|
|
||||||
}else{
|
|
||||||
rentMap.put("明细-租费", (zf * qijianyueshu) + "");
|
|
||||||
}
|
|
||||||
endTime.add(Calendar.DAY_OF_MONTH, -1);
|
|
||||||
rentMap.put("明细-结束日期", sdf.format(endTime.getTime()));
|
|
||||||
}
|
|
||||||
startTime.add(Calendar.DAY_OF_MONTH, 1);
|
|
||||||
calendar.add(Calendar.DAY_OF_MONTH, 1);
|
|
||||||
if (isMaxDay) {
|
|
||||||
startTime.set(Calendar.DAY_OF_MONTH, startTime.getActualMaximum(Calendar.DAY_OF_MONTH));
|
|
||||||
}
|
|
||||||
rents.add(rentMap);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return rents;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user