结算费用开发

This commit is contained in:
bonus 2025-06-29 14:43:51 +08:00
parent 002f325cb1
commit 67f56ecba2
19 changed files with 1165 additions and 9 deletions

View File

@ -600,5 +600,15 @@ public class DateTimeHelper {
}
}
/**
* 格式化 时间
* @param
* @return
*/
public static String currentDateTime() {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return df.format(new Date());
}
}

View File

@ -277,6 +277,14 @@ public class MachineController extends BaseController {
return machineService.getHisByQrcode(machine);
}
/**
* 根据qrcode查询机具历史信息
* @param machine
* @return
*/
@GetMapping("/getHisByCode")
public AjaxResult getHisByCode(Machine machine) {
return machineService.getHisByCode(machine);
}
}

View File

@ -233,4 +233,8 @@ public class Machine extends BaseEntity
private String backTime;
@ApiModelProperty(value = "任务")
private Integer taskId;
@ApiModelProperty(value = "机具名称")
private String maName;
@ApiModelProperty(value = "机具规格")
private String maModel;
}

View File

@ -164,4 +164,6 @@ public interface MachineMapper
Machine getScrapTimeByQrcode(Machine machine);
Machine getLeaseInfoByQrcode(Machine machine);
List<Machine> getListByCode(Machine machine);
}

View File

@ -117,4 +117,6 @@ public interface IMachineService
public int editAssetsCode(Machine machine);
AjaxResult getHisByQrcode(Machine machine);
AjaxResult getHisByCode(Machine machine);
}

View File

@ -327,7 +327,7 @@ public class MachineServiceImpl implements IMachineService
if (inTime != null){
Integer taskId = inTime.getTaskId();
if(taskId != null){
baseInfo.setInTime(inTime.getInTime()+"新购");
baseInfo.setInTime(inTime.getInTime()+"(新购)");
}else{
baseInfo.setInTime(inTime.getInTime());
}
@ -363,4 +363,71 @@ public class MachineServiceImpl implements IMachineService
return success(baseInfo);
}
@Override
public AjaxResult getHisByCode(Machine machine) {
List<Machine> result = new ArrayList<>();
List<Machine> maList = machineMapper.getListByCode(machine);
if (CollectionUtils.isNotEmpty(maList)){
if(maList.size() == 1){
Machine baseInfo = maList.get(0);
machine.setMaId(baseInfo.getMaId());
machine.setMaCode(baseInfo.getMaCode());
//2根据二维码查询初次入库时间
Machine inTime = machineMapper.getInTimeByQrcode(machine);
//服务工程次数检验次数
Machine serviceNum = machineMapper.getServiceNumByQrcode(machine);
//更换配件次数
Machine checkNum = machineMapper.getCheckNumByQrcode(machine);
//报废时间
Machine scrapTime = machineMapper.getScrapTimeByQrcode(machine);
//3根据机具id查询领退工程
Machine leaseInfo = machineMapper.getLeaseInfoByQrcode(machine);
if (inTime != null){
Integer taskId = inTime.getTaskId();
if(taskId != null){
baseInfo.setInTime(inTime.getInTime()+"(新购)");
}else{
baseInfo.setInTime(inTime.getInTime());
}
}
if(serviceNum != null){
baseInfo.setServiceNum(serviceNum.getServiceNum());
}else{
baseInfo.setServiceNum(0);
}
if(checkNum != null){
baseInfo.setCheckNum(checkNum.getCheckNum());
}else{
baseInfo.setCheckNum(0);
}
if (scrapTime != null){
baseInfo.setScrapTime(scrapTime.getScrapTime());
}else{
baseInfo.setScrapTime("暂无");
}
if(leaseInfo != null){
baseInfo.setLeaseTime(leaseInfo.getLeaseTime());
baseInfo.setLeaseUnit(leaseInfo.getLeaseUnit());
baseInfo.setLeaseProject(leaseInfo.getLeaseProject());
baseInfo.setBackTime(leaseInfo.getBackTime());
baseInfo.setBackUnit(leaseInfo.getBackUnit());
baseInfo.setBackProject(leaseInfo.getBackProject());
}
result.add(baseInfo);
return success(result);
}else{
return success(maList);
}
}else{
return error("暂无该设备信息");
}
}
}

View File

