Merge branch 'master' of http://192.168.30.2:3000/bonus/Bonus-Cloud-Material
This commit is contained in:
commit
288d52e280
|
|
@ -3,6 +3,7 @@ package com.bonus.material.clz.controller;
|
|||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.nacos.common.utils.StringUtils;
|
||||
import com.bonus.common.biz.config.PoiOutPage;
|
||||
|
|
@ -182,7 +183,17 @@ public class ClzSltAgreementInfoController extends BaseController {
|
|||
List<MaterialSltAgreementInfo> oneOfList = clzSltAgreementInfoMapper.getLeaseList(sltAgreementInfo);
|
||||
//设定班组实际出场时间
|
||||
if(!oneOfList.isEmpty()){
|
||||
String date = clzSltAgreementInfoMapper.getTeamOutTime(oneOfList.get(0));
|
||||
|
||||
String date = "暂无" ;
|
||||
//先判断是否在场
|
||||
String exitTime = clzSltAgreementInfoMapper.getTeamSjOutTime(oneOfList.get(0));
|
||||
if( exitTime!=null && !exitTime.isEmpty() ){
|
||||
|
||||
}else{
|
||||
date = clzSltAgreementInfoMapper.getTeamOutTime(oneOfList.get(0));
|
||||
}
|
||||
|
||||
|
||||
if(date!=null && !date.isEmpty()){
|
||||
oneOfList.get(0).setActualExitTime(date);
|
||||
}
|
||||
|
|
@ -280,7 +291,16 @@ public class ClzSltAgreementInfoController extends BaseController {
|
|||
loseList.addAll(overdueReturnedList);
|
||||
//设定班组实际出场时间
|
||||
if(!loseList.isEmpty()){
|
||||
String date = clzSltAgreementInfoMapper.getTeamOutTime(loseList.get(0));
|
||||
|
||||
String date = "暂无" ;
|
||||
//先判断是否在场
|
||||
String exitTime = clzSltAgreementInfoMapper.getTeamSjOutTime(oneOfList.get(0));
|
||||
if( exitTime!=null && !exitTime.isEmpty() ){
|
||||
|
||||
}else{
|
||||
date = clzSltAgreementInfoMapper.getTeamOutTime(loseList.get(0));
|
||||
}
|
||||
|
||||
if(date!=null && !date.isEmpty()){
|
||||
loseList.get(0).setActualExitTime(date);
|
||||
}
|
||||
|
|
@ -442,7 +462,15 @@ public class ClzSltAgreementInfoController extends BaseController {
|
|||
}
|
||||
//设定班组实际出场时间
|
||||
if(!listAll.isEmpty()){
|
||||
String date = clzSltAgreementInfoMapper.getTeamOutTime(listAll.get(0));
|
||||
String date = "暂无" ;
|
||||
//先判断是否在场
|
||||
String exitTime = clzSltAgreementInfoMapper.getTeamSjOutTime(listAll.get(0));
|
||||
if( exitTime!=null && !exitTime.isEmpty() ){
|
||||
|
||||
}else{
|
||||
date = clzSltAgreementInfoMapper.getTeamOutTime(listAll.get(0));
|
||||
}
|
||||
|
||||
if(date!=null && !date.isEmpty()){
|
||||
listAll.get(0).setActualExitTime(date);
|
||||
}
|
||||
|
|
@ -551,7 +579,19 @@ public class ClzSltAgreementInfoController extends BaseController {
|
|||
|
||||
private BigDecimal calculateRentalCostByTeamExitTime(MaterialSltAgreementInfo bean, BigDecimal leasePrice, BigDecimal num) {
|
||||
// 模拟班组退场时间(后续会通过参数传入)
|
||||
Date teamExitTime = simulateTeamExitTime();
|
||||
// Date teamExitTime = simulateTeamExitTime();
|
||||
String teamExitTime = bean.getActualExitTime();
|
||||
if (teamExitTime == null) {
|
||||
teamExitTime = DateTime.now().toString("yyyy-MM-dd");
|
||||
}
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Date exitTime = null;
|
||||
try {
|
||||
exitTime = format.parse(teamExitTime);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
// 物资是否已退还(根据endTime字段判断)
|
||||
boolean isReturned = bean.getEndTime() != null;
|
||||
|
|
@ -565,7 +605,7 @@ public class ClzSltAgreementInfoController extends BaseController {
|
|||
Date materialReturnTime = bean.getEndTime();
|
||||
|
||||
// 计算超期天数
|
||||
long overdueDays = calculateOverdueDays(materialReturnTime, teamExitTime);
|
||||
long overdueDays = calculateOverdueDays(materialReturnTime, exitTime);
|
||||
|
||||
if (overdueDays <= 0) {
|
||||
// 1.3 在班组退场之前归还的物资不收费
|
||||
|
|
|
|||
|
|
@ -123,4 +123,6 @@ public interface ClzSltAgreementInfoMapper {
|
|||
List<MaterialSltAgreementInfo> getClzTeamList(MaterialSltAgreementInfo bean);
|
||||
|
||||
String getTeamOutTime(MaterialSltAgreementInfo materialSltAgreementInfo);
|
||||
|
||||
String getTeamSjOutTime(MaterialSltAgreementInfo materialSltAgreementInfo);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.bonus.material.clz.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.bonus.common.biz.constant.GlobalConstants;
|
||||
import com.bonus.common.biz.domain.ProjectTreeBuild;
|
||||
|
|
@ -32,6 +33,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
|
@ -775,9 +777,17 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic
|
|||
*/
|
||||
private List<MaterialSltAgreementInfo> getLeaseList(MaterialSltAgreementInfo info) {
|
||||
List<MaterialSltAgreementInfo> oneOfList = clzSltAgreementInfoMapper.getLeaseList(info);
|
||||
String date = null ;
|
||||
//设定班组实际出场时间
|
||||
if(!oneOfList.isEmpty()){
|
||||
String date = clzSltAgreementInfoMapper.getTeamOutTime(oneOfList.get(0));
|
||||
//先判断是否在场
|
||||
String exitTime = clzSltAgreementInfoMapper.getTeamSjOutTime(oneOfList.get(0));
|
||||
if( exitTime!=null && !exitTime.isEmpty() ){
|
||||
|
||||
}else{
|
||||
date = clzSltAgreementInfoMapper.getTeamOutTime(oneOfList.get(0));
|
||||
}
|
||||
|
||||
if(date!=null && !date.isEmpty()){
|
||||
oneOfList.get(0).setActualExitTime(date);
|
||||
}
|
||||
|
|
@ -816,7 +826,19 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic
|
|||
*/
|
||||
private BigDecimal calculateRentalCostByTeamExitTime(MaterialSltAgreementInfo bean, BigDecimal leasePrice, BigDecimal num) {
|
||||
// 模拟班组退场时间(后续会通过参数传入)
|
||||
Date teamExitTime = simulateTeamExitTime();
|
||||
// Date teamExitTime = simulateTeamExitTime();
|
||||
String teamExitTime = bean.getActualExitTime();
|
||||
if (teamExitTime == null) {
|
||||
teamExitTime = DateTime.now().toString("yyyy-MM-dd");
|
||||
}
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Date exitTime = null;
|
||||
try {
|
||||
exitTime = format.parse(teamExitTime);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
// 物资是否已退还(根据endTime字段判断)
|
||||
boolean isReturned = bean.getEndTime() != null;
|
||||
|
|
@ -830,7 +852,7 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic
|
|||
Date materialReturnTime = bean.getEndTime();
|
||||
|
||||
// 计算超期天数
|
||||
long overdueDays = calculateOverdueDays(materialReturnTime, teamExitTime);
|
||||
long overdueDays = calculateOverdueDays(materialReturnTime, exitTime);
|
||||
|
||||
if (overdueDays <= 0) {
|
||||
// 1.3 在班组退场之前归还的物资不收费
|
||||
|
|
|
|||
|
|
@ -1380,17 +1380,6 @@ public class MaterialMachineServiceImpl implements MaterialMachineService {
|
|||
if (CollectionUtils.isEmpty(recordList)) {
|
||||
return recordList;
|
||||
}
|
||||
// 获取所有领料未结算协议id
|
||||
List<MaterialProvideNumInfo> subAgreementIds = materialMachineMapper.getSubAgreementIds(bean);
|
||||
|
||||
// 查询分包商领用数据,不作为库存,作为再用数据
|
||||
List<MaterialRetainedEquipmentInfo> subList = materialMachineMapper.getSubInfoList(bean);
|
||||
// 根据工程id获取分包的在用数量,存储在map集合中
|
||||
Map<String, BigDecimal> subMap = new HashMap<>();
|
||||
subList.forEach(info -> {
|
||||
String key = getCompositeKey(info.getProId(), info.getTypeId());
|
||||
subMap.putIfAbsent(key, info.getAllNum());
|
||||
});
|
||||
|
||||
// 1. 过滤数据(并行流加速大集合过滤)
|
||||
if (teamData != null) {
|
||||
|
|
@ -1400,7 +1389,7 @@ public class MaterialMachineServiceImpl implements MaterialMachineService {
|
|||
}
|
||||
|
||||
// 2. 转换参数:将agreementIds(逗号字符串)转为List<String>
|
||||
List<Map<String, Object>> queryParams = subAgreementIds.stream()
|
||||
List<Map<String, Object>> queryParams = recordList.stream()
|
||||
.map(record -> {
|
||||
Map<String, Object> param = new HashMap<>(3);
|
||||
param.put("proId", record.getProId());
|
||||
|
|
@ -1457,12 +1446,6 @@ public class MaterialMachineServiceImpl implements MaterialMachineService {
|
|||
String key = getCompositeKey(record.getProId(), record.getTypeId());
|
||||
// 从Map获取数据(默认0,避免null)
|
||||
BigDecimal businessNum = leaseBusinessMap.getOrDefault(key, BigDecimal.ZERO);
|
||||
// 从subMap获取在用数量
|
||||
BigDecimal useNum = subMap.getOrDefault(key, BigDecimal.ZERO);
|
||||
// 追加在用数量给实际供应数量和已有在用数量
|
||||
record.setSupplyNum(record.getSupplyNum().add(useNum));
|
||||
record.setUseNum(record.getUseNum().add(useNum));
|
||||
|
||||
// 设置record的businessNum(原逻辑保留)
|
||||
record.setBusinessNum(businessNum);
|
||||
|
||||
|
|
|
|||
|
|
@ -98,6 +98,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
res.agreementId,
|
||||
res.unitName,
|
||||
res.unitId,
|
||||
res.wsProId,
|
||||
res.projectName,
|
||||
res.companyId,
|
||||
res.typeId,
|
||||
|
|
@ -118,9 +119,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
sai.agreement_id as agreementId,
|
||||
bui.unit_id as unitId,
|
||||
bui.unit_name as unitName,
|
||||
bp.external_id as wsProId,
|
||||
bp.pro_name as projectName,
|
||||
sai.company_id as companyId,
|
||||
sai.type_id as typeId,
|
||||
|
||||
sai.ma_id as maId,
|
||||
mt.unit_value as unitValue,
|
||||
mt1.type_name as typeName,
|
||||
|
|
@ -148,6 +151,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
res.unitId,
|
||||
res.unitName,
|
||||
res.projectName,
|
||||
res.wsProId,
|
||||
res.companyId,
|
||||
res.typeId,
|
||||
res.typeName,
|
||||
|
|
@ -170,6 +174,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
bui.unit_id as unitId,
|
||||
bui.unit_name as unitName,
|
||||
bp.pro_name as projectName,
|
||||
bp.external_id as wsProId,
|
||||
sai.company_id as companyId,
|
||||
sai.type_id as typeId,
|
||||
sai.ma_id as maId,
|
||||
|
|
@ -177,7 +182,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
mt1.type_name as typeName,
|
||||
mt.type_name as modelName,
|
||||
mt.unit_name as mtUnitName,
|
||||
sai.buy_price as buyPrice,
|
||||
mt.buy_price as buyPrice,
|
||||
sai.num as num,
|
||||
sai.start_time as startTime,
|
||||
sai.end_time as endTime,
|
||||
|
|
@ -384,14 +389,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
where `code` = #{sltApplyCode}
|
||||
</select>
|
||||
<select id="getClzTeamList" resultType="com.bonus.material.clz.domain.vo.MaterialSltAgreementInfo">
|
||||
SELECT
|
||||
bu.unit_id AS unitId,
|
||||
bu.unit_name AS unitName
|
||||
FROM
|
||||
clz_bm_agreement_info bai
|
||||
left join bm_unit bu on bai.unit_id = bu.unit_id
|
||||
WHERE
|
||||
bai.project_id = #{proId}
|
||||
SELECT
|
||||
bu.unit_id AS unitId,
|
||||
bu.unit_name AS unitName
|
||||
FROM
|
||||
clz_bm_agreement_info bai
|
||||
left join bm_unit bu on bai.unit_id = bu.unit_id
|
||||
WHERE
|
||||
bu.unit_name IS NOT NULL
|
||||
AND bai.project_id = #{proId}
|
||||
GROUP BY
|
||||
bu.unit_id
|
||||
</select>
|
||||
<select id="getTeamOutTime" resultType="java.lang.String">
|
||||
select
|
||||
|
|
@ -405,6 +413,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
order by bzj.sjccsj desc limit 1
|
||||
</select>
|
||||
|
||||
<select id="getTeamSjOutTime" resultType="java.lang.String">
|
||||
select
|
||||
|
||||
bz.sjjcsj as time
|
||||
from
|
||||
bm_unit bu
|
||||
left join `micro-tool`.bzgl_bz bz on bz.bzz_idcard = bu.bzz_idcard
|
||||
|
||||
where bu.unit_id = #{unitId} AND bz.project_id = #{wsProId}
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<update id="updateClzAgreementInfoByIds">
|
||||
update clz_bm_agreement_info
|
||||
set is_slt = 1, update_time = now()
|
||||
|
|
|
|||
|
|
@ -1975,19 +1975,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
subquery1.impUnit AS impUnit,
|
||||
subquery3.idCard AS idCard,
|
||||
CASE
|
||||
WHEN IFNULL(subquery1.usNum, 0) - IFNULL(subquery3.usNum, 0) < 0
|
||||
THEN 0
|
||||
ELSE IFNULL(subquery1.usNum, 0) - IFNULL(subquery3.usNum, 0)
|
||||
END
|
||||
AS storeNum,
|
||||
IFNULL(subquery3.usNum, 0) AS useNum,
|
||||
(
|
||||
WHEN subquery1.typeId = 36 THEN
|
||||
GREATEST(IFNULL(subquery1.usNum, 0) - IFNULL(subquery3.usNum, 0), 0)
|
||||
ELSE
|
||||
IFNULL(subquery3.usNum, 0)
|
||||
END AS storeNum,
|
||||
CASE
|
||||
WHEN IFNULL(subquery1.usNum, 0) - IFNULL(subquery3.usNum, 0) < 0
|
||||
THEN 0
|
||||
ELSE IFNULL(subquery1.usNum, 0) - IFNULL(subquery3.usNum, 0)
|
||||
END + IFNULL(subquery3.usNum, 0)
|
||||
) AS supplyNum,
|
||||
WHEN subquery1.typeId = 36 THEN
|
||||
IFNULL(subquery3.usNum, 0)
|
||||
ELSE
|
||||
IFNULL(subquery1.usNum, 0)
|
||||
END AS useNum,
|
||||
IFNULL(subquery1.supplyNum, 0) AS supplyNum,
|
||||
subquery1.proCenter AS departName,
|
||||
subquery1.departName AS impUnitName,
|
||||
CASE mt.manage_type
|
||||
|
|
@ -2015,7 +2014,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
mt2.type_name AS typeName,
|
||||
mt2.type_id AS thirdTypeId,
|
||||
mt.type_name AS typeModelName,
|
||||
SUM(IFNULL( sai.num, 0 )) AS usNum,
|
||||
SUM(CASE WHEN sai.`status` = '0' THEN IFNULL(sai.num, 0) ELSE 0 END) AS usNum,
|
||||
SUM(IFNULL( sai.num, 0 )) AS supplyNum,
|
||||
bp.pro_name as proName,
|
||||
bp.pro_id as proId,
|
||||
bp.external_id as externalId,
|
||||
|
|
@ -2023,7 +2023,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
bu.bzz_idcard AS idCard,
|
||||
df.project_dept AS proCenter,
|
||||
sd.dept_name AS departName,
|
||||
GROUP_CONCAT(DISTINCT sai.agreement_id) AS agreementId
|
||||
GROUP_CONCAT(DISTINCT sai.agreement_id) AS agreementId,
|
||||
bu.type_id AS typeId
|
||||
FROM
|
||||
slt_agreement_info sai
|
||||
LEFT JOIN ma_type mt ON mt.type_id = sai.type_id
|
||||
|
|
@ -2037,12 +2038,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
LEFT JOIN sys_dept sd ON sd.dept_id = bp.imp_unit
|
||||
LEFT JOIN data_center.dx_fb_son df ON bp.external_id = df.id
|
||||
WHERE
|
||||
sai.`status` = '0'
|
||||
AND sai.is_slt = '0'
|
||||
AND sai.end_time IS NULL
|
||||
AND sai.back_id IS NULL
|
||||
sai.is_slt = '0'
|
||||
AND bp.external_id IS NOT NULL
|
||||
AND bu.type_id = 36
|
||||
<if test="impUnitName != null and impUnitName != ''">
|
||||
AND sd.dept_name = #{impUnitName}
|
||||
</if>
|
||||
|
|
@ -2164,6 +2161,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
LEFT JOIN ma_type mt4 ON mt4.type_id = mt3.parent_id
|
||||
WHERE mt.`level` = 4 and mt.del_flag = '0'
|
||||
AND subquery1.proName IS NOT NULL
|
||||
AND (
|
||||
IFNULL(subquery1.usNum, 0) > 0
|
||||
OR (
|
||||
CASE
|
||||
WHEN subquery1.typeId = 36 THEN GREATEST(IFNULL(subquery1.usNum, 0) - IFNULL(subquery3.usNum, 0), 0)
|
||||
ELSE IFNULL(subquery3.usNum, 0)
|
||||
END
|
||||
) > 0
|
||||
OR (
|
||||
CASE
|
||||
WHEN subquery1.typeId = 36 THEN IFNULL(subquery3.usNum, 0)
|
||||
ELSE IFNULL(subquery1.usNum, 0)
|
||||
END
|
||||
) > 0
|
||||
)
|
||||
GROUP BY
|
||||
subquery1.proId,
|
||||
mt.type_id
|
||||
|
|
|
|||
Loading…
Reference in New Issue