| | |
| | | |
| | | // 查询销售前十占比 |
| | | List<SupplierSalesStatisticsGoodsTypeVO> supplierSalesStatisticsGoodsTypeVOS = erpProcurementService.supplierSalesStatisticsGoodsType(crmSupplier.getId(), startTime, endTime); |
| | | // 判断集合是否大于9 |
| | | if(supplierSalesStatisticsGoodsTypeVOS.size() > 9){ |
| | | // 其余的添加到其他 |
| | | List<SupplierSalesStatisticsGoodsTypeVO> otherList = supplierSalesStatisticsGoodsTypeVOS.subList(9, supplierSalesStatisticsGoodsTypeVOS.size()); |
| | | SupplierSalesStatisticsGoodsTypeVO other = new SupplierSalesStatisticsGoodsTypeVO(); |
| | | other.setTypeName("其他"); |
| | | other.setGoodsCount(otherList.stream().mapToInt(SupplierSalesStatisticsGoodsTypeVO::getGoodsCount).sum()); |
| | | supplierSalesStatisticsGoodsTypeVOS.add(other); |
| | | supplierSalesStatisticsGoodsTypeVOS = supplierSalesStatisticsGoodsTypeVOS.subList(0, 9); |
| | | } |
| | | supplierSalesStatisticsVO.setSupplierSalesStatisticsGoodsTypeVOS(supplierSalesStatisticsGoodsTypeVOS); |
| | | // 查询30天销售统计 |
| | | List<SupplierSalesStatisticsGoodsCountVO> supplierSalesStatisticsGoodsCountVOS; |
| | |
| | | |
| | | // 查询销售前十占比 |
| | | List<ClinicSalesStatisticsGoodsTypeVO> clinicSalesStatisticsGoodsTypeVOS = sysOrderService.supplierSalesStatisticsGoodsType(crmClinic.getId(), startTime, endTime); |
| | | // 判断集合是否大于9 |
| | | if(clinicSalesStatisticsGoodsTypeVOS.size() > 9){ |
| | | // 其余的添加到其他 |
| | | List<ClinicSalesStatisticsGoodsTypeVO> otherList = clinicSalesStatisticsGoodsTypeVOS.subList(9, clinicSalesStatisticsGoodsTypeVOS.size()); |
| | | ClinicSalesStatisticsGoodsTypeVO other = new ClinicSalesStatisticsGoodsTypeVO(); |
| | | other.setTypeName("其他"); |
| | | other.setGoodsCount(otherList.stream().mapToInt(ClinicSalesStatisticsGoodsTypeVO::getGoodsCount).sum()); |
| | | clinicSalesStatisticsGoodsTypeVOS.add(other); |
| | | clinicSalesStatisticsGoodsTypeVOS = clinicSalesStatisticsGoodsTypeVOS.subList(0, 9); |
| | | } |
| | | clinicSalesStatisticsVO.setClinicSalesStatisticsGoodsTypeVOS(clinicSalesStatisticsGoodsTypeVOS); |
| | | // 查询30天销售统计 |
| | | List<ClinicSalesStatisticsGoodsCountVO> clinicSalesStatisticsGoodsCountVOS; |
| | |
| | | |
| | | public static void main(String[] args) { |
| | | System.out.println(LocalDate.now().minusMonths(6)); |
| | | List<Integer> list = new ArrayList<>(); |
| | | for (int i = 0; i < 6; i++) { |
| | | list.add(i); |
| | | } |
| | | System.out.println(list.subList(2,list.size())); |
| | | System.out.println(list.subList(0,2 )); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | package com.ruoyi.web.controller.api; |
| | | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.model.TCrmClinic; |
| | | import com.ruoyi.system.model.TCrmSupplier; |
| | | import com.ruoyi.system.model.TErpProcurement; |
| | | import com.ruoyi.system.model.TSysAppUser; |
| | | import com.ruoyi.system.query.ClinicProcurementReportQuery; |
| | | import com.ruoyi.system.query.DataStatisticsQuery; |
| | | import com.ruoyi.system.service.*; |
| | | import com.ruoyi.system.vo.ClinicProcurementReportVO; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | |
| | | @Api(tags = "财务报表") |
| | | @RestController |
| | | @RequestMapping("/financial-statements") |
| | | public class FinancialStatementsController { |
| | | |
| | | private final TErpProcurementService erpProcurementService; |
| | | private final TokenService tokenService; |
| | | private final ISysUserService sysUserService; |
| | | private final TCrmSupplierService crmSupplierService; |
| | | private final TCrmClinicService crmClinicService; |
| | | private final TSysAppUserService sysAppUserService; |
| | | private final TCrmClinicPointsService crmClinicPointsService; |
| | | private final TSysOrderService sysOrderService; |
| | | |
| | | @Autowired |
| | | public FinancialStatementsController(TErpProcurementService erpProcurementService, TokenService tokenService, ISysUserService sysUserService, TCrmSupplierService crmSupplierService, TCrmClinicService crmClinicService, TSysAppUserService sysAppUserService, TCrmClinicPointsService crmClinicPointsService, TSysOrderService sysOrderService) { |
| | | this.erpProcurementService = erpProcurementService; |
| | | this.tokenService = tokenService; |
| | | this.sysUserService = sysUserService; |
| | | this.crmSupplierService = crmSupplierService; |
| | | this.crmClinicService = crmClinicService; |
| | | this.sysAppUserService = sysAppUserService; |
| | | this.crmClinicPointsService = crmClinicPointsService; |
| | | this.sysOrderService = sysOrderService; |
| | | } |
| | | |
| | | /** |
| | | * 诊所采购报表 |
| | | */ |
| | | @ApiOperation(value = "诊所采购报表") |
| | | @PostMapping(value = "/clinicProcurementReport") |
| | | public R<PageInfo<ClinicProcurementReportVO>> clinicProcurementReport(@RequestBody ClinicProcurementReportQuery query) { |
| | | Long userId = tokenService.getLoginUser().getUserId(); |
| | | Integer roleType = tokenService.getLoginUser().getUser().getRoleType(); |
| | | query.setRoleType(roleType); |
| | | if (Objects.equals(roleType, 4)) { |
| | | TCrmSupplier crmSupplier = crmSupplierService.getOne(Wrappers.lambdaQuery(TCrmSupplier.class) |
| | | .eq(TCrmSupplier::getUserId, userId) |
| | | .last("LIMIT 1")); |
| | | query.setSupplierId(crmSupplier.getId()); |
| | | } |
| | | if (Objects.equals(roleType, 5)) { |
| | | TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class) |
| | | .eq(TCrmClinic::getUserId, userId) |
| | | .last("LIMIT 1")); |
| | | query.setClinicId(crmClinic.getId()); |
| | | } |
| | | |
| | | PageInfo<ClinicProcurementReportVO> pageInfo = erpProcurementService.clinicProcurementReport(query); |
| | | return R.ok(pageInfo); |
| | | } |
| | | |
| | | } |
| | |
| | | if(code != 200){ |
| | | return R.fail("单点登录失败"); |
| | | } |
| | | code = aiUtil.initUser(userId, sysAppUser.getNickName(), sysAppUser.getSex(), DateUtils.localDateTimeToString(sysAppUser.getBirthTime())).getCode(); |
| | | code = aiUtil.initUser(userId, sysAppUser.getNickName(), sysAppUser.getSex(), sysAppUser.getBirthTime().toString()).getCode(); |
| | | if(code != 200){ |
| | | return R.fail("初始化用户失败"); |
| | | } |
| New file |
| | |
| | | package com.ruoyi.system.export; |
| | | |
| | | import cn.afterturn.easypoi.excel.annotation.Excel; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | |
| | | @Data |
| | | @ApiModel(value = "诊所采购报表ClinicProcurementReportExport") |
| | | public class ClinicProcurementReportExport implements Serializable { |
| | | private String id; |
| | | @ApiModelProperty(value = "采购单号") |
| | | @Excel(name = "采购单号", width = 20) |
| | | private String procurementCode; |
| | | @ApiModelProperty(value = "采购金额") |
| | | @Excel(name = "采购金额", width = 20) |
| | | private BigDecimal payMoney; |
| | | @ApiModelProperty(value = "采购药品数") |
| | | @Excel(name = "采购药品数", width = 20) |
| | | private Integer procurementGoodsNum; |
| | | @ApiModelProperty(value = "采购供应商") |
| | | @Excel(name = "采购供应商", width = 20) |
| | | private String supplierName; |
| | | @ApiModelProperty(value = "采购时间") |
| | | @Excel(name = "采购时间", width = 20) |
| | | private String payTimeStr; |
| | | private LocalDateTime payTime; |
| | | @ApiModelProperty(value = "状态 1=草稿 2=待支付 3=待发货 4=已发货 5=已入库 6=已取消") |
| | | @Excel(name = "状态", width = 20,replace = {"草稿_1","待支付_2","待发货_3","已发货_4","已入库_5","已取消_6"}) |
| | | private Integer status; |
| | | |
| | | } |
| | |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.system.model.TErpProcurement; |
| | | import com.ruoyi.system.query.ClinicProcurementReportQuery; |
| | | import com.ruoyi.system.query.TErpGoodsQuery; |
| | | import com.ruoyi.system.query.TErpProcurementQuery; |
| | | import com.ruoyi.system.vo.*; |
| | |
| | | @Param("endTime")String endTime, |
| | | @Param("goodsName")String goodsName); |
| | | |
| | | /** |
| | | * 诊所采购报表 |
| | | * @param query |
| | | * @return |
| | | */ |
| | | List<ClinicProcurementReportVO> clinicProcurementReport(@Param("query")ClinicProcurementReportQuery query, @Param("pageInfo")PageInfo<ClinicProcurementReportVO> pageInfo); |
| | | } |
| | |
| | | @TableField("nick_name") |
| | | private String nickName; |
| | | |
| | | @ApiModelProperty(value = "头像") |
| | | @TableField("avatar") |
| | | private String avatar; |
| | | |
| | | @ApiModelProperty(value = "手机号") |
| | | @TableField("phone") |
| | | private String phone; |
| New file |
| | |
| | | package com.ruoyi.system.query; |
| | | |
| | | import com.ruoyi.common.core.domain.model.TimeRangeQueryBody; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | @ApiModel(value = "诊所采购报表ClinicProcurementReportQuery") |
| | | public class ClinicProcurementReportQuery extends TimeRangeQueryBody { |
| | | |
| | | @ApiModelProperty(value = "采购单号") |
| | | private String procurementCode; |
| | | |
| | | @ApiModelProperty(value = "供应商名称") |
| | | private String supplierName; |
| | | |
| | | @ApiModelProperty(value = "诊所名称") |
| | | private String clinicName; |
| | | |
| | | @ApiModelProperty(value = "状态 1=草稿 2=待支付 3=待发货 4=已发货 5=已入库 6=已取消") |
| | | private Integer status; |
| | | |
| | | @ApiModelProperty(value = "管理员") |
| | | private String personChargeName; |
| | | |
| | | @ApiModelProperty(value = "联系电话") |
| | | private String phone; |
| | | |
| | | @ApiModelProperty(value = "诊所id 前端忽略") |
| | | private String clinicId; |
| | | @ApiModelProperty(value = "供应商id 前端忽略") |
| | | private String supplierId; |
| | | @ApiModelProperty(value = "前端忽略") |
| | | private Integer roleType; |
| | | |
| | | } |
| | |
| | | import com.ruoyi.system.dto.AddProcurementDto; |
| | | import com.ruoyi.system.model.TErpGoods; |
| | | import com.ruoyi.system.model.TErpProcurement; |
| | | import com.ruoyi.system.query.ClinicProcurementReportQuery; |
| | | import com.ruoyi.system.query.TErpGoodsQuery; |
| | | import com.ruoyi.system.query.TErpProcurementQuery; |
| | | import com.ruoyi.system.vo.*; |
| | |
| | | * @return |
| | | */ |
| | | List<SupplierSalesStatisticsGoodsCountVO> supplierSalesStatisticsGoodsCountMonth(String supplierId, String startTime, String endTime, String goodsName); |
| | | |
| | | /** |
| | | * 诊所采购报表 |
| | | * @param query |
| | | * @return |
| | | */ |
| | | PageInfo<ClinicProcurementReportVO> clinicProcurementReport(ClinicProcurementReportQuery query); |
| | | |
| | | } |
| | |
| | | import com.ruoyi.system.dto.AddProcurementDto; |
| | | import com.ruoyi.system.mapper.*; |
| | | import com.ruoyi.system.model.*; |
| | | import com.ruoyi.system.query.ClinicProcurementReportQuery; |
| | | import com.ruoyi.system.query.TErpGoodsQuery; |
| | | import com.ruoyi.system.query.TErpProcurementQuery; |
| | | import com.ruoyi.system.service.TErpGoodsService; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Propagation; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.net.ssl.SSLContext; |
| | |
| | | return this.baseMapper.supplierSalesStatisticsGoodsCountMonth(supplierId,startTime, endTime,goodsName); |
| | | } |
| | | |
| | | @Override |
| | | public PageInfo<ClinicProcurementReportVO> clinicProcurementReport(ClinicProcurementReportQuery query) { |
| | | PageInfo<ClinicProcurementReportVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); |
| | | List<ClinicProcurementReportVO> list = this.baseMapper.clinicProcurementReport(query, pageInfo); |
| | | if(CollectionUtils.isEmpty(list)){ |
| | | return pageInfo; |
| | | } |
| | | List<String> procurementIds = list.stream().map(TErpProcurement::getId).collect(Collectors.toList()); |
| | | List<TErpProcurementGoods> erpProcurementGoods = erpProcurementGoodsMapper.selectList(new QueryWrapper<TErpProcurementGoods>().lambda().in(TErpProcurementGoods::getProcurementId, procurementIds)); |
| | | for (ClinicProcurementReportVO clinicProcurementReportVO : list) { |
| | | List<TErpProcurementGoods> procurementGoods = erpProcurementGoods.stream().filter(tErpProcurementGoods -> tErpProcurementGoods.getProcurementId().equals(clinicProcurementReportVO.getId())).collect(Collectors.toList()); |
| | | if(!CollectionUtils.isEmpty(procurementGoods)){ |
| | | int sum = procurementGoods.stream().mapToInt(TErpProcurementGoods::getPurchaseCount).sum(); |
| | | clinicProcurementReportVO.setProcurementGoodsNum(sum); |
| | | } |
| | | } |
| | | pageInfo.setRecords(list); |
| | | return pageInfo; |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | package com.ruoyi.system.vo; |
| | | |
| | | import com.ruoyi.system.model.TErpProcurement; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | |
| | | @Data |
| | | @ApiModel(value = "诊所采购报表ClinicProcurementReportVO") |
| | | public class ClinicProcurementReportVO extends TErpProcurement { |
| | | |
| | | @ApiModelProperty(value = "采购药品数") |
| | | private Integer procurementGoodsNum=0; |
| | | @ApiModelProperty(value = "采购供应商") |
| | | private String supplierName; |
| | | @ApiModelProperty(value = "采购诊所") |
| | | private String clinicName; |
| | | } |
| | |
| | | </if> |
| | | group by date_format(t1.pay_time, '%Y.%m') |
| | | </select> |
| | | <select id="clinicProcurementReport" resultType="com.ruoyi.system.vo.ClinicProcurementReportVO"> |
| | | select tep.id, tep.procurement_code, tep.pay_money, tep.status,tep.pay_time,tep.clinic_id, tep.supplier_id, |
| | | tep.money,tep.supplier_money, |
| | | tcs.supplier_name as supplierName, tcc.clinic_name as clinicName |
| | | from t_erp_procurement tep |
| | | left join t_crm_supplier tcs on tep.supplier_id = tcs.id |
| | | left join t_crm_clinic tcc on tep.clinic_id = tcc.id |
| | | <where> |
| | | <if test="query.procurementCode != null and query.procurementCode != ''"> |
| | | and tep.procurement_code like concat('%',#{query.procurementCode},'%') |
| | | </if> |
| | | <if test="query.supplierName != null and query.supplierName != ''"> |
| | | and tcs.supplier_name like concat('%',#{query.supplierName},'%') |
| | | </if> |
| | | <if test="query.clinicName != null and query.clinicName != ''"> |
| | | and tcc.clinic_name like concat('%',#{query.clinicName},'%') |
| | | </if> |
| | | <if test="query.status != null and query.status != ''"> |
| | | and tep.status = #{query.status} |
| | | </if> |
| | | <if test="query.startTime != null and query.startTime != '' and query.endTime != null and query.endTime != ''"> |
| | | AND tep.pay_time >= #{query.startTime} |
| | | AND tep.pay_time <= #{query.endTime} |
| | | </if> |
| | | <if test="query.clinicId != null and query.clinicId != ''"> |
| | | and tep.clinic_id = #{query.clinicId} |
| | | </if> |
| | | <if test="query.supplierId != null and query.supplierId != ''"> |
| | | and tep.supplier_id = #{query.supplierId} |
| | | </if> |
| | | <if test="query.personChargeName != null and query.personChargeName != ''"> |
| | | and tep.person_charge_name like concat('%',#{query.personChargeName},'%') |
| | | </if> |
| | | <if test="query.phone != null and query.phone != ''"> |
| | | and tep.phone like concat('%',#{query.phone},'%') |
| | | </if> |
| | | AND tep.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()} |
| | | </where> |
| | | order by tep.pay_time desc |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | <resultMap id="BaseResultMap" type="com.ruoyi.system.model.TSysAppUser"> |
| | | <id column="id" property="id" /> |
| | | <result column="nick_name" property="nickName" /> |
| | | <result column="avatar" property="avatar" /> |
| | | <result column="phone" property="phone" /> |
| | | <result column="birth_time" property="birthTime" /> |
| | | <result column="sex" property="sex" /> |
| | |
| | | |
| | | <!-- 通用查询结果列 --> |
| | | <sql id="Base_Column_List"> |
| | | id, nick_name, phone, birth_time, sex, open_id,chronic_disease_id,status,last_reminder_time, |
| | | id, nick_name,avatar, phone, birth_time, sex, open_id,chronic_disease_id,status,last_reminder_time, |
| | | office_open_id,clinic_id, create_time, update_time, create_by, update_by, disabled |
| | | </sql> |
| | | <select id="pageList" resultType="com.ruoyi.system.vo.TSysAppUserVO"> |
| | | select tsau.id, tsau.nick_name, tsau.phone, tsau.birth_time, tsau.sex, tsau.open_id,tsau.office_open_id, |
| | | select tsau.id, tsau.nick_name,tsau.avatar, tsau.phone, tsau.birth_time, tsau.sex, tsau.open_id,tsau.office_open_id, |
| | | tsau.chronic_disease_id,tsau.status,tsau.last_reminder_time,tsau.clinic_id, tsau.create_time, |
| | | tsau.update_time, tsau.create_by,tsau.update_by, tsau.disabled, tsi.lastInspectionTime |
| | | from t_sys_app_user tsau |
| | |
| | | ORDER BY tsau.create_time DESC |
| | | </select> |
| | | <select id="pageChronicDiseaseUserList" resultType="com.ruoyi.system.vo.TSysAppUserVO"> |
| | | select tsau.id, tsau.nick_name, tsau.phone, tsau.birth_time, tsau.sex, tsau.open_id,tsau.office_open_id, |
| | | select tsau.id, tsau.nick_name,tsau.avatar, tsau.phone, tsau.birth_time, tsau.sex, tsau.open_id,tsau.office_open_id, |
| | | tsau.chronic_disease_id,tsau.status,tsau.last_reminder_time,tsau.clinic_id, tsau.create_time, |
| | | tsau.update_time, tsau.create_by,tsau.update_by, tsau.disabled |
| | | from t_sys_app_user tsau |
| | |
| | | ORDER BY tsau.create_time DESC |
| | | </select> |
| | | <select id="exportList" resultType="com.ruoyi.system.export.TSysAppUserListExport"> |
| | | select tsau.id, tsau.nick_name, tsau.phone, tsau.birth_time, tsau.sex, tsau.open_id,tsau.office_open_id, |
| | | select tsau.id, tsau.nick_name,tsau.avatar, tsau.phone, tsau.birth_time, tsau.sex, tsau.open_id,tsau.office_open_id, |
| | | tsau.chronic_disease_id,tsau.status,tsau.last_reminder_time,tsau.clinic_id, tsau.create_time, |
| | | tsau.update_time, tsau.create_by,tsau.update_by, tsau.disabled |
| | | from t_sys_app_user tsau |
| | |
| | | ORDER BY tsau.create_time DESC |
| | | </select> |
| | | <select id="exportListClinic" resultType="com.ruoyi.system.export.TSysAppUserClinicExport"> |
| | | select tsau.id, tsau.nick_name, tsau.phone, tsau.birth_time, tsau.sex, tsau.open_id,tsau.office_open_id, |
| | | select tsau.id, tsau.nick_name,tsau.avatar, tsau.phone, tsau.birth_time, tsau.sex, tsau.open_id,tsau.office_open_id, |
| | | tsau.chronic_disease_id,tsau.status,tsau.last_reminder_time,tsau.clinic_id, tsau.create_time, |
| | | tsau.update_time, tsau.create_by,tsau.update_by, tsau.disabled |
| | | from t_sys_app_user tsau |
| | |
| | | ORDER BY tsau.create_time DESC |
| | | </select> |
| | | <select id="exportListAppUser" resultType="com.ruoyi.system.export.TSysAppUserExport"> |
| | | select tsau.id, tsau.nick_name, tsau.phone, tsau.birth_time, tsau.sex, tsau.open_id,tsau.office_open_id, |
| | | select tsau.id, tsau.nick_name,tsau.avatar, tsau.phone, tsau.birth_time, tsau.sex, tsau.open_id,tsau.office_open_id, |
| | | tsau.chronic_disease_id,tsau.status,tsau.last_reminder_time,tsau.clinic_id, tsau.create_time, |
| | | tsau.update_time, tsau.create_by,tsau.update_by, tsau.disabled, tsi.lastInspectionTime |
| | | from t_sys_app_user tsau |