@ -0,0 +1,48 @@
package com.bonus.material.push.controller;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.poi.ExcelUtil;
import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.core.web.page.TableDataInfo;
import com.bonus.material.push.domain.IwsCostPushBean;
import com.bonus.material.push.domain.vo.IwsCostPushExportVo;
import com.bonus.material.push.service.IwsCostPushService;
import com.bonus.material.push.service.RentalCostsService;
import com.bonus.material.settlement.domain.SltAgreementInfo;
import com.bonus.material.settlement.service.impl.SltAgreementInfoServiceImpl;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.math.BigDecimal;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* @author : 阮世耀
* @version : 1.0
* @PackagePath: com.bonus.material.push.controller
* @CreateTime: 2025-01-23 15:04
* @Description: i皖送费用推送控制器
*/
@RestController
@RequestMapping("/rental_cost")
@Validated
public class RentalCostsController extends BaseController {
@Resource
private RentalCostsService rService;
}

View File

@ -0,0 +1,85 @@
package com.bonus.material.push.domain;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
/**
*
* 描述:工程租赁费用查询
* @table:
* @author
* @date 2021年11月23日
*/
@Data
public class AccProjectLeaseMoneyBean implements java.io.Serializable {
private static final long serialVersionUID = 1L;
private Integer id;
private String code;
private String number;
private String codeId;
private String leaseType;
private String typeId;
private String leaseId;
private String proId; //i8工程id
private String proCode; //i8工程code
private String projectId;
private String leaseName;
private String projectName;
private String leasePrice;
private String leaseMoney;
private String deviceName;
private String deviceModel;
private String deviceUnit;
private String leaseNum;
private String leaseDay;
private String startTime;
private String endTime;
private String keyWord;
private String companyName;
private String isSlt;
private String modelId;
private List<String> chks;
private String taskId;
/**
* 费用结算时间
*/
private String time;
private String agreementId;
private String buyPrice;
private String money;
}

View File

@ -0,0 +1,95 @@
package com.bonus.material.push.domain;
import lombok.Data;
import java.util.List;
/**
*
* 描述:工程租赁费用查询
* @table:
* @author
* @date 2021年11月23日
*/
@Data
public class ConsProjectLeaseMoneyBean implements java.io.Serializable {
private static final long serialVersionUID = 1L;
private Integer id;
private String code;
private String number;
private String codeId;
private String leaseType;
private String typeId;
private String leaseId;
private String proId; //i8工程id
private String proCode; //i8工程code
private String projectId;
private String leaseName;
private String projectName;
private String buyPrice;
private String leaseMoney;
private String leasePrice;
private String deviceName;
private String deviceModel;
private String deviceUnit;
private String leaseNum;
private String leaseDay;
private String startTime;
private String endTime;
private String keyWord;
private String companyName;
private String isSlt;
private String modelId;
private List<String> chks;
private String taskId;
private String type;
private String leaseTotal;
private String consTotal;
private String scrapTotal;
private String lostTotal;
private String repairTotal;
private String time;
private String agreementId;
private int maId;
private String month;
}

View File

@ -0,0 +1,83 @@
package com.bonus.material.push.domain;
import lombok.Data;
import org.apache.ibatis.type.Alias;
import java.math.BigDecimal;
@Data
@Alias("RentalCostsBean")
public class RentalCostsBean implements java.io.Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private String id;
private String taskId;
//i8工程id
private String proId;
//i8工程code
private String proCode;
//项目id
private String projectId;
//项目名称
private String projectName;
//所属分公司
private String companyName;
//单位id
private String unitId;
//单位名称
private String unitName;
//领料单位
private String leaseName;
private String typeName;
private String modelName;
private String deviceName;
private String deviceModel;
private BigDecimal leaseNum;
private String startTime;
private String endTime;
private BigDecimal 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;
}

View File

@ -0,0 +1,25 @@
package com.bonus.material.push.mapper;
import com.bonus.material.push.domain.AccProjectLeaseMoneyBean;
import com.bonus.material.push.domain.RentalCostsBean;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* @author : 阮世耀
* @version : 1.0
* @PackagePath: com.bonus.material.push.mapper
* @CreateTime: 2025-01-23 14:40
* @Description: i皖送费用推送mapper
*/
@Mapper
public interface AccProjectLeaseMoneyMapper {
int insertCalcRecord(RentalCostsBean o);
List<AccProjectLeaseMoneyBean> getLeaseMoneyDetail(AccProjectLeaseMoneyBean o);
int insertProjectMonthInfo(List<AccProjectLeaseMoneyBean> infos);
}

View File

