仓储接收租赁装备推送逻辑优化,租赁退租时,查询装备状态以及修改装备状态的接口编写

This commit is contained in:
15856 2024-11-06 18:28:19 +08:00
parent 39ad23571f
commit abf9a77602
16 changed files with 85 additions and 31 deletions

View File

@ -267,4 +267,7 @@ public class MaMachine extends BaseEntity {
@ApiModelProperty(value = "Iot定位设备编号") @ApiModelProperty(value = "Iot定位设备编号")
private String iotCode; private String iotCode;
@ApiModelProperty(value = "推送到租赁标识0未推送 1推送")
private Integer pushStatus;
} }

View File

@ -1,6 +1,7 @@
package com.bonus.sgzb.app.service.impl; package com.bonus.sgzb.app.service.impl;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import com.alibaba.fastjson2.JSONObject;
import com.bonus.sgzb.app.domain.LeaseApplyDetails; import com.bonus.sgzb.app.domain.LeaseApplyDetails;
import com.bonus.sgzb.app.domain.TmTask; import com.bonus.sgzb.app.domain.TmTask;
import com.bonus.sgzb.app.mapper.LeaseApplyDetailsMapper; import com.bonus.sgzb.app.mapper.LeaseApplyDetailsMapper;
@ -11,18 +12,18 @@ import com.bonus.sgzb.base.mapper.MaLabelBindMapper;
import com.bonus.sgzb.base.mapper.MaMachineMapper; import com.bonus.sgzb.base.mapper.MaMachineMapper;
import com.bonus.sgzb.base.vo.MaLabelBindVO; import com.bonus.sgzb.base.vo.MaLabelBindVO;
import com.bonus.sgzb.common.core.constant.Constants; import com.bonus.sgzb.common.core.constant.Constants;
import com.bonus.sgzb.common.core.utils.HttpHelper;
import com.bonus.sgzb.common.core.utils.StringUtils; import com.bonus.sgzb.common.core.utils.StringUtils;
import com.bonus.sgzb.common.core.web.domain.AjaxResult; import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import com.bonus.sgzb.common.security.utils.SecurityUtils; import com.bonus.sgzb.common.security.utils.SecurityUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.*;
import java.util.List;
import java.util.Objects;
/** /**
* Description: 领料出库详情接口实现类 * Description: 领料出库详情接口实现类
@ -45,6 +46,9 @@ public class LeaseOutDetailsServiceImpl implements LeaseOutDetailsService {
@Resource @Resource
private MaLabelBindMapper maLabelBindMapper; private MaLabelBindMapper maLabelBindMapper;
@Value("${sgzb.updateItemStatusUrl}")
private String updateItemStatus;
/** /**
* 根据任务id查询出库数据 * 根据任务id查询出库数据
* *
@ -144,7 +148,7 @@ public class LeaseOutDetailsServiceImpl implements LeaseOutDetailsService {
* @return 结果 * @return 结果
*/ */
@Override @Override
@Transactional @Transactional(rollbackFor = Exception.class)
public AjaxResult submitOut(LeaseOutDetails record) { public AjaxResult submitOut(LeaseOutDetails record) {
int res = 0; int res = 0;
try { try {
@ -241,6 +245,22 @@ public class LeaseOutDetailsServiceImpl implements LeaseOutDetailsService {
} }
// 更新 (ma_machine 设备表)的状态 // 更新 (ma_machine 设备表)的状态
leaseOutDetailsMapper.updateMaMachineStatus(record); leaseOutDetailsMapper.updateMaMachineStatus(record);
//同步租赁商城机具状态
try {
MaMachine maMachine = new MaMachine();
maMachine.setMaId(record.getMaId());
// 15---1在库16---2已出库
maMachine.setMaStatus("2");
String content = JSONObject.toJSONString(maMachine);
Map<String, String> map = new HashMap<>();
map.put("body", content);
String body = JSONObject.toJSONString(map);
String data = HttpHelper.sendHttpPost(updateItemStatus, body);
log.info("dataString-=========:" + data);
} catch (Exception e) {
log.error("同步租赁商城机具状态失败");
throw new RuntimeException("同步租赁商城机具状态失败");
}
} }
} }
return res; return res;

