|
@@ -4,15 +4,16 @@ import com.global.base.log.LogLevelFlag;
|
|
|
import com.global.base.log.LogPrintMgr;
|
|
import com.global.base.log.LogPrintMgr;
|
|
|
import com.shkpr.service.customgateway.core.constants.*;
|
|
import com.shkpr.service.customgateway.core.constants.*;
|
|
|
import com.shkpr.service.customgateway.core.domain.ResultResponse;
|
|
import com.shkpr.service.customgateway.core.domain.ResultResponse;
|
|
|
-import com.shkpr.service.customgateway.core.exception.SelfException;
|
|
|
|
|
-import com.shkpr.service.customgateway.core.utils.CommTool;
|
|
|
|
|
-import com.shkpr.service.customgateway.core.utils.ExcelUtil;
|
|
|
|
|
import com.shkpr.service.customgateway.core.domain.po.CustomerInfo;
|
|
import com.shkpr.service.customgateway.core.domain.po.CustomerInfo;
|
|
|
import com.shkpr.service.customgateway.core.domain.po.CustomerMeterRead;
|
|
import com.shkpr.service.customgateway.core.domain.po.CustomerMeterRead;
|
|
|
|
|
+import com.shkpr.service.customgateway.core.exception.SelfException;
|
|
|
import com.shkpr.service.customgateway.core.service.CustomerInfoService;
|
|
import com.shkpr.service.customgateway.core.service.CustomerInfoService;
|
|
|
import com.shkpr.service.customgateway.core.service.CustomerMeterReadService;
|
|
import com.shkpr.service.customgateway.core.service.CustomerMeterReadService;
|
|
|
|
|
+import com.shkpr.service.customgateway.core.utils.CommTool;
|
|
|
|
|
+import com.shkpr.service.customgateway.core.utils.ExcelUtil;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.apache.commons.collections4.MapUtils;
|
|
import org.apache.commons.collections4.MapUtils;
|
|
|
|
|
+import org.apache.commons.lang3.ArrayUtils;
|
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
@@ -71,6 +72,7 @@ public class CustomerController {
|
|
|
public ResultResponse<String> customerInfoImport(HttpServletRequest request
|
|
public ResultResponse<String> customerInfoImport(HttpServletRequest request
|
|
|
, @RequestHeader(value = Api.HEADER_CLIENT_TYPE, required = false) String strClientType
|
|
, @RequestHeader(value = Api.HEADER_CLIENT_TYPE, required = false) String strClientType
|
|
|
, @RequestHeader(value = Api.HEADER_USER_AGENT, required = false) String strUserAgent
|
|
, @RequestHeader(value = Api.HEADER_USER_AGENT, required = false) String strUserAgent
|
|
|
|
|
+ , @RequestParam(value = "meterType", required = false) Short meterType
|
|
|
, @RequestParam(value = "file", required = false) MultipartFile file) throws SelfException {
|
|
, @RequestParam(value = "file", required = false) MultipartFile file) throws SelfException {
|
|
|
//初始化序列
|
|
//初始化序列
|
|
|
requestSeq.putIfAbsent(Api.URI_XXX_CUSTOMER_INFO_IMPORT, new AtomicInteger(0));
|
|
requestSeq.putIfAbsent(Api.URI_XXX_CUSTOMER_INFO_IMPORT, new AtomicInteger(0));
|
|
@@ -78,11 +80,12 @@ public class CustomerController {
|
|
|
final String requestURI = request.getRequestURI();
|
|
final String requestURI = request.getRequestURI();
|
|
|
final String strPlatform = CommTool.getPlatformByAgent(strClientType, strUserAgent);
|
|
final String strPlatform = CommTool.getPlatformByAgent(strClientType, strUserAgent);
|
|
|
//参数校验
|
|
//参数校验
|
|
|
- if (file == null || file.isEmpty()) throw new SelfException(ResponseCode.STATUS_ERROR_JSON_FORMAT.getCode() + ""
|
|
|
|
|
- , String.format(Api.EXCEPTION_FORMAT
|
|
|
|
|
- , strPlatform
|
|
|
|
|
- , requestURI
|
|
|
|
|
- , ResponseCode.STATUS_ERROR_JSON_FORMAT.getMessage()));
|
|
|
|
|
|
|
+ if (meterType == null || file == null || file.isEmpty() || !ArrayUtils.contains(CustomerMeterType.codes(), meterType))
|
|
|
|
|
+ throw new SelfException(ResponseCode.STATUS_ERROR_JSON_FORMAT.getCode() + ""
|
|
|
|
|
+ , String.format(Api.EXCEPTION_FORMAT
|
|
|
|
|
+ , strPlatform
|
|
|
|
|
+ , requestURI
|
|
|
|
|
+ , ResponseCode.STATUS_ERROR_JSON_FORMAT.getMessage()));
|
|
|
|
|
|
|
|
//begin
|
|
//begin
|
|
|
long begin = System.currentTimeMillis();
|
|
long begin = System.currentTimeMillis();
|
|
@@ -106,8 +109,9 @@ public class CustomerController {
|
|
|
if (MapUtils.isNotEmpty(excel)) for (Map.Entry<String, List<CustomerInfo>> dataEntry : excel.entrySet()) {
|
|
if (MapUtils.isNotEmpty(excel)) for (Map.Entry<String, List<CustomerInfo>> dataEntry : excel.entrySet()) {
|
|
|
//获取数据
|
|
//获取数据
|
|
|
List<CustomerInfo> dates = dataEntry.getValue().stream()
|
|
List<CustomerInfo> dates = dataEntry.getValue().stream()
|
|
|
- //修改表状态为正常
|
|
|
|
|
|
|
+ //修改表类型,表状态为正常
|
|
|
.peek(info -> {
|
|
.peek(info -> {
|
|
|
|
|
+ info.setMeterType(meterType);
|
|
|
info.setStatusCode(CustomerInfoStatus.NORMAL.getCode());
|
|
info.setStatusCode(CustomerInfoStatus.NORMAL.getCode());
|
|
|
info.setStatusName(CustomerInfoStatus.NORMAL.getName());
|
|
info.setStatusName(CustomerInfoStatus.NORMAL.getName());
|
|
|
})
|
|
})
|