修改查询交班数据

This commit is contained in:
牛叉闪闪 2024-08-05 14:31:09 +08:00
parent b8e1907d49
commit 13961cc6fc
11 changed files with 562 additions and 59 deletions

View File

@ -0,0 +1,133 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.ysk.cashier.cons.domain;
import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.persistence.*;
import javax.validation.constraints.*;
import java.sql.Timestamp;
import java.io.Serializable;
/**
* @author admin
* @date 2024-08-05
**/
@Entity
@Data
@Table(name="view_handover")
public class ViewHandover implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "`id`")
@ApiModelProperty(value = "id")
private Integer id;
@Column(name = "`trade_day`")
@ApiModelProperty(value = "交班日期")
private Integer tradeDay;
@Column(name = "`print_no`")
@ApiModelProperty(value = "打印机编号")
private String printNo;
@Column(name = "`duty_id`")
@ApiModelProperty(value = "dutyId")
private Integer dutyId;
@Column(name = "`shop_id`")
@ApiModelProperty(value = "shopId")
private Integer shopId;
@Column(name = "`merchant_name`")
@ApiModelProperty(value = "merchantName")
private String merchantName;
@Column(name = "`start_time`")
@ApiModelProperty(value = "startTime")
private String startTime;
@Column(name = "`end_time`")
@ApiModelProperty(value = "endTime")
private String endTime;
@Column(name = "`staff_id`")
@ApiModelProperty(value = "staffId")
private Integer staffId;
@Column(name = "`staff_name`")
@ApiModelProperty(value = "staffName")
private String staffName;
@Column(name = "`pay_infos`")
@ApiModelProperty(value = "payInfos")
private String payInfos;
@Column(name = "`member_data`")
@ApiModelProperty(value = "memberData")
private String memberData;
@Column(name = "`product_categories`")
@ApiModelProperty(value = "productCategories")
private String productCategories;
@Column(name = "`total_amount`")
@ApiModelProperty(value = "totalAmount")
private String totalAmount;
@Column(name = "`imprest`")
@ApiModelProperty(value = "imprest")
private String imprest;
@Column(name = "`payable`")
@ApiModelProperty(value = "payable")
private String payable;
@Column(name = "`hand_in`")
@ApiModelProperty(value = "handIn")
private String handIn;
@Column(name = "`return_amount`")
@ApiModelProperty(value = "returnAmount")
private String returnAmount;
@Column(name = "`order_num`")
@ApiModelProperty(value = "orderNum")
private String orderNum;
@Column(name = "`quick_amount`")
@ApiModelProperty(value = "quickAmount")
private String quickAmount;
@Column(name = "`product_info_pos`")
@ApiModelProperty(value = "productInfoPos")
private String productInfoPos;
@Column(name = "`product_infos`")
@ApiModelProperty(value = "productInfos")
private String productInfos;
@Column(name = "`create_time`")
@ApiModelProperty(value = "createTime")
private Timestamp createTime;
public void copy(ViewHandover source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
}

View File

@ -0,0 +1,13 @@
package cn.ysk.cashier.cons.repository;
import cn.ysk.cashier.cons.domain.ViewHandover;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* @website https://eladmin.vip
* @author admin
* @date 2024-08-05
**/
public interface ViewHandoverRepository extends JpaRepository<ViewHandover, Integer>, JpaSpecificationExecutor<ViewHandover> {
}

View File

