Commit dcb7bde5 by levphon

工单标准接口-数据迁移

1 parent e47720fa
...@@ -218,4 +218,10 @@ public class Vehicle extends BaseEntity { ...@@ -218,4 +218,10 @@ public class Vehicle extends BaseEntity {
@Column(name = "validate_info") @Column(name = "validate_info")
private String validateInfo; private String validateInfo;
/**
* 关联车辆id
*/
@Column(name = "ref_vehicle_id")
private Long refVehicleId;
} }
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.stdinterface.modules.entity;
import com.glsx.plat.mybatis.base.BaseEntity;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.Table;
@Data
@Table(name = "t_vehicle_permit")
public class VehiclePermit extends BaseEntity {
/**
* 授权数据id
*/
@Column(name = "content_id")
private Long contentId;
/**
* 授权人id
*/
@Column(name = "accorder_id")
private Long accorderId;
/**
* 获权人id
*/
@Column(name = "receiver_id")
private Long receiverId;
/**
* 内容类型
*/
@Column(name = "content_type")
private Integer contentType;
/**
* 权限类型 0=读写 1=只读
*/
@Column(name = "permit_type")
private Integer permitType;
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.stdinterface.modules.entity;
import com.glsx.plat.mybatis.base.BaseEntity;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.Table;
@Data
@Table(name = "t_zhongli_account")
public class ZhongliAccount extends BaseEntity {
/**
* e盾角色
*/
@Column(name = "edun_role")
private String edunRole;
/**
* 用户账号
*/
private String account;
/**
* 用户名称
*/
private String username;
/**
* 分组
*/
@Column(name = "group_name")
private String groupName;
/**
* 分类
*/
@Column(name = "class_name")
private String className;
/**
* 级别
*/
private String level;
/**
* 部门
*/
private String department;
/**
* 新角色
*/
@Column(name = "role_name")
private String roleName;
/**
* 类型
*/
private Integer type;
}
\ No newline at end of file \ No newline at end of file
...@@ -6,9 +6,15 @@ import com.glsx.plat.mybatis.mapper.CommonBaseMapper; ...@@ -6,9 +6,15 @@ import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper @Mapper
public interface VehicleMapper extends CommonBaseMapper<Vehicle> { public interface VehicleMapper extends CommonBaseMapper<Vehicle> {
Vehicle selectByWorkOrderId(@Param("workOrderId") Long workOrderId); Vehicle selectByWorkOrderId(@Param("workOrderId") Long workOrderId);
List<Vehicle> selectAllByNoNullRefVehicleId();
Vehicle selectByRefVehicleId(@Param("refVehicleId") Long refVehicleId);
} }
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.stdinterface.modules.mapper;
import cn.com.glsx.stdinterface.modules.entity.VehiclePermit;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface VehiclePermitMapper extends CommonBaseMapper<VehiclePermit> {
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.stdinterface.modules.mapper;
import cn.com.glsx.stdinterface.modules.entity.ZhongliAccount;
import cn.com.glsx.stdinterface.modules.model.ZhongliAccountModel;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface ZhongliAccountMapper extends CommonBaseMapper<ZhongliAccount> {
List<ZhongliAccountModel> selectByLevel(@Param("level") String level);
}
\ No newline at end of file \ No newline at end of file
...@@ -3,7 +3,13 @@ package cn.com.glsx.stdinterface.modules.mapper; ...@@ -3,7 +3,13 @@ package cn.com.glsx.stdinterface.modules.mapper;
import cn.com.glsx.stdinterface.modules.entity.ZhongliVehicle; import cn.com.glsx.stdinterface.modules.entity.ZhongliVehicle;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper; import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper @Mapper
public interface ZhongliVehicleMapper extends CommonBaseMapper<ZhongliVehicle> { public interface ZhongliVehicleMapper extends CommonBaseMapper<ZhongliVehicle> {
List<ZhongliVehicle> selectByAccount(@Param("account") String account);
} }
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.stdinterface.modules.model;
import lombok.Data;
@Data
public class ZhongliAccountModel {
private String level;
private String account;
private String username;
private String department;
private String roleName;
}
package cn.com.glsx.stdinterface.modules.service;
import cn.com.glsx.stdinterface.modules.entity.Vehicle;
import cn.com.glsx.stdinterface.modules.entity.VehiclePermit;
import cn.com.glsx.stdinterface.modules.entity.ZhongliVehicle;
import cn.com.glsx.stdinterface.modules.mapper.VehicleMapper;
import cn.com.glsx.stdinterface.modules.mapper.VehiclePermitMapper;
import cn.com.glsx.stdinterface.modules.mapper.ZhongliAccountMapper;
import cn.com.glsx.stdinterface.modules.mapper.ZhongliVehicleMapper;
import cn.com.glsx.stdinterface.modules.model.ZhongliAccountModel;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Slf4j
@Service
public class ZhongliVehicleService {
@Resource
private ZhongliAccountMapper zhongliAccountMapper;
@Resource
private ZhongliVehicleMapper zhongliVehicleMapper;
@Resource
private VehicleMapper vehicleMapper;
@Resource
private VehiclePermitMapper vehiclePermitMapper;
public void linkVehicle2Account() {
List<ZhongliAccountModel> accountModelList = zhongliAccountMapper.selectByLevel(null);
Map<String, List<ZhongliAccountModel>> accountMapByRoleName = accountModelList.stream().collect(Collectors.groupingBy(ZhongliAccountModel::getRoleName));
Map<String, List<ZhongliAccountModel>> accountMapByLevel = accountModelList.stream()
.filter(zam -> !zam.getRoleName().equals("仲利法务") && !zam.getRoleName().equals("仲利收车"))
.sorted(Comparator.comparing(ZhongliAccountModel::getLevel))
.collect(Collectors.groupingBy(ZhongliAccountModel::getLevel));
//全部同步车辆
List<Vehicle> vehicleList = vehicleMapper.selectAllByNoNullRefVehicleId();
Map<Long, Vehicle> vehicleMap = vehicleList.stream().collect(Collectors.toMap(Vehicle::getRefVehicleId, v -> v));
log.info("绝对授权方式");
accountMapByRoleName.forEach((k, v) -> {
v.forEach(account -> {
List<ZhongliVehicle> zhongliVehicleList = zhongliVehicleMapper.selectByAccount(account.getAccount());
log.info("账号{}(角色为:{})的车辆数:{}", account.getAccount(), k, zhongliVehicleList.size());
if (k.equals("仲利法务") || k.equals("仲利收车")) {
List<VehiclePermit> permitList = Lists.newArrayList();
zhongliVehicleList.forEach(zv -> {
Vehicle vehicle = vehicleMap.get(zv.getVehicleId());
if (vehicle == null) {
return;
}
VehiclePermit vp = new VehiclePermit();
vp.setContentId(vehicle.getId());
vp.setAccorderId(0L);
vp.setReceiverId(1L);
vp.setContentType(0);
vp.setPermitType(1);
vp.setCreatedDate(new Date());
permitList.add(vp);
});
if (CollectionUtils.isNotEmpty(permitList)) {
//vehiclePermitMapper.insertList(permitList);
}
}
});
});
log.info("相对授权方式");
accountMapByLevel.forEach((k, v) -> {
v.forEach(account -> {
List<ZhongliVehicle> zhongliVehicleList = zhongliVehicleMapper.selectByAccount(account.getAccount());
log.info("{}账号{}(角色为:{})的车辆数:{}", k, account.getAccount(), k, zhongliVehicleList.size());
});
});
}
}
...@@ -49,6 +49,7 @@ ...@@ -49,6 +49,7 @@
<result column="sale_manager" jdbcType="VARCHAR" property="saleManager"/> <result column="sale_manager" jdbcType="VARCHAR" property="saleManager"/>
<result column="sale_manager_phone" jdbcType="VARCHAR" property="saleManagerPhone"/> <result column="sale_manager_phone" jdbcType="VARCHAR" property="saleManagerPhone"/>
<result column="buy_type" jdbcType="DATE" property="buyType"/> <result column="buy_type" jdbcType="DATE" property="buyType"/>
<result column="ref_vehicle_id" jdbcType="INTEGER" property="refVehicleId"/>
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
...@@ -60,7 +61,7 @@ ...@@ -60,7 +61,7 @@
config_id, config_desc, color, inner_color, license_plate, vehicle_type, engine, config_id, config_desc, color, inner_color, license_plate, vehicle_type, engine,
displacement, mileage, buy_type, buy_date, description, remark, serve_type, sale_manager, displacement, mileage, buy_type, buy_date, description, remark, serve_type, sale_manager,
sale_manager_phone, validate_status, vehicle_usages, validate_info, del_flag, created_date, sale_manager_phone, validate_status, vehicle_usages, validate_info, del_flag, created_date,
created_by, updated_date, updated_by, registration_date created_by, updated_date, updated_by, registration_date, ref_vehicle_id
</sql> </sql>
<select id="selectByWorkOrderId" resultMap="BaseResultMap"> <select id="selectByWorkOrderId" resultMap="BaseResultMap">
...@@ -70,4 +71,21 @@ ...@@ -70,4 +71,21 @@
where del_flag = 0 where del_flag = 0
and workorder_id = #{workOrderId} and workorder_id = #{workOrderId}
</select> </select>
<select id="selectAllByNoNullRefVehicleId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from t_vehicle
where del_flag = 0
and ref_vehicle_id is not null
</select>
<select id="selectByRefVehicleId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from t_vehicle
where del_flag = 0
and ref_vehicle_id = #{refVehicleId}
limit 1
</select>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
<?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="cn.com.glsx.stdinterface.modules.mapper.VehiclePermitMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.stdinterface.modules.entity.VehiclePermit">
<!--
WARNING - @mbg.generated
-->
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="content_id" jdbcType="INTEGER" property="contentId"/>
<result column="accorder_id" jdbcType="INTEGER" property="accorderId"/>
<result column="receiver_id" jdbcType="INTEGER" property="receiverId"/>
<result column="content_type" jdbcType="TINYINT" property="contentType"/>
<result column="permit_type" jdbcType="TINYINT" property="permitType"/>
<result column="del_flag" jdbcType="TINYINT" property="delFlag"/>
<result column="created_date" jdbcType="TIMESTAMP" property="createdDate"/>
<result column="created_by" jdbcType="INTEGER" property="createdBy"/>
<result column="updated_date" jdbcType="TIMESTAMP" property="updatedDate"/>
<result column="updated_by" jdbcType="INTEGER" property="updatedBy"/>
</resultMap>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
-->
id, content_id, accorder_id, receiver_id, content_type, permit_type, del_flag, created_date,
created_by, updated_date, updated_by
</sql>
</mapper>
\ No newline at end of file \ No newline at end of file
<?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="cn.com.glsx.stdinterface.modules.mapper.ZhongliAccountMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.stdinterface.modules.entity.ZhongliAccount">
<!--
WARNING - @mbg.generated
-->
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="edun_role" jdbcType="VARCHAR" property="edunRole"/>
<result column="account" jdbcType="VARCHAR" property="account"/>
<result column="username" jdbcType="VARCHAR" property="username"/>
<result column="group_name" jdbcType="VARCHAR" property="groupName"/>
<result column="class_name" jdbcType="VARCHAR" property="className"/>
<result column="level" jdbcType="VARCHAR" property="level"/>
<result column="department" jdbcType="VARCHAR" property="department"/>
<result column="role_name" jdbcType="VARCHAR" property="roleName"/>
<result column="type" jdbcType="TINYINT" property="type"/>
<result column="del_flag" jdbcType="TINYINT" property="delFlag"/>
<result column="created_date" jdbcType="TIMESTAMP" property="createdDate"/>
<result column="created_by" jdbcType="INTEGER" property="createdBy"/>
<result column="updated_date" jdbcType="TIMESTAMP" property="updatedDate"/>
<result column="updated_by" jdbcType="INTEGER" property="updatedBy"/>
</resultMap>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
-->
id, edun_role, account, username, group_name, class_name, `level`, department, role_name,
`type`, del_flag, created_date, created_by, updated_date, updated_by
</sql>
<select id="selectByLevel" resultType="cn.com.glsx.stdinterface.modules.model.ZhongliAccountModel">
select `level`, account, username, department, role_name roleName
from t_zhongli_account
where del_flag = 0
<if test="level != null and level != ''">
and `level` = #{level}
</if>
group by account, username, department, role_name
</select>
</mapper>
\ No newline at end of file \ No newline at end of file
...@@ -34,4 +34,11 @@ ...@@ -34,4 +34,11 @@
roleId, roleName, userId, account, username, `type`, del_flag, created_date, created_by, roleId, roleName, userId, account, username, `type`, del_flag, created_date, created_by,
updated_date, updated_by updated_date, updated_by
</sql> </sql>
<select id="selectByAccount" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from t_zhongli_vehicle
where account = #{account}
</select>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
...@@ -13,7 +13,6 @@ import cn.com.glsx.stdinterface.modules.model.WorkOrderInfoBO; ...@@ -13,7 +13,6 @@ import cn.com.glsx.stdinterface.modules.model.WorkOrderInfoBO;
import cn.com.glsx.stdinterface.modules.remote.NotifyCenterService; import cn.com.glsx.stdinterface.modules.remote.NotifyCenterService;
import cn.com.glsx.stdinterface.modules.util.Sm4EncryptUtils; import cn.com.glsx.stdinterface.modules.util.Sm4EncryptUtils;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -43,6 +42,9 @@ public class WorkOrderServiceTest { ...@@ -43,6 +42,9 @@ public class WorkOrderServiceTest {
@Resource @Resource
private WorkOrderDocsMapper workOrderDocsMapper; private WorkOrderDocsMapper workOrderDocsMapper;
@Resource
private ZhongliVehicleService zhongliVehicleService;
@Test @Test
public void test() { public void test() {
for (int i = 0; i < 1000; i++) { for (int i = 0; i < 1000; i++) {
...@@ -136,4 +138,9 @@ public class WorkOrderServiceTest { ...@@ -136,4 +138,9 @@ public class WorkOrderServiceTest {
System.out.println("workOrderDocs = " + JSONUtil.toJsonStr(workOrderDocs)); System.out.println("workOrderDocs = " + JSONUtil.toJsonStr(workOrderDocs));
} }
@Test
public void testLinkZhongliVehicle2Account() {
zhongliVehicleService.linkVehicle2Account();
}
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!