Browse Source

git-svn-id: https://192.168.57.71/svn/jsgkj@1958 931142cf-59ea-a443-aa0e-51397b428577

xt_xuhao 8 years ago
parent
commit
887ca23c8a

+ 103 - 0
gkaq/yjpt-java/trunk/java_src/com/jtgh/yjpt/controller/cgInfo/cgInfoController.java

@@ -1,6 +1,7 @@
 package com.jtgh.yjpt.controller.cgInfo;
 
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 
 import org.springframework.beans.factory.annotation.Autowired;
@@ -9,17 +10,28 @@ import org.springframework.data.domain.Pageable;
 import org.springframework.data.jpa.domain.Specification;
 import org.springframework.flex.remoting.RemotingDestination;
 import org.springframework.stereotype.Controller;
+import org.springframework.util.CollectionUtils;
 
 import com.jtgh.yjpt.anon.Log;
 import com.jtgh.yjpt.anon.Log.Type;
 import com.jtgh.yjpt.common.BusinessContext;
+import com.jtgh.yjpt.common.Constants;
+import com.jtgh.yjpt.common.GlobalData;
 import com.jtgh.yjpt.common.PredicateModel;
+import com.jtgh.yjpt.common.SinglePageRequest;
 import com.jtgh.yjpt.common.PredicateModel.Operator;
 import com.jtgh.yjpt.common.SpecificationCreater;
+import com.jtgh.yjpt.common.Utils;
 import com.jtgh.yjpt.controller.BaseController;
 import com.jtgh.yjpt.entity.BaseEntity;
 import com.jtgh.yjpt.entity.cginfo.CgInfoEntity;
+import com.jtgh.yjpt.entity.cginfo.CgOperationConditionEntity;
+import com.jtgh.yjpt.entity.cginfo.CgStorageEntity;
+import com.jtgh.yjpt.entity.check.ZcyhEntity;
+import com.jtgh.yjpt.entity.common.AccessoryEntity;
 import com.jtgh.yjpt.service.cginfo.CgInfoService;
+import com.jtgh.yjpt.service.cginfo.CgOperationConditionService;
+import com.jtgh.yjpt.service.cginfo.CgStorageService;
 
 /**
  * 储罐基本信息Controller
@@ -32,6 +44,10 @@ import com.jtgh.yjpt.service.cginfo.CgInfoService;
 public class cgInfoController extends BaseController {
 	@Autowired
 	CgInfoService cgInfoService;
+	@Autowired
+	CgStorageService storageService;
+	@Autowired
+	CgOperationConditionService opService;
 	
 	@Log(Type.QUERY)
 	public BusinessContext list(Pageable pageable,Long functionId) {
@@ -45,4 +61,91 @@ public class cgInfoController extends BaseController {
 	}
 	
 	
+	@Log(Type.ADD)
+	public BusinessContext add(Long functionId, CgInfoEntity entity,
+			List<CgStorageEntity> storageList,List<CgStorageEntity> del_storageList, 
+			List<CgOperationConditionEntity> opList,List<CgOperationConditionEntity> del_opList) {
+		return save(functionId, entity, storageList,del_storageList, opList,del_opList);
+	}
+
+	@Log(Type.EDIT)
+	public BusinessContext edit(Long functionId, CgInfoEntity entity,
+			List<CgStorageEntity> storageList,List<CgStorageEntity> del_storageList, 
+			List<CgOperationConditionEntity> opList,List<CgOperationConditionEntity> del_opList) {
+		return save(functionId, entity, storageList,del_storageList, opList,del_opList);
+	}
+	
+	
+	private BusinessContext save(Long functionId, CgInfoEntity entity,
+			List<CgStorageEntity> storageList,List<CgStorageEntity> del_storageList, 
+			List<CgOperationConditionEntity> opList,List<CgOperationConditionEntity> del_opList) { 
+		if (null == entity.getId() || entity.getId()==0L) {
+			entity.setAddUser(Utils.getCurrentUser());
+			entity.setAddDate(new Date());
+			entity.setRecordCode(getCurrentRoleCode(functionId)); 
+		} else {
+			entity.setUpdateUser(Utils.getCurrentUser());
+			entity.setUpdateDate(new Date());
+		}
+		 
+		// 先保存cginfo实体
+		CgInfoEntity cginfoEntity = cgInfoService.save(entity);
+		
+		//cg storage
+		for(CgStorageEntity storage_entity:storageList){ 
+			if(storage_entity.getId()==null || storage_entity.getId()==0L){
+				storage_entity.setAddUser(Utils.getCurrentUser());
+				storage_entity.setAddDate(new Date());
+				storage_entity.setRecordCode(getCurrentRoleCode(functionId));
+				storage_entity.setCgInfoId(cginfoEntity);
+			}
+			else{
+				storage_entity.setUpdateDate(new Date());
+				storage_entity.setUpdateUser(Utils.getCurrentUser());
+			}
+			storageService.save(storage_entity);
+		}
+		for(CgStorageEntity storage_entity:del_storageList){ 
+			storageService.logicDelete(storage_entity);
+		} 
+		
+		//cg operation condidtion
+		for(CgOperationConditionEntity op_entity:opList){ 
+			if(op_entity.getId()==null || op_entity.getId()==0L){
+				op_entity.setAddUser(Utils.getCurrentUser());
+				op_entity.setAddDate(new Date());
+				op_entity.setRecordCode(getCurrentRoleCode(functionId));
+				op_entity.setCgInfoId(cginfoEntity);
+			}
+			else{
+				op_entity.setUpdateDate(new Date());
+				op_entity.setUpdateUser(Utils.getCurrentUser());
+			} 
+			opService.save(op_entity);
+		}
+		for(CgOperationConditionEntity op_entity:del_opList){ 
+			opService.logicDelete(op_entity);
+		} 
+		
+		// 同步
+		if (Constants.YES.equals(GlobalData.JAXWS_SYNC) && GlobalData.DEPLOY_MODE.equals(Constants.DEPLOY_MODE_CITY)) {
+		
+		}
+		BusinessContext bc = new BusinessContext(); 
+		bc.setAttribute("success", true);
+		return bc;
+	}
+	
+	 
+	public BusinessContext getCgRelatedInfo(long cgInfoId) {
+		BusinessContext bc = new BusinessContext();
+		List<CgStorageEntity> storageList=storageService.findCgStorage(cgInfoId);
+		List<CgOperationConditionEntity> opList = opService.findOpCondition(cgInfoId); 
+		bc.setAttribute("storage", storageList);
+		bc.setAttribute("op", opList); 
+		return bc;
+	}
+	
+	
+	
 }

+ 1 - 2
gkaq/yjpt-java/trunk/java_src/com/jtgh/yjpt/controller/check/ZcController.java

@@ -310,8 +310,7 @@ public class ZcController extends BaseController {
 					}
 				}
 				if (null != zcyhEntity.getZgjg()) {
-					AccessoryEntity zgjg = accessoryService.findOne(zcyhEntity
-							.getZgjg().getId());
+					AccessoryEntity zgjg = accessoryService.findOne(zcyhEntity.getZgjg().getId());
 					if (null != zgjg) {
 						zgjg.setEntityId(zcyhEntity.getId());
 						accessoryService.save(zgjg);

+ 8 - 1
gkaq/yjpt-java/trunk/java_src/com/jtgh/yjpt/dao/cginfo/CgOperationConditionDao.java

@@ -1,9 +1,16 @@
 package com.jtgh.yjpt.dao.cginfo;
 
+import java.util.List;
+
+import org.springframework.data.jpa.repository.Query;
+
 import com.jtgh.yjpt.dao.common.MyRepository;
 import com.jtgh.yjpt.entity.cginfo.CgOperationConditionEntity;
 
 
 public interface CgOperationConditionDao extends MyRepository<CgOperationConditionEntity, Long>{
-
+	
+	@Query("from CgOperationConditionEntity where cgInfoId.id = ?1 and  recordStatus <> 9")
+	public List<CgOperationConditionEntity> findOpCondition(long cgInfoId);
+	
 }

+ 6 - 0
gkaq/yjpt-java/trunk/java_src/com/jtgh/yjpt/dao/cginfo/CgStorageDao.java

@@ -1,8 +1,14 @@
 package com.jtgh.yjpt.dao.cginfo;
 
+import java.util.List;
+
+import org.springframework.data.jpa.repository.Query;
+
 import com.jtgh.yjpt.dao.common.MyRepository;
 import com.jtgh.yjpt.entity.cginfo.CgStorageEntity;
 
 public interface CgStorageDao extends MyRepository<CgStorageEntity, Long>{
 
+	@Query("from CgStorageEntity where cgInfoId.id = ?1 and  recordStatus <> 9")
+	public List<CgStorageEntity> findCgStorage(long cgInfoId);
 }

+ 17 - 28
gkaq/yjpt-java/trunk/java_src/com/jtgh/yjpt/dao/common/MyCustomRepository.java

@@ -34,25 +34,22 @@ public class MyCustomRepository<T extends BaseEntity<ID>, ID extends Serializabl
 	public <S extends T> S save(S entity) {
 		try {
 			ID id = (ID) entity.getClass().getMethod("getId").invoke(entity);
-			if (id == null || id.equals(0l)) {
+			if (id == null || id.equals(0L)) {
 				// 通过序列自动生成ID
-				id = (ID) entityManager.createNativeQuery(
-						"SELECT " + entity.getSequenceName()
-								+ ".NEXTVAL FROM DUAL").getSingleResult();
-				entity.getClass().getMethod("setId", Long.class)
-						.invoke(entity, new Long(id.toString()));
+				id = (ID) entityManager.createNativeQuery("SELECT " + entity.getSequenceName()+ ".NEXTVAL FROM DUAL").getSingleResult();
+				entity.getClass().getMethod("setId", Long.class).invoke(entity, new Long(id.toString()));
 			}
 			if (entity.getSzd() == null) {
 				CodeEntity szd = new CodeEntity();
 				// 先从用户取所在地,再从系统配置中取
-				if (Utils.getCurrentUser() != null
-						&& Utils.getCurrentUser().getSzd() != null) {
+				if (Utils.getCurrentUser() != null && Utils.getCurrentUser().getSzd() != null) {
 					szd = Utils.getCurrentUser().getSzd();
 				} else {
 					szd.setId(new Long(GlobalData.CITY_CODE));
 				}
 				entity.setSzd(szd);
 			}
+			entity.setTbzt(Constants.NO);
 		} catch (Exception e) {
 			e.printStackTrace();
 		}
@@ -62,25 +59,22 @@ public class MyCustomRepository<T extends BaseEntity<ID>, ID extends Serializabl
 	public T saveAndFlush(T entity) {
 		try {
 			ID id = (ID) entity.getClass().getMethod("getId").invoke(entity);
-			if (id == null || id.equals(0l)) {
+			if (id == null || id.equals(0L)) {
 				// 通过序列自动生成ID
-				id = (ID) entityManager.createNativeQuery(
-						"SELECT " + entity.getSequenceName()
-								+ ".NEXTVAL FROM DUAL").getSingleResult();
-				entity.getClass().getMethod("setId", Long.class)
-						.invoke(entity, new Long(id.toString()));
+				id = (ID) entityManager.createNativeQuery("SELECT " + entity.getSequenceName()+ ".NEXTVAL FROM DUAL").getSingleResult();
+				entity.getClass().getMethod("setId", Long.class).invoke(entity, new Long(id.toString()));
 			}
 			if (entity.getSzd() == null) {
 				CodeEntity szd = new CodeEntity();
 				// 先从用户取所在地,再从系统配置中取
-				if (Utils.getCurrentUser() != null
-						&& Utils.getCurrentUser().getSzd() != null) {
+				if (Utils.getCurrentUser() != null && Utils.getCurrentUser().getSzd() != null) {
 					szd = Utils.getCurrentUser().getSzd();
 				} else {
 					szd.setId(new Long(GlobalData.CITY_CODE));
 				}
 				entity.setSzd(szd);
 			}
+			entity.setTbzt(Constants.NO);
 		} catch (Exception e) {
 			e.printStackTrace();
 		}
@@ -91,26 +85,22 @@ public class MyCustomRepository<T extends BaseEntity<ID>, ID extends Serializabl
 		try {
 			CodeEntity szd = new CodeEntity();
 			// 先从用户取所在地,再从系统配置中取
-			if (Utils.getCurrentUser() != null
-					&& Utils.getCurrentUser().getSzd() != null) {
+			if (Utils.getCurrentUser() != null && Utils.getCurrentUser().getSzd() != null) {
 				szd = Utils.getCurrentUser().getSzd();
 			} else {
 				szd.setId(new Long(GlobalData.CITY_CODE));
 			}
 			for (S entity : entities) {
-				ID id = (ID) entity.getClass().getMethod("getId")
-						.invoke(entity);
-				if (id == null || id.equals(0l)) {
+				ID id = (ID) entity.getClass().getMethod("getId") .invoke(entity);
+				if (id == null || id.equals(0L)) {
 					// 通过序列自动生成ID
-					id = (ID) entityManager.createNativeQuery(
-							"SELECT " + entity.getSequenceName()
-									+ ".NEXTVAL FROM DUAL").getSingleResult();
-					entity.getClass().getMethod("setId", Long.class)
-							.invoke(entity, new Long(id.toString()));
+					id = (ID) entityManager.createNativeQuery( "SELECT " + entity.getSequenceName() + ".NEXTVAL FROM DUAL").getSingleResult();
+					entity.getClass().getMethod("setId", Long.class) .invoke(entity, new Long(id.toString()));
 				}
 				if (entity.getSzd() == null) {
 					entity.setSzd(szd);
 				}
+				entity.setTbzt(Constants.NO);
 			}
 		} catch (Exception e) {
 			e.printStackTrace();
@@ -204,8 +194,7 @@ public class MyCustomRepository<T extends BaseEntity<ID>, ID extends Serializabl
 	public void logicDelete(Iterable<T> entities) {
 		for (T entity : entities) {
 			try {
-				logicDelete((ID) entity.getClass().getMethod("getId")
-						.invoke(entity));
+				logicDelete((ID) entity.getClass().getMethod("getId") .invoke(entity));
 			} catch (Exception e) {
 				e.printStackTrace();
 			}

+ 5 - 0
gkaq/yjpt-java/trunk/java_src/com/jtgh/yjpt/service/cginfo/CgOperationConditionService.java

@@ -1,5 +1,7 @@
 package com.jtgh.yjpt.service.cginfo;
 
+import java.util.List;
+
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
 import org.springframework.data.jpa.domain.Specification;
@@ -12,4 +14,7 @@ public interface CgOperationConditionService {
 	//public CgOperationConditionEntity save(CgOperationConditionEntity entity);
 	public <S extends CgOperationConditionEntity> S save(S entity);
 	public void logicDelete(Long id);
+	public void logicDelete(CgOperationConditionEntity entity);
+	public void logicDelete(Iterable<CgOperationConditionEntity> entities);
+	public List<CgOperationConditionEntity> findOpCondition(long cgInfoId);
 }

+ 6 - 1
gkaq/yjpt-java/trunk/java_src/com/jtgh/yjpt/service/cginfo/CgStorageService.java

@@ -1,10 +1,12 @@
 package com.jtgh.yjpt.service.cginfo;
 
+import java.util.List;
+
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
 import org.springframework.data.jpa.domain.Specification;
 
-import com.jtgh.yjpt.entity.cginfo.CgStorageEntity;
+import com.jtgh.yjpt.entity.cginfo.CgStorageEntity; 
 
 public interface CgStorageService {
 	public Page<CgStorageEntity> findAll(Specification<CgStorageEntity> spec, Pageable pageable);
@@ -12,4 +14,7 @@ public interface CgStorageService {
 	//public CgStorageEntity save(CgStorageEntity entity);
 	public <S extends CgStorageEntity> S save(S entity);
 	public void logicDelete(Long id);
+	public void logicDelete(CgStorageEntity entity);
+	public void logicDelete(Iterable<CgStorageEntity> entities);
+	public List<CgStorageEntity> findCgStorage(long cgInfoId);
 }

+ 6 - 0
gkaq/yjpt-java/trunk/java_src/com/jtgh/yjpt/service/impl/cginfo/CgOperationConditionServiceImpl.java

@@ -1,5 +1,7 @@
 package com.jtgh.yjpt.service.impl.cginfo;
 
+import java.util.List;
+
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -20,5 +22,9 @@ public class CgOperationConditionServiceImpl extends BaseService<CgOperationCond
 		return dao;
 	}
 
+	@Override
+	public List<CgOperationConditionEntity> findOpCondition(long cgInfoId){
+		return dao.findOpCondition(cgInfoId);
+	}
 	
 }

+ 7 - 0
gkaq/yjpt-java/trunk/java_src/com/jtgh/yjpt/service/impl/cginfo/CgStorageServiceImpl.java

@@ -1,5 +1,7 @@
 package com.jtgh.yjpt.service.impl.cginfo;
 
+import java.util.List;
+
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -19,4 +21,9 @@ public class CgStorageServiceImpl extends BaseService<CgStorageEntity, Long> imp
 		return dao;
 	}
 	
+	@Override
+	public List<CgStorageEntity> findCgStorage(long cgInfoId){
+		return dao.findCgStorage(cgInfoId);
+	}
+	
 }

+ 2 - 2
gkaq/yjpt-java/trunk/resources/sql/init/9.update.sql.ftl

@@ -8661,7 +8661,7 @@ create table T_YJPT_CG_INFO
 	DESIGN_ORG_QUALIFICATION VARCHAR2(100),
 	DESIGN_PRESSURE NUMBER(*,3),
 	DESIGN_TEMP NUMBER(*,3),
-	HAVA_COMPLETION_INFO CHAR(1),
+	HAVE_COMPLETION_INFO CHAR(1),
 	BUILD_ORG_NAME VARCHAR2(100),
 	BUILD_ORG_QUALIFICATION VARCHAR2(100),
 	IS_REGULAR_DETECTION CHAR(1),
@@ -8707,7 +8707,7 @@ comment on column T_YJPT_CG_INFO.DESIGN_ORG_NAME is '储罐设计单位名称';
 comment on column T_YJPT_CG_INFO.DESIGN_ORG_QUALIFICATION is '储罐设计单位资质';
 comment on column T_YJPT_CG_INFO.DESIGN_PRESSURE is '储罐设计压力MPa';
 comment on column T_YJPT_CG_INFO.DESIGN_TEMP is '储罐设计温度℃';
-comment on column T_YJPT_CG_INFO.HAVA_COMPLETION_INFO is '是否有建造工程资料(竣工资料)';
+comment on column T_YJPT_CG_INFO.HAVE_COMPLETION_INFO is '是否有建造工程资料(竣工资料)';
 comment on column T_YJPT_CG_INFO.BUILD_ORG_NAME is '建造单位名称';
 comment on column T_YJPT_CG_INFO.BUILD_ORG_NAME is '建造单位资质';
 comment on column T_YJPT_CG_INFO.IS_REGULAR_DETECTION is '是否对储罐进行过定期检测';