feat:预炸
This commit is contained in:
@@ -2,6 +2,7 @@ package com.cool.store.dao;
|
|||||||
|
|
||||||
import com.cool.store.entity.PreFriedProductsDO;
|
import com.cool.store.entity.PreFriedProductsDO;
|
||||||
import com.cool.store.mapper.PreFriedProductsMapper;
|
import com.cool.store.mapper.PreFriedProductsMapper;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
@@ -28,6 +29,14 @@ public class PreFriedProductsDAO {
|
|||||||
return preFriedProductsMapper.forceUpdate(product);
|
return preFriedProductsMapper.forceUpdate(product);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<PreFriedProductsDO> selectByProductIds( List<Long> productIds) {
|
||||||
|
if (CollectionUtils.isEmpty(productIds)){
|
||||||
|
return Lists.newArrayList();
|
||||||
|
}
|
||||||
|
return preFriedProductsMapper.selectByProductIds(productIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public PreFriedProductsDO queryById(Long id){
|
public PreFriedProductsDO queryById(Long id){
|
||||||
return preFriedProductsMapper.selectByPrimaryKey(id);
|
return preFriedProductsMapper.selectByPrimaryKey(id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.cool.store.dao;
|
package com.cool.store.dao;
|
||||||
|
|
||||||
import com.cool.store.constants.CommonConstants;
|
import com.cool.store.constants.CommonConstants;
|
||||||
|
import com.cool.store.dto.pre.fry.DailyFryCountDTO;
|
||||||
import com.cool.store.entity.PreFryRecordsDO;
|
import com.cool.store.entity.PreFryRecordsDO;
|
||||||
import com.cool.store.mapper.PreFryRecordsMapper;
|
import com.cool.store.mapper.PreFryRecordsMapper;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
@@ -8,6 +9,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@@ -48,7 +50,7 @@ public class PreFryRecordsDAO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int batchUpdateStageByIds( List<Integer> ids,
|
public int batchUpdateStageByIds( List<Long> ids,
|
||||||
Integer currentStage){
|
Integer currentStage){
|
||||||
if (CollectionUtils.isEmpty(ids)) {
|
if (CollectionUtils.isEmpty(ids)) {
|
||||||
return CommonConstants.ZERO;
|
return CommonConstants.ZERO;
|
||||||
@@ -56,13 +58,20 @@ public class PreFryRecordsDAO {
|
|||||||
return preFryRecordsMapper.batchUpdateStageByIds(ids,currentStage);
|
return preFryRecordsMapper.batchUpdateStageByIds(ids,currentStage);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<PreFryRecordsDO> selectByStoreAndDateStage(String storeCode,
|
public List<PreFryRecordsDO> selectByStoreAndDateStage(String storeCode,
|
||||||
List<Integer> yesterdayStageList,
|
List<Integer> yesterdayStageList,
|
||||||
Integer todayStage){
|
Integer todayStage, String queryDate){
|
||||||
if (StringUtils.isBlank(storeCode) || CollectionUtils.isEmpty(yesterdayStageList)) {
|
if (StringUtils.isBlank(storeCode) || CollectionUtils.isEmpty(yesterdayStageList)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return preFryRecordsMapper.selectByStoreAndDateStage(storeCode,yesterdayStageList,todayStage);
|
return preFryRecordsMapper.selectByStoreAndDateStage(storeCode,yesterdayStageList,todayStage,queryDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<DailyFryCountDTO> selectDailyFryCountInCurrentMonth(String storeCode,Long time) {
|
||||||
|
if (StringUtils.isEmpty(storeCode)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return preFryRecordsMapper.selectDailyFryCountInCurrentMonth(storeCode,time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -31,14 +31,19 @@ public class PreFryStageChangesDAO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<PreFryStageImagesDTO> selectByRecordId( Integer recordId){
|
public List<PreFryStageImagesDTO> selectByRecordId( Long recordId){
|
||||||
if (recordId == null){
|
if (recordId == null){
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
return preFryStageChangesMapper.selectByRecordId(recordId);
|
return preFryStageChangesMapper.selectByRecordId(recordId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<PreFryStageImagesDTO> selectByRecordIdList( List<Long> recordIdList){
|
||||||
|
if (recordIdList == null){
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
return preFryStageChangesMapper.selectByRecordIdList(recordIdList);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -47,5 +47,7 @@ public interface PreFriedProductsMapper extends Mapper<PreFriedProductsDO> {
|
|||||||
*/
|
*/
|
||||||
int forceUpdate(@Param("product") PreFriedProductsDO product);
|
int forceUpdate(@Param("product") PreFriedProductsDO product);
|
||||||
|
|
||||||
|
List<PreFriedProductsDO> selectByProductIds(@Param("productIds") List<Long> productIds);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,22 +1,27 @@
|
|||||||
package com.cool.store.mapper;
|
package com.cool.store.mapper;
|
||||||
|
|
||||||
|
import com.cool.store.dto.pre.fry.DailyFryCountDTO;
|
||||||
import com.cool.store.entity.PreFryRecordsDO;
|
import com.cool.store.entity.PreFryRecordsDO;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import tk.mybatis.mapper.common.Mapper;
|
import tk.mybatis.mapper.common.Mapper;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface PreFryRecordsMapper extends Mapper<PreFryRecordsDO> {
|
public interface PreFryRecordsMapper extends Mapper<PreFryRecordsDO> {
|
||||||
|
|
||||||
int batchInsert(List<PreFryRecordsDO> records);
|
int batchInsert(List<PreFryRecordsDO> records);
|
||||||
|
|
||||||
int batchUpdateStageByIds(@Param("ids") List<Integer> ids,
|
int batchUpdateStageByIds(@Param("ids") List<Long> ids,
|
||||||
@Param("currentStage") Integer currentStage);
|
@Param("currentStage") Integer currentStage);
|
||||||
|
|
||||||
List<PreFryRecordsDO> selectByStoreAndDateStage(
|
List<PreFryRecordsDO> selectByStoreAndDateStage(
|
||||||
@Param("storeCode") String storeCode,
|
@Param("storeCode") String storeCode,
|
||||||
@Param("yesterdayStageList") List<Integer> yesterdayStageList,
|
@Param("yesterdayStageList") List<Integer> yesterdayStageList,
|
||||||
@Param("todayStage") Integer todayStage);
|
@Param("todayStage") Integer todayStage,
|
||||||
|
@Param("queryDate") String queryDate);
|
||||||
|
|
||||||
|
|
||||||
|
List<DailyFryCountDTO> selectDailyFryCountInCurrentMonth(
|
||||||
|
@Param("storeCode") String storeCode,@Param("time") Long time);
|
||||||
}
|
}
|
||||||
@@ -12,7 +12,8 @@ public interface PreFryStageChangesMapper extends Mapper<PreFryStageChangesDO> {
|
|||||||
|
|
||||||
int batchInsert(List<PreFryStageChangesDO> records);
|
int batchInsert(List<PreFryStageChangesDO> records);
|
||||||
|
|
||||||
List<PreFryStageImagesDTO> selectByRecordId(@Param("recordId") Integer recordId);
|
List<PreFryStageImagesDTO> selectByRecordId(@Param("recordId") Long recordId);
|
||||||
|
|
||||||
|
List<PreFryStageImagesDTO> selectByRecordIdList(@Param("recordIdList") List<Long> recordIdList);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -59,6 +59,14 @@
|
|||||||
</foreach>
|
</foreach>
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
<select id="selectByProductIds" resultMap="BaseResultMap">
|
||||||
|
SELECT * FROM xfsg_pre_fried_products where deleted = 0
|
||||||
|
and id IN
|
||||||
|
<foreach collection="productIds" item="id" open="(" separator="," close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
<update id="forceUpdate">
|
<update id="forceUpdate">
|
||||||
UPDATE xfsg_pre_fried_products
|
UPDATE xfsg_pre_fried_products
|
||||||
|
|||||||
@@ -7,7 +7,8 @@
|
|||||||
-->
|
-->
|
||||||
<id column="id" jdbcType="INTEGER" property="id" />
|
<id column="id" jdbcType="INTEGER" property="id" />
|
||||||
<result column="store_code" jdbcType="VARCHAR" property="storeCode" />
|
<result column="store_code" jdbcType="VARCHAR" property="storeCode" />
|
||||||
<result column="product_code" jdbcType="INTEGER" property="productId" />
|
<result column="product_id" jdbcType="INTEGER" property="productId" />
|
||||||
|
<result column="record_code" jdbcType="VARCHAR" property="recordCode" />
|
||||||
<result column="fry_date" jdbcType="DATE" property="fryDate" />
|
<result column="fry_date" jdbcType="DATE" property="fryDate" />
|
||||||
<result column="fry_complete_time" jdbcType="TIMESTAMP" property="fryCompleteTime" />
|
<result column="fry_complete_time" jdbcType="TIMESTAMP" property="fryCompleteTime" />
|
||||||
<result column="latest_sale_time" jdbcType="TIMESTAMP" property="latestSaleTime" />
|
<result column="latest_sale_time" jdbcType="TIMESTAMP" property="latestSaleTime" />
|
||||||
@@ -44,16 +45,28 @@
|
|||||||
SELECT * FROM xfsg_pre_fry_records
|
SELECT * FROM xfsg_pre_fry_records
|
||||||
WHERE store_code = #{storeCode}
|
WHERE store_code = #{storeCode}
|
||||||
AND (
|
AND (
|
||||||
(fry_date = DATE_SUB(CURDATE(), INTERVAL 1 DAY)
|
(fry_date = DATE_SUB(#{queryDate}, INTERVAL 1 DAY)
|
||||||
AND current_stage IN
|
AND current_stage IN
|
||||||
<foreach collection="yesterdayStageList" item="stage" open="(" separator="," close=")">
|
<foreach collection="yesterdayStageList" item="stage" open="(" separator="," close=")">
|
||||||
#{stage}
|
#{stage}
|
||||||
</foreach>)
|
</foreach>)
|
||||||
OR
|
OR
|
||||||
(fry_date = CURDATE() AND current_stage = #{todayStage})
|
(fry_date = #{queryDate} AND current_stage = #{todayStage})
|
||||||
)
|
)
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectDailyFryCountInCurrentMonth" resultType="com.cool.store.dto.pre.fry.DailyFryCountDTO">
|
||||||
|
SELECT
|
||||||
|
fry_date as fryDate,
|
||||||
|
COUNT(*) as count
|
||||||
|
FROM xfsg_pre_fry_records
|
||||||
|
WHERE store_code = #{storeCode}
|
||||||
|
AND fry_date BETWEEN DATE_FORMAT(FROM_UNIXTIME(#{timestamp}/1000), '%Y-%m-01')
|
||||||
|
AND LAST_DAY(FROM_UNIXTIME(#{timestamp}/1000)
|
||||||
|
GROUP BY fry_date
|
||||||
|
ORDER BY fry_date
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
@@ -34,6 +34,18 @@
|
|||||||
WHERE record_id = #{recordId}
|
WHERE record_id = #{recordId}
|
||||||
ORDER BY created_time DESC
|
ORDER BY created_time DESC
|
||||||
</select>
|
</select>
|
||||||
|
<select id="selectByRecordIdList" resultType="com.cool.store.dto.pre.fry.PreFryStageImagesDTO">
|
||||||
|
SELECT id, record_id, image1, image2, created_time,stage
|
||||||
|
FROM xfsg_pre_fry_stage_changes
|
||||||
|
<where>
|
||||||
|
and record_id in
|
||||||
|
<foreach collection="recordIdList" item="item" open="(" separator="," close=")">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
</where>
|
||||||
|
ORDER BY created_time DESC
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.cool.store.dto.pre.fry;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author suzhuhong
|
||||||
|
* @Date 2025/6/23 19:04
|
||||||
|
* @Version 1.0
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class DailyFryCountDTO {
|
||||||
|
|
||||||
|
private Date fryDate;
|
||||||
|
private Integer count;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package com.cool.store.dto.pre.fry;
|
||||||
|
|
||||||
|
import com.cool.store.common.PageBasicInfo;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author suzhuhong
|
||||||
|
* @Date 2025/6/23 18:24
|
||||||
|
* @Version 1.0
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class FryRecordsQueryDTO extends PageBasicInfo {
|
||||||
|
|
||||||
|
@ApiModelProperty("门店编码")
|
||||||
|
private String storeCode;
|
||||||
|
@ApiModelProperty("当前日期")
|
||||||
|
private Date currentDate;
|
||||||
|
@ApiModelProperty("申请类型")
|
||||||
|
private Integer applyType;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package com.cool.store.dto.pre.fry;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author suzhuhong
|
||||||
|
* @Date 2025/6/23 17:23
|
||||||
|
* @Version 1.0
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class PreFryRecordsDetailDTO {
|
||||||
|
|
||||||
|
@ApiModelProperty( "ID")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@ApiModelProperty( "门店编码")
|
||||||
|
private String storeCode;
|
||||||
|
|
||||||
|
@ApiModelProperty( "预炸产品编码")
|
||||||
|
private Long productId;
|
||||||
|
|
||||||
|
@ApiModelProperty( "预炸产品名称")
|
||||||
|
private String productName;
|
||||||
|
@ApiModelProperty( "预炸记录编码")
|
||||||
|
private String recordCode;
|
||||||
|
|
||||||
|
@ApiModelProperty( "预炸产品图片")
|
||||||
|
private String productImageUrl;
|
||||||
|
|
||||||
|
@ApiModelProperty( "预炸完成时间")
|
||||||
|
private Date fryCompleteTime;
|
||||||
|
|
||||||
|
@ApiModelProperty( "最迟售卖时间")
|
||||||
|
private Date latestSaleTime;
|
||||||
|
|
||||||
|
@ApiModelProperty( "当前产品阶段:1-预炸完成,2-存入展示柜,3-放入冰箱,4-次日拿出,5-报废")
|
||||||
|
private Integer currentStage;
|
||||||
|
|
||||||
|
@ApiModelProperty( "申请类型")
|
||||||
|
private Integer currentApplyType;
|
||||||
|
|
||||||
|
@ApiModelProperty( "状态记录")
|
||||||
|
private List<PreFryStageImagesDTO> stageHistory;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.cool.store.dto.pre.fry;
|
package com.cool.store.dto.pre.fry;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@@ -12,10 +13,17 @@ import java.util.Date;
|
|||||||
@Data
|
@Data
|
||||||
public class PreFryStageImagesDTO {
|
public class PreFryStageImagesDTO {
|
||||||
|
|
||||||
|
@ApiModelProperty("ID")
|
||||||
private Integer id;
|
private Integer id;
|
||||||
private Integer recordId;
|
@ApiModelProperty("记录ID")
|
||||||
|
private Long recordId;
|
||||||
|
@ApiModelProperty("当前阶段")
|
||||||
|
private Integer stage;
|
||||||
|
@ApiModelProperty("图片1")
|
||||||
private String image1;
|
private String image1;
|
||||||
|
@ApiModelProperty("图片2")
|
||||||
private String image2;
|
private String image2;
|
||||||
|
@ApiModelProperty("时间")
|
||||||
private Date createdTime;
|
private Date createdTime;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,9 @@ public class PreFryRecordsDO {
|
|||||||
@Column(name = "product_id")
|
@Column(name = "product_id")
|
||||||
private Long productId;
|
private Long productId;
|
||||||
|
|
||||||
|
@Column(name = "record_code")
|
||||||
|
private String recordCode;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 预炸日期
|
* 预炸日期
|
||||||
@@ -76,6 +79,14 @@ public class PreFryRecordsDO {
|
|||||||
this.currentApplyType = currentApplyType;
|
this.currentApplyType = currentApplyType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getRecordCode() {
|
||||||
|
return recordCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRecordCode(String recordCode) {
|
||||||
|
this.recordCode = recordCode;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取主键ID
|
* 获取主键ID
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,7 +1,13 @@
|
|||||||
package com.cool.store.service;
|
package com.cool.store.service;
|
||||||
|
|
||||||
import com.cool.store.dto.pre.fry.AddPreFryRecordsDTO;
|
import com.cool.store.dto.pre.fry.AddPreFryRecordsDTO;
|
||||||
|
import com.cool.store.dto.pre.fry.DailyFryCountDTO;
|
||||||
|
import com.cool.store.dto.pre.fry.FryRecordsQueryDTO;
|
||||||
|
import com.cool.store.dto.pre.fry.PreFryRecordsDetailDTO;
|
||||||
import com.cool.store.vo.PartnerUserInfoVO;
|
import com.cool.store.vo.PartnerUserInfoVO;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author suzhuhong
|
* @Author suzhuhong
|
||||||
@@ -19,6 +25,13 @@ public interface PreFryRecordsService {
|
|||||||
Boolean batchInsert(AddPreFryRecordsDTO addPreFryRecordsDTO, PartnerUserInfoVO user);
|
Boolean batchInsert(AddPreFryRecordsDTO addPreFryRecordsDTO, PartnerUserInfoVO user);
|
||||||
|
|
||||||
|
|
||||||
|
PageInfo<PreFryRecordsDetailDTO> ListByStoreCodeAndDate(FryRecordsQueryDTO dto);
|
||||||
|
|
||||||
|
PreFryRecordsDetailDTO getById(Long id);
|
||||||
|
|
||||||
|
List<DailyFryCountDTO> queryByStoreCode(String storeCode, Long time);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -209,7 +209,7 @@ public class PreFryQualificationApplyServiceImpl implements PreFryQualificationA
|
|||||||
public String getPreFlyQualificationApplyCode() {
|
public String getPreFlyQualificationApplyCode() {
|
||||||
//当前日期
|
//当前日期
|
||||||
String today = CoolDateUtils.getToday();
|
String today = CoolDateUtils.getToday();
|
||||||
return "13" + today + String.format("%04d", ThreadLocalRandom.current().nextInt(10000));
|
return "13" + today + String.format("%04d", ThreadLocalRandom.current().nextInt(100000));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
package com.cool.store.service.impl;
|
package com.cool.store.service.impl;
|
||||||
|
|
||||||
|
import com.cool.store.dao.PreFriedProductsDAO;
|
||||||
import com.cool.store.dao.PreFryQualificationApplyDAO;
|
import com.cool.store.dao.PreFryQualificationApplyDAO;
|
||||||
import com.cool.store.dao.PreFryRecordsDAO;
|
import com.cool.store.dao.PreFryRecordsDAO;
|
||||||
import com.cool.store.dao.PreFryStageChangesDAO;
|
import com.cool.store.dao.PreFryStageChangesDAO;
|
||||||
import com.cool.store.dto.pre.fry.AddPreFryRecordsDTO;
|
import com.cool.store.dto.pre.fry.*;
|
||||||
|
import com.cool.store.entity.PreFriedProductsDO;
|
||||||
import com.cool.store.entity.PreFryQualificationApplyDO;
|
import com.cool.store.entity.PreFryQualificationApplyDO;
|
||||||
import com.cool.store.entity.PreFryRecordsDO;
|
import com.cool.store.entity.PreFryRecordsDO;
|
||||||
import com.cool.store.entity.PreFryStageChangesDO;
|
import com.cool.store.entity.PreFryStageChangesDO;
|
||||||
@@ -12,15 +14,21 @@ import com.cool.store.enums.PreFryApplyTypeEnum;
|
|||||||
import com.cool.store.enums.PreFryStageEnum;
|
import com.cool.store.enums.PreFryStageEnum;
|
||||||
import com.cool.store.exception.ServiceException;
|
import com.cool.store.exception.ServiceException;
|
||||||
import com.cool.store.service.PreFryRecordsService;
|
import com.cool.store.service.PreFryRecordsService;
|
||||||
|
import com.cool.store.utils.CoolDateUtils;
|
||||||
|
import com.cool.store.utils.poi.DateUtils;
|
||||||
import com.cool.store.vo.PartnerUserInfoVO;
|
import com.cool.store.vo.PartnerUserInfoVO;
|
||||||
|
import com.github.pagehelper.PageHelper;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Calendar;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
import java.util.Date;
|
import java.util.stream.Collectors;
|
||||||
import java.util.List;
|
|
||||||
|
import static com.cool.store.enums.PreFryStageEnum.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author suzhuhong
|
* @Author suzhuhong
|
||||||
@@ -38,6 +46,8 @@ public class PreFryRecordsServiceImpl implements PreFryRecordsService {
|
|||||||
PreFryStageChangesDAO preFryStageChangesDAO;
|
PreFryStageChangesDAO preFryStageChangesDAO;
|
||||||
@Resource
|
@Resource
|
||||||
PreFryQualificationApplyDAO preFryQualificationApplyDAO;
|
PreFryQualificationApplyDAO preFryQualificationApplyDAO;
|
||||||
|
@Resource
|
||||||
|
PreFriedProductsDAO preFriedProductsDAO;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -52,7 +62,7 @@ public class PreFryRecordsServiceImpl implements PreFryRecordsService {
|
|||||||
}
|
}
|
||||||
//如果出现优先级升高的情况 优先级低的只有报废可选择 1的优先级最高 3最低
|
//如果出现优先级升高的情况 优先级低的只有报废可选择 1的优先级最高 3最低
|
||||||
if (minApplyTypeByStoreCode.getApplyType()<addPreFryRecordsDTO.getApplyType()
|
if (minApplyTypeByStoreCode.getApplyType()<addPreFryRecordsDTO.getApplyType()
|
||||||
&&addPreFryRecordsDTO.getCurrentStage()!= PreFryStageEnum.DISCARDED.getCode()){
|
&&addPreFryRecordsDTO.getCurrentStage()!= DISCARDED.getCode()){
|
||||||
//当前有更优选择,请确认
|
//当前有更优选择,请确认
|
||||||
throw new ServiceException(ErrorCodeEnum.CURRENT_STAGE_NOT_OPERATION);
|
throw new ServiceException(ErrorCodeEnum.CURRENT_STAGE_NOT_OPERATION);
|
||||||
}
|
}
|
||||||
@@ -61,8 +71,10 @@ public class PreFryRecordsServiceImpl implements PreFryRecordsService {
|
|||||||
if (addPreFryRecordsFlag(minApplyTypeByStoreCode.getApplyType(), addPreFryRecordsDTO.getCurrentStage())){
|
if (addPreFryRecordsFlag(minApplyTypeByStoreCode.getApplyType(), addPreFryRecordsDTO.getCurrentStage())){
|
||||||
addPreFryRecordsDTO.getRecords().forEach(x->{
|
addPreFryRecordsDTO.getRecords().forEach(x->{
|
||||||
PreFryRecordsDO preFryRecordsDO = new PreFryRecordsDO();
|
PreFryRecordsDO preFryRecordsDO = new PreFryRecordsDO();
|
||||||
|
preFryRecordsDO.setStoreCode(addPreFryRecordsDTO.getStoreCode());
|
||||||
preFryRecordsDO.setProductId(x.getProductId());
|
preFryRecordsDO.setProductId(x.getProductId());
|
||||||
preFryRecordsDO.setFryDate(new Date());
|
preFryRecordsDO.setFryDate(new Date());
|
||||||
|
preFryRecordsDO.setRecordCode(getRecordCode());
|
||||||
preFryRecordsDO.setFryCompleteTime(new Date());
|
preFryRecordsDO.setFryCompleteTime(new Date());
|
||||||
preFryRecordsDO.setLatestSaleTime(getLatestSaleTime(minApplyTypeByStoreCode.getApplyType()));
|
preFryRecordsDO.setLatestSaleTime(getLatestSaleTime(minApplyTypeByStoreCode.getApplyType()));
|
||||||
preFryRecordsDO.setCurrentStage(addPreFryRecordsDTO.getCurrentStage());
|
preFryRecordsDO.setCurrentStage(addPreFryRecordsDTO.getCurrentStage());
|
||||||
@@ -77,6 +89,7 @@ public class PreFryRecordsServiceImpl implements PreFryRecordsService {
|
|||||||
list.add(preFryStageChangesDO);
|
list.add(preFryStageChangesDO);
|
||||||
});
|
});
|
||||||
}else {
|
}else {
|
||||||
|
List<Long> recordList= new ArrayList<>();
|
||||||
addPreFryRecordsDTO.getRecords().forEach(x->{
|
addPreFryRecordsDTO.getRecords().forEach(x->{
|
||||||
PreFryStageChangesDO preFryStageChangesDO = new PreFryStageChangesDO();
|
PreFryStageChangesDO preFryStageChangesDO = new PreFryStageChangesDO();
|
||||||
preFryStageChangesDO.setStage(addPreFryRecordsDTO.getCurrentStage());
|
preFryStageChangesDO.setStage(addPreFryRecordsDTO.getCurrentStage());
|
||||||
@@ -84,21 +97,91 @@ public class PreFryRecordsServiceImpl implements PreFryRecordsService {
|
|||||||
preFryStageChangesDO.setImage1(x.getImage1());
|
preFryStageChangesDO.setImage1(x.getImage1());
|
||||||
preFryStageChangesDO.setImage2(x.getImage2());
|
preFryStageChangesDO.setImage2(x.getImage2());
|
||||||
preFryStageChangesDO.setOperatorName(user.getUsername());
|
preFryStageChangesDO.setOperatorName(user.getUsername());
|
||||||
|
recordList.add(x.getRecordId());
|
||||||
list.add(preFryStageChangesDO);
|
list.add(preFryStageChangesDO);
|
||||||
});
|
});
|
||||||
|
preFryRecordsDAO.batchUpdateStageByIds(recordList,addPreFryRecordsDTO.getCurrentStage());
|
||||||
}
|
}
|
||||||
preFryStageChangesDAO.batchInsert(list);
|
preFryStageChangesDAO.batchInsert(list);
|
||||||
return Boolean.TRUE;
|
return Boolean.TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageInfo<PreFryRecordsDetailDTO> ListByStoreCodeAndDate(FryRecordsQueryDTO dto) {
|
||||||
|
PageHelper.startPage(dto.getPageNum(),dto.getPageSize());
|
||||||
|
if (dto.getCurrentDate()==null|| StringUtils.isBlank(dto.getStoreCode())){
|
||||||
|
throw new ServiceException(ErrorCodeEnum.PARAMS_REQUIRED);
|
||||||
|
}
|
||||||
|
List<PreFryRecordsDO> preFryRecordsDOS = preFryRecordsDAO.selectByStoreAndDateStage(dto.getStoreCode(), Arrays.asList(STORED_IN_FRIDGE.getCode(),
|
||||||
|
TAKEN_OUT_NEXT_DAY.getCode(), DISCARDED.getCode()), PRE_FRY_COMPLETED.getCode(), DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD,dto.getCurrentDate()));
|
||||||
|
PageInfo result = new PageInfo<>(preFryRecordsDOS);
|
||||||
|
if (CollectionUtils.isEmpty(preFryRecordsDOS)){
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
List<Long> recordIdList = preFryRecordsDOS.stream().map(PreFryRecordsDO::getId).collect(Collectors.toList());
|
||||||
|
List<PreFryStageImagesDTO> stageImagesDTOS = preFryStageChangesDAO.selectByRecordIdList(recordIdList);
|
||||||
|
List<Long> productIdList = preFryRecordsDOS.stream().map(PreFryRecordsDO::getProductId).collect(Collectors.toList());
|
||||||
|
List<PreFriedProductsDO> preFriedProductsDOS = preFriedProductsDAO.selectByProductIds(productIdList);
|
||||||
|
Map<Long, PreFriedProductsDO> preFriedProductsDOSMap = preFriedProductsDOS.stream().collect(Collectors.toMap(PreFriedProductsDO::getId, x -> x));
|
||||||
|
|
||||||
|
//将数据根据recordId分组 并根据id排序
|
||||||
|
Map<Long, List<PreFryStageImagesDTO>> stageImagesDTOMap =
|
||||||
|
stageImagesDTOS.stream().collect(Collectors.groupingBy(PreFryStageImagesDTO::getRecordId));
|
||||||
|
List<PreFryRecordsDetailDTO> list = new ArrayList<>();
|
||||||
|
preFryRecordsDOS.forEach(x->{
|
||||||
|
PreFryRecordsDetailDTO preFryRecordsDetailDTO = new PreFryRecordsDetailDTO();
|
||||||
|
preFryRecordsDetailDTO.setId(x.getId());
|
||||||
|
preFryRecordsDetailDTO.setStoreCode(x.getStoreCode());
|
||||||
|
preFryRecordsDetailDTO.setProductId(x.getProductId());
|
||||||
|
preFryRecordsDetailDTO.setProductName(preFriedProductsDOSMap.getOrDefault(x.getProductId(),new PreFriedProductsDO()).getProductName());
|
||||||
|
preFryRecordsDetailDTO.setProductImageUrl(preFriedProductsDOSMap.getOrDefault(x.getProductId(),new PreFriedProductsDO()).getProductImage());
|
||||||
|
preFryRecordsDetailDTO.setFryCompleteTime(x.getFryCompleteTime());
|
||||||
|
preFryRecordsDetailDTO.setLatestSaleTime(x.getLatestSaleTime());
|
||||||
|
preFryRecordsDetailDTO.setCurrentStage(x.getCurrentStage());
|
||||||
|
preFryRecordsDetailDTO.setCurrentApplyType(x.getCurrentApplyType());
|
||||||
|
preFryRecordsDetailDTO.setStageHistory(stageImagesDTOMap.getOrDefault(x.getId(),new ArrayList<>()));
|
||||||
|
list.add(preFryRecordsDetailDTO);
|
||||||
|
});
|
||||||
|
result.setList( list);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PreFryRecordsDetailDTO getById(Long id) {
|
||||||
|
PreFryRecordsDO preFryRecordsDO = preFryRecordsDAO.queryById(id);
|
||||||
|
if (preFryRecordsDO == null) {
|
||||||
|
throw new ServiceException(ErrorCodeEnum.PARAMS_REQUIRED);
|
||||||
|
}
|
||||||
|
List<PreFryStageImagesDTO> preFryStageImagesDTOS = preFryStageChangesDAO.selectByRecordId(id);
|
||||||
|
PreFriedProductsDO preFriedProductsDO = preFriedProductsDAO.queryById(preFryRecordsDO.getProductId());
|
||||||
|
PreFryRecordsDetailDTO preFryRecordsDetailDTO = new PreFryRecordsDetailDTO();
|
||||||
|
preFryRecordsDetailDTO.setId(preFryRecordsDO.getId());
|
||||||
|
preFryRecordsDetailDTO.setStoreCode(preFryRecordsDO.getStoreCode());
|
||||||
|
preFryRecordsDetailDTO.setProductId(preFryRecordsDO.getProductId());
|
||||||
|
preFryRecordsDetailDTO.setRecordCode(preFryRecordsDO.getRecordCode());
|
||||||
|
preFryRecordsDetailDTO.setProductName(preFriedProductsDO.getProductName());
|
||||||
|
preFryRecordsDetailDTO.setProductImageUrl(preFriedProductsDO.getProductImage());
|
||||||
|
preFryRecordsDetailDTO.setFryCompleteTime(preFryRecordsDO.getFryCompleteTime());
|
||||||
|
preFryRecordsDetailDTO.setLatestSaleTime(preFryRecordsDO.getLatestSaleTime());
|
||||||
|
preFryRecordsDetailDTO.setCurrentStage(preFryRecordsDO.getCurrentStage());
|
||||||
|
preFryRecordsDetailDTO.setCurrentApplyType(preFryRecordsDO.getCurrentApplyType());
|
||||||
|
preFryRecordsDetailDTO.setStageHistory(preFryStageImagesDTOS);
|
||||||
|
return preFryRecordsDetailDTO;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DailyFryCountDTO> queryByStoreCode(String storeCode,Long time) {
|
||||||
|
return preFryRecordsDAO.selectDailyFryCountInCurrentMonth(storeCode, time);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private Boolean addPreFryRecordsFlag(Integer applyType,Integer stage){
|
private Boolean addPreFryRecordsFlag(Integer applyType,Integer stage){
|
||||||
if (applyType== PreFryApplyTypeEnum.HAS_REFRIGERATED_DISPLAY.getCode() && stage==PreFryStageEnum.PRE_FRY_COMPLETED.getCode()){
|
if (applyType== PreFryApplyTypeEnum.HAS_REFRIGERATED_DISPLAY.getCode() && stage== PRE_FRY_COMPLETED.getCode()){
|
||||||
return Boolean.TRUE;
|
return Boolean.TRUE;
|
||||||
}else if (applyType == PreFryApplyTypeEnum.NO_DISPLAY.getCode() && stage==PreFryStageEnum.PRE_FRY_COMPLETED.getCode()){
|
}else if (applyType == PreFryApplyTypeEnum.NO_DISPLAY.getCode() && stage== PRE_FRY_COMPLETED.getCode()){
|
||||||
return Boolean.TRUE;
|
return Boolean.TRUE;
|
||||||
}
|
}
|
||||||
if (applyType==PreFryApplyTypeEnum.HAS_NORMAL_DISPLAY.getCode() && stage==PreFryStageEnum.STORED_IN_DISPLAY_CABINET.getCode()){
|
if (applyType==PreFryApplyTypeEnum.HAS_NORMAL_DISPLAY.getCode() && stage== STORED_IN_DISPLAY_CABINET.getCode()){
|
||||||
return Boolean.TRUE;
|
return Boolean.TRUE;
|
||||||
}
|
}
|
||||||
return Boolean.FALSE;
|
return Boolean.FALSE;
|
||||||
@@ -116,5 +199,11 @@ public class PreFryRecordsServiceImpl implements PreFryRecordsService {
|
|||||||
return calendar.getTime();
|
return calendar.getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getRecordCode() {
|
||||||
|
//当前日期
|
||||||
|
String today = CoolDateUtils.getToday();
|
||||||
|
return "14" + today + String.format("%04d", ThreadLocalRandom.current().nextInt(100000));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -203,9 +203,9 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
|
|||||||
* @param millis 毫秒数
|
* @param millis 毫秒数
|
||||||
* @return 时间
|
* @return 时间
|
||||||
*/
|
*/
|
||||||
public static String getDateByMillis(long millis) {
|
public static String getDateByMillis(long millis,String format) {
|
||||||
//12小时制
|
//12小时制
|
||||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(YYYY_MM_DD_HH_MM_SS);
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format);
|
||||||
Date date = new Date();
|
Date date = new Date();
|
||||||
date.setTime(millis);
|
date.setTime(millis);
|
||||||
return simpleDateFormat.format(date);
|
return simpleDateFormat.format(date);
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
package com.cool.store.controller.webc;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.cool.store.context.PartnerUserHolder;
|
||||||
|
import com.cool.store.dto.pre.fry.*;
|
||||||
|
import com.cool.store.response.ResponseResult;
|
||||||
|
import com.cool.store.service.PreFryRecordsService;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author suzhuhong
|
||||||
|
* @Date 2025/6/23 19:00
|
||||||
|
* @Version 1.0
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Api(tags = "预炸-预炸记录")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/mini/pre/record/")
|
||||||
|
public class PreFryRecordsController {
|
||||||
|
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
PreFryRecordsService preFryRecordsService;
|
||||||
|
|
||||||
|
@ApiOperation("预炸记录-按日期查询是否有预炸记录")
|
||||||
|
@GetMapping("/queryByStoreCode")
|
||||||
|
public ResponseResult<List<DailyFryCountDTO>> queryByStoreCode(@RequestParam(required = true, value = "storeCode") String storeCode,
|
||||||
|
@RequestParam(required = true, value = "time") Long time) {
|
||||||
|
log.info("预炸记录-按日期查询是否有预炸记录:{}", JSONObject.toJSONString(storeCode));
|
||||||
|
return ResponseResult.success(preFryRecordsService.queryByStoreCode(storeCode,time));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("预炸记录详情列表")
|
||||||
|
@GetMapping("/queryById")
|
||||||
|
public ResponseResult<PreFryRecordsDetailDTO> queryById(@RequestParam(required = true, value = "id") Long id) {
|
||||||
|
log.info("预炸记录详情:{}", JSONObject.toJSONString(id));
|
||||||
|
return ResponseResult.success(preFryRecordsService.getById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ApiOperation("预炸批量新增")
|
||||||
|
@PostMapping("/batchAdd")
|
||||||
|
public ResponseResult<Boolean> batchInsert(@RequestBody @Validated AddPreFryRecordsDTO dto) {
|
||||||
|
log.info("批量新增:{}", JSONObject.toJSONString(dto));
|
||||||
|
return ResponseResult.success(preFryRecordsService.batchInsert(dto, PartnerUserHolder.getUser()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("预炸列表 根据门店编码与日期查询")
|
||||||
|
@PostMapping("/ListByStoreCodeAndDate")
|
||||||
|
public ResponseResult<PageInfo<PreFryRecordsDetailDTO>> ListByStoreCodeAndDate(@RequestBody @Validated FryRecordsQueryDTO dto) {
|
||||||
|
log.info("预炸列表 根据门店编码与日期查询:{}", JSONObject.toJSONString(dto));
|
||||||
|
return ResponseResult.success(preFryRecordsService.ListByStoreCodeAndDate(dto));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user