@ -0,0 +1,35 @@
package com.bonus.material.push.mapper;
import com.bonus.material.push.domain.ConsProjectLeaseMoneyBean;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author : 阮世耀
* @version : 1.0
* @PackagePath: com.bonus.material.push.mapper
* @CreateTime: 2025-01-23 14:40
* @Description: i皖送费用推送mapper
*/
@Mapper
public interface ConsProjectLeaseMoneyMapper {
List<ConsProjectLeaseMoneyBean> getRealtionList(ConsProjectLeaseMoneyBean cons);
List<ConsProjectLeaseMoneyBean> getConsMonthMoney(ConsProjectLeaseMoneyBean o);
int insertProjectConsMonthInfo(@Param("list") List<ConsProjectLeaseMoneyBean> infos);
List<ConsProjectLeaseMoneyBean> getScrapMoney(ConsProjectLeaseMoneyBean o);
int insertProjectOthersMonthInfo(@Param("list") List<ConsProjectLeaseMoneyBean> infos);
List<ConsProjectLeaseMoneyBean> getLostMoney(ConsProjectLeaseMoneyBean o);
List<ConsProjectLeaseMoneyBean> getRepairMoney(ConsProjectLeaseMoneyBean o);
int insertProjectMonthCosts(@Param("list") List<ConsProjectLeaseMoneyBean> total);
}

View File

@ -0,0 +1,19 @@
package com.bonus.material.push.mapper;
import com.bonus.material.push.domain.IwsCostPushBean;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* @author : 阮世耀
* @version : 1.0
* @PackagePath: com.bonus.material.push.mapper
* @CreateTime: 2025-01-23 14:40
* @Description: i皖送费用推送mapper
*/
@Mapper
public interface RentalCostsMapper {
}

View File

@ -0,0 +1,19 @@
package com.bonus.material.push.service;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.material.push.domain.IwsCostPushBean;
import java.util.List;
/**
* @author : 阮世耀
* @version : 1.0
* @PackagePath: com.bonus.material.push.service
* @CreateTime: 2025-01-23 14:48
* @Description: i皖送推送server 接口
*/
public interface RentalCostsService {
void calcMonthInfo();
}

View File

