26 changed files with 828 additions and 32 deletions
@ -0,0 +1,45 @@ |
|||||
|
package com.ccsens.ptccsens.api; |
||||
|
|
||||
|
import com.ccsens.cloudutil.annotation.MustLogin; |
||||
|
import com.ccsens.ptccsens.bean.dto.DeliverDto; |
||||
|
import com.ccsens.ptccsens.bean.vo.DeliverVo; |
||||
|
import com.ccsens.ptccsens.service.IDeliverService; |
||||
|
import com.ccsens.util.JsonResponse; |
||||
|
import com.ccsens.util.bean.dto.QueryDto; |
||||
|
import io.swagger.annotations.Api; |
||||
|
import io.swagger.annotations.ApiOperation; |
||||
|
import io.swagger.annotations.ApiParam; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.stereotype.Controller; |
||||
|
import org.springframework.validation.annotation.Validated; |
||||
|
import org.springframework.web.bind.annotation.RequestBody; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestMethod; |
||||
|
import org.springframework.web.bind.annotation.RestController; |
||||
|
|
||||
|
import javax.annotation.Resource; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @author AUSU |
||||
|
*/ |
||||
|
@Api(tags = "交付物相关" ) |
||||
|
@RestController |
||||
|
@RequestMapping("/member") |
||||
|
@Slf4j |
||||
|
public class MemberController { |
||||
|
|
||||
|
@Resource |
||||
|
private IDeliverService deliverService; |
||||
|
|
||||
|
@MustLogin |
||||
|
@ApiOperation(value = "查询所有成员", notes = "") |
||||
|
@RequestMapping(value = "/queryChecker", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) |
||||
|
public JsonResponse<List<DeliverVo.Checker>> queryChecker(@ApiParam @Validated @RequestBody QueryDto<DeliverDto.QueryChecker> params) throws Exception { |
||||
|
log.info("查询所有成员--{}", params); |
||||
|
List<DeliverVo.Checker> checkers = deliverService.queryChecker(params.getParam(), params.getUserId()); |
||||
|
log.info("返回所有成员--{}", checkers); |
||||
|
return JsonResponse.newInstance().ok(checkers); |
||||
|
|
||||
|
} |
||||
|
} |
@ -0,0 +1,57 @@ |
|||||
|
package com.ccsens.ptccsens.api; |
||||
|
|
||||
|
import cn.hutool.core.codec.Base64; |
||||
|
import cn.hutool.core.util.ImageUtil; |
||||
|
import com.ccsens.cloudutil.annotation.MustLogin; |
||||
|
import com.ccsens.ptccsens.bean.dto.ProjectFinanceDto; |
||||
|
import com.ccsens.ptccsens.bean.vo.OcrVo; |
||||
|
import com.ccsens.ptccsens.bean.vo.ProjectFinanceVo; |
||||
|
import com.ccsens.ptccsens.service.IOcrService; |
||||
|
import com.ccsens.ptccsens.util.BasicsConstant; |
||||
|
import com.ccsens.util.JsonResponse; |
||||
|
import com.ccsens.util.baidu.BaiDuDto; |
||||
|
import com.ccsens.util.baidu.BaiDuUtil; |
||||
|
import com.ccsens.util.baidu.BaiDuVo; |
||||
|
import com.ccsens.util.bean.dto.QueryDto; |
||||
|
import com.github.pagehelper.PageInfo; |
||||
|
import io.swagger.annotations.Api; |
||||
|
import io.swagger.annotations.ApiOperation; |
||||
|
import io.swagger.annotations.ApiParam; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.validation.annotation.Validated; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
import javax.annotation.Resource; |
||||
|
import javax.imageio.ImageIO; |
||||
|
import javax.servlet.http.Part; |
||||
|
import java.io.ByteArrayOutputStream; |
||||
|
import java.io.IOException; |
||||
|
import java.text.ParseException; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* @author AUSU |
||||
|
*/ |
||||
|
@Api(tags = "图片识别" ) |
||||
|
@RestController |
||||
|
@RequestMapping("/ocr") |
||||
|
@Slf4j |
||||
|
public class OcrController { |
||||
|
|
||||
|
@Resource |
||||
|
private IOcrService ocrService; |
||||
|
|
||||
|
@ApiOperation(value = "图像识别", notes = "whj") |
||||
|
@RequestMapping(value = "/bill", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) |
||||
|
public JsonResponse<OcrVo.BillInfo> identifyBill(@RequestParam(required = true) Part part) throws Exception { |
||||
|
log.info("图像识别"); |
||||
|
// 压缩图像
|
||||
|
ByteArrayOutputStream out = new ByteArrayOutputStream(); |
||||
|
ImageUtil.scale(ImageIO.read(part.getInputStream()), out, 1f); |
||||
|
String img = Base64.encode(out.toByteArray()); |
||||
|
OcrVo.BillInfo billInfo = ocrService.identifyBill(img); |
||||
|
log.info("图像识别结束:{}", billInfo); |
||||
|
return JsonResponse.newInstance().ok(billInfo); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,162 @@ |
|||||
|
package com.ccsens.ptccsens.bean.dto; |
||||
|
|
||||
|
import io.swagger.annotations.ApiModel; |
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import javax.validation.constraints.*; |
||||
|
import java.math.BigDecimal; |
||||
|
import java.util.List; |
||||
|
|
||||
|
@Data |
||||
|
public class DeliverDto { |
||||
|
|
||||
|
@Data |
||||
|
@ApiModel("查询所有检查人") |
||||
|
public static class QueryChecker{ |
||||
|
@NotNull(message = "请选择项目") |
||||
|
@ApiModelProperty("项目id") |
||||
|
private Long projectId; |
||||
|
} |
||||
|
|
||||
|
@Data |
||||
|
@ApiModel("查询任务下的交付物信息") |
||||
|
public static class GetTaskDeliver{ |
||||
|
@NotNull(message = "请选择任务") |
||||
|
@ApiModelProperty("任务id(分解id)") |
||||
|
private Long taskId; |
||||
|
} |
||||
|
|
||||
|
@Data |
||||
|
@ApiModel("查询交付物的上传记录") |
||||
|
public static class QueryRecord{ |
||||
|
@NotNull(message = "请选择交付物信息") |
||||
|
@ApiModelProperty("交付物Id") |
||||
|
private Long deliverId; |
||||
|
} |
||||
|
|
||||
|
@Data |
||||
|
@ApiModel("查询交付物的检查记录") |
||||
|
public static class QueryCheckLog{ |
||||
|
@NotNull(message = "请选择交付物") |
||||
|
@ApiModelProperty("提交记录id") |
||||
|
private Long deliverRecordId; |
||||
|
} |
||||
|
|
||||
|
@Data |
||||
|
@ApiModel("添加交付物") |
||||
|
public static class SaveDeliver{ |
||||
|
@NotNull(message = "请选择项目") |
||||
|
@ApiModelProperty("项目id") |
||||
|
private Long projectId; |
||||
|
@NotNull(message = "请选择任务") |
||||
|
@ApiModelProperty("任务id(分解id)") |
||||
|
private Long taskId; |
||||
|
@NotBlank(message = "交付物名称不能为空") |
||||
|
@ApiModelProperty("交付物名称") |
||||
|
private String deliverName; |
||||
|
} |
||||
|
|
||||
|
@Data |
||||
|
@ApiModel("提交交付物信息") |
||||
|
public static class SubmitDeliver{ |
||||
|
@NotNull(message = "请选择项目") |
||||
|
@ApiModelProperty("项目id") |
||||
|
private Long projectId; |
||||
|
@NotNull(message = "请选择交付物") |
||||
|
@ApiModelProperty("交付物id") |
||||
|
private Long deliverId; |
||||
|
@NotNull(message = "请传入文件信息") |
||||
|
@ApiModelProperty("文件信息") |
||||
|
private List<String> fileList; |
||||
|
@NotNull(message = "请选择检查人") |
||||
|
@ApiModelProperty("检查人id") |
||||
|
private List<Long> checkerList; |
||||
|
} |
||||
|
|
||||
|
@Data |
||||
|
@ApiModel("检查交付物信息") |
||||
|
public static class CheckDeliver{ |
||||
|
@NotNull(message = "请选择项目") |
||||
|
@ApiModelProperty("项目id") |
||||
|
private Long projectId; |
||||
|
@NotNull(message = "请选择要审核交付物") |
||||
|
@ApiModelProperty("交付物提交记录id") |
||||
|
private Long deliverRecordId; |
||||
|
@ApiModelProperty("审核状态 0未检查,1已通过,2驳回 默认1已通过") |
||||
|
private byte type = 1; |
||||
|
@ApiModelProperty("备注信息") |
||||
|
private String remark; |
||||
|
@ApiModelProperty("分数") |
||||
|
private BigDecimal score; |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
// @Data
|
||||
|
// @ApiModel("检查交付物")
|
||||
|
// public static class CheckDeliver{
|
||||
|
// @NotNull(message = "检查信息错误")
|
||||
|
// @ApiModelProperty("检查记录id")
|
||||
|
// private Long checkId;
|
||||
|
// @NotNull(message = "项目信息错误")
|
||||
|
// @ApiModelProperty("项目id")
|
||||
|
// private Long projectId;
|
||||
|
// @ApiModelProperty("检查状态(1-通过,2-驳回)")
|
||||
|
// private Byte status;
|
||||
|
// @ApiModelProperty("分数")
|
||||
|
// private String score;
|
||||
|
// @ApiModelProperty("评论")
|
||||
|
// private String remark;
|
||||
|
// }
|
||||
|
//
|
||||
|
// @Data
|
||||
|
// @ApiModel("提交交付物")
|
||||
|
// public static class SaveDeliver{
|
||||
|
// @NotNull(message = "请选择项目")
|
||||
|
// @ApiModelProperty("项目id")
|
||||
|
// private Long projectId;
|
||||
|
// @NotNull(message = "请选择任务")
|
||||
|
// @ApiModelProperty("分解任务id")
|
||||
|
// private Long taskSubId;
|
||||
|
// @ApiModelProperty("文本内容")
|
||||
|
// private String content;
|
||||
|
// @ApiModelProperty("文件信息")
|
||||
|
// private List<FileVo.FileInfo> fileInfoList;
|
||||
|
//// @ApiModelProperty("文件id")
|
||||
|
//// private Long fileId;
|
||||
|
//// @ApiModelProperty("文件路径")
|
||||
|
//// private String filePath;
|
||||
|
// @NotEmpty(message = "请选择检查人")
|
||||
|
// @ApiModelProperty("检查人列表")
|
||||
|
// private List<Long> checkerList;
|
||||
|
// }
|
||||
|
//
|
||||
|
// @Data
|
||||
|
// @ApiModel("查询任务的交付物历史")
|
||||
|
// public static class QueryDeliverOfTask{
|
||||
|
// @NotNull(message = "请选择项目信息")
|
||||
|
// @ApiModelProperty("项目id")
|
||||
|
// private Long projectId;
|
||||
|
// @NotNull(message = "请选择任务")
|
||||
|
// @ApiModelProperty("任务分解id")
|
||||
|
// private Long taskSubId;
|
||||
|
// }
|
||||
|
//
|
||||
|
// @Data
|
||||
|
// @ApiModel("查询项目的交付物历史")
|
||||
|
// public static class QueryDeliverOfProject {
|
||||
|
// @NotNull(message = "请选择项目信息")
|
||||
|
// @ApiModelProperty("项目id")
|
||||
|
// private Long projectId;
|
||||
|
// @ApiModelProperty("第几页")
|
||||
|
// @Min(value = 1)
|
||||
|
// private int pageNum = 1;
|
||||
|
// @ApiModelProperty("每页多少条")
|
||||
|
// @Min(value = 1)
|
||||
|
// @Max(value=100)
|
||||
|
// private int pageSize = 10;
|
||||
|
// }
|
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,150 @@ |
|||||
|
package com.ccsens.ptccsens.bean.vo; |
||||
|
|
||||
|
import io.swagger.annotations.ApiModel; |
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.math.BigDecimal; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @author 逗 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class DeliverVo { |
||||
|
|
||||
|
@Data |
||||
|
@ApiModel("查询任务下的交付物信息") |
||||
|
public static class DeliverOfTask{ |
||||
|
@ApiModelProperty("交付物id") |
||||
|
private Long deliverId; |
||||
|
@ApiModelProperty("交付物名字") |
||||
|
private String deliverName; |
||||
|
@ApiModelProperty("交付物提交记录id") |
||||
|
private Long deliverRecordId; |
||||
|
@ApiModelProperty("文件路径") |
||||
|
private List<String> details; |
||||
|
@ApiModelProperty("提交时间") |
||||
|
private Long submitTime; |
||||
|
@ApiModelProperty("提交人Id") |
||||
|
private Long submitMemberId; |
||||
|
@ApiModelProperty("提交人名称") |
||||
|
private String submitMemberName; |
||||
|
@ApiModelProperty("检查人列表") |
||||
|
private List<CheckerInfo> checkerList; |
||||
|
} |
||||
|
|
||||
|
@Data |
||||
|
@ApiModel("检查人信息") |
||||
|
public static class CheckerInfo{ |
||||
|
@ApiModelProperty("检查记录id") |
||||
|
private Long checkId; |
||||
|
@ApiModelProperty("检查人id") |
||||
|
private Long checkerId; |
||||
|
@ApiModelProperty("检查人名字") |
||||
|
private String checkerName; |
||||
|
@ApiModelProperty("检查状态(0-未审核,1-通过,2-驳回)") |
||||
|
private Byte status; |
||||
|
@ApiModelProperty("分数") |
||||
|
private BigDecimal score; |
||||
|
@ApiModelProperty("备注") |
||||
|
private String remark; |
||||
|
@ApiModelProperty("是不是我(0-否,1-是)") |
||||
|
private Byte isMine; |
||||
|
@ApiModelProperty("检查时间") |
||||
|
private Long checkTime; |
||||
|
} |
||||
|
|
||||
|
@Data |
||||
|
@ApiModel("查询交付物提交记录") |
||||
|
public static class QueryDeliverRecord{ |
||||
|
@ApiModelProperty("交付物id") |
||||
|
private Long deliverId; |
||||
|
@ApiModelProperty("交付物名字") |
||||
|
private String deliverName; |
||||
|
@ApiModelProperty("交付物提交id") |
||||
|
private List<DeliverRecord> deliverRecordList; |
||||
|
} |
||||
|
@Data |
||||
|
@ApiModel("交付物提交记录") |
||||
|
public static class DeliverRecord{ |
||||
|
@ApiModelProperty("交付物提交记录id") |
||||
|
private Long deliverRecordId; |
||||
|
@ApiModelProperty("文件路径") |
||||
|
private List<String> details; |
||||
|
@ApiModelProperty("提交时间") |
||||
|
private Long submitTime; |
||||
|
@ApiModelProperty("检查人列表") |
||||
|
private List<CheckerInfo> checkerList; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
// @Data
|
||||
|
// @ApiModel("检查人信息")
|
||||
|
// public static class CheckerInfo{
|
||||
|
// @ApiModelProperty("检查记录id")
|
||||
|
// private String checkId;
|
||||
|
// @ApiModelProperty("检查人id")
|
||||
|
// private Long checkerId;
|
||||
|
// @ApiModelProperty("检查人名字")
|
||||
|
// private String checkerName;
|
||||
|
// @ApiModelProperty("检查状态(0-未审核,1-通过,2-驳回)")
|
||||
|
// private Byte status;
|
||||
|
// @ApiModelProperty("分数")
|
||||
|
// private String score;
|
||||
|
// @ApiModelProperty("备注")
|
||||
|
// private String remark;
|
||||
|
// @ApiModelProperty("是不是我(0-否,1-是)")
|
||||
|
// private Byte isMine;
|
||||
|
//
|
||||
|
// }
|
||||
|
//
|
||||
|
@Data |
||||
|
@ApiModel("所有检查人信息") |
||||
|
public static class Checker{ |
||||
|
@ApiModelProperty("检查人id") |
||||
|
private Long memberId; |
||||
|
@ApiModelProperty("检查人名字") |
||||
|
private String name; |
||||
|
@ApiModelProperty("用户id") |
||||
|
private Long userId; |
||||
|
@ApiModelProperty("是不是我(0-否,1-是)") |
||||
|
private Byte isMine = 0; |
||||
|
} |
||||
|
//
|
||||
|
//
|
||||
|
// @Data
|
||||
|
// @ApiModel("项目下的交付物记录")
|
||||
|
// public static class DeliverOfProject{
|
||||
|
// @ApiModelProperty("项目名称")
|
||||
|
// private String projectName;
|
||||
|
// @ApiModelProperty("任务列表")
|
||||
|
// private List<DeliverOfTask> deliverOfTaskList;
|
||||
|
// }
|
||||
|
//
|
||||
|
// @Data
|
||||
|
// @ApiModel("任务的交付物历史")
|
||||
|
// public static class DeliverOfTask{
|
||||
|
// @ApiModelProperty("交付物id")
|
||||
|
// private String id;
|
||||
|
// @ApiModelProperty("上传人名字")
|
||||
|
// private String name;
|
||||
|
// @ApiModelProperty("任务名称")
|
||||
|
// private String taskName;
|
||||
|
// @ApiModelProperty("上传时间")
|
||||
|
// private Long time;
|
||||
|
// @ApiModelProperty("文本内容")
|
||||
|
// private String content;
|
||||
|
// @ApiModelProperty("文件信息")
|
||||
|
// private List<FileVo.FileInfo> fileInfoList;
|
||||
|
//// @ApiModelProperty("文件id")
|
||||
|
//// private Long fileId;
|
||||
|
//// @ApiModelProperty("文件路径")
|
||||
|
//// private String filePath;
|
||||
|
// @ApiModelProperty("检查人列表")
|
||||
|
// private List<CheckerInfo> checkerList;
|
||||
|
// }
|
||||
|
|
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,25 @@ |
|||||
|
package com.ccsens.ptccsens.bean.vo; |
||||
|
|
||||
|
import com.alibaba.fastjson.annotation.JSONField; |
||||
|
import io.swagger.annotations.ApiModel; |
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
@Data |
||||
|
public class OcrVo { |
||||
|
|
||||
|
@Data |
||||
|
@ApiModel("发票信息") |
||||
|
public static class BillInfo { |
||||
|
@ApiModelProperty("发票代码") |
||||
|
private String invoiceCode; |
||||
|
@ApiModelProperty("发票号码") |
||||
|
private String invoiceNum; |
||||
|
@ApiModelProperty("金额") |
||||
|
private Long totalAmount; |
||||
|
@ApiModelProperty("税额") |
||||
|
private Long totalTax; |
||||
|
@ApiModelProperty("开票时间") |
||||
|
private Long invoiceDate; |
||||
|
} |
||||
|
} |
@ -0,0 +1,24 @@ |
|||||
|
package com.ccsens.ptccsens.persist.dao; |
||||
|
|
||||
|
|
||||
|
import com.ccsens.ptccsens.bean.vo.DeliverVo; |
||||
|
import org.apache.ibatis.annotations.Param; |
||||
|
import org.springframework.stereotype.Repository; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
@Repository |
||||
|
public interface ProDeliverDao{ |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 查询所有检查人 |
||||
|
* @param projectId 项目id |
||||
|
* @param userId userId |
||||
|
* @return 检查人列表 |
||||
|
*/ |
||||
|
List<DeliverVo.Checker> queryChecker(@Param("projectId") Long projectId, @Param("userId") Long userId); |
||||
|
|
||||
|
} |
@ -0,0 +1,26 @@ |
|||||
|
package com.ccsens.ptccsens.service; |
||||
|
|
||||
|
import com.ccsens.ptccsens.bean.dto.DeliverDto; |
||||
|
import com.ccsens.ptccsens.bean.vo.DeliverVo; |
||||
|
import com.ccsens.ptccsens.persist.dao.ProDeliverDao; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.transaction.annotation.Propagation; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
|
||||
|
import javax.annotation.Resource; |
||||
|
import java.util.List; |
||||
|
|
||||
|
@Slf4j |
||||
|
@Service |
||||
|
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) |
||||
|
public class DeliverService implements IDeliverService { |
||||
|
|
||||
|
@Resource |
||||
|
private ProDeliverDao deliverDao; |
||||
|
|
||||
|
@Override |
||||
|
public List<DeliverVo.Checker> queryChecker(DeliverDto.QueryChecker params, Long userId) { |
||||
|
return deliverDao.queryChecker(params.getProjectId(),userId); |
||||
|
} |
||||
|
} |
@ -0,0 +1,16 @@ |
|||||
|
package com.ccsens.ptccsens.service; |
||||
|
|
||||
|
import com.ccsens.ptccsens.bean.dto.DeliverDto; |
||||
|
import com.ccsens.ptccsens.bean.vo.DeliverVo; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
public interface IDeliverService { |
||||
|
/** |
||||
|
* 查询所有检查人 |
||||
|
* @param params 项目id |
||||
|
* @param userId 用户id |
||||
|
* @return 检查人列表 |
||||
|
*/ |
||||
|
List<DeliverVo.Checker> queryChecker(DeliverDto.QueryChecker params, Long userId); |
||||
|
} |
@ -0,0 +1,14 @@ |
|||||
|
package com.ccsens.ptccsens.service; |
||||
|
|
||||
|
import com.ccsens.ptccsens.bean.vo.OcrVo; |
||||
|
|
||||
|
import java.text.ParseException; |
||||
|
|
||||
|
public interface IOcrService { |
||||
|
/** |
||||
|
* 发票识别 |
||||
|
* @param img 发表base64 |
||||
|
* @return 识别结果 |
||||
|
*/ |
||||
|
OcrVo.BillInfo identifyBill(String img) throws ParseException; |
||||
|
} |
@ -0,0 +1,52 @@ |
|||||
|
package com.ccsens.ptccsens.service; |
||||
|
|
||||
|
import cn.hutool.core.bean.BeanUtil; |
||||
|
import cn.hutool.core.collection.CollectionUtil; |
||||
|
import cn.hutool.core.util.StrUtil; |
||||
|
import com.alibaba.druid.sql.visitor.functions.If; |
||||
|
import com.ccsens.ptccsens.bean.vo.OcrVo; |
||||
|
import com.ccsens.ptccsens.util.BasicsConstant; |
||||
|
import com.ccsens.util.RestTemplateUtil; |
||||
|
import com.ccsens.util.baidu.BaiDuDto; |
||||
|
import com.ccsens.util.baidu.BaiDuUtil; |
||||
|
import com.ccsens.util.baidu.BaiDuVo; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.transaction.annotation.Propagation; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
|
||||
|
import java.math.BigDecimal; |
||||
|
import java.text.ParseException; |
||||
|
import java.text.SimpleDateFormat; |
||||
|
|
||||
|
@Service |
||||
|
@Slf4j |
||||
|
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) |
||||
|
public class OcrService implements IOcrService{ |
||||
|
|
||||
|
@Override |
||||
|
public OcrVo.BillInfo identifyBill(String img) throws ParseException { |
||||
|
// 图像识别
|
||||
|
BaiDuDto.GeneralBasic basic = new BaiDuDto.GeneralBasic(); |
||||
|
basic.setImage(img); |
||||
|
BaiDuVo.BillBasic words = BaiDuUtil.billBasic(BasicsConstant.BaiDu.INVOICE_APP_KEY, BasicsConstant.BaiDu.INVOICE_SECRET_KEY, basic); |
||||
|
log.info("识别结果:{}",words); |
||||
|
// String token = BaiDuUtil.getToken(BasicsConstant.BaiDu.INVOICE_APP_KEY, BasicsConstant.BaiDu.INVOICE_SECRET_KEY);
|
||||
|
// String invoiceUrl = "https://aip.baidubce.com/rest/2.0/ocr/v1/vat_invoice?access_token={}";
|
||||
|
// String url = StrUtil.format(invoiceUrl, token);
|
||||
|
// String result = RestTemplateUtil.postUrlEncode(url, basic);
|
||||
|
// log.info("result:{}", result);
|
||||
|
// 返回数据
|
||||
|
OcrVo.BillInfo billInfo = new OcrVo.BillInfo(); |
||||
|
if (CollectionUtil.isNotEmpty(words.getWordsResult())) { |
||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd"); |
||||
|
BeanUtil.copyProperties(words.getWordsResult().get(0),billInfo); |
||||
|
billInfo.setTotalAmount(new BigDecimal(words.getWordsResult().get(0).getTotalAmount()).multiply(BigDecimal.valueOf(100)).longValue()); |
||||
|
billInfo.setTotalTax(new BigDecimal(words.getWordsResult().get(0).getTotalTax()).multiply(BigDecimal.valueOf(100)).longValue()); |
||||
|
billInfo.setInvoiceDate(sdf.parse(words.getWordsResult().get(0).getInvoiceDate()).getTime()); |
||||
|
|
||||
|
} |
||||
|
// personMsg.toMsg(words.getWordsResult());
|
||||
|
return billInfo; |
||||
|
} |
||||
|
} |
@ -0,0 +1,20 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
|
<mapper namespace="com.ccsens.ptccsens.persist.dao.ProDeliverDao"> |
||||
|
|
||||
|
|
||||
|
|
||||
|
<select id="queryChecker" resultType="com.ccsens.ptccsens.bean.vo.DeliverVo$Checker"> |
||||
|
SELECT |
||||
|
id AS memberId, |
||||
|
`name`, |
||||
|
user_id, |
||||
|
if(user_id = #{userId},1,0) as isMine |
||||
|
FROM |
||||
|
t_pro_member |
||||
|
WHERE |
||||
|
rec_status = 0 |
||||
|
AND project_id = #{projectId} |
||||
|
</select> |
||||
|
|
||||
|
</mapper> |
Loading…
Reference in new issue