@ -1,57 +1,57 @@
package cn.ysk.cashier.cons.rest;
import cn.ysk.cashier.annotation.Log;
import cn.ysk.cashier.cons.domain.TbHandover;
import cn.ysk.cashier.cons.service.TbHandoverService;
import cn.ysk.cashier.cons.service.dto.TbHandoverQueryCriteria;
import org.springframework.data.domain.Pageable;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
/**
* @author admin
* @date 2024-07-25
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "查询交班记录管理")
@RequestMapping("/api/tbHandover")
public class TbHandoverController {
private final TbHandoverService tbHandoverService;
@Log("导出数据")
@ApiOperation("导出数据")
@GetMapping(value = "/download")
public void exportTbHandover(HttpServletResponse response, TbHandoverQueryCriteria criteria) throws IOException {
tbHandoverService.download(tbHandoverService.queryAll(criteria), response);
}
@GetMapping
@ApiOperation("查询查询交班记录")
public ResponseEntity<Object> queryTbHandover(TbHandoverQueryCriteria criteria, Pageable pageable){
return new ResponseEntity<>(tbHandoverService.queryAll(criteria,pageable),HttpStatus.OK);
}
@PutMapping
@Log("修改查询交班记录")
@ApiOperation("修改查询交班记录")
public ResponseEntity<Object> updateTbHandover(@Validated @RequestBody TbHandover resources){
tbHandoverService.update(resources);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
@DeleteMapping
@Log("删除查询交班记录")
@ApiOperation("删除查询交班记录")
public ResponseEntity<Object> deleteTbHandover(@RequestBody Integer[] ids) {
tbHandoverService.deleteAll(ids);
return new ResponseEntity<>(HttpStatus.OK);
}
}
//package cn.ysk.cashier.cons.rest;
//
//import cn.ysk.cashier.annotation.Log;
//import cn.ysk.cashier.cons.domain.TbHandover;
//import cn.ysk.cashier.cons.service.TbHandoverService;
//import cn.ysk.cashier.cons.service.dto.TbHandoverQueryCriteria;
//import org.springframework.data.domain.Pageable;
//import lombok.RequiredArgsConstructor;
//import org.springframework.http.HttpStatus;
//import org.springframework.http.ResponseEntity;
//import org.springframework.validation.annotation.Validated;
//import org.springframework.web.bind.annotation.*;
//import io.swagger.annotations.*;
//import java.io.IOException;
//import javax.servlet.http.HttpServletResponse;
//
///**
//* @author admin
//* @date 2024-07-25
//**/
//@RestController
//@RequiredArgsConstructor
//@Api(tags = "查询交班记录管理")
//@RequestMapping("/api/tbHandover")
//public class TbHandoverController {
//
// private final TbHandoverService tbHandoverService;
//
// @Log("导出数据")
// @ApiOperation("导出数据")
// @GetMapping(value = "/download")
// public void exportTbHandover(HttpServletResponse response, TbHandoverQueryCriteria criteria) throws IOException {
// tbHandoverService.download(tbHandoverService.queryAll(criteria), response);
// }
//
// @GetMapping
// @ApiOperation("查询查询交班记录")
// public ResponseEntity<Object> queryTbHandover(TbHandoverQueryCriteria criteria, Pageable pageable){
// return new ResponseEntity<>(tbHandoverService.queryAll(criteria,pageable),HttpStatus.OK);
// }
//
// @PutMapping
// @Log("修改查询交班记录")
// @ApiOperation("修改查询交班记录")
// public ResponseEntity<Object> updateTbHandover(@Validated @RequestBody TbHandover resources){
// tbHandoverService.update(resources);
// return new ResponseEntity<>(HttpStatus.NO_CONTENT);
// }
//
// @DeleteMapping
// @Log("删除查询交班记录")
// @ApiOperation("删除查询交班记录")
// public ResponseEntity<Object> deleteTbHandover(@RequestBody Integer[] ids) {
// tbHandoverService.deleteAll(ids);
// return new ResponseEntity<>(HttpStatus.OK);
// }
//}

View File

