|
@@ -65,11 +65,53 @@ object ComponentService : Service<Equipment>(SMybatisDao(Equipment::class.java))
|
|
|
}
|
|
|
/** 项目id */
|
|
|
component.projectId = Opt.projectId
|
|
|
+
|
|
|
+ if (component.classCode.isNullOrEmpty()) {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ if (!Opt.coming.isNullOrEmpty()) {
|
|
|
+ component.appId = Opt.coming
|
|
|
+ }
|
|
|
+ if(component.classCode!!.length<8){
|
|
|
+ val entity = EquipmentService.defClassService.select(
|
|
|
+ SFilter.eq("projectId", component.projectId!!),
|
|
|
+ SFilter.endWith("code", component.classCode!!)
|
|
|
+ ).entity()
|
|
|
+ if (entity!=null&&entity.code!!.length>=8){
|
|
|
+ component.classCode = entity.code
|
|
|
+ } else {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ val entity = EquipmentService.defClassService.select(
|
|
|
+ SFilter.eq("projectId", component.projectId!!),
|
|
|
+ SFilter.endWith("code", component.classCode!!)
|
|
|
+ ).entity()
|
|
|
+ if (entity == null) {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /** 设备名字 */
|
|
|
+ if (component.name.isNullOrEmpty()) {
|
|
|
+ val entity = EquipmentService.defClassService.select(
|
|
|
+ SFilter.eq("projectId", component.projectId!!),
|
|
|
+ SFilter.eq("code", component.classCode!!)
|
|
|
+ ).entity()
|
|
|
+ if (entity!=null) {
|
|
|
+ component.name = ShaftNameUtil.shaftName(entity.name+"-")
|
|
|
+ }else {
|
|
|
+ component.name = ShaftNameUtil.shaftName("设备-")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!Opt.account.isNullOrEmpty()){
|
|
|
+ component.findPeople = Opt.account
|
|
|
+ }
|
|
|
+
|
|
|
/** 部件名字 */
|
|
|
if (component.name.isNullOrEmpty()) {
|
|
|
component.name = ShaftNameUtil.shaftName("部件-")
|
|
|
}
|
|
|
- component.objectType = "Component"
|
|
|
+ component.objectType = "component"
|
|
|
return true
|
|
|
} // Function onCreateBefore()
|
|
|
|
|
@@ -93,6 +135,8 @@ object ComponentService : Service<Equipment>(SMybatisDao(Equipment::class.java))
|
|
|
return
|
|
|
} // Function onCountBefore()
|
|
|
|
|
|
+
|
|
|
+
|
|
|
override fun onDeleteBefore(cquipment: Equipment): Boolean {
|
|
|
try {
|
|
|
cquipment.objectType = "component"
|
|
@@ -108,6 +152,21 @@ object ComponentService : Service<Equipment>(SMybatisDao(Equipment::class.java))
|
|
|
|
|
|
override fun onUpdateBefore(entity: Equipment): Boolean {
|
|
|
entity.objectType = "component"
|
|
|
+ if(entity.classCode!!.length<8){
|
|
|
+ val defClass = EquipmentService.defClassService.select(
|
|
|
+ SFilter.eq("projectId", Opt.projectId!!),
|
|
|
+ SFilter.endWith("code", entity.classCode!!)
|
|
|
+ ).entity()
|
|
|
+ if (defClass!=null){
|
|
|
+ entity.classCode = defClass.code
|
|
|
+ } else {
|
|
|
+ entity.classCode = null
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (entity.projectId.isNullOrEmpty()){
|
|
|
+ entity.projectId = Opt.projectId
|
|
|
+ }
|
|
|
+
|
|
|
return super.onUpdateBefore(entity)
|
|
|
}
|
|
|
|