diff --git a/chushang-common/chushang-common-log/src/main/java/com/chushang/common/log/annotation/SysLog.java b/chushang-common/chushang-common-log/src/main/java/com/chushang/common/log/annotation/SysLog.java index 904fd4e..4e6fb31 100644 --- a/chushang-common/chushang-common-log/src/main/java/com/chushang/common/log/annotation/SysLog.java +++ b/chushang-common/chushang-common-log/src/main/java/com/chushang/common/log/annotation/SysLog.java @@ -28,4 +28,9 @@ public @interface SysLog { */ BusinessType businessType() default BusinessType.OTHER; + /** + * 是否为远程 接口, + */ + boolean remote() default false; + } diff --git a/chushang-common/chushang-common-log/src/main/java/com/chushang/common/log/aspect/SysLogAspect.java b/chushang-common/chushang-common-log/src/main/java/com/chushang/common/log/aspect/SysLogAspect.java index 874b1bb..ea322b0 100644 --- a/chushang-common/chushang-common-log/src/main/java/com/chushang/common/log/aspect/SysLogAspect.java +++ b/chushang-common/chushang-common-log/src/main/java/com/chushang/common/log/aspect/SysLogAspect.java @@ -107,7 +107,7 @@ public class SysLogAspect { SysLogEntity sysLogEntity = new SysLogEntity(); SysLog syslog = method.getAnnotation(SysLog.class); - + boolean remote = false; if (syslog != null) { String value = syslog.value(); BusinessType businessType = syslog.businessType(); @@ -115,6 +115,7 @@ public class SysLogAspect { value = businessType.getDesc() + value; sysLogEntity.setOperationType(businessType.getCode()); } + remote = syslog.remote(); sysLogEntity.setOperation(value); if (null != args && args.length > 0) { // 将导出的response 过滤掉 @@ -159,11 +160,12 @@ public class SysLogAspect { sysLogEntity.setUsername(username); //保存系统日志 } else { - if (!ipAddr.equals("localhost") && !ipAddr.equals("127.0.0.1")) { + + if (!ipAddr.equals("localhost") && !ipAddr.equals("127.0.0.1") && remote) { throw new ResultException("没有权限"); } sysLogEntity.setUserId(1L); - sysLogEntity.setUsername("error"); + sysLogEntity.setUsername("system"); } String startTime = request.getHeader(CommonConstants.START_TIME); // 执行时间 diff --git a/chushang-common/chushang-common-mybatis/src/main/java/com/chushang/common/mybatis/config/MybatisPlusMetaObjectHandler.java b/chushang-common/chushang-common-mybatis/src/main/java/com/chushang/common/mybatis/config/MybatisPlusMetaObjectHandler.java index c85a80c..d35ede8 100644 --- a/chushang-common/chushang-common-mybatis/src/main/java/com/chushang/common/mybatis/config/MybatisPlusMetaObjectHandler.java +++ b/chushang-common/chushang-common-mybatis/src/main/java/com/chushang/common/mybatis/config/MybatisPlusMetaObjectHandler.java @@ -30,8 +30,11 @@ public class MybatisPlusMetaObjectHandler implements MetaObjectHandler { // 用于填充 创建人以及修改人 // String userName = SecurityContextHolder.getUserName(); String userName = "system"; + this.fillStrategy(metaObject, "createBy", userName); + // 自动填充下 版本号 + this.fillStrategy(metaObject, "version", 0); this.strictInsertFill(metaObject, "createTime", LocalDateTime.class, LocalDateTime.now()); - this.strictInsertFill(metaObject, "createBy", String.class, userName); +// this.strictInsertFill(metaObject, "createBy", String.class, userName); } /** @@ -45,6 +48,8 @@ public class MybatisPlusMetaObjectHandler implements MetaObjectHandler { String userName = "system"; this.strictUpdateFill(metaObject, "updateTime", LocalDateTime.class, LocalDateTime.now()); this.strictUpdateFill(metaObject, "updateBy", String.class, userName); + // 自动填充下 版本号 + this.fillStrategy(metaObject, "version", 0); } } diff --git a/chushang-modules/chushang-module-inspection/inspection-feign/src/main/java/com/chushang/inspection/terminal/enums/MerTypeOperation.java b/chushang-modules/chushang-module-inspection/inspection-feign/src/main/java/com/chushang/inspection/terminal/enums/MerTypeOperation.java new file mode 100644 index 0000000..7624379 --- /dev/null +++ b/chushang-modules/chushang-module-inspection/inspection-feign/src/main/java/com/chushang/inspection/terminal/enums/MerTypeOperation.java @@ -0,0 +1,44 @@ +package com.chushang.inspection.terminal.enums; + + +import cn.hutool.core.util.StrUtil; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum MerTypeOperation { + // 1-POS 商户,2-条码支付商户 + POS_MERCHANT("1", 7), + BARCODE_PAYMENT_MERCHANT("2", 8); + + private final String code; + private final Integer merType; + + // 通过编号获取枚举值 + public static Integer valueOfCode(String code) { + if (StrUtil.isEmpty(code)) { + return null; + } + for (MerTypeOperation operation : MerTypeOperation.values()) { + if (operation.code.equals(code)) { + return operation.merType; + } + } + return null; + } + + // 通过编号获取枚举值 + public static String valueOfMerType(Integer workType) { + if (workType == null) { + return null; + } + for (MerTypeOperation operation : MerTypeOperation.values()) { + if (operation.merType.equals(workType)) { + return operation.code; + } + } + return null; + } + +} diff --git a/chushang-modules/chushang-module-inspection/inspection-feign/src/main/java/com/chushang/inspection/terminal/po/Store.java b/chushang-modules/chushang-module-inspection/inspection-feign/src/main/java/com/chushang/inspection/terminal/po/Store.java index 99df54f..8a9e22f 100644 --- a/chushang-modules/chushang-module-inspection/inspection-feign/src/main/java/com/chushang/inspection/terminal/po/Store.java +++ b/chushang-modules/chushang-module-inspection/inspection-feign/src/main/java/com/chushang/inspection/terminal/po/Store.java @@ -8,6 +8,10 @@ import com.chushang.common.mybatis.base.BaseEntity; import java.time.LocalDateTime; import java.util.Date; + +import com.chushang.inspection.terminal.enums.MerTypeOperation; +import com.chushang.inspection.work.dto.WrkIcbcJsReceive; +import com.chushang.inspection.work.enums.BankBranchesEnum; import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; @@ -162,4 +166,22 @@ public class Store extends BaseEntity { */ @TableField(value = "state") private Integer state; + + public Store save(WrkIcbcJsReceive dto) { + this.storeNo = dto.getMerId(); + this.storeName = dto.getMerName(); + this.storeContact = dto.getLinkName(); + this.storePhone = dto.getContactWay(); + this.storeAddress = dto.getMerAddress(); + this.storeType = MerTypeOperation.valueOfCode(dto.getMerType()); + // todo 所属 任务id + this.taskId = 1L; + // todo 所属部门id + this.deptId = 1L; + this.createBy = "zhuguihua"; + this.isEnter = 2; + Long lowerTaskId = BankBranchesEnum.getByCode(dto.getArea()); + this.lowerTaskId = lowerTaskId == null ? this.taskId : lowerTaskId; + return this; + } } diff --git a/chushang-modules/chushang-module-inspection/inspection-feign/src/main/java/com/chushang/inspection/terminal/po/Terminal.java b/chushang-modules/chushang-module-inspection/inspection-feign/src/main/java/com/chushang/inspection/terminal/po/Terminal.java index 11c994b..79a7c8b 100644 --- a/chushang-modules/chushang-module-inspection/inspection-feign/src/main/java/com/chushang/inspection/terminal/po/Terminal.java +++ b/chushang-modules/chushang-module-inspection/inspection-feign/src/main/java/com/chushang/inspection/terminal/po/Terminal.java @@ -9,6 +9,9 @@ import com.chushang.common.mybatis.base.BaseEntity; import java.time.LocalDate; import java.time.LocalDateTime; import java.util.Date; + +import com.chushang.inspection.work.dto.WrkIcbcJsReceive; +import com.chushang.inspection.work.enums.TerminalTypeOperation; import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; @@ -129,4 +132,18 @@ public class Terminal extends BaseEntity { private String remark; + public Terminal save(Store store, WrkIcbcJsReceive dto) { + this.storeId = store.getStoreId(); + this.storeNo = store.getStoreNo(); + this.taskId = store.getTaskId(); + this.lowerTaskId = store.getLowerTaskId(); + this.deptId = store.getDeptId(); + this.createBy = store.getCreateBy(); + this.terminalNo = dto.getTermId(); + this.terminalSn = dto.getDeviceNo(); + this.terminalType = TerminalTypeOperation.valueOfCode(dto.getDeviceType()); + this.remark = dto.getNoteMsg(); + this.occupy = 0; + return this; + } } diff --git a/chushang-modules/chushang-module-inspection/inspection-feign/src/main/java/com/chushang/inspection/terminal/po/TerminalIns.java b/chushang-modules/chushang-module-inspection/inspection-feign/src/main/java/com/chushang/inspection/terminal/po/TerminalIns.java index 629a0a2..1c189f1 100644 --- a/chushang-modules/chushang-module-inspection/inspection-feign/src/main/java/com/chushang/inspection/terminal/po/TerminalIns.java +++ b/chushang-modules/chushang-module-inspection/inspection-feign/src/main/java/com/chushang/inspection/terminal/po/TerminalIns.java @@ -29,30 +29,6 @@ public class TerminalIns extends BaseEntity { @TableId(value = "terminal_id", type = IdType.ASSIGN_ID) private Long terminalId; - /** - * 租户id - */ - @TableField(value = "dept_id") - private Long deptId; - - /** - * 任务id - */ - @TableField(value = "task_id") - private Long taskId; - - /** - * 下级任务id - */ - @TableField(value = "lower_task_id") - private Long lowerTaskId; - - /** - * 所属商户id - */ - @TableField(value = "store_id") - private Long storeId; - /** * 银行资产管理码 */ diff --git a/chushang-modules/chushang-module-inspection/inspection-feign/src/main/java/com/chushang/inspection/work/dto/DispatchDTO.java b/chushang-modules/chushang-module-inspection/inspection-feign/src/main/java/com/chushang/inspection/work/dto/DispatchDTO.java index 71efbeb..fb7860d 100644 --- a/chushang-modules/chushang-module-inspection/inspection-feign/src/main/java/com/chushang/inspection/work/dto/DispatchDTO.java +++ b/chushang-modules/chushang-module-inspection/inspection-feign/src/main/java/com/chushang/inspection/work/dto/DispatchDTO.java @@ -18,10 +18,7 @@ import java.time.LocalDateTime; @AllArgsConstructor public class DispatchDTO implements Serializable { - /** - * 主键 - */ - private Long terminalId; + /** * 部门id @@ -128,6 +125,11 @@ public class DispatchDTO implements Serializable { */ private String legalName; + /** + * 主键 + */ + private Long terminalId; + /** * 终端sn号 */ @@ -184,24 +186,24 @@ public class DispatchDTO implements Serializable { protected LocalDateTime createTime; public DispatchDTO dispatch(WrkIcbcJs entity) { - terminalId = entity.getTerminalId(); - // 此处应当为 江苏工行的部门id - deptId = 200L; - taskId = 1701151817643495425L; - storeId = entity.getStoreId(); + this.terminalId = entity.getTerminalId(); + // todo 此处应当为 江苏工行的部门id + this.deptId = 200L; + this.taskId = 1701151817643495425L; + this.storeId = entity.getStoreId(); Long lowerTaskId = BankBranchesEnum.getByCode(entity.getArea()); this.lowerTaskId = lowerTaskId == null ? this.taskId : lowerTaskId; - storeNo = entity.getMerId(); - storeName = entity.getMerName(); - storeContact = entity.getLinkName(); - storePhone = entity.getContactWay(); - storeAddress = entity.getMerAddress(); - createBy = "zhuguihua"; - createTime = LocalDateTime.now(); - terminalAddress = entity.getMerAddress(); - terminalNo = entity.getTermId(); - terminalSn = entity.getDeviceNo(); - terminalType = TerminalTypeOperation.valueOfCode(entity.getDeviceType()); + this.storeNo = entity.getMerId(); + this.storeName = entity.getMerName(); + this.storeContact = entity.getLinkName(); + this.storePhone = entity.getContactWay(); + this.storeAddress = entity.getMerAddress(); + this.createBy = "zhuguihua"; + this.createTime = LocalDateTime.now(); + this.terminalAddress = entity.getMerAddress(); + this.terminalNo = entity.getTermId(); + this.terminalSn = entity.getDeviceNo(); + this.terminalType = TerminalTypeOperation.valueOfCode(entity.getDeviceType()); return this; } } diff --git a/chushang-modules/chushang-module-inspection/inspection-feign/src/main/java/com/chushang/inspection/work/po/WrkIcbcJs.java b/chushang-modules/chushang-module-inspection/inspection-feign/src/main/java/com/chushang/inspection/work/po/WrkIcbcJs.java index ec96810..46ffd46 100644 --- a/chushang-modules/chushang-module-inspection/inspection-feign/src/main/java/com/chushang/inspection/work/po/WrkIcbcJs.java +++ b/chushang-modules/chushang-module-inspection/inspection-feign/src/main/java/com/chushang/inspection/work/po/WrkIcbcJs.java @@ -1,11 +1,19 @@ package com.chushang.inspection.work.po; +import cn.hutool.core.date.DatePattern; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.chushang.common.mybatis.base.BaseEntity; + +import java.io.Serial; +import java.io.Serializable; +import java.time.LocalDate; +import java.time.LocalTime; import java.util.Date; + +import com.fasterxml.jackson.annotation.JsonFormat; import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; @@ -19,11 +27,13 @@ import lombok.NoArgsConstructor; * 江苏工行数据推送 */ @Data -@EqualsAndHashCode(callSuper=true) +@EqualsAndHashCode @AllArgsConstructor @NoArgsConstructor @TableName(value = "wrk_icbc_js") -public class WrkIcbcJs extends BaseEntity { +public class WrkIcbcJs implements Serializable { + @Serial + private static final long serialVersionUID = 1L; /** * 主键 */ @@ -136,13 +146,13 @@ public class WrkIcbcJs extends BaseEntity { * 请求日期 */ @TableField(value = "req_date") - private Date reqDate; + private LocalDate reqDate; /** * 请求时间 */ @TableField(value = "req_time") - private Date reqTime; + private LocalTime reqTime; /** * 工单状态 @@ -172,7 +182,7 @@ public class WrkIcbcJs extends BaseEntity { * 状态(1 下发 2 回送成功 3 回送失败) */ @TableField(value = "`status`") - private Byte status; + private Integer status; /** * 商户类型 @@ -184,13 +194,13 @@ public class WrkIcbcJs extends BaseEntity { * 请求日期 */ @TableField(value = "comp_date") - private Date compDate; + private LocalDate compDate; /** * 请求时间 */ @TableField(value = "comp_time") - private Date compTime; + private LocalTime compTime; /** * 异常消息 @@ -202,5 +212,6 @@ public class WrkIcbcJs extends BaseEntity { * 是否为银行派单(1 是 2否) */ @TableField(value = "is_bank") - private Boolean isBank; + private Byte isBank; + } diff --git a/chushang-modules/chushang-module-inspection/inspection-feign/src/main/java/com/chushang/inspection/work/po/WrkInfo.java b/chushang-modules/chushang-module-inspection/inspection-feign/src/main/java/com/chushang/inspection/work/po/WrkInfo.java index bddca11..900e201 100644 --- a/chushang-modules/chushang-module-inspection/inspection-feign/src/main/java/com/chushang/inspection/work/po/WrkInfo.java +++ b/chushang-modules/chushang-module-inspection/inspection-feign/src/main/java/com/chushang/inspection/work/po/WrkInfo.java @@ -97,6 +97,11 @@ public class WrkInfo extends BaseEntity { */ @TableField(value = "work_source") private Integer workSource; + /** + * 第三方 工单编号 + */ + @TableField(value = "order_no") + private String orderNo; /** * 业务员处理时间 diff --git a/chushang-modules/chushang-module-inspection/inspection-service/src/main/java/com/chushang/inspection/terminal/service/StoreService.java b/chushang-modules/chushang-module-inspection/inspection-service/src/main/java/com/chushang/inspection/terminal/service/StoreService.java index 7204234..86bd0ac 100644 --- a/chushang-modules/chushang-module-inspection/inspection-service/src/main/java/com/chushang/inspection/terminal/service/StoreService.java +++ b/chushang-modules/chushang-module-inspection/inspection-service/src/main/java/com/chushang/inspection/terminal/service/StoreService.java @@ -5,6 +5,7 @@ import com.chushang.common.mybatis.utils.PageResult; import com.chushang.inspection.project.po.Template; import com.chushang.inspection.terminal.po.Store; import com.chushang.inspection.terminal.query.StoreQuery; +import com.chushang.inspection.work.dto.WrkIcbcJsReceive; import org.springframework.web.multipart.MultipartFile; /** @@ -18,4 +19,5 @@ public interface StoreService extends IService{ void upload(MultipartFile file, Long taskId); + Store save(WrkIcbcJsReceive dto); } diff --git a/chushang-modules/chushang-module-inspection/inspection-service/src/main/java/com/chushang/inspection/terminal/service/TerminalService.java b/chushang-modules/chushang-module-inspection/inspection-service/src/main/java/com/chushang/inspection/terminal/service/TerminalService.java index fb27c91..69e0b5d 100644 --- a/chushang-modules/chushang-module-inspection/inspection-service/src/main/java/com/chushang/inspection/terminal/service/TerminalService.java +++ b/chushang-modules/chushang-module-inspection/inspection-service/src/main/java/com/chushang/inspection/terminal/service/TerminalService.java @@ -1,15 +1,19 @@ package com.chushang.inspection.terminal.service; +import com.alibaba.fastjson2.JSONObject; import com.baomidou.mybatisplus.extension.service.IService; import com.chushang.common.mybatis.utils.PageResult; import com.chushang.inspection.project.vo.TerminalApp; +import com.chushang.inspection.terminal.po.Store; import com.chushang.inspection.terminal.po.Terminal; import com.chushang.inspection.terminal.query.TerminalAppQuery; import com.chushang.inspection.terminal.query.TerminalQuery; import com.chushang.inspection.work.dto.DispatchDTO; +import com.chushang.inspection.work.dto.WrkIcbcJsReceive; import com.chushang.inspection.work.query.DispatchQuery; import java.util.List; +import java.util.Map; /** * @auther: zhao @@ -49,4 +53,6 @@ public interface TerminalService extends IService{ * @return */ List getStoreByTasKIdOrIds(DispatchQuery query); + + JSONObject save(Store store, WrkIcbcJsReceive dto); } diff --git a/chushang-modules/chushang-module-inspection/inspection-service/src/main/java/com/chushang/inspection/terminal/service/impl/StoreImportServiceImpl.java b/chushang-modules/chushang-module-inspection/inspection-service/src/main/java/com/chushang/inspection/terminal/service/impl/StoreImportServiceImpl.java index 70bcb97..8efe2ca 100644 --- a/chushang-modules/chushang-module-inspection/inspection-service/src/main/java/com/chushang/inspection/terminal/service/impl/StoreImportServiceImpl.java +++ b/chushang-modules/chushang-module-inspection/inspection-service/src/main/java/com/chushang/inspection/terminal/service/impl/StoreImportServiceImpl.java @@ -175,9 +175,9 @@ public class StoreImportServiceImpl extends ServiceImpl implements } + /** + * TODO 此处需要添加 任务id + * @param dto + * @return + */ + @Override + public Store save(WrkIcbcJsReceive dto) { + Store store = getOne(new LambdaQueryWrapper() + .eq(Store::getTaskId, "") + .eq(Store::getStoreNo, dto.getMerId()) + ); + if (store == null) { + store = new Store().save(dto); + save(store); + } + return store; + } + private List convert(List records){ List storeVOS = new ArrayList<>(); diff --git a/chushang-modules/chushang-module-inspection/inspection-service/src/main/java/com/chushang/inspection/terminal/service/impl/TerminalServiceImpl.java b/chushang-modules/chushang-module-inspection/inspection-service/src/main/java/com/chushang/inspection/terminal/service/impl/TerminalServiceImpl.java index 9f79c15..e71b249 100644 --- a/chushang-modules/chushang-module-inspection/inspection-service/src/main/java/com/chushang/inspection/terminal/service/impl/TerminalServiceImpl.java +++ b/chushang-modules/chushang-module-inspection/inspection-service/src/main/java/com/chushang/inspection/terminal/service/impl/TerminalServiceImpl.java @@ -2,7 +2,10 @@ package com.chushang.inspection.terminal.service.impl; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.convert.Convert; +import cn.hutool.core.lang.Assert; import cn.hutool.core.util.ObjectUtil; +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.chushang.common.core.constant.SecurityConstants; @@ -15,14 +18,17 @@ import com.chushang.inspection.project.vo.TerminalApp; import com.chushang.inspection.project.vo.TerminalAppVO; import com.chushang.inspection.terminal.po.Store; import com.chushang.inspection.terminal.po.Terminal; +import com.chushang.inspection.terminal.po.TerminalIns; import com.chushang.inspection.terminal.query.TerminalAppQuery; import com.chushang.inspection.terminal.query.TerminalQuery; import com.chushang.inspection.terminal.service.StoreService; +import com.chushang.inspection.terminal.service.TerminalInsService; import com.chushang.inspection.terminal.service.TerminalService; import com.chushang.inspection.terminal.vo.StoreTerminalVO; import com.chushang.inspection.terminal.vo.TerminalVO; import com.chushang.inspection.utils.TaskConfigUtils; import com.chushang.inspection.work.dto.DispatchDTO; +import com.chushang.inspection.work.dto.WrkIcbcJsReceive; import com.chushang.inspection.work.po.WrkInfo; import com.chushang.inspection.work.query.DispatchQuery; import com.chushang.system.feign.RemoteDeptService; @@ -45,6 +51,8 @@ public class TerminalServiceImpl extends ServiceImpl i @Resource private StoreService storeService; @Resource + private TerminalInsService terminalInsService; + @Resource private RemoteDeptService remoteDeptService; @@ -110,4 +118,26 @@ public class TerminalServiceImpl extends ServiceImpl i return baseMapper.getStoreByTasKIdOrIds(query); } + @Override + public JSONObject save(Store store, WrkIcbcJsReceive dto) { + Terminal terminal = getOne(new LambdaQueryWrapper() + .eq(Terminal::getStoreId, store.getStoreId()) + .eq(Terminal::getTerminalNo, dto.getTermId()) + ); + TerminalIns terminalIns; + if (terminal == null){ + terminal = new Terminal().save(store, dto); + save(terminal); + terminalIns = new TerminalIns(); + terminalIns.setTerminalId(terminal.getTerminalId()); + terminalIns.setIsEnter(2); + terminalIns.setCreateBy(store.getCreateBy()); + terminalInsService.save(terminalIns); + return JSONObject.of("terminal", terminal, "terminalIns", terminalIns); + }else { + terminalIns = terminalInsService.getById(terminal.getTerminalId()); + } + return JSONObject.of("terminal", terminal, "terminalIns", terminalIns); + } + } diff --git a/chushang-modules/chushang-module-inspection/inspection-service/src/main/java/com/chushang/inspection/work/controller/WrkIcbcJsController.java b/chushang-modules/chushang-module-inspection/inspection-service/src/main/java/com/chushang/inspection/work/controller/WrkIcbcJsController.java index ff2ac60..ece8707 100644 --- a/chushang-modules/chushang-module-inspection/inspection-service/src/main/java/com/chushang/inspection/work/controller/WrkIcbcJsController.java +++ b/chushang-modules/chushang-module-inspection/inspection-service/src/main/java/com/chushang/inspection/work/controller/WrkIcbcJsController.java @@ -33,7 +33,7 @@ public class WrkIcbcJsController { @Resource private WrkIcbcJsService wrkIcbcJsService; - @SysLog("江苏工行数据接收") + @SysLog(value = "江苏工行数据接收", remote = true, businessType = BusinessType.INSERT) @PostMapping("/receive") public Result receive(@RequestBody WrkIcbcJsReceive dto) { try { diff --git a/chushang-modules/chushang-module-inspection/inspection-service/src/main/java/com/chushang/inspection/work/service/WrkInfoService.java b/chushang-modules/chushang-module-inspection/inspection-service/src/main/java/com/chushang/inspection/work/service/WrkInfoService.java index df0c237..eb313c4 100644 --- a/chushang-modules/chushang-module-inspection/inspection-service/src/main/java/com/chushang/inspection/work/service/WrkInfoService.java +++ b/chushang-modules/chushang-module-inspection/inspection-service/src/main/java/com/chushang/inspection/work/service/WrkInfoService.java @@ -2,6 +2,9 @@ package com.chushang.inspection.work.service; import com.chushang.common.mybatis.utils.PageResult; import com.chushang.inspection.project.dto.AuditDTO; +import com.chushang.inspection.terminal.po.Store; +import com.chushang.inspection.terminal.po.Terminal; +import com.chushang.inspection.terminal.po.TerminalIns; import com.chushang.inspection.work.dto.WrkInfoDTO; import com.chushang.inspection.work.po.WrkInfo; import com.baomidou.mybatisplus.extension.service.IService; @@ -40,4 +43,7 @@ public interface WrkInfoService extends IService { void audit(AuditDTO audit); void exportDispatchPage(HttpServletResponse response, WrkInfoQuery query); + + Long dispatch(WrkInfo wrkInfo, Store store, Terminal terminal, TerminalIns terminalIns); + } diff --git a/chushang-modules/chushang-module-inspection/inspection-service/src/main/java/com/chushang/inspection/work/service/WrkScheduleService.java b/chushang-modules/chushang-module-inspection/inspection-service/src/main/java/com/chushang/inspection/work/service/WrkScheduleService.java new file mode 100644 index 0000000..a2f986d --- /dev/null +++ b/chushang-modules/chushang-module-inspection/inspection-service/src/main/java/com/chushang/inspection/work/service/WrkScheduleService.java @@ -0,0 +1,8 @@ +package com.chushang.inspection.work.service; + + +import java.util.Collection; + +public interface WrkScheduleService { + void updateWorkOrderProgress(int status, Collection list); +} diff --git a/chushang-modules/chushang-module-inspection/inspection-service/src/main/java/com/chushang/inspection/work/service/impl/WrkIcbcJsServiceImpl.java b/chushang-modules/chushang-module-inspection/inspection-service/src/main/java/com/chushang/inspection/work/service/impl/WrkIcbcJsServiceImpl.java index 65f7653..d50515b 100644 --- a/chushang-modules/chushang-module-inspection/inspection-service/src/main/java/com/chushang/inspection/work/service/impl/WrkIcbcJsServiceImpl.java +++ b/chushang-modules/chushang-module-inspection/inspection-service/src/main/java/com/chushang/inspection/work/service/impl/WrkIcbcJsServiceImpl.java @@ -1,25 +1,90 @@ package com.chushang.inspection.work.service.impl; +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.ListUtil; +import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson2.JSONObject; +import com.chushang.common.core.constant.SecurityConstants; +import com.chushang.common.core.exception.utils.AssertUtil; +import com.chushang.common.core.web.Result; import com.chushang.common.mybatis.utils.PageResult; +import com.chushang.inspection.project.po.PollingTask; +import com.chushang.inspection.project.service.PollingTaskService; +import com.chushang.inspection.terminal.po.Store; +import com.chushang.inspection.terminal.po.Terminal; +import com.chushang.inspection.terminal.po.TerminalIns; +import com.chushang.inspection.terminal.service.StoreService; +import com.chushang.inspection.terminal.service.TerminalService; +import com.chushang.inspection.utils.PoolUtils; +import com.chushang.inspection.utils.TaskConfigUtils; import com.chushang.inspection.work.dto.BankDispatchQuery; +import com.chushang.inspection.work.dto.DispatchDTO; import com.chushang.inspection.work.dto.WrkIcbcJsReceive; +import com.chushang.inspection.work.enums.BankBranchesEnum; +import com.chushang.inspection.work.enums.WorkTypeOperation; +import com.chushang.inspection.work.po.WrkInfo; +import com.chushang.inspection.work.service.WrkScheduleService; import com.chushang.inspection.work.service.WrkIcbcJsService; +import com.chushang.inspection.work.service.WrkInfoService; import com.chushang.inspection.work.vo.BankDispatchDTO; +import com.chushang.security.entity.po.SysUser; +import com.chushang.system.feign.RemoteUserService; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.chushang.inspection.work.mapper.WrkIcbcJsMapper; import com.chushang.inspection.work.po.WrkIcbcJs; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.util.Map; +import java.util.Set; /** * @auther: zhao * @date: 2024/6/28 15:38 */ +@Slf4j @Service public class WrkIcbcJsServiceImpl extends ServiceImpl implements WrkIcbcJsService { - @Override - public void receive(WrkIcbcJsReceive dto) { + @Resource + StoreService storeService; + @Resource + TerminalService terminalService; + @Resource + PollingTaskService taskService; + @Resource + RemoteUserService remoteUserService; + @Resource + WrkInfoService wrkInfoService; + @Resource + WrkScheduleService scheduleService; + + @Override + @Transactional + public void receive(WrkIcbcJsReceive dto) { + Store store = storeService.save(dto); + JSONObject terJson = terminalService.save(store, dto); + WrkIcbcJs wrkIcbcJs = save(dto, terJson, store); + // 派单 + PoolUtils.SENTINEL.getInstance().execute(()->{ + dispatchOrder(wrkIcbcJs, terJson, store, null); + }); + } + + private WrkIcbcJs save(WrkIcbcJsReceive dto, JSONObject terJson, Store store) { + Terminal terminal = terJson.getObject("terminal", Terminal.class); + // 江苏工行实体类信息 + WrkIcbcJs wrkIcbcJs = BeanUtil.copyProperties(dto, WrkIcbcJs.class); + wrkIcbcJs.setStatus(1); + wrkIcbcJs.setStoreId(store.getStoreId()); + wrkIcbcJs.setTerminalId(terminal.getTerminalId()); + wrkIcbcJs.setIsBank((byte) '1'); + save(wrkIcbcJs); + return wrkIcbcJs; } @Override @@ -42,6 +107,62 @@ public class WrkIcbcJsServiceImpl extends ServiceImpl> result = remoteUserService.getIdByNicknames(Set.of(), SecurityConstants.INNER); + AssertUtil.invalidate(!result.isSuccess(), "获取业务员信息失败"); + wrkInfo = dispatchWrkInfo(dispatch, result.getData().get(task.getContact()), task.getContact(), WorkTypeOperation.valueOfCode(icbcJs.getOrderType())); + } else { + Result result = remoteUserService.getInfoById(userId, SecurityConstants.INNER); + AssertUtil.invalidate(!result.isSuccess(), "获取业务员信息失败"); + wrkInfo = dispatchWrkInfo(dispatch, userId, result.getData().getNickName(), WorkTypeOperation.valueOfCode(icbcJs.getOrderType())); + } + // 派单 + Long wrkId = wrkInfoService.dispatch(wrkInfo, store, terminal, terminalIns); + if (!TaskConfigUtils.isRepeat(dispatch.getTaskId())) { + // 修改 终端占用 + terminalService.updateOccupy(ListUtil.toList(terminal.getTerminalId()), 1); + } + // 修改派单进度 + scheduleService.updateWorkOrderProgress(6, ListUtil.toList(wrkId)); + WrkIcbcJs wrkIcbcJs = new WrkIcbcJs(); + wrkIcbcJs.setId(entity.getId()); + wrkIcbcJs.setWrkId(wrkId); + wrkIcbcJs.setStatus(2); + // 修改 银行派单状态 + updateById(wrkIcbcJs); + } + + private void dispatchWrkTerminal(DispatchDTO dispatch) { + + } + + private void dispatchWrkStore(DispatchDTO dispatch) { + + } + + private WrkInfo dispatchWrkInfo(DispatchDTO dispatch, Long userId, String userName, Integer workType) { + WrkInfo wrkInfo = BeanUtil.copyProperties(dispatch, WrkInfo.class); + wrkInfo.setUserId(userId); + wrkInfo.setWorkNo(IdUtil.getSnowflake().nextId()); + wrkInfo.setUserName(userName); + wrkInfo.setWrkStatus(1); + wrkInfo.setWorkType(workType); + wrkInfo.setWorkSource(3); + return wrkInfo; + } + @Override public void manualPush(Long id) { diff --git a/chushang-modules/chushang-module-inspection/inspection-service/src/main/java/com/chushang/inspection/work/service/impl/WrkInfoServiceImpl.java b/chushang-modules/chushang-module-inspection/inspection-service/src/main/java/com/chushang/inspection/work/service/impl/WrkInfoServiceImpl.java index 0733081..c57195a 100644 --- a/chushang-modules/chushang-module-inspection/inspection-service/src/main/java/com/chushang/inspection/work/service/impl/WrkInfoServiceImpl.java +++ b/chushang-modules/chushang-module-inspection/inspection-service/src/main/java/com/chushang/inspection/work/service/impl/WrkInfoServiceImpl.java @@ -463,6 +463,28 @@ public class WrkInfoServiceImpl extends ServiceImpl impl + @Override + @Transactional + public Long dispatch(WrkInfo wrkInfo, Store store, Terminal terminal, TerminalIns terminalIns) { + // 工单信息 + save(wrkInfo); + //终端信息 + WrkInfoTerminalRecord wrkInfoTerminalRecord = BeanUtil.copyProperties(terminal, WrkInfoTerminalRecord.class); + wrkInfoTerminalRecord.setWrkId(wrkInfo.getWrkId()); + wrkInfoTerminalRecordService.save(wrkInfoTerminalRecord); + // 终端巡检信息 + WrkInfoTerminalInsRecord wrkInfoTerminalInsRecord = BeanUtil.copyProperties(terminalIns, WrkInfoTerminalInsRecord.class); + wrkInfoTerminalInsRecord.setWrkId(wrkInfo.getWrkId()); + wrkInfoTerminalInsRecordService.save(wrkInfoTerminalInsRecord); + // 商户信息 + WrkInfoStoreRecord wrkInfoStoreRecord = BeanUtil.copyProperties(store, WrkInfoStoreRecord.class); + wrkInfoStoreRecord.setWrkId(wrkInfo.getWrkId()); + wrkInfoStoreRecord.setDeptId(wrkInfo.getDeptId()); + wrkInfoStoreRecord.setStoreId(store.getStoreId()); + wrkInfoStoreRecordService.save(wrkInfoStoreRecord); + return wrkInfo.getWrkId(); + } + /** * 计算经纬度 偏差 */ diff --git a/chushang-modules/chushang-module-inspection/inspection-service/src/main/java/com/chushang/inspection/work/service/impl/WrkScheduleServiceImpl.java b/chushang-modules/chushang-module-inspection/inspection-service/src/main/java/com/chushang/inspection/work/service/impl/WrkScheduleServiceImpl.java new file mode 100644 index 0000000..0656eda --- /dev/null +++ b/chushang-modules/chushang-module-inspection/inspection-service/src/main/java/com/chushang/inspection/work/service/impl/WrkScheduleServiceImpl.java @@ -0,0 +1,15 @@ +package com.chushang.inspection.work.service.impl; + +import com.chushang.inspection.work.service.WrkScheduleService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import java.util.Collection; + +@Slf4j +@Service +public class WrkScheduleServiceImpl implements WrkScheduleService { + public void updateWorkOrderProgress(int status, Collection list){ + + } +} diff --git a/chushang-modules/chushang-module-inspection/inspection-service/src/test/java/MybatisInsertFillTest.java b/chushang-modules/chushang-module-inspection/inspection-service/src/test/java/MybatisInsertFillTest.java new file mode 100644 index 0000000..dcb8b4c --- /dev/null +++ b/chushang-modules/chushang-module-inspection/inspection-service/src/test/java/MybatisInsertFillTest.java @@ -0,0 +1,28 @@ +import com.chushang.InspectionApplication; +import com.chushang.inspection.work.dto.WrkIcbcJsReceive; +import com.chushang.inspection.work.service.WrkIcbcJsService; +import lombok.extern.slf4j.Slf4j; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +import javax.annotation.Resource; + +@Slf4j +@RunWith(SpringRunner.class) +@SpringBootTest(classes = InspectionApplication.class) +public class MybatisInsertFillTest { + + @Resource + WrkIcbcJsService wrkIcbcJsService; + + @Test + public void save(){ + WrkIcbcJsReceive wrkIcbcJsReceive = new WrkIcbcJsReceive(); + wrkIcbcJsReceive.setMerId("merId"); + + wrkIcbcJsService.receive(wrkIcbcJsReceive); + } + +}