123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299 |
- package com.pj.project.tb_business;
- import java.util.Date;
- import java.util.List;
- import cn.dev33.satoken.stp.StpUtil;
- import cn.hutool.core.date.DateUtil;
- import cn.hutool.core.util.StrUtil;
- import com.pj.constants.UserTypeEnum;
- import com.pj.project.tb_business_item.TbBusinessItem;
- import com.pj.project.tb_business_item.TbBusinessItemService;
- import com.pj.project.tb_notices.TbNoticesService;
- import com.pj.project.tb_pass_record.TbPassRecord;
- import com.pj.project.tb_pass_record.TbPassRecordService;
- import com.pj.utils.so.SoMap;
- import org.aspectj.weaver.loadtime.Aj;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.transaction.annotation.Transactional;
- import org.springframework.web.bind.annotation.*;
- import com.pj.utils.sg.*;
- import com.pj.project4sp.SP;
- import com.pj.current.satoken.StpUserUtil;
- import cn.dev33.satoken.annotation.SaCheckPermission;
- import javax.annotation.Resource;
- /**
- * Controller: tb_business -- 入境登记
- *
- * @author qzy
- */
- @RestController
- @RequestMapping("/TbBusiness/")
- public class TbBusinessController {
- /**
- * 底层 Service 对象
- */
- @Autowired
- TbBusinessService tbBusinessService;
- @Resource
- private TbBusinessItemService tbBusinessItemService;
- @Resource
- private TbPassRecordService tbPassRecordService;
- @Resource
- private TbNoticesService tbNoticesService;
- @RequestMapping(value = "getMsg")
- public AjaxJson getMsg(){
- return AjaxJson.getSuccessData(BusinessMessageManager.get(StpUserUtil.getCustomerId()));
- }
- /**
- * 增
- */
- @RequestMapping("add")
- @SaCheckPermission(TbBusiness.PERMISSION_CODE)
- @Transactional(rollbackFor = Exception.class)
- public AjaxJson add(TbBusiness t) {
- return tbBusinessService.addOrUpdate(t);
- }
- /**
- * 删
- */
- @RequestMapping("delete")
- @SaCheckPermission(TbBusiness.PERMISSION_INPUT)
- @Transactional(rollbackFor = Exception.class)
- public AjaxJson delete(String id) {
- TbBusiness db= tbBusinessService.getById(id);
- if (db!=null){
- tbBusinessService.storeMsg(db.getCustomerId(),"业务订单【"+db.getNo()+"】已删除。"+ DateUtil.now()+"。");
- }
- tbBusinessService.removeById(id);
- tbBusinessItemService.removeByBusinessId(id);
- tbPassRecordService.removeByBusinessId(id);
- return AjaxJson.getSuccess();
- }
- /**
- * 删 - 根据id列表
- */
- @RequestMapping("deleteByIds")
- @SaCheckPermission(TbBusiness.PERMISSION_CODE)
- @Transactional(rollbackFor = Exception.class)
- public AjaxJson deleteByIds() {
- List<Long> ids = SoMap.getRequestSoMap().getListByComma("ids", long.class);
- ids.forEach(id -> {
- tbBusinessItemService.removeByBusinessId(id + "");
- });
- int line = SP.publicMapper.deleteByIds(TbBusiness.TABLE_NAME, ids);
- return AjaxJson.getByLine(line);
- }
- /**
- * 改
- */
- @RequestMapping("update")
- @SaCheckPermission(TbBusiness.PERMISSION_CODE)
- public AjaxJson update(TbBusiness t) {
- tbBusinessService.addOrUpdate(t);
- return AjaxJson.getSuccess();
- }
- /**
- * 确认业务
- */
- @RequestMapping("confirm")
- @Transactional(rollbackFor = Exception.class)
- public AjaxJson confirm() {
- if (!StpUtil.hasPermissionAnd(TbBusiness.PERMISSION_CONFIRM) && !
- StrUtil.equals(StpUserUtil.getCustomerId(), UserTypeEnum.PLATFORM_ADMIN.getCustomerId())) {
- return AjaxJson.getError("无确认业务权限");
- }
- SoMap so = SoMap.getRequestSoMap();
- List<String> ids = so.getListByComma("ids", String.class);
- tbBusinessService.confirm(ids);
- return AjaxJson.getSuccess();
- }
- /**
- * 确认业务
- */
- @RequestMapping("adminConfirmPay")
- @Transactional(rollbackFor = Exception.class)
- public AjaxJson adminConfirmPay() {
- if (!StrUtil.equals(StpUserUtil.getCustomerId(), UserTypeEnum.PLATFORM_ADMIN.getCustomerId())) {
- return AjaxJson.getError("无确认支付权限");
- }
- SoMap so = SoMap.getRequestSoMap();
- List<String> ids = so.getListByComma("ids", String.class);
- String ticket = so.getString("payTicket");
- tbBusinessService.adminConfirmPay(ids, ticket);
- return AjaxJson.getSuccess();
- }
- /**
- * 手动入场确认 see adminSetIn
- */
- @RequestMapping("adminConfirmIn")
- @Transactional(rollbackFor = Exception.class)
- @Deprecated
- public AjaxJson adminConfirmIn() {
- if (!StrUtil.equals(StpUserUtil.getCustomerId(), UserTypeEnum.PLATFORM_ADMIN.getCustomerId())) {
- return AjaxJson.getError("无确认入场权限");
- }
- SoMap so = SoMap.getRequestSoMap();
- String id = so.getString("id");
- String inChannel = so.getString("inChannel");
- tbBusinessService.adminConfirmIn(id, inChannel);
- return AjaxJson.getSuccess();
- }
- /**
- * 查 - 根据id
- */
- @RequestMapping("getById")
- public AjaxJson getById(String id) {
- TbBusiness t = tbBusinessService.getById(id);
- List<TbBusinessItem> items = tbBusinessItemService.findByBusinessId(id);
- t.setItems(items);
- return AjaxJson.getSuccessData(t);
- }
- /**
- * 查集合 - 根据条件(参数为空时代表忽略指定条件)
- */
- @RequestMapping("getList")
- public AjaxJson getList() {
- SoMap so = SoMap.getRequestSoMap();
- String currentCustomerId = StpUserUtil.getCustomerId();
- if (!currentCustomerId.equals(UserTypeEnum.PLATFORM_ADMIN.getCustomerId())) {
- so.put("customerId", currentCustomerId);
- }
- List<TbBusiness> list = tbBusinessService.getList(so.startPage());
- return AjaxJson.getPageData(so.getDataCount(), list);
- }
- /**
- * 改
- */
- @RequestMapping("pay")
- public AjaxJson pay() {
- if (!StpUtil.hasPermissionAnd("tb-business-pay") && !
- StrUtil.equals(StpUserUtil.getCustomerId(), UserTypeEnum.PLATFORM_ADMIN.getCustomerId())) {
- return AjaxJson.getError("无支付权限");
- }
- SoMap so = SoMap.getRequestSoMap();
- String id = so.getString("id");
- String payTicket = so.getString("payTicket");
- tbBusinessService.pay(id, payTicket);
- return AjaxJson.getSuccess();
- }
- @RequestMapping("adminSetIn")
- public AjaxJson adminSetIn() {
- if (!StrUtil.equals(StpUserUtil.getCustomerId(), UserTypeEnum.PLATFORM_ADMIN.getCustomerId())) {
- return AjaxJson.getError("无入场权限");
- }
- SoMap so = SoMap.getRequestSoMap();
- String id = so.getString("id");
- Date inTime = so.getDateTime("realInTime");
- Date chinaCarInTime = so.getDateTime("chinaCarInTime");
- TbBusiness tbBusiness = tbBusinessService.getById(id);
- tbBusiness.setChinaCarInTime(chinaCarInTime).setRealInTime(inTime).setAdminConfirmIn(1);
- tbBusinessService.updateById(tbBusiness);
- //更新境外车入场记录
- tbPassRecordService.addOrUpdate(tbBusiness.getId(), tbBusiness.getCustomerId(), tbBusiness.getCustomerName(),
- tbBusiness.getCardNo(), 2, tbBusiness.getRealInTime(), null, tbBusiness.getCountryName());
- //更新中国车入场记录
- tbPassRecordService.addOrUpdate(tbBusiness.getId(), tbBusiness.getCustomerId(), tbBusiness.getCustomerName(),
- tbBusiness.getChinaCarNo(), 2, tbBusiness.getChinaCarInTime(), null, "中国车");
- //发送消息
- String text = "您的车辆已入场,业务单号["+ tbBusiness.getNo() + "]";
- tbNoticesService.sendNotice(tbBusiness.getId(), tbBusiness.getNo(), tbBusiness.getCustomerId(), text);
- return AjaxJson.getSuccess();
- }
- @RequestMapping("adminOut")
- public AjaxJson adminOut(){
- if (!StrUtil.equals(StpUserUtil.getCustomerId(), UserTypeEnum.PLATFORM_ADMIN.getCustomerId())) {
- return AjaxJson.getError("无离场权限");
- }
- SoMap so = SoMap.getRequestSoMap();
- String id = so.getString("id");
- TbBusiness business= tbBusinessService.getById(id);
- Date outTime=so.getDateTime("outDayTime");
- if (business.getRealInTime().getTime()>outTime.getTime()) {
- return AjaxJson.getError("离场时间须大于出场时间");
- }
- business.setOutDayTime(outTime);
- tbBusinessService. calculationPartMoney("越南车",business);
- tbBusinessService.updateById(business);
- Date chinaCarOutTime=so.getDateTime("chinaCarOutTime");
- if (chinaCarOutTime.getTime()<business.getChinaCarInTime().getTime()){
- return AjaxJson.getError("离场时间须大于出场时间");
- }
- business.setChinaCarOutTime(chinaCarOutTime);
- tbBusinessService. calculationPartMoney("中国车",business);
- business.setAdminConfirmOut(1);
- tbBusinessService.updateById(business);
- //更新境外车出场记录
- tbPassRecordService.addOrUpdate(business.getId(), business.getCustomerId(), business.getCustomerName(),
- business.getCardNo(), 3,
- business.getRealInTime(), business.getOutDayTime(), business.getCountryName());
- //更新中国车出场记录
- tbPassRecordService.addOrUpdate(business.getId(), business.getCustomerId(), business.getCustomerName(),
- business.getChinaCarNo(), 3,
- business.getChinaCarInTime(), business.getChinaCarOutTime(), "中国车");
- tbBusinessService.storeMsg(business.getCustomerId(), "业务订单【"+business.getNo()+"】已完成作业离场"+ DateUtil.now()+"。");
- //发送消息
- String text = "您的车辆已离场,业务单号["+ business.getNo() + "]";
- tbNoticesService.sendNotice(business.getId(), business.getNo(), business.getCustomerId(), text);
- return AjaxJson.getSuccess();
- }
- @RequestMapping("calJwPartMoney")
- public AjaxJson calJwPartMoney(TbBusiness business) {
- if (!StrUtil.equals(StpUserUtil.getCustomerId(), UserTypeEnum.PLATFORM_ADMIN.getCustomerId())) {
- return AjaxJson.getError("无生成账单权限");
- }
- tbBusinessService.calculationPartMoney("越南车", business);
- return AjaxJson.getSuccessData(business);
- }
- @RequestMapping("calChinaPartMoney")
- public AjaxJson calChinaPartMoney(TbBusiness business) {
- if (!StrUtil.equals(StpUserUtil.getCustomerId(), UserTypeEnum.PLATFORM_ADMIN.getCustomerId())) {
- return AjaxJson.getError("无生成账单权限");
- }
- tbBusinessService.calculationPartMoney("中国车", business);
- return AjaxJson.getSuccessData(business);
- }
- @RequestMapping("complete")
- public AjaxJson complete(TbBusiness business) {
- if (!StrUtil.equals(StpUserUtil.getCustomerId(), UserTypeEnum.PLATFORM_ADMIN.getCustomerId())) {
- return AjaxJson.getError("无生成账单权限");
- }
- business.setComplete(1);
- tbBusinessService.updateById(business);
- tbBusinessService.storeMsg(business.getCustomerId(), "业务订单【"+business.getNo()+"】账单已生成!"+ DateUtil.now()+"。");
- //发送消息
- String text = "您的账单已生成,业务单号["+ business.getNo() + "]";
- tbNoticesService.sendNotice(business.getId(), business.getNo(), business.getCustomerId(), text);
- return AjaxJson.getSuccessData(business);
- }
- // ------------------------- 前端接口 -------------------------
- }
|