月度结算
This commit is contained in:
parent
0107d9be5a
commit
a00cbbd709
|
|
@ -205,6 +205,15 @@ public class DateTimeHelper {
|
||||||
return minusMonth(new Date(), 1);
|
return minusMonth(new Date(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前时间的年月
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String getCurrentMonth() {
|
||||||
|
return minusMonth(new Date(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前时间的上个年月
|
* 获取当前时间的上个年月
|
||||||
*
|
*
|
||||||
|
|
@ -907,4 +916,21 @@ public class DateTimeHelper {
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getCalStartDay() {
|
||||||
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
Calendar c = Calendar.getInstance();
|
||||||
|
c.add(Calendar.MONTH, -1);
|
||||||
|
c.set(Calendar.DAY_OF_MONTH, 21);
|
||||||
|
String first = format.format(c.getTime());
|
||||||
|
return first;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getCalDay(int day) {
|
||||||
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
Calendar c = Calendar.getInstance();
|
||||||
|
c.add(Calendar.MONTH, 0);
|
||||||
|
c.set(Calendar.DAY_OF_MONTH, day);
|
||||||
|
return format.format(c.getTime());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,100 @@
|
||||||
|
package com.bonus.sgzb.material.domain;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class CalMonthlyBean implements java.io.Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
private String taskId;
|
||||||
|
|
||||||
|
private String projectId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据工程分组后协议id集合
|
||||||
|
*/
|
||||||
|
private String agreementConcatId;
|
||||||
|
|
||||||
|
private String projectName;
|
||||||
|
|
||||||
|
private String unitName;
|
||||||
|
|
||||||
|
private String typeName;
|
||||||
|
|
||||||
|
private String modelName;
|
||||||
|
|
||||||
|
private int num;
|
||||||
|
|
||||||
|
private String leaseDate;
|
||||||
|
|
||||||
|
private String backDate;
|
||||||
|
|
||||||
|
private String money;
|
||||||
|
|
||||||
|
private String leasePrice;
|
||||||
|
|
||||||
|
private String time;
|
||||||
|
|
||||||
|
private String month;
|
||||||
|
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
private String buyPrice;
|
||||||
|
|
||||||
|
private String leaseMoney;
|
||||||
|
|
||||||
|
private String lostMoney;
|
||||||
|
|
||||||
|
private String repairMoney;
|
||||||
|
|
||||||
|
private String scrapMoney;
|
||||||
|
|
||||||
|
private String charge;
|
||||||
|
|
||||||
|
private String typeId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* i8工程编号
|
||||||
|
*/
|
||||||
|
private String pc_no;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类别编号(周转安全工器具-2or周转工器具-1
|
||||||
|
*/
|
||||||
|
private String category="1";
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统标识 1代表机具系统 2代表机具物资 3代表送变电物资系统
|
||||||
|
*/
|
||||||
|
private String sysType="1";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提交人
|
||||||
|
*/
|
||||||
|
private String submitUser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 推送状态 0 未推送 1已推送 2退回
|
||||||
|
*/
|
||||||
|
private String pushStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 推送备注
|
||||||
|
*/
|
||||||
|
private String pushRemark;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数
|
||||||
|
*/
|
||||||
|
private String body;
|
||||||
|
|
||||||
|
private List<String> agreementId;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
package com.bonus.sgzb.material.mapper;
|
||||||
|
|
||||||
|
import com.bonus.sgzb.material.domain.CalMonthlyBean;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 综合查询--维修记录查询
|
||||||
|
* @author hay
|
||||||
|
* @date 2024/2/26 14:19
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface CalMonthlyMapper {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 综合查询--维修记录列表
|
||||||
|
* @param bean
|
||||||
|
* @return List<RepairRecord>
|
||||||
|
*/
|
||||||
|
int insertCalcRecord(CalMonthlyBean bean);
|
||||||
|
|
||||||
|
List<CalMonthlyBean> getCalcRecords(CalMonthlyBean bean);
|
||||||
|
|
||||||
|
int deleteCalcRecord(CalMonthlyBean bean);
|
||||||
|
|
||||||
|
int deleteMonthlyCosts(CalMonthlyBean bean);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
package com.bonus.sgzb.material.remind;
|
||||||
|
|
||||||
|
import com.bonus.sgzb.material.remind.service.CalcMonthlyService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.scheduling.annotation.Async;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class Inform {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CalcMonthlyService calcfourCostService;
|
||||||
|
|
||||||
|
private final int CAL_DAY = 21;
|
||||||
|
|
||||||
|
@Scheduled(cron = "0 */5 * * * ? ") // 间隔5分钟执行
|
||||||
|
//@Scheduled(cron = "0 0 1 22 * ? ") // 每个月22日凌晨1点执行
|
||||||
|
@Async
|
||||||
|
public void taskCycle() {
|
||||||
|
System.out.println("===springMVC定时器启动====");
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
// 生成每月数据 (上月21日---本月20日)
|
||||||
|
calcfourCostService.calcMonthInfo(CAL_DAY);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("===springMVC定时器结束====");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.bonus.sgzb.material.remind.service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算租赁、丢失、维修、报废等四类费用的未结算费用
|
||||||
|
*
|
||||||
|
* @author 吕继龙
|
||||||
|
* @date 2024/04/23
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface CalcMonthlyService {
|
||||||
|
|
||||||
|
void calcMonthInfo(int day) throws Exception;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,52 @@
|
||||||
|
package com.bonus.sgzb.material.remind.service;
|
||||||
|
|
||||||
|
import com.bonus.sgzb.common.core.utils.DateTimeHelper;
|
||||||
|
import com.bonus.sgzb.material.domain.CalMonthlyBean;
|
||||||
|
import com.bonus.sgzb.material.mapper.CalMonthlyMapper;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class CalcMonthlyServiceImp implements CalcMonthlyService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
CalMonthlyMapper calMonthlyMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void calcMonthInfo(int day) throws Exception {
|
||||||
|
String time = DateTimeHelper.getNowDate();
|
||||||
|
String calDay = DateTimeHelper.getCalDay(day);
|
||||||
|
if (time.equals(calDay)) {
|
||||||
|
CalMonthlyBean record = new CalMonthlyBean();
|
||||||
|
String month = DateTimeHelper.getCurrentMonth();
|
||||||
|
record.setMonth(month);
|
||||||
|
cleanSameMonthOldRecords(record);
|
||||||
|
calMonthlyMapper.insertCalcRecord(record);
|
||||||
|
String taskId = record.getId();
|
||||||
|
String startTime = DateTimeHelper.getCalStartDay();
|
||||||
|
String endTime = DateTimeHelper.getCalDay(day - 1);
|
||||||
|
|
||||||
|
//TODO, use startTime, endTime, taskId to save monthly result to a new table.
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cleanSameMonthOldRecords(CalMonthlyBean record) {
|
||||||
|
List<CalMonthlyBean> list = calMonthlyMapper.getCalcRecords(record);
|
||||||
|
if (!CollectionUtils.isEmpty(list)) {
|
||||||
|
for (CalMonthlyBean bean : list) {
|
||||||
|
//清除上月之前计算过的记录 calc_project_month
|
||||||
|
calMonthlyMapper.deleteCalcRecord(bean);
|
||||||
|
|
||||||
|
//清除上月之前计算过的记录 project_month_costs(表名待定)
|
||||||
|
calMonthlyMapper.deleteMonthlyCosts(bean);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.bonus.sgzb.material.mapper.CalMonthlyMapper">
|
||||||
|
|
||||||
|
<insert id="insertCalcRecord" parameterType="com.bonus.sgzb.material.domain.CalMonthlyBean" useGeneratedKeys="true" keyProperty="id">
|
||||||
|
INSERT INTO calc_project_month (MONTH) VALUES (#{month})
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<select id="getCalcRecords" parameterType="com.bonus.sgzb.material.domain.CalMonthlyBean" resultType="com.bonus.sgzb.material.domain.CalMonthlyBean">
|
||||||
|
select id,month from calc_project_month
|
||||||
|
where month = #{month}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<delete id="deleteCalcRecord" parameterType="com.bonus.sgzb.material.domain.CalMonthlyBean">
|
||||||
|
delete from calc_project_month
|
||||||
|
where id = #{id}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<delete id="deleteMonthlyCosts" parameterType="com.bonus.sgzb.material.domain.CalMonthlyBean">
|
||||||
|
delete from project_month_costs
|
||||||
|
where task_id = #{id}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
Loading…
Reference in New Issue