推送地址

This commit is contained in:
sxu 2024-09-04 15:32:02 +08:00
parent c3f7eacb79
commit 6b69ffcf8b
3 changed files with 37 additions and 30 deletions

View File

@ -1,10 +1,8 @@
package com.bonus.sgzb.common.core.utils; package com.bonus.sgzb.common.core.utils;
import java.security.SecureRandom; import java.security.SecureRandom;
import java.util.Collection; import java.util.*;
import java.util.Date;
import java.util.List;
import java.util.Map;
import com.bonus.sgzb.common.core.constant.Constants; import com.bonus.sgzb.common.core.constant.Constants;
import com.bonus.sgzb.common.core.text.StrFormatter; import com.bonus.sgzb.common.core.text.StrFormatter;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -24,7 +22,18 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
/** 下划线 */ /** 下划线 */
private static final char SEPARATOR = '_'; private static final char SEPARATOR = '_';
private static SecureRandom random = null; private static final Map<String, String> CAT_MAP;
static {
CAT_MAP = new HashMap<>();
CAT_MAP.put("线路施工类", "A");
CAT_MAP.put("变电施工类", "B");
CAT_MAP.put("特种及其他设备", "C");
CAT_MAP.put("检修试验", "D");
CAT_MAP.put("创新装备", "E");
}
/** /**
* 获取参数不为空值 * 获取参数不为空值
@ -557,29 +566,19 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
return sb.toString(); return sb.toString();
} }
// public static String getDeviceCode() { /** 生成工器具编码: 类似CSG-A101-2024061900001 */
// String randomNum = null; public static String getDeviceCode(String ownerCode, String typeName, String typeId, Date date, String maId) {
// try {
// random = SecureRandom.getInstance("SHA1PRNG");
// randomNum = String.format("%02d", random.nextInt(100));
// } catch (NoSuchAlgorithmException e) {
// log.error("生成随机数失败,", e);
// }
// String deviceCode = "CSG-A101-" + DateUtils.dateTime() + randomNum; //like CSG-A101-2024061900001, need save it
// return deviceCode;
// }
public static String getDeviceCode(Date date, String maId) {
int number = Integer.parseInt(maId); int number = Integer.parseInt(maId);
if (number > 50000) { if (number > 30000) {
number = number % 50000; number = number % 30000;
} }
String numberStr = String.format("%05d", number); String numberStr = String.format("%05d", number);
String deviceCode = "CSG-A101-" + DateUtils.getDateTimeString(date) + numberStr; //like CSG-A101-2024061900001 String deviceCode = ownerCode + "-" + CAT_MAP.get(typeName) + typeId + "-" + DateUtils.getDateTimeString(date) + numberStr;
return deviceCode; return deviceCode;
} }
// public static void main(String[] args) { // public static void main(String[] args) {
// System.out.println(getDeviceCode(new Date(), "500322")); // System.out.println(getDeviceCode("CSG", "线路施工类", "102", new Date(), "500322"));
// } // }
} }

View File

@ -1417,7 +1417,8 @@ public class TmTaskServiceImpl implements TmTaskService {
intelVO.setSpecificationType(""); intelVO.setSpecificationType("");
intelVO.setValidityDate(new Date()); intelVO.setValidityDate(new Date());
//每个设备不同点的设置 //每个设备不同点的设置
intelVO.setDeviceCode(StringUtils.getDeviceCode(subTask.getCreateTime(), subTask.getMaId())); String ownerCode = loginUser.getSysUser().getDept().getEnterpriseOwnershipCode();
intelVO.setDeviceCode(StringUtils.getDeviceCode(ownerCode, subTask.getTypeName(), subTask.getTypeId(), subTask.getCreateTime(), subTask.getMaId()));
intelVO.setFactoryDate(subTask.getOutFacTime()); intelVO.setFactoryDate(subTask.getOutFacTime());
intelVO.setMachineryCode(subTask.getMaId()); intelVO.setMachineryCode(subTask.getMaId());
intelVO.setTrialDate(subTask.getThisCheckTime()); intelVO.setTrialDate(subTask.getThisCheckTime());

View File

@ -1176,14 +1176,21 @@
</select> </select>
<select id="getLeaseOutDetails" resultType="com.bonus.sgzb.app.domain.TmTask"> <select id="getLeaseOutDetails" resultType="com.bonus.sgzb.app.domain.TmTask">
select mam.ma_id as maId, select
mam.ma_code as maCode, mam.ma_id as maId,
mam.out_fac_time as outFacTime, mam.ma_code as maCode,
mam.out_fac_code as outFacCode, mam.out_fac_time as outFacTime,
mam.this_check_time as thisCheckTime, mam.out_fac_code as outFacCode,
mam.create_time as createTime mam.this_check_time as thisCheckTime,
mam.create_time as createTime,
mt.type_id,
mt3.type_name as typeName
from lease_out_details lod from lease_out_details lod
left join ma_machine mam on mam.ma_id = lod.ma_id left join ma_machine mam on mam.ma_id = lod.ma_id
where parent_id = #{id} left join ma_type mt on mam.type_id = mt.type_id
left join ma_type mt1 on mt.parent_id = mt1.type_id
left join ma_type mt2 on mt1.parent_id = mt2.type_id
left join ma_type mt3 on mt2.parent_id = mt3.type_id
where lod.parent_id = #{id}
</select> </select>
</mapper> </mapper>