@ -0,0 +1,270 @@
package com.bonus.material.push.service.impl;
import com.alibaba.nacos.common.utils.CollectionUtils;
import com.bonus.common.biz.config.DateTimeHelper;
import com.bonus.common.core.utils.StringUtils;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.material.push.domain.AccProjectLeaseMoneyBean;
import com.bonus.material.push.domain.ConsProjectLeaseMoneyBean;
import com.bonus.material.push.domain.IwsCostPushBean;
import com.bonus.material.push.domain.RentalCostsBean;
import com.bonus.material.push.mapper.AccProjectLeaseMoneyMapper;
import com.bonus.material.push.mapper.ConsProjectLeaseMoneyMapper;
import com.bonus.material.push.mapper.IwsCostPushMapper;
import com.bonus.material.push.mapper.RentalCostsMapper;
import com.bonus.material.push.service.IwsCostPushService;
import com.bonus.material.push.service.RentalCostsService;
import com.bonus.material.settlement.domain.SltAgreementInfo;
import com.bonus.material.settlement.domain.vo.SltInfoVo;
import com.bonus.material.settlement.service.ISltAgreementInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalAdjusters;
import java.util.*;
import java.util.stream.Collectors;
/**
* @author : 阮世耀
* @version : 1.0
* @PackagePath: com.bonus.material.push.service.impl
* @CreateTime: 2025-01-23 14:48
* @Description: 描述
*/
@Service
public class RentalCostsServiceImpl implements RentalCostsService {
@Autowired
private RentalCostsMapper dao;
@Autowired
private AccProjectLeaseMoneyMapper accDao;
@Autowired
ConsProjectLeaseMoneyMapper consDao;
@Override
@Transactional(rollbackFor = Exception.class)
public void calcMonthInfo() {
RentalCostsBean o = new RentalCostsBean();
// yyyy-MM 获取上个月的月份
o.setMonth(DateTimeHelper.getPrevMonth());
int res = accDao.insertCalcRecord(o);
if (res == 0) {
throw new RuntimeException("新增calc_project_month失败");
}
String taskId = o.getId();
// 获取上个月的第一天日期:2024-05-01
String startTime = DateTimeHelper.getPreFirstDay();
// 获取上个月的最后一天:2024-05-31
String endTime = DateTimeHelper.getPreLastDay();
ConsProjectLeaseMoneyBean cons = new ConsProjectLeaseMoneyBean();
cons.setStartTime(startTime);
cons.setEndTime(endTime);
List<ConsProjectLeaseMoneyBean> list = consDao.getRealtionList(cons);
calcMonthInfoDetails(list, startTime, endTime, taskId);
}
private void calcMonthInfoDetails(List<ConsProjectLeaseMoneyBean> list, String startTime, String endTime, String taskId) {
int res;
LocalDate date = LocalDate.parse(startTime, DateTimeFormatter.ISO_DATE);
String month = date.format(DateTimeFormatter.ofPattern("yyyy-MM"));
List<ConsProjectLeaseMoneyBean> total = new ArrayList<>();
for(ConsProjectLeaseMoneyBean bean : list){
String agreementId = bean.getAgreementId();
String projectId = bean.getProjectId();
String leaseType = bean.getLeaseType();
String leaseName = bean.getLeaseName();
// 机具部分中转表 project_month_info
float leaseTotal = generatePushData4Machines(leaseName,agreementId,projectId,leaseType, startTime, endTime, taskId);
//消耗品部分中转表 project_month_info
float consTotal = generatePushData4Consumables(leaseName,agreementId,projectId,leaseType, startTime, endTime, taskId);
//报废费用中转表 project_month_info
float scrapTotal = generatePushData4Scrap(leaseName,agreementId,projectId,leaseType, startTime, endTime, taskId);
//丢失费用中转表 project_month_info
float lostTotal = generatePushData4Lost(leaseName,agreementId,projectId,leaseType, startTime, endTime, taskId);
//维修费用中转表 project_month_info
float repairTotal = generatePushData4Repair(leaseName,agreementId,projectId,leaseType, startTime, endTime, taskId);
if (leaseTotal > 0 || consTotal > 0 || scrapTotal > 0 || lostTotal > 0) {
bean.setLeaseTotal(leaseTotal + "");
bean.setConsTotal(consTotal + "");
bean.setScrapTotal(scrapTotal + "");
bean.setLostTotal(lostTotal + "");
bean.setRepairTotal(repairTotal + "");
bean.setTaskId(taskId);
bean.setMonth(month);
total.add(bean);
}
}
res = consDao.insertProjectMonthCosts(total);
if (res == 0) {
throw new RuntimeException("新增project_month_costs失败");
}
}
private float generatePushData4Machines(String leaseName,String agreementId,String projectId,String leaseType,String startTime, String endTime, String taskId) {
System.out.println("开始机具费用数据收集定时任务");
AccProjectLeaseMoneyBean o = new AccProjectLeaseMoneyBean();
o.setStartTime(startTime);
o.setEndTime(endTime);
o.setAgreementId(agreementId);
o.setProjectId(projectId);
o.setLeaseType(leaseType);
BigDecimal total = new BigDecimal("0");
List<AccProjectLeaseMoneyBean> infos = accDao.getLeaseMoneyDetail(o);
if (infos != null && infos.size() > 0) {
for(AccProjectLeaseMoneyBean info : infos){
info.setTaskId(taskId);
info.setAgreementId(agreementId);
info.setLeaseType(leaseType);
info.setProjectId(projectId);
info.setLeaseName(leaseName);
total = total.add(new BigDecimal(info.getLeaseMoney()));
}
int res = accDao.insertProjectMonthInfo(infos);
if (res == 0) {
throw new RuntimeException("新增project_month_info失败");
}
}
return total.setScale(2).floatValue();
}
private float generatePushData4Consumables(String leaseName,String agreementId,String projectId,String leaseType,String startTime, String endTime, String taskId) {
System.out.println("开始消耗品费用数据收集定时任务");
ConsProjectLeaseMoneyBean o = new ConsProjectLeaseMoneyBean();
o.setStartTime(startTime);
o.setEndTime(endTime);
o.setAgreementId(agreementId);
o.setProjectId(projectId);
o.setLeaseType(leaseType);
BigDecimal total = new BigDecimal("0");
List<ConsProjectLeaseMoneyBean> infos = consDao.getConsMonthMoney(o);
if (infos != null && infos.size() > 0) {
for(ConsProjectLeaseMoneyBean info : infos){
info.setTaskId(taskId);
info.setAgreementId(agreementId);
info.setLeaseType(leaseType);
info.setProjectId(projectId);
info.setLeaseName(leaseName);
total = total.add(new BigDecimal(info.getLeaseMoney()));
}
int res = consDao.insertProjectConsMonthInfo(infos);
if (res == 0) {
throw new RuntimeException("新增project_month_info失败");
}
}
return total.setScale(2).floatValue();
}
private float generatePushData4Scrap(String leaseName,String agreementId,String projectId,String leaseType,String startTime, String endTime, String taskId) {
System.out.println("开始报废费用数据收集定时任务");
ConsProjectLeaseMoneyBean o = new ConsProjectLeaseMoneyBean();
o.setStartTime(startTime);
o.setEndTime(endTime);
o.setAgreementId(agreementId);
o.setProjectId(projectId);
o.setLeaseType(leaseType);
BigDecimal total = new BigDecimal("0");
List<ConsProjectLeaseMoneyBean> infos = consDao.getScrapMoney(o);
if (infos != null && infos.size() > 0) {
for(ConsProjectLeaseMoneyBean info : infos){
info.setTaskId(taskId);
info.setAgreementId(agreementId);
info.setLeaseType(leaseType);
info.setProjectId(projectId);
info.setLeaseName(leaseName);
info.setType("4");
total = total.add(new BigDecimal(info.getLeaseMoney()));
}
int res = consDao.insertProjectOthersMonthInfo(infos);
if (res == 0) {
throw new RuntimeException("新增project_month_info失败");
}
}
return total.setScale(2).floatValue();
}
private float generatePushData4Lost(String leaseName,String agreementId,String projectId,String leaseType,String startTime, String endTime, String taskId) {
System.out.println("开始丢失费用数据收集定时任务");
ConsProjectLeaseMoneyBean o = new ConsProjectLeaseMoneyBean();
o.setStartTime(startTime);
o.setEndTime(endTime);
o.setAgreementId(agreementId);
o.setProjectId(projectId);
o.setLeaseType(leaseType);
BigDecimal total = new BigDecimal("0");
List<ConsProjectLeaseMoneyBean> infos = consDao.getLostMoney(o);
if (infos != null && infos.size() > 0) {
for(ConsProjectLeaseMoneyBean info : infos){
info.setTaskId(taskId);
info.setAgreementId(agreementId);
info.setLeaseType(leaseType);
info.setProjectId(projectId);
info.setLeaseName(leaseName);
info.setType("2");
total = total.add(new BigDecimal(info.getLeaseMoney()));
}
int res = consDao.insertProjectOthersMonthInfo(infos);
if (res == 0) {
throw new RuntimeException("新增project_month_info失败");
}
}
return total.setScale(2).floatValue();
}
private float generatePushData4Repair(String leaseName, String agreementId, String projectId, String leaseType, String startTime, String endTime, String taskId) {
System.out.println("开始维修费用数据收集定时任务");
ConsProjectLeaseMoneyBean o = new ConsProjectLeaseMoneyBean();
o.setStartTime(startTime);
o.setEndTime(endTime);
o.setAgreementId(agreementId);
o.setProjectId(projectId);
o.setLeaseType(leaseType);
BigDecimal total = new BigDecimal("0");
List<ConsProjectLeaseMoneyBean> infos = consDao.getRepairMoney(o);
if (infos != null && infos.size() > 0) {
for(ConsProjectLeaseMoneyBean info : infos){
info.setTaskId(taskId);
info.setAgreementId(agreementId);
info.setLeaseType(leaseType);
info.setProjectId(projectId);
info.setLeaseName(leaseName);
info.setType("3");
total = total.add(new BigDecimal(info.getLeaseMoney()));
}
int res = consDao.insertProjectOthersMonthInfo(infos);
if (res == 0) {
throw new RuntimeException("新增project_month_info失败");
}
}
return total.setScale(2).floatValue();
}
}

