Commit e26e9146 by 412743165@qq.com

提交第一版:后续的表也完成,同步动作

parent a9f2aa43
package com.jarvis.dataCenter.bean;
import com.jarvis.dataCenter.entity.jws.InvoiceSignEntity;
import com.jarvis.dataCenter.entity.jws.TLicenceEntity;
import com.jarvis.dataCenter.entity.jws.TProductLicenceEntity;
import com.jarvis.dataCenter.entity.prod.*;
import com.jarvis.dataCenter.entity.report.*;
import com.jarvis.dataCenter.entity.warehouse.*;
......@@ -687,6 +689,49 @@ public class BeanUtils {
//
// }
public static void build(ReportTLicenceInfo reportTLicenceInfo, Long productLicenceId, Integer productId, Integer licenceId, String majorStatus, TLicenceEntity tLicenceEntity) {
reportTLicenceInfo.setProductLicenceId(productLicenceId);
reportTLicenceInfo.setProductId(productId);
reportTLicenceInfo.setLicenceId(licenceId);
reportTLicenceInfo.setMajorStatus(majorStatus);
if (tLicenceEntity != null) {
reportTLicenceInfo.setLicenceCode(tLicenceEntity.getLicenceCode());
reportTLicenceInfo.setLicenceTypeId(tLicenceEntity.getLicenceTypeId());
reportTLicenceInfo.setRegperson(tLicenceEntity.getRegperson());
reportTLicenceInfo.setProductName(tLicenceEntity.getProductName());
reportTLicenceInfo.setProductOrigin(tLicenceEntity.getProductOrigin());
reportTLicenceInfo.setProductSpec(tLicenceEntity.getProductSpec());
reportTLicenceInfo.setBeginDate(tLicenceEntity.getBeginDate());
reportTLicenceInfo.setEndDate(tLicenceEntity.getEndDate());
reportTLicenceInfo.setRemark(tLicenceEntity.getRemark());
reportTLicenceInfo.setResourceId(tLicenceEntity.getResourceId());
reportTLicenceInfo.setStatus(tLicenceEntity.getStatus());
reportTLicenceInfo.setCreator(tLicenceEntity.getCreator());
reportTLicenceInfo.setModifier(tLicenceEntity.getModifier());
reportTLicenceInfo.setCreatedTime(tLicenceEntity.getCreatedTime());
reportTLicenceInfo.setModifiedTime(tLicenceEntity.getModifiedTime());
reportTLicenceInfo.setIsEternal(tLicenceEntity.getIsEternal());
}
}
public static void build(ReportDolicenceInfo reportDolicenceInfo, DeliveryLicenceEntity deliveryLicenceEntity) {
if (deliveryLicenceEntity != null) {
reportDolicenceInfo.setId(deliveryLicenceEntity.getId());
reportDolicenceInfo.setDoCode(deliveryLicenceEntity.getDoCode());
reportDolicenceInfo.setSupplierId(deliveryLicenceEntity.getSupplierId());
reportDolicenceInfo.setAgencyId(deliveryLicenceEntity.getAgencyId());
reportDolicenceInfo.setGroupId(deliveryLicenceEntity.getGroupId());
reportDolicenceInfo.setLicenceType(deliveryLicenceEntity.getLicenceType());
reportDolicenceInfo.setProductId(deliveryLicenceEntity.getProductId());
reportDolicenceInfo.setCreatedTime(deliveryLicenceEntity.getCreatedTime());
reportDolicenceInfo.setUpdatedTime(deliveryLicenceEntity.getUpdatedTime());
reportDolicenceInfo.setVersion(deliveryLicenceEntity.getVersion());
}
}
public static void build(ReportDoInfo reportDoInfo, WarehouseEntity warehouseEntity) {
if (warehouseEntity != null) {
reportDoInfo.setWarehouseId(warehouseEntity.getId());
......
package com.jarvis.dataCenter.entity.jws;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
import java.io.Serializable;
import lombok.Data;
import com.jarvis.lib.common.mybatisplus.entity.AbstractEntity;
/**
* <p>
* 产品证照信息表 ENTITY
* </p>
*
* @author jinzhaopo
* @since 2019-11-06
*/
@Data
@TableName("t_licence")
public class TLicenceEntity extends AbstractEntity {
private static final long serialVersionUID = 1L;
@TableId(value = ID, type = IdType.AUTO)
private Integer id;
/**
* 证照编号
*/
@TableField(LICENCECODE)
private String licenceCode;
/**
* 产品证照类型,bus_product_apparatustype,itemGpCode=bus_licenceType
*/
@TableField(LICENCETYPEID)
private Integer licenceTypeId;
/**
* 注册人名称
*/
@TableField(REGPERSON)
private String regperson;
/**
* 产品名称
*/
@TableField(PRODUCTNAME)
private String productName;
/**
* 商品产地
*/
@TableField(PRODUCTORIGIN)
private String productOrigin;
/**
* 产品规范
*/
@TableField(PRODUCTSPEC)
private String productSpec;
/**
* 生效日期
*/
@TableField(BEGINDATE)
private Date beginDate;
/**
* 到期日期
*/
@TableField(ENDDATE)
private Date endDate;
/**
* 备注信息
*/
@TableField(REMARK)
private String remark;
/**
* 附件id(关联t_resource表的id)
*/
@TableField(RESOURCEID)
private Long resourceId;
/**
* 状态 0:失效 1:有效
*/
@TableField(STATUS)
private Integer status;
/**
* 创建人
*/
@TableField(CREATOR)
private String creator;
/**
* 修改人
*/
@TableField(MODIFIER)
private String modifier;
/**
* 创建时间
*/
@TableField(CREATEDTIME)
private Date createdTime;
/**
* 更新时间
*/
@TableField(MODIFIEDTIME)
private Date modifiedTime;
/**
* 是否长期有效(0:否1:是)
*/
@TableField(ISETERNAL)
private Integer isEternal;
/**
*
*/
public static final String ID = "id";
/**
* 证照编号
*/
public static final String LICENCECODE = "licenceCode";
/**
* 产品证照类型,bus_product_apparatustype,itemGpCode=bus_licenceType
*/
public static final String LICENCETYPEID = "licenceTypeId";
/**
* 注册人名称
*/
public static final String REGPERSON = "regperson";
/**
* 产品名称
*/
public static final String PRODUCTNAME = "productName";
/**
* 商品产地
*/
public static final String PRODUCTORIGIN = "productOrigin";
/**
* 产品规范
*/
public static final String PRODUCTSPEC = "productSpec";
/**
* 生效日期
*/
public static final String BEGINDATE = "beginDate";
/**
* 到期日期
*/
public static final String ENDDATE = "endDate";
/**
* 备注信息
*/
public static final String REMARK = "remark";
/**
* 附件id(关联t_resource表的id)
*/
public static final String RESOURCEID = "resourceId";
/**
* 状态 0:失效 1:有效
*/
public static final String STATUS = "status";
/**
* 创建人
*/
public static final String CREATOR = "creator";
/**
* 修改人
*/
public static final String MODIFIER = "modifier";
/**
* 创建时间
*/
public static final String CREATEDTIME = "createdTime";
/**
* 更新时间
*/
public static final String MODIFIEDTIME = "modifiedTime";
/**
* 是否长期有效(0:否1:是)
*/
public static final String ISETERNAL = "isEternal";
}
package com.jarvis.dataCenter.entity.jws;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
import java.io.Serializable;
import lombok.Data;
import com.jarvis.lib.common.mybatisplus.entity.AbstractEntity;
/**
* <p>
* 产品证照关系表 ENTITY
* </p>
*
* @author jinzhaopo
* @since 2019-11-06
*/
@Data
@TableName("t_product_licence")
public class TProductLicenceEntity extends AbstractEntity {
private static final long serialVersionUID = 1L;
@TableId(value = ID, type = IdType.AUTO)
private Integer id;
/**
* 产品id
*/
@TableField(PRODUCTID)
private Integer productId;
/**
* 证照id
*/
@TableField(LICENCEID)
private Integer licenceId;
/**
* 是否主试剂证件 0-否 1-是
*/
@TableField(MAJORSTATUS)
private String majorStatus;
/**
* 状态:0-失效 1- 有效
*/
@TableField(STATUS)
private String status;
/**
* 创建人
*/
@TableField(CREATOR)
private String creator;
/**
* 修改人
*/
@TableField(MODIFIER)
private String modifier;
/**
* 创建时间
*/
@TableField(CREATEDTIME)
private Date createdTime;
/**
* 修改时间
*/
@TableField(MODIFIEDTIME)
private Date modifiedTime;
/**
*
*/
public static final String ID = "id";
/**
* 产品id
*/
public static final String PRODUCTID = "productId";
/**
* 证照id
*/
public static final String LICENCEID = "licenceId";
/**
* 是否主试剂证件 0-否 1-是
*/
public static final String MAJORSTATUS = "majorStatus";
/**
* 状态:0-失效 1- 有效
*/
public static final String STATUS = "status";
/**
* 创建人
*/
public static final String CREATOR = "creator";
/**
* 修改人
*/
public static final String MODIFIER = "modifier";
/**
* 创建时间
*/
public static final String CREATEDTIME = "createdTime";
/**
* 修改时间
*/
public static final String MODIFIEDTIME = "modifiedTime";
}
package com.jarvis.dataCenter.entity.report;
import com.baomidou.mybatisplus.annotation.TableName;
import com.jarvis.lib.common.mybatisplus.entity.AbstractEntity;
import lombok.Data;
import java.util.Date;
/**
* @author jinzhaopo
* @date 2019-11-06 14:37
*/
@Data
@TableName("report_do_licence_info")
public class ReportDolicenceInfo extends AbstractEntity {
private Long id;
/**
* 发货单号
*/
private String doCode;
/**
* 供应商id
*/
private Long supplierId;
/**
* 机构id
*/
private Long agencyId;
/**
* 集团id
*/
private Long groupId;
/**
* 证照类型
*/
private String licenceType;
/**
* 产品id
*/
private Long productId;
private Date createdTime;
private Date updatedTime;
private Integer version;
}
package com.jarvis.dataCenter.entity.report;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.jarvis.lib.common.mybatisplus.entity.AbstractEntity;
import lombok.Data;
import java.util.Date;
/**
* 证照关联表 证照和产品的中间表
*
* @author jinzhaopo
* @date 2019-11-06 16:30
*/
@Data
@TableName("report_t_licence_info")
public class ReportTLicenceInfo extends AbstractEntity {
/**
* 自增长
*/
@TableId(type = IdType.AUTO)
private Integer id;
private Long productLicenceId;
/**
* 产品id
*/
private Integer productId;
/**
* 证照id
*/
private Integer licenceId;
/**
* 是否主试剂证件 0-否 1-是
*/
private String majorStatus;
//------t_licence
/**
* 证照编号
*/
private String licenceCode;
/**
* 产品证照类型,bus_product_apparatustype,itemGpCode=bus_licenceType
*/
private Integer licenceTypeId;
/**
* 注册人名称
*/
private String regperson;
/**
* 产品名称
*/
private String productName;
/**
* 商品产地
*/
private String productOrigin;
/**
* 产品规范
*/
private String productSpec;
/**
* 生效日期
*/
private Date beginDate;
/**
* 到期日期
*/
private Date endDate;
/**
* 备注信息
*/
private String remark;
/**
* 附件id(关联t_resource表的id)
*/
private Long resourceId;
/**
* 状态 0:失效 1:有效
*/
private Integer status;
/**
* 创建人
*/
private String creator;
/**
* 修改人
*/
private String modifier;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新时间
*/
private Date modifiedTime;
/**
* 是否长期有效(0:否1:是)
*/
private Integer isEternal;
}
package com.jarvis.dataCenter.mapper.jws;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.jarvis.dataCenter.constants.DbConstants;
import com.jarvis.dataCenter.entity.jws.TLicenceEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jarvis.lib.common.mybatisplus.mapper.IBaseMapper;
import org.apache.ibatis.annotations.Select;
/**
* <p>
* 产品证照信息表
* </p>
*
* @author jinzhaopo
* @since 2019-11-06
*/
@DS(DbConstants.JWS)
public interface TLicenceMapper extends IBaseMapper<TLicenceEntity> {
@Select("select max(id) from t_licence")
Long maxId();
}
\ No newline at end of file
package com.jarvis.dataCenter.mapper.jws;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.jarvis.dataCenter.constants.DbConstants;
import com.jarvis.dataCenter.entity.jws.TProductLicenceEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jarvis.lib.common.mybatisplus.mapper.IBaseMapper;
import org.apache.ibatis.annotations.Select;
/**
* <p>
* 产品证照关系表
* </p>
*
* @author jinzhaopo
* @since 2019-11-06
*/
@DS(DbConstants.JWS)
public interface TProductLicenceMapper extends IBaseMapper<TProductLicenceEntity> {
@Select("select max(id) from t_product_licence")
Long maxId();
}
\ No newline at end of file
package com.jarvis.dataCenter.mapper.jws;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.jarvis.dataCenter.constants.DbConstants;
import com.jarvis.dataCenter.entity.jws.TProductEntity;
import com.jarvis.lib.common.mybatisplus.mapper.IBaseMapper;
import org.apache.ibatis.annotations.Select;
/**
* <p>
*
* </p>
*
* @author jinzhaopo
* @since 2019-11-06
*/
@DS(DbConstants.JWS)
public interface TProductMapper extends IBaseMapper<TProductEntity> {
@Select("select max(id) from t_product")
Long maxId();
}
\ No newline at end of file
package com.jarvis.dataCenter.mapper.report;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.jarvis.dataCenter.constants.DbConstants;
import com.jarvis.dataCenter.entity.report.ReportDolicenceInfo;
import com.jarvis.lib.common.mybatisplus.mapper.IBaseMapper;
/**
* @author jinzhaopo
* @date 2019-11-06 14:41
*/
@DS(DbConstants.REPORT)
public interface ReportDolicenceInfoMapper extends IBaseMapper<ReportDolicenceInfo> {
}
package com.jarvis.dataCenter.mapper.report;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.jarvis.dataCenter.constants.DbConstants;
import com.jarvis.dataCenter.entity.report.ReportTLicenceInfo;
import com.jarvis.lib.common.mybatisplus.mapper.IBaseMapper;
/**
* @author jinzhaopo
* @date 2019-11-06 16:42
*/
@DS(DbConstants.REPORT)
public interface ReportTLicenceInfoMapper extends IBaseMapper<ReportTLicenceInfo> {
}
......@@ -4,6 +4,7 @@ import com.baomidou.dynamic.datasource.annotation.DS;
import com.jarvis.dataCenter.constants.DbConstants;
import com.jarvis.dataCenter.entity.warehouse.DeliveryLicenceEntity;
import com.jarvis.lib.common.mybatisplus.mapper.IBaseMapper;
import org.apache.ibatis.annotations.Select;
/**
* <p>
......@@ -16,4 +17,7 @@ import com.jarvis.lib.common.mybatisplus.mapper.IBaseMapper;
@DS(DbConstants.WAREHOUSE)
public interface DeliveryLicenceMapper extends IBaseMapper<DeliveryLicenceEntity> {
@Select("select max(id) from delivery_licence")
Long maxId();
}
\ No newline at end of file
package com.jarvis.dataCenter.runner;
import com.jarvis.common.redis.service.RedisService;
import com.jarvis.dataCenter.service.impl.report.ReportDolicenceInfoServiceImpl;
import com.jarvis.dataCenter.service.impl.report.ReportTLicenceInfoServiceImpl;
import com.jarvis.dataCenter.service.report.ReportDolicenceInfoService;
import com.jarvis.dataCenter.service.report.ThreadService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -32,6 +35,8 @@ public class InitRunner implements ApplicationRunner {
// redisService.del(ReportSkuInfoServiceImpl.REDIS_KEY);
// redisService.del(ReportSoPoInfoServiceImpl.REDIS_KEY);
// redisService.del(ReportInvoiceInfoServiceImpl.REDIS_KEY);
// redisService.del(ReportDolicenceInfoServiceImpl.REDIS_KEY);
// redisService.del(ReportTLicenceInfoServiceImpl.REDIS_KEY);
threadService.syncAgency();
threadService.syncAddress();
......@@ -39,8 +44,9 @@ public class InitRunner implements ApplicationRunner {
threadService.sycnDoInfo();
threadService.syncSku();
threadService.syncCsInfo();
threadService.syncSoInfo();
threadService.syncSoInfo ();
threadService.syncDoLicenceInfo();
threadService.syncProductLicenceInfo();
}
......
package com.jarvis.dataCenter.service.impl.jws;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.jarvis.dataCenter.constants.DbConstants;
import com.jarvis.dataCenter.entity.jws.InvoiceSignEntity;
import com.jarvis.dataCenter.mapper.jws.InvoiceSignMapper;
import com.jarvis.dataCenter.service.jws.InvoiceSignService;
......@@ -15,6 +17,7 @@ import org.springframework.stereotype.Service;
* @since 2019-11-01
*/
@Service
@DS(DbConstants.JWS)
public class InvoiceSignServiceImpl extends BaseServiceImpl<InvoiceSignMapper, InvoiceSignEntity> implements InvoiceSignService {
}
\ No newline at end of file
package com.jarvis.dataCenter.service.impl.jws;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.jarvis.dataCenter.constants.DbConstants;
import com.jarvis.dataCenter.entity.jws.TLicenceEntity;
import com.jarvis.dataCenter.mapper.jws.TLicenceMapper;
import com.jarvis.dataCenter.service.jws.TLicenceService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.jarvis.lib.common.mybatisplus.service.impl.BaseServiceImpl;
/**
* <p>
* 产品证照信息表
* </p>
*
* @author jinzhaopo
* @since 2019-11-06
*/
@Service
@DS(DbConstants.JWS)
public class TLicenceServiceImpl extends BaseServiceImpl<TLicenceMapper, TLicenceEntity> implements TLicenceService {
}
\ No newline at end of file
package com.jarvis.dataCenter.service.impl.jws;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.jarvis.dataCenter.constants.DbConstants;
import com.jarvis.dataCenter.entity.jws.TProductLicenceEntity;
import com.jarvis.dataCenter.mapper.jws.TProductLicenceMapper;
import com.jarvis.dataCenter.service.jws.TProductLicenceService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.jarvis.lib.common.mybatisplus.service.impl.BaseServiceImpl;
/**
* <p>
* 产品证照关系表
* </p>
*
* @author jinzhaopo
* @since 2019-11-06
*/
@Service
@DS(DbConstants.JWS)
public class TProductLicenceServiceImpl extends BaseServiceImpl<TProductLicenceMapper, TProductLicenceEntity> implements TProductLicenceService {
}
\ No newline at end of file
package com.jarvis.dataCenter.service.impl.jws;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.jarvis.dataCenter.constants.DbConstants;
import com.jarvis.dataCenter.entity.jws.TProductEntity;
import com.jarvis.dataCenter.mapper.jws.TProductMapper;
import com.jarvis.dataCenter.service.jws.TProductService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.jarvis.lib.common.mybatisplus.service.impl.BaseServiceImpl;
/**
* <p>
*
* </p>
*
* @author jinzhaopo
* @since 2019-11-06
*/
@Service
@DS(DbConstants.JWS)
public class TProductServiceImpl extends BaseServiceImpl<TProductMapper, TProductEntity> implements TProductService {
}
\ No newline at end of file
......@@ -9,6 +9,7 @@ import com.jarvis.dataCenter.entity.report.ReportAddressInfo;
import com.jarvis.dataCenter.mapper.prod.BusAgencyaddressMapper;
import com.jarvis.dataCenter.mapper.report.ReportAddressInfoMapper;
import com.jarvis.dataCenter.service.prod.BusAgencyaddressService;
import com.jarvis.dataCenter.service.report.ReportAddressInfoService;
import com.jarvis.lib.common.mybatisplus.service.impl.BaseServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -21,7 +22,7 @@ import org.springframework.stereotype.Service;
@DS(DbConstants.REPORT)
@Service
@Slf4j
public class ReportAddressInfoService extends BaseServiceImpl<ReportAddressInfoMapper, ReportAddressInfo> implements com.jarvis.dataCenter.service.report.ReportAddressInfoService {
public class ReportAddressInfoServiceImpl extends BaseServiceImpl<ReportAddressInfoMapper, ReportAddressInfo> implements ReportAddressInfoService {
@Autowired
private BusAgencyaddressMapper busAgencyaddressMapper;
......
package com.jarvis.dataCenter.service.impl.report;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.jarvis.common.redis.service.RedisService;
import com.jarvis.dataCenter.bean.BeanUtils;
import com.jarvis.dataCenter.constants.DbConstants;
import com.jarvis.dataCenter.entity.report.ReportDolicenceInfo;
import com.jarvis.dataCenter.entity.warehouse.DeliveryLicenceEntity;
import com.jarvis.dataCenter.mapper.report.ReportDolicenceInfoMapper;
import com.jarvis.dataCenter.mapper.warehouse.DeliveryLicenceMapper;
import com.jarvis.dataCenter.service.report.ReportDolicenceInfoService;
import com.jarvis.dataCenter.service.warehouse.DeliveryLicenceService;
import com.jarvis.lib.common.base.util.JarvisCopyUtils;
import com.jarvis.lib.common.mybatisplus.service.impl.BaseServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @author jinzhaopo
* @date 2019-11-06 14:45
*/
@DS(DbConstants.REPORT)
@Service
@Slf4j
public class ReportDolicenceInfoServiceImpl extends BaseServiceImpl<ReportDolicenceInfoMapper, ReportDolicenceInfo> implements ReportDolicenceInfoService {
@Autowired
private DeliveryLicenceService deliveryLicenceService;
@Autowired
private DeliveryLicenceMapper deliveryLicenceMapper;
@Autowired
private RedisService redisService;
public static String REDIS_KEY = "sync:report:do:licence:id:";
@Override
public boolean sync() {
Long endId = deliveryLicenceMapper.maxId();
Integer startId = (Integer) redisService.get(REDIS_KEY);
if (startId == null) {
startId = 0;
}
log.info(startId+","+endId);
if (startId.intValue() > endId.intValue()) {
return false;
}
//  同步信息
for (long i = startId.intValue(); i <= endId.intValue(); i++) {
try {
sync(i);
} catch (Exception e) {
e.printStackTrace();
}
redisService.getRedisTemplateObj().opsForValue().increment(REDIS_KEY, 1);
}
return true;
}
@Override
public ReportDolicenceInfo sync(Long doLicenceId) {
ReportDolicenceInfo reportDolicenceInfo = new ReportDolicenceInfo();
DeliveryLicenceEntity deliveryLicenceEntity = deliveryLicenceService.getById(doLicenceId);
if (deliveryLicenceEntity == null) {
return null;
}
BeanUtils.build(reportDolicenceInfo, deliveryLicenceEntity);
save(reportDolicenceInfo);
return reportDolicenceInfo;
}
}
package com.jarvis.dataCenter.service.impl.report;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.jarvis.common.redis.service.RedisService;
import com.jarvis.dataCenter.bean.BeanUtils;
import com.jarvis.dataCenter.constants.DbConstants;
import com.jarvis.dataCenter.entity.jws.TLicenceEntity;
import com.jarvis.dataCenter.entity.jws.TProductLicenceEntity;
import com.jarvis.dataCenter.entity.report.ReportTLicenceInfo;
import com.jarvis.dataCenter.mapper.jws.TProductLicenceMapper;
import com.jarvis.dataCenter.mapper.report.ReportTLicenceInfoMapper;
import com.jarvis.dataCenter.service.jws.TLicenceService;
import com.jarvis.dataCenter.service.jws.TProductLicenceService;
import com.jarvis.dataCenter.service.report.ReportTLicenceInfoService;
import com.jarvis.lib.common.mybatisplus.service.impl.BaseServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @author jinzhaopo
* @date 2019-11-06 16:54
*/
@DS(DbConstants.REPORT)
@Service
@Slf4j
public class ReportTLicenceInfoServiceImpl extends BaseServiceImpl<ReportTLicenceInfoMapper, ReportTLicenceInfo> implements ReportTLicenceInfoService {
@Autowired
private TProductLicenceService tProductLicenceService;
@Autowired
private TProductLicenceMapper tProductLicenceMapper;
@Autowired
private TLicenceService tLicenceService;
@Autowired
private RedisService redisService;
public static String REDIS_KEY = "sync:report:product:licence:id:";
@Override
public boolean sync() {
Long endId = tProductLicenceMapper.maxId();
Integer startId = (Integer) redisService.get(REDIS_KEY);
if (startId == null) {
startId = 0;
}
if (startId.intValue() > endId.intValue()) {
return false;
}
//  同步信息
for (long i = startId.intValue(); i <= endId.intValue(); i++) {
try {
sync(i);
} catch (Exception e) {
e.printStackTrace();
}
redisService.getRedisTemplateObj().opsForValue().increment(REDIS_KEY, 1);
}
return true;
}
@Override
public ReportTLicenceInfo sync(Long tLicenceProductId) {
ReportTLicenceInfo reportTLicenceInfo = new ReportTLicenceInfo();
TProductLicenceEntity tProductLicenceEntity = tProductLicenceService.getById(tLicenceProductId);
if (tProductLicenceEntity == null) {
return null;
}
TLicenceEntity tLicenceEntity = tLicenceService.getById(tProductLicenceEntity.getLicenceId());
// Long productLicenceId, Integer productId, Integer licenceId, String majorStatus,
BeanUtils.build(reportTLicenceInfo, Long.valueOf(tProductLicenceEntity.getId()), tProductLicenceEntity.getProductId(), tProductLicenceEntity.getLicenceId(), tProductLicenceEntity.getMajorStatus(), tLicenceEntity);
save(reportTLicenceInfo);
return reportTLicenceInfo;
}
}
......@@ -27,6 +27,8 @@ public class ThreadServiceImpl implements ThreadService {
public static boolean syncCsInfo = true;
public static boolean sycnDoInfo = true;
public static boolean syncInvoiceInfo = true;
public static boolean syncDoLicenceInfo = true;
public static boolean syncProductLicenceInfo = true;
public static long sleepSku = 10;
......@@ -36,6 +38,9 @@ public class ThreadServiceImpl implements ThreadService {
public static long sleepCsInfo = 10;
public static long sleepDoInfo = 10;
public static long sleepInvoiceInfo = 10;
public static long sleepDoILicenceInfo = 10;
public static long sleepProductLicenceInfo = 10;
@Autowired
private ReportSkuInfoService reportSkuInfoService;
......@@ -58,6 +63,12 @@ public class ThreadServiceImpl implements ThreadService {
@Autowired
private ReportInvoiceInfoService reportInvoiceInfoService;
@Autowired
private ReportDolicenceInfoService reportDolicenceInfoService;
@Autowired
private ReportTLicenceInfoService reportTLicenceInfoService;
private Thread syncSkuThread = new Thread(new Runnable() {
@Override
public void run() {
......@@ -184,6 +195,42 @@ public class ThreadServiceImpl implements ThreadService {
}
});
public Thread syncDoLicenceThread = new Thread(new Runnable() {
@Override
public void run() {
while (true) {
if (syncDoLicenceInfo) {
boolean sync = reportDolicenceInfoService.sync();
if (!sync) {
try {
TimeUnit.MINUTES.sleep(sleepDoILicenceInfo);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
}
});
public Thread syncProductLicenceThread = new Thread(new Runnable() {
@Override
public void run() {
while (true) {
if (syncProductLicenceInfo) {
boolean sync = reportTLicenceInfoService.sync();
if (!sync) {
try {
TimeUnit.MINUTES.sleep(sleepProductLicenceInfo);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
}
});
@Override
public boolean syncSku() {
......@@ -231,4 +278,16 @@ public class ThreadServiceImpl implements ThreadService {
return true;
}
@Override
public boolean syncDoLicenceInfo() {
syncDoLicenceThread.start();
return true;
}
@Override
public boolean syncProductLicenceInfo() {
syncProductLicenceThread.start();
return true;
}
}
package com.jarvis.dataCenter.service.jws;
import com.jarvis.dataCenter.entity.jws.TLicenceEntity;
import com.baomidou.mybatisplus.extension.service.IService;
import com.jarvis.lib.common.mybatisplus.service.IBaseService;
/**
* <p>
* 产品证照信息表
* </p>
*
* @author jinzhaopo
* @since 2019-11-06
*/
public interface TLicenceService extends IBaseService<TLicenceEntity> {
}
\ No newline at end of file
package com.jarvis.dataCenter.service.jws;
import com.jarvis.dataCenter.entity.jws.TProductLicenceEntity;
import com.baomidou.mybatisplus.extension.service.IService;
import com.jarvis.lib.common.mybatisplus.service.IBaseService;
/**
* <p>
* 产品证照关系表
* </p>
*
* @author jinzhaopo
* @since 2019-11-06
*/
public interface TProductLicenceService extends IBaseService<TProductLicenceEntity> {
}
\ No newline at end of file
package com.jarvis.dataCenter.service.jws;
import com.jarvis.dataCenter.entity.jws.TProductEntity;
import com.baomidou.mybatisplus.extension.service.IService;
import com.jarvis.lib.common.mybatisplus.service.IBaseService;
/**
* <p>
*
* </p>
*
* @author jinzhaopo
* @since 2019-11-06
*/
public interface TProductService extends IBaseService<TProductEntity> {
}
\ No newline at end of file
package com.jarvis.dataCenter.service.report;
import com.jarvis.dataCenter.entity.report.ReportDolicenceInfo;
import com.jarvis.lib.common.mybatisplus.service.IBaseService;
/**
* @author jinzhaopo
* @date 2019-11-06 14:44
*/
public interface ReportDolicenceInfoService extends IBaseService<ReportDolicenceInfo> {
boolean sync();
ReportDolicenceInfo sync(Long doLicenceId);
}
package com.jarvis.dataCenter.service.report;
import com.jarvis.dataCenter.entity.report.ReportSoPoInfo;
import com.jarvis.dataCenter.entity.report.ReportTLicenceInfo;
import com.jarvis.lib.common.mybatisplus.service.IBaseService;
/**
* @author jinzhaopo
* @date 2019-11-06 16:46
*/
public interface ReportTLicenceInfoService extends IBaseService<ReportTLicenceInfo> {
boolean sync();
ReportTLicenceInfo sync(Long tLicenceProductId);
}
......@@ -19,4 +19,8 @@ public interface ThreadService {
boolean sycnDoInfo();
boolean syncInvoiceInfo();
boolean syncDoLicenceInfo();
boolean syncProductLicenceInfo();
}
......@@ -68,22 +68,22 @@ spring:
jarvis:
username: jarvis_test
password: Jarvis_test
url: jdbc:mysql://rm-2zer7527706ysmqd4o.mysql.rds.aliyuncs.com:3306/jarvis_prod_test?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&tinyInt1isBit=false&serverTimezone=Asia/Shanghai
url: jdbc:mysql://rm-2zer7527706ysmqd4o.mysql.rds.aliyuncs.com:3306/jarvis_prod_test?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&tinyInt1isBit=false&serverTimezone=Asia/Shanghai&autoReconnect=true
driver-class-name: com.mysql.cj.jdbc.Driver
jws:
username: jarvis_test
password: Jarvis_test
url: jdbc:mysql://rm-2zer7527706ysmqd4o.mysql.rds.aliyuncs.com:3306/jws_test?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&tinyInt1isBit=false&serverTimezone=Asia/Shanghai
url: jdbc:mysql://rm-2zer7527706ysmqd4o.mysql.rds.aliyuncs.com:3306/jws_test?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&tinyInt1isBit=false&serverTimezone=Asia/Shanghai&autoReconnect=true
driver-class-name: com.mysql.cj.jdbc.Driver
warehouse:
username: jarvis_test
password: Jarvis_test
url: jdbc:mysql://rm-2zer7527706ysmqd4o.mysql.rds.aliyuncs.com:3306/jws_warehouse_test?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&tinyInt1isBit=false&serverTimezone=Asia/Shanghai
url: jdbc:mysql://rm-2zer7527706ysmqd4o.mysql.rds.aliyuncs.com:3306/jws_warehouse_test?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&tinyInt1isBit=false&serverTimezone=Asia/Shanghai&autoReconnect=true
driver-class-name: com.mysql.cj.jdbc.Driver
report:
username: jarvis_admin
password: Quanli123
url: jdbc:mysql://rm-2zer7527706ysmqd4o.mysql.rds.aliyuncs.com:3306/jarvis_data_center_test?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&tinyInt1isBit=false&serverTimezone=Asia/Shanghai
url: jdbc:mysql://rm-2zer7527706ysmqd4o.mysql.rds.aliyuncs.com:3306/jarvis_data_center_test?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&tinyInt1isBit=false&serverTimezone=Asia/Shanghai&autoReconnect=true
driver-class-name: com.mysql.cj.jdbc.Driver
rabbitmq:
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.jarvis.dataCenter.mapper.jws.TLicenceMapper">
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.jarvis.dataCenter.mapper.jws.TProductLicenceMapper">
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.jarvis.dataCenter.mapper.jws.TProductMapper">
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment