车辆导入导出
This commit is contained in:
@ -24,6 +24,7 @@ import com.ruoyi.common.core.controller.BaseController;
|
|||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 车辆管理Controller
|
* 车辆管理Controller
|
||||||
@ -44,8 +45,10 @@ public class ZcCarController extends BaseController
|
|||||||
|
|
||||||
@RequiresPermissions("operation:car:view")
|
@RequiresPermissions("operation:car:view")
|
||||||
@GetMapping()
|
@GetMapping()
|
||||||
public String car()
|
public String car(ModelMap mmap)
|
||||||
{
|
{
|
||||||
|
List<Company> companyList = companyService.getCompanyList(new Company(),getSysUser()); // 获取运营商列表
|
||||||
|
mmap.put("companyList", companyList); // 将运营商列表传递到前端
|
||||||
return prefix + "/car";
|
return prefix + "/car";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,6 +61,10 @@ public class ZcCarController extends BaseController
|
|||||||
public TableDataInfo list(ZcCar zcCar)
|
public TableDataInfo list(ZcCar zcCar)
|
||||||
{
|
{
|
||||||
startPage();
|
startPage();
|
||||||
|
// 运营者账号,只能查询所属商户数据
|
||||||
|
if(UserConstants.USER_TYPE_02 .equals(getSysUser().getUserType())){
|
||||||
|
zcCar.setOperatorId(getSysUser().getGroupId());
|
||||||
|
}
|
||||||
List<ZcCar> list = zcCarService.selectZcCarList(zcCar);
|
List<ZcCar> list = zcCarService.selectZcCarList(zcCar);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
@ -71,6 +78,10 @@ public class ZcCarController extends BaseController
|
|||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult export(ZcCar zcCar)
|
public AjaxResult export(ZcCar zcCar)
|
||||||
{
|
{
|
||||||
|
// 运营者账号,只能查询所属商户数据
|
||||||
|
if(UserConstants.USER_TYPE_02 .equals(getSysUser().getUserType())){
|
||||||
|
zcCar.setOperatorId(getSysUser().getGroupId());
|
||||||
|
}
|
||||||
List<ZcCar> list = zcCarService.selectZcCarList(zcCar);
|
List<ZcCar> list = zcCarService.selectZcCarList(zcCar);
|
||||||
ExcelUtil<ZcCar> util = new ExcelUtil<ZcCar>(ZcCar.class);
|
ExcelUtil<ZcCar> util = new ExcelUtil<ZcCar>(ZcCar.class);
|
||||||
return util.exportExcel(list, "车辆管理数据");
|
return util.exportExcel(list, "车辆管理数据");
|
||||||
@ -134,9 +145,25 @@ public class ZcCarController extends BaseController
|
|||||||
&& OperationConstants.USER_VIN_NOT_UNIQUE.equals(zcCarService.checkVinUnique(zcCar))) {
|
&& OperationConstants.USER_VIN_NOT_UNIQUE.equals(zcCarService.checkVinUnique(zcCar))) {
|
||||||
return error("修改失败,车机号已存在");
|
return error("修改失败,车机号已存在");
|
||||||
}
|
}
|
||||||
|
|
||||||
return toAjax(zcCarService.updateZcCar(zcCar));
|
return toAjax(zcCarService.updateZcCar(zcCar));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分配车辆
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("operation:car:distribute")
|
||||||
|
@GetMapping("/distribute/{id}")
|
||||||
|
public String distribute(@PathVariable("id") Long id, ModelMap mmap)
|
||||||
|
{
|
||||||
|
List<Company> companyList = companyService.getCompanyList(new Company(),getSysUser()); // 获取运营商列表
|
||||||
|
mmap.put("companyList", companyList); // 将运营商列表传递到前端
|
||||||
|
|
||||||
|
ZcCar zcCar = zcCarService.selectZcCarById(id);
|
||||||
|
mmap.put("zcCar", zcCar);
|
||||||
|
return prefix + "/distribute";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除车辆管理
|
* 删除车辆管理
|
||||||
*/
|
*/
|
||||||
@ -164,7 +191,20 @@ public class ZcCarController extends BaseController
|
|||||||
public AjaxResult importTemplate()
|
public AjaxResult importTemplate()
|
||||||
{
|
{
|
||||||
ExcelUtil<ZcCar> util = new ExcelUtil<ZcCar>(ZcCar.class);
|
ExcelUtil<ZcCar> util = new ExcelUtil<ZcCar>(ZcCar.class);
|
||||||
return util.importTemplateExcel("车辆数据");
|
return util.importTemplateExcel("车辆数据模板");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Log(title = "车辆管理-导入", businessType = BusinessType.IMPORT)
|
||||||
|
@RequiresPermissions("operation:car:import")
|
||||||
|
@PostMapping("/importData")
|
||||||
|
@ResponseBody
|
||||||
|
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
|
||||||
|
{
|
||||||
|
ExcelUtil<ZcCar> util = new ExcelUtil<ZcCar>(ZcCar.class);
|
||||||
|
List<ZcCar> carList = util.importExcel(file.getInputStream());
|
||||||
|
String message = zcCarService.importCar(carList, updateSupport, getSysUser());
|
||||||
|
return AjaxResult.success(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -80,6 +80,10 @@ public class ZcRentCarRuleController extends BaseController
|
|||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult export(ZcRentCarRule zcRentCarRule)
|
public AjaxResult export(ZcRentCarRule zcRentCarRule)
|
||||||
{
|
{
|
||||||
|
// 运营者账号,只能查询所属商户数据
|
||||||
|
if(UserConstants.USER_TYPE_02 .equals(getSysUser().getUserType())){
|
||||||
|
zcRentCarRule.setOperatingCompanyId(getSysUser().getGroupId());
|
||||||
|
}
|
||||||
List<ZcRentCarRule> list = zcRentCarRuleService.selectZcRentCarRuleList(zcRentCarRule);
|
List<ZcRentCarRule> list = zcRentCarRuleService.selectZcRentCarRuleList(zcRentCarRule);
|
||||||
ExcelUtil<ZcRentCarRule> util = new ExcelUtil<ZcRentCarRule>(ZcRentCarRule.class);
|
ExcelUtil<ZcRentCarRule> util = new ExcelUtil<ZcRentCarRule>(ZcRentCarRule.class);
|
||||||
return util.exportExcel(list, "租车计费规则数据");
|
return util.exportExcel(list, "租车计费规则数据");
|
||||||
|
|||||||
@ -30,31 +30,26 @@ public class ZcCar extends BaseEntity
|
|||||||
private String licensePlate;
|
private String licensePlate;
|
||||||
|
|
||||||
/** 车辆品牌ID */
|
/** 车辆品牌ID */
|
||||||
@Excel(name = "车辆品牌ID")
|
|
||||||
private Long brandId;
|
private Long brandId;
|
||||||
|
|
||||||
/** 车辆品牌名称 */
|
/** 车辆品牌名称 */
|
||||||
@Excel(name = "车辆品牌名称")
|
@Excel(name = "车辆品牌")
|
||||||
private String brandName;
|
private String brandName;
|
||||||
|
|
||||||
/** 车辆型号ID */
|
/** 车辆型号ID */
|
||||||
@Excel(name = "车辆型号ID")
|
|
||||||
private Long modelId;
|
private Long modelId;
|
||||||
|
|
||||||
/** 车辆型号名称 */
|
/** 车辆型号名称 */
|
||||||
@Excel(name = "车辆型号名称")
|
@Excel(name = "车辆型号")
|
||||||
private String modelName;
|
private String modelName;
|
||||||
|
|
||||||
/** 支持电池类型 */
|
/** 支持电池类型 */
|
||||||
@Excel(name = "支持电池类型")
|
|
||||||
private String batteryType;
|
private String batteryType;
|
||||||
|
|
||||||
/** 整车重量(kg) */
|
/** 整车重量(kg) */
|
||||||
@Excel(name = "整车重量(kg)")
|
|
||||||
private String weight;
|
private String weight;
|
||||||
|
|
||||||
/** 最高时速(km/h) */
|
/** 最高时速(km/h) */
|
||||||
@Excel(name = "最高时速(km/h)")
|
|
||||||
private String maxSpeed;
|
private String maxSpeed;
|
||||||
|
|
||||||
/** LOT识别号 */
|
/** LOT识别号 */
|
||||||
@ -75,15 +70,12 @@ public class ZcCar extends BaseEntity
|
|||||||
private String belongType;
|
private String belongType;
|
||||||
|
|
||||||
/** 车辆图片 */
|
/** 车辆图片 */
|
||||||
@Excel(name = "车辆图片")
|
|
||||||
private String images;
|
private String images;
|
||||||
|
|
||||||
/** BRS车辆状态 */
|
/** BRS车辆状态 */
|
||||||
@Excel(name = "BRS车辆状态")
|
|
||||||
private String brsStatus;
|
private String brsStatus;
|
||||||
|
|
||||||
/** IoT设备状态 */
|
/** IoT设备状态 */
|
||||||
@Excel(name = "IoT设备状态")
|
|
||||||
private String iotStatus;
|
private String iotStatus;
|
||||||
|
|
||||||
/** IoT识别码 */
|
/** IoT识别码 */
|
||||||
@ -91,31 +83,26 @@ public class ZcCar extends BaseEntity
|
|||||||
private String iotCode;
|
private String iotCode;
|
||||||
|
|
||||||
/** 所属运营商ID */
|
/** 所属运营商ID */
|
||||||
@Excel(name = "所属运营商ID")
|
|
||||||
private Long operatorId;
|
private Long operatorId;
|
||||||
|
|
||||||
/** 所属运营商名称 */
|
/** 所属运营商名称 */
|
||||||
@Excel(name = "所属运营商名称")
|
@Excel(name = "所属运营商")
|
||||||
private String operatorName;
|
private String operatorName;
|
||||||
|
|
||||||
/** 所属门店ID */
|
/** 所属门店ID */
|
||||||
@Excel(name = "所属门店ID")
|
|
||||||
private Long storeId;
|
private Long storeId;
|
||||||
|
|
||||||
/** 所属门店名称 */
|
/** 所属门店名称 */
|
||||||
@Excel(name = "所属门店名称")
|
@Excel(name = "所属门店")
|
||||||
private String storeName;
|
private String storeName;
|
||||||
|
|
||||||
/** 应用套餐ID */
|
/** 应用套餐ID */
|
||||||
@Excel(name = "应用套餐ID")
|
|
||||||
private Long packageId;
|
private Long packageId;
|
||||||
|
|
||||||
/** 应用套餐名称 */
|
/** 应用套餐名称 */
|
||||||
@Excel(name = "应用套餐名称")
|
|
||||||
private String packageName;
|
private String packageName;
|
||||||
|
|
||||||
/** 状态 */
|
/** 状态 */
|
||||||
@Excel(name = "状态")
|
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
/** 删除标志 */
|
/** 删除标志 */
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package com.ruoyi.operation.mapper;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.ruoyi.operation.domain.ZcCar;
|
import com.ruoyi.operation.domain.ZcCar;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 车型管理Mapper接口
|
* 车型管理Mapper接口
|
||||||
@ -35,6 +36,8 @@ public interface ZcCarMapper
|
|||||||
*/
|
*/
|
||||||
public int insertZcCar(ZcCar zcCar);
|
public int insertZcCar(ZcCar zcCar);
|
||||||
|
|
||||||
|
int batchInsert(@Param("list") List<ZcCar> carList);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改车型管理
|
* 修改车型管理
|
||||||
*
|
*
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
package com.ruoyi.operation.service;
|
package com.ruoyi.operation.service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||||
import com.ruoyi.operation.domain.ZcCar;
|
import com.ruoyi.operation.domain.ZcCar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -68,4 +70,8 @@ public interface IZcCarService
|
|||||||
String checkVinUnique(ZcCar zcCar);
|
String checkVinUnique(ZcCar zcCar);
|
||||||
|
|
||||||
public int changeStatus(ZcCar zcCar);
|
public int changeStatus(ZcCar zcCar);
|
||||||
|
|
||||||
|
public String importCar(List<ZcCar> carList, Boolean isUpdateSupport, SysUser user);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,24 @@
|
|||||||
package com.ruoyi.operation.service.impl;
|
package com.ruoyi.operation.service.impl;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||||
|
import com.ruoyi.common.exception.ServiceException;
|
||||||
import com.ruoyi.common.utils.DateUtils;
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
|
import com.ruoyi.common.utils.DictUtils;
|
||||||
|
import com.ruoyi.common.utils.ShiroUtils;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
import com.ruoyi.common.utils.bean.BeanValidators;
|
||||||
|
import com.ruoyi.operation.domain.Company;
|
||||||
|
import com.ruoyi.operation.domain.CompanyStore;
|
||||||
|
import com.ruoyi.operation.service.ICompanyService;
|
||||||
|
import com.ruoyi.operation.service.ICompanyStoreService;
|
||||||
import com.ruoyi.operation.util.OperationConstants;
|
import com.ruoyi.operation.util.OperationConstants;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.ruoyi.operation.mapper.ZcCarMapper;
|
import com.ruoyi.operation.mapper.ZcCarMapper;
|
||||||
@ -11,6 +26,8 @@ import com.ruoyi.operation.domain.ZcCar;
|
|||||||
import com.ruoyi.operation.service.IZcCarService;
|
import com.ruoyi.operation.service.IZcCarService;
|
||||||
import com.ruoyi.common.core.text.Convert;
|
import com.ruoyi.common.core.text.Convert;
|
||||||
|
|
||||||
|
import javax.validation.Validator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 车型管理Service业务层处理
|
* 车型管理Service业务层处理
|
||||||
*
|
*
|
||||||
@ -20,9 +37,18 @@ import com.ruoyi.common.core.text.Convert;
|
|||||||
@Service
|
@Service
|
||||||
public class ZcCarServiceImpl implements IZcCarService
|
public class ZcCarServiceImpl implements IZcCarService
|
||||||
{
|
{
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(ZcCarServiceImpl.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ZcCarMapper zcCarMapper;
|
private ZcCarMapper zcCarMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ICompanyService companyService;
|
||||||
|
@Autowired
|
||||||
|
private ICompanyStoreService companyStoreService;
|
||||||
|
|
||||||
|
protected Validator validator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询车型管理
|
* 查询车型管理
|
||||||
*
|
*
|
||||||
@ -57,6 +83,7 @@ public class ZcCarServiceImpl implements IZcCarService
|
|||||||
public int insertZcCar(ZcCar zcCar)
|
public int insertZcCar(ZcCar zcCar)
|
||||||
{
|
{
|
||||||
zcCar.setCreateTime(DateUtils.getNowDate());
|
zcCar.setCreateTime(DateUtils.getNowDate());
|
||||||
|
zcCar.setUpdateTime(DateUtils.getNowDate());
|
||||||
return zcCarMapper.insertZcCar(zcCar);
|
return zcCarMapper.insertZcCar(zcCar);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,5 +140,82 @@ public class ZcCarServiceImpl implements IZcCarService
|
|||||||
return zcCarMapper.updateZcCar(zcCar);
|
return zcCarMapper.updateZcCar(zcCar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String importCar(List<ZcCar> carList, Boolean isUpdateSupport, SysUser user) {
|
||||||
|
if (StringUtils.isNull(carList) || carList.size() == 0)
|
||||||
|
{
|
||||||
|
throw new ServiceException("导入车辆数据不能为空!");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 一次性查询所有运营商和门店,构建成 Map 用于快速查找
|
||||||
|
List<Company> companyList = companyService.getCompanyList(new Company(),user); // 获取运营商列表
|
||||||
|
Map<String, Long> companyMap = companyList.stream()
|
||||||
|
.collect(Collectors.toMap(Company::getCompanyName, Company::getId));
|
||||||
|
|
||||||
|
List<CompanyStore> storeList = companyStoreService.selectCompanyStoreList(new CompanyStore());
|
||||||
|
Map<String, Long> storeMap = storeList.stream()
|
||||||
|
.collect(Collectors.toMap(CompanyStore::getName, CompanyStore::getId));
|
||||||
|
|
||||||
|
|
||||||
|
int successNum = 0;
|
||||||
|
int failureNum = 0;
|
||||||
|
StringBuilder successMsg = new StringBuilder();
|
||||||
|
StringBuilder failureMsg = new StringBuilder();
|
||||||
|
List<ZcCar> processedList = new ArrayList<ZcCar>();
|
||||||
|
for (ZcCar car : carList)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// 验证是否存在这个用户
|
||||||
|
ZcCar u = zcCarMapper.checkVinUnique(car.getVin());
|
||||||
|
if (StringUtils.isNull(u))
|
||||||
|
{
|
||||||
|
// 车辆归属字典转换
|
||||||
|
car.setBelongType(DictUtils.getDictValue("key_car_belong_type", car.getBelongType(), car.getBelongType()));
|
||||||
|
// 设置运营商ID
|
||||||
|
if (StringUtils.isNotEmpty(car.getOperatorName()) && companyMap.containsKey(car.getOperatorName())) {
|
||||||
|
car.setOperatorId(companyMap.get(car.getOperatorName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置门店ID
|
||||||
|
if (StringUtils.isNotEmpty(car.getStoreName()) && storeMap.containsKey(car.getStoreName())) {
|
||||||
|
car.setStoreId(storeMap.get(car.getStoreName()));
|
||||||
|
}
|
||||||
|
car.setCreateBy(user.getLoginName());
|
||||||
|
|
||||||
|
this.insertZcCar(car);
|
||||||
|
// processedList.add(car);
|
||||||
|
successNum++;
|
||||||
|
successMsg.append("<br/>" + successNum + "、车机号 " + car.getVin() + " 导入成功");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
failureNum++;
|
||||||
|
failureMsg.append("<br/>" + failureNum + "、车机号 " + car.getVin() + " 已存在");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
failureNum++;
|
||||||
|
String msg = "<br/>" + failureNum + "、车机号 " + car.getVin() + " 导入失败:";
|
||||||
|
failureMsg.append(msg + e.getMessage());
|
||||||
|
log.error(msg, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (failureNum > 0)
|
||||||
|
{
|
||||||
|
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
||||||
|
throw new ServiceException(failureMsg.toString());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// zcCarMapper.batchInsert(processedList);
|
||||||
|
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
|
||||||
|
}
|
||||||
|
return successMsg.toString();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -163,6 +163,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="extend5 != null">#{extend5},</if>
|
<if test="extend5 != null">#{extend5},</if>
|
||||||
</trim>
|
</trim>
|
||||||
</insert>
|
</insert>
|
||||||
|
<insert id="batchInsert">
|
||||||
|
INSERT INTO zc_car (vin, license_plate, brand_name,
|
||||||
|
model_name, lot_number, purchase_date,
|
||||||
|
purchase_price, belong_type, iot_code,
|
||||||
|
operator_id, operator_name,
|
||||||
|
store_id, store_name,
|
||||||
|
create_by, create_time, update_time, remark)
|
||||||
|
VALUES
|
||||||
|
<foreach collection="list" item="item" separator=",">
|
||||||
|
(#{item.vin}, #{item.licensePlate}, #{item.brandName}
|
||||||
|
#{item.modelName}, #{item.lotNumber}, #{item.purchaseDate}
|
||||||
|
#{item.purchasePrice}, #{item.belongType}, #{item.iotCode}
|
||||||
|
#{item.operatorId}, #{item.operatorName},
|
||||||
|
#{item.storeId}, #{item.storeName},
|
||||||
|
#{item.createBy}, #{item.createTime}, #{item.updateTime},#{item.remark})
|
||||||
|
</foreach>
|
||||||
|
</insert>
|
||||||
|
|
||||||
<update id="updateZcCar" parameterType="ZcCar">
|
<update id="updateZcCar" parameterType="ZcCar">
|
||||||
update zc_car
|
update zc_car
|
||||||
@ -186,7 +203,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="iotCode != null">iot_code = #{iotCode},</if>
|
<if test="iotCode != null">iot_code = #{iotCode},</if>
|
||||||
<if test="operatorId != null">operator_id = #{operatorId},</if>
|
<if test="operatorId != null">operator_id = #{operatorId},</if>
|
||||||
<if test="operatorName != null">operator_name = #{operatorName},</if>
|
<if test="operatorName != null">operator_name = #{operatorName},</if>
|
||||||
<if test="storeId != null">store_id = #{storeId},</if>
|
|
||||||
<if test="storeName != null">store_name = #{storeName},</if>
|
<if test="storeName != null">store_name = #{storeName},</if>
|
||||||
<if test="packageId != null">package_id = #{packageId},</if>
|
<if test="packageId != null">package_id = #{packageId},</if>
|
||||||
<if test="packageName != null">package_name = #{packageName},</if>
|
<if test="packageName != null">package_name = #{packageName},</if>
|
||||||
@ -202,6 +218,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="extend3 != null">extend3 = #{extend3},</if>
|
<if test="extend3 != null">extend3 = #{extend3},</if>
|
||||||
<if test="extend4 != null">extend4 = #{extend4},</if>
|
<if test="extend4 != null">extend4 = #{extend4},</if>
|
||||||
<if test="extend5 != null">extend5 = #{extend5},</if>
|
<if test="extend5 != null">extend5 = #{extend5},</if>
|
||||||
|
store_id = #{storeId}
|
||||||
</trim>
|
</trim>
|
||||||
where id = #{id}
|
where id = #{id}
|
||||||
</update>
|
</update>
|
||||||
|
|||||||
@ -27,11 +27,14 @@
|
|||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
<label>所属运营商名称:</label>
|
<label>所属运营商:</label>
|
||||||
<input type="text" name="operatorName"/>
|
<select name="operatingId" id="operatingId" >
|
||||||
|
<option value="">请选择所属运营商</option>
|
||||||
|
<option th:each="company : ${companyList}" th:value="${company.id}" th:text="${company.companyName}"></option>
|
||||||
|
</select>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<label>所属门店名称:</label>
|
<label>所属门店:</label>
|
||||||
<input type="text" name="storeName"/>
|
<input type="text" name="storeName"/>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
@ -68,6 +71,7 @@
|
|||||||
<th:block th:include="include :: footer" />
|
<th:block th:include="include :: footer" />
|
||||||
<script th:inline="javascript">
|
<script th:inline="javascript">
|
||||||
var editFlag = [[${@permission.hasPermi('operation:car:edit')}]];
|
var editFlag = [[${@permission.hasPermi('operation:car:edit')}]];
|
||||||
|
var distributeFlag = [[${@permission.hasPermi('operation:car:distribute')}]];
|
||||||
var removeFlag = [[${@permission.hasPermi('operation:car:remove')}]];
|
var removeFlag = [[${@permission.hasPermi('operation:car:remove')}]];
|
||||||
var statusDatas = [[${@dict.getType('key_car_status')}]];
|
var statusDatas = [[${@dict.getType('key_car_status')}]];
|
||||||
var batteryTypeDatas = [[${@dict.getType('key_car_battery_type')}]];
|
var batteryTypeDatas = [[${@dict.getType('key_car_battery_type')}]];
|
||||||
@ -160,7 +164,7 @@
|
|||||||
formatter: function(value, row, index) {
|
formatter: function(value, row, index) {
|
||||||
var actions = [];
|
var actions = [];
|
||||||
actions.push('<a class="btn btn-success btn-xs ' + editFlag + ' btnOption" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
|
actions.push('<a class="btn btn-success btn-xs ' + editFlag + ' btnOption" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
|
||||||
actions.push('<a class="btn btn-success btn-xs ' + editFlag + ' btnOption" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>分配</a> ');
|
actions.push('<a class="btn btn-success btn-xs ' + distributeFlag + ' btnOption" href="javascript:void(0)" onclick="distribute(\'' + row.id + '\')"><i class="fa fa-edit"></i>分配</a> ');
|
||||||
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + ' btnOption" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
|
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + ' btnOption" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
|
||||||
if (row.status == 1) {
|
if (row.status == 1) {
|
||||||
actions.push('<a class="btn btn-success btn-xs ' + editFlag + ' btnOption" href="javascript:void(0)" onclick="enable(\'' + row.id + '\')"><i class="fa fa-edit"></i>上架</a> ');
|
actions.push('<a class="btn btn-success btn-xs ' + editFlag + ' btnOption" href="javascript:void(0)" onclick="enable(\'' + row.id + '\')"><i class="fa fa-edit"></i>上架</a> ');
|
||||||
@ -174,6 +178,9 @@
|
|||||||
$.table.init(options);
|
$.table.init(options);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function distribute(id){
|
||||||
|
$.modal.open("车辆分配", prefix + "/distribute/" + id);
|
||||||
|
}
|
||||||
/* 下架 */
|
/* 下架 */
|
||||||
function disable(id) {
|
function disable(id) {
|
||||||
$.modal.confirm("确认是否下架此车辆?<span style='color: red'>下架后此车辆将在不会显示在用户小程序中</span>", function() {
|
$.modal.confirm("确认是否下架此车辆?<span style='color: red'>下架后此车辆将在不会显示在用户小程序中</span>", function() {
|
||||||
|
|||||||
@ -0,0 +1,163 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
|
||||||
|
<head>
|
||||||
|
<th:block th:include="include :: header('分配车辆')" />
|
||||||
|
<th:block th:include="include :: datetimepicker-css" />
|
||||||
|
</head>
|
||||||
|
<body class="white-bg">
|
||||||
|
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
|
||||||
|
<form class="form-horizontal m" id="form-car-edit" th:object="${zcCar}">
|
||||||
|
<input name="id" th:field="*{id}" type="hidden">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">车架号(VIN):</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input readonly name="vin" th:field="*{vin}" class="form-control" type="text">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">车牌号码:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input readonly name="licensePlate" th:field="*{licensePlate}" class="form-control" type="text">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">车辆归属:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<select readonly name="belongType" class="form-control m-b" th:with="type=${@dict.getType('key_car_belong_type')}">
|
||||||
|
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{belongType}"></option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label is-required">所属运营商:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input name="operatorName" id="operatorName" class="form-control" type="hidden" >
|
||||||
|
<select name="operatorId" id="operator-select" class="form-control m-b" required>
|
||||||
|
<option value="">请选择运营商</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">所属门店:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input name="storeName" id="storeName" class="form-control" type="hidden" >
|
||||||
|
<select name="storeId" id="store-select" class="form-control m-b" disabled>
|
||||||
|
<option value="">请先选择运营商</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<th:block th:include="include :: footer" />
|
||||||
|
<th:block th:include="include :: datetimepicker-js" />
|
||||||
|
<script th:inline="javascript">
|
||||||
|
var prefix = ctx + "operation/car";
|
||||||
|
$("#form-car-edit").validate({
|
||||||
|
focusCleanup: true
|
||||||
|
});
|
||||||
|
$(function () {
|
||||||
|
|
||||||
|
// 获取运营商与门店下拉框
|
||||||
|
var operatorSelect = $('#operator-select');
|
||||||
|
var storeSelect = $('#store-select');
|
||||||
|
|
||||||
|
// 保存当前车辆的运营商与门店值
|
||||||
|
var savedOperatorId = [[${zcCar.operatorId}]];
|
||||||
|
var savedStoreId = [[${zcCar.storeId}]];
|
||||||
|
|
||||||
|
// =================== 加载运营商列表 ===================
|
||||||
|
$.ajax({
|
||||||
|
url: ctx + 'operation/company/companyAll',
|
||||||
|
type: 'GET',
|
||||||
|
success: function (companies) {
|
||||||
|
companies.forEach(function (company) {
|
||||||
|
var option = $('<option>').val(company.id).text(company.companyName);
|
||||||
|
if (company.id == savedOperatorId) {
|
||||||
|
option.attr('selected', 'selected');
|
||||||
|
}
|
||||||
|
operatorSelect.append(option);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 如果有已选运营商,则触发加载门店
|
||||||
|
if (savedOperatorId) {
|
||||||
|
storeSelect.prop('disabled', false).empty().append('<option value="">加载中...</option>');
|
||||||
|
loadStores(savedOperatorId, savedStoreId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// =================== 运营商选择变化事件 ===================
|
||||||
|
operatorSelect.on('change', function () {
|
||||||
|
var selectedOperatorId = $(this).val();
|
||||||
|
if (!selectedOperatorId) {
|
||||||
|
storeSelect.empty().append('<option value="">请先选择运营商</option>').prop('disabled', true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置隐藏域 operatorName
|
||||||
|
var selectedOperatorName = operatorSelect.find('option:selected').text();
|
||||||
|
$('#operatorName').val(selectedOperatorName);
|
||||||
|
|
||||||
|
loadStores(selectedOperatorId);
|
||||||
|
});
|
||||||
|
|
||||||
|
// =================== 加载门店方法封装 ===================
|
||||||
|
function loadStores(operatorId, savedStoreId = null) {
|
||||||
|
$.ajax({
|
||||||
|
url: ctx + 'operation/store/storesByCompanyId',
|
||||||
|
type: 'POST',
|
||||||
|
data: { companyId: operatorId },
|
||||||
|
success: function (stores) {
|
||||||
|
storeSelect.empty();
|
||||||
|
$('#storeName').val('');
|
||||||
|
if (stores.length === 0) {
|
||||||
|
storeSelect.append('<option value="">暂无门店</option>').prop('disabled', true);
|
||||||
|
} else {
|
||||||
|
storeSelect.append($('<option>').val('').text('请选择门店'));
|
||||||
|
stores.forEach(function (store) {
|
||||||
|
storeSelect.append($('<option>').val(store.id).text(store.name));
|
||||||
|
});
|
||||||
|
storeSelect.prop('disabled', false);
|
||||||
|
|
||||||
|
// 回显门店
|
||||||
|
if (savedStoreId) {
|
||||||
|
storeSelect.val(savedStoreId);
|
||||||
|
// 设置隐藏域 storeName
|
||||||
|
var selectedStoreName = storeSelect.find('option:selected').text();
|
||||||
|
$('#storeName').val(selectedStoreName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// =================== 门店选择变化事件 ===================
|
||||||
|
storeSelect.on('change', function () {
|
||||||
|
var selectedStoreId = $(this).val();
|
||||||
|
var selectedStoreName = $(this).find('option:selected').text();
|
||||||
|
if(selectedStoreId != ''){
|
||||||
|
$('#storeName').val(selectedStoreName);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function submitHandler() {
|
||||||
|
if ($.validate.form()) {
|
||||||
|
$.operate.save(prefix + "/edit", $('#form-car-edit').serialize());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$("input[name='purchaseDate']").datetimepicker({
|
||||||
|
format: "yyyy-mm-dd",
|
||||||
|
minView: "month",
|
||||||
|
autoclose: true
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@ -234,10 +234,11 @@
|
|||||||
data: { companyId: operatorId },
|
data: { companyId: operatorId },
|
||||||
success: function (stores) {
|
success: function (stores) {
|
||||||
storeSelect.empty();
|
storeSelect.empty();
|
||||||
|
$('#storeName').val('');
|
||||||
if (stores.length === 0) {
|
if (stores.length === 0) {
|
||||||
storeSelect.append('<option value="">暂无门店</option>').prop('disabled', true);
|
storeSelect.append('<option value="">暂无门店</option>').prop('disabled', true);
|
||||||
} else {
|
} else {
|
||||||
|
storeSelect.append($('<option>').val('').text('请选择门店'));
|
||||||
stores.forEach(function (store) {
|
stores.forEach(function (store) {
|
||||||
storeSelect.append($('<option>').val(store.id).text(store.name));
|
storeSelect.append($('<option>').val(store.id).text(store.name));
|
||||||
});
|
});
|
||||||
@ -259,7 +260,9 @@
|
|||||||
storeSelect.on('change', function () {
|
storeSelect.on('change', function () {
|
||||||
var selectedStoreId = $(this).val();
|
var selectedStoreId = $(this).val();
|
||||||
var selectedStoreName = $(this).find('option:selected').text();
|
var selectedStoreName = $(this).find('option:selected').text();
|
||||||
$('#storeName').val(selectedStoreName);
|
if(selectedStoreId != ''){
|
||||||
|
$('#storeName').val(selectedStoreName);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user