sql语句
<select id="getPortraitInfoByShopName" resultType="com.allcam.abshop.service.portrait.model.PortraitInfo">
select * from tbl_sss_portrait_info
where 1=1
<if test="beginTime != null">
and beginTime >= #{beginTime}
</if>
<if test="endTime != null">
and endTime &lt;= #{endTime}
</if>
<if test="shopName!=null and !&quot;&quot;.equals(shopName.trim()) ">
and shopName = #{shopName}
</if>
order by beginTime desc
</select>
<select id="getPortraitInfoByShopNameAndPortraitId" resultType="com.allcam.abshop.service.portrait.model.PortraitInfo">
select * from tbl_sss_portrait_info
where 1=1
<if test="beginTime != null">
and beginTime >= #{beginTime}
</if>
<if test="endTime != null">
and endTime &lt;= #{endTime}
</if>
<if test="portraitId != null">
and portraitId = #{portraitId}
</if>
<if test="shopName!=null and !&quot;&quot;.equals(shopName.trim()) ">
and shopName = #{shopName}
</if>
order by beginTime desc
</select>


<select id="getPortraitByShopId" resultType="com.allcam.abshop.service.portrait.model.PortraitInfo">
select * from tbl_sss_portrait_info
where shopId = #{shopId}
</select>

----------------------------------------------------------------------------------------------
 partraitMapper层
List<PortraitInfo> getPortraitInfoByShopNameAndPortraitId(@Param("shopName")String shopName,@Param("beginTime")String beginTime,@Param("endTime")String endTime,@Param("portraitId")List<PortraitInfo> portraitId);
List<PortraitInfo> getPortraitInfoByShopName(@Param("shopName")String shopName,@Param("beginTime")String beginTime,@Param("endTime")String endTime);
PortraitInfo getPortraitByShopId(String shopId);

----------------------------------------------------------------------------------------------
portraitDateService层
public List<PortraitInfo> getPortraitByName(String ShopName,String beginTime,String endTime){
List<PortraitInfo> portraitInfoListByName = portraitMapper.getPortraitInfoByShopName(ShopName,beginTime,endTime);
return portraitInfoListByName;
}
public List<PortraitInfo> getPortraitByNameAndPortraitId(String ShopName,String beginTime,String endTime,List<PortraitInfo> portraitId){
List<PortraitInfo> portraitInfoListByName = portraitMapper.getPortraitInfoByShopNameAndPortraitId(ShopName,beginTime,endTime,portraitId);
return portraitInfoListByName;
}
public PortraitInfo getPortraitByShopId(String ShopId){
PortraitInfo portraitInfoListByName = portraitMapper.getPortraitByShopId(ShopId);
return portraitInfoListByName;
}

---------------------------------------------------------------------------------------
portraitServiceImpl层
@Override
public PortraitExporateResponse portraitExport(GetClockPratraitInRequest request) {
// PortraitSeachInfo seachInfo = request.getPortraitSeachInfo();
PortraitExporateResponse response = new PortraitExporateResponse();
List<ExportPortraitInfo> exportPortraitInfoList = new ArrayList<>();

List<PortraitInfo> portraitInfoList;
if (!CollectionUtils.isEmpty(request.getPratraitId()))
{
portraitInfoList = portraitDataService.getPortraitByNameAndPortraitId(request.getShopName(),request.getBeginTime(),request.getEndTime(),request.getPratraitId());
}
else
{
portraitInfoList = portraitDataService.getPortraitByName(request.getShopName(),request.getBeginTime(),request.getEndTime());
}
AcsAssert.notEmpty(portraitInfoList, PORTRAIT_NOT_EXIST);

PortraitInfo portrait = portraitDataService.getPortraitByShopId(portraitInfoList.get(0).getShopId());
String shopId = portrait.getShopId();
String shopName = portrait.getShopName();
int total = portrait.getTotal();
int newCustomerNum = portrait.getNewCustomerNum();
int oldCustomerNum = portrait.getOldCustomerNum();
int blackCustomerNum = portrait.getBlackCustomerNum();
int underEighteen = portrait.getUnderEighteen();
int eighteenToThirty = portrait.getEighteenToThirty();
int thirtyToFortyFive = portrait.getThirtyToFortyFive();
int fortyFiveToSixty = portrait.getFortyFiveToSixty();
int moreThanSixty = portrait.getMoreThanSixty();
int unknownOfAge = portrait.getUnknownOfAge();
int numOfMale = portrait.getNumOfMale();
int numOfFemale = portrait.getNumOfFemale();
int unknownOfGender = portrait.getUnknownOfGender();
String dayStr = portrait.getDayStr();
String beginTime = portrait.getBeginTime();
String endTime = portrait.getEndTime();

for (PortraitInfo portraitInfo : portraitInfoList)
{
ExportPortraitInfo exportPortraitInfo = new ExportPortraitInfo();
exportPortraitInfo.setShopId(shopId);
exportPortraitInfo.setShopName(shopName);
exportPortraitInfo.setTotal(total);
exportPortraitInfo.setNewCustomerNum(newCustomerNum);
exportPortraitInfo.setOldCustomerNum(oldCustomerNum);
exportPortraitInfo.setBlackCustomerNum(blackCustomerNum);
exportPortraitInfo.setUnderEighteen(underEighteen);
exportPortraitInfo.setEighteenToThirty(eighteenToThirty);
exportPortraitInfo.setThirtyToFortyFive(thirtyToFortyFive);
exportPortraitInfo.setFortyFiveToSixty(fortyFiveToSixty);
exportPortraitInfo.setMoreThanSixty(moreThanSixty);
exportPortraitInfo.setUnknownOfAge(unknownOfAge);
exportPortraitInfo.setNumOfMale(numOfMale);
exportPortraitInfo.setNumOfFemale(numOfFemale);
exportPortraitInfo.setUnknownOfGender(unknownOfGender);
exportPortraitInfo.setDayStr(dayStr);
exportPortraitInfo.setBeginTime(beginTime);
exportPortraitInfo.setEndTime(endTime);
BeanUtils.copyProperties(portraitInfo, exportPortraitInfo);
exportPortraitInfoList.add(exportPortraitInfo);
}
AcsAssert.notEmpty(exportPortraitInfoList, PORTRAIT_EXPORT_FAILED);
String url = ExcelUtils.exportExcel("考勤统计表", exportPortraitInfoList, ExportPortraitInfo.class);
AcsAssert.hasText(url, ATTENDANCE_RECORD_EXPORT_FAILED);
response.setUrl(url);
return response;
}
}
posted on 2022-11-24 14:32  村边大麦地  阅读(23)  评论(0编辑  收藏  举报