View File

@ -0,0 +1,54 @@
package com.bonus.material.remind;
import com.bonus.common.biz.config.DateTimeHelper;
import com.bonus.material.push.service.RentalCostsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@Component
public class InformMonthly {
@Autowired
RentalCostsService service;
/**
* 定时任务注解用于配置任务的执行周期
* 该任务被安排在每月的第一天凌晨3点执行
* cron表达式解释
* - "0 0 3 1 * ?" 表示在每月的第一天的3点0分0秒执行
* - 分钟0表示分钟这里指定为0分钟
* - 小时0表示小时这里指定为3点
* - 日期1表示日期这里指定为每月的第一天
* - 月份*表示月份这里使用通配符*表示所有月份
* - 星期?表示星期由于每月第一天的星期不固定因此使用?表示
* - 年份不指定年份表示每年都执行
*/
@Scheduled(cron = "0 0 1 * * ?")
public void taskCycle() {
System.out.println("使用SpringMVC框架配置定时任务");
try {
System.out.println("执行每月初1号的一次的定时任务...执行时间:" + DateTimeHelper.currentDateTime());
} catch (Exception e) {
System.err.println("定时任务获取时间报错:" + e.getMessage());
}
String time = DateTimeHelper.getNowDate();
String firstDay = DateTimeHelper.getFirstDay();
if (time.equals(firstDay)) {
// 执行业务逻辑
service.calcMonthInfo();
}
try {
System.out.println("本月的定时任务已结束:" + DateTimeHelper.currentDateTime());
} catch (Exception e) {
System.err.println("定时任务获取时间报错:" + e.getMessage());
}
}
}

