提交代码

dev-discount
胡锐 3 years ago
parent 45420bc7ae
commit 63e2aacfa5
  1. 34
      hai-bweb/src/main/java/com/bweb/controller/HighDeviceController.java
  2. 4
      hai-service/src/main/java/com/hai/config/SpPrinterConfig.java
  3. 4
      hai-service/src/main/java/com/hai/enum_type/DeviceTypeEnum.java
  4. 7
      hai-service/src/main/java/com/hai/service/HighDeviceService.java
  5. 17
      hai-service/src/main/java/com/hai/service/impl/HighDeviceServiceImpl.java

@ -6,14 +6,11 @@ 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.config.SpPrinterConfig;
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;
@ -22,7 +19,6 @@ 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;
@ -30,7 +26,6 @@ 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;
@ -76,13 +71,12 @@ public class HighDeviceController {
}
if (body.getType().equals(DeviceTypeEnum.type1.getType())
&& (StringUtils.isBlank(body.getDeviceSn())) || StringUtils.isBlank(body.getDeviceKey())) {
&& (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())) {
} else 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, "");
}
@ -114,12 +108,20 @@ public class HighDeviceController {
}
// 查询分公司
BsCompany company = companyService.getCompanyById(store.getMerchantId());
BsCompany company = companyService.getCompanyById(merchant.getCompanyId());
if (company == null) {
log.error("HighDeviceController -> editDevice() error!","参数错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的分公司");
}
if (body.getType().equals(DeviceTypeEnum.type1.getType())) {
SpPrinterConfig sp = new SpPrinterConfig();
JSONObject jsonObject = JSONObject.parseObject(sp.addPrinter(body.getDeviceSn(), body.getDeviceKey(), body.getDeviceName()));
if (!jsonObject.getInteger("errorcode").equals(0)) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, jsonObject.getString("errormsg"));
}
}
device.setCompanyId(company.getId());
device.setCompanyName(company.getName());
device.setMerId(merchant.getId());
@ -137,7 +139,7 @@ public class HighDeviceController {
return ResponseMsgUtil.success("操作成功");
} catch (Exception e) {
log.error("HighDeviceController -> insertCoupon() error!",e);
log.error("HighDeviceController -> editDevice() error!",e);
return ResponseMsgUtil.exception(e);
}
}
@ -160,6 +162,14 @@ public class HighDeviceController {
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
if (device.getType().equals(DeviceTypeEnum.type1.getType())) {
SpPrinterConfig sp = new SpPrinterConfig();
JSONObject jsonObject = JSONObject.parseObject(sp.deletePrinter(device.getDeviceSn()));
if (!jsonObject.getInteger("errorcode").equals(0)) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, jsonObject.getString("errormsg"));
}
}
device.setStatus(0);
deviceService.editDevice(device);

@ -162,9 +162,9 @@ public class SpPrinterConfig {
throw new ClientProtocolException();
}
if (response.getStatusLine().getStatusCode() != 200) {
/* if (response.getStatusLine().getStatusCode() != 200) {
throw new ClientProtocolException(EntityUtils.toString(httpEntity));
}
}*/
return EntityUtils.toString(httpEntity);
}

@ -7,8 +7,8 @@ import java.util.Objects;
* @author hurui
*/
public enum DeviceTypeEnum {
type1(0 , "商鹏-4G"),
type2(1, "ZKC-4G"),
type1(1 , "商鹏云打印"),
type2(2, "ZKC云打印"),
;
private Integer type;

@ -31,5 +31,12 @@ public interface HighDeviceService {
*/
List<HighDevice> getDeviceList(Map<String, Object> param);
/**
* 根据门店id查询设备列表
* @param storeId
* @return
*/
List<HighDevice> getDeviceListByStoreId(Long storeId);
}

@ -21,7 +21,7 @@ public class HighDeviceServiceImpl implements HighDeviceService {
@Override
public void editDevice(HighDevice device) {
if (device.getId() != null) {
if (device.getId() == null) {
device.setCreateTime(new Date());
device.setUpdateTime(new Date());
device.setStatus(1);
@ -47,15 +47,15 @@ public class HighDeviceServiceImpl implements HighDeviceService {
}
if (MapUtils.getLong(param, "companyId") != null) {
criteria.andCompanyIdEqualTo(MapUtils.getLong(param, "type"));
criteria.andCompanyIdEqualTo(MapUtils.getLong(param, "companyId"));
}
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 (MapUtils.getLong(param, "storeId") != null) {
criteria.andMerStoreIdEqualTo(MapUtils.getLong(param, "storeId"));
}
if (StringUtils.isNotBlank(MapUtils.getString(param, "deviceName"))) {
@ -65,4 +65,13 @@ public class HighDeviceServiceImpl implements HighDeviceService {
example.setOrderByClause("create_time desc");
return deviceMapper.selectByExample(example);
}
@Override
public List<HighDevice> getDeviceListByStoreId(Long storeId) {
HighDeviceExample example = new HighDeviceExample();
example.createCriteria()
.andMerStoreIdEqualTo(storeId)
.andStatusNotEqualTo(0);
return deviceMapper.selectByExample(example);
}
}

Loading…
Cancel
Save