bug优化、app获取天气接口
This commit is contained in:
@ -233,14 +233,29 @@ public class BusPurchaseDocServiceImpl extends ServiceImpl<BusPurchaseDocMapper,
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@Override
|
||||
@Transactional( rollbackFor = Exception.class)
|
||||
public Boolean updateByBo(BusPurchaseDocBo bo) {
|
||||
BusPurchaseDoc update = MapstructUtils.convert(bo, BusPurchaseDoc.class);
|
||||
validEntityBeforeSave(update);
|
||||
|
||||
planDocAssociationService.remove(Wrappers.<BusPlanDocAssociation>lambdaQuery()
|
||||
.eq(BusPlanDocAssociation::getProjectId, update.getProjectId())
|
||||
.eq(BusPlanDocAssociation::getDocId, update.getId()));
|
||||
if (CollectionUtil.isNotEmpty(bo.getAssociationList())) {
|
||||
planDocAssociationService.remove(Wrappers.<BusPlanDocAssociation>lambdaQuery()
|
||||
.eq(BusPlanDocAssociation::getProjectId, update.getProjectId())
|
||||
.eq(BusPlanDocAssociation::getDocId, update.getId()));
|
||||
for (BusPlanDocAssociationBo association : bo.getAssociationList()) {
|
||||
|
||||
BusMaterialbatchdemandplan byId = materialbatchdemandplanService.getById(association.getPlanId());
|
||||
|
||||
List<BusPlanDocAssociation> list = planDocAssociationService.list(Wrappers.lambdaQuery(BusPlanDocAssociation.class)
|
||||
.eq(BusPlanDocAssociation::getPlanId, association.getPlanId()));
|
||||
BigDecimal total = list.stream()
|
||||
.map(BusPlanDocAssociation::getDemandQuantity)
|
||||
.filter(Objects::nonNull)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
|
||||
if(total.add(association.getDemandQuantity()).compareTo(byId.getDemandQuantity()) > 0){
|
||||
throw new ServiceException("材料:" + byId.getName() + "已超出计划单的物料批次需求计划数量");
|
||||
}
|
||||
}
|
||||
List<BusPlanDocAssociation> convert = MapstructUtils.convert(bo.getAssociationList(), BusPlanDocAssociation.class);
|
||||
convert.forEach(item -> {
|
||||
item.setProjectId(update.getProjectId());
|
||||
|
||||
@ -52,7 +52,7 @@ public class WeatherManager {
|
||||
String latTwo = roundToTwoDecimalPlacesString(lat);
|
||||
String location = lngTwo + "," + latTwo;
|
||||
// 获取天气请求路径
|
||||
String dayWeatherUrl = getDayWeatherUrl(weatherPath, location);
|
||||
String dayWeatherUrl = getDayWeatherUrl(weatherPath, location, "zh");
|
||||
String body;
|
||||
try (HttpResponse result = HttpRequest.get(dayWeatherUrl)
|
||||
.header("Authorization", "Bearer " + getJwt())
|
||||
@ -134,8 +134,8 @@ public class WeatherManager {
|
||||
* @param weatherPath 天气请求路径
|
||||
* @param location 位置
|
||||
*/
|
||||
private String getDayWeatherUrl(String weatherPath, String location) {
|
||||
return String.format("https://%s%s?location=%s", weatherProperties.getApiHost(), weatherPath, location);
|
||||
private String getDayWeatherUrl(String weatherPath, String location, String lang) {
|
||||
return String.format("https://%s%s?location=%s&lang=%s", weatherProperties.getApiHost(), weatherPath, location, lang);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1,11 +1,14 @@
|
||||
package org.dromara.safety.controller.app;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import org.dromara.bigscreen.domain.dto.WeatherQueryReq;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.manager.weathermanager.vo.WeatherVo;
|
||||
import org.dromara.safety.domain.dto.safetylog.HseSafetyLogCreateReq;
|
||||
import org.dromara.safety.domain.dto.safetylog.HseSafetyLogQueryReq;
|
||||
import org.dromara.safety.domain.vo.safetylog.HseSafetyLogVo;
|
||||
@ -13,6 +16,8 @@ import org.dromara.safety.service.IHseSafetyLogService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 安全日志 app 接口
|
||||
*
|
||||
@ -53,4 +58,12 @@ public class HseSafetyLogAppController extends BaseController {
|
||||
@PathVariable Long id) {
|
||||
return R.ok(safetyLogService.queryById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询天气
|
||||
*/
|
||||
@GetMapping("/weather")
|
||||
public R<WeatherVo> getProjectWeather(WeatherQueryReq req) {
|
||||
return R.ok(safetyLogService.getWeatherNowDaysList(req));
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,8 +3,10 @@ package org.dromara.safety.service;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.dromara.bigscreen.domain.dto.WeatherQueryReq;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.manager.weathermanager.vo.WeatherVo;
|
||||
import org.dromara.safety.domain.HseSafetyLog;
|
||||
import org.dromara.safety.domain.dto.safetylog.HseSafetyLogCreateReq;
|
||||
import org.dromara.safety.domain.dto.safetylog.HseSafetyLogQueryReq;
|
||||
@ -95,4 +97,6 @@ public interface IHseSafetyLogService extends IService<HseSafetyLog> {
|
||||
* @return 安全日志分页对象视图
|
||||
*/
|
||||
Page<HseSafetyLogVo> getVoPage(Page<HseSafetyLog> safetyLogPage);
|
||||
|
||||
WeatherVo getWeatherNowDaysList(WeatherQueryReq req);
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.dromara.bigscreen.domain.dto.WeatherQueryReq;
|
||||
import org.dromara.common.core.constant.HttpStatus;
|
||||
import org.dromara.common.core.domain.vo.IdAndNameVO;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
@ -13,6 +14,9 @@ import org.dromara.common.core.utils.ObjectUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.manager.weathermanager.WeatherConstant;
|
||||
import org.dromara.manager.weathermanager.WeatherManager;
|
||||
import org.dromara.manager.weathermanager.vo.WeatherVo;
|
||||
import org.dromara.project.service.IBusProjectService;
|
||||
import org.dromara.safety.domain.HseSafetyLog;
|
||||
import org.dromara.safety.domain.dto.safetylog.HseSafetyLogCreateReq;
|
||||
@ -47,6 +51,9 @@ public class HseSafetyLogServiceImpl extends ServiceImpl<HseSafetyLogMapper, Hse
|
||||
@Resource
|
||||
private SysUserMapper userMapper;
|
||||
|
||||
@Resource
|
||||
private WeatherManager weatherManager;
|
||||
|
||||
/**
|
||||
* 查询安全日志
|
||||
*
|
||||
@ -245,4 +252,10 @@ public class HseSafetyLogServiceImpl extends ServiceImpl<HseSafetyLogMapper, Hse
|
||||
safetyLogVoPage.setRecords(safetyLogVoList);
|
||||
return safetyLogVoPage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WeatherVo getWeatherNowDaysList(WeatherQueryReq req) {
|
||||
List<WeatherVo> weatherListVo = weatherManager.getWeatherListVo(req.getLng(), req.getLat(), WeatherConstant.THREE_DAYS_WEATHER_PATH);
|
||||
return weatherListVo.getFirst();
|
||||
}
|
||||
}
|
||||
|
||||
@ -130,7 +130,7 @@ public class TenderSupplierInputController extends BaseController {
|
||||
@Log(title = "供应商入库", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@RequestBody TenderSupplierInputBo bo,@RequestPart(value = "file",required = false) MultipartFile file) {
|
||||
public R<Void> edit(TenderSupplierInputBo bo,@RequestParam("file") MultipartFile file) {
|
||||
return toAjax(tenderSupplierInputService.updateByBo(bo,file));
|
||||
}
|
||||
|
||||
|
||||
@ -5,6 +5,8 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.cailiaoshebei.controller.constant;
|
||||
import org.dromara.cailiaoshebei.domain.BusCailiaoshebeiPici;
|
||||
import org.dromara.common.core.domain.event.ProcessEvent;
|
||||
import org.dromara.common.core.enums.BusinessStatusEnum;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.core.service.OssService;
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
@ -14,6 +16,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.formalities.enums.FormalitiesStatusEnum;
|
||||
import org.dromara.system.domain.vo.SysOssUploadVo;
|
||||
import org.dromara.system.domain.vo.SysOssVo;
|
||||
import org.dromara.system.service.ISysOssService;
|
||||
@ -107,10 +110,13 @@ public class TenderSupplierInputServiceImpl extends ServiceImpl<TenderSupplierIn
|
||||
@Override
|
||||
public Boolean insertByBo(TenderSupplierInputBo bo, MultipartFile file) {
|
||||
TenderSupplierInput add = MapstructUtils.convert(bo, TenderSupplierInput.class);
|
||||
validEntityBeforeSave(add);
|
||||
if (file == null || file.isEmpty()) {
|
||||
throw new ServiceException("文件不能为空!");
|
||||
}
|
||||
SysOssVo upload = ossService.upload(file, ossService.minioFileName(SupplierInput, file));
|
||||
add.setInputFile(upload.getUrl());
|
||||
add.setFileId(Long.valueOf(upload.getOssId()));
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setId(add.getId());
|
||||
@ -126,15 +132,24 @@ public class TenderSupplierInputServiceImpl extends ServiceImpl<TenderSupplierIn
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(TenderSupplierInputBo bo,MultipartFile file) {
|
||||
if (bo.getId() == null) {
|
||||
throw new ServiceException("id不能为空");
|
||||
}
|
||||
TenderSupplierInput update = MapstructUtils.convert(bo, TenderSupplierInput.class);
|
||||
TenderSupplierInput byId = getById(update.getId());
|
||||
if (file != null) {
|
||||
ossService.deleteWithValidByIds(List.of(byId.getFileId()), false);
|
||||
SysOssVo sysOssUploadVo = ossService.upload(file, ossService.minioFileName(SupplierInput, file));
|
||||
update.setInputFile(sysOssUploadVo.getUrl());
|
||||
update.setFileId(Long.valueOf(sysOssUploadVo.getOssId()));
|
||||
if (BusinessStatusEnum.FINISH.getStatus().equals(byId.getState())) {
|
||||
throw new ServiceException("已审核完成数据不能修改");
|
||||
}
|
||||
validEntityBeforeSave(update);
|
||||
|
||||
if (file != null) {
|
||||
if (byId.getFileId() != null) {
|
||||
ossService.deleteWithValidByIds(List.of(byId.getFileId()), false);
|
||||
}
|
||||
SysOssVo sysOssUploadVo = ossService.upload(file, ossService.minioFileName(SupplierInput, file));
|
||||
update.setInputFile(sysOssUploadVo.getUrl());
|
||||
update.setFileId(sysOssUploadVo.getOssId());
|
||||
}
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
@ -143,6 +158,28 @@ public class TenderSupplierInputServiceImpl extends ServiceImpl<TenderSupplierIn
|
||||
*/
|
||||
private void validEntityBeforeSave(TenderSupplierInput entity){
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
if (entity.getProjectId() == null){
|
||||
throw new ServiceException("项目id不能为空");
|
||||
}
|
||||
if (entity.getSupplierType() == null || entity.getSupplierType().isEmpty()){
|
||||
throw new ServiceException("企业登记注册类型不能为空");
|
||||
}
|
||||
if (entity.getSupplierName() == null || entity.getSupplierName().isEmpty()){
|
||||
throw new ServiceException("企业名称不能为空");
|
||||
}
|
||||
if (entity.getSupplierPerson() == null || entity.getSupplierPerson().isEmpty()){
|
||||
throw new ServiceException("企业法定代表人不能为空");
|
||||
}
|
||||
if (entity.getSupplierCode() == null || entity.getSupplierCode().isEmpty()){
|
||||
throw new ServiceException("统一社会信用代码不能为空");
|
||||
}
|
||||
if (entity.getPersonName() == null || entity.getPersonName().isEmpty()){
|
||||
throw new ServiceException("负责人姓名不能为空");
|
||||
}
|
||||
if (entity.getPersonPhone() == null || entity.getPersonPhone().isEmpty()){
|
||||
throw new ServiceException("负责人联系电话不能为空");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user