feat:预炸
This commit is contained in:
@@ -1,9 +1,15 @@
|
||||
package com.cool.store.dao;
|
||||
|
||||
import com.cool.store.constants.CommonConstants;
|
||||
import com.cool.store.entity.PreFryRecordsDO;
|
||||
import com.cool.store.mapper.PreFryRecordsMapper;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @Author suzhuhong
|
||||
@@ -16,9 +22,50 @@ public class PreFryRecordsDAO {
|
||||
@Resource
|
||||
private PreFryRecordsMapper preFryRecordsMapper;
|
||||
|
||||
public int insert(PreFryRecordsDO record) {
|
||||
if (Objects.isNull(record)) {
|
||||
return CommonConstants.ZERO;
|
||||
}
|
||||
return preFryRecordsMapper.insertSelective(record);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public int batchInsert(List<PreFryRecordsDO> records) {
|
||||
if (CollectionUtils.isEmpty(records)) {
|
||||
return CommonConstants.ZERO;
|
||||
}
|
||||
return preFryRecordsMapper.batchInsert(records);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public PreFryRecordsDO queryById(Long id) {
|
||||
if (id == null) {
|
||||
return null;
|
||||
}
|
||||
return preFryRecordsMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
|
||||
|
||||
int batchUpdateStageByIds( List<Integer> ids,
|
||||
Integer currentStage){
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return CommonConstants.ZERO;
|
||||
}
|
||||
return preFryRecordsMapper.batchUpdateStageByIds(ids,currentStage);
|
||||
}
|
||||
|
||||
List<PreFryRecordsDO> selectByStoreAndDateStage(String storeCode,
|
||||
List<Integer> yesterdayStageList,
|
||||
Integer todayStage){
|
||||
if (StringUtils.isBlank(storeCode) || CollectionUtils.isEmpty(yesterdayStageList)) {
|
||||
return null;
|
||||
}
|
||||
return preFryRecordsMapper.selectByStoreAndDateStage(storeCode,yesterdayStageList,todayStage);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
package com.cool.store.dao;
|
||||
|
||||
import com.cool.store.constants.CommonConstants;
|
||||
import com.cool.store.dto.pre.fry.PreFryStageImagesDTO;
|
||||
import com.cool.store.entity.PreFryStageChangesDO;
|
||||
import com.cool.store.mapper.PreFryStageChangesMapper;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author suzhuhong
|
||||
@@ -16,11 +23,20 @@ public class PreFryStageChangesDAO {
|
||||
@Resource
|
||||
PreFryStageChangesMapper preFryStageChangesMapper;
|
||||
|
||||
public int batchInsert(List<PreFryStageChangesDO> records){
|
||||
if (CollectionUtils.isEmpty(records)){
|
||||
return CommonConstants.ZERO;
|
||||
}
|
||||
return preFryStageChangesMapper.batchInsert(records);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public List<PreFryStageImagesDTO> selectByRecordId( Integer recordId){
|
||||
if (recordId == null){
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return preFryStageChangesMapper.selectByRecordId(recordId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,15 +1,22 @@
|
||||
package com.cool.store.mapper;
|
||||
|
||||
import com.cool.store.entity.PreFryRecordsDO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import tk.mybatis.mapper.common.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface PreFryRecordsMapper extends Mapper<PreFryRecordsDO> {
|
||||
|
||||
|
||||
int batchInsert(List<PreFryRecordsDO> records);
|
||||
|
||||
int batchUpdateStageByIds(@Param("ids") List<Integer> ids,
|
||||
@Param("currentStage") Integer currentStage);
|
||||
|
||||
List<PreFryRecordsDO> selectByStoreAndDateStage(
|
||||
@Param("storeCode") String storeCode,
|
||||
@Param("yesterdayStageList") List<Integer> yesterdayStageList,
|
||||
@Param("todayStage") Integer todayStage);
|
||||
|
||||
|
||||
}
|
||||
@@ -1,14 +1,18 @@
|
||||
package com.cool.store.mapper;
|
||||
|
||||
import com.cool.store.dto.pre.fry.PreFryStageImagesDTO;
|
||||
import com.cool.store.entity.PreFryStageChangesDO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import tk.mybatis.mapper.common.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface PreFryStageChangesMapper extends Mapper<PreFryStageChangesDO> {
|
||||
|
||||
|
||||
int batchInsert(List<PreFryStageChangesDO> records);
|
||||
|
||||
|
||||
|
||||
List<PreFryStageImagesDTO> selectByRecordId(@Param("recordId") Integer recordId);
|
||||
|
||||
|
||||
}
|
||||
@@ -7,8 +7,7 @@
|
||||
-->
|
||||
<id column="id" jdbcType="INTEGER" property="id" />
|
||||
<result column="store_code" jdbcType="VARCHAR" property="storeCode" />
|
||||
<result column="product_code" jdbcType="VARCHAR" property="productCode" />
|
||||
<result column="product_name" jdbcType="VARCHAR" property="productName" />
|
||||
<result column="product_code" jdbcType="INTEGER" property="productId" />
|
||||
<result column="fry_date" jdbcType="DATE" property="fryDate" />
|
||||
<result column="fry_complete_time" jdbcType="TIMESTAMP" property="fryCompleteTime" />
|
||||
<result column="latest_sale_time" jdbcType="TIMESTAMP" property="latestSaleTime" />
|
||||
@@ -21,13 +20,40 @@
|
||||
|
||||
<insert id="batchInsert" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO xfsg_pre_fry_records
|
||||
(store_code, product_code, product_name, fry_date, fry_complete_time,
|
||||
(store_code, product_code, fry_date, fry_complete_time,
|
||||
latest_sale_time, current_stage, current_apply_type, created_time, updated_time)
|
||||
VALUES
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(#{item.storeCode}, #{item.productCode}, #{item.productName}, #{item.fryDate},
|
||||
(#{item.storeCode}, #{item.productCode}, #{item.fryDate},
|
||||
#{item.fryCompleteTime}, #{item.latestSaleTime}, #{item.currentStage},#{item.currentApplyType},
|
||||
NOW(), NOW())
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<update id="batchUpdateStageByIds">
|
||||
UPDATE xfsg_pre_fry_records
|
||||
SET current_stage = #{currentStage},
|
||||
updated_time = NOW()
|
||||
WHERE id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<select id="selectByStoreAndDateStage" resultMap="BaseResultMap">
|
||||
SELECT * FROM xfsg_pre_fry_records
|
||||
WHERE store_code = #{storeCode}
|
||||
AND (
|
||||
(fry_date = DATE_SUB(CURDATE(), INTERVAL 1 DAY)
|
||||
AND current_stage IN
|
||||
<foreach collection="yesterdayStageList" item="stage" open="(" separator="," close=")">
|
||||
#{stage}
|
||||
</foreach>)
|
||||
OR
|
||||
(fry_date = CURDATE() AND current_stage = #{todayStage})
|
||||
)
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -15,4 +15,25 @@
|
||||
<result column="created_time" jdbcType="TIMESTAMP" property="createdTime" />
|
||||
<result column="updated_time" jdbcType="TIMESTAMP" property="updatedTime" />
|
||||
</resultMap>
|
||||
|
||||
|
||||
<insert id="batchInsert" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO xfsg_pre_fry_stage_changes
|
||||
(record_id, stage, image1, image2, operator_name, remark, created_time, updated_time)
|
||||
VALUES
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(#{item.recordId}, #{item.stage}, #{item.image1}, #{item.image2},
|
||||
#{item.operatorName}, #{item.remark}, NOW(), NOW())
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
|
||||
<select id="selectByRecordId" resultType="com.cool.store.dto.pre.fry.PreFryStageImagesDTO">
|
||||
SELECT id, record_id, image1, image2, created_time
|
||||
FROM xfsg_pre_fry_stage_changes
|
||||
WHERE record_id = #{recordId}
|
||||
ORDER BY created_time DESC
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user