|
@@ -66,61 +66,67 @@ object EquipmentService : Service<Equipment>(SMybatisDao(Equipment::class.java))
|
|
|
* @param equip 设备对象
|
|
|
*/
|
|
|
override fun onCreateBefore(equip: Equipment): Boolean {
|
|
|
- /** 查询准备类型 */
|
|
|
- if (!equip.id.isNullOrEmpty()) {
|
|
|
- val isStartsWith = equip.id.toString().startsWith("Eq")
|
|
|
- if (!isStartsWith) {
|
|
|
+ try {
|
|
|
+ /** 查询准备类型 */
|
|
|
+ if (!equip.id.isNullOrEmpty()) {
|
|
|
+ val isStartsWith = equip.id.toString().startsWith("Eq")
|
|
|
+ if (!isStartsWith) {
|
|
|
+ /** 资产id */
|
|
|
+ equip.id = IdUtils.equipmentIdCreate(Opt.projectId!!)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
/** 资产id */
|
|
|
equip.id = IdUtils.equipmentIdCreate(Opt.projectId!!)
|
|
|
}
|
|
|
- } else {
|
|
|
- /** 资产id */
|
|
|
- equip.id = IdUtils.equipmentIdCreate(Opt.projectId!!)
|
|
|
- }
|
|
|
- /** 项目id */
|
|
|
- equip.projectId = Opt.projectId
|
|
|
- if (equip.classCode.isNullOrEmpty()) {
|
|
|
- return false
|
|
|
- }
|
|
|
- if (!Opt.coming.isNullOrEmpty()) {
|
|
|
- equip.appId = Opt.coming
|
|
|
- }
|
|
|
- if(equip.classCode!!.length<6){
|
|
|
- val entity = defClassService.select(
|
|
|
+ /** 项目id */
|
|
|
+ equip.projectId = Opt.projectId
|
|
|
+
|
|
|
+ if (equip.classCode.isNullOrEmpty()) {
|
|
|
+ logger.debug("33333333333333333333333333333333333")
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ if (!Opt.coming.isNullOrEmpty()) {
|
|
|
+ equip.appId = Opt.coming
|
|
|
+ }
|
|
|
+ if(equip.classCode!!.length<6){
|
|
|
+ val entity = defClassService.select(
|
|
|
+ SFilter.eq("projectId", equip.projectId!!),
|
|
|
+ SFilter.endWith("code", equip.classCode!!)
|
|
|
+ ).entity()
|
|
|
+ if (entity!=null&&entity.code!!.length>=6){
|
|
|
+ equip.classCode = entity.code
|
|
|
+ } else {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ val entity = defClassService.select(
|
|
|
SFilter.eq("projectId", equip.projectId!!),
|
|
|
SFilter.endWith("code", equip.classCode!!)
|
|
|
- ).entity()
|
|
|
- if (entity!=null&&equip.classCode!!.length>=6){
|
|
|
- equip.classCode = entity.code
|
|
|
- } else {
|
|
|
- return false
|
|
|
+ ).entity()
|
|
|
+ if (entity == null) {
|
|
|
+ return false
|
|
|
+ }
|
|
|
}
|
|
|
- } else {
|
|
|
- val entity = defClassService.select(
|
|
|
- SFilter.eq("projectId", equip.projectId!!),
|
|
|
- SFilter.endWith("code", equip.classCode!!)
|
|
|
- ).entity()
|
|
|
- if (entity == null) {
|
|
|
- return false
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /** 设备名字 */
|
|
|
- if (equip.name.isNullOrEmpty()) {
|
|
|
- val entity = defClassService.select(
|
|
|
- SFilter.eq("projectId", equip.projectId!!),
|
|
|
- SFilter.eq("code", equip.classCode!!)
|
|
|
- ).entity()
|
|
|
- if (entity!=null) {
|
|
|
- equip.name = ShaftNameUtil.shaftName(entity.name+"-")
|
|
|
- }else {
|
|
|
- equip.name = ShaftNameUtil.shaftName("设备-")
|
|
|
+ /** 设备名字 */
|
|
|
+ if (equip.name.isNullOrEmpty()) {
|
|
|
+ val entity = defClassService.select(
|
|
|
+ SFilter.eq("projectId", equip.projectId!!),
|
|
|
+ SFilter.eq("code", equip.classCode!!)
|
|
|
+ ).entity()
|
|
|
+ if (entity!=null) {
|
|
|
+ equip.name = ShaftNameUtil.shaftName(entity.name+"-")
|
|
|
+ }else {
|
|
|
+ equip.name = ShaftNameUtil.shaftName("设备-")
|
|
|
+ }
|
|
|
}
|
|
|
+ if (!Opt.account.isNullOrEmpty()){
|
|
|
+ equip.findPeople = Opt.account
|
|
|
+ }
|
|
|
+ equip.codeType = 1
|
|
|
+ } catch (e: Exception) {
|
|
|
+ e.localizedMessage
|
|
|
+ return false
|
|
|
}
|
|
|
- if (!Opt.account.isNullOrEmpty()){
|
|
|
- equip.findPeople = Opt.account
|
|
|
- }
|
|
|
- equip.codeType = 1
|
|
|
return true
|
|
|
} // Function onCreateBefore()
|
|
|
|