提交代码

dev-discount
胡锐 2 years ago
parent a1fbf5ae96
commit f6092f9954
  1. 239
      hai-bweb/src/main/java/com/bweb/controller/HighDeviceController.java
  2. 6
      hai-service/src/main/java/com/hai/config/MqttProviderConfig.java
  3. 155
      hai-service/src/main/java/com/hai/dao/HighDeviceMapper.java
  4. 7
      hai-service/src/main/java/com/hai/dao/HighDeviceMapperExt.java
  5. 430
      hai-service/src/main/java/com/hai/dao/HighDeviceSqlProvider.java
  6. 344
      hai-service/src/main/java/com/hai/entity/HighDevice.java
  7. 1473
      hai-service/src/main/java/com/hai/entity/HighDeviceExample.java
  8. 44
      hai-service/src/main/java/com/hai/enum_type/DeviceTypeEnum.java
  9. 35
      hai-service/src/main/java/com/hai/service/HighDeviceService.java
  10. 68
      hai-service/src/main/java/com/hai/service/impl/HighDeviceServiceImpl.java

@ -0,0 +1,239 @@
package com.bweb.controller;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode;
import com.hai.common.security.SessionObject;
import com.hai.common.security.UserCenter;
import com.hai.common.utils.DateUtil;
import com.hai.common.utils.ResponseMsgUtil;
import com.hai.entity.*;
import com.hai.enum_type.DeviceTypeEnum;
import com.hai.model.HighCouponHandselModel;
import com.hai.model.HighMerchantModel;
import com.hai.model.ResponseData;
import com.hai.model.UserInfoModel;
import com.hai.service.BsCompanyService;
import com.hai.service.HighDeviceService;
import com.hai.service.HighMerchantService;
import com.hai.service.HighMerchantStoreService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
@Controller
@RequestMapping(value = "/device")
@Api(value = "卡卷接口")
public class HighDeviceController {
private static Logger log = LoggerFactory.getLogger(HighCouponController.class);
@Resource
private UserCenter userCenter;
@Resource
private HighDeviceService deviceService;
@Resource
private HighMerchantService merchantService;
@Resource
private HighMerchantStoreService merchantStoreService;
@Resource
private BsCompanyService companyService;
@RequestMapping(value="/editDevice",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "编辑设备")
public ResponseData editDevice(@RequestBody HighDevice body) {
try {
if (body.getMerStoreId() == null
|| body.getType() == null
|| StringUtils.isBlank(body.getDeviceName())
) {
log.error("HighDeviceController -> editDevice() error!","参数错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
if (DeviceTypeEnum.getNameByType(body.getType()) == null) {
log.error("HighDeviceController -> editDevice() error!","参数错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的设备类型");
}
if (body.getType().equals(DeviceTypeEnum.type1.getType())
&& (StringUtils.isBlank(body.getDeviceSn())) || StringUtils.isBlank(body.getDeviceKey())) {
log.error("HighDeviceController -> editDevice() error!","参数错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
if (body.getType().equals(DeviceTypeEnum.type2.getType())
&& (StringUtils.isBlank(body.getDeviceImei())) || StringUtils.isBlank(body.getDeviceIccid())) {
log.error("HighDeviceController -> editDevice() error!","参数错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
HighDevice device;
if (body.getId() != null) {
// 查询设备
device = deviceService.getDetailById(body.getId());
if (device == null) {
log.error("HighDeviceController -> editDevice() error!","参数错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
} else {
device = new HighDevice();
}
// 查询门店
HighMerchantStore store = merchantStoreService.getDetailById(body.getMerStoreId());
if (store == null) {
log.error("HighDeviceController -> editDevice() error!","参数错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的门店");
}
// 查询商户
HighMerchant merchant = merchantService.getDetailById(store.getMerchantId());
if (merchant == null) {
log.error("HighDeviceController -> editDevice() error!","参数错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的商户");
}
// 查询分公司
BsCompany company = companyService.getCompanyById(store.getMerchantId());
if (company == null) {
log.error("HighDeviceController -> editDevice() error!","参数错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的分公司");
}
device.setCompanyId(company.getId());
device.setCompanyName(company.getName());
device.setMerId(merchant.getId());
device.setMerName(merchant.getMerchantName());
device.setMerStoreId(store.getId());
device.setMerStoreName(store.getStoreName());
device.setType(body.getType());
device.setDeviceName(body.getDeviceName());
device.setDeviceSn(body.getDeviceSn());
device.setDeviceKey(body.getDeviceKey());
device.setDeviceImei(body.getDeviceImei());
device.setDeviceIccid(body.getDeviceIccid());
deviceService.editDevice(device);
return ResponseMsgUtil.success("操作成功");
} catch (Exception e) {
log.error("HighDeviceController -> insertCoupon() error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/delDevice",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "删除设备")
public ResponseData delDevice(@RequestBody JSONObject body) {
try {
if (body.getLong("deviceId") == null) {
log.error("HighDeviceController -> delDevice() error!","参数错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
// 查询设备
HighDevice device = deviceService.getDetailById(body.getLong("deviceId"));
if (device == null) {
log.error("HighDeviceController -> delDevice() error!","参数错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
device.setStatus(0);
deviceService.editDevice(device);
return ResponseMsgUtil.success("操作成功");
} catch (Exception e) {
log.error("HighDeviceController -> delDevice() error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/getDetailById",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "根据id查询设备详情")
public ResponseData getDetailById(@RequestParam(name = "deviceId", required = true) Long deviceId) {
try {
return ResponseMsgUtil.success(deviceService.getDetailById(deviceId));
} catch (Exception e) {
log.error("HighDeviceController -> getDetailById() error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/getDeviceList",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "根据id查询设备详情")
public ResponseData getDeviceList(@RequestParam(name = "companyId", required = false) Long companyId,
@RequestParam(name = "merId", required = false) Long merId,
@RequestParam(name = "storeId", required = false) Long storeId,
@RequestParam(name = "deviceName", required = false) String deviceName,
@RequestParam(name = "pageNum", required = true) Integer pageNum,
@RequestParam(name = "pageSize", required = true) Integer pageSize) {
try {
UserInfoModel sessionModel = userCenter.getSessionModel(UserInfoModel.class);
if (sessionModel == null) {
log.error("HighDeviceController -> getDeviceList() error!","");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到");
}
Map<String, Object> param = new HashMap<>();
param.put("deviceName", deviceName);
if (sessionModel.getSecUser().getObjectType().equals(0)) {
param.put("companyId", companyId);
param.put("merId", merId);
param.put("storeId", storeId);
} else if (sessionModel.getSecUser().getObjectType().equals(1)) {
param.put("companyId", sessionModel.getBsCompany().getId());
param.put("merId", merId);
param.put("storeId", storeId);
} else if (sessionModel.getSecUser().getObjectType().equals(2)) {
param.put("merId", sessionModel.getMerchant().getId());
param.put("storeId", storeId);
} else if (sessionModel.getSecUser().getObjectType().equals(3)) {
param.put("storeId", sessionModel.getMerchantStore().getId());
} else {
log.error("HighDeviceController -> getDeviceList() error!","");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMPETENCE_INSUFFICIENT, "");
}
PageHelper.startPage(pageNum, pageSize);
return ResponseMsgUtil.success(new PageInfo<>(deviceService.getDeviceList(param)));
} catch (Exception e) {
log.error("HighDeviceController -> getDeviceList() error!",e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -14,13 +14,13 @@ import org.springframework.context.annotation.Configuration;
@Configuration
@Slf4j
public class MqttProviderConfig {
// @Value("${spring.mqtt.username}")
@Value("${spring.mqtt.username}")
private String username;
// @Value("${spring.mqtt.password}")
@Value("${spring.mqtt.password}")
private String password;
// @Value("${spring.mqtt.url}")
@Value("${spring.mqtt.url}")
private String hostUrl;
/* @Value("${spring.mqtt.client.id}")

@ -0,0 +1,155 @@
package com.hai.dao;
import com.hai.entity.HighDevice;
import com.hai.entity.HighDeviceExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.springframework.stereotype.Repository;
/**
*
* 代码由工具生成,请勿修改!!!
* 如果需要扩展请在其父类进行扩展
*
**/
@Repository
public interface HighDeviceMapper extends HighDeviceMapperExt {
@SelectProvider(type=HighDeviceSqlProvider.class, method="countByExample")
long countByExample(HighDeviceExample example);
@DeleteProvider(type=HighDeviceSqlProvider.class, method="deleteByExample")
int deleteByExample(HighDeviceExample example);
@Delete({
"delete from high_device",
"where id = #{id,jdbcType=BIGINT}"
})
int deleteByPrimaryKey(Long id);
@Insert({
"insert into high_device (`type`, company_id, ",
"company_name, mer_id, ",
"mer_name, mer_store_id, ",
"mer_store_name, device_name, ",
"device_sn, device_key, ",
"device_imei, device_iccid, ",
"`status`, create_time, ",
"update_time, ext_1, ",
"ext_2, ext_3)",
"values (#{type,jdbcType=INTEGER}, #{companyId,jdbcType=BIGINT}, ",
"#{companyName,jdbcType=VARCHAR}, #{merId,jdbcType=BIGINT}, ",
"#{merName,jdbcType=VARCHAR}, #{merStoreId,jdbcType=BIGINT}, ",
"#{merStoreName,jdbcType=VARCHAR}, #{deviceName,jdbcType=VARCHAR}, ",
"#{deviceSn,jdbcType=VARCHAR}, #{deviceKey,jdbcType=VARCHAR}, ",
"#{deviceImei,jdbcType=VARCHAR}, #{deviceIccid,jdbcType=VARCHAR}, ",
"#{status,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, ",
"#{updateTime,jdbcType=TIMESTAMP}, #{ext1,jdbcType=VARCHAR}, ",
"#{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})"
})
@Options(useGeneratedKeys=true,keyProperty="id")
int insert(HighDevice record);
@InsertProvider(type=HighDeviceSqlProvider.class, method="insertSelective")
@Options(useGeneratedKeys=true,keyProperty="id")
int insertSelective(HighDevice record);
@SelectProvider(type=HighDeviceSqlProvider.class, method="selectByExample")
@Results({
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
@Result(column="type", property="type", jdbcType=JdbcType.INTEGER),
@Result(column="company_id", property="companyId", jdbcType=JdbcType.BIGINT),
@Result(column="company_name", property="companyName", jdbcType=JdbcType.VARCHAR),
@Result(column="mer_id", property="merId", jdbcType=JdbcType.BIGINT),
@Result(column="mer_name", property="merName", jdbcType=JdbcType.VARCHAR),
@Result(column="mer_store_id", property="merStoreId", jdbcType=JdbcType.BIGINT),
@Result(column="mer_store_name", property="merStoreName", jdbcType=JdbcType.VARCHAR),
@Result(column="device_name", property="deviceName", jdbcType=JdbcType.VARCHAR),
@Result(column="device_sn", property="deviceSn", jdbcType=JdbcType.VARCHAR),
@Result(column="device_key", property="deviceKey", jdbcType=JdbcType.VARCHAR),
@Result(column="device_imei", property="deviceImei", jdbcType=JdbcType.VARCHAR),
@Result(column="device_iccid", property="deviceIccid", jdbcType=JdbcType.VARCHAR),
@Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR),
@Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR),
@Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR)
})
List<HighDevice> selectByExample(HighDeviceExample example);
@Select({
"select",
"id, `type`, company_id, company_name, mer_id, mer_name, mer_store_id, mer_store_name, ",
"device_name, device_sn, device_key, device_imei, device_iccid, `status`, create_time, ",
"update_time, ext_1, ext_2, ext_3",
"from high_device",
"where id = #{id,jdbcType=BIGINT}"
})
@Results({
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
@Result(column="type", property="type", jdbcType=JdbcType.INTEGER),
@Result(column="company_id", property="companyId", jdbcType=JdbcType.BIGINT),
@Result(column="company_name", property="companyName", jdbcType=JdbcType.VARCHAR),
@Result(column="mer_id", property="merId", jdbcType=JdbcType.BIGINT),
@Result(column="mer_name", property="merName", jdbcType=JdbcType.VARCHAR),
@Result(column="mer_store_id", property="merStoreId", jdbcType=JdbcType.BIGINT),
@Result(column="mer_store_name", property="merStoreName", jdbcType=JdbcType.VARCHAR),
@Result(column="device_name", property="deviceName", jdbcType=JdbcType.VARCHAR),
@Result(column="device_sn", property="deviceSn", jdbcType=JdbcType.VARCHAR),
@Result(column="device_key", property="deviceKey", jdbcType=JdbcType.VARCHAR),
@Result(column="device_imei", property="deviceImei", jdbcType=JdbcType.VARCHAR),
@Result(column="device_iccid", property="deviceIccid", jdbcType=JdbcType.VARCHAR),
@Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR),
@Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR),
@Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR)
})
HighDevice selectByPrimaryKey(Long id);
@UpdateProvider(type=HighDeviceSqlProvider.class, method="updateByExampleSelective")
int updateByExampleSelective(@Param("record") HighDevice record, @Param("example") HighDeviceExample example);
@UpdateProvider(type=HighDeviceSqlProvider.class, method="updateByExample")
int updateByExample(@Param("record") HighDevice record, @Param("example") HighDeviceExample example);
@UpdateProvider(type=HighDeviceSqlProvider.class, method="updateByPrimaryKeySelective")
int updateByPrimaryKeySelective(HighDevice record);
@Update({
"update high_device",
"set `type` = #{type,jdbcType=INTEGER},",
"company_id = #{companyId,jdbcType=BIGINT},",
"company_name = #{companyName,jdbcType=VARCHAR},",
"mer_id = #{merId,jdbcType=BIGINT},",
"mer_name = #{merName,jdbcType=VARCHAR},",
"mer_store_id = #{merStoreId,jdbcType=BIGINT},",
"mer_store_name = #{merStoreName,jdbcType=VARCHAR},",
"device_name = #{deviceName,jdbcType=VARCHAR},",
"device_sn = #{deviceSn,jdbcType=VARCHAR},",
"device_key = #{deviceKey,jdbcType=VARCHAR},",
"device_imei = #{deviceImei,jdbcType=VARCHAR},",
"device_iccid = #{deviceIccid,jdbcType=VARCHAR},",
"`status` = #{status,jdbcType=INTEGER},",
"create_time = #{createTime,jdbcType=TIMESTAMP},",
"update_time = #{updateTime,jdbcType=TIMESTAMP},",
"ext_1 = #{ext1,jdbcType=VARCHAR},",
"ext_2 = #{ext2,jdbcType=VARCHAR},",
"ext_3 = #{ext3,jdbcType=VARCHAR}",
"where id = #{id,jdbcType=BIGINT}"
})
int updateByPrimaryKey(HighDevice record);
}

@ -0,0 +1,7 @@
package com.hai.dao;
/**
* mapper扩展类
*/
public interface HighDeviceMapperExt {
}

@ -0,0 +1,430 @@
package com.hai.dao;
import com.hai.entity.HighDevice;
import com.hai.entity.HighDeviceExample.Criteria;
import com.hai.entity.HighDeviceExample.Criterion;
import com.hai.entity.HighDeviceExample;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.jdbc.SQL;
public class HighDeviceSqlProvider {
public String countByExample(HighDeviceExample example) {
SQL sql = new SQL();
sql.SELECT("count(*)").FROM("high_device");
applyWhere(sql, example, false);
return sql.toString();
}
public String deleteByExample(HighDeviceExample example) {
SQL sql = new SQL();
sql.DELETE_FROM("high_device");
applyWhere(sql, example, false);
return sql.toString();
}
public String insertSelective(HighDevice record) {
SQL sql = new SQL();
sql.INSERT_INTO("high_device");
if (record.getType() != null) {
sql.VALUES("`type`", "#{type,jdbcType=INTEGER}");
}
if (record.getCompanyId() != null) {
sql.VALUES("company_id", "#{companyId,jdbcType=BIGINT}");
}
if (record.getCompanyName() != null) {
sql.VALUES("company_name", "#{companyName,jdbcType=VARCHAR}");
}
if (record.getMerId() != null) {
sql.VALUES("mer_id", "#{merId,jdbcType=BIGINT}");
}
if (record.getMerName() != null) {
sql.VALUES("mer_name", "#{merName,jdbcType=VARCHAR}");
}
if (record.getMerStoreId() != null) {
sql.VALUES("mer_store_id", "#{merStoreId,jdbcType=BIGINT}");
}
if (record.getMerStoreName() != null) {
sql.VALUES("mer_store_name", "#{merStoreName,jdbcType=VARCHAR}");
}
if (record.getDeviceName() != null) {
sql.VALUES("device_name", "#{deviceName,jdbcType=VARCHAR}");
}
if (record.getDeviceSn() != null) {
sql.VALUES("device_sn", "#{deviceSn,jdbcType=VARCHAR}");
}
if (record.getDeviceKey() != null) {
sql.VALUES("device_key", "#{deviceKey,jdbcType=VARCHAR}");
}
if (record.getDeviceImei() != null) {
sql.VALUES("device_imei", "#{deviceImei,jdbcType=VARCHAR}");
}
if (record.getDeviceIccid() != null) {
sql.VALUES("device_iccid", "#{deviceIccid,jdbcType=VARCHAR}");
}
if (record.getStatus() != null) {
sql.VALUES("`status`", "#{status,jdbcType=INTEGER}");
}
if (record.getCreateTime() != null) {
sql.VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}");
}
if (record.getUpdateTime() != null) {
sql.VALUES("update_time", "#{updateTime,jdbcType=TIMESTAMP}");
}
if (record.getExt1() != null) {
sql.VALUES("ext_1", "#{ext1,jdbcType=VARCHAR}");
}
if (record.getExt2() != null) {
sql.VALUES("ext_2", "#{ext2,jdbcType=VARCHAR}");
}
if (record.getExt3() != null) {
sql.VALUES("ext_3", "#{ext3,jdbcType=VARCHAR}");
}
return sql.toString();
}
public String selectByExample(HighDeviceExample example) {
SQL sql = new SQL();
if (example != null && example.isDistinct()) {
sql.SELECT_DISTINCT("id");
} else {
sql.SELECT("id");
}
sql.SELECT("`type`");
sql.SELECT("company_id");
sql.SELECT("company_name");
sql.SELECT("mer_id");
sql.SELECT("mer_name");
sql.SELECT("mer_store_id");
sql.SELECT("mer_store_name");
sql.SELECT("device_name");
sql.SELECT("device_sn");
sql.SELECT("device_key");
sql.SELECT("device_imei");
sql.SELECT("device_iccid");
sql.SELECT("`status`");
sql.SELECT("create_time");
sql.SELECT("update_time");
sql.SELECT("ext_1");
sql.SELECT("ext_2");
sql.SELECT("ext_3");
sql.FROM("high_device");
applyWhere(sql, example, false);
if (example != null && example.getOrderByClause() != null) {
sql.ORDER_BY(example.getOrderByClause());
}
return sql.toString();
}
public String updateByExampleSelective(Map<String, Object> parameter) {
HighDevice record = (HighDevice) parameter.get("record");
HighDeviceExample example = (HighDeviceExample) parameter.get("example");
SQL sql = new SQL();
sql.UPDATE("high_device");
if (record.getId() != null) {
sql.SET("id = #{record.id,jdbcType=BIGINT}");
}
if (record.getType() != null) {
sql.SET("`type` = #{record.type,jdbcType=INTEGER}");
}
if (record.getCompanyId() != null) {
sql.SET("company_id = #{record.companyId,jdbcType=BIGINT}");
}
if (record.getCompanyName() != null) {
sql.SET("company_name = #{record.companyName,jdbcType=VARCHAR}");
}
if (record.getMerId() != null) {
sql.SET("mer_id = #{record.merId,jdbcType=BIGINT}");
}
if (record.getMerName() != null) {
sql.SET("mer_name = #{record.merName,jdbcType=VARCHAR}");
}
if (record.getMerStoreId() != null) {
sql.SET("mer_store_id = #{record.merStoreId,jdbcType=BIGINT}");
}
if (record.getMerStoreName() != null) {
sql.SET("mer_store_name = #{record.merStoreName,jdbcType=VARCHAR}");
}
if (record.getDeviceName() != null) {
sql.SET("device_name = #{record.deviceName,jdbcType=VARCHAR}");
}
if (record.getDeviceSn() != null) {
sql.SET("device_sn = #{record.deviceSn,jdbcType=VARCHAR}");
}
if (record.getDeviceKey() != null) {
sql.SET("device_key = #{record.deviceKey,jdbcType=VARCHAR}");
}
if (record.getDeviceImei() != null) {
sql.SET("device_imei = #{record.deviceImei,jdbcType=VARCHAR}");
}
if (record.getDeviceIccid() != null) {
sql.SET("device_iccid = #{record.deviceIccid,jdbcType=VARCHAR}");
}
if (record.getStatus() != null) {
sql.SET("`status` = #{record.status,jdbcType=INTEGER}");
}
if (record.getCreateTime() != null) {
sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}");
}
if (record.getUpdateTime() != null) {
sql.SET("update_time = #{record.updateTime,jdbcType=TIMESTAMP}");
}
if (record.getExt1() != null) {
sql.SET("ext_1 = #{record.ext1,jdbcType=VARCHAR}");
}
if (record.getExt2() != null) {
sql.SET("ext_2 = #{record.ext2,jdbcType=VARCHAR}");
}
if (record.getExt3() != null) {
sql.SET("ext_3 = #{record.ext3,jdbcType=VARCHAR}");
}
applyWhere(sql, example, true);
return sql.toString();
}
public String updateByExample(Map<String, Object> parameter) {
SQL sql = new SQL();
sql.UPDATE("high_device");
sql.SET("id = #{record.id,jdbcType=BIGINT}");
sql.SET("`type` = #{record.type,jdbcType=INTEGER}");
sql.SET("company_id = #{record.companyId,jdbcType=BIGINT}");
sql.SET("company_name = #{record.companyName,jdbcType=VARCHAR}");
sql.SET("mer_id = #{record.merId,jdbcType=BIGINT}");
sql.SET("mer_name = #{record.merName,jdbcType=VARCHAR}");
sql.SET("mer_store_id = #{record.merStoreId,jdbcType=BIGINT}");
sql.SET("mer_store_name = #{record.merStoreName,jdbcType=VARCHAR}");
sql.SET("device_name = #{record.deviceName,jdbcType=VARCHAR}");
sql.SET("device_sn = #{record.deviceSn,jdbcType=VARCHAR}");
sql.SET("device_key = #{record.deviceKey,jdbcType=VARCHAR}");
sql.SET("device_imei = #{record.deviceImei,jdbcType=VARCHAR}");
sql.SET("device_iccid = #{record.deviceIccid,jdbcType=VARCHAR}");
sql.SET("`status` = #{record.status,jdbcType=INTEGER}");
sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}");
sql.SET("update_time = #{record.updateTime,jdbcType=TIMESTAMP}");
sql.SET("ext_1 = #{record.ext1,jdbcType=VARCHAR}");
sql.SET("ext_2 = #{record.ext2,jdbcType=VARCHAR}");
sql.SET("ext_3 = #{record.ext3,jdbcType=VARCHAR}");
HighDeviceExample example = (HighDeviceExample) parameter.get("example");
applyWhere(sql, example, true);
return sql.toString();
}
public String updateByPrimaryKeySelective(HighDevice record) {
SQL sql = new SQL();
sql.UPDATE("high_device");
if (record.getType() != null) {
sql.SET("`type` = #{type,jdbcType=INTEGER}");
}
if (record.getCompanyId() != null) {
sql.SET("company_id = #{companyId,jdbcType=BIGINT}");
}
if (record.getCompanyName() != null) {
sql.SET("company_name = #{companyName,jdbcType=VARCHAR}");
}
if (record.getMerId() != null) {
sql.SET("mer_id = #{merId,jdbcType=BIGINT}");
}
if (record.getMerName() != null) {
sql.SET("mer_name = #{merName,jdbcType=VARCHAR}");
}
if (record.getMerStoreId() != null) {
sql.SET("mer_store_id = #{merStoreId,jdbcType=BIGINT}");
}
if (record.getMerStoreName() != null) {
sql.SET("mer_store_name = #{merStoreName,jdbcType=VARCHAR}");
}
if (record.getDeviceName() != null) {
sql.SET("device_name = #{deviceName,jdbcType=VARCHAR}");
}
if (record.getDeviceSn() != null) {
sql.SET("device_sn = #{deviceSn,jdbcType=VARCHAR}");
}
if (record.getDeviceKey() != null) {
sql.SET("device_key = #{deviceKey,jdbcType=VARCHAR}");
}
if (record.getDeviceImei() != null) {
sql.SET("device_imei = #{deviceImei,jdbcType=VARCHAR}");
}
if (record.getDeviceIccid() != null) {
sql.SET("device_iccid = #{deviceIccid,jdbcType=VARCHAR}");
}
if (record.getStatus() != null) {
sql.SET("`status` = #{status,jdbcType=INTEGER}");
}
if (record.getCreateTime() != null) {
sql.SET("create_time = #{createTime,jdbcType=TIMESTAMP}");
}
if (record.getUpdateTime() != null) {
sql.SET("update_time = #{updateTime,jdbcType=TIMESTAMP}");
}
if (record.getExt1() != null) {
sql.SET("ext_1 = #{ext1,jdbcType=VARCHAR}");
}
if (record.getExt2() != null) {
sql.SET("ext_2 = #{ext2,jdbcType=VARCHAR}");
}
if (record.getExt3() != null) {
sql.SET("ext_3 = #{ext3,jdbcType=VARCHAR}");
}
sql.WHERE("id = #{id,jdbcType=BIGINT}");
return sql.toString();
}
protected void applyWhere(SQL sql, HighDeviceExample example, boolean includeExamplePhrase) {
if (example == null) {
return;
}
String parmPhrase1;
String parmPhrase1_th;
String parmPhrase2;
String parmPhrase2_th;
String parmPhrase3;
String parmPhrase3_th;
if (includeExamplePhrase) {
parmPhrase1 = "%s #{example.oredCriteria[%d].allCriteria[%d].value}";
parmPhrase1_th = "%s #{example.oredCriteria[%d].allCriteria[%d].value,typeHandler=%s}";
parmPhrase2 = "%s #{example.oredCriteria[%d].allCriteria[%d].value} and #{example.oredCriteria[%d].criteria[%d].secondValue}";
parmPhrase2_th = "%s #{example.oredCriteria[%d].allCriteria[%d].value,typeHandler=%s} and #{example.oredCriteria[%d].criteria[%d].secondValue,typeHandler=%s}";
parmPhrase3 = "#{example.oredCriteria[%d].allCriteria[%d].value[%d]}";
parmPhrase3_th = "#{example.oredCriteria[%d].allCriteria[%d].value[%d],typeHandler=%s}";
} else {
parmPhrase1 = "%s #{oredCriteria[%d].allCriteria[%d].value}";
parmPhrase1_th = "%s #{oredCriteria[%d].allCriteria[%d].value,typeHandler=%s}";
parmPhrase2 = "%s #{oredCriteria[%d].allCriteria[%d].value} and #{oredCriteria[%d].criteria[%d].secondValue}";
parmPhrase2_th = "%s #{oredCriteria[%d].allCriteria[%d].value,typeHandler=%s} and #{oredCriteria[%d].criteria[%d].secondValue,typeHandler=%s}";
parmPhrase3 = "#{oredCriteria[%d].allCriteria[%d].value[%d]}";
parmPhrase3_th = "#{oredCriteria[%d].allCriteria[%d].value[%d],typeHandler=%s}";
}
StringBuilder sb = new StringBuilder();
List<Criteria> oredCriteria = example.getOredCriteria();
boolean firstCriteria = true;
for (int i = 0; i < oredCriteria.size(); i++) {
Criteria criteria = oredCriteria.get(i);
if (criteria.isValid()) {
if (firstCriteria) {
firstCriteria = false;
} else {
sb.append(" or ");
}
sb.append('(');
List<Criterion> criterions = criteria.getAllCriteria();
boolean firstCriterion = true;
for (int j = 0; j < criterions.size(); j++) {
Criterion criterion = criterions.get(j);
if (firstCriterion) {
firstCriterion = false;
} else {
sb.append(" and ");
}
if (criterion.isNoValue()) {
sb.append(criterion.getCondition());
} else if (criterion.isSingleValue()) {
if (criterion.getTypeHandler() == null) {
sb.append(String.format(parmPhrase1, criterion.getCondition(), i, j));
} else {
sb.append(String.format(parmPhrase1_th, criterion.getCondition(), i, j,criterion.getTypeHandler()));
}
} else if (criterion.isBetweenValue()) {
if (criterion.getTypeHandler() == null) {
sb.append(String.format(parmPhrase2, criterion.getCondition(), i, j, i, j));
} else {
sb.append(String.format(parmPhrase2_th, criterion.getCondition(), i, j, criterion.getTypeHandler(), i, j, criterion.getTypeHandler()));
}
} else if (criterion.isListValue()) {
sb.append(criterion.getCondition());
sb.append(" (");
List<?> listItems = (List<?>) criterion.getValue();
boolean comma = false;
for (int k = 0; k < listItems.size(); k++) {
if (comma) {
sb.append(", ");
} else {
comma = true;
}
if (criterion.getTypeHandler() == null) {
sb.append(String.format(parmPhrase3, i, j, k));
} else {
sb.append(String.format(parmPhrase3_th, i, j, k, criterion.getTypeHandler()));
}
}
sb.append(')');
}
}
sb.append(')');
}
}
if (sb.length() > 0) {
sql.WHERE(sb.toString());
}
}
}

@ -0,0 +1,344 @@
package com.hai.entity;
import java.io.Serializable;
import java.util.Date;
/**
* high_device
* @author
*/
/**
*
* 代码由工具生成
*
**/
public class HighDevice implements Serializable {
/**
* 主键
*/
private Long id;
/**
* 设备类型 1. 商鹏4G 2. 4G打印机
*/
private Integer type;
/**
* 公司id
*/
private Long companyId;
/**
* 公司名称
*/
private String companyName;
/**
* 商户id
*/
private Long merId;
/**
* 商户名称
*/
private String merName;
/**
* 门店id
*/
private Long merStoreId;
/**
* 门店名称
*/
private String merStoreName;
/**
* 设备名称
*/
private String deviceName;
/**
* 设备SN编号
*/
private String deviceSn;
/**
* 设备KEY编号
*/
private String deviceKey;
/**
* 设备IMEI
*/
private String deviceImei;
/**
* 设备ICCID
*/
private String deviceIccid;
/**
* 状态0删除1正常
*/
private Integer status;
/**
* 创建时间
*/
private Date createTime;
/**
* 修改时间
*/
private Date updateTime;
private String ext1;
private String ext2;
private String ext3;
private static final long serialVersionUID = 1L;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public Long getCompanyId() {
return companyId;
}
public void setCompanyId(Long companyId) {
this.companyId = companyId;
}
public String getCompanyName() {
return companyName;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
}
public Long getMerId() {
return merId;
}
public void setMerId(Long merId) {
this.merId = merId;
}
public String getMerName() {
return merName;
}
public void setMerName(String merName) {
this.merName = merName;
}
public Long getMerStoreId() {
return merStoreId;
}
public void setMerStoreId(Long merStoreId) {
this.merStoreId = merStoreId;
}
public String getMerStoreName() {
return merStoreName;
}
public void setMerStoreName(String merStoreName) {
this.merStoreName = merStoreName;
}
public String getDeviceName() {
return deviceName;
}
public void setDeviceName(String deviceName) {
this.deviceName = deviceName;
}
public String getDeviceSn() {
return deviceSn;
}
public void setDeviceSn(String deviceSn) {
this.deviceSn = deviceSn;
}
public String getDeviceKey() {
return deviceKey;
}
public void setDeviceKey(String deviceKey) {
this.deviceKey = deviceKey;
}
public String getDeviceImei() {
return deviceImei;
}
public void setDeviceImei(String deviceImei) {
this.deviceImei = deviceImei;
}
public String getDeviceIccid() {
return deviceIccid;
}
public void setDeviceIccid(String deviceIccid) {
this.deviceIccid = deviceIccid;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public String getExt1() {
return ext1;
}
public void setExt1(String ext1) {
this.ext1 = ext1;
}
public String getExt2() {
return ext2;
}
public void setExt2(String ext2) {
this.ext2 = ext2;
}
public String getExt3() {
return ext3;
}
public void setExt3(String ext3) {
this.ext3 = ext3;
}
@Override
public boolean equals(Object that) {
if (this == that) {
return true;
}
if (that == null) {
return false;
}
if (getClass() != that.getClass()) {
return false;
}
HighDevice other = (HighDevice) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getType() == null ? other.getType() == null : this.getType().equals(other.getType()))
&& (this.getCompanyId() == null ? other.getCompanyId() == null : this.getCompanyId().equals(other.getCompanyId()))
&& (this.getCompanyName() == null ? other.getCompanyName() == null : this.getCompanyName().equals(other.getCompanyName()))
&& (this.getMerId() == null ? other.getMerId() == null : this.getMerId().equals(other.getMerId()))
&& (this.getMerName() == null ? other.getMerName() == null : this.getMerName().equals(other.getMerName()))
&& (this.getMerStoreId() == null ? other.getMerStoreId() == null : this.getMerStoreId().equals(other.getMerStoreId()))
&& (this.getMerStoreName() == null ? other.getMerStoreName() == null : this.getMerStoreName().equals(other.getMerStoreName()))
&& (this.getDeviceName() == null ? other.getDeviceName() == null : this.getDeviceName().equals(other.getDeviceName()))
&& (this.getDeviceSn() == null ? other.getDeviceSn() == null : this.getDeviceSn().equals(other.getDeviceSn()))
&& (this.getDeviceKey() == null ? other.getDeviceKey() == null : this.getDeviceKey().equals(other.getDeviceKey()))
&& (this.getDeviceImei() == null ? other.getDeviceImei() == null : this.getDeviceImei().equals(other.getDeviceImei()))
&& (this.getDeviceIccid() == null ? other.getDeviceIccid() == null : this.getDeviceIccid().equals(other.getDeviceIccid()))
&& (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
&& (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()))
&& (this.getExt1() == null ? other.getExt1() == null : this.getExt1().equals(other.getExt1()))
&& (this.getExt2() == null ? other.getExt2() == null : this.getExt2().equals(other.getExt2()))
&& (this.getExt3() == null ? other.getExt3() == null : this.getExt3().equals(other.getExt3()));
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getType() == null) ? 0 : getType().hashCode());
result = prime * result + ((getCompanyId() == null) ? 0 : getCompanyId().hashCode());
result = prime * result + ((getCompanyName() == null) ? 0 : getCompanyName().hashCode());
result = prime * result + ((getMerId() == null) ? 0 : getMerId().hashCode());
result = prime * result + ((getMerName() == null) ? 0 : getMerName().hashCode());
result = prime * result + ((getMerStoreId() == null) ? 0 : getMerStoreId().hashCode());
result = prime * result + ((getMerStoreName() == null) ? 0 : getMerStoreName().hashCode());
result = prime * result + ((getDeviceName() == null) ? 0 : getDeviceName().hashCode());
result = prime * result + ((getDeviceSn() == null) ? 0 : getDeviceSn().hashCode());
result = prime * result + ((getDeviceKey() == null) ? 0 : getDeviceKey().hashCode());
result = prime * result + ((getDeviceImei() == null) ? 0 : getDeviceImei().hashCode());
result = prime * result + ((getDeviceIccid() == null) ? 0 : getDeviceIccid().hashCode());
result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
result = prime * result + ((getExt1() == null) ? 0 : getExt1().hashCode());
result = prime * result + ((getExt2() == null) ? 0 : getExt2().hashCode());
result = prime * result + ((getExt3() == null) ? 0 : getExt3().hashCode());
return result;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", type=").append(type);
sb.append(", companyId=").append(companyId);
sb.append(", companyName=").append(companyName);
sb.append(", merId=").append(merId);
sb.append(", merName=").append(merName);
sb.append(", merStoreId=").append(merStoreId);
sb.append(", merStoreName=").append(merStoreName);
sb.append(", deviceName=").append(deviceName);
sb.append(", deviceSn=").append(deviceSn);
sb.append(", deviceKey=").append(deviceKey);
sb.append(", deviceImei=").append(deviceImei);
sb.append(", deviceIccid=").append(deviceIccid);
sb.append(", status=").append(status);
sb.append(", createTime=").append(createTime);
sb.append(", updateTime=").append(updateTime);
sb.append(", ext1=").append(ext1);
sb.append(", ext2=").append(ext2);
sb.append(", ext3=").append(ext3);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
}
}

@ -0,0 +1,44 @@
package com.hai.enum_type;
import java.util.Objects;
/**
* 设备类型
* @author hurui
*/
public enum DeviceTypeEnum {
type1(0 , "商鹏-4G"),
type2(1, "ZKC-4G"),
;
private Integer type;
private String name;
DeviceTypeEnum(int type , String name) {
this.type = type;
this.name = name;
}
public static String getNameByType(Integer type) {
for (DeviceTypeEnum ele : values()) {
if(Objects.equals(type,ele.getType())) return ele.getName();
}
return null;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}

@ -0,0 +1,35 @@
package com.hai.service;
import com.hai.entity.HighDevice;
import java.util.List;
import java.util.Map;
/**
* 设备管理
* @author hurui
*/
public interface HighDeviceService {
/**
* 编辑设备
* @param device
*/
void editDevice(HighDevice device);
/**
* 查询设备详情
* @param deviceId
* @return
*/
HighDevice getDetailById(Long deviceId);
/**
* 查询设备列表
* @param param
* @return
*/
List<HighDevice> getDeviceList(Map<String, Object> param);
}

@ -0,0 +1,68 @@
package com.hai.service.impl;
import com.hai.dao.HighDeviceMapper;
import com.hai.entity.HighDevice;
import com.hai.entity.HighDeviceExample;
import com.hai.service.HighDeviceService;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;
@Service("deviceService")
public class HighDeviceServiceImpl implements HighDeviceService {
@Resource
private HighDeviceMapper deviceMapper;
@Override
public void editDevice(HighDevice device) {
if (device.getId() != null) {
device.setCreateTime(new Date());
device.setUpdateTime(new Date());
device.setStatus(1);
deviceMapper.insert(device);
} else {
device.setUpdateTime(new Date());
deviceMapper.updateByPrimaryKey(device);
}
}
@Override
public HighDevice getDetailById(Long deviceId) {
return deviceMapper.selectByPrimaryKey(deviceId);
}
@Override
public List<HighDevice> getDeviceList(Map<String, Object> param) {
HighDeviceExample example = new HighDeviceExample();
HighDeviceExample.Criteria criteria = example.createCriteria().andStatusNotEqualTo(0);
if (MapUtils.getInteger(param, "type") != null) {
criteria.andTypeEqualTo(MapUtils.getInteger(param, "type"));
}
if (MapUtils.getLong(param, "companyId") != null) {
criteria.andCompanyIdEqualTo(MapUtils.getLong(param, "type"));
}
if (MapUtils.getLong(param, "merId") != null) {
criteria.andMerIdEqualTo(MapUtils.getLong(param, "merId"));
}
if (MapUtils.getLong(param, "merStoreId") != null) {
criteria.andMerStoreIdEqualTo(MapUtils.getLong(param, "merStoreId"));
}
if (StringUtils.isNotBlank(MapUtils.getString(param, "deviceName"))) {
criteria.andDeviceNameLike("%" + MapUtils.getString(param, "deviceName") + "%");
}
example.setOrderByClause("create_time desc");
return deviceMapper.selectByExample(example);
}
}
Loading…
Cancel
Save