@ -0,0 +1,64 @@
package cn.ysk.cashier.cons.rest;
import cn.ysk.cashier.annotation.Log;
import cn.ysk.cashier.cons.domain.ViewHandover;
import cn.ysk.cashier.cons.service.ViewHandoverService;
import cn.ysk.cashier.cons.service.dto.ViewHandoverQueryCriteria;
import org.springframework.data.domain.Pageable;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
/**
* @author admin
* @date 2024-08-05
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "交班查询管理")
@RequestMapping("/api/tbHandover")
public class ViewHandoverController {
private final ViewHandoverService viewHandoverService;
@Log("导出数据")
@ApiOperation("导出数据")
@GetMapping(value = "/download")
public void exportViewHandover(HttpServletResponse response, ViewHandoverQueryCriteria criteria) throws IOException {
viewHandoverService.download(viewHandoverService.queryAll(criteria), response);
}
@GetMapping
@ApiOperation("查询交班查询")
public ResponseEntity<Object> queryViewHandover(ViewHandoverQueryCriteria criteria, Pageable pageable){
return new ResponseEntity<>(viewHandoverService.queryAll(criteria,pageable),HttpStatus.OK);
}
@PostMapping
@Log("新增交班查询")
@ApiOperation("新增交班查询")
public ResponseEntity<Object> createViewHandover(@Validated @RequestBody ViewHandover resources){
return new ResponseEntity<>(viewHandoverService.create(resources),HttpStatus.CREATED);
}
@PutMapping
@Log("修改交班查询")
@ApiOperation("修改交班查询")
public ResponseEntity<Object> updateViewHandover(@Validated @RequestBody ViewHandover resources){
viewHandoverService.update(resources);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
@DeleteMapping
@Log("删除交班查询")
@ApiOperation("删除交班查询")
public ResponseEntity<Object> deleteViewHandover(@RequestBody Integer[] ids) {
viewHandoverService.deleteAll(ids);
return new ResponseEntity<>(HttpStatus.OK);
}
}

View File

@ -0,0 +1,66 @@
package cn.ysk.cashier.cons.service;
import cn.ysk.cashier.cons.domain.ViewHandover;
import cn.ysk.cashier.cons.service.dto.ViewHandoverDto;
import cn.ysk.cashier.cons.service.dto.ViewHandoverQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.util.Map;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
/**
* @author admin
* @date 2024-08-05
**/
public interface ViewHandoverService {
/**
* 查询数据分页
* @param criteria 条件
* @param pageable 分页参数
* @return Map<String,Object>
*/
Map<String,Object> queryAll(ViewHandoverQueryCriteria criteria, Pageable pageable);
/**
* 查询所有数据不分页
* @param criteria 条件参数
* @return List<ViewHandoverDto>
*/
List<ViewHandoverDto> queryAll(ViewHandoverQueryCriteria criteria);
/**
* 根据ID查询
* @param id ID
* @return ViewHandoverDto
*/
ViewHandoverDto findById(Integer id);
/**
* 创建
* @param resources /
* @return ViewHandoverDto
*/
ViewHandoverDto create(ViewHandover resources);
/**
* 编辑
* @param resources /
*/
void update(ViewHandover resources);
/**
* 多选删除
* @param ids /
*/
void deleteAll(Integer[] ids);
/**
* 导出数据
* @param all 待导出的数据
* @param response /
* @throws IOException /
*/
void download(List<ViewHandoverDto> all, HttpServletResponse response) throws IOException;
}

View File

@ -0,0 +1,76 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.ysk.cashier.cons.service.dto;
import lombok.Data;
import java.sql.Timestamp;
import java.io.Serializable;
/**
* @author admin
* @date 2024-08-05
**/
@Data
public class ViewHandoverDto implements Serializable {
private Integer id;
/** 交班日期 */
private Integer tradeDay;
/** 打印机编号 */
private String printNo;
private Integer dutyId;
private Integer shopId;
private String merchantName;
private String startTime;
private String endTime;
private Integer staffId;
private String staffName;
private String payInfos;
private String memberData;
private String productCategories;
private String totalAmount;
private String imprest;
private String payable;
private String handIn;
private String returnAmount;
private String orderNum;
private String quickAmount;
private String productInfoPos;
private String productInfos;
private Timestamp createTime;
}

View File

@ -0,0 +1,24 @@
package cn.ysk.cashier.cons.service.dto;
import lombok.Data;
import java.util.List;
import cn.ysk.cashier.annotation.Query;
/**
* @author admin
* @date 2024-08-05
**/
@Data
public class ViewHandoverQueryCriteria{
/** 精确 */
@Query
private Integer shopId;
/** 精确 */
@Query
private String merchantName;
/** BETWEEN */
@Query(type = Query.Type.BETWEEN)
private List<Integer> tradeDay;
}

View File

@ -279,9 +279,9 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
flow.setBizName("耗材出库");
flow.setBizType("-");
purveyorTransact.setTotalAmount(resources.getAccountsPayable().negate());
purveyorTransact.setPaidAmount(resources.getActualPayment());
purveyorTransact.setTotalAmount(resources.getAccountsPayable().negate());
purveyorTransact.setWaitAmount((resources.getAccountsPayable().subtract(resources.getActualPayment())).negate());
purveyorTransact.setType("cons_out");
object.put("number",conInfos.getStockNumber());

View File

