1. 江苏工行相关代码

This commit is contained in:
ant 2024-07-24 11:03:43 +08:00
parent ef662ba7cc
commit bef28bb083
7 changed files with 229 additions and 59 deletions

View File

@ -13,6 +13,13 @@ import java.time.LocalDate;
import java.time.LocalTime;
import java.util.Date;
import com.chushang.inspection.terminal.enums.MerTypeOperation;
import com.chushang.inspection.work.enums.TerminalTypeOperation;
import com.chushang.inspection.work.enums.WorkTypeOperation;
import com.chushang.inspection.work.vo.WrkInfoDetailsVO;
import com.chushang.inspection.work.vo.WrkInfoStoreVO;
import com.chushang.inspection.work.vo.WrkInfoTerminalVO;
import com.chushang.inspection.work.vo.WrkInfoVO;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
@ -86,7 +93,7 @@ public class WrkIcbcJs implements Serializable {
* 工单创建日期yyyyMMdd
*/
@TableField(value = "start_date")
private Date startDate;
private LocalDate startDate;
/**
* 工单编号
@ -214,4 +221,57 @@ public class WrkIcbcJs implements Serializable {
@TableField(value = "is_bank")
private Byte isBank;
public WrkIcbcJs save(WrkInfoDetailsVO infoDetail, String area) {
WrkInfoStoreVO infoStore = infoDetail.getInfoStore();
WrkInfoVO wrkInfo = infoDetail.getWrkInfo();
WrkInfoTerminalVO infoTerminal = infoDetail.getInfoTerminal();
this.agentId = "000004";
this.transCode = "1020";
this.storeId = infoStore.getStoreId();
this.merId = infoStore.getStoreNo();
this.merName = infoStore.getStoreName();
this.linkName = infoStore.getStoreContact();
this.merType = MerTypeOperation.valueOfMerType(infoStore.getStoreType());
this.contactWay = infoStore.getStorePhone();
this.merAddress = infoStore.getStoreAddress();
this.terminalId = infoTerminal.getTerminalId();
this.termId = infoTerminal.getTerminalNo();
this.deviceNo = infoTerminal.getTerminalNo();
this.wrkId = wrkInfo.getWrkId();
this.startDate = wrkInfo.getCreateTime().toLocalDate();
this.orderNo = wrkInfo.getWorkNo();
this.reqDate = wrkInfo.getCreateTime().toLocalDate();
this.reqTime = wrkInfo.getCreateTime().toLocalTime();
this.orderType = WorkTypeOperation.valueOfWorkType(wrkInfo.getWorkType());
this.compDate = wrkInfo.getDisposeTime().toLocalDate();
this.compTime = wrkInfo.getDisposeTime().toLocalTime();
this.orderStatus = "1";
this.area = area;
this.deviceType = TerminalTypeOperation.valueOfTerminalType(infoTerminal.getTerminalType());
return this;
}
public WrkIcbcJs push(WrkInfoDetailsVO infoDetail) {
this.agentId = "000004";
this.transCode = "1020";
this.startDate = LocalDate.now();
WrkInfoVO wrkInfo = infoDetail.getWrkInfo();
WrkInfoStoreVO infoStore = infoDetail.getInfoStore();
WrkInfoTerminalVO infoTerminal = infoDetail.getInfoTerminal();
this.merName = infoStore.getStoreName();
this.linkName = infoStore.getStoreContact();
this.merType = MerTypeOperation.valueOfMerType(infoStore.getStoreType());
this.contactWay = infoStore.getStorePhone();
this.merAddress = infoStore.getStoreAddress();
this.compDate = wrkInfo.getDisposeTime().toLocalDate();
this.compTime = wrkInfo.getDisposeTime().toLocalTime();
this.deviceNo = infoTerminal.getTerminalNo();
this.orderStatus = "1";
this.status = 3;
return this;
}
}

View File

@ -54,7 +54,7 @@ public class WrkInfoVO implements Serializable {
/**
* 工单编号
*/
private Long workNo;
private String workNo;
/**
* 工单类型
*/

View File

@ -60,7 +60,7 @@ public class DefaultGeneratedIns implements GeneratedIns{
});
}
// 此时取远程模板
String fileName = generateAFileName(basePath, infoStore.getStoreNo(), wrkInfo.getLowerTaskName(), infoStore.getStoreName(), wrkInfo.getWorkNo() + "");
String fileName = generateAFileName(basePath, infoStore.getStoreNo(), wrkInfo.getLowerTaskName(), infoStore.getStoreName(), wrkInfo.getWorkNo());
if (null != insConfig){
String templateFid = insConfig.getTemplateFid();
// 巡检单相关 数据

View File

@ -1,12 +0,0 @@
package com.chushang.inspection.work.controller;
import org.springframework.web.bind.annotation.*;
/**
* 工单商户信息(wrk_info_store_record)表控制层
*
* @author xxxxx
*/
@RestController
@RequestMapping("/wrk_info_store_record")
public class WrkInfoStoreRecordController {
}

View File

@ -6,6 +6,7 @@ import com.chushang.inspection.work.dto.WrkIcbcJsReceive;
import com.chushang.inspection.work.po.WrkIcbcJs;
import com.baomidou.mybatisplus.extension.service.IService;
import com.chushang.inspection.work.vo.BankDispatchDTO;
import com.chushang.inspection.work.vo.WrkInfoDetailsVO;
/**
* @auther: zhao
@ -23,4 +24,6 @@ public interface WrkIcbcJsService extends IService<WrkIcbcJs> {
void dispatchOrder(WrkIcbcJs entity, Long userId);
void manualPush(Long id);
void push(WrkInfoDetailsVO infoDetail);
}

View File

@ -13,6 +13,7 @@ import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.chushang.common.core.constant.SecurityConstants;
import com.chushang.common.core.exception.utils.AssertUtil;
@ -43,6 +44,8 @@ import com.chushang.inspection.work.service.WrkInfoDispatchService;
import com.chushang.inspection.work.service.WrkIcbcJsService;
import com.chushang.inspection.work.service.WrkInfoService;
import com.chushang.inspection.work.vo.BankDispatchDTO;
import com.chushang.inspection.work.vo.WrkInfoDetailsVO;
import com.chushang.inspection.work.vo.WrkInfoVO;
import com.chushang.security.entity.po.SysUser;
import com.chushang.system.feign.RemoteUserService;
import lombok.extern.slf4j.Slf4j;
@ -54,6 +57,7 @@ import com.chushang.inspection.work.po.WrkIcbcJs;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -210,6 +214,44 @@ public class WrkIcbcJsServiceImpl extends ServiceImpl<WrkIcbcJsMapper, WrkIcbcJs
}
}
@Override
public void push(WrkInfoDetailsVO infoDetail) {
WrkInfoVO wrkInfo = infoDetail.getWrkInfo();
WrkIcbcJs entity = getOne(new LambdaQueryWrapper<WrkIcbcJs>()
.eq(WrkIcbcJs::getWrkId, wrkInfo.getWrkId())
.last(" LIMIT 1")
);
if (entity == null) {
String area = BankBranchesEnum.getByLowerTaskId(wrkInfo.getLowerTaskId());
if (area == null && wrkInfo.getLowerTaskId() != 0) {
PollingTask task = taskService.getById(wrkInfo.getLowerTaskId());
if (task != null) {
List<String> split = StrUtil.split(task.getSearchNum(), "-");
if (split.size() > 2) {
PollingTask pollingTask = taskService.getOne(new LambdaQueryWrapper<PollingTask>()
.select(PollingTask::getId)
.eq(PollingTask::getSearchNum, split.get(0) + "-" + split.get(1) + "-"));
area = BankBranchesEnum.getByLowerTaskId(pollingTask.getId());
}
}
}
entity = new WrkIcbcJs().save(infoDetail, area);
save(entity);
} else {
entity = entity.push(infoDetail);
}
com.chushang.inspection.work.vo.Result result = sendHttp(BeanCopyUtils.copy(entity, WrkIcbcJsPush.class));
if (result != null && result.getRespCode().equals("00")) {
entity.setStatus(3);
updateById(entity);
} else {
entity.setStatus(4);
String msg = result != null ? result.getRespMssg() : "推送江苏工行数据失败";
entity.setRespMssg(msg);
updateById(entity);
}
}
private com.chushang.inspection.work.vo.Result sendHttp(WrkIcbcJsPush wrkIcbcJsPush) {
HttpRequest request = HttpRequest.post(url);
String parse = JSONObject.toJSONString(wrkIcbcJsPush);

View File

@ -8,7 +8,6 @@ import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
@ -21,6 +20,7 @@ import com.chushang.common.core.exception.ResultException;
import com.chushang.common.core.exception.utils.AssertUtil;
import com.chushang.common.core.util.DateUtils;
import com.chushang.common.core.util.IPUtils;
import com.chushang.common.core.util.SpringUtils;
import com.chushang.common.core.web.Result;
import com.chushang.common.dict.utils.DictUtils;
import com.chushang.common.excel.utils.ExcelUtils;
@ -41,10 +41,12 @@ 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.FiveStoreVO;
import com.chushang.inspection.utils.PoolUtils;
import com.chushang.inspection.utils.StreamUtils;
import com.chushang.inspection.utils.TaskConfigUtils;
import com.chushang.inspection.work.dto.DispatchDTO;
import com.chushang.inspection.work.dto.WrkInfoDTO;
import com.chushang.inspection.work.enums.WorkTypeOperation;
import com.chushang.inspection.work.po.*;
import com.chushang.inspection.work.query.DispatchQuery;
import com.chushang.inspection.work.query.ReviewedQuery;
@ -53,7 +55,6 @@ import com.chushang.inspection.work.query.WrkInfoQuery;
import com.chushang.inspection.work.service.*;
import com.chushang.inspection.work.vo.*;
import com.chushang.security.utils.SecurityUtils;
import com.chushang.system.entity.po.SysDictType;
import com.chushang.task.entity.dto.CreateTaskDTO;
import com.chushang.task.enums.ServiceEnum;
import com.chushang.task.enums.TaskTypeEnum;
@ -268,10 +269,9 @@ public class WrkInfoServiceImpl extends ServiceImpl<WrkInfoMapper, WrkInfo> impl
tempStorageTerminalInsRecord.setWrkId(wrkInfo.getWrkId());
LocalDateTime now = LocalDateTime.now();
// 工单状态比较 -- 7应该是暂存
if (info.getWrkStatus() != 7) {
if (info.getWrkStatus() != 9) {
tempStorageWrkInfo.setWrkStatus(info.getWrkStatus());
tempStorageWrkInfo.setDisposeTime(now);
// // 修改 工单信息
// updateById(tempStorageWrkInfo);
// // 修改 商户信息
@ -318,11 +318,11 @@ public class WrkInfoServiceImpl extends ServiceImpl<WrkInfoMapper, WrkInfo> impl
Integer timesPass = terminalIns.getTimesPass();
terminalIns.setTimesPass(timesPass == null ? 1 : timesPass + 1);
// 修改 终端的状态
getMerState(info, terminal, store);
getMerState(info.getTerminalStatus(), info.getStoreStatus(), info.getWorkType(), info.getServiceResult(), terminal, store);
tempStorageStore.setState(store.getState());
tempStorageTerminalInsRecord.setTimesPass(timesPass);
tempStorageTerminalInsRecord.setInspectionStatus(1);
tempStorageTerminalInsRecord.setTimesPass(terminalIns.getTimesPass());
tempStorageTerminalInsRecord.setInspectionStatus(terminal.getTerminalStatus());
tempStorageTerminalInsRecord.setInspectionTime(now);
// 这块 可能为新增商户以及终端信息
@ -398,50 +398,52 @@ public class WrkInfoServiceImpl extends ServiceImpl<WrkInfoMapper, WrkInfo> impl
// 审核方式
Integer reviewMethod = TaskConfigUtils.reviewMethod(wrkInfo.getTaskId());
// 工单状态(记录表使用) 1. 已分配 2. 审核中 3. 初审通过-待复审 4. 复审通过 5. 初审驳回 6. 复审驳回 7. 初审通过 8. 默认审核通过
Integer wrkStatus = 0;
// 当前 任务审核方式为 无需审核
AssertUtil.invalidate(1 == reviewMethod, "当前工单所属任务为无需审核");
Integer curStatus = wrkInfo.getWrkStatus();
WrkInfo auditInfo = new WrkInfo();
auditInfo.setWrkId(audit.getWrkId());
// 初审
if (2 == reviewMethod) {
// 审核通过
if (1 == auditStatus) {
wrkStatus = 7;
// 不为
AssertUtil.invalidate(2 != curStatus && 3 != curStatus, "当前工单状态不属于待审核状态");
// 说明在审核中
if (2 == curStatus)
{
// 只需要初审
if (2 == reviewMethod) {
// 通过或者驳回
auditInfo.setWrkStatus(1 == auditStatus ? 7 : 5);
}
// 审核驳回
else {
wrkStatus = 5;
// 需要复
else if (3 == reviewMethod){
auditInfo.setWrkStatus(1 == auditStatus ? 3 : 5);
}
}
// 需复审
else if (3 == reviewMethod) {
// 不为待审核中时, 即为 3, 待复审 && 需要复审
else if (3 == reviewMethod)
{
// 获取上一个审核
List<WrkInfoAudit> list = infoAuditService.list(new LambdaQueryWrapper<WrkInfoAudit>()
.eq(WrkInfoAudit::getWrkId, audit.getWrkId())
.eq(WrkInfoAudit::getAuditState, 7)
// 此处需要的 初审通过-待复审 的记录信息
.eq(WrkInfoAudit::getAuditState, 3)
.eq(WrkInfoAudit::getIsRecord, 0)
);
AssertUtil.invalidate(CollectionUtil.isEmpty(list), "待复审工单, 未找寻到初审信息");
for (WrkInfoAudit wrkInfoAudit : list) {
AssertUtil.invalidate(wrkInfoAudit.getUserId().equals(SecurityUtils.getUserId()), "两次审核通过不能为同一人");
}
// 审核通过
if (1 == auditStatus) {
wrkStatus = 4;
}
// 审核驳回
else {
wrkStatus = 6;
}
auditInfo.setWrkStatus(1 == auditStatus ? 4 : 6);
}
auditInfo.setWrkStatus(wrkStatus);
updateById(auditInfo);
// todo 处理工单信息
// infoService.updateStateById(audit.getId(), audit.getState());
// 处理工单信息
updateStateById(auditInfo);
// 审核记录
saveAndUpdateAudit(audit, auditInfo.getWrkStatus());
}
/**
* 新增一条审核记录
*/
private void saveAndUpdateAudit(AuditDTO audit, int wrkStatus){
// 新增一条审核工单记录
WrkInfoAudit infoAudit = new WrkInfoAudit();
infoAudit.setIsRecord(1);
@ -464,8 +466,79 @@ public class WrkInfoServiceImpl extends ServiceImpl<WrkInfoMapper, WrkInfo> impl
infoAuditService.save(infoAudit);
}
private void updateStateById(Long wrkId, Integer wrkStatus) {
private void updateStateById(WrkInfo auditWrkInfo) {
// 3,7 代表初审通过 4, 代表复审通过
Integer wrkStatus = auditWrkInfo.getWrkStatus();
// 修改 工单的审核状态
updateById(auditWrkInfo);
// 解除 终端占用, 因为审核通过了
if (4 == wrkStatus || 7 == wrkStatus){
// 工单, 商户, 终端信息
WrkInfoDetailsVO infoDetail = baseMapper.getWrkInfoDetails(auditWrkInfo.getWrkId());
// 工单
WrkInfoVO wrkInfo = infoDetail.getWrkInfo();
// 终端
WrkInfoTerminalVO infoTerminal = infoDetail.getInfoTerminal();
// 商户
WrkInfoStoreVO infoStore = infoDetail.getInfoStore();
// 终端巡检
WrkInfoTerminalInsVO infoTerminalIns = infoDetail.getInfoTerminalIns();
LocalDateTime now = LocalDateTime.now();
// 此处应当修改 商户记录表
// // 1. 修改工单
Assert.notNull(wrkInfo, "请确认此工单是否存在");
Store store = BeanUtil.copyProperties(infoStore, Store.class);
store.setStoreId(infoStore.getStoreId());
Terminal terminal = BeanUtil.copyProperties(infoTerminal, Terminal.class);
Long terminalId = infoTerminal.getTerminalId();
// 拷贝复制 一些 提交的终端信息
terminal.setTerminalId(terminalId);
// 解除终端占用
terminal.setOccupy(0);
// 设置终端状态为 已巡检
terminal.setTerminalStatus(1);
TerminalIns terminalIns = BeanUtil.copyProperties(infoTerminalIns, TerminalIns.class);
terminalIns.setTerminalId(terminal.getTerminalId());
terminalIns.setTerminalId(terminalId);
// 设置 巡检时间为当前
terminalIns.setInspectionTime(now);
// 本次巡检结果, 取字典表数据
terminalIns.setServiceResult(wrkInfo.getServiceResult());
// 设置 审核通过次数 + 1
Integer timesPass = terminalIns.getTimesPass();
terminalIns.setTimesPass(timesPass == null ? 1 : timesPass + 1);
// 修改 终端的状态
getMerState(infoTerminal.getTerminalStatus(),
infoStore.getStoreStatus(),
wrkInfo.getWorkType(),
wrkInfo.getServiceResult(),
terminal, store);
store.setState(store.getState());
terminalIns.setInspectionStatus(1);
// 更新对应的终端以及商户信息
// 这块 可能为新增商户以及终端信息
// 更新商户 信息, 同时 也需要更新
// 更新商户状态
storeService.saveOrUpdate(store);
// 更新终端状态
terminalService.saveOrUpdate(terminal);
// 更新终端巡检时间以及审核通过次数等
terminalInsService.saveOrUpdate(terminalIns);
// 还需要 更改 记录表对应的数据.
if (enable){
// 江苏工行的数据推送
PoolUtils.SENTINEL.getInstance().execute(()->{
// 只有江苏工行的才进行推送
if (wrkInfo.getTaskId().equals(1701151817643495425L) && WorkTypeOperation.workTypes().contains(wrkInfo.getWorkType())){
SpringUtils.getBean(WrkIcbcJsService.class).push(infoDetail);
}
});
}
}
// 需要同步修改 商户信息 以及 终端信息
}
@ -521,7 +594,11 @@ public class WrkInfoServiceImpl extends ServiceImpl<WrkInfoMapper, WrkInfo> impl
/**
* 获取商户状态
*/
private void getMerState(WrkInfoDTO info, Terminal record, Store store) {
private void getMerState(Integer terminalStatus,
Integer storeStatus,
Integer workType,
Integer serviceResult,
Terminal record, Store store) {
// 2023年4月19号修改 市场部
//撤机 两种情况下归属撤机
@ -531,33 +608,33 @@ public class WrkInfoServiceImpl extends ServiceImpl<WrkInfoMapper, WrkInfo> impl
// 审核拒绝之后 撤回 回归原来状态
// 撤机 1 机具状态 选择 银行撤机 2 工单类型选择 撤机
if (DictUtils.getDictLabel("terminal_status", "银行撤机").equals(info.getTerminalStatus() + "") ||
DictUtils.getDictLabel("wrk_type", "撤机").equals(info.getWorkType() + "")) {
if (DictUtils.getDictLabel("terminal_status", "银行撤机").equals(String.valueOf(terminalStatus)) ||
DictUtils.getDictLabel("wrk_type", "撤机").equals(String.valueOf(workType))) {
//设置商户状态为异常
store.setState(Integer.valueOf(Objects.requireNonNull(DictUtils.getDictValue("mer_status", "异常"))));
// 添加备注
// 终端状态
// 终端状态改为 已经撤机, 此处可能会改为 异常
record.setTerminalStatus(Integer.valueOf(DictUtils.getDictLabel("terminal_status", "银行撤机")));
record.setRemark(DictUtils.getDictLabel("terminal_status", info.getTerminalStatus() + ""));
record.setRemark(DictUtils.getDictLabel("terminal_status", String.valueOf(terminalStatus)));
}
// 异常 服务结果 选择 原址无此终端 原址无此商户 机具状态 选择 设备丢失 门店状态 选择 门店不存在
else if (DictUtils.getDictLabel("terminal_status", "设备丢失").equals(info.getTerminalStatus() + "") ||
else if (DictUtils.getDictLabel("terminal_status", "设备丢失").equals(String.valueOf(terminalStatus)) ||
// 门店状态
DictUtils.getDictLabel("store_status", "门店不存在").equals(info.getStoreStatus() + "") ||
DictUtils.getDictLabel("store_status", "门店不存在").equals(String.valueOf(storeStatus)) ||
// service_results 服务结果
List.of(DictUtils.getDictLabel("service_results", "原址无此终端"), DictUtils.getDictLabel("service_results", "原址无此商户"))
.contains(info.getServiceResult() + "")) {
.contains(String.valueOf(serviceResult))) {
// 设置商户状态为异常
//设置商户状态为异常
store.setState(Integer.valueOf(Objects.requireNonNull(DictUtils.getDictValue("mer_status", "异常"))));
record.setRemark(DictUtils.getDictLabel("terminal_status", info.getTerminalStatus() + ""));
record.setRemark(DictUtils.getDictLabel("terminal_status", String.valueOf(terminalStatus)));
} else {
// 商户正常
store.setState(Integer.valueOf(Objects.requireNonNull(DictUtils.getDictValue("mer_status", "正常"))));
// 终端正常
record.setRemark(DictUtils.getDictLabel("terminal_status", info.getTerminalStatus() + ""));
record.setRemark(DictUtils.getDictLabel("terminal_status", String.valueOf(terminalStatus)));
}
}