package com.ltkj.web.controller.system;
|
|
import cn.hutool.core.date.DateUtil;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.google.common.base.Joiner;
|
import com.ltkj.common.core.domain.AjaxResult;
|
import com.ltkj.common.utils.SecurityUtils;
|
import com.ltkj.framework.config.UserHoder;
|
import com.ltkj.hosp.domain.TjSummary;
|
import com.ltkj.hosp.domain.TjTollCollector;
|
import com.ltkj.hosp.service.ITjSummaryService;
|
import com.ltkj.hosp.service.ITjTollCollectorService;
|
import com.ltkj.system.service.ISysConfigService;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiParam;
|
import org.springframework.web.bind.annotation.*;
|
import javax.annotation.Resource;
|
import java.math.BigDecimal;
|
import java.text.SimpleDateFormat;
|
import java.util.Date;
|
import java.util.List;
|
|
/**
|
* @Company: 西安路泰科技有限公司
|
* @Author: zjh
|
* @Date: 2023/10/16 09:02
|
*/
|
@RestController
|
@RequestMapping("/hosp/summary")
|
@Api(tags = "PC端 汇总结账接口")
|
public class TjSummaryController {
|
@Resource
|
private ITjTollCollectorService collectorService;
|
|
@Resource
|
private ITjSummaryService summaryService;
|
@Resource
|
private ISysConfigService configService;
|
|
|
@GetMapping("/getTjSummaryList")
|
@ApiOperation(value = "查询汇总单据信息接口")
|
public AjaxResult getTjSummaryList(@RequestParam(required = false) @ApiParam(value = "收费员id") String tollCollectorId,
|
@RequestParam(required = false) @ApiParam(value = "起始时间") String accountBeginTime,
|
@RequestParam(required = false) @ApiParam(value = "起始时间") String accountEndTime) {
|
|
LambdaQueryWrapper<TjSummary> wqq = new LambdaQueryWrapper<>();
|
if (null != tollCollectorId) {
|
wqq.eq(TjSummary::getHzUserId, tollCollectorId);
|
}
|
if (null != accountBeginTime && null != accountEndTime) {
|
wqq.between(TjSummary::getCreateTime, accountBeginTime, accountEndTime);
|
}
|
wqq.orderByDesc(TjSummary::getCreateTime);
|
List<TjSummary> list= summaryService.list(wqq);
|
if(null !=list && list.size()>0){
|
for (TjSummary summary : list) {
|
String accountId = summary.getAccountId();
|
String[] split = accountId.split(";");
|
LambdaQueryWrapper<TjTollCollector> wq = new LambdaQueryWrapper<>();
|
wq.in(TjTollCollector::getId, (Object[]) split);
|
summary.setCollectorList(collectorService.list(wq));
|
}
|
}
|
return AjaxResult.success(list);
|
}
|
|
|
@GetMapping("/list")
|
@ApiOperation(value = "查询收费员日结未汇总单据信息")
|
public AjaxResult list(@RequestParam(required = false) @ApiParam(value = "收费员id") String tollCollectorId,
|
@RequestParam(required = false) @ApiParam(value = "起始时间") String accountBeginTime,
|
@RequestParam(required = false) @ApiParam(value = "起始时间") String accountEndTime) {
|
|
LambdaQueryWrapper<TjTollCollector> wqq = new LambdaQueryWrapper<>();
|
if (null != tollCollectorId) {
|
wqq.eq(TjTollCollector::getTollCollectorId, tollCollectorId);
|
}
|
if (null != accountBeginTime && null != accountEndTime) {
|
wqq.between(TjTollCollector::getCreateTime, accountBeginTime, accountEndTime);
|
}
|
wqq.orderByDesc(TjTollCollector::getCreateTime);
|
wqq.isNull(TjTollCollector::getIsHz);
|
List<TjTollCollector> list= collectorService.list(wqq);
|
return AjaxResult.success(list);
|
}
|
|
|
|
@PostMapping("/addTjSummary")
|
@ApiOperation(value = "点击汇总 新增汇总信息接口")
|
public AjaxResult addTjSummary(@RequestBody List<String> ids) {
|
|
if(null !=ids && ids.size()>0){
|
String accountId = "HZ" + SecurityUtils.getUsername() + (new SimpleDateFormat("yyMMddHHmmssSSS").format(new Date()));
|
BigDecimal zshoukuan = new BigDecimal("0.00");
|
BigDecimal ztuikuan = new BigDecimal("0.00");
|
BigDecimal zyingjiao = new BigDecimal("0.00");
|
for (String id : ids) {
|
TjTollCollector collector = collectorService.getById(id);
|
if(null !=collector){
|
zshoukuan=zshoukuan.add(collector.getAmountReceived());
|
ztuikuan=ztuikuan.add(collector.getRefundAmount());
|
zyingjiao=zyingjiao.add(collector.getPayable());
|
collector.setIsHz(accountId);
|
collectorService.updateById(collector);
|
}
|
}
|
String join = Joiner.on(";").join(ids);
|
TjSummary summary=new TjSummary();
|
summary.setHzName(UserHoder.getLoginUser().getUser().getNickName());
|
summary.setHzUserId(Long.valueOf(UserHoder.getLoginUser().getUserId()));
|
summary.setHzCard(accountId);
|
summary.setHzSj("汇总结账");
|
summary.setAmountReceived(zshoukuan);
|
summary.setRefundAmount(ztuikuan);
|
summary.setPayable(zyingjiao);
|
summary.setAccountId(join);
|
summaryService.save(summary);
|
return AjaxResult.success(accountId);
|
}
|
return AjaxResult.error("请选择汇总单据");
|
}
|
|
|
@DeleteMapping("/removeTjSummaryById")
|
@ApiOperation(value = "汇总员撤销 汇总账单 接口")
|
public AjaxResult removeTjSummaryById(@RequestParam @ApiParam(value = "结账id") String id,
|
@RequestParam @ApiParam(value = "结账员id") String tollCollectorId) {
|
String userId = SecurityUtils.getLoginUser().getUserId();
|
if (!userId.equals(tollCollectorId)) {
|
return AjaxResult.error("非当前用户禁止操作");
|
}
|
TjSummary summary = summaryService.getById(id);
|
if (summaryService.removeById(id)) {
|
if (null != summary) {
|
String accountId = summary.getAccountId();
|
String[] split = accountId.split(";");
|
for (String s : split) {
|
TjTollCollector tollCollector = collectorService.getTjTollCollectorById(s);
|
tollCollector.setIsHz(null);
|
collectorService.updateById(tollCollector);
|
}
|
return AjaxResult.success("该账单已成功撤销");
|
}
|
return AjaxResult.success("该账单已撤销");
|
}
|
return AjaxResult.error("撤销失败");
|
}
|
|
|
@GetMapping("/getPrintSetUp")
|
@ApiOperation(value = "查询打印设置 0小票 1 发票")
|
public AjaxResult getPrintSetUp() {
|
String printSetUp = configService.selectConfigByKey("print_set_up");
|
return AjaxResult.success(printSetUp);
|
}
|
|
|
@GetMapping("/getLastTime")
|
@ApiOperation(value = "获取汇总时间起始时间")
|
public AjaxResult getLastTime() {
|
LambdaQueryWrapper<TjSummary> wq = new LambdaQueryWrapper<>();
|
wq.orderByDesc(TjSummary::getCreateTime);
|
List<TjSummary> list = summaryService.list(wq);
|
if (null != list && list.size() > 0) return AjaxResult.success(list.get(0).getCreateTime());
|
String dateStr = "2023-10-01 00:00:00";
|
Date date = DateUtil.parse(dateStr, "yyyy-MM-dd HH:mm:ss");
|
return AjaxResult.success(date);
|
}
|
|
}
|