重庆机具配置项功能优化

This commit is contained in:
liang.chao 2024-11-18 13:39:08 +08:00
parent 38ff4b5289
commit fd9fd2d17c
5 changed files with 52 additions and 51 deletions

View File

@ -10,12 +10,14 @@ import com.bonus.sgzb.base.api.domain.MaMachine;
import com.bonus.sgzb.base.api.domain.MachinePart; import com.bonus.sgzb.base.api.domain.MachinePart;
import com.bonus.sgzb.base.api.domain.SltAgreementInfo; import com.bonus.sgzb.base.api.domain.SltAgreementInfo;
import com.bonus.sgzb.base.mapper.MaMachineMapper; import com.bonus.sgzb.base.mapper.MaMachineMapper;
import com.bonus.sgzb.base.service.ISysConfigService;
import com.bonus.sgzb.common.core.constant.TaskTypeConstants; import com.bonus.sgzb.common.core.constant.TaskTypeConstants;
import com.bonus.sgzb.common.core.enums.TaskStatusEnum; import com.bonus.sgzb.common.core.enums.TaskStatusEnum;
import com.bonus.sgzb.common.core.enums.TaskTypeEnum; import com.bonus.sgzb.common.core.enums.TaskTypeEnum;
import com.bonus.sgzb.common.core.utils.DateUtils; import com.bonus.sgzb.common.core.utils.DateUtils;
import com.bonus.sgzb.common.core.utils.HttpHelper; import com.bonus.sgzb.common.core.utils.HttpHelper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; 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;
@ -41,13 +43,12 @@ public class BackReceiveServiceImpl implements BackReceiveService {
@Resource @Resource
private MaMachineMapper maMachineMapper; private MaMachineMapper maMachineMapper;
@Autowired
private ISysConfigService configService;
@Resource @Resource
private TmTaskMapper tmTaskMapper; private TmTaskMapper tmTaskMapper;
@Value("${sgzb.updateItemStatusUrl}")
private String updateItemStatus;
@Override @Override
@ -543,6 +544,7 @@ public class BackReceiveServiceImpl implements BackReceiveService {
Map<String, String> map = new HashMap<>(); 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 updateItemStatus = configService.selectConfigByKey("updateItemStatusUrl");
String data = HttpHelper.sendHttpPost(updateItemStatus, body); String data = HttpHelper.sendHttpPost(updateItemStatus, body);
log.info("dataString-=========:" + data); log.info("dataString-=========:" + data);
} catch (Exception e) { } catch (Exception e) {

View File

@ -11,6 +11,7 @@ import com.bonus.sgzb.app.service.LeaseOutDetailsService;
import com.bonus.sgzb.base.api.domain.*; import com.bonus.sgzb.base.api.domain.*;
import com.bonus.sgzb.base.mapper.MaLabelBindMapper; 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.service.ISysConfigService;
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.HttpHelper;
@ -18,6 +19,7 @@ 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.Autowired;
import org.springframework.beans.factory.annotation.Value; 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;
@ -47,8 +49,9 @@ public class LeaseOutDetailsServiceImpl implements LeaseOutDetailsService {
@Resource @Resource
private MaLabelBindMapper maLabelBindMapper; private MaLabelBindMapper maLabelBindMapper;
@Value("${sgzb.updateItemStatusUrl}") @Autowired
private String updateItemStatus; private ISysConfigService configService;
/** /**
* 根据任务id查询出库数据 * 根据任务id查询出库数据
@ -272,7 +275,8 @@ public class LeaseOutDetailsServiceImpl implements LeaseOutDetailsService {
Map<String, String> map = new HashMap<>(); 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(updateItemStatus, body); String updateItemStatusUrl = configService.selectConfigByKey("updateItemStatusUrl");
String data = HttpHelper.sendHttpPost(updateItemStatusUrl, body);
log.info("dataString-=========:" + data); log.info("dataString-=========:" + data);
} catch (Exception e) { } catch (Exception e) {
log.error("同步租赁商城机具状态失败"); log.error("同步租赁商城机具状态失败");

View File

@ -11,6 +11,7 @@ import com.bonus.sgzb.app.mapper.LeaseApplyInfoMapper;
import com.bonus.sgzb.app.mapper.TmTaskMapper; import com.bonus.sgzb.app.mapper.TmTaskMapper;
import com.bonus.sgzb.app.service.*; import com.bonus.sgzb.app.service.*;
import com.bonus.sgzb.base.api.domain.*; import com.bonus.sgzb.base.api.domain.*;
import com.bonus.sgzb.base.service.ISysConfigService;
import com.bonus.sgzb.common.core.constant.Constants; import com.bonus.sgzb.common.core.constant.Constants;
import com.bonus.sgzb.common.core.domain.R; import com.bonus.sgzb.common.core.domain.R;
import com.bonus.sgzb.common.core.exception.ServiceException; import com.bonus.sgzb.common.core.exception.ServiceException;
@ -26,6 +27,7 @@ import com.bonus.sgzb.material.exception.ExceptionDict;
import com.bonus.sgzb.material.mapper.LeaseRecordMapper; import com.bonus.sgzb.material.mapper.LeaseRecordMapper;
import com.bonus.sgzb.system.api.model.LoginUser; import com.bonus.sgzb.system.api.model.LoginUser;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; 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;
@ -48,14 +50,8 @@ import java.util.stream.Collectors;
@Slf4j @Slf4j
public class TmTaskServiceImpl implements TmTaskService { public class TmTaskServiceImpl implements TmTaskService {
@Value("${sgzb.intelligentUrl}") @Autowired
private String intelligentUrl; private ISysConfigService configService;
@Value("${sgzb.intelligentAppKey}")
private String intelligentAppKey;
@Value("${sgzb.intelligentAesKey}")
private String intelligentAesKey;
@Resource @Resource
private TmTaskMapper tmTaskMapper; private TmTaskMapper tmTaskMapper;
@ -1395,9 +1391,12 @@ public class TmTaskServiceImpl implements TmTaskService {
MaMachineIntelligentVO maMachineIntelligentVO = intelVOList.get(0); MaMachineIntelligentVO maMachineIntelligentVO = intelVOList.get(0);
String content = JSONObject.toJSONString(maMachineIntelligentVO); String content = JSONObject.toJSONString(maMachineIntelligentVO);
//获取token //获取token
String intelligentAppKey = configService.selectConfigByKey("intelligentAppKey");
String intelligentAesKey = configService.selectConfigByKey("intelligentAesKey");
String token = GetTokenByAppKey.getToken(intelligentAppKey, intelligentAesKey); String token = GetTokenByAppKey.getToken(intelligentAppKey, intelligentAesKey);
log.info("token-=========:" + token); log.info("token-=========:" + token);
//调用推送的方法 //调用推送的方法
String intelligentUrl = configService.selectConfigByKey("intelligentUrl");
String data = HttpHelper.sendHttpPost(intelligentUrl, token,content,intelligentAppKey); String data = HttpHelper.sendHttpPost(intelligentUrl, token,content,intelligentAppKey);
log.info("dataString-=========:" + data); log.info("dataString-=========:" + data);
resultDataHandler(data); resultDataHandler(data);

View File

@ -26,8 +26,7 @@ import java.util.List;
*/ */
@RestController @RestController
@RequestMapping("/config") @RequestMapping("/config")
public class SysConfigController extends BaseController public class SysConfigController extends BaseController {
{
private final String publicKey = "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKoR8mX0rGKLqzcWmOzbfj64K8ZIgOdHnzkXSOVOZbFu/TJhZ7rFAN+eaGkl3C4buccQd/EjEsj9ir7ijT7h96MCAwEAAQ=="; private final String publicKey = "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKoR8mX0rGKLqzcWmOzbfj64K8ZIgOdHnzkXSOVOZbFu/TJhZ7rFAN+eaGkl3C4buccQd/EjEsj9ir7ijT7h96MCAwEAAQ==";
private final String CONFIG_KEY = "sys.user.initPassword"; private final String CONFIG_KEY = "sys.user.initPassword";
@ -54,8 +53,7 @@ public class SysConfigController extends BaseController
@Log(title = "参数管理", businessType = BusinessType.EXPORT) @Log(title = "参数管理", businessType = BusinessType.EXPORT)
@RequiresPermissions("system:config:export") @RequiresPermissions("system:config:export")
@PostMapping("/export") @PostMapping("/export")
public void export(HttpServletResponse response, MaConfig config) public void export(HttpServletResponse response, MaConfig config) {
{
List<MaConfig> list = configService.selectConfigList(config); List<MaConfig> list = configService.selectConfigList(config);
ExcelUtil<MaConfig> util = new ExcelUtil<MaConfig>(MaConfig.class); ExcelUtil<MaConfig> util = new ExcelUtil<MaConfig>(MaConfig.class);
util.exportExcel(response, list, "参数数据"); util.exportExcel(response, list, "参数数据");
@ -65,8 +63,7 @@ public class SysConfigController extends BaseController
* 根据参数编号获取详细信息 * 根据参数编号获取详细信息
*/ */
@GetMapping(value = "/{configId}") @GetMapping(value = "/{configId}")
public AjaxResult getInfo(@PathVariable Long configId) public AjaxResult getInfo(@PathVariable Long configId) {
{
return success(configService.selectConfigById(configId)); return success(configService.selectConfigById(configId));
} }
@ -89,10 +86,8 @@ public class SysConfigController extends BaseController
@RequiresPermissions("system:config:add") @RequiresPermissions("system:config:add")
@Log(title = "参数管理", businessType = BusinessType.INSERT) @Log(title = "参数管理", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public AjaxResult add(@Validated @RequestBody MaConfig config) public AjaxResult add(@Validated @RequestBody MaConfig config) {
{ if (!configService.checkConfigKeyUnique(config)) {
if (!configService.checkConfigKeyUnique(config))
{
return error("新增参数'" + config.getConfigName() + "'失败,参数键名已存在"); return error("新增参数'" + config.getConfigName() + "'失败,参数键名已存在");
} }
config.setCreateBy(SecurityUtils.getUsername()); config.setCreateBy(SecurityUtils.getUsername());
@ -105,10 +100,8 @@ public class SysConfigController extends BaseController
@RequiresPermissions("system:config:edit") @RequiresPermissions("system:config:edit")
@Log(title = "参数管理", businessType = BusinessType.UPDATE) @Log(title = "参数管理", businessType = BusinessType.UPDATE)
@PutMapping @PutMapping
public AjaxResult edit(@Validated @RequestBody MaConfig config) public AjaxResult edit(@Validated @RequestBody MaConfig config) {
{ if (!configService.checkConfigKeyUnique(config)) {
if (!configService.checkConfigKeyUnique(config))
{
return error("修改参数'" + config.getConfigName() + "'失败,参数键名已存在"); return error("修改参数'" + config.getConfigName() + "'失败,参数键名已存在");
} }
config.setUpdateBy(SecurityUtils.getUsername()); config.setUpdateBy(SecurityUtils.getUsername());
@ -121,8 +114,7 @@ public class SysConfigController extends BaseController
@RequiresPermissions("system:config:remove") @RequiresPermissions("system:config:remove")
@Log(title = "参数管理", businessType = BusinessType.DELETE) @Log(title = "参数管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{configIds}") @DeleteMapping("/{configIds}")
public AjaxResult remove(@PathVariable Long[] configIds) public AjaxResult remove(@PathVariable Long[] configIds) {
{
configService.deleteConfigByIds(configIds); configService.deleteConfigByIds(configIds);
return success(); return success();
} }
@ -133,8 +125,7 @@ public class SysConfigController extends BaseController
@RequiresPermissions("system:config:remove") @RequiresPermissions("system:config:remove")
@Log(title = "参数管理", businessType = BusinessType.CLEAN) @Log(title = "参数管理", businessType = BusinessType.CLEAN)
@DeleteMapping("/refreshCache") @DeleteMapping("/refreshCache")
public AjaxResult refreshCache() public AjaxResult refreshCache() {
{
configService.resetConfigCache(); configService.resetConfigCache();
return success(); return success();
} }

View File

@ -9,6 +9,7 @@ import com.bonus.sgzb.base.api.domain.SltAgreementApply;
import com.bonus.sgzb.base.domain.MaPropSet; import com.bonus.sgzb.base.domain.MaPropSet;
import com.bonus.sgzb.base.domain.vo.IotRecordVo; import com.bonus.sgzb.base.domain.vo.IotRecordVo;
import com.bonus.sgzb.base.mapper.*; import com.bonus.sgzb.base.mapper.*;
import com.bonus.sgzb.base.service.ISysConfigService;
import com.bonus.sgzb.base.service.MaMachineService; import com.bonus.sgzb.base.service.MaMachineService;
import com.bonus.sgzb.common.core.constant.Constants; import com.bonus.sgzb.common.core.constant.Constants;
import com.bonus.sgzb.common.core.exception.ServiceException; import com.bonus.sgzb.common.core.exception.ServiceException;
@ -18,6 +19,7 @@ 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 com.bonus.sgzb.material.exception.ExceptionDict; import com.bonus.sgzb.material.exception.ExceptionDict;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; 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;
@ -28,13 +30,14 @@ import java.util.*;
@Service @Service
@Slf4j @Slf4j
public class MaMachineServiceImpl implements MaMachineService { public class MaMachineServiceImpl implements MaMachineService {
@Value("${sgzb.zlptUrl}")
private String zlptUrl; private String zlptUrl;
@Resource @Resource
private MaMachineMapper maMachineMapper; private MaMachineMapper maMachineMapper;
@Resource @Resource
private MaTypeMapper typeMapper; private MaTypeMapper typeMapper;
@Autowired
private ISysConfigService configService;
@Resource @Resource
private MaLabelBindMapper labelBindMapper; private MaLabelBindMapper labelBindMapper;
@ -49,17 +52,17 @@ public class MaMachineServiceImpl implements MaMachineService {
@Override @Override
public List<MaMachine> getMaMachine(MaMachine maMachine) { public List<MaMachine> getMaMachine(MaMachine maMachine) {
List<MaMachine> listMaMachine = new ArrayList<>(); List<MaMachine> listMaMachine = new ArrayList<>();
listMaMachine =maMachineMapper.getMaMachine(maMachine); listMaMachine = maMachineMapper.getMaMachine(maMachine);
if (listMaMachine.size() > 0){ if (listMaMachine.size() > 0) {
for (MaMachine ma : listMaMachine) { for (MaMachine ma : listMaMachine) {
//根据机具编码查询iot设备 //根据机具编码查询iot设备
List<IotRecordVo> iotRecordVoList = baseIotMachineMapper.selectList(ma.getMaCode()); List<IotRecordVo> iotRecordVoList = baseIotMachineMapper.selectList(ma.getMaCode());
ma.setIotNum(iotRecordVoList.size()); ma.setIotNum(iotRecordVoList.size());
//判断是否绑定了iot设备 //判断是否绑定了iot设备
if (iotRecordVoList.size()>0){ if (iotRecordVoList.size() > 0) {
for (int i = 0; i < iotRecordVoList.size(); i++) { for (int i = 0; i < iotRecordVoList.size(); i++) {
//保存定位iot设备编码 //保存定位iot设备编码
if ("125".equals(iotRecordVoList.get(i).getIotType())){ if ("125".equals(iotRecordVoList.get(i).getIotType())) {
ma.setIotCode(iotRecordVoList.get(i).getIotCode()); ma.setIotCode(iotRecordVoList.get(i).getIotCode());
} }
} }
@ -70,7 +73,8 @@ public class MaMachineServiceImpl implements MaMachineService {
} }
/** /**
* 添加查询物品种类,设备类型,规格型号 * 添加查询物品种类,设备类型,规格型号
*
* @param machine * @param machine
* @return * @return
*/ */
@ -90,6 +94,7 @@ public class MaMachineServiceImpl implements MaMachineService {
/** /**
* 新增机具设备 * 新增机具设备
*
* @param maMachine 机具设备信息 * @param maMachine 机具设备信息
* @return 结果 * @return 结果
*/ */
@ -156,28 +161,27 @@ public class MaMachineServiceImpl implements MaMachineService {
* @return 机具设备管理ma_machine * @return 机具设备管理ma_machine
*/ */
@Override @Override
public MaMachine selectMaMachineByMaId(Long maId) public MaMachine selectMaMachineByMaId(Long maId) {
{
return maMachineMapper.selectMaMachineByMaId(maId); return maMachineMapper.selectMaMachineByMaId(maId);
} }
@Override @Override
public MaMachine getMachineByQrCode(MaMachine maMachine) { public MaMachine getMachineByQrCode(MaMachine maMachine) {
MaMachine ma = maMachineMapper.getMachineByQrCode(maMachine); MaMachine ma = maMachineMapper.getMachineByQrCode(maMachine);
if(ma != null){ if (ma != null) {
SltAgreementApply leaseProject = maMachineMapper.getLeaseProject(ma); SltAgreementApply leaseProject = maMachineMapper.getLeaseProject(ma);
SltAgreementApply backProject = maMachineMapper.getBackProject(ma); SltAgreementApply backProject = maMachineMapper.getBackProject(ma);
if (leaseProject != null){ if (leaseProject != null) {
ma.setLeaseUnit(leaseProject.getUnitName()); ma.setLeaseUnit(leaseProject.getUnitName());
ma.setLeasePro(leaseProject.getProjectName()); ma.setLeasePro(leaseProject.getProjectName());
ma.setLeaseTime(leaseProject.getCreateTime()); ma.setLeaseTime(leaseProject.getCreateTime());
} }
if (backProject != null){ if (backProject != null) {
ma.setBackUnit(backProject.getUnitName()); ma.setBackUnit(backProject.getUnitName());
ma.setBackPro(backProject.getProjectName()); ma.setBackPro(backProject.getProjectName());
ma.setBackTime(backProject.getCreateTime()); ma.setBackTime(backProject.getCreateTime());
} }
}else { } else {
throw new ServiceException("二维码对应机具信息无效"); throw new ServiceException("二维码对应机具信息无效");
} }
return ma; return ma;
@ -185,9 +189,10 @@ public class MaMachineServiceImpl implements MaMachineService {
@Override @Override
public AjaxResult pushNotifications(List<MaMachine> maMachineList) { public AjaxResult pushNotifications(List<MaMachine> maMachineList) {
log.info("MaMachineServiceImpl pushNotifications 开始处理设备推送逻辑==={},地址{}",maMachineList,zlptUrl); zlptUrl = configService.selectConfigByKey("zlptUrl");
if (maMachineList.isEmpty()){ log.info("MaMachineServiceImpl pushNotifications 开始处理设备推送逻辑==={},地址{}", maMachineList, zlptUrl);
throw new ServiceException(String.format(ExceptionDict.PARAM_IS_NULL_ERROR_MSG,"maMachineList"), ExceptionDict.PARAM_IS_NULL_ERROR); if (maMachineList.isEmpty()) {
throw new ServiceException(String.format(ExceptionDict.PARAM_IS_NULL_ERROR_MSG, "maMachineList"), ExceptionDict.PARAM_IS_NULL_ERROR);
} }
String content = JSONObject.toJSONString(maMachineList); String content = JSONObject.toJSONString(maMachineList);
String encrypt; String encrypt;
@ -199,9 +204,9 @@ public class MaMachineServiceImpl implements MaMachineService {
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) { for (MaMachine maMachine : maMachineList) {
MaMachine maMachine1 = new MaMachine(); MaMachine maMachine1 = new MaMachine();
maMachine1.setMaId(maMachine.getMaId()); maMachine1.setMaId(maMachine.getMaId());
maMachine1.setPushStatus(1); maMachine1.setPushStatus(1);