123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 |
- package com.ruoyi.basicData.service.impl;
- import com.ruoyi.basicData.domain.TFees;
- import com.ruoyi.basicData.domain.TGoods;
- import com.ruoyi.basicData.mapper.TFeesMapper;
- import com.ruoyi.basicData.service.ITFeesService;
- import com.ruoyi.common.constant.UserConstants;
- import com.ruoyi.common.core.domain.AjaxResult;
- import com.ruoyi.common.utils.DateUtils;
- import com.ruoyi.common.utils.StringUtils;
- import com.ruoyi.warehouseBusiness.domain.TWarehousebillsfees;
- import com.ruoyi.warehouseBusiness.domain.TWarehousebillsitems;
- import com.ruoyi.warehouseBusiness.mapper.TWarehousebillsfeesMapper;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import org.springframework.transaction.annotation.Transactional;
- import org.springframework.transaction.interceptor.TransactionAspectSupport;
- import java.util.*;
- /**
- * 费用信息Service业务层处理
- *
- * @author ruoyi
- * @date 2020-12-11
- */
- @Service
- public class TFeesServiceImpl implements ITFeesService {
- @Autowired
- private TFeesMapper tFeesMapper;
- @Autowired
- private TWarehousebillsfeesMapper tWarehousebillsfeesMapper;
- /**
- * 查询费用信息
- *
- * @param fId 费用信息ID
- * @return 费用信息
- */
- @Override
- public TFees selectTFeesById(Long fId) {
- return tFeesMapper.selectTFeesById(fId);
- }
- /**
- * 查询费用信息列表
- *
- * @param tFees 费用信息
- * @return 费用信息
- */
- @Override
- public List<TFees> selectTFeesList(TFees tFees) {
- return tFeesMapper.selectTFeesList(tFees);
- }
- /**
- * 新增费用信息
- *
- * @param tFees 费用信息
- * @return 结果
- */
- @Override
- public int insertTFees(TFees tFees) {
- tFees.setCreateTime(DateUtils.getNowDate());
- return tFeesMapper.insertTFees(tFees);
- }
- /**
- * 修改费用信息
- *
- * @param tFees 费用信息
- * @return 结果
- */
- @Override
- @Transactional
- public AjaxResult updateTFees(TFees tFees) {
- /* String modify = tFeesMapper.selectTFeesModify(tFees);
- if ("F".equals(modify)) {
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- return AjaxResult.error("该费用不允许修改数据");
- }*/
- tFees.setUpdateTime(DateUtils.getNowDate());
- tFeesMapper.updateTFees(tFees);
- return AjaxResult.success();
- }
- /**
- * 批量删除费用信息
- *
- * @param fIds 需要删除的费用信息ID
- * @return 结果
- */
- @Override
- @Transactional
- public AjaxResult deleteTFeesByIds(Long[] fIds) {
- // return tFeesMapper.deleteTFeesByIds(fIds);
- int i = 1;
- for(Long id:fIds){
- TFees tFees = new TFees();
- tFees.setfId(id);
- String modify = tFeesMapper.selectTFeesModify(tFees);
- if ("F".equals(modify)) {
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- return AjaxResult.error("费用第" + i + "行为不允许修改数据");
- }
- TWarehousebillsfees tWarehousebillsfees =new TWarehousebillsfees();
- tWarehousebillsfees.setfFeeid(id);
- List<TWarehousebillsfees> TWarehousebillsfeesList =tWarehousebillsfeesMapper.selectTWarehousebillsfeesList(tWarehousebillsfees);
- if(TWarehousebillsfeesList!=null && !TWarehousebillsfeesList.isEmpty()){
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- return AjaxResult.error("费用第" + i + "行不可删除");
- }
- tFeesMapper.deleteTFeesById(id);
- i++;
- }
- return AjaxResult.success();
- }
- /**
- * 删除费用信息信息
- *
- * @param fId 费用信息ID
- * @return 结果
- */
- @Override
- public int deleteTFeesById(Long fId) {
- return tFeesMapper.deleteTFeesById(fId);
- }
- @Override
- public String checkUFNoUnique(TFees tFees) {
- TFees tFees1= tFeesMapper.checkFNoUnique(tFees.getfNo());
- if (StringUtils.isNotNull(tFees1) && tFees1.getfId()!=tFees.getfId()) {
- return UserConstants.NOT_UNIQUE;
- }
- return UserConstants.UNIQUE;
- }
- @Override
- public String checkUFNnameUnique(TFees tFees) {
- TFees tFees1 = tFeesMapper.checkUFNnameUnique(tFees.getfName());
- if (StringUtils.isNotNull(tFees1) && tFees1.getfId()!=tFees.getfId()) {
- return UserConstants.NOT_UNIQUE;
- }
- return UserConstants.UNIQUE;
- }
- /**
- * 获取费用统计
- *
- * @param tFees 费用信息
- * @return 费用统计
- */
- @Override
- public Map<String, Object> getFeeStatistics(TFees tFees) {
- List<String> dimensions = Arrays.asList("product", "应收", "已收", "利润");
- List<Map<String, Object>> source = new ArrayList<>();
- for (int i = -5; i <= 0; i++) {
- tFees.getParams().put("beginDate", DateUtils.beginOfOffsetMonth(i) + " 00:00:00");
- tFees.getParams().put("endDate", DateUtils.endOfOffsetMonth(i) + " 23:59:59");
- Map<String, String> feeMap = tFeesMapper.getFeeStatistics(tFees);
- Map<String, Object> temp = new HashMap<>();
- temp.put("product", DateUtils.offsetFormatMonth(i, "yyyy-MM"));
- temp.put("应收", feeMap.get("receivable"));
- temp.put("已收", feeMap.get("received"));
- temp.put("利润", feeMap.get("profit"));
- source.add(temp);
- }
- return new HashMap<String, Object>() {{
- this.put("dimensions", dimensions);
- this.put("source", source);
- }};
- }
- /**
- * 获取费用统计
- *
- * @param tFees 费用信息
- * @return 费用统计
- */
- @Override
- public Map<String, Object> getArrearsStatistics(TFees tFees) {
- List<String> key = new ArrayList<>();
- List<String> value = new ArrayList<>();
- List<Map<String, String>> statisticsList = tFeesMapper.getArrearsStatistics(tFees);
- for (Map<String, String> statisticsMap : statisticsList) {
- String name = statisticsMap.get("name");
- key.add(name.length() > 6 ? name.substring(0,6) : name);
- value.add(statisticsMap.get("receivable"));
- }
- return new HashMap<String, Object>() {{
- this.put("key", key);
- this.put("value", value);
- }};
- }
- }
|