View File

@ -355,7 +355,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
UPDATE
ma_machine
SET
ma_status = #{status}
ma_status = #{status},
in_out_num = ifnull(in_out_num,0) + 1
where
ma_id = #{maId}
</update>
@ -551,7 +552,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="getInfoByQrcode" resultMap="MachineResult">
<select id="getInfoByQrcode" resultType="com.bonus.material.ma.domain.Machine">
SELECT
mm.ma_id as maId,
mt2.type_name as maName,
@ -578,7 +579,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="getInTimeByQrcode" resultMap="MachineResult">
<select id="getInTimeByQrcode" resultType="com.bonus.material.ma.domain.Machine">
SELECT
bqi.qr_code as qrCode,
bqi.task_id as taskId,
@ -588,14 +589,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
WHERE bqi.qr_code = #{qrCode}
</select>
<select id="getServiceNumByQrcode" resultMap="MachineResult">
<select id="getServiceNumByQrcode" resultType="com.bonus.material.ma.domain.Machine">
SELECT
COUNT(DISTINCT sai.agreement_id) as serviceNum
FROM slt_agreement_info sai
WHERE sai.ma_id = #{maId}
</select>
<select id="getCheckNumByQrcode" resultMap="MachineResult">
<select id="getCheckNumByQrcode" resultType="com.bonus.material.ma.domain.Machine">
SELECT
COUNT(rp.ma_id ) as checkNum
@ -604,7 +605,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
WHERE rp.ma_id = #{maId} and rp.is_ds = 0
</select>
<select id="getScrapTimeByQrcode" resultMap="MachineResult">
<select id="getScrapTimeByQrcode" resultType="com.bonus.material.ma.domain.Machine">
SELECT
sd.ma_id,
sd.task_id,
@ -615,6 +616,55 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="getLeaseInfoByQrcode" resultMap="MachineResult">
<select id="getLeaseInfoByQrcode" resultType="com.bonus.material.ma.domain.Machine">
SELECT
sai.id,
bu.unit_name AS leaseUnit,
bp.pro_name AS leaseProject,
sai.start_time AS leaseTime,
IF( sai.status = 1, bu.unit_name,"") AS backUnit,
IF( sai.status = 1, bp.pro_name ,"") AS backProject,
IF( sai.status = 1, sai.end_time ,"") AS backTime,
sai.status
FROM
slt_agreement_info sai
LEFT JOIN bm_agreement_info bai on sai.agreement_id = bai.agreement_id
LEFT JOIN bm_unit bu on bai.unit_id = bu.unit_id
LEFT JOIN bm_project bp on bai.project_id = bp.pro_id
WHERE sai.ma_id = #{maId}
ORDER BY sai.ID desc
limit 1
</select>
<select id="getListByCode" resultType="com.bonus.material.ma.domain.Machine">
SELECT
mm.ma_id as maId,
mt2.type_name as maName,
mt.type_name as maModel,
mm.ma_code as maCode,
mm.qr_code as qrCode,
mm.type_id as typeId,
sd.dict_label as maStatus,
mm.qr_code as qrCode,
mm.ma_vender as maVender,
mm.out_fac_time as outFacTime,
mm.out_fac_code as outFacCode,
mm.assets_code as assetsCode,
mm.check_man as checkMan,
mm.this_check_time as thisCheckTime,
mm.next_check_time as nextCheckTime,
mm.in_out_num as inOutNum
FROM
ma_machine mm
LEFT JOIN ma_type mt ON mt.type_id = mm.type_id
LEFT JOIN ma_type mt2 ON mt.parent_id = mt2.type_id
LEFT JOIN sys_dict_data sd on mm.ma_status = sd.dict_value and sd.dict_type = "ma_machine_status"
where 1=1
<if test="maCode != null">and mm.ma_code LIKE CONCAT('%',#{maCode},'%')</if>
<if test="maId != null">and mm.ma_id = #{maId}</if>
limit 100
</select>
</mapper>

View File

@ -0,0 +1,80 @@
<?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.material.push.mapper.AccProjectLeaseMoneyMapper">
<insert id="insertCalcRecord" useGeneratedKeys="true" keyProperty="id">
INSERT INTO calc_project_month (MONTH, create_time) VALUES (#{month}, now())
</insert>
<select id="getLeaseMoneyDetail" resultType="com.bonus.material.push.domain.AccProjectLeaseMoneyBean">
SELECT
res.id,
res.deviceName,
res.deviceModel,
res.modelId,
sum(res.leaseNum) as leaseNum,
res.startTime,
IF(DATEDIFF(res.endTime, res.sltTime) > 0,res.sltTime,res.endTime) as endTime ,
DATEDIFF(IF(DATEDIFF(res.endTime, res.sltTime) > 0,res.sltTime,res.endTime),res.startTime)+1 as leaseDay,
res.leasePrice,
sum(ROUND(res.leaseNum*res.leasePrice*(DATEDIFF(IF(DATEDIFF(res.endTime, res.sltTime) > 0,res.sltTime,res.endTime),res.startTime)+1),2)) as leaseMoney,
res.time
FROM
(
SELECT
sai.id,
sai.type_id as modelId,
mt2.name as deviceName,
mt1.name as deviceModel,
sai.num AS leaseNum,
IF(DATEDIFF(sai.start_time,#{startTime}) > 0,sai.start_time,#{startTime}) as startTime,
IF(DATEDIFF( #{endTime} ,ifnull(tt.CREATE_TIME,#{endTime})) > 0,tt.CREATE_TIME,#{endTime}) as endTime,
sai.slt_time as sltTime,
IFNULL( ROUND( mt1.lease_price, 2 ), 0.00 ) AS leasePrice,
tt.CREATE_TIME as time
FROM
slt_agreement_info sai
LEFT JOIN ma_type mt1 ON sai.type_id = mt1.type_id
LEFT JOIN ma_type mt2 ON mt1.parent_id = mt2.type_id
LEFT JOIN tm_task tt on sai..back_id = tt.task_id
WHERE
sai.agreement_id = #{agreementId} AND mt1.CONSUMABLE != 1
ORDER BY sai.type_id
)
res
group by res.modelId,
res.startTime,
res.endTime
HAVING leaseDay > 0
</select>
<insert id="insertProjectMonthInfo" parameterType="java.util.List">
insert into project_month_info (agreementId,typeId,leaseNum,leaseDate,returnDate,leasePrice,leaseMoney,
taskId,push_status,push_time,push_remark,is_flag,type,buy_price,money)
VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.leaseName},
#{item.typeId},
#{item.leaseNum},
#{item.leaseDate},
#{item.returnDate},
#{item.leasePrice},
#{item.leaseMoney},
#{item.taskId},
#{item.pushStatus},
#{item.pushTime},
#{item.pushRemark},
0,
1,
#{item.buyPrice},
#{item.money}
)
</foreach>
</insert>
</mapper>

View File

@ -0,0 +1,200 @@
<?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.material.push.mapper.ConsProjectLeaseMoneyMapper">
<select id="getRealtionList" resultType="com.bonus.material.push.domain.ConsProjectLeaseMoneyBean">
select
bai.agreement_id as agreementId
from bm_agreement_info bai
left join bm_unit bu on bai.unit_id = bu.unit_id
left join bm_project bp on bai.project_id = bp.pro_id
</select>
<select id="getConsMonthMoney" resultType="com.bonus.material.push.domain.ConsProjectLeaseMoneyBean">
SELECT
res.id,
res.deviceName,
res.deviceModel,
res.modelId,
sum(res.leaseNum) as leaseNum,
res.startTime,
res.buyPrice,
res.code,
sum(ROUND(res.leaseNum*res.buyPrice*res.type,2)) as leaseMoney,
res.time
FROM
(
SELECT
sai.id,
sai.type_id as modelId,
mt2.name as deviceName,
mt1.name as deviceModel,
sai.num AS leaseNum,
sai.start_time as startTime,
tt.CODE as code,
ROUND(IFNULL(mt1.NOTAX_PRICE,0) ,2) as buyPrice,
1 as type,
tt.CREATE_TIME as time
FROM
slt_agreement_info sai
LEFT JOIN ma_type mt1 ON sai.type_id = mt1.type_id
LEFT JOIN ma_type mt2 ON mt1.parent_id = mt2.type_id
LEFT JOIN tm_task tt on sai..back_id = tt.task_id
WHERE sai.agreement_id = #{agreementId} AND sai.start_time BETWEEN #{startTime} AND #{endTime} AND mt1.CONSUMABLE = 1 AND (ISNULL(sai.end_time) OR LEFT(sai.start_time,7) != LEFT(sai.end_time,7))
UNION
SELECT
sai.ID,
sai.type_id as modelId,
mt2.name as deviceName,
mt1.name as deviceModel,
sai.NUM AS leaseNum,
sai.start_time as startTime,
tt.CODE as code,
ROUND(IFNULL(mt1.NOTAX_PRICE,0) ,2) as buyPrice,
-1 as type,tt.CREATE_TIME as time
FROM
slt_agreement_info sai
LEFT JOIN ma_type mt1 ON sai.type_id = mt1.type_id
LEFT JOIN ma_type mt2 ON mt1.parent_id = mt2.type_id
LEFT JOIN tm_task tt on sai..back_id = tt.task_id
WHERE
sai.agreement_id = #{agreementId} AND sai.status = 1
AND sai.end_time BETWEEN #{startTime} AND #{endTime} AND mt1.CONSUMABLE = 1 AND LEFT(sai.start_time,7) != LEFT(sai.end_time,7) AND sai.start_time > '2024-01-01'
) res
group by res.modelId,
res.startTime,
res.code
</select>
<insert id="insertProjectConsMonthInfo" parameterType="java.util.List">
insert into project_month_info (agreementId,typeId,leaseNum,leaseDate,returnDate,leasePrice,leaseMoney,
taskId,push_status,push_time,push_remark,is_flag,type,buy_price,money)
VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.leaseName},
#{item.typeId},
#{item.leaseNum},
#{item.leaseDate},
#{item.returnDate},
#{item.leasePrice},
#{item.leaseMoney},
#{item.taskId},
#{item.pushStatus},
#{item.pushTime},
#{item.pushRemark},
0,
2,
#{item.buyPrice},
#{item.money}
)
</foreach>
</insert>
<select id="getScrapMoney" resultType="com.bonus.material.push.domain.ConsProjectLeaseMoneyBean">
select
sad.id as id,
sad.apply_id as applyId,
sad.type_id as typeId,
sad.ma_id as maId,
sad.num as leaseNum,
sad.start_time as startTime,
sad.end_time as endTime,
sad.price as leasePrice,
sad.money as leaseMoney
from slt_agreement_details sad
left join slt_agreement_apply saa on sad.apply_id = saa.id
where
saa.agreement_id = #{agreementId}
and sad.slt_type=4 and sad.is_charge = 1
</select>
<insert id="insertProjectOthersMonthInfo" parameterType="java.util.List">
insert into project_month_info (agreementId,typeId,leaseNum,leaseDate,returnDate,leasePrice,leaseMoney,
taskId,push_status,push_time,push_remark,is_flag,type,buy_price,money)
VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.leaseName},
#{item.typeId},
#{item.leaseNum},
#{item.leaseDate},
#{item.returnDate},
#{item.leasePrice},
#{item.leaseMoney},
#{item.taskId},
#{item.pushStatus},
#{item.pushTime},
#{item.pushRemark},
0,
#{item.type},
#{item.buyPrice},
#{item.money}
)
</foreach>
</insert>
<select id="getLostMoney" resultType="com.bonus.material.push.domain.ConsProjectLeaseMoneyBean">
select
sad.id as id,
sad.apply_id as applyId,
sad.type_id as typeId,
sad.ma_id as maId,
sad.num as leaseNum,
sad.start_time as startTime,
sad.end_time as endTime,
sad.price as leasePrice,
sad.money as leaseMoney
from slt_agreement_details sad
left join slt_agreement_apply saa on sad.apply_id = saa.id
where
saa.agreement_id = #{agreementId}
and sad.slt_type=2 and sad.is_charge = 1
</select>
<select id="getRepairMoney" resultType="com.bonus.material.push.domain.ConsProjectLeaseMoneyBean">
select
sad.id as id,
sad.apply_id as applyId,
sad.type_id as typeId,
sad.ma_id as maId,
sad.num as leaseNum,
sad.start_time as startTime,
sad.end_time as endTime,
sad.price as leasePrice,
sad.money as leaseMoney
from slt_agreement_details sad
left join slt_agreement_apply saa on sad.apply_id = saa.id
where
saa.agreement_id = #{agreementId}
and sad.slt_type=3 and sad.is_charge = 1
</select>
<insert id="insertProjectMonthCosts" parameterType="java.util.List">
insert into project_month_costs (agreement_id,lease_money,cons_money,scrap_money,
lost_money,repair_money,task_id,is_flag,month)
VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.agreementId},
#{item.leaseTotal},
#{item.consTotal},
#{item.scrapTotal},
#{item.lostTotal},
#{item.repairTotal},
#{item.taskId},
0,
#{item.month}
)
</foreach>
</insert>
</mapper>