|
|
@@ -1,16 +1,24 @@
|
|
|
package org.dromara.server.base.service.yktOperation;
|
|
|
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
+import cn.hutool.core.util.ObjUtil;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
import org.dromara.backstage.api.RemoteBagService;
|
|
|
+import org.dromara.backstage.api.domain.bo.RemoteCardBo;
|
|
|
import org.dromara.backstage.api.domain.bo.RemoteConsumptionBo;
|
|
|
import org.dromara.backstage.api.domain.bo.RemotePurseInOutBo;
|
|
|
+import org.dromara.common.core.constant.DefaultConstants;
|
|
|
+import org.dromara.common.core.enums.CardOperateEnum;
|
|
|
import org.dromara.common.core.exception.ServiceException;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
/**
|
|
|
* 卡务中心卡务操作同步
|
|
|
*/
|
|
|
@@ -108,4 +116,42 @@ public class SyncRemotePtCardCenterService {
|
|
|
throw new ServiceException("卡片解挂失败");
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ public void cardOperation(Object msg) throws ServiceException{
|
|
|
+ //json转map
|
|
|
+ Map<String, Object> initParam = JSONUtil.parseObj(msg).toBean(Map.class);
|
|
|
+ boolean flag = bagService.initEntityCard(getInitInfo(initParam));
|
|
|
+ if (!flag){
|
|
|
+ throw new ServiceException("卡片操作失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private RemoteCardBo getInitInfo(Map<String, Object> initParam) {
|
|
|
+ RemoteCardBo bo = new RemoteCardBo();
|
|
|
+ bo.setCardId(ObjUtil.isNotEmpty(initParam.get("cardId")) ? Long.parseLong(initParam.get("cardId").toString()) : null);
|
|
|
+ bo.setUserId(ObjUtil.isNotEmpty(initParam.get("userId")) ? Long.parseLong(initParam.get("userId").toString()) : 0);
|
|
|
+ bo.setCardType(ObjUtil.isNotEmpty(initParam.get("cardTypeId")) ? Long.parseLong(initParam.get("cardTypeId").toString()) : 0);
|
|
|
+ bo.setLifespan(ObjUtil.isNotEmpty(initParam.get("expiryDate")) ? DateUtil.parse(initParam.get("expiryDate").toString(),
|
|
|
+ DefaultConstants.DATE_TIME_FORMAT) : null);
|
|
|
+ bo.setFactoryId(ObjUtil.isNotEmpty(initParam.get("factoryFixId")) ? Long.parseLong(initParam.get("factoryFixId").toString()) : 0);
|
|
|
+ if (ObjUtil.isNotEmpty(initParam.get("mainDeputyType"))) {
|
|
|
+ bo.setMainCard(ObjectUtil.equals(initParam.get("mainDeputyType"), "1") ? "Y" : "N");
|
|
|
+ } else {
|
|
|
+ bo.setMainCard("Y");
|
|
|
+ }
|
|
|
+ bo.setCardNo(ObjectUtil.isNotEmpty(initParam.get("cardNo")) ? Long.parseLong(initParam.get("cardNo").toString()) : 0);
|
|
|
+ // 默认为发新卡
|
|
|
+ String temp = initParam.get("cardOperate").toString();
|
|
|
+ if(ObjUtil.isNotEmpty(temp)){
|
|
|
+ bo.setOperateType(CardOperateEnum.valueOf(temp));
|
|
|
+ } else {
|
|
|
+ bo.setOperateType(CardOperateEnum.ISSUE);
|
|
|
+ }
|
|
|
+ bo.setStationNumb(ObjUtil.isNotEmpty(initParam.get("workStationNumb")) ? Long.parseLong(initParam.get("workStationNumb").toString()) : 0);
|
|
|
+ bo.setTenantId(ObjUtil.isNotEmpty(initParam.get("tenantId")) ? initParam.get("tenantId").toString() : DefaultConstants.TENANT_ID);
|
|
|
+ bo.setOldCardNo(ObjUtil.isNotEmpty(initParam.get("oldCardNo")) ? Long.parseLong(initParam.get("oldCardNo").toString()) : 0);
|
|
|
+ bo.setOldFactoryId(ObjUtil.isNotEmpty(initParam.get("oldFactoryFixId")) ? Long.parseLong(initParam.get("oldFactoryFixId").toString()) : 0);
|
|
|
+ bo.setOldCardId(ObjUtil.isNotEmpty(initParam.get("oldCardId")) ? Long.parseLong(initParam.get("oldCardId").toString()) : 0);
|
|
|
+ return bo;
|
|
|
+ }
|
|
|
}
|