Commit 4ebc7ff3 by huluobin

update

parent bdf1b53e
......@@ -9,36 +9,36 @@ public class PathUtil {
/**
* 获取项目图片根路径
*
* @return basePath
*/
public static String getBasePath() {
/**
* 获取操作系统的类型
*/
String os = System.getProperty("os.name");
String basePath = "";
if (os.toLowerCase().startsWith("win")) {
// basePath = "E:/library/Documents/file/bailuntec/other/";
basePath = "C:/FeeSystemFiles/other/";
}else if (os.toLowerCase().startsWith("mac")){
} else if (os.toLowerCase().startsWith("mac")) {
basePath = "/Users/bailuntec/other/";
}else {
} else {
basePath = "/home/bailuntec/other/";
}
return basePath.replace("/",separator);
return basePath.replace("/", separator);
}
/**
* 根据业务需求返回相对应的子路径
*
* @return 系统格式化后的文件路径
*/
public static String getPath(String path){
String filePath = String.format(path);
return filePath.replace("/",separator);
public static String getPath(String path) {
return path.replace("/", separator);
}
/**
* 获取文件名
*
* @param filePath
* @return
*/
......
package com.blt.other.module.commons.controller;
import com.bailuntec.cost.api.response.CostResult;
import com.blt.other.common.exception.BizRuntimeException;
import com.blt.other.common.util.PathUtil;
import com.blt.other.module.cost.utils.CostFileUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
/**
* <p>
*
* </p>
*
* @author robbendev
* @since 2020/10/26 2:04 下午
*/
@Api(tags = "文件服务接口")
@RestController
public class FileController {
@ApiOperation("文件上传接口")
@PostMapping("/file/upload")
public CostResult<String> upload(MultipartFile file) {
/*附件字段*/
if (file != null) {
// 文件上传的路径
String filePath = PathUtil.getBasePath() + PathUtil.getPath("cost/");
// 调用工具类执行保存,并返回 path
String path = CostFileUtil.upload(file, filePath);
return CostResult.success(path);
}
throw new BizRuntimeException("文件不能为空");
}
}
......@@ -78,7 +78,7 @@ public class CostPlanNewController {
@ApiOperation("更新费用计划")
@PostMapping(value = {"/reset", "resetNoFile", "resetFile"})
public CostPlanNewApiDto.RestResp reset(CostPlanDomain costPlanDomain) {
public CostPlanNewApiDto.RestResp reset(@RequestBody CostPlanDomain costPlanDomain) {
CostPlanService costPlanService = CostPlanServiceFactory.getCostPlanService(costPlanDomain);
costPlanService.update(costPlanDomain);
......@@ -90,7 +90,7 @@ public class CostPlanNewController {
@ApiOperation("新增费用计划")
@PostMapping(value = {"/save", "saveNoFile", "saveFile"})
public CostPlanNewApiDto.SaveResp save(CostPlanDomain costPlanDomain) {
public CostPlanNewApiDto.SaveResp save(@RequestBody CostPlanDomain costPlanDomain) {
CostPlanService costPlanService = CostPlanServiceFactory.getCostPlanService(costPlanDomain);
costPlanService.save(costPlanDomain);
......
......@@ -43,7 +43,7 @@ public final class CostPlanTempApiDto {
private String typeNo; // 大类编号
private BigDecimal planAmount;
private MultipartFile fileSelect;
// private MultipartFile fileSelect;
}
@ApiModel("获取费用计划编号对应的费用计划子项出参")
......
......@@ -43,12 +43,6 @@ public class CostTemplateBaseCol implements Serializable {
@ApiModelProperty(value = "表单字段数据来源 1. input 人工输入 2. api 网络请求 3. enum 枚举")
private Integer colDataSource;
@ApiModelProperty(value = "如果字段数据来源是api网络请求(colDateSource = 2) 这里记获取可选值的api全链接。")
private String colApi;
@ApiModelProperty(value = "如果费用单字段记录是enum枚举(colDateSource = 3),这里可选的枚举值,用逗号分隔。")
private String colEnum;
@ApiModelProperty("是否扩展字段")
private Boolean isExtension;
......
package com.blt.other.module.cost.service.impl.costplan;
import com.bailuntec.cost.api.dto.CostPlanDto;
import com.blt.other.common.util.PathUtil;
import com.blt.other.module.auth.dao.UserDao;
import com.blt.other.module.cost.dao.*;
import com.blt.other.module.cost.dto.CostPlanApiDto;
import com.blt.other.module.cost.service.*;
import com.blt.other.module.cost.utils.CostFileUtil;
import com.blt.other.module.cost.utils.CostUtils;
import com.blt.other.module.database.model.*;
import com.github.pagehelper.PageHelper;
......@@ -91,14 +89,14 @@ public abstract class AbstractCostPlanService implements CostPlanService {
costPlanDomain.setPayCur(costPlanDomain.getCur());
/*附件字段*/
if (costPlanDomain.getFileSelect() != null) {
// 文件上传的路径
String filePath = PathUtil.getBasePath() + PathUtil.getPath("cost/" + costPlanDomain.getCostPlanNo() + "/");
// 调用工具类执行保存,并返回 path
String path = CostFileUtil.upload(costPlanDomain.getFileSelect(), filePath);
costPlanDomain.setFilePath(path);
}
// /*附件字段*/
// if (costPlanDomain.getFileSelect() != null) {
// // 文件上传的路径
// String filePath = PathUtil.getBasePath() + PathUtil.getPath("cost/" + costPlanDomain.getCostPlanNo() + "/");
// // 调用工具类执行保存,并返回 path
// String path = CostFileUtil.upload(costPlanDomain.getFileSelect(), filePath);
// costPlanDomain.setFilePath(path);
// }
}
......
......@@ -35,7 +35,6 @@ public class CostPlanNewReceiptServiceImpl extends AbstractCostPlanService imple
planDomain.setTypeNo(costTypeKindDomain.getTypeNo());
planDomain.setTypeName(costTypeKindDomain.getTypeName());
costPlanDao.insert(planDomain);
}
......
......@@ -80,14 +80,7 @@ public class CostPlanTempServiceImpl implements CostPlanTempService {
costPlanTempDomain.setTempNo(this.createNo());
this.checkDic(costPlanTempDomain);
/*附件字段*/
if (req.getFileSelect() != null) {
// 文件上传的路径
String filePath = PathUtil.getBasePath() + PathUtil.getPath("cost/" + costPlanTempDomain.getTempNo() + "/");
// 调用工具类执行保存,并返回 path
String path = CostFileUtil.upload(req.getFileSelect(), filePath);
costPlanTempDomain.setFilePath(path);
}
//新增付款子项目
costPlanTempDao.insert(costPlanTempDomain);
......
......@@ -3,6 +3,7 @@ package com.blt.other.module.cost.service.impl.costtemplate;
import com.bailuntec.common.ListUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.blt.other.common.exception.BizRuntimeException;
import com.blt.other.module.cost.dao.CostTemplateColMapper;
import com.blt.other.module.cost.model.CostTemplate;
import com.blt.other.module.cost.model.CostTemplateCol;
......@@ -32,11 +33,18 @@ public class CostTemplateColServiceImpl extends ServiceImpl<CostTemplateColMappe
@Override
public void delete(Integer id) {
CostTemplateCol costTemplateCol = this.getById(id);
if (costTemplateCol.getIsDefault()) {
throw new BizRuntimeException("unable to remove default costTemplateCol");
}
this.removeById(id);
}
@Override
public void modify(CostTemplateCol costTemplateCol) {
if (costTemplateCol.getIsDefault()) {
throw new BizRuntimeException("unable to modify default costTemplateCol");
}
this.updateById(costTemplateCol);
}
......
package com.blt.other.module.database.model;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* <p>
* 费用单附加字段
* </p>
*
* @author robbendev
* @since 2020/10/26 1:21 下午
*/
@Data
public class CostAttach {
@ApiModelProperty("附加字段名")
private String name;
@ApiModelProperty("附加字段值")
private String value;
}
......@@ -6,15 +6,15 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.blt.other.module.database.mapper.StatusMapper;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import org.springframework.beans.BeanUtils;
import org.springframework.web.multipart.MultipartFile;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
@TableName("cost_plan")
@Data
......@@ -83,10 +83,11 @@ public class CostPlanDomain {
private Integer isTax; // 0 不抵扣个税 1 抵扣个税
private Integer companyValue; // 公司主体value
@TableField(typeHandler = JacksonTypeHandler.class)
private List<CostAttach> attach;
@JsonIgnore
@TableField(exist = false)
private MultipartFile fileSelect;
private String costTemplateId;
public CostPlanDto castToDto() {
StatusMapper statusMapper = SpringContextUtil.getBean(StatusMapper.class);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment