代码提交
This commit is contained in:
parent
dd96cd056b
commit
6f40e1d72f
|
|
@ -130,8 +130,8 @@ public class BackChangeServiceImpl implements BackChangeService {
|
|||
if (usedNum.compareTo(totalOccupyNum) < 0) {
|
||||
// 格式化数值:根据业务场景选择舍入模式(此处以保留2位小数、四舍五入为例,可调整)
|
||||
// 注意:展示的是总占用数量,与校验逻辑一致,避免用户误解
|
||||
String totalOccupyNumStr = formatBigDecimal(onWayNum, 2, RoundingMode.HALF_UP);
|
||||
String applyNumStr = formatBigDecimal(applyNum, 2, RoundingMode.HALF_UP);
|
||||
String totalOccupyNumStr = formatBigDecimal(onWayNum, 0, RoundingMode.HALF_UP);
|
||||
String applyNumStr = formatBigDecimal(applyNum, 0, RoundingMode.HALF_UP);
|
||||
String typeName = details.getTypeName();
|
||||
|
||||
// 构建错误信息
|
||||
|
|
|
|||
|
|
@ -544,16 +544,30 @@ public class OrderServiceImpl implements OrderService {
|
|||
devInfo.setBuyerCompany(deptId.intValue());
|
||||
}
|
||||
List<OrderInfoDto> orderInfoDtos = orderMapper.getOrderDetails(devInfo);
|
||||
|
||||
String deviceName = devInfo.getDeviceName();
|
||||
List<OrderInfoDto> resultList = new ArrayList<>();
|
||||
|
||||
for (OrderInfoDto dto : orderInfoDtos) {
|
||||
dto.setPhoneNumber(Sm4Utils.decrypt(dto.getPhoneNumber()));
|
||||
List<OrderDetailDto> list = new ArrayList<>();
|
||||
String ids = dto.getIds();
|
||||
for (String id : ids.split(",")) {
|
||||
OrderDetailDto orderDetailDto = orderMapper.selectOrderDetailsById(id);
|
||||
list.add(orderDetailDto);
|
||||
|
||||
if (StringUtils.isNotBlank(deviceName)) {
|
||||
String detailDeviceName = orderDetailDto.getDeviceName();
|
||||
if (detailDeviceName != null && detailDeviceName.contains(deviceName)) {
|
||||
list.add(orderDetailDto);
|
||||
}
|
||||
} else {
|
||||
list.add(orderDetailDto);
|
||||
}
|
||||
|
||||
}
|
||||
list.removeIf(Objects::isNull);
|
||||
dto.setDetailsList(list);
|
||||
if (!list.isEmpty()) {
|
||||
Optional<OrderDetailDto> minOrderStatus = list.stream().min(Comparator.comparingInt(p -> Integer.parseInt(p.getOrderStatus())));
|
||||
minOrderStatus.ifPresent(orderDetailDto -> dto.setOrderStatus(orderDetailDto.getOrderStatus()));
|
||||
//根据订单id去lease_repair_record表中查询是否已填写退租检修信息
|
||||
|
|
@ -566,8 +580,11 @@ public class OrderServiceImpl implements OrderService {
|
|||
dto.setPartBacked(list.stream().anyMatch(o -> OrderStatusEnum.ORDER_UNDER_LEASE.getStatus().toString().equals(o.getOrderStatus())));
|
||||
LeaseRepair leaseRepair = new LeaseRepair();
|
||||
leaseRepair.setOrderId(String.valueOf(dto.getOrderId()));
|
||||
// 将符合条件的订单加入结果集
|
||||
resultList.add(dto);
|
||||
}
|
||||
}
|
||||
return orderInfoDtos;
|
||||
return resultList;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@ package com.bonus.material.project.mapper;
|
|||
|
||||
import com.bonus.material.project.domain.Project;
|
||||
import com.bonus.material.project.domain.ProjectType;
|
||||
import feign.Param;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -22,7 +23,7 @@ public interface ProjectMapper {
|
|||
* @param projectId 工程ID
|
||||
* @return 工程对象
|
||||
*/
|
||||
public Project selectProjectById(@Param("projectId") Long projectId);
|
||||
public Project selectProjectById(@Param("id") Long projectId);
|
||||
|
||||
/**
|
||||
* 新增工程
|
||||
|
|
@ -46,7 +47,7 @@ public interface ProjectMapper {
|
|||
* @param projectId 工程ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteProjectById(@Param("projectId") Long projectId);
|
||||
public int deleteProjectById(@Param("id") Long projectId);
|
||||
|
||||
/**
|
||||
* 查询工程类型列表
|
||||
|
|
@ -60,4 +61,6 @@ public interface ProjectMapper {
|
|||
int countByProjectName(String proName);
|
||||
|
||||
int countByProjectCode(String proCode);
|
||||
|
||||
int countByProjectNameById(@Param("proName")String proName, @Param("id") Integer id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ public class ProjectServiceImpl implements ProjectService {
|
|||
@Override
|
||||
public void updateProject(Project project)
|
||||
{
|
||||
int count =projectMapper.countByProjectName(project.getPro_name());
|
||||
int count =projectMapper.countByProjectNameById(project.getPro_name(),project.getId());
|
||||
if(count>0){
|
||||
throw new RuntimeException("工程名称已存在,请重新修改");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import com.bonus.material.scrap.domain.ToBeScrap;
|
|||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
|
|
@ -85,4 +86,6 @@ public interface ScrapMapper {
|
|||
ToBeScrap selectByTypeIdAndCode(ToBeScrap toBeScrap);
|
||||
|
||||
List<ToBeScrap> getDetail(String id);
|
||||
|
||||
BigDecimal getDetailsNum(ToBeScrap toBeScrap);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,10 +20,13 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
import static com.bonus.common.biz.constant.MaterialConstants.ADMIN_ID;
|
||||
import static com.bonus.common.biz.constant.MaterialConstants.PROVINCE_COMPANY_DEPT_ID;
|
||||
|
|
@ -164,6 +167,9 @@ public class ToBeScrapServiceImpl implements ToBeScrapService {
|
|||
if (Objects.isNull(bean.getOperationType()) || !StrUtil.equalsAny(bean.getOperationType(), "add", "edit")) {
|
||||
return AjaxResult.error("操作类型异常!");
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 如果是编辑操作,那么就直接把之前的任务删掉重新建立
|
||||
if (Objects.equals("edit", bean.getOperationType())) {
|
||||
scrapMapper.deleteChangeInfo(bean.getId());
|
||||
|
|
@ -186,8 +192,40 @@ public class ToBeScrapServiceImpl implements ToBeScrapService {
|
|||
Long changeId = deviceInfo.getId();
|
||||
// 保存任务明细
|
||||
for (ToBeScrap toBeScrap : bean.getToBeScrapList()) {
|
||||
|
||||
BigDecimal onWayNum = Optional.ofNullable(scrapMapper.getDetailsNum(toBeScrap)).orElse(BigDecimal.ZERO);
|
||||
// 获取已使用数量(可能为null,转0)
|
||||
BigDecimal usedNum = Optional.ofNullable(toBeScrap.getInStockNum()).orElse(BigDecimal.ZERO);
|
||||
// 获取本次申请数量(可能为null,转0)
|
||||
BigDecimal applyNum = Optional.ofNullable(toBeScrap.getScrapNum()).orElse(BigDecimal.ZERO);
|
||||
|
||||
// ========== 步骤2:计算总占用数量(在途 + 本次申请) ==========
|
||||
BigDecimal totalOccupyNum = onWayNum.add(applyNum);
|
||||
|
||||
// ========== 步骤3:业务校验(usedNum < totalOccupyNum 时触发错误) ==========
|
||||
if (usedNum.compareTo(totalOccupyNum) < 0) {
|
||||
// 格式化数值:根据业务场景选择舍入模式(此处以保留2位小数、四舍五入为例,可调整)
|
||||
// 注意:展示的是总占用数量,与校验逻辑一致,避免用户误解
|
||||
String totalOccupyNumStr = formatBigDecimal(onWayNum, 0, RoundingMode.HALF_UP);
|
||||
String applyNumStr = formatBigDecimal(applyNum, 0, RoundingMode.HALF_UP);
|
||||
String typeName = toBeScrap.getTypeName();
|
||||
|
||||
// 构建错误信息
|
||||
String errorMsg = String.format("%s,已有在途单据,在途数量%s,本次申请数量%s", typeName, totalOccupyNumStr,applyNumStr);
|
||||
|
||||
// 记录日志:包含关键参数,便于问题排查
|
||||
|
||||
|
||||
// 返回错误结果
|
||||
return AjaxResult.error(errorMsg, AjaxResult.class);
|
||||
}
|
||||
|
||||
|
||||
|
||||
toBeScrap.setChangeId(changeId);
|
||||
toBeScrap.setCreateUser(username);
|
||||
|
||||
|
||||
if (CollectionUtils.isNotEmpty(toBeScrap.getBmFileInfos())) {
|
||||
toBeScrap.setScrapUrl(toBeScrap.getBmFileInfos().get(0).getFileUrl());
|
||||
}
|
||||
|
|
@ -260,4 +298,13 @@ public class ToBeScrapServiceImpl implements ToBeScrapService {
|
|||
|
||||
return scrapMapper.getDetail(id);
|
||||
}
|
||||
|
||||
|
||||
private String formatBigDecimal(BigDecimal value, int scale, RoundingMode roundingMode) {
|
||||
// 空值转0后再格式化,消除空指针
|
||||
return Optional.ofNullable(value)
|
||||
.orElse(BigDecimal.ZERO)
|
||||
.setScale(scale, roundingMode)
|
||||
.toPlainString(); // 避免科学计数法
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -176,7 +176,7 @@ public class ToolLedgerController extends BaseController {
|
|||
list.stream()
|
||||
.forEach(item -> {
|
||||
String code = item.getManageMode();
|
||||
String name = "0".equals(code) ? "编码管理" : "1".equals(code) ? "数量管理" : "未知管理模式";
|
||||
String name = "0".equals(code) ? "编码工具" : "1".equals(code) ? "数量工具" : "未知管理模式";
|
||||
item.setManageMode(name);
|
||||
});
|
||||
ExcelUtil<ToolLedgerAllEntity> util = new ExcelUtil<ToolLedgerAllEntity>(ToolLedgerAllEntity.class);
|
||||
|
|
|
|||
|
|
@ -86,6 +86,7 @@ public class ToolLedgerAllEntity implements Serializable {
|
|||
/**
|
||||
* 报废数量(非空,默认0.00)
|
||||
*/
|
||||
@Excel(name = "退役数量", sort = 10)
|
||||
private BigDecimal scrapNum;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -196,9 +196,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="sellerCompany != null">
|
||||
AND mdi.on_company = #{sellerCompany}
|
||||
</if>
|
||||
<if test="deviceName != null and deviceName != ''">
|
||||
AND mdi.device_name like concat('%',#{deviceName},'%')
|
||||
</if>
|
||||
<!-- <if test="deviceName != null and deviceName != ''">-->
|
||||
<!-- AND mdi.device_name like concat('%',#{deviceName},'%')-->
|
||||
<!-- </if>-->
|
||||
<if test="orderStatus != null and orderStatus != ''">
|
||||
AND hh.order_status = #{orderStatus}
|
||||
</if>
|
||||
|
|
@ -206,9 +206,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
AND moi.code = #{code}
|
||||
</if>
|
||||
<if test="startTime != null and endTime != null ">
|
||||
AND ((hh.rent_begin_time BETWEEN #{startTime} AND #{endTime})
|
||||
OR (hh.rent_end_time BETWEEN #{startTime} AND #{endTime})
|
||||
OR (hh.rent_begin_time < #{startTime} AND hh.rent_end_time > #{endTime}))
|
||||
and moi.order_time >= #{startTime}
|
||||
and moi.order_time < DATE_ADD(#{endTime}, INTERVAL 1 DAY)
|
||||
</if>
|
||||
<if test="czcompanyName != null and czcompanyName != ''">
|
||||
AND up.dept_name like concat('%',#{czcompanyName},'%')
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@
|
|||
</select>
|
||||
|
||||
<select id="countByProjectName" resultType="java.lang.Integer">
|
||||
select count(*)
|
||||
select count(1)
|
||||
from jj_sing_project
|
||||
where pro_name = #{pro_name}
|
||||
</select>
|
||||
|
|
@ -177,5 +177,11 @@
|
|||
from jj_sing_project
|
||||
where pro_code = #{pro_code}
|
||||
</select>
|
||||
<select id="countByProjectNameById" resultType="java.lang.Integer">
|
||||
select count(1)
|
||||
from jj_sing_project
|
||||
where pro_name = #{proName}
|
||||
and id !=#{id}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
@ -421,6 +421,19 @@
|
|||
WHERE mdi.ma_id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="getDetailsNum" resultType="java.math.BigDecimal">
|
||||
SELECT IFNULL(SUM(cdcd.num),0)
|
||||
FROM cs_device_change_details cdcd
|
||||
LEFT JOIN cs_device_change cdc ON cdc.id = cdcd.change_id
|
||||
WHERE cdcd.dev_type_id = #{typeId}
|
||||
AND cdc.review_status in ('1','0','5') AND cdc.type ='3'
|
||||
<if test="devCode!=null and devCode!="/"">
|
||||
AND cdcd.dev_code = #{devCode}
|
||||
</if>
|
||||
GROUP BY
|
||||
cdcd.dev_type_id
|
||||
</select>
|
||||
|
||||
<update id="updateChangeStatus">
|
||||
update cs_device_change set review_status = #{reviewStatus} where id = #{changeId}
|
||||
</update>
|
||||
|
|
|
|||
Loading…
Reference in New Issue