From 3b16f67e2c2ebc00e5f28b7398346052395a7dcb Mon Sep 17 00:00:00 2001
From: k94314517 <8417338+k94314517@user.noreply.gitee.com>
Date: 星期一, 26 二月 2024 19:03:21 +0800
Subject: [PATCH] ERP接口
---
server/dmvisit_service/src/main/java/com/doumee/service/business/impl/VisitsServiceImpl.java | 158 +++++++++++++++++++++++++++++++++++++---------------
1 files changed, 111 insertions(+), 47 deletions(-)
diff --git a/server/dmvisit_service/src/main/java/com/doumee/service/business/impl/VisitsServiceImpl.java b/server/dmvisit_service/src/main/java/com/doumee/service/business/impl/VisitsServiceImpl.java
index a5f05fa..065884b 100644
--- a/server/dmvisit_service/src/main/java/com/doumee/service/business/impl/VisitsServiceImpl.java
+++ b/server/dmvisit_service/src/main/java/com/doumee/service/business/impl/VisitsServiceImpl.java
@@ -38,6 +38,7 @@
import com.doumee.dao.web.response.VisitDetailVO;
import com.doumee.dao.web.response.VisitRecordVO;
import com.doumee.service.business.ApproveService;
+import com.doumee.service.business.InterfaceLogService;
import com.doumee.service.business.VisitsService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
@@ -84,6 +85,8 @@
private SystemDictDataBiz systemDictDataBiz;
@Autowired
private DeviceJoinMapper deviceJoinMapper;
+ @Autowired
+ private ErpTool erpTool;
@Autowired
private WxPlatNotice wxPlatNotice;
@@ -126,18 +129,20 @@
visits.setMemberId(member.getId());
//鍒濆鍖栬瀹俊鎭�
initVisitInfo(visits,date);
+ visitsMapper.insert(visits);
//鍙戣捣ERP瀹℃壒鐢宠
String erpId = startSendErpCheck(visits,visitMember);
if(StringUtils.isNotBlank(erpId)){
visits.setErpId(erpId);
+ visits.setStatus(Constants.VisitStatus.submitCheck);
+ visitsMapper.updateById(visits);
}else{
-// throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "瀵逛笉璧凤紝鍙戣捣鎷滆瀹℃壒鐢宠澶辫触锛�");
+ throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "瀵逛笉璧凤紝鍙戣捣鎷滆瀹℃壒鐢宠澶辫触锛�");
}
- visitsMapper.insert(visits);
initWithVisitInfo(visits);
updateProblemLog(visits,problemLog,member);
//鍒涘缓瀹℃壒璁板綍
- createApprove(visits,visitMember);
+// createApprove(visits,visitMember);
//鍙戦�佸井淇″叕浼楀彿閫氱煡
wxPlatNotice.sendVisitAuditTemplateNotice(visits,
systemDictDataBiz.queryByCode(Constants.WX_PLATFORM,Constants.WX_PLATFORM_PREFIX).getCode(),
@@ -380,9 +385,9 @@
ApproveParam approveParam = new ApproveParam();
//鍙戦�佸鎵�/鎶勯�佽褰曠殑鐢ㄦ埛涓婚敭闆嗗悎
ids.clear();
- if(Objects.isNull(allParam)){
+ if(!CollectionUtils.isNotEmpty(allParam)){
if(Objects.isNull(level)){
- throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鏈厤缃瀹㈣褰曞鎵规祦锛岃鑱旂郴绠$悊鍛�");
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鏈厤缃瀹㈠鎵规祦锛岃鑱旂郴绠$悊鍛�");
}
}else{
approveParam = allParam.get(0);
@@ -471,7 +476,7 @@
private void isValidBaseParam(Visits visits) {
if(visits.getEndtime() == null
|| visits.getStarttime() == null
- || StringUtils.isBlank(visits.getReason())
+// || StringUtils.isBlank(visits.getReason())
|| StringUtils.isBlank( visits.getName())
|| StringUtils.isBlank( visits.getPhone())
|| visits.getIdcardType() == null
@@ -480,9 +485,9 @@
|| visits.getReceptMemberId() == null){
throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝淇℃伅濉啓涓嶆纭紒");
}
- if(visits.getStarttime().getTime() < System.currentTimeMillis()){
- throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝棰勭害寮�濮嬫椂闂村繀椤诲ぇ浜庡綋鍓嶆椂闂达紒");//
- }
+// if(visits.getStarttime().getTime() < System.currentTimeMillis()){
+// throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝棰勭害寮�濮嬫椂闂村繀椤诲ぇ浜庡綋鍓嶆椂闂达紒");//
+// }
if(visits.getEndtime().getTime() <= visits.getStarttime().getTime()){
throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝棰勭害缁撴潫鏃堕棿蹇呴』澶т簬寮�濮嬫椂闂达紒");//
}
@@ -528,6 +533,7 @@
private void initWithVisitInfo(Visits visits) {
if(CollectionUtils.isNotEmpty(visits.getWithUserList())){
for(Visits v :visits.getWithUserList()){
+ v.setBirthday(Constants.getBirthdyByCardNo(v.getIdcardNo()));
v.setParentId(visits.getId());
v.setStarttime(visits.getStarttime());
v.setEndtime(visits.getEndtime());
@@ -537,8 +543,12 @@
v.setIdcardDecode(Constants.getTuominStr(v.getIdcardNo()));//鑴辨晱韬唤璇佸彿
v.setIdcardNo(DESUtil.encrypt(Constants.EDS_PWD, v.getIdcardNo()));//韬唤璇佸彿鍔犲瘑
v.setErpId(visits.getErpId());
+ v.setReceptMemberId(visits.getReceptMemberId());
+ v.setMemberNum(Constants.ZERO);
v.setHkStatus(Constants.ZERO);
- v.setStatus(Constants.ZERO);
+ v.setReason(visits.getReason());
+ v.setDoors(visits.getDoors());
+ v.setStatus(Constants.VisitStatus.submitCheck);
}
//鎵归噺鎻掑叆鏁版嵁
visitsMapper.insertBatchSomeColumn(visits.getWithUserList());
@@ -560,6 +570,15 @@
ApproveAddRequest param = new ApproveAddRequest();
List<Visits> withUserVisitsList = visits.getWithUserList();
List<UserInfoRequest> withUserList = new ArrayList<>();
+ UserInfoRequest mainUser = new UserInfoRequest();
+ mainUser.setName(visits.getName());
+ mainUser.setIdNo(DESUtil.decrypt(Constants.EDS_PWD, visits.getIdcardNo()));
+ mainUser.setSex(visits.getSex());
+ mainUser.setPhone(visits.getPhone());
+ mainUser.setFaceImg(visits.getFaceImg());
+ mainUser.setHealthImg(visits.getImgurl());
+ withUserList.add(mainUser);
+
if(CollectionUtils.isNotEmpty(withUserVisitsList)){
for (Visits v:withUserVisitsList) {
UserInfoRequest userInfoRequest = new UserInfoRequest();
@@ -571,14 +590,16 @@
userInfoRequest.setHealthImg(v.getImgurl());
withUserList.add(userInfoRequest);
}
- param.setWithUserList(withUserList);
}
+ param.setWithUserList(withUserList);
+
param.setId(visits.getId());
param.setBeVisitedUserId(visitMember.getErpId());
param.setVisitorWorkUint(visits.getCompanyName());
param.setPurpose(visits.getReason());
- param.setStartTime(DateUtil.getDate(visits.getStarttime(),"yyyy-MM-dd HH:mm:ss"));
- param.setEndTime(DateUtil.getDate(visits.getEndtime(),"yyyy-MM-dd HH:mm:ss"));
+ param.setStartTime(DateUtil.DateToStr(visits.getStarttime(),"yyyy-MM-dd HH:mm:ss"));
+ param.setEndTime(DateUtil.DateToStr(visits.getEndtime(),"yyyy-MM-dd HH:mm:ss"));
+ param.setBeVisitedOrgId(visitMember.getErpOrgId());
if(StringUtils.isNotBlank(visits.getCarNos())){
param.setCarNo(Arrays.asList(visits.getCarNos().split(",")));
}
@@ -589,12 +610,15 @@
param.setRoleNames(deviceRoleList.stream().map(m->m.getName()).collect(Collectors.toList()));
}
}
- ApproveInfoResponse response = ErpTool.submitApprove(ErpConstants.approveUrl,param);
+ ApproveInfoResponse response = erpTool.submitApprove(ErpConstants.approveUrl,param);
if(!Objects.isNull(response)){
- return response.getId().toString();
+ return visits.getId().toString();
}
+
return null;
}
+
+
private String visitAppiontment(Visits visits) {
VisitAppointmentRequest param = new VisitAppointmentRequest();
@@ -634,31 +658,40 @@
//闅忚浜哄憳淇℃伅澶勭悊
if(visits.getWithUserList()!= null && visits.getWithUserList().size()>0){
for(Visits model:visits.getWithUserList()){
+ model.setBirthday(Constants.getBirthdyByCardNo(model.getIdcardNo()));
model.setStarttime(visits.getStarttime());
model.setEndtime(visits.getEndtime());
//鏍¢獙闅忚浜哄憳濉姤鏁版嵁鍚堟硶鎬�
isValidWithVisitParam(model,addList,editList);
model.setCreateDate(visits.getCreateDate());
- getMemberListParam(model.getIdcardNo(),model,addList,editList);
+ Member visitsMember = getMemberListParam(model.getIdcardNo(),model,addList,editList);
+ model.setMemberId(visitsMember.getId());
}
}
- if(CollectionUtils.isNotEmpty(addList)){
- memberMapper.insertBatchSomeColumn(addList);
- }
- if(CollectionUtils.isNotEmpty(editList)){
- editList.forEach(i->{
- memberMapper.updateById(i);
- });
-
- }
+// if(CollectionUtils.isNotEmpty(addList)){
+// memberMapper.insertBatchSomeColumn(addList);
+// }
+// if(CollectionUtils.isNotEmpty(editList)){
+// editList.forEach(i->{
+// memberMapper.updateById(i);
+// });
+//
+// }
return m;
}
private Member getMemberListParam(String cardno, Visits visits, List<Member> addList, List<Member> editList) {
- if(StringUtils.isNotBlank(visits.getCarNos())&&!Constants.checkCarNo(visits.getCarNos())){
- throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝杞︾墝鍙枫��"+visits.getCarNos()+"銆戜笉鍚堟硶锛岃鏍稿疄鍚庨噸璇晘");
+// if(!StringUtils.isNotBlank(visits.getCarNos())
+//// &&!Constants.checkCarNo(visits.getCarNos())
+// ){
+// throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝杞︾墝鍙枫��"+visits.getCarNos()+"銆戜笉鍚堟硶锛岃鏍稿疄鍚庨噸璇晘");
+// }
+ if(Constants.equalsInteger(Constants.ZERO, visits.getIdcardType())&&cardno.length()!=18
+ //&&!IdcardUtil.isValidCard(cardno)
+ ){
+ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝韬唤璇佸彿鐮佹湁璇紝璇锋牳瀹炲悗閲嶈瘯锛�");
}
Member member = memberMapper.selectOne(new QueryWrapper<Member>().lambda()
.eq(Member::getType,Constants.memberType.visitor)
@@ -671,6 +704,7 @@
member.setCreateDate(visits.getCreateDate());
member.setIsdeleted(Constants.ZERO);
member.setIdcardNo(visits.getIdcardNo());
+ member.setBirthday(Constants.getBirthdyByCardNo(cardno));
member.setIdcardDecode(visits.getIdcardDecode());
member.setIdcardNo(DESUtil.encrypt(Constants.EDS_PWD, cardno));//韬唤璇佸彿鍔犲瘑
member.setIdcardDecode(Constants.getTuominStr(cardno));//鑴辨晱鎵嬫満鍙�
@@ -686,8 +720,10 @@
member.setSex(Constants.getSexByCardNo(cardno));
member.setHkStatus(Constants.ZERO);
member.setErpStatus(Constants.ZERO);
- // 鏂板璁垮璁板綍
- addList.add(member);
+ member.setVisitCompanyName(visits.getCompanyName());
+ memberMapper.insert(member);
+ // 鏂板璁垮
+// addList.add(member);
}else{
if(!Constants.equalsInteger(Constants.ZERO,member.getStatus() )){
//濡傛灉鐢ㄦ埛鐘舵�佸紓甯革紝鍒欐彁绀�
@@ -708,11 +744,14 @@
member.setSex(Constants.getSexByCardNo(cardno));
member.setHkStatus(Constants.ZERO);
member.setErpStatus(Constants.ZERO);
+ member.setVisitCompanyName(visits.getCompanyName());
+ memberMapper.updateById(member);
// 鏇存柊璁垮淇℃伅,
- editList.add(member);
+// editList.add(member);
}
//鏍规嵁鎵嬫満鍙峰拰韬唤璇佸彿鐮佹煡璇� 褰撳墠棰勭害鐨勬椂闂存槸鍚︿笌鍏朵粬棰勭害璁板綍鏈夊啿绐�
if (visitsMapper.selectCount(new QueryWrapper<Visits>().lambda()
+ .notIn(Visits::getStatus,Constants.VisitStatus.cancel,Constants.VisitStatus.cancel,Constants.VisitStatus.noPass,Constants.VisitStatus.xfFail)
.and(ms -> ms.eq(Visits::getPhone, visits.getPhone())
.or().eq(Visits::getIdcardDecode, Constants.getTuominStr(cardno)))
.and(ms -> ms.apply(" visits.STARTTIME <= '" + DateUtil.DateToStr(visits.getStarttime(),"yyyy-MM-dd HH:mm:ss") + "' and visits.ENDTIME >= '" + DateUtil.DateToStr(visits.getStarttime(),"yyyy-MM-dd HH:mm:ss") + "' ")
@@ -891,7 +930,7 @@
queryWrapper.selectAs(Member::getName,Visits::getReceptMemberName);
queryWrapper.selectAs(Company::getName,Visits::getReceptMemberDepartment);
queryWrapper.leftJoin(Member.class,Member::getId,Visits::getReceptMemberId);
- queryWrapper.leftJoin(Company.class,Company::getId,Member::getCompanyId);
+ queryWrapper.leftJoin(Company.class,Company::getErpId,Member::getErpOrgId);
queryWrapper.eq(Visits::getId,id);
Visits result = visitsJoinMapper.selectJoinOne(Visits.class,queryWrapper);
@@ -899,10 +938,10 @@
if(result!=null){
if(StringUtils.isNotBlank(result.getDoors())){
String[] doorList=result.getDoors().split(",");
- MPJLambdaWrapper<Device> deviceQuery = new MPJLambdaWrapper<>();
- deviceQuery.in(Device::getId,doorList);
- List<Device> deviceList= deviceJoinMapper.selectList(deviceQuery);
- result.setDeviceList(deviceList);
+ MPJLambdaWrapper<DeviceRole> deviceQuery = new MPJLambdaWrapper<>();
+ deviceQuery.in(DeviceRole::getId,doorList);
+ List<DeviceRole> deviceRoleList= deviceRoleMapper.selectList(deviceQuery);
+ result.setDeviceRoleList(deviceRoleList);
}
}
@@ -939,6 +978,7 @@
MPJLambdaWrapper<Visits> queryWrapper = new MPJLambdaWrapper<>();
queryWrapper.selectAll(Visits.class);
+ queryWrapper.select(" ( select count(distinct(v.CAR_NOS)) from visits v where v.PARENT_ID = t.ID and v.CAR_NOS is not null and v.CAR_NOS != '' and v.CAR_NOS != t.CAR_NOS ) as carNum ");
queryWrapper.selectAs(Member::getName,Visits::getReceptMemberName);
queryWrapper.selectAs(Company::getName,Visits::getReceptMemberDepartment);
queryWrapper.leftJoin(Member.class,Member::getId,Visits::getReceptMemberId);
@@ -954,6 +994,12 @@
queryWrapper.isNull(Visits::getParentId);
queryWrapper.orderByDesc(Visits::getCreateDate);
IPage<Visits> result = visitsJoinMapper.selectJoinPage(page, Visits.class,queryWrapper);
+
+ for (Visits visits:result.getRecords()) {
+ if(StringUtils.isNotBlank(visits.getCarNos())){
+ visits.setCarNum(visits.getCarNum() + Constants.ONE);
+ }
+ }
return PageData.from(result);
}
@@ -966,17 +1012,21 @@
@Override
public PageData<Visits> retentionPage(PageWrap<Visits> pageWrap) {
+ String code= systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.TIMEOUT_WARNING).getCode();
IPage<Visits> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity());
MPJLambdaWrapper<Visits> queryWrapper = new MPJLambdaWrapper<>();
-
queryWrapper.selectAll(Visits.class);
queryWrapper.selectAs(Member::getName,Visits::getReceptMemberName);
- queryWrapper.select("TIMESTAMPDIFF(MINUTE,t.ENDTIME , NOW()) AS timeOut");
+ queryWrapper.select("TIMESTAMPDIFF( MINUTE, NOW(), t.OUT_DATE) AS timeOut");
queryWrapper.selectAs(Member::getType,Visits::getMemberType);
queryWrapper.selectAs(Company::getName,Visits::getReceptMemberDepartment);
queryWrapper.leftJoin(Member.class,Member::getId,Visits::getReceptMemberId);
queryWrapper.leftJoin(Company.class,Company::getId,Member::getCompanyId);
queryWrapper.leftJoin(" member m on m.id=t.MEMBER_ID");
+
+ queryWrapper.eq(Objects.nonNull(pageWrap.getModel().getLevelStatus()),Visits::getStatus,Constants.VisitStatus.signin);
+
+ queryWrapper.apply(Objects.nonNull(pageWrap.getModel().getLevelStatus())," TIMESTAMPDIFF( MINUTE, NOW(), t.OUT_DATE) <= "+code+" ");
queryWrapper.ne("m.type ",Constants.TWO);
queryWrapper.eq(Visits::getIsdeleted,Constants.ZERO);
@@ -986,20 +1036,20 @@
.eq(StringUtils.isNotBlank(pageWrap.getModel().getIdcardNo()),Visits::getIdcardNo,StringUtils.isNotBlank(pageWrap.getModel().getIdcardNo()))
.eq(StringUtils.isNotBlank(pageWrap.getModel().getCompanyName()),Visits::getCompanyName,pageWrap.getModel().getCompanyName())
.eq(Objects.nonNull(pageWrap.getModel().getStatus()),Visits::getStatus,pageWrap.getModel().getStatus());
- queryWrapper.isNull(Visits::getOutDate);
+ queryWrapper.isNull(!Objects.nonNull(pageWrap.getModel().getLevelStatus()),Visits::getOutDate);
queryWrapper.orderByDesc(Visits::getEditDate);
- String code= systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.TIMEOUT_FREEZE).getCode();
IPage<Visits> result = visitsJoinMapper.selectJoinPage(page, Visits.class,queryWrapper);
if(result!=null&&result.getRecords()!=null){
result.getRecords().stream().forEach(s ->{
- if(s.getTimeOut()>=Constants.ZERO){
- s.setOutStatus(Constants.ONE);
- }else if(s.getTimeOut()<=Integer.valueOf(code)&&s.getTimeOut()>0){
- s.setOutStatus(Constants.TWO);
- }else{
- s.setOutStatus(Constants.ZERO);
+ if(s.getStatus().equals(Constants.VisitStatus.signin)){
+ if(s.getTimeOut()<=Integer.valueOf(code)&&s.getTimeOut()>=0){
+ s.setOutStatus(Constants.TWO);
+ }else if(s.getTimeOut()>Constants.ZERO){
+ s.setOutStatus(Constants.ZERO);
+ }else{
+ s.setOutStatus(Constants.ONE);
+ }
}
-
});
}
@@ -1049,7 +1099,7 @@
}
visitDetailVO.setWithVisitsList(
visitsMapper.selectList(new QueryWrapper<Visits>().lambda()
- .select(Visits::getName,Visits::getPhone,Visits::getFaceImg,Visits::getImgurl,Visits::getIdcardDecode)
+ .select(Visits::getName,Visits::getPhone,Visits::getFaceImg,Visits::getImgurl,Visits::getIdcardDecode,Visits::getStatus)
.eq(Visits::getParentId,id)));
return visitDetailVO;
}
@@ -1092,4 +1142,18 @@
+ @Override
+ public void visitLevel(Integer visitId){
+ Visits visits = visitsMapper.selectById(visitId);
+ if(Objects.isNull(visits)){
+ throw new BusinessException(ResponseStatus.DATA_EMPTY);
+ }
+ if(!visits.getStatus().equals(Constants.VisitStatus.signin)){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"璁垮璁板綍鐘舵�侀敊璇紝璇峰埛鏂伴噸璇�");
+ }
+ visitsMapper.update(null,new UpdateWrapper<Visits>().lambda().set(Visits::getStatus,Constants.VisitStatus.signout)
+ .eq(Visits::getId,visitId));
+
+ }
+
}
--
Gitblit v1.9.3