|
|
|
@ -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); |
|
|
|
|
|
|
|
|
|