@ -37,6 +37,7 @@ public class TbHandoverServiceImpl implements TbHandoverService {
@Override
public Map<String,Object> queryAll(TbHandoverQueryCriteria criteria, Pageable pageable){
Page<TbHandover> page = tbHandoverRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
return PageUtil.toPage(page.map(tbHandoverMapper::toDto));
}

View File

@ -0,0 +1,110 @@
package cn.ysk.cashier.cons.service.impl;
import cn.ysk.cashier.cons.domain.ViewHandover;
import cn.ysk.cashier.utils.FileUtil;
import cn.ysk.cashier.utils.PageUtil;
import cn.ysk.cashier.utils.QueryHelp;
import cn.ysk.cashier.utils.ValidationUtil;
import lombok.RequiredArgsConstructor;
import cn.ysk.cashier.cons.repository.ViewHandoverRepository;
import cn.ysk.cashier.cons.service.ViewHandoverService;
import cn.ysk.cashier.cons.service.dto.ViewHandoverDto;
import cn.ysk.cashier.cons.service.dto.ViewHandoverQueryCriteria;
import cn.ysk.cashier.cons.service.mapstruct.ViewHandoverMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import java.util.List;
import java.util.Map;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.LinkedHashMap;
/**
* @website https://eladmin.vip
* @description 服务实现
* @author admin
* @date 2024-08-05
**/
@Service
@RequiredArgsConstructor
public class ViewHandoverServiceImpl implements ViewHandoverService {
private final ViewHandoverRepository viewHandoverRepository;
private final ViewHandoverMapper viewHandoverMapper;
@Override
public Map<String,Object> queryAll(ViewHandoverQueryCriteria criteria, Pageable pageable){
Page<ViewHandover> page = viewHandoverRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
return PageUtil.toPage(page.map(viewHandoverMapper::toDto));
}
@Override
public List<ViewHandoverDto> queryAll(ViewHandoverQueryCriteria criteria){
return viewHandoverMapper.toDto(viewHandoverRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
}
@Override
@Transactional
public ViewHandoverDto findById(Integer id) {
ViewHandover viewHandover = viewHandoverRepository.findById(id).orElseGet(ViewHandover::new);
ValidationUtil.isNull(viewHandover.getId(),"ViewHandover","id",id);
return viewHandoverMapper.toDto(viewHandover);
}
@Override
@Transactional(rollbackFor = Exception.class)
public ViewHandoverDto create(ViewHandover resources) {
return viewHandoverMapper.toDto(viewHandoverRepository.save(resources));
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(ViewHandover resources) {
ViewHandover viewHandover = viewHandoverRepository.findById(resources.getId()).orElseGet(ViewHandover::new);
ValidationUtil.isNull( viewHandover.getId(),"ViewHandover","id",resources.getId());
viewHandover.copy(resources);
viewHandoverRepository.save(viewHandover);
}
@Override
public void deleteAll(Integer[] ids) {
for (Integer id : ids) {
viewHandoverRepository.deleteById(id);
}
}
@Override
public void download(List<ViewHandoverDto> all, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (ViewHandoverDto viewHandover : all) {
Map<String,Object> map = new LinkedHashMap<>();
map.put("交班日期", viewHandover.getTradeDay());
map.put("打印机编号", viewHandover.getPrintNo());
map.put(" dutyId", viewHandover.getDutyId());
map.put(" shopId", viewHandover.getShopId());
map.put(" merchantName", viewHandover.getMerchantName());
map.put(" startTime", viewHandover.getStartTime());
map.put(" endTime", viewHandover.getEndTime());
map.put(" staffId", viewHandover.getStaffId());
map.put(" staffName", viewHandover.getStaffName());
map.put(" payInfos", viewHandover.getPayInfos());
map.put(" memberData", viewHandover.getMemberData());
map.put(" productCategories", viewHandover.getProductCategories());
map.put(" totalAmount", viewHandover.getTotalAmount());
map.put(" imprest", viewHandover.getImprest());
map.put(" payable", viewHandover.getPayable());
map.put(" handIn", viewHandover.getHandIn());
map.put(" returnAmount", viewHandover.getReturnAmount());
map.put(" orderNum", viewHandover.getOrderNum());
map.put(" quickAmount", viewHandover.getQuickAmount());
map.put(" productInfoPos", viewHandover.getProductInfoPos());
map.put(" productInfos", viewHandover.getProductInfos());
map.put(" createTime", viewHandover.getCreateTime());
list.add(map);
}
FileUtil.downloadExcel(list, response);
}
}

View File

@ -0,0 +1,16 @@
package cn.ysk.cashier.cons.service.mapstruct;
import cn.ysk.cashier.base.BaseMapper;
import cn.ysk.cashier.cons.domain.ViewHandover;
import cn.ysk.cashier.cons.service.dto.ViewHandoverDto;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
/**
* @author admin
* @date 2024-08-05
**/
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface ViewHandoverMapper extends BaseMapper<ViewHandoverDto, ViewHandover> {
}