工程预付款统计功能开发

This commit is contained in:
lSun 2025-04-16 18:52:44 +08:00
parent 11086496c9
commit f13a35d40a
9 changed files with 135 additions and 117 deletions

View File

@ -35,7 +35,10 @@ public class OperationsBean {
private String operator;//更新人
@JsonSerialize(using = ToStringSerializer.class)
private BigDecimal currentBalance;//当前余额
private BigDecimal currentBalance;//未进行新增修改时余额就是此余额加上调整金额就是现在的金额
@JsonSerialize(using = ToStringSerializer.class)
private BigDecimal currentBalanceNew;//当前余额
private String userId; //用户id
private String userName; //用户名

View File

@ -98,7 +98,10 @@ public class PrepaymentServiceImpl implements PrepaymentService {
@Override
public void delOperations(Long id) {
String userId =UserUtil.getLoginUser().getId().toString();
OperationsBean bean = dao.getOperationsById(id.toString());
bean.setCurrentBalanceNew(bean.getCurrentBalance());
dao.delOperations(id,userId);
dao.updatePrepaymentId(bean);
}
/**

View File

@ -6,17 +6,17 @@
<insert id="addPrepayment">
INSERT INTO `bm_project_prepayment` (`project_code`, `project_name`, `business_unit`, `contact_unit`, `type`,
`initial_amount`, `first_payment_date`, `current_balance`, `remarks`,`operator`,`is_active`)
VALUES (#{projectCode},#{projectName},#{businessUnit},#{contactUnit},#{type},
#{initialAmount},#{firstPaymentDate},#{initialAmount},#{remarks},#{operator},'1')
`initial_amount`, `first_payment_date`, `current_balance`, `remarks`,
`operator`, `is_active`)
VALUES (#{projectCode}, #{projectName}, #{businessUnit}, #{contactUnit}, #{type},
#{initialAmount}, #{firstPaymentDate}, #{initialAmount}, #{remarks}, #{operator}, '1')
</insert>
<insert id="addOperations">
INSERT INTO `bm_monthly_operations` ( `p_id`, `month`, `operation_type`, `amount`, `executor`, `remarks`,
`next_month`, `proposed_amount`, `handler`, `next_remarks`,`is_active`,`operator` )
VALUES
(
#{prepaymentId},
INSERT INTO `bm_monthly_operations` (`p_id`, `month`, `operation_type`, `amount`, `executor`, `remarks`,
`next_month`, `proposed_amount`, `handler`, `next_remarks`, `is_active`,
`operator`,`current_balance`)
VALUES (#{prepaymentId},
#{month},
#{operationType},
#{amount},
@ -25,10 +25,13 @@
#{nextMonth},
#{proposedAmount},
#{handler},
#{nextRemarks},'1',#{operator})
#{nextRemarks}, '1', #{operator},#{currentBalance})
</insert>
<update id="updatePrepaymentId">
UPDATE `bm_project_prepayment` SET `current_balance` = #{currentBalance}, `operator` = #{operator} WHERE `id` = #{prepaymentId}
UPDATE `bm_project_prepayment`
SET `current_balance` = #{currentBalanceNew},
`operator` = #{operator}
WHERE `id` = #{prepaymentId}
</update>
<update id="updatePrepayment">
UPDATE `bm_project_prepayment` SET `operator` = #{operator}
@ -59,11 +62,11 @@
<if test="remarks != null">
,remarks = #{remarks}
</if>
WHERE `id` = #{id}
WHERE `id` = #{id}
</update>
<update id="updateOperations">
UPDATE `bm_monthly_operations` SET `month` = #{month}, `operation_type` = #{operationType},
`amount` = #{amount}, `executor` = #{executor},operator = #{operator},
`amount` = #{amount}, `executor` = #{executor},operator = #{operator}
<if test="remarks != null">
,remarks = #{remarks}
</if>
@ -83,128 +86,118 @@
</update>
<delete id="delPrepayment">
UPDATE `bm_project_prepayment` SET `is_active` = '0' , operator = #{userId} WHERE `id` = #{id}
UPDATE `bm_project_prepayment`
SET `is_active` = '0',
operator = #{userId}
WHERE `id` = #{id}
</delete>
<delete id="delOperations">
UPDATE `bm_monthly_operations` SET `is_active` = '0' , operator = #{userId} WHERE `id` = #{id}
UPDATE `bm_monthly_operations`
SET `is_active` = '0',
operator = #{userId}
WHERE `id` = #{id}
</delete>
<select id="getList" resultType="com.bonus.boot.manager.ca.bm.entity.PrepaymentBean">
SELECT
id,
project_code as projectCode,
project_name as projectName,
business_unit as businessUnit,
contact_unit as contactUnit,
type,
initial_amount as initialAmount,
first_payment_date as firstPaymentDate,
current_balance as currentBalance,
remarks,
operator,
created_time as createdTime,
updated_time as updatedTime,
GREATEST(PERIOD_DIFF(DATE_FORMAT(CURDATE(), '%Y%m'), DATE_FORMAT(first_payment_date, '%Y%m')), 0) AS agingMonths,
CASE
WHEN current_balance = 0 THEN 0
ELSE 1
END AS state
bm.id,
bm.project_code as projectCode,
bm.project_name as projectName,
bm.business_unit as businessUnit,
bm.contact_unit as contactUnit,
bm.type,
bm.initial_amount as initialAmount,
bm.first_payment_date as firstPaymentDate,
bm.current_balance as currentBalance,
bm.remarks,
u.username as operator,
bm.created_time as createdTime,
bm.updated_time as updatedTime,
GREATEST(PERIOD_DIFF(DATE_FORMAT(CURDATE(), '%Y%m'), DATE_FORMAT(bm.first_payment_date, '%Y%m')), 0) AS
agingMonths,
CASE
WHEN bm.current_balance = 0 THEN 0
ELSE 1
END AS state
FROM
`bm_project_prepayment`
WHERE is_active = '1'
`bm_project_prepayment` bm
LEFT JOIN sys_user u ON u.id = bm.operator
WHERE bm.is_active = '1'
<if test="params.keyword != null and params.keyword != ''">
AND (
project_code LIKE CONCAT('%', #{params.keyword}, '%')
OR project_name LIKE CONCAT('%', #{params.keyword}, '%')
OR business_unit LIKE CONCAT('%', #{params.keyword}, '%')
OR contact_unit LIKE CONCAT('%', #{params.keyword}, '%')
OR type LIKE CONCAT('%', #{params.keyword}, '%')
bm.project_code LIKE CONCAT('%', #{params.keyword}, '%')
OR bm.project_name LIKE CONCAT('%', #{params.keyword}, '%')
OR bm.business_unit LIKE CONCAT('%', #{params.keyword}, '%')
OR bm.contact_unit LIKE CONCAT('%', #{params.keyword}, '%')
OR bm.type LIKE CONCAT('%', #{params.keyword}, '%')
)
</if>
<if test="params.state =='1' || params.state ==1">
AND current_balance>0
AND bm.current_balance>0
</if>
<if test="params.state =='2' || params.state ==2">
AND current_balance=0
AND bm.current_balance=0
</if>
ORDER BY updated_time DESC
ORDER BY bm.updated_time DESC
</select>
<select id="getListById" resultType="com.bonus.boot.manager.ca.bm.entity.PrepaymentBean">
SELECT
id,
project_code as projectCode,
project_name as projectName,
business_unit as businessUnit,
contact_unit as contactUnit,
type,
initial_amount as initialAmount,
first_payment_date as firstPaymentDate,
current_balance as currentBalance,
remarks,
operator,
created_time as createdTime,
updated_time as updatedTime,
GREATEST(PERIOD_DIFF(DATE_FORMAT(CURDATE(), '%Y%m'), DATE_FORMAT(first_payment_date, '%Y%m')), 0) AS agingMonths,
CASE
WHEN current_balance = 0 THEN 0
ELSE 1
END AS state
FROM
`bm_project_prepayment`
WHERE is_active = '1' and id= #{id}
SELECT id,
project_code as projectCode,
project_name as projectName,
business_unit as businessUnit,
contact_unit as contactUnit,
type,
initial_amount as initialAmount,
first_payment_date as firstPaymentDate,
current_balance as currentBalance,
remarks,
operator,
created_time as createdTime,
updated_time as updatedTime,
GREATEST(PERIOD_DIFF(DATE_FORMAT(CURDATE(), '%Y%m'), DATE_FORMAT(first_payment_date, '%Y%m')),
0) AS agingMonths,
CASE
WHEN current_balance = 0 THEN 0
ELSE 1
END AS state
FROM `bm_project_prepayment`
WHERE is_active = '1'
and id = #{id}
</select>
<select id="getOperationsList" resultType="com.bonus.boot.manager.ca.bm.entity.OperationsBean">
SELECT
id,
p_id as prepaymentId,
month,
operation_type as operationType,
amount,
executor,
remarks,
next_month as nextMonth,
proposed_amount as proposedAmount,
handler,
next_remarks as nextRemarks,
operator,
created_time as createdTime,
updated_time as updatedTime
FROM `bm_monthly_operations`
WHERE is_active = '1' AND p_id = #{params.prepaymentId}
ORDER BY updated_time DESC
SELECT bm.id,
bm.p_id as prepaymentId, bm.month, bm.operation_type as operationType,
bm.amount, u2.username as executor, bm.remarks, bm.next_month as nextMonth,
bm.proposed_amount as proposedAmount, bm.handler, bm.next_remarks as nextRemarks,
u.username as operator, bm.created_time as createdTime, bm.updated_time as updatedTime
FROM `bm_monthly_operations` bm
LEFT JOIN sys_user u ON u.id = bm.operator
LEFT JOIN sys_user u2 ON u2.id = bm.executor
WHERE bm.is_active = '1' AND bm.p_id = #{params.prepaymentId}
ORDER BY bm.updated_time DESC
</select>
<select id="getMath" resultType="java.lang.Integer">
SELECT COUNT(*) FROM `bm_monthly_operations`
WHERE p_id = #{prepaymentId} and `month` = #{month} AND is_active = '1'
WHERE p_id = #{prepaymentId} and `month` = #{month} AND is_active = '1'
<if test="id !=null ">
and id != #{id}
</if>
</select>
<select id="getOperationsById" resultType="com.bonus.boot.manager.ca.bm.entity.OperationsBean">
SELECT
bm.id,
p_id as prepaymentId,
month,
operation_type as operationType,
amount,
executor,
remarks,
next_month as nextMonth,
proposed_amount as proposedAmount,
handler,
next_remarks as nextRemarks,
u.username as operator,
created_time as createdTime,
updated_time as updatedTime,
u.id as userId,
u.username as userName
SELECT bm.id,
p_id as prepaymentId, month, operation_type as operationType, amount,
u2.username as executor, remarks, next_month as nextMonth,
proposed_amount as proposedAmount, handler, next_remarks as nextRemarks,
u.username as operator, created_time as createdTime, updated_time as updatedTime,
u.id as userId, u.username as userName,bm.current_balance as currentBalance
FROM `bm_monthly_operations` bm
LEFT JOIN sys_user u ON u.id = bm.operator
LEFT JOIN sys_user u ON u.id = bm.operator
LEFT JOIN sys_user u2 ON u2.id = bm.executor
WHERE bm.is_active = '1' AND bm.id= #{id}
</select>
</mapper>

View File

@ -38,4 +38,14 @@ function getCurrentMonth() {
var year = now.getFullYear();
var month = now.getMonth() + 1; // 月份从 0 开始
return year + '-' + (month < 10 ? '0' + month : month);
}
function getToday() {
var now = new Date();
var year = now.getFullYear();
var month = now.getMonth() + 1; // 月份从 0 开始
var day = now.getDate();
return year + '-' +
(month < 10 ? '0' + month : month) + '-' +
(day < 10 ? '0' + day : day);
}

View File

@ -104,6 +104,7 @@ function initData(){
$("#proposedAmount").val(info.proposedAmount);
$("#handler").val(info.handler);
$("#nextRemarks").val(info.nextRemarks);
currentBalance = info.currentBalance;
}
},
error: function (XMLHttpRequest, textStatus, e) {
@ -118,21 +119,29 @@ function initData(){
function calculateNewBalance() {
var amount = parseFloat($('#amount').val()) || 0;
var operationType = $('#operationType').val();
var num = currentBalance;
// 将 currentBalance 转换为数字
num = parseFloat(num) || 0;
if (operationType === '1') {
// 冲销是减少余额
currentBalance = currentBalance - amount;
num = num - amount;
} else {
// 新增是增加余额
currentBalance = currentBalance + amount;
num = num + amount;
}
return currentBalance.toFixed(2);
// 确保返回值是保留两位小数的字符串
console.log("最终余额:", num.toFixed(2));
return num.toFixed(2);
}
function add(formData) {
// 计算更新后的余额
var currentBalance = calculateNewBalance();
// 添加更新后的余额到表单数据
//先保证未进行冲销或新增金额
formData.field.currentBalance = currentBalance;
// 计算更新后的余额
var currentBalanceNew = calculateNewBalance();
// 添加更新后的余额到表单数据
formData.field.currentBalanceNew = currentBalanceNew;
formData.field.prepaymentId = prepaymentId;
formData.field.executor = $("#prepaymentUserId").val();
@ -166,6 +175,7 @@ function add(formData) {
top.layer.close(addLoadingMsg); //再执行关闭
parent.layer.msg(tip + '成功', { icon: 1, time: 2000 });
parent.table.reload('menuTable');
parent.initData()
} else {
top.layer.close(addLoadingMsg); //再执行关闭
if(data.resMsg ==="当前月份已经存在"){

View File

@ -6,7 +6,8 @@ layui.use(['table', 'layer', 'laydate', 'jquery', 'form'], function(){
laydate = layui.laydate;
// 渲染
laydate.render({
elem: '#firstPaymentDate'
elem: '#firstPaymentDate',
max: getToday(),
});
initData();
form.render();

View File

@ -176,6 +176,7 @@ function del(id) {
url: ctxPath + '/prepayment/delOperations/' + id,
success: function (data) {
table.reload('menuTable');
initData()
layer.msg("删除成功");
}
});

View File

@ -129,14 +129,14 @@
<div class="form-row">
<div class="form-label required">经办人:</div>
<div class="form-input">
<input type="text" class="layui-input" name="executor" id="executor" style="background-color: #eeeeee;" readonly>
<input type="text" class="layui-input" name="executor" id="executor" style="background-color: #eeeeee;" readonly>
</div>
</div>
<div class="form-row">
<div class="form-label">备注:</div>
<div class="form-input">
<textarea class="layui-input" name="remarks" id="remarks" ></textarea>
<textarea class="layui-input" name="remarks" id="remarks" maxlength="200" ></textarea>
</div>
</div>
</div>
@ -146,7 +146,7 @@
<div class="form-row">
<div class="form-label">月度冲销计划及措施:</div>
<div class="form-input">
<textarea class="layui-input" name="nextMonth" id="nextMonth" ></textarea>
<textarea class="layui-input" name="nextMonth" id="nextMonth" maxlength="200" ></textarea>
</div>
</div>
@ -160,14 +160,14 @@
<div class="form-row">
<div class="form-label ">责任人:</div>
<div class="form-input">
<input type="text" class="layui-input" name="handler" id="handler" >
<input type="text" class="layui-input" name="handler" id="handler" maxlength="30" >
</div>
</div>
<div class="form-row">
<div class="form-label">备注:</div>
<div class="form-input">
<textarea class="layui-input" name="nextRemarks" id="nextRemarks"></textarea>
<textarea class="layui-input" name="nextRemarks" id="nextRemarks" maxlength="200"></textarea>
</div>
</div>
</div>

View File

@ -150,9 +150,6 @@
<button class="layui-btn layui-btn-primary">
导出
</button>
<button class="layui-btn layui-btn-primary">
删除
</button>
</div>
</div>