用 GlobalConstants 替代硬编码的数字值

- 将硬编码的 1、2 等数字值替换为 GlobalConstants 中的常量
This commit is contained in:
syruan 2025-08-14 11:14:43 +08:00
parent aeb6f957e0
commit 193b71a798
3 changed files with 29 additions and 30 deletions

View File

@ -394,7 +394,7 @@ public class MaterialBackApplyInfoServiceImpl implements MaterialBackApplyInfoSe
try { try {
int thisMonthMaxOrder = taskMapper.getMonthMaxOrderByDate(DateUtils.getCurrentYear(), DateUtils.getCurrentMonth(), TmTaskTypeEnum.TM_TASK_MATERIAL_BACK.getTaskTypeId()); int thisMonthMaxOrder = taskMapper.getMonthMaxOrderByDate(DateUtils.getCurrentYear(), DateUtils.getCurrentMonth(), TmTaskTypeEnum.TM_TASK_MATERIAL_BACK.getTaskTypeId());
String code = genderTaskCode(thisMonthMaxOrder); String code = genderTaskCode(thisMonthMaxOrder);
TmTask tmTask = new TmTask(); TmTask tmTask;
if (dto.getBackApplyInfo().getIsBack() == 1) { if (dto.getBackApplyInfo().getIsBack() == 1) {
tmTask = new TmTask(null, TmTaskTypeEnum.TM_TASK_MATERIAL_BACK.getTaskTypeId(), tmTask = new TmTask(null, TmTaskTypeEnum.TM_TASK_MATERIAL_BACK.getTaskTypeId(),
BackTaskStatusEnum.BACK_TASK_IN_FINISHED.getStatus(), BackTaskStatusEnum.BACK_TASK_IN_FINISHED.getStatus(),

View File

@ -61,10 +61,10 @@ import javax.annotation.Resource;
public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService { public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
// 来源1: 单位直接领用 // 来源1: 单位直接领用
private static final Integer DIRECT_RESOURCE = 1; private static final Integer DIRECT_RESOURCE = GlobalConstants.INT_1;
// 来源2: 班组领用同步过来的数据 // 来源2: 班组领用同步过来的数据
private static final Integer SYNC_RESOURCE = 2; private static final Integer SYNC_RESOURCE = GlobalConstants.INT_2;
@Autowired @Autowired
LeaseApplyInfoMapper leaseApplyInfoMapper; LeaseApplyInfoMapper leaseApplyInfoMapper;
@ -272,7 +272,7 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
String taskCode = genderTaskCode(thisMonthMaxOrder); String taskCode = genderTaskCode(thisMonthMaxOrder);
TmTask tmTask = new TmTask(null, TmTaskTypeEnum.TM_TASK_MATERIAL_LEASE.getTaskTypeId(), TmTask tmTask = new TmTask(null, TmTaskTypeEnum.TM_TASK_MATERIAL_LEASE.getTaskTypeId(),
LeaseTaskStatusEnum.LEASE_TASK_FINISHED.getStatus(), LeaseTaskStatusEnum.LEASE_TASK_FINISHED.getStatus(),
null, thisMonthMaxOrder + 1, taskCode); null, thisMonthMaxOrder + GlobalConstants.INT_1, taskCode);
tmTask.setCreateTime(DateUtils.getNowDate()); tmTask.setCreateTime(DateUtils.getNowDate());
tmTask.setCreateBy(createBy); tmTask.setCreateBy(createBy);
tmTask.setPreTaskId(Long.parseLong(record.getTaskId())); tmTask.setPreTaskId(Long.parseLong(record.getTaskId()));
@ -415,7 +415,7 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
record.setCreateTime(DateUtils.getNowDate()); record.setCreateTime(DateUtils.getNowDate());
record.setCreateBy(createBy); record.setCreateBy(createBy);
record.setParentId(id); record.setParentId(id);
record.setIsFinished(1); record.setIsFinished(GlobalConstants.INT_1);
int res = materialLeaseInfoMapper.insertLeaseOutDetails(record); int res = materialLeaseInfoMapper.insertLeaseOutDetails(record);
if (res == GlobalConstants.INT_0) { if (res == GlobalConstants.INT_0) {
throw new RuntimeException("出库失败,插入结算记录失败"); throw new RuntimeException("出库失败,插入结算记录失败");
@ -467,7 +467,7 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
Date nowDate = DateUtils.getNowDate(); Date nowDate = DateUtils.getNowDate();
String format = dateFormat.format(nowDate); String format = dateFormat.format(nowDate);
String result = format.replace("-", ""); String result = format.replace("-", "");
return MaterialConstants.MATERIAL_LEASE_TASK_TYPE_LABEL + result + String.format("-%03d", thisMonthMaxOrder + 1); return MaterialConstants.MATERIAL_LEASE_TASK_TYPE_LABEL + result + String.format("-%03d", thisMonthMaxOrder + GlobalConstants.INT_1);
} }
/** /**
@ -481,7 +481,7 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
String format = dateFormat.format(nowDate); String format = dateFormat.format(nowDate);
String result = format.replace("-", ""); String result = format.replace("-", "");
int num = bmAgreementInfoMapper.selectNumByMonthClz(nowDate); int num = bmAgreementInfoMapper.selectNumByMonthClz(nowDate);
return MaterialConstants.AGREEMENT_PREFIX + result + String.format("-%03d", num + 1); return MaterialConstants.AGREEMENT_PREFIX + result + String.format("-%03d", num + GlobalConstants.INT_1);
} }
/** /**
@ -556,7 +556,7 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
} }
for (LeaseOutDetails leaseOutDetails : record.getMaCodeList()) { for (LeaseOutDetails leaseOutDetails : record.getMaCodeList()) {
// 3插入出库记录修改库存修改机具状态 // 3插入出库记录修改库存修改机具状态
leaseOutDetails.setOutNum(BigDecimal.valueOf(1)); leaseOutDetails.setOutNum(BigDecimal.valueOf(GlobalConstants.INT_1));
leaseOutDetails.setParentId(record.getParentId()); leaseOutDetails.setParentId(record.getParentId());
leaseOutDetails.setPublishTask(StringUtils.isNotBlank(record.getPublishTask()) ? record.getPublishTask() : null); leaseOutDetails.setPublishTask(StringUtils.isNotBlank(record.getPublishTask()) ? record.getPublishTask() : null);
leaseOutDetails.setLeaseUnit(record.getLeaseUnit()); leaseOutDetails.setLeaseUnit(record.getLeaseUnit());
@ -753,7 +753,7 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
} }
} }
} }
return 1; return GlobalConstants.INT_1;
} }
private int insertRecords(LeaseOutDetails record) { private int insertRecords(LeaseOutDetails record) {
@ -780,11 +780,11 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
// 普通机具减少 (ma_type 设备规格表)的库存数量 // 普通机具减少 (ma_type 设备规格表)的库存数量
res = typeMapper.updateMaTypeStockNum(record); res = typeMapper.updateMaTypeStockNum(record);
if (record.getMaId() != null) { if (record.getMaId() != null) {
if (record.getJiJuType() == 1) { if (record.getJiJuType() == GlobalConstants.INT_1) {
record.setThisCheckTime(DateUtils.getNowDate()); record.setThisCheckTime(DateUtils.getNowDate());
LocalDate currentDate = LocalDate.now(); LocalDate currentDate = LocalDate.now();
// 计算下一次检验日期当前日期加一年减一天 // 计算下一次检验日期当前日期加一年减一天
LocalDate nextCheckDate = currentDate.plusYears(1).minusDays(1); LocalDate nextCheckDate = currentDate.plusYears(GlobalConstants.INT_1).minusDays(GlobalConstants.INT_1);
record.setNextCheckTime(DateUtils.toDate(nextCheckDate)); record.setNextCheckTime(DateUtils.toDate(nextCheckDate));
} }
// 更新 (ma_machine 设备表)的状态 // 更新 (ma_machine 设备表)的状态

View File

@ -56,10 +56,10 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
private static final String SAFETY_EQUIPMENT_COST_USERS = "safety_equipment_cost_users"; private static final String SAFETY_EQUIPMENT_COST_USERS = "safety_equipment_cost_users";
// 工器具结算类型settlement_type键值 // 工器具结算类型settlement_type键值
private static final Byte EQUIPMENT_SETTLEMENT_TYPE = 1; private static final Byte EQUIPMENT_SETTLEMENT_TYPE = (byte) GlobalConstants.INT_1;
// 安全工器具结算类型settlement_type键值 // 安全工器具结算类型settlement_type键值
private static final Byte SAFETY_EQUIPMENT_SETTLEMENT_TYPE = 2; private static final Byte SAFETY_EQUIPMENT_SETTLEMENT_TYPE = (byte) GlobalConstants.INT_2;
@Autowired @Autowired
private SltAgreementInfoMapper sltAgreementInfoMapper; private SltAgreementInfoMapper sltAgreementInfoMapper;
@ -110,11 +110,11 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
SltInfoVo sltInfoVo = new SltInfoVo(); SltInfoVo sltInfoVo = new SltInfoVo();
sltInfoVo.setUnitName(info.getUnitName()); sltInfoVo.setUnitName(info.getUnitName());
sltInfoVo.setProjectName(info.getProjectName()); sltInfoVo.setProjectName(info.getProjectName());
BigDecimal leaseCost = BigDecimal.valueOf(0.00); BigDecimal leaseCost = BigDecimal.ZERO;
BigDecimal repairCost = BigDecimal.valueOf(0.00); BigDecimal repairCost = BigDecimal.ZERO;
BigDecimal scrapCost = BigDecimal.valueOf(0.00); BigDecimal scrapCost = BigDecimal.ZERO;
BigDecimal loseCost = BigDecimal.valueOf(0.00); BigDecimal loseCost = BigDecimal.ZERO;
BigDecimal reducCost = BigDecimal.valueOf(0.00); BigDecimal reducCost = BigDecimal.ZERO;
//租赁费用列表 //租赁费用列表
List<SltAgreementInfo> leaseList = getLeaseList(info); List<SltAgreementInfo> leaseList = getLeaseList(info);
//维修费用列表 //维修费用列表
@ -235,7 +235,7 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
bean.setLeasePrice(bean.getLeasePrice().setScale(2, RoundingMode.HALF_UP)); bean.setLeasePrice(bean.getLeasePrice().setScale(2, RoundingMode.HALF_UP));
} }
if (null == bean.getNum()) { if (null == bean.getNum()) {
bean.setNum(BigDecimal.valueOf(0L)); bean.setNum(BigDecimal.ZERO);
} }
if (null == bean.getLeaseDays()) { if (null == bean.getLeaseDays()) {
bean.setLeaseDay(0L); bean.setLeaseDay(0L);
@ -243,7 +243,7 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
BigDecimal leasePrice = bean.getLeasePrice(); BigDecimal leasePrice = bean.getLeasePrice();
BigDecimal num = bean.getNum(); BigDecimal num = bean.getNum();
BigDecimal leaseDays = new BigDecimal(bean.getLeaseDays()); BigDecimal leaseDays = new BigDecimal(bean.getLeaseDays());
BigDecimal costs = leasePrice.multiply(num).multiply(leaseDays).setScale(2, RoundingMode.HALF_UP); BigDecimal costs = leasePrice.multiply(num).multiply(leaseDays).setScale(GlobalConstants.INT_2, RoundingMode.HALF_UP);
bean.setCosts(costs); bean.setCosts(costs);
} }
return leaseList; return leaseList;
@ -275,10 +275,10 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
for (SltAgreementInfo bean : loseList) { for (SltAgreementInfo bean : loseList) {
if (null == bean.getBuyPrice()) { if (null == bean.getBuyPrice()) {
bean.setBuyPrice(BigDecimal.valueOf(0.00)); bean.setBuyPrice(BigDecimal.ZERO);
} }
if (null == bean.getNum()) { if (null == bean.getNum()) {
bean.setNum(BigDecimal.valueOf(0L)); bean.setNum(BigDecimal.ZERO);
} }
BigDecimal buyPrice = bean.getBuyPrice(); BigDecimal buyPrice = bean.getBuyPrice();
BigDecimal num = bean.getNum(); BigDecimal num = bean.getNum();
@ -293,8 +293,7 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
private List<SltAgreementReduce> getReductionList(SltAgreementInfo info) { private List<SltAgreementReduce> getReductionList(SltAgreementInfo info) {
SltAgreementReduce bean =new SltAgreementReduce(); SltAgreementReduce bean =new SltAgreementReduce();
bean.setAgreementId(info.getAgreementId()); bean.setAgreementId(info.getAgreementId());
List<SltAgreementReduce> reductionList = sltAgreementRecudceMapper.getReductionList(bean); return sltAgreementRecudceMapper.getReductionList(bean);
return reductionList;
} }
private List<SltAgreementRelation> getRelations(List<SltAgreementInfo> leaseList, List<SltAgreementInfo> repairList, private List<SltAgreementRelation> getRelations(List<SltAgreementInfo> leaseList, List<SltAgreementInfo> repairList,
@ -308,7 +307,7 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
BigDecimal scrapCost = BigDecimal.ZERO; BigDecimal scrapCost = BigDecimal.ZERO;
BigDecimal repairCost = BigDecimal.ZERO; BigDecimal repairCost = BigDecimal.ZERO;
for (SltAgreementInfo lease : leaseList) { for (SltAgreementInfo lease : leaseList) {
if (lease.getAgreementId().equals(sltInfo.getAgreementId().toString())) { if (lease.getAgreementId().equals(sltInfo.getAgreementId())) {
relation.setAgreementId(String.valueOf(lease.getAgreementId())); relation.setAgreementId(String.valueOf(lease.getAgreementId()));
relation.setProjectName(lease.getProjectName()); relation.setProjectName(lease.getProjectName());
relation.setUnitName(lease.getUnitName()); relation.setUnitName(lease.getUnitName());
@ -318,19 +317,19 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
} }
} }
for (SltAgreementInfo repair : repairList) { for (SltAgreementInfo repair : repairList) {
if (repair.getAgreementId().equals(sltInfo.getAgreementId().toString())) { if (repair.getAgreementId().equals(sltInfo.getAgreementId())) {
BigDecimal cost = repair.getCosts(); BigDecimal cost = repair.getCosts();
repairCost = repairCost.add(cost); repairCost = repairCost.add(cost);
} }
} }
for (SltAgreementInfo scrap : scrapList) { for (SltAgreementInfo scrap : scrapList) {
if (scrap.getAgreementId().equals(sltInfo.getAgreementId().toString())) { if (scrap.getAgreementId().equals(sltInfo.getAgreementId())) {
BigDecimal cost = scrap.getCosts(); BigDecimal cost = scrap.getCosts();
scrapCost = scrapCost.add(cost); scrapCost = scrapCost.add(cost);
} }
} }
for (SltAgreementInfo lose : loseList) { for (SltAgreementInfo lose : loseList) {
if (lose.getAgreementId().equals(sltInfo.getAgreementId().toString())) { if (lose.getAgreementId().equals(sltInfo.getAgreementId())) {
relation.setAgreementId(String.valueOf(lose.getAgreementId())); relation.setAgreementId(String.valueOf(lose.getAgreementId()));
relation.setProjectName(lose.getProjectName()); relation.setProjectName(lose.getProjectName());
relation.setUnitName(lose.getUnitName()); relation.setUnitName(lose.getUnitName());
@ -509,13 +508,13 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
if (equipmentConfigUsers != null && equipmentConfigUsers.getItemValue() != null) { if (equipmentConfigUsers != null && equipmentConfigUsers.getItemValue() != null) {
boolean isContains = containsExactValue(equipmentConfigUsers.getItemValue(), String.valueOf(theLoginUserId)); boolean isContains = containsExactValue(equipmentConfigUsers.getItemValue(), String.valueOf(theLoginUserId));
if (isContains) { if (isContains) {
return 1; return GlobalConstants.INT_1;
} }
} }
if (safetyEquipmentConfigUsers != null && safetyEquipmentConfigUsers.getItemValue() != null) { if (safetyEquipmentConfigUsers != null && safetyEquipmentConfigUsers.getItemValue() != null) {
boolean isContains = containsExactValue(safetyEquipmentConfigUsers.getItemValue(), String.valueOf(theLoginUserId)); boolean isContains = containsExactValue(safetyEquipmentConfigUsers.getItemValue(), String.valueOf(theLoginUserId));
if (isContains) { if (isContains) {
return 2; return GlobalConstants.INT_2;
} }
} }
throw new ServiceException("没有权限进行系统结算!"); throw new ServiceException("没有权限进行系统结算!");