结算导出领退料明细
This commit is contained in:
parent
2307a79659
commit
4065a867a4
|
|
@ -1,177 +1,183 @@
|
|||
<?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.cost.dao.ProjectCostDao">
|
||||
|
||||
<select id="queryProjectLeaseDetails" parameterType="com.bonus.cost.beans.ProjectLeaseCostDetail" resultType="com.bonus.cost.beans.ProjectLeaseCostDetail">
|
||||
SELECT
|
||||
wir.`CODE` AS machineCode,
|
||||
1 AS operateType,
|
||||
mt2.`NAME` AS machineTypeName,
|
||||
mt.`NAME` AS machineModel,mt.ID AS machineTypeId,
|
||||
mt.UNIT AS machineModel,
|
||||
mt.LEASE_PRICE AS price,
|
||||
mm.REMARK as remark,
|
||||
bu.`NAME` AS leaseUnit,
|
||||
bp.`NAME` AS projectName,
|
||||
wla.`CODE` AS taskCode,
|
||||
wtr1.NUMBER AS taskCode,
|
||||
ROUND(wir.num) AS leaseNum,
|
||||
wtr.OPERATION_TIME AS operateTime,
|
||||
wtr1.LEASE_PERSON AS operatePersonName,
|
||||
pmo. NAME AS companyName,
|
||||
pu.`NAME` as servicer,
|
||||
bs.`NAME` as bsName
|
||||
FROM wf_info_record wir
|
||||
LEFT JOIN wf_task_record wtr ON wir.SUP_ID = wtr.ID
|
||||
LEFT JOIN wf_task_record wtr1 ON wtr1.ID = wtr.SUP_ID
|
||||
LEFT JOIN wf_task_record wtr2 ON wtr2.ID = wtr1.SUP_ID
|
||||
LEFT JOIN wf_collar_apply wca ON wca.APPLY_NUMBER = wtr2.NUMBER
|
||||
LEFT JOIN bm_subcontractors bs ON wca.SUBCONTRACTORS_ID = bs.ID
|
||||
LEFT JOIN wf_agreement_task wat ON wtr.SUP_ID = wat.TASK_ID
|
||||
LEFT JOIN wf_lease_agreement wla ON wat.AGREEMENT_ID = wla.ID
|
||||
LEFT JOIN mm_type mt ON wir.MODEL_ID = mt.ID
|
||||
LEFT JOIN mm_type mt2 ON mt.PARENT_ID = mt2.ID
|
||||
LEFT JOIN bm_unit bu ON wla.LEASE_COMPANY = bu.id
|
||||
LEFT JOIN bm_project bp ON wla.PROJECT = bp.ID
|
||||
LEFT JOIN pm_organization pmo ON pmo.id = wtr.ORG_ID
|
||||
LEFT JOIN wf_ma_outstock wmo ON wir.SUP_ID = wmo.TASK_ID
|
||||
LEFT JOIN pm_user pu ON wmo.OUT_PERSON = pu.ID
|
||||
LEFT JOIN mm_machines mm ON mm.ID = wir.MA_ID
|
||||
WHERE wir.TYPE = 2
|
||||
and wtr.IS_ACTIVE = 1
|
||||
and wla.PROJECT = #{param.projectId}
|
||||
<if test="param.machineTypeId != null">
|
||||
and wir.MODEL_ID = #{param.machineTypeId}
|
||||
</if>
|
||||
<if test="param.endTime != null">
|
||||
<!-- 查询所有在统计结束时间之前的领料记录(包括统计期间开始之前的领料) -->
|
||||
and left(wtr.OPERATION_TIME,10) <= #{param.endTime}
|
||||
</if>
|
||||
<if test="param.keyWord != null and param.keyWord != ''">
|
||||
AND(
|
||||
mt2.`NAME` LIKE CONCAT('%',#{param.keyWord},'%') OR
|
||||
mt.`NAME` LIKE CONCAT('%',#{param.keyWord},'%') OR
|
||||
mt.UNIT LIKE CONCAT('%',#{param.keyWord},'%') OR
|
||||
bu.`NAME` LIKE CONCAT('%',#{param.keyWord},'%') OR
|
||||
bp.`NAME` LIKE CONCAT('%',#{param.keyWord},'%') OR
|
||||
wtr.OPERATION_TIME LIKE CONCAT('%',#{param.keyWord},'%') OR
|
||||
wtr.LEASE_PERSON LIKE CONCAT('%',#{param.keyWord},'%') OR
|
||||
wla.`CODE` LIKE CONCAT('%',#{param.keyWord},'%') OR
|
||||
wtr1.NUMBER LIKE CONCAT('%',#{param.keyWord},'%') OR
|
||||
pmo. NAME LIKE CONCAT('%',#{param.keyWord},'%')
|
||||
)
|
||||
</if>
|
||||
GROUP BY wir.SUP_ID,wir.MODEL_ID,wir.`CODE`
|
||||
</select>
|
||||
|
||||
<select id="queryProjectReturnDetails" resultType="com.bonus.cost.beans.ProjectLeaseCostDetail">
|
||||
SELECT DISTINCT
|
||||
wir.ID as id,wir.MODEL_ID as machineTypeId,wla.`CODE` AS agreementCode,bu.`NAME` AS leaseUnit,
|
||||
bp.`NAME` AS projectName,mmt.`NAME` as machineTypeName,mt.`NAME` as machineModel,mt.BUY_PRICE AS price,
|
||||
wtr.NUMBER AS taskCode,wir.`CODE` as machineCode,wir.TIME as operateTime,ROUND(wir.NUM) as returnNum,
|
||||
mt.IS_COUNT as isCount,wir.TYPE as type,pmo.`NAME` as companyName,wrd.OPERATOR as operatePersonName,
|
||||
mm.REMARK AS remark,bs.`NAME` as bsName,wir.RM_STATUS as rmStatus,2 AS operateType,mt.LEASE_PRICE AS price
|
||||
FROM wf_info_record wir
|
||||
LEFT JOIN wf_return_material_details wrd ON wir.SUP_ID = wrd.ID
|
||||
LEFT JOIN wf_task_record wtr ON wrd.TASK_ID = wtr.ID
|
||||
LEFT JOIN bm_subcontractors bs ON wtr.SUBCONTRACTORS_ID = bs.ID
|
||||
LEFT JOIN wf_agreement_task wat ON wtr.ID = wat.TASK_ID
|
||||
LEFT JOIN wf_lease_agreement wla ON wat.AGREEMENT_ID = wla.ID
|
||||
LEFT JOIN bm_unit bu ON wla.LEASE_COMPANY = bu.ID
|
||||
LEFT JOIN pm_organization pmo on wtr.ORG_ID = pmo.id
|
||||
LEFT JOIN bm_project bp ON wla.PROJECT = bp.ID
|
||||
LEFT JOIN pm_user pu ON wtr.CHECKER_ID = pu.ID
|
||||
LEFT JOIN mm_type mt ON wir.MODEL_ID = mt.ID
|
||||
LEFT JOIN mm_type mmt ON mt.PARENT_ID = mmt.ID
|
||||
LEFT JOIN mm_machines mm ON mm.ID = wir.MA_ID
|
||||
where
|
||||
wir.TYPE = 4 and wtr.IS_ACTIVE = 1 and wla.PROJECT = #{param.projectId}
|
||||
<if test="param.machineTypeId != null">
|
||||
and wir.MODEL_ID = #{param.machineTypeId}
|
||||
</if>
|
||||
<if test="param.endTime != null">
|
||||
<!-- 查询所有在统计结束时间之前的退料记录(包括统计期间开始之前的退料) -->
|
||||
and left(wir.TIME,10) <= #{param.endTime}
|
||||
</if>
|
||||
<if test="param.keyWord != null and param.keyWord != ''">
|
||||
and (
|
||||
bu.`NAME` like concat('%',#{param.keyWord},'%') OR
|
||||
pmo.`NAME` like concat('%',#{param.keyWord},'%') OR
|
||||
bp.`NAME` like concat('%',#{param.keyWord},'%') OR
|
||||
mmt.`NAME` like concat('%',#{param.keyWord},'%') OR
|
||||
mt.`NAME` like concat('%',#{param.keyWord},'%') OR
|
||||
wir.`CODE` like concat('%',#{param.keyWord},'%') OR
|
||||
wtr.NUMBER like concat('%',#{param.keyWord},'%') OR
|
||||
wla.`CODE` like concat('%',#{param.keyWord},'%')
|
||||
)
|
||||
</if>
|
||||
group by wir.ID
|
||||
</select>
|
||||
|
||||
<select id="saveSettlement" resultType="int">
|
||||
INSERT INTO wf_project_settlement(
|
||||
ID,
|
||||
PROJECT_ID,
|
||||
PROJECT_NAME,
|
||||
START_TIME,
|
||||
END_TIME,
|
||||
LEASE_COUNT,
|
||||
RETURN_COUNT,
|
||||
CREATE_TIME,
|
||||
CREATE_USER,
|
||||
DEL_FLAG
|
||||
) VALUES (
|
||||
#{id},
|
||||
#{projectId},
|
||||
#{projectName},
|
||||
#{startTime},
|
||||
#{endTime},
|
||||
#{leaseCount},
|
||||
#{returnCount},
|
||||
#{createTime},
|
||||
#{createUser},
|
||||
0
|
||||
)
|
||||
</select>
|
||||
|
||||
|
||||
<insert id="saveSettlementDetails" parameterType="java.util.List">
|
||||
insert into wf_project_settlement_details(
|
||||
ID,
|
||||
SETTLEMENT_ID,
|
||||
OPERATE_TYPE,
|
||||
MACHINE_TYPE_ID,
|
||||
MACHINE_TYPE_NAME,
|
||||
MACHINE_CODE,
|
||||
MACHINE_MODEL,
|
||||
MACHINE_UNIT,
|
||||
PRICE,
|
||||
LEASE_NUM,
|
||||
RETURN_NUM,
|
||||
LEASE_UNIT,
|
||||
OPERATE_PERSON_NAME,
|
||||
OPERATE_DATE,
|
||||
TASK_CODE
|
||||
) values
|
||||
<foreach collection="list" item="item" index="index" separator=",">
|
||||
(
|
||||
#{item.id},
|
||||
#{item.settlementId},
|
||||
#{item.operateType},
|
||||
#{item.machineTypeId},
|
||||
#{item.machineTypeName},
|
||||
#{item.machineCode},
|
||||
#{item.machineModel},
|
||||
#{item.machineUnit},
|
||||
#{item.price},
|
||||
#{item.leaseNum},
|
||||
#{item.returnNum},
|
||||
#{item.leaseUnit},
|
||||
#{item.operatePersonName},
|
||||
#{item.operateDate},
|
||||
#{item.taskCode}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
<?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.cost.dao.ProjectCostDao">
|
||||
|
||||
<select id="queryProjectLeaseDetails" parameterType="com.bonus.cost.beans.ProjectLeaseCostDetail" resultType="com.bonus.cost.beans.ProjectLeaseCostDetail">
|
||||
SELECT
|
||||
wir.`CODE` AS machineCode,
|
||||
1 AS operateType,
|
||||
mt2.`NAME` AS machineTypeName,
|
||||
mt.`NAME` AS machineModel,mt.ID AS machineTypeId,
|
||||
mt.UNIT AS machineUnit,
|
||||
mt3.`NAME` AS machineCodeName,
|
||||
mt.LEASE_PRICE AS price,
|
||||
mm.REMARK as remark,
|
||||
bu.`NAME` AS leaseUnit,
|
||||
bp.`NAME` AS projectName,
|
||||
wla.`CODE` AS taskCode,
|
||||
wtr1.NUMBER AS taskCode,
|
||||
ROUND(wir.num) AS leaseNum,
|
||||
wtr.OPERATION_TIME AS operateTime,
|
||||
wtr1.LEASE_PERSON AS operatePersonName,
|
||||
pmo. NAME AS companyName,
|
||||
pu.`NAME` as servicer,
|
||||
bs.`NAME` as bsName,
|
||||
mm.REMARK as oldMachineCode
|
||||
FROM wf_info_record wir
|
||||
LEFT JOIN wf_task_record wtr ON wir.SUP_ID = wtr.ID
|
||||
LEFT JOIN wf_task_record wtr1 ON wtr1.ID = wtr.SUP_ID
|
||||
LEFT JOIN wf_task_record wtr2 ON wtr2.ID = wtr1.SUP_ID
|
||||
LEFT JOIN wf_collar_apply wca ON wca.APPLY_NUMBER = wtr2.NUMBER
|
||||
LEFT JOIN bm_subcontractors bs ON wca.SUBCONTRACTORS_ID = bs.ID
|
||||
LEFT JOIN wf_agreement_task wat ON wtr.SUP_ID = wat.TASK_ID
|
||||
LEFT JOIN wf_lease_agreement wla ON wat.AGREEMENT_ID = wla.ID
|
||||
LEFT JOIN mm_type mt ON wir.MODEL_ID = mt.ID
|
||||
LEFT JOIN mm_type mt2 ON mt.PARENT_ID = mt2.ID
|
||||
LEFT JOIN mm_type mt3 ON mt2.PARENT_ID = mt3.ID
|
||||
LEFT JOIN bm_unit bu ON wla.LEASE_COMPANY = bu.id
|
||||
LEFT JOIN bm_project bp ON wla.PROJECT = bp.ID
|
||||
LEFT JOIN pm_organization pmo ON pmo.id = wtr.ORG_ID
|
||||
LEFT JOIN wf_ma_outstock wmo ON wir.SUP_ID = wmo.TASK_ID
|
||||
LEFT JOIN pm_user pu ON wmo.OUT_PERSON = pu.ID
|
||||
LEFT JOIN mm_machines mm ON mm.ID = wir.MA_ID
|
||||
WHERE wir.TYPE = 2
|
||||
and wtr.IS_ACTIVE = 1
|
||||
and wla.PROJECT = #{param.projectId}
|
||||
<if test="param.machineTypeId != null">
|
||||
and wir.MODEL_ID = #{param.machineTypeId}
|
||||
</if>
|
||||
<if test="param.endTime != null">
|
||||
<!-- 查询所有在统计结束时间之前的领料记录(包括统计期间开始之前的领料) -->
|
||||
and left(wtr.OPERATION_TIME,10) <= #{param.endTime}
|
||||
</if>
|
||||
<if test="param.keyWord != null and param.keyWord != ''">
|
||||
AND(
|
||||
mt2.`NAME` LIKE CONCAT('%',#{param.keyWord},'%') OR
|
||||
mt.`NAME` LIKE CONCAT('%',#{param.keyWord},'%') OR
|
||||
mt.UNIT LIKE CONCAT('%',#{param.keyWord},'%') OR
|
||||
bu.`NAME` LIKE CONCAT('%',#{param.keyWord},'%') OR
|
||||
bp.`NAME` LIKE CONCAT('%',#{param.keyWord},'%') OR
|
||||
wtr.OPERATION_TIME LIKE CONCAT('%',#{param.keyWord},'%') OR
|
||||
wtr.LEASE_PERSON LIKE CONCAT('%',#{param.keyWord},'%') OR
|
||||
wla.`CODE` LIKE CONCAT('%',#{param.keyWord},'%') OR
|
||||
wtr1.NUMBER LIKE CONCAT('%',#{param.keyWord},'%') OR
|
||||
pmo. NAME LIKE CONCAT('%',#{param.keyWord},'%')
|
||||
)
|
||||
</if>
|
||||
GROUP BY wir.SUP_ID,wir.MODEL_ID,wir.`CODE`
|
||||
</select>
|
||||
|
||||
<select id="queryProjectReturnDetails" resultType="com.bonus.cost.beans.ProjectLeaseCostDetail">
|
||||
SELECT DISTINCT
|
||||
wir.ID as id,wir.MODEL_ID as machineTypeId,wla.`CODE` AS agreementCode,bu.`NAME` AS leaseUnit,
|
||||
bp.`NAME` AS projectName,mmt.`NAME` as machineTypeName,mt.`NAME` as machineModel,mt.BUY_PRICE AS price,
|
||||
mt.UNIT AS machineUnit,mt.ID AS machineTypeId,
|
||||
wtr.NUMBER AS taskCode,wir.`CODE` as machineCode,wir.TIME as operateTime,ROUND(wir.NUM) as returnNum,
|
||||
mt.IS_COUNT as isCount,wir.TYPE as type,pmo.`NAME` as companyName,wrd.OPERATOR as operatePersonName,
|
||||
mm.REMARK AS remark,bs.`NAME` as bsName,wir.RM_STATUS as rmStatus,2 AS operateType,mt.LEASE_PRICE AS price,
|
||||
mt3.`NAME` AS machineCodeName,mm.REMARK as oldMachineCode
|
||||
FROM wf_info_record wir
|
||||
LEFT JOIN wf_return_material_details wrd ON wir.SUP_ID = wrd.ID
|
||||
LEFT JOIN wf_task_record wtr ON wrd.TASK_ID = wtr.ID
|
||||
LEFT JOIN bm_subcontractors bs ON wtr.SUBCONTRACTORS_ID = bs.ID
|
||||
LEFT JOIN wf_agreement_task wat ON wtr.ID = wat.TASK_ID
|
||||
LEFT JOIN wf_lease_agreement wla ON wat.AGREEMENT_ID = wla.ID
|
||||
LEFT JOIN bm_unit bu ON wla.LEASE_COMPANY = bu.ID
|
||||
LEFT JOIN pm_organization pmo on wtr.ORG_ID = pmo.id
|
||||
LEFT JOIN bm_project bp ON wla.PROJECT = bp.ID
|
||||
LEFT JOIN pm_user pu ON wtr.CHECKER_ID = pu.ID
|
||||
LEFT JOIN mm_type mt ON wir.MODEL_ID = mt.ID
|
||||
LEFT JOIN mm_type mmt ON mt.PARENT_ID = mmt.ID
|
||||
LEFT JOIN mm_type mt3 ON mmt.PARENT_ID = mt3.ID
|
||||
LEFT JOIN mm_machines mm ON mm.ID = wir.MA_ID
|
||||
where
|
||||
wir.TYPE = 4 and wtr.IS_ACTIVE = 1 and wla.PROJECT = #{param.projectId}
|
||||
<if test="param.machineTypeId != null">
|
||||
and wir.MODEL_ID = #{param.machineTypeId}
|
||||
</if>
|
||||
<if test="param.endTime != null">
|
||||
<!-- 查询所有在统计结束时间之前的退料记录(包括统计期间开始之前的退料) -->
|
||||
and left(wir.TIME,10) <= #{param.endTime}
|
||||
</if>
|
||||
<if test="param.keyWord != null and param.keyWord != ''">
|
||||
and (
|
||||
bu.`NAME` like concat('%',#{param.keyWord},'%') OR
|
||||
pmo.`NAME` like concat('%',#{param.keyWord},'%') OR
|
||||
bp.`NAME` like concat('%',#{param.keyWord},'%') OR
|
||||
mmt.`NAME` like concat('%',#{param.keyWord},'%') OR
|
||||
mt.`NAME` like concat('%',#{param.keyWord},'%') OR
|
||||
wir.`CODE` like concat('%',#{param.keyWord},'%') OR
|
||||
wtr.NUMBER like concat('%',#{param.keyWord},'%') OR
|
||||
wla.`CODE` like concat('%',#{param.keyWord},'%')
|
||||
)
|
||||
</if>
|
||||
group by wir.ID
|
||||
</select>
|
||||
|
||||
<select id="saveSettlement" resultType="int">
|
||||
INSERT INTO wf_project_settlement(
|
||||
ID,
|
||||
PROJECT_ID,
|
||||
PROJECT_NAME,
|
||||
START_TIME,
|
||||
END_TIME,
|
||||
LEASE_COUNT,
|
||||
RETURN_COUNT,
|
||||
CREATE_TIME,
|
||||
CREATE_USER,
|
||||
DEL_FLAG
|
||||
) VALUES (
|
||||
#{id},
|
||||
#{projectId},
|
||||
#{projectName},
|
||||
#{startTime},
|
||||
#{endTime},
|
||||
#{leaseCount},
|
||||
#{returnCount},
|
||||
#{createTime},
|
||||
#{createUser},
|
||||
0
|
||||
)
|
||||
</select>
|
||||
|
||||
|
||||
<insert id="saveSettlementDetails" parameterType="java.util.List">
|
||||
insert into wf_project_settlement_details(
|
||||
ID,
|
||||
SETTLEMENT_ID,
|
||||
OPERATE_TYPE,
|
||||
MACHINE_TYPE_ID,
|
||||
MACHINE_TYPE_NAME,
|
||||
MACHINE_CODE,
|
||||
MACHINE_MODEL,
|
||||
MACHINE_UNIT,
|
||||
PRICE,
|
||||
LEASE_NUM,
|
||||
RETURN_NUM,
|
||||
LEASE_UNIT,
|
||||
OPERATE_PERSON_NAME,
|
||||
OPERATE_DATE,
|
||||
TASK_CODE
|
||||
) values
|
||||
<foreach collection="list" item="item" index="index" separator=",">
|
||||
(
|
||||
#{item.id},
|
||||
#{item.settlementId},
|
||||
#{item.operateType},
|
||||
#{item.machineTypeId},
|
||||
#{item.machineTypeName},
|
||||
#{item.machineCode},
|
||||
#{item.machineModel},
|
||||
#{item.machineUnit},
|
||||
#{item.price},
|
||||
#{item.leaseNum},
|
||||
#{item.returnNum},
|
||||
#{item.leaseUnit},
|
||||
#{item.operatePersonName},
|
||||
#{item.operateDate},
|
||||
#{item.taskCode}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
|
|
|
|||
|
|
@ -1,327 +1,416 @@
|
|||
package com.bonus.cost.beans;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 工程领退物资明细实体类
|
||||
*
|
||||
* @author syruan
|
||||
*/
|
||||
public class ProjectLeaseCostDetail {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 机具名称
|
||||
*/
|
||||
private String machineName;
|
||||
|
||||
/**
|
||||
* 机具类型名称
|
||||
*/
|
||||
private String machineTypeName;
|
||||
|
||||
/**
|
||||
* 机具类型ID
|
||||
*/
|
||||
private Integer machineTypeId;
|
||||
|
||||
/**
|
||||
* 机具规格
|
||||
*/
|
||||
private String machineModel;
|
||||
|
||||
/**
|
||||
* 租赁单价/天
|
||||
*/
|
||||
private Double price;
|
||||
|
||||
/**
|
||||
* 物资单位
|
||||
*/
|
||||
private String machineUnit;
|
||||
|
||||
/**
|
||||
* 设备编码
|
||||
*/
|
||||
private String machineCode;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 协议号
|
||||
*/
|
||||
private String protocolNumber;
|
||||
|
||||
/**
|
||||
* 任务单号
|
||||
*/
|
||||
private String taskCode;
|
||||
|
||||
/**
|
||||
* 工程名称
|
||||
*/
|
||||
private String projectName;
|
||||
|
||||
/**
|
||||
* 工程ID
|
||||
*/
|
||||
private String projectId;
|
||||
|
||||
/**
|
||||
* 领料单位
|
||||
*/
|
||||
private String leaseUnit;
|
||||
|
||||
/**
|
||||
* 操作类型(1领料 2退料)
|
||||
*/
|
||||
private Byte operateType;
|
||||
|
||||
/**
|
||||
* 是否数量管理(0编码管理 1数量管理)
|
||||
*/
|
||||
private Byte isCount;
|
||||
|
||||
/**
|
||||
* 领料数量
|
||||
*/
|
||||
private Integer leaseNum;
|
||||
|
||||
/**
|
||||
* 退料数量
|
||||
*/
|
||||
private Integer returnNum;
|
||||
|
||||
/**
|
||||
* 操作人员名称
|
||||
*/
|
||||
private String operatePersonName;
|
||||
|
||||
/**
|
||||
* 操作日期
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||
private String operateDate;
|
||||
|
||||
/**
|
||||
* 操作时间 注意:数据库字段为varchar类型,需要自定义转换逻辑 格式应为"yyyy-MM-dd HH:mm:ss"
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private String operateTime;
|
||||
|
||||
/**
|
||||
* 查询开始时间
|
||||
*/
|
||||
private String startTime;
|
||||
|
||||
/**
|
||||
* 查询结束时间
|
||||
*/
|
||||
private String endTime;
|
||||
|
||||
/**
|
||||
* 查询关键字
|
||||
*/
|
||||
private Map<String, Object> keyWord;
|
||||
|
||||
public Map<String, Object> getKeyWord() {
|
||||
return keyWord;
|
||||
}
|
||||
|
||||
public void setKeyWord(Map<String, Object> keyWord) {
|
||||
this.keyWord = keyWord;
|
||||
}
|
||||
|
||||
public Double getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(Double price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public Integer getMachineTypeId() {
|
||||
return machineTypeId;
|
||||
}
|
||||
|
||||
public void setMachineTypeId(Integer machineTypeId) {
|
||||
this.machineTypeId = machineTypeId;
|
||||
}
|
||||
|
||||
public Byte getIsCount() {
|
||||
return isCount;
|
||||
}
|
||||
|
||||
public void setIsCount(Byte isCount) {
|
||||
this.isCount = isCount;
|
||||
}
|
||||
|
||||
public String getMachineUnit() {
|
||||
return machineUnit;
|
||||
}
|
||||
|
||||
public void setMachineUnit(String machineUnit) {
|
||||
this.machineUnit = machineUnit;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Byte getOperateType() {
|
||||
return operateType;
|
||||
}
|
||||
|
||||
public void setOperateType(Byte operateType) {
|
||||
this.operateType = operateType;
|
||||
}
|
||||
|
||||
public String getMachineName() {
|
||||
return machineName;
|
||||
}
|
||||
|
||||
public void setMachineName(String machineName) {
|
||||
this.machineName = machineName;
|
||||
}
|
||||
|
||||
public Integer getReturnNum() {
|
||||
return returnNum;
|
||||
}
|
||||
|
||||
public void setReturnNum(Integer returnNum) {
|
||||
this.returnNum = returnNum;
|
||||
}
|
||||
|
||||
public String getMachineModel() {
|
||||
return machineModel;
|
||||
}
|
||||
|
||||
public void setMachineModel(String machineModel) {
|
||||
this.machineModel = machineModel;
|
||||
}
|
||||
|
||||
public String getMachineCode() {
|
||||
return machineCode;
|
||||
}
|
||||
|
||||
public void setMachineCode(String machineCode) {
|
||||
this.machineCode = machineCode;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public String getProtocolNumber() {
|
||||
return protocolNumber;
|
||||
}
|
||||
|
||||
public void setProtocolNumber(String protocolNumber) {
|
||||
this.protocolNumber = protocolNumber;
|
||||
}
|
||||
|
||||
public String getProjectName() {
|
||||
return projectName;
|
||||
}
|
||||
|
||||
public void setProjectName(String projectName) {
|
||||
this.projectName = projectName;
|
||||
}
|
||||
|
||||
public String getProjectId() {
|
||||
return projectId;
|
||||
}
|
||||
|
||||
public void setProjectId(String projectId) {
|
||||
this.projectId = projectId;
|
||||
}
|
||||
|
||||
public String getLeaseUnit() {
|
||||
return leaseUnit;
|
||||
}
|
||||
|
||||
public void setLeaseUnit(String leaseUnit) {
|
||||
this.leaseUnit = leaseUnit;
|
||||
}
|
||||
|
||||
public Integer getLeaseNum() {
|
||||
return leaseNum;
|
||||
}
|
||||
|
||||
public void setLeaseNum(Integer leaseNum) {
|
||||
this.leaseNum = leaseNum;
|
||||
}
|
||||
|
||||
public String getOperatePersonName() {
|
||||
return operatePersonName;
|
||||
}
|
||||
|
||||
public void setOperatePersonName(String operatePersonName) {
|
||||
this.operatePersonName = operatePersonName;
|
||||
}
|
||||
|
||||
public String getOperateDate() {
|
||||
return operateDate;
|
||||
}
|
||||
|
||||
public void setOperateDate(String operateDate) {
|
||||
this.operateDate = operateDate;
|
||||
}
|
||||
|
||||
public String getTaskCode() {
|
||||
return taskCode;
|
||||
}
|
||||
|
||||
public void setTaskCode(String taskCode) {
|
||||
this.taskCode = taskCode;
|
||||
}
|
||||
|
||||
public String getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public void setEndTime(String endTime) {
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
public String getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setStartTime(String startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public String getOperateTime() {
|
||||
return operateTime;
|
||||
}
|
||||
|
||||
public void setOperateTime(String operateTime) {
|
||||
this.operateTime = operateTime;
|
||||
}
|
||||
|
||||
public String getMachineTypeName() {
|
||||
return machineTypeName;
|
||||
}
|
||||
|
||||
public void setMachineTypeName(String machineTypeName) {
|
||||
this.machineTypeName = machineTypeName;
|
||||
}
|
||||
}
|
||||
package com.bonus.cost.beans;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 工程领退物资明细实体类
|
||||
*
|
||||
* @author syruan
|
||||
*/
|
||||
public class ProjectLeaseCostDetail {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 机具名称
|
||||
*/
|
||||
private String machineName;
|
||||
|
||||
/**
|
||||
* 机具类别
|
||||
*/
|
||||
private String machineCodeName;
|
||||
|
||||
/**
|
||||
* 机具类型名称
|
||||
*/
|
||||
private String machineTypeName;
|
||||
|
||||
/**
|
||||
* 机具类型ID
|
||||
*/
|
||||
private Integer machineTypeId;
|
||||
|
||||
/**
|
||||
* 机具规格
|
||||
*/
|
||||
private String machineModel;
|
||||
|
||||
/**
|
||||
* 租赁单价/天
|
||||
*/
|
||||
private Double price;
|
||||
|
||||
/**
|
||||
* 物资单位
|
||||
*/
|
||||
private String machineUnit;
|
||||
|
||||
/**
|
||||
* 设备编码
|
||||
*/
|
||||
private String machineCode;
|
||||
|
||||
private String oldMachineCode;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 协议号
|
||||
*/
|
||||
private String protocolNumber;
|
||||
|
||||
/**
|
||||
* 任务单号
|
||||
*/
|
||||
private String taskCode;
|
||||
|
||||
/**
|
||||
* 工程名称
|
||||
*/
|
||||
private String projectName;
|
||||
|
||||
/**
|
||||
* 工程ID
|
||||
*/
|
||||
private String projectId;
|
||||
|
||||
/**
|
||||
* 领料单位
|
||||
*/
|
||||
private String leaseUnit;
|
||||
|
||||
/**
|
||||
* 操作类型(1领料 2退料)
|
||||
*/
|
||||
private Byte operateType;
|
||||
|
||||
/**
|
||||
* 是否数量管理(0编码管理 1数量管理)
|
||||
*/
|
||||
private Byte isCount;
|
||||
|
||||
/**
|
||||
* 领料数量
|
||||
*/
|
||||
private Integer leaseNum;
|
||||
|
||||
/**
|
||||
* 退料数量
|
||||
*/
|
||||
private Integer returnNum;
|
||||
|
||||
/**
|
||||
* 操作人员名称
|
||||
*/
|
||||
private String operatePersonName;
|
||||
|
||||
/**
|
||||
* 累计领料数量
|
||||
*/
|
||||
private BigDecimal totalLeaseQuantity;
|
||||
|
||||
/**
|
||||
* 累计退料数量
|
||||
*/
|
||||
private BigDecimal totalReturnQuantity;
|
||||
|
||||
/**
|
||||
* 领退料差额
|
||||
*/
|
||||
private BigDecimal differenceQuantity;
|
||||
|
||||
/**
|
||||
* 操作日期
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||
private String operateDate;
|
||||
|
||||
/**
|
||||
* 操作时间 注意:数据库字段为varchar类型,需要自定义转换逻辑 格式应为"yyyy-MM-dd HH:mm:ss"
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private String operateTime;
|
||||
|
||||
/**
|
||||
* 查询开始时间
|
||||
*/
|
||||
private String startTime;
|
||||
|
||||
/**
|
||||
* 查询结束时间
|
||||
*/
|
||||
private String endTime;
|
||||
|
||||
/**
|
||||
* 租赁单位
|
||||
*/
|
||||
private String bsName;
|
||||
|
||||
/**
|
||||
* 序号(第几次领料)
|
||||
*/
|
||||
private Integer sequence;
|
||||
|
||||
/**
|
||||
* 查询关键字
|
||||
*/
|
||||
private Map<String, Object> keyWord;
|
||||
|
||||
public Map<String, Object> getKeyWord() {
|
||||
return keyWord;
|
||||
}
|
||||
|
||||
public void setKeyWord(Map<String, Object> keyWord) {
|
||||
this.keyWord = keyWord;
|
||||
}
|
||||
|
||||
public Double getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(Double price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public Integer getMachineTypeId() {
|
||||
return machineTypeId;
|
||||
}
|
||||
|
||||
public void setMachineTypeId(Integer machineTypeId) {
|
||||
this.machineTypeId = machineTypeId;
|
||||
}
|
||||
|
||||
public Byte getIsCount() {
|
||||
return isCount;
|
||||
}
|
||||
|
||||
public void setIsCount(Byte isCount) {
|
||||
this.isCount = isCount;
|
||||
}
|
||||
|
||||
public String getMachineUnit() {
|
||||
return machineUnit;
|
||||
}
|
||||
|
||||
public void setMachineUnit(String machineUnit) {
|
||||
this.machineUnit = machineUnit;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Byte getOperateType() {
|
||||
return operateType;
|
||||
}
|
||||
|
||||
public void setOperateType(Byte operateType) {
|
||||
this.operateType = operateType;
|
||||
}
|
||||
|
||||
public String getMachineName() {
|
||||
return machineName;
|
||||
}
|
||||
|
||||
public void setMachineName(String machineName) {
|
||||
this.machineName = machineName;
|
||||
}
|
||||
|
||||
public Integer getReturnNum() {
|
||||
return returnNum;
|
||||
}
|
||||
|
||||
public void setReturnNum(Integer returnNum) {
|
||||
this.returnNum = returnNum;
|
||||
}
|
||||
|
||||
public String getMachineModel() {
|
||||
return machineModel;
|
||||
}
|
||||
|
||||
public void setMachineModel(String machineModel) {
|
||||
this.machineModel = machineModel;
|
||||
}
|
||||
|
||||
public String getMachineCode() {
|
||||
return machineCode;
|
||||
}
|
||||
|
||||
public void setMachineCode(String machineCode) {
|
||||
this.machineCode = machineCode;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public String getProtocolNumber() {
|
||||
return protocolNumber;
|
||||
}
|
||||
|
||||
public void setProtocolNumber(String protocolNumber) {
|
||||
this.protocolNumber = protocolNumber;
|
||||
}
|
||||
|
||||
public String getProjectName() {
|
||||
return projectName;
|
||||
}
|
||||
|
||||
public void setProjectName(String projectName) {
|
||||
this.projectName = projectName;
|
||||
}
|
||||
|
||||
public String getProjectId() {
|
||||
return projectId;
|
||||
}
|
||||
|
||||
public void setProjectId(String projectId) {
|
||||
this.projectId = projectId;
|
||||
}
|
||||
|
||||
public String getLeaseUnit() {
|
||||
return leaseUnit;
|
||||
}
|
||||
|
||||
public void setLeaseUnit(String leaseUnit) {
|
||||
this.leaseUnit = leaseUnit;
|
||||
}
|
||||
|
||||
public Integer getLeaseNum() {
|
||||
return leaseNum;
|
||||
}
|
||||
|
||||
public void setLeaseNum(Integer leaseNum) {
|
||||
this.leaseNum = leaseNum;
|
||||
}
|
||||
|
||||
public String getOperatePersonName() {
|
||||
return operatePersonName;
|
||||
}
|
||||
|
||||
public void setOperatePersonName(String operatePersonName) {
|
||||
this.operatePersonName = operatePersonName;
|
||||
}
|
||||
|
||||
public String getOperateDate() {
|
||||
return operateDate;
|
||||
}
|
||||
|
||||
public void setOperateDate(String operateDate) {
|
||||
this.operateDate = operateDate;
|
||||
}
|
||||
|
||||
public String getTaskCode() {
|
||||
return taskCode;
|
||||
}
|
||||
|
||||
public void setTaskCode(String taskCode) {
|
||||
this.taskCode = taskCode;
|
||||
}
|
||||
|
||||
public String getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public void setEndTime(String endTime) {
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
public String getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setStartTime(String startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public String getOperateTime() {
|
||||
return operateTime;
|
||||
}
|
||||
|
||||
public void setOperateTime(String operateTime) {
|
||||
this.operateTime = operateTime;
|
||||
}
|
||||
|
||||
public String getMachineTypeName() {
|
||||
return machineTypeName;
|
||||
}
|
||||
|
||||
public void setMachineTypeName(String machineTypeName) {
|
||||
this.machineTypeName = machineTypeName;
|
||||
}
|
||||
|
||||
public String getOldMachineCode() {
|
||||
return oldMachineCode;
|
||||
}
|
||||
|
||||
public void setOldMachineCode(String oldMachineCode) {
|
||||
this.oldMachineCode = oldMachineCode;
|
||||
}
|
||||
|
||||
public String getBsName() {
|
||||
return bsName;
|
||||
}
|
||||
|
||||
public void setBsName(String bsName) {
|
||||
this.bsName = bsName;
|
||||
}
|
||||
|
||||
public String getMachineCodeName() {
|
||||
return machineCodeName;
|
||||
}
|
||||
|
||||
public void setMachineCodeName(String machineCodeName) {
|
||||
this.machineCodeName = machineCodeName;
|
||||
}
|
||||
|
||||
public Integer getSequence() {
|
||||
return sequence;
|
||||
}
|
||||
|
||||
public void setSequence(Integer sequence) {
|
||||
this.sequence = sequence;
|
||||
}
|
||||
|
||||
public BigDecimal getTotalLeaseQuantity() {
|
||||
return totalLeaseQuantity;
|
||||
}
|
||||
|
||||
public void setTotalLeaseQuantity(BigDecimal totalLeaseQuantity) {
|
||||
this.totalLeaseQuantity = totalLeaseQuantity;
|
||||
}
|
||||
|
||||
public BigDecimal getTotalReturnQuantity() {
|
||||
return totalReturnQuantity;
|
||||
}
|
||||
|
||||
public void setTotalReturnQuantity(BigDecimal totalReturnQuantity) {
|
||||
this.totalReturnQuantity = totalReturnQuantity;
|
||||
}
|
||||
|
||||
public BigDecimal getDifferenceQuantity() {
|
||||
return differenceQuantity;
|
||||
}
|
||||
|
||||
public void setDifferenceQuantity(BigDecimal differenceQuantity) {
|
||||
this.differenceQuantity = differenceQuantity;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,11 +21,14 @@ import org.apache.poi.hssf.usermodel.HSSFSheet;
|
|||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.math.BigDecimal;
|
||||
import java.net.URLEncoder;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
|
@ -50,7 +53,7 @@ public class ProjectCostServiceImpl implements ProjectCostService {
|
|||
|
||||
/**
|
||||
* 安全转换为Double类型
|
||||
*
|
||||
*
|
||||
* @param obj 要转换的对象
|
||||
* @param defaultValue 默认值
|
||||
* @return 转换后的Double值
|
||||
|
|
@ -84,7 +87,7 @@ public class ProjectCostServiceImpl implements ProjectCostService {
|
|||
|
||||
/**
|
||||
* 安全转换为Integer类型
|
||||
*
|
||||
*
|
||||
* @param obj 要转换的对象
|
||||
* @param defaultValue 默认值
|
||||
* @return 转换后的Integer值
|
||||
|
|
@ -344,7 +347,7 @@ public class ProjectCostServiceImpl implements ProjectCostService {
|
|||
LocalDateTime endtime = LocalDateTime.parse("2025-05-26 14:21:00", formatter);
|
||||
long daysBetween = java.time.Duration.between(operateTime, endtime).toDays();
|
||||
System.err.println(daysBetween);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -431,9 +434,6 @@ public class ProjectCostServiceImpl implements ProjectCostService {
|
|||
for (Map.Entry<String, List<ProjectLeaseCostDetail>> entry : groupedByMachineType.entrySet()) {
|
||||
String machineTypeId = entry.getKey();
|
||||
List<ProjectLeaseCostDetail> items = entry.getValue();
|
||||
if("531".equals(machineTypeId)) {
|
||||
System.err.println(machineTypeId);
|
||||
}
|
||||
// 按操作时间排序
|
||||
items.sort(Comparator.comparing(ProjectLeaseCostDetail::getOperateTime,
|
||||
Comparator.nullsFirst(Comparator.naturalOrder())));
|
||||
|
|
@ -500,7 +500,7 @@ public class ProjectCostServiceImpl implements ProjectCostService {
|
|||
// 如果统计期间内没有操作,计算从开始时间到结束时间的费用
|
||||
LocalDateTime endTimeForInitialSegment = firstOperateTimeInPeriod != null ? firstOperateTimeInPeriod : endDate;
|
||||
long daysBetween = getDay(startDate, endTimeForInitialSegment);
|
||||
|
||||
|
||||
LocalDateTime lastTimes = LocalDateTime.parse(o.getEndTime()+" 23:59:59", formatter);
|
||||
if(lastTimes.equals(endTimeForInitialSegment)) {
|
||||
daysBetween+=1;
|
||||
|
|
@ -562,8 +562,8 @@ public class ProjectCostServiceImpl implements ProjectCostService {
|
|||
if (daysBetween < 1) {
|
||||
daysBetween = 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// 计算该时间段的租赁费用
|
||||
double segmentAmount = currentCount * unitPrice * daysBetween;
|
||||
totalItemAmount += segmentAmount;
|
||||
|
|
@ -706,14 +706,14 @@ public class ProjectCostServiceImpl implements ProjectCostService {
|
|||
result.put("totalAmount", totalAmount); // 总金额
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public long getDay(LocalDateTime operateTime,LocalDateTime endtime) {
|
||||
LocalDate startDate = operateTime.toLocalDate();
|
||||
LocalDate endDate = endtime.toLocalDate();
|
||||
long naturalDays = ChronoUnit.DAYS.between(startDate, endDate);
|
||||
System.out.println("自然日天数差(正确结果):" + naturalDays);
|
||||
System.out.println("自然日天数差(正确结果):" + naturalDays);
|
||||
return naturalDays;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -848,7 +848,8 @@ public class ProjectCostServiceImpl implements ProjectCostService {
|
|||
// 合并领料和退料记录
|
||||
List<ProjectLeaseCostDetail> leaseDetails = queryProjectLeaseDetails(queryParam);
|
||||
List<ProjectLeaseCostDetail> returnDetails = queryProjectReturnDetails(queryParam);
|
||||
|
||||
//计算差额
|
||||
calculateMaterialDifference(leaseDetails, returnDetails);
|
||||
List<ProjectLeaseCostDetail> allDetails = new ArrayList<>();
|
||||
if (leaseDetails != null) {
|
||||
allDetails.addAll(leaseDetails);
|
||||
|
|
@ -927,10 +928,99 @@ public class ProjectCostServiceImpl implements ProjectCostService {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return calculation;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算领退料差额
|
||||
* @param leaseDetails 领料明细列表
|
||||
* @param returnDetails 退料明细列表
|
||||
* @return 计算后的领料明细列表(包含差额)
|
||||
*/
|
||||
public List<ProjectLeaseCostDetail> calculateMaterialDifference(
|
||||
List<ProjectLeaseCostDetail> leaseDetails,
|
||||
List<ProjectLeaseCostDetail> returnDetails) {
|
||||
|
||||
// 1. 按物料类型分组领料数据
|
||||
Map<Integer, List<ProjectLeaseCostDetail>> leaseByMaterial =
|
||||
leaseDetails.stream()
|
||||
.sorted(Comparator.comparing(ProjectLeaseCostDetail::getOperateTime))
|
||||
.collect(Collectors.groupingBy(
|
||||
ProjectLeaseCostDetail::getMachineTypeId,
|
||||
LinkedHashMap::new, // 保持顺序
|
||||
Collectors.toList()
|
||||
));
|
||||
|
||||
// 2. 按物料类型分组退料数据
|
||||
Map<Integer, List<ProjectLeaseCostDetail>> returnByMaterial =
|
||||
returnDetails.stream()
|
||||
.sorted(Comparator.comparing(ProjectLeaseCostDetail::getOperateTime))
|
||||
.collect(Collectors.groupingBy(
|
||||
ProjectLeaseCostDetail::getMachineTypeId,
|
||||
LinkedHashMap::new,
|
||||
Collectors.toList()
|
||||
));
|
||||
|
||||
// 3. 处理每个物料类型
|
||||
List<ProjectLeaseCostDetail> result = new ArrayList<>();
|
||||
|
||||
for (Map.Entry<Integer, List<ProjectLeaseCostDetail>> entry : leaseByMaterial.entrySet()) {
|
||||
Integer materialType = entry.getKey();
|
||||
List<ProjectLeaseCostDetail> materialLeases = entry.getValue();
|
||||
List<ProjectLeaseCostDetail> materialReturns =
|
||||
returnByMaterial.getOrDefault(materialType, new ArrayList<>());
|
||||
|
||||
// 计算该物料的累计差额
|
||||
List<ProjectLeaseCostDetail> calculated =
|
||||
calculateForSingleMaterial(materialLeases, materialReturns);
|
||||
|
||||
result.addAll(calculated);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算单个物料的领退料差额
|
||||
*/
|
||||
private List<ProjectLeaseCostDetail> calculateForSingleMaterial(
|
||||
List<ProjectLeaseCostDetail> leases,
|
||||
List<ProjectLeaseCostDetail> returns) {
|
||||
|
||||
List<ProjectLeaseCostDetail> result = new ArrayList<>();
|
||||
|
||||
// 初始化累计量
|
||||
BigDecimal totalReturn = BigDecimal.ZERO;
|
||||
|
||||
// 累计退料
|
||||
for (ProjectLeaseCostDetail detail : returns) {
|
||||
BigDecimal returnQty = detail.getReturnNum() != null ?
|
||||
BigDecimal.valueOf(detail.getReturnNum()) : BigDecimal.ZERO;
|
||||
totalReturn = totalReturn.add(returnQty);
|
||||
}
|
||||
|
||||
// 按时间顺序处理每次领料
|
||||
for (ProjectLeaseCostDetail lease : leases) {
|
||||
|
||||
//比较当前退料数量和领料数量
|
||||
if(BigDecimal.valueOf(lease.getLeaseNum()).compareTo(totalReturn)>=0){
|
||||
lease.setDifferenceQuantity(BigDecimal.valueOf(lease.getLeaseNum()).subtract(totalReturn));
|
||||
totalReturn = BigDecimal.ZERO;
|
||||
}else {
|
||||
lease.setDifferenceQuantity(BigDecimal.ZERO);
|
||||
//获取剩余的退料数量
|
||||
totalReturn = totalReturn.subtract(BigDecimal.valueOf(lease.getLeaseNum()));
|
||||
}
|
||||
|
||||
result.add(lease);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean deleteCalculation(Integer id) {
|
||||
return projectCostDao.deleteCalculation(id) > 0;
|
||||
|
|
@ -938,7 +1028,7 @@ public class ProjectCostServiceImpl implements ProjectCostService {
|
|||
|
||||
/**
|
||||
* 封装导出Excel的方法,适用于只有HttpServletResponse的情况
|
||||
*
|
||||
*
|
||||
* @param fileName 文件名
|
||||
* @param sheetName sheet名称
|
||||
* @param headers 表头
|
||||
|
|
@ -1781,46 +1871,106 @@ public class ProjectCostServiceImpl implements ProjectCostService {
|
|||
|
||||
// 准备Excel数据
|
||||
String fileName = "领退记录表_" + calculation.getProjectName() + "_" + calculation.getId() + ".xls";
|
||||
String sheetName = "领退记录表";
|
||||
String sheetName = "领用、差缺明细表";
|
||||
String sheetName2 = "退料明细表";
|
||||
|
||||
// 表头 - 增加规格型号字段
|
||||
String[] headers = { "序号", "物资类型", "规格型号", "操作类型", "操作时间", "数量", "单位", "操作人", "任务编号" };
|
||||
/*String[] headers = { "序号", "物资类型", "规格型号", "操作类型", "操作时间", "数量", "单位", "操作人", "任务编号" };*/
|
||||
String[] headers = { "领料日期", "工程名称", "库房", "类别", "机具设备名称", "规格型号", "编码",
|
||||
"新编码", "单位", "数量", "差额", "租赁单位", "备注" };
|
||||
String[] headers2 = { "退料工程名称", "退料单位", "退料日期", "库房", "类别", "机具设备名称", "规格",
|
||||
"编号", "单位", "数量", "备注" };
|
||||
// 列宽 - 添加规格型号列宽
|
||||
int[] widths = { 256 * 5, 256 * 15, 256 * 15, 256 * 10, 256 * 18, 256 * 10, 256 * 10, 256 * 10, 256 * 15 };
|
||||
int[] widths = { 256 * 15,256 * 30,256 * 15,256 * 15,256 * 20,256 * 20,256 * 20,256 * 10,256 * 10, 256 * 10, 256 * 10, 256 * 20, 256 * 10 };
|
||||
int[] widths2 = { 256 * 30,256 * 15,256 * 15,256 * 15,256 * 18,256 * 20,256 * 20,256 * 10,256 * 10, 256 * 10, 256 * 10 };
|
||||
|
||||
// 数据格式(1:String left; 2:String center; 3:String right; 4:int right; 5:float
|
||||
// right)
|
||||
int[] formats = { 4, 2, 2, 2, 2, 4, 2, 2, 2 };
|
||||
|
||||
int[] formats = { 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2 };
|
||||
int[] formats2 = { 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2 };
|
||||
// 准备数据
|
||||
List<Map<String, Object>> dataList = new ArrayList<>();
|
||||
|
||||
List<Map<String, Object>> dataList2 = new ArrayList<>();
|
||||
// 获取所有物资的领退记录
|
||||
List<ProjectCostCalculationDetail> details = calculation.getDetails();
|
||||
if (details != null && !details.isEmpty()) {
|
||||
int index = 1;
|
||||
int index2 = 1;
|
||||
for (ProjectCostCalculationDetail detail : details) {
|
||||
List<ProjectLeaseCostDetail> operRecords = detail.getDetails();
|
||||
if (operRecords != null && !operRecords.isEmpty()) {
|
||||
for (ProjectLeaseCostDetail record : operRecords) {
|
||||
Map<String, Object> row = new HashMap<>();
|
||||
row.put("序号", index++);
|
||||
row.put("物资类型", record.getMachineTypeName());
|
||||
row.put("规格型号", record.getMachineModel()); // 添加规格型号字段
|
||||
row.put("操作类型", record.getOperateType() == 1 ? "领料" : "退料");
|
||||
row.put("操作时间", record.getOperateTime());
|
||||
row.put("数量", record.getOperateType() == 1 ? record.getLeaseNum() : record.getReturnNum());
|
||||
row.put("单位", record.getMachineUnit());
|
||||
row.put("操作人", record.getOperatePersonName());
|
||||
row.put("任务编号", record.getTaskCode());
|
||||
dataList.add(row);
|
||||
if (record.getOperateType() == 1){
|
||||
Map<String, Object> row = new HashMap<>();
|
||||
row.put("领料日期", record.getOperateTime().substring(0,10));
|
||||
row.put("工程名称", calculation.getProjectName());
|
||||
if ("牵张设备".equals(record.getMachineCodeName()) ||"施工机械".equals(record.getMachineCodeName()) ||"仪器设备".equals(record.getMachineCodeName())){
|
||||
row.put("库房", "设备库");
|
||||
}else {
|
||||
row.put("库房", "机具库");
|
||||
}
|
||||
row.put("类别", record.getMachineCodeName()); // 添加规格型号字段
|
||||
row.put("机具设备名称", record.getMachineTypeName());
|
||||
row.put("规格型号", record.getMachineModel());
|
||||
row.put("编码", record.getOldMachineCode());
|
||||
row.put("新编码", record.getMachineCode());
|
||||
row.put("单位", record.getMachineUnit());
|
||||
row.put("数量", record.getOperateType() == 1 ? record.getLeaseNum() : record.getReturnNum());
|
||||
row.put("差额", record.getDifferenceQuantity().compareTo(BigDecimal.valueOf(record.getLeaseNum())) > 0 ? record.getLeaseNum():record.getDifferenceQuantity());
|
||||
row.put("租赁单位", record.getBsName());
|
||||
row.put("备注",null);
|
||||
dataList.add(row);
|
||||
}else {
|
||||
Map<String, Object> row = new HashMap<>();
|
||||
row.put("退料工程名称", calculation.getProjectName());
|
||||
row.put("退料单位", record.getBsName());
|
||||
row.put("退料日期", record.getOperateTime().substring(0,10)); // 添加规格型号字段
|
||||
if ("牵张设备".equals(record.getMachineCodeName()) ||"施工机械".equals(record.getMachineCodeName()) ||"仪器设备".equals(record.getMachineCodeName())){
|
||||
row.put("库房", "设备库");
|
||||
}else {
|
||||
row.put("库房", "机具库");
|
||||
}
|
||||
row.put("类别", record.getMachineCodeName()); // 添加规格型号字段
|
||||
row.put("机具设备名称", record.getMachineTypeName());
|
||||
row.put("规格", record.getMachineModel());
|
||||
row.put("编号", record.getOldMachineCode());
|
||||
row.put("单位", record.getMachineUnit());
|
||||
row.put("数量", record.getOperateType() == 1 ? record.getLeaseNum() : record.getReturnNum());
|
||||
row.put("备注",null);
|
||||
dataList2.add(row);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 设置文件名
|
||||
String filename = "";
|
||||
try {
|
||||
filename = URLEncoder.encode(fileName, "UTF-8");
|
||||
} catch (Exception e) {
|
||||
filename = fileName;
|
||||
}
|
||||
|
||||
// 设置响应头
|
||||
response.setHeader("Content-disposition", "attachment;filename=" + filename);
|
||||
response.setContentType("application/vnd.ms-excel");
|
||||
response.setHeader("Pragma", "No-cache");
|
||||
|
||||
// 创建一个工作簿
|
||||
HSSFWorkbook wb = new HSSFWorkbook();
|
||||
// 创建一个sheet
|
||||
HSSFSheet sheet = wb.createSheet(sheetName);
|
||||
// 创建一个sheet
|
||||
HSSFSheet sheet2 = wb.createSheet(sheetName2);
|
||||
// 调用导出方法
|
||||
exportExcel(fileName, sheetName, headers, widths, formats, dataList, response);
|
||||
exportExcelNew(wb, sheet, headers, widths, formats, dataList, response);
|
||||
exportExcelNew(wb, sheet2, headers2, widths2, formats2, dataList2, response);
|
||||
// 输出文件
|
||||
OutputStream ouputStream = response.getOutputStream();
|
||||
wb.write(ouputStream);
|
||||
ouputStream.flush();
|
||||
ouputStream.close();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1835,4 +1985,135 @@ public class ProjectCostServiceImpl implements ProjectCostService {
|
|||
}
|
||||
return totalDays;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 封装导出Excel的方法,适用于只有HttpServletResponse的情况
|
||||
*
|
||||
* @param wb 文件名
|
||||
* @param sheet sheet名称
|
||||
* @param headers 表头
|
||||
* @param widths 列宽
|
||||
* @param formats 数据格式
|
||||
* @param dataList 数据列表
|
||||
* @param response HttpServletResponse对象
|
||||
* @throws Exception 导出异常
|
||||
*/
|
||||
private void exportExcelNew(HSSFWorkbook wb, HSSFSheet sheet, String[] headers, int[] widths, int[] formats,
|
||||
List<Map<String, Object>> dataList, javax.servlet.http.HttpServletResponse response) throws Exception {
|
||||
try {
|
||||
|
||||
|
||||
// 创建表头
|
||||
int headerrow = 0;
|
||||
if (headers != null) {
|
||||
HSSFRow row = sheet.createRow(headerrow);
|
||||
// 设置表头行高 - 调高表头高度
|
||||
row.setHeight((short) 500); // 设置为原高度的约2倍
|
||||
|
||||
// 表头样式
|
||||
HSSFCellStyle style = wb.createCellStyle();
|
||||
HSSFFont font = wb.createFont();
|
||||
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
|
||||
font.setFontName("微软雅黑");
|
||||
font.setFontHeightInPoints((short) 11);
|
||||
style.setFont(font);
|
||||
style.setAlignment(HSSFCellStyle.ALIGN_CENTER); // 水平居中
|
||||
style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); // 垂直居中
|
||||
style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
|
||||
style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
|
||||
style.setBorderRight(HSSFCellStyle.BORDER_THIN);
|
||||
style.setBorderTop(HSSFCellStyle.BORDER_THIN);
|
||||
|
||||
// 设置淡黄色背景
|
||||
style.setFillForegroundColor((short) 0x2B); // 修改为更明确的淡黄色,0x2B是淡黄色(light yellow)
|
||||
style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
|
||||
|
||||
for (int i = 0; i < headers.length; i++) {
|
||||
sheet.setColumnWidth((short) i, (short) widths[i]);
|
||||
HSSFCell cell = row.createCell(i);
|
||||
cell.setCellValue(headers[i]);
|
||||
cell.setCellStyle(style);
|
||||
}
|
||||
headerrow++;
|
||||
}
|
||||
|
||||
// 表格主体
|
||||
if (dataList != null) {
|
||||
List<HSSFCellStyle> styleList = new ArrayList<HSSFCellStyle>();
|
||||
|
||||
if (headers != null) {
|
||||
for (int i = 0; i < headers.length; i++) { // 列数
|
||||
HSSFCellStyle style = wb.createCellStyle();
|
||||
HSSFFont font = wb.createFont();
|
||||
font.setFontName("微软雅黑");
|
||||
font.setFontHeightInPoints((short) 10);
|
||||
style.setFont(font);
|
||||
style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
|
||||
style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
|
||||
style.setBorderRight(HSSFCellStyle.BORDER_THIN);
|
||||
style.setBorderTop(HSSFCellStyle.BORDER_THIN);
|
||||
// 添加垂直居中对齐
|
||||
style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
|
||||
|
||||
if (formats[i] == 1) {
|
||||
style.setAlignment(HSSFCellStyle.ALIGN_LEFT);
|
||||
} else if (formats[i] == 2) {
|
||||
style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
|
||||
} else if (formats[i] == 3) {
|
||||
style.setAlignment(HSSFCellStyle.ALIGN_RIGHT);
|
||||
} else if (formats[i] == 4) {
|
||||
style.setAlignment(HSSFCellStyle.ALIGN_RIGHT);
|
||||
// int类型
|
||||
style.setDataFormat(HSSFDataFormat.getBuiltinFormat("0"));
|
||||
} else if (formats[i] == 5) {
|
||||
// float类型
|
||||
style.setAlignment(HSSFCellStyle.ALIGN_RIGHT);
|
||||
style.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0.00"));
|
||||
} else if (formats[i] == 6) {
|
||||
// 百分比类型
|
||||
style.setAlignment(HSSFCellStyle.ALIGN_RIGHT);
|
||||
style.setDataFormat(HSSFDataFormat.getBuiltinFormat("0.00%"));
|
||||
}
|
||||
styleList.add(style);
|
||||
}
|
||||
}
|
||||
|
||||
for (Map<String, Object> stringObjectMap : dataList) { // 行数
|
||||
HSSFRow row = sheet.createRow(headerrow);
|
||||
int j = 0;
|
||||
for (String key : headers) { // 列数
|
||||
HSSFCell cell = row.createCell(j);
|
||||
Object o = stringObjectMap.get(key);
|
||||
if (o == null || "".equals(o)) {
|
||||
cell.setCellValue("");
|
||||
} else if (formats[j] == 4) {
|
||||
// int
|
||||
try {
|
||||
cell.setCellValue(Long.parseLong(String.valueOf(o)));
|
||||
} catch (Exception e) {
|
||||
cell.setCellValue(0);
|
||||
}
|
||||
} else if (formats[j] == 5 || formats[j] == 6) {
|
||||
// float
|
||||
try {
|
||||
cell.setCellValue(Double.parseDouble(String.valueOf(o)));
|
||||
} catch (Exception e) {
|
||||
cell.setCellValue(0.0);
|
||||
}
|
||||
} else {
|
||||
cell.setCellValue(String.valueOf(o));
|
||||
}
|
||||
|
||||
cell.setCellStyle(styleList.get(j));
|
||||
j++;
|
||||
}
|
||||
headerrow++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new Exception("导出Excel异常", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue