|
@@ -0,0 +1,115 @@
|
|
|
+package com.jtgh.yjpt.service.impl.cjhs;
|
|
|
+
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+import javax.persistence.EntityManager;
|
|
|
+import javax.persistence.PersistenceContext;
|
|
|
+
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.domain.Page;
|
|
|
+import org.springframework.data.domain.Pageable;
|
|
|
+import org.springframework.data.jpa.domain.Specification;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import com.jtgh.cjhs.entity.DtywCbsbEntity;
|
|
|
+import com.jtgh.cjhs.service.DtywCbsbService;
|
|
|
+import com.jtgh.yjpt.entity.cjhs.CjhsDbEntity;
|
|
|
+import com.jtgh.yjpt.entity.cjhs.CjhsEntity;
|
|
|
+import com.jtgh.yjpt.entity.zysqbp.ZysqbpEntity;
|
|
|
+import com.jtgh.yjpt.service.cjhs.CjhsService;
|
|
|
+import com.jtgh.yjpt.service.common.QueryService;
|
|
|
+import com.jtgh.yjpt.service.zysqbp.ZysqbpService;
|
|
|
+
|
|
|
+@Service
|
|
|
+public class CjhsServiceImpl implements CjhsService {
|
|
|
+ @Autowired
|
|
|
+ private QueryService query;
|
|
|
+ @Autowired
|
|
|
+ @PersistenceContext(unitName = "entityManagerFactory")
|
|
|
+ private EntityManager entityManager;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ZysqbpService zysqbpService;
|
|
|
+ @Autowired
|
|
|
+ private CjhsService cjhsService;
|
|
|
+ @Autowired
|
|
|
+ private DtywCbsbService dtywCbsbService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Page<CjhsDbEntity> findAll(Specification<CjhsDbEntity> spec,
|
|
|
+ Pageable pageable) {
|
|
|
+ try {
|
|
|
+ return query.findAll(spec, pageable, CjhsDbEntity.class);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void save(CjhsDbEntity entity) {
|
|
|
+ entityManager.persist(entity);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<CjhsDbEntity> findByGksbbh(Long gksbbh) {
|
|
|
+ try {
|
|
|
+ Map<String, Object> params = new HashMap<String, Object>();
|
|
|
+ params.put("gksbbh", gksbbh);
|
|
|
+ return query.nativeQuery(
|
|
|
+ "SELECT * FROM T_CJHS_GKBD WHERE GKSBBH=#{gksbbh}",
|
|
|
+ CjhsDbEntity.class, params);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取海事申报记录,不论结果都返回
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public CjhsEntity findCjhsByGksbbh(Long gksbbh) {
|
|
|
+ CjhsEntity cjhs = null;
|
|
|
+ ZysqbpEntity vo = zysqbpService.findOne(gksbbh);
|
|
|
+ // 获取比对数据
|
|
|
+ try {
|
|
|
+ List<CjhsDbEntity> cjhsdbList = cjhsService.findByGksbbh(gksbbh);
|
|
|
+ if (cjhsdbList == null || cjhsdbList.size() <= 0) {
|
|
|
+ List<DtywCbsbEntity> dtywCbsbEntityList = dtywCbsbService
|
|
|
+ .findByZwcm(vo.getCm());
|
|
|
+ if (dtywCbsbEntityList != null) {
|
|
|
+ DtywCbsbEntity dtywCbsbEntity = dtywCbsbEntityList.get(0);
|
|
|
+ cjhs = changeFromDtywCbsb(dtywCbsbEntity);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ CjhsDbEntity cjhsdbEntity = cjhsdbList.get(0);
|
|
|
+ DtywCbsbEntity dtywCbsbEntity =dtywCbsbService.findBySbdbh(cjhsdbEntity.getHssbbh());
|
|
|
+ cjhs = changeFromDtywCbsb(dtywCbsbEntity);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return cjhs;
|
|
|
+ }
|
|
|
+
|
|
|
+ public CjhsEntity changeFromDtywCbsb(DtywCbsbEntity entity){
|
|
|
+ CjhsEntity cjhs = new CjhsEntity();
|
|
|
+ cjhs.setBwmc(bwmc);
|
|
|
+ cjhs.setBwdm(entity.getBwdm());
|
|
|
+ cjhs.setCbmc(entity.getZwcm());
|
|
|
+ cjhs.setHc(entity.getHc());
|
|
|
+ cjhs.setJcgbz(entity.getJcgbz());
|
|
|
+ cjhs.setJszysj(entity.getJszysj());
|
|
|
+ cjhs.setKszysj(entity.getKszysj());
|
|
|
+ cjhs.setLzbz(entity.getLzbz());
|
|
|
+ cjhs.setNwmbz(entity.getNwmbz());
|
|
|
+ cjhs.setSbdbh(entity.getSbdbh());
|
|
|
+ cjhs.setSsmt(ssmt);
|
|
|
+ cjhs.setZygkmc(entity.getZygkmc());
|
|
|
+ return cjhs;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|