View File

@ -103,8 +103,8 @@ public class MaReceiveController extends BaseController {
@ApiOperation(value = "修改租赁设备状态") @ApiOperation(value = "修改租赁设备状态")
@GetMapping("/updateItemStatus") @GetMapping("/updateItemStatus")
public AjaxResult updateItemStatus(Long itemId) { public AjaxResult updateItemStatus(DataReceiveDetail dataReceiveDetail) {
Integer itemStatus = maReceiveService.updateItemStatus(itemId); Integer itemStatus = maReceiveService.updateItemStatus(dataReceiveDetail);
return success(itemStatus); return success(itemStatus);
} }
} }

View File

@ -56,14 +56,14 @@ public class MaTypeKeeperController extends BaseController {
@ApiOperation(value = "查询库管员信息") @ApiOperation(value = "查询库管员信息")
@PostMapping("/getMaTypeKeeper") @PostMapping("/getMaTypeKeeper")
public AjaxResult getMaTypeKeeper(SysDept sysDept){ public AjaxResult getMaTypeKeeper(@RequestBody String sysDept){
List<MaKeeperUser> maTypeList = maTypeKeeperService.getMaTypeKeeper(sysDept); List<MaKeeperUser> maTypeList = maTypeKeeperService.getMaTypeKeeper(sysDept);
return AjaxResult.success(maTypeList); return AjaxResult.success(maTypeList);
} }
@ApiOperation(value = "查询公司信息") @ApiOperation(value = "查询公司信息")
@PostMapping("/getEnterprise") @PostMapping("/getEnterprise")
public AjaxResult getEnterprise(SysDept sysDept){ public AjaxResult getEnterprise(@RequestBody String sysDept){
SysDept sysDeptRes = maTypeKeeperService.getEnterprise(sysDept); SysDept sysDeptRes = maTypeKeeperService.getEnterprise(sysDept);
return AjaxResult.success(sysDeptRes); return AjaxResult.success(sysDeptRes);
} }

View File

@ -2,6 +2,7 @@ package com.bonus.sgzb.base.mapper;
import com.bonus.sgzb.system.api.domain.SysDept; import com.bonus.sgzb.system.api.domain.SysDept;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
@ -9,5 +10,5 @@ import java.util.List;
public interface DeptMapper { public interface DeptMapper {
public List<SysDept> getDeptList(); public List<SysDept> getDeptList();
SysDept getDeptBySocialCreditCode(SysDept sysDept); SysDept getDeptBySocialCreditCode(@Param("socialCreditCode") String socialCreditCode);
} }

View File

@ -2,6 +2,7 @@ package com.bonus.sgzb.base.mapper;
import com.bonus.sgzb.base.api.domain.MaMachine; import com.bonus.sgzb.base.api.domain.MaMachine;
import com.bonus.sgzb.base.api.domain.SltAgreementApply; import com.bonus.sgzb.base.api.domain.SltAgreementApply;
import com.bonus.sgzb.base.domain.DataReceiveDetail;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import java.util.List; import java.util.List;
@ -51,5 +52,5 @@ public interface MaMachineMapper {
Long selectMaMachineByItemId(Long itemId); Long selectMaMachineByItemId(Long itemId);
Integer updateItemStatus(Long itemId); Integer updateItemStatus(DataReceiveDetail dataReceiveDetail);
} }

View File

@ -26,4 +26,6 @@ public interface MaReceiveMapper {
List<DataReceiveDetail> getDateReceiveMachine(DataReceiveDetail dataReceiveDetail); List<DataReceiveDetail> getDateReceiveMachine(DataReceiveDetail dataReceiveDetail);
int updateInfoStatus(@Param("id") Integer id); int updateInfoStatus(@Param("id") Integer id);
Integer updateOrderOverTime(DataReceiveDetail dataReceiveDetail);
} }

View File

@ -34,13 +34,13 @@ public interface IMaTypeKeeperService {
* 查询全部库管员信息 * 查询全部库管员信息
* @return * @return
*/ */
List<MaKeeperUser> getMaTypeKeeper(SysDept sysDept); List<MaKeeperUser> getMaTypeKeeper(String sysDept);
/** /**
* 查询企业信息 * 查询企业信息
* @param sysDept * @param sysDept
* @return * @return
*/ */
SysDept getEnterprise(SysDept sysDept); SysDept getEnterprise(String sysDept);
} }

View File

@ -23,5 +23,5 @@ public interface MaReceiveService {
Long getItemStatus(Long itemId); Long getItemStatus(Long itemId);
Integer updateItemStatus(Long itemId); Integer updateItemStatus(DataReceiveDetail dataReceiveDetail);
} }

View File

@ -74,6 +74,7 @@ public class MaMachineServiceImpl implements MaMachineService {
* @param machine * @param machine
* @return * @return
*/ */
private void getType(MaMachine machine) { private void getType(MaMachine machine) {
long typeId = machine.getTypeId(); long typeId = machine.getTypeId();
// 规格型号 // 规格型号
@ -117,6 +118,7 @@ public class MaMachineServiceImpl implements MaMachineService {
} }
@Override @Override
@Transactional
public int remove(Long[] maIds) { public int remove(Long[] maIds) {
int res = 0; int res = 0;
if (maIds != null || maIds.length > 0) { if (maIds != null || maIds.length > 0) {
@ -191,14 +193,20 @@ public class MaMachineServiceImpl implements MaMachineService {
String encrypt; String encrypt;
try { try {
//encrypt = RsaUtil.encryptByPublicKey(content, Constants.publicKey); //encrypt = RsaUtil.encryptByPublicKey(content, Constants.publicKey);
Map<String, String> map = new HashMap<String, String>(); Map<String, String> map = new HashMap<>();
map.put("body", content); map.put("body", content);
String body = JSONObject.toJSONString(map); String body = JSONObject.toJSONString(map);
String data = HttpHelper.sendHttpPost(zlptUrl, body); String data = HttpHelper.sendHttpPost(zlptUrl, body);
log.info("dataString-=========:" + data); log.info("dataString-=========:" + data);
//对返回的结果进行处理 //对返回的结果进行处理
// resultDataHandler(data); // resultDataHandler(data);
//修改设备状态防止重复推送
for (MaMachine maMachine:maMachineList) {
MaMachine maMachine1 = new MaMachine();
maMachine1.setMaId(maMachine.getMaId());
maMachine1.setPushStatus(1);
maMachineMapper.updateMaMachine(maMachine1);
}
} catch (Exception e) { } catch (Exception e) {
// throw new RuntimeException(e); // throw new RuntimeException(e);
return AjaxResult.error("推送失败!"); return AjaxResult.error("推送失败!");

View File

@ -11,6 +11,7 @@ import com.bonus.sgzb.base.mapper.MaMachineMapper;
import com.bonus.sgzb.base.mapper.MaReceiveMapper; import com.bonus.sgzb.base.mapper.MaReceiveMapper;
import com.bonus.sgzb.base.mapper.MaTypeMapper; import com.bonus.sgzb.base.mapper.MaTypeMapper;
import com.bonus.sgzb.base.service.MaReceiveService; import com.bonus.sgzb.base.service.MaReceiveService;
import com.bonus.sgzb.material.config.FieldGenerator;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -108,7 +109,7 @@ public class MaReceiveServiceImpl implements MaReceiveService {
public int saveMachine(DataReceiveInfo dataReceiveInfo) { public int saveMachine(DataReceiveInfo dataReceiveInfo) {
for (DataReceiveDetail dataReceiveDetail : dataReceiveInfo.getDataReceiveDetailList()) { for (DataReceiveDetail dataReceiveDetail : dataReceiveInfo.getDataReceiveDetailList()) {
MaMachine maMachine = new MaMachine(); MaMachine maMachine = new MaMachine();
maMachine.setMaCode(dataReceiveDetail.getMaCode()); maMachine.setMaCode(FieldGenerator.generateField());
maMachine.setTypeId(dataReceiveDetail.getTypeId()); maMachine.setTypeId(dataReceiveDetail.getTypeId());
maMachine.setMaStatus("15"); maMachine.setMaStatus("15");
maMachine.setCreateTime(new Date()); maMachine.setCreateTime(new Date());
@ -153,8 +154,14 @@ public class MaReceiveServiceImpl implements MaReceiveService {
return maMachineMapper.selectMaMachineByItemId(itemId); return maMachineMapper.selectMaMachineByItemId(itemId);
} }
@Override
public Integer updateItemStatus(Long itemId) {
return maMachineMapper.updateItemStatus(itemId); public Integer updateItemStatus(DataReceiveDetail dataReceiveDetail) {
if (dataReceiveDetail!=null && dataReceiveDetail.getOrderOverTime()!= null){
return maReceiveMapper.updateOrderOverTime(dataReceiveDetail);
}else {
return maMachineMapper.updateItemStatus(dataReceiveDetail);
}
} }
} }

View File

@ -1,5 +1,6 @@
package com.bonus.sgzb.base.service.impl; package com.bonus.sgzb.base.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.bonus.sgzb.base.domain.MaKeeperUser; import com.bonus.sgzb.base.domain.MaKeeperUser;
import com.bonus.sgzb.base.mapper.DeptMapper; import com.bonus.sgzb.base.mapper.DeptMapper;
import com.bonus.sgzb.base.mapper.MaTypeKeeperMapper; import com.bonus.sgzb.base.mapper.MaTypeKeeperMapper;
@ -58,20 +59,24 @@ public class MaTypeKeeperServiceImpl implements IMaTypeKeeperService {
* @return * @return
*/ */
@Override @Override
public List<MaKeeperUser> getMaTypeKeeper(SysDept sysDept) { public List<MaKeeperUser> getMaTypeKeeper(String sysDept) {
log.info("MaTypeKeeperServiceImpl getMaTypeKeeper {}", sysDept); log.info("MaTypeKeeperServiceImpl getMaTypeKeeper {}", sysDept);
JSONObject object = JSONObject.parseObject(sysDept);
String socialCreditCode = object.getString("body");
//根据企业机构代码统一社会信用代码获取企业信息 //根据企业机构代码统一社会信用代码获取企业信息
sysDept = deptMapper.getDeptBySocialCreditCode(sysDept); SysDept newSysDept = deptMapper.getDeptBySocialCreditCode(socialCreditCode);
//获取该企业下的库管员 //获取该企业下的库管员
return maTypeKeeperMapper.getMaTypeKeeper(sysDept.getDeptId()); return maTypeKeeperMapper.getMaTypeKeeper(newSysDept.getDeptId());
} }
@Override @Override
public SysDept getEnterprise(SysDept sysDept) { public SysDept getEnterprise(String sysDept) {
log.info("MaTypeKeeperServiceImpl getEnterprise {}", sysDept); log.info("MaTypeKeeperServiceImpl getEnterprise {}", sysDept);
JSONObject object = JSONObject.parseObject(sysDept);
String socialCreditCode = object.getString("body");
//根据企业机构代码统一社会信用代码获取企业信息 //根据企业机构代码统一社会信用代码获取企业信息
sysDept = deptMapper.getDeptBySocialCreditCode(sysDept); SysDept newSysDept = deptMapper.getDeptBySocialCreditCode(socialCreditCode);
return sysDept; return newSysDept;
} }
} }

View File

@ -15,11 +15,11 @@ spring:
nacos: nacos:
discovery: discovery:
# 服务注册地址 # 服务注册地址
server-addr: 192.168.0.119:8848 server-addr: 127.0.0.1:8848
namespace: sgzb_nwjj namespace: sgzb_nwjj
config: config:
# 配置中心地址 # 配置中心地址
server-addr: 192.168.0.119:8848 server-addr: 127.0.0.1:8848
namespace: sgzb_nwjj namespace: sgzb_nwjj
# 配置文件格式 # 配置文件格式
file-extension: yml file-extension: yml
@ -38,8 +38,9 @@ sgzb:
job: job:
settlementJobDay: 1 settlementJobDay: 1
settlementJobCron: "0 0 1 1 * ?" settlementJobCron: "0 0 1 1 * ?"
zlptUrl: http://test-rental.zhgkxt.com/proxy/item-center/supply/item/pushNotifications zlptUrl: https://test-rental.zhgkxt.com/proxy/item-center/supply/item/pushNotifications
intelligentUrl: http://www.zhgkxt.com/api/clientapi/public/externalApi updateItemStatusUrl: https://test-rental.zhgkxt.com/proxy/item-center/supply/item/updateItemStatus
intelligentUrl: https://sit.zhgkxt.com/api/clientapi/public/externalApi/acceptExternalMechanical
intelligentAppKey: abc123 intelligentAppKey: abc123
intelligentAesKey: abcdefghijklmnop intelligentAesKey: abcdefghijklmnop

View File

@ -40,7 +40,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
create_by, create_time, update_by, update_time create_by, create_time, update_by, update_time
from sys_dept from sys_dept
</select> </select>
<select id="getDeptBySocialCreditCode" resultType="com.bonus.sgzb.system.api.domain.SysDept"> <select id="getDeptBySocialCreditCode" resultMap="sysDeptResult">
select * from sys_dept where social_credit_code = #{socialCreditCode} select * from sys_dept where social_credit_code = #{socialCreditCode}
</select> </select>

View File

@ -42,7 +42,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
m.ma_vender, m.out_fac_time, m.out_fac_code, m.assets_code, m.check_man, m.this_check_time, m.next_check_time, m.ma_vender, m.out_fac_time, m.out_fac_code, m.assets_code, m.check_man, m.this_check_time, m.next_check_time,
m.gps_code, m.rfid_code, m.erp_code, m.transfer_code,m.create_time ,m.in_out_num, m.buy_task, m.own_house , m.gps_code, m.rfid_code, m.erp_code, m.transfer_code,m.create_time ,m.in_out_num, m.buy_task, m.own_house ,
m.company_id ,mt.type_name specificationType,mt1.type_name deviceType, mt2.type_name itemType, m.company_id ,mt.type_name specificationType,mt1.type_name deviceType, mt2.type_name itemType,
mmb.label_code labelCode,mhi.house_name ownHouseName mmb.label_code labelCode,mhi.house_name ownHouseName,m.push_status
from ma_machine m from ma_machine m
left join (select id,p_id,name from sys_dic where p_id in (select id from sys_dic where value = 'ma_status')) dic on m.ma_status = dic.id left join (select id,p_id,name from sys_dic where p_id in (select id from sys_dic where value = 'ma_status')) dic on m.ma_status = dic.id
left join ma_type mt on m.type_id = mt.type_id left join ma_type mt on m.type_id = mt.type_id
@ -265,6 +265,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="buyTask != null and buyTask != ''">buy_task = #{buyTask},</if> <if test="buyTask != null and buyTask != ''">buy_task = #{buyTask},</if>
<if test="ownHouse != null and ownHouse != ''">own_house = #{ownHouse},</if> <if test="ownHouse != null and ownHouse != ''">own_house = #{ownHouse},</if>
<if test="companyId != null and companyId != ''">company_id = #{companyId},</if> <if test="companyId != null and companyId != ''">company_id = #{companyId},</if>
<if test="pushStatus != null and pushStatus != ''">push_status = #{pushStatus},</if>
update_time = sysdate() update_time = sysdate()
</set> </set>
where ma_id = #{maId} where ma_id = #{maId}

View File

@ -29,6 +29,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
SET receive_status = 1 SET receive_status = 1
where id = #{id} where id = #{id}
</update> </update>
<update id="updateOrderOverTime">
UPDATE data_receive_detail
SET order_over_time = #{orderOverTime}
where item_id = #{itemId}
</update>
<select id="getDataReceive" resultType="com.bonus.sgzb.base.domain.DataReceiveInfo"> <select id="getDataReceive" resultType="com.bonus.sgzb.base.domain.DataReceiveInfo">
select * from data_receive_info where 1=1 select * from data_receive_info where 1=1
<if test="receiveStatus != null"> <if test="receiveStatus != null">