This commit is contained in:
cun-nan 2024-10-25 13:46:53 +08:00
parent a25303b23a
commit 130e8556ac
9 changed files with 361 additions and 203 deletions

View File

@ -41,7 +41,7 @@ export function getOilPresetList(data) {
return request({
url: 'business/petrolStationManagement/oilPresetPrices/getList',
method: 'get',
data: data
params: data
})
}
@ -79,6 +79,28 @@ export function insertOilPresePricesApi(data) {
data: data
})
}
// 修改预设
export function updateOilPresePricesApi(data) {
return request({
url: 'business/petrolStationManagement/oilPresetPrices',
method: 'put',
data: data
})
}
// 删除预设
export function deleteOilPresePricesApi(id) {
return request({
url: 'business/petrolStationManagement/oilPresetPrices/'+id,
method: 'delete',
})
}
// 删除预设
export function getOilPresePricesApi(id) {
return request({
url: 'business/petrolStationManagement/oilPresetPrices/'+id,
method: 'get',
})
}
export function stopJobApi(data) {
return request({

View File

@ -1,10 +1,11 @@
<script>
import {
deleteOilPresePricesApi,
getAllOilListApi,
getOilNameListApi,
getOilNameListApi, getOilPresePricesApi,
getOilPresetList,
insertOilPresePricesApi,
stopJobApi
stopJobApi, updateOilPresePricesApi
} from "@/api/oilPrice";
export default {
@ -19,13 +20,13 @@ export default {
},
},
oilPresetPricesList: [],
AllOilList:[],
AllOilList: [],
queryParams: {
pageNo: 1,
pageSize: 10,
},
title:'',
total:0,
title: '',
total: 0,
dialogFormPricesAdd: false,
oilPresetPrices: {
numberId: '',
@ -40,7 +41,18 @@ export default {
selectOilTypeByPrice: [],
oilPresetPricesRules: {
presetOilPrices: []
numberId: [
{required: true, message: "预设油品油号不能为空", trigger: "blur"},
],
presetOilPrices: [
{required: true, message: "预设油品挂牌价不能为空", trigger: "blur"},
],
presetGbPrice: [
{required: true, message: "预设油品国标价不能为空", trigger: "blur"},
],
effectiveTime: [
{required: true, message: "预设活动开始时间不能为空", trigger: "blur"},
],
}
}
},
@ -54,7 +66,7 @@ export default {
}
},
methods: {
async inittt(){
async inittt() {
await this.getAllOilList();
await this.getOilPresetListin();
@ -113,30 +125,67 @@ export default {
//
this.getOilNameList();
},
//
editRow(data) {
getOilPresePricesApi(data.presetId).then(res => {
this.dialogFormPricesAdd = true
this.oilPresetPrices = res.data
//
this.getOilNameList();
})
},
// youjia1
insertOilPresePrices() {
this.$refs["priForm"].validate(valid => {
if (valid) {
this.dialogFormPricesAdd = false
insertOilPresePricesApi(this.oilPresetPrices).then(response => {
var list = response.data
this.getOilNameList();
this.getAllOilList();
this.getOilPresetListin();
});
if (this.oilPresetPrices.presetId) {
updateOilPresePricesApi(this.oilPresetPrices).then(response => {
var list = response.data
this.getOilNameList();
this.getAllOilList();
this.getOilPresetListin();
});
} else {
insertOilPresePricesApi(this.oilPresetPrices).then(response => {
var list = response.data
this.getOilNameList();
this.getAllOilList();
this.getOilPresetListin();
});
}
}
});
},
//
deleteRow(data1, data2) {
stopJobApi(data2).then(response => {
this.$modal.msgSuccess("停止成功");
this.getOilPresetListin();
this.$confirm('是否停止本条数据,停止后无法恢复!', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
}).then(() => {
stopJobApi(data2).then(response => {
this.$modal.msgSuccess("停止成功");
this.getOilPresetListin();
});
});
}).catch(() => {});
},
//
deleteOilPresePrices(data) {
this.$confirm('是否删除本条数据,删除后无法恢复!', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
}).then(() => {
deleteOilPresePricesApi(data.presetId).then(response => {
this.$modal.msgSuccess("删除成功");
this.getOilPresetListin();
});
}).catch(() => {});
},
//
@ -157,173 +206,191 @@ export default {
</script>
<template>
<div>
<div class="card-change-1-search" style="margin-bottom: 20px">
<div style="display: flex; justify-content: space-between;margin-bottom: 10px">
<div style="display: flex;">
<div style="background-color: #FF9655;height: 22px;width: 4px;margin-right: 10px"></div>
<span>预设油价记录</span>
<div>
<div class="card-change-1-search" style="margin-bottom: 20px">
<div style="display: flex; justify-content: space-between;margin-bottom: 10px">
<div style="display: flex;">
<div style="background-color: #FF9655;height: 22px;width: 4px;margin-right: 10px"></div>
<span>预设油价记录</span>
</div>
<div>
<el-button type="primary" @click="addOilPresePrices()"
>新增预设油价
</el-button>
</div>
</div>
<div>
<el-button type="primary" @click = "addOilPresePrices()"
>新增预设油价</el-button>
<div class="table-box">
<el-table
:data="oilPresetPricesList"
style="width: auto">
<el-table-column
type="index"
label="序号"
align="center"
width="100">
</el-table-column>
<!-- prop="presetGbPrice"-->
<el-table-column
prop="oilNameT"
align="center"
label="预设油号"
>
</el-table-column>
<el-table-column label="当前数据" style="width: 100%" align="center"
>
<el-table-column
prop="currentPetrolPrices"
align="center"
label="油站价"
>
</el-table-column>
<el-table-column
prop="currentGbPrice"
align="center"
label="国标价"
>
</el-table-column>
</el-table-column>
<el-table-column label="预设新数据" style="width: 100%" align="center"
>
<el-table-column
prop="presetOilPrices"
align="center"
label="挂牌价"
>
</el-table-column>
<el-table-column
prop="presetGbPrice"
align="center"
label="国标价"
>
</el-table-column>
</el-table-column>
<el-table-column
prop="effectiveTime"
align="center"
label="预设活动开始时间"
>
</el-table-column>
<el-table-column label="状态" align="center">
<template slot-scope="scope">
<div style="color: #009946" v-if="scope.row.state == 'occur'">已生效</div>
<div style="color: #00CAFF" v-else-if="scope.row.state == 'wait'">等待中</div>
<div style="color: #F44522" v-else>已失效</div>
</template>
</el-table-column>
<el-table-column
prop="realName"
align="center"
label="创建人"
>
</el-table-column>
<el-table-column
prop="createTime"
align="center"
label="创建时间"
>
</el-table-column>
<el-table-column
fixed="right"
align="center"
label="操作"
width="120">
<template slot-scope="scope">
<el-button v-if="scope.row.state == 'wait'"
@click.native.prevent="editRow(scope.row)"
type="text"
size="small">
修改
</el-button>
<el-button v-if="scope.row.state == 'wait'"
@click.native.prevent="deleteRow(scope.$index, scope.row)"
type="text"
size="small">
停止
</el-button>
<el-button v-if="scope.row.state == 'lose'"
@click.native.prevent="deleteOilPresePrices(scope.row)"
type="text"
size="small">
删除
</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNo"
:limit.sync="queryParams.pageSize"
@pagination="inittt"
/>
</div>
</div>
<div class="table-box">
<el-table
:data="oilPresetPricesList"
style="width: auto">
<el-table-column
type="index"
label="序号"
align="center"
width="100">
</el-table-column>
<!-- prop="presetGbPrice"-->
<el-table-column
prop="oilNameT"
align="center"
label="预设油号"
>
</el-table-column>
<el-table-column label="当前数据" style="width: 100%" align="center"
>
<el-table-column
prop="currentPetrolPrices"
align="center"
label="油站价"
>
</el-table-column>
<el-table-column
prop="currentGbPrice"
align="center"
label="国标价"
>
</el-table-column>
</el-table-column>
<el-table-column label="预设新数据" style="width: 100%" align="center"
>
<el-table-column
prop="presetOilPrices"
align="center"
label="油站价"
>
</el-table-column>
<el-table-column
prop="presetGbPrice"
align="center"
label="国标价"
>
</el-table-column>
</el-table-column>
<el-table-column
prop="effectiveTime"
align="center"
label="预设时间"
>
</el-table-column>
<!-- <el-table-column-->
<!-- prop="state"-->
<!-- label="处理状态"-->
<!-- >-->
<el-table-column label="状态" align="center">
<template slot-scope="scope">
<!-- <dict-tag :options="dict.type.jobState" :value="scope.row.state"/>-->
<el-tag v-if="scope.row.state == 'occur'" type="success">已生效</el-tag>
<el-tag v-else-if="scope.row.state == 'wait'">等待中</el-tag>
<el-tag v-else type="info">已失效</el-tag>
</template>
</el-table-column>
<el-table-column
prop="createTime"
align="center"
label="创建时间"
>
</el-table-column>
<el-table-column
fixed="right"
align="center"
label="操作"
width="120">
<template slot-scope="scope">
<el-button v-if="scope.row.state == 'wait'"
@click.native.prevent="deleteRow(scope.$index, scope.row)"
type="text"
size="small">
停止
</el-button>
<span v-else> -- </span>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNo"
:limit.sync="queryParams.pageSize"
@pagination="inittt"
/>
</div>
<el-dialog title="新增/修改预设油价" :visible.sync="dialogFormPricesAdd" width="30%" :close-on-click-modal="false">
<el-form ref="priForm" :model="oilPresetPrices" label-width="140px" :rules="oilPresetPricesRules">
<el-form-item label="预设油品油号" prop="numberId">
<el-select v-model="oilPresetPrices.numberId" placeholder="请选择油品名称" style="width: 100%"
@change="oilTypeClickByPrice()">
<el-option
v-for="option in selectOilTypeByPrice"
:key="option.numberId"
:label="option.oilType +' '+option.oilName"
:value="option.numberId"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="当前油品挂牌价">
<el-input v-model="oilPresetPrices.currentPetrolPrices " readonly disabled>
<template slot="append">{{ oilPresetPrices.unit ? "/" + oilPresetPrices.unit : oilPresetPrices.unit }}
</template>
</el-input>
</el-form-item>
<el-form-item label="预设油站挂牌价" prop="presetOilPrices">
<el-input v-model="oilPresetPrices.presetOilPrices" pattern="^\d+(\.\d+)?$">
<template slot="append">{{ oilPresetPrices.unit ? "/" + oilPresetPrices.unit : oilPresetPrices.unit }}
</template>
</el-input>
</el-form-item>
<el-form-item label="当前油品国标价">
<el-input v-model="oilPresetPrices.currentGbPrice" readonly disabled>
<template slot="append">{{ oilPresetPrices.unit ? "/" + oilPresetPrices.unit : oilPresetPrices.unit }}
</template>
</el-input>
</el-form-item>
<el-form-item label="预设油品国标价" prop="presetGbPrice">
<el-input v-model="oilPresetPrices.presetGbPrice" pattern="^\d+(\.\d+)?$">
<template slot="append">{{ oilPresetPrices.unit ? "/" + oilPresetPrices.unit : oilPresetPrices.unit }}
</template>
</el-input>
</el-form-item>
<el-form-item label="预设活动开始时间" prop="effectiveTime">
<el-date-picker
v-model="oilPresetPrices.effectiveTime"
type="datetime"
placeholder="选择日期时间"
style="width: 100%"
:default-value="defaultDateTime"
:picker-options="pickerOptions"
value-format="yyyy-MM-dd HH:mm:ss">
</el-date-picker>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="dialogFormPricesAdd = false"> </el-button>
<el-button type="primary" @click="insertOilPresePrices()"> </el-button>
</div>
</el-dialog>
</div>
<el-dialog title="添加预设" :visible.sync="dialogFormPricesAdd" width="20%" :close-on-click-modal="false">
<el-form ref="priForm" :model="oilPresetPrices" label-width="100px" :rules="oilPresetPricesRules">
<el-form-item label="预设油号" prop="numberId" label-width="120px">
<el-select v-model="oilPresetPrices.numberId" placeholder="请选择油号" @change="oilTypeClickByPrice()">
<el-option
v-for="option in selectOilTypeByPrice"
:key="option.numberId"
:label="option.oilType +' '+option.oilName"
:value="option.numberId"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="当前油品售出价" label-width="120px">
<el-input v-model="oilPresetPrices.currentPetrolPrices " style="width: 217px" readonly disabled>
<template slot="append">{{oilPresetPrices.unit?"/"+oilPresetPrices.unit:oilPresetPrices.unit}}</template>
</el-input>
</el-form-item>
<el-form-item label="预设油站售出价" prop="presetOilPrices" label-width="120px">
<el-input v-model="oilPresetPrices.presetOilPrices" pattern="^\d+(\.\d+)?$" style="width: 217px">
<template slot="append">{{oilPresetPrices.unit?"/"+oilPresetPrices.unit:oilPresetPrices.unit}}</template>
</el-input>
</el-form-item>
<el-form-item label="当前国标价" label-width="120px">
<el-input v-model="oilPresetPrices.currentGbPrice" style="width: 217px" readonly disabled>
<template slot="append">{{oilPresetPrices.unit?"/"+oilPresetPrices.unit:oilPresetPrices.unit}}</template>
</el-input>
</el-form-item>
<el-form-item label="预设国标价" prop="presetGbPrice" label-width="120px">
<el-input v-model="oilPresetPrices.presetGbPrice" pattern="^\d+(\.\d+)?$" style="width: 217px">
<template slot="append">{{oilPresetPrices.unit?"/"+oilPresetPrices.unit:oilPresetPrices.unit}}</template>
</el-input>
</el-form-item>
<el-form-item label="活动时间" prop="effectiveTime" label-width="120px">
<el-date-picker
v-model="oilPresetPrices.effectiveTime"
type="datetime"
placeholder="选择日期时间"
style="width: 217px"
:default-value="defaultDateTime"
:picker-options="pickerOptions"
value-format="yyyy-MM-dd HH:mm:ss">
</el-date-picker>
</el-form-item>
<!-- <div class="hui-seiz">如生效时间与当前时间间隔小于1分钟,当前油价将立即生效</div>-->
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="dialogFormPricesAdd = false"> </el-button>
<el-button type="primary" @click="insertOilPresePrices()"> </el-button>
</div>
</el-dialog>
</div>
</template>
<style scoped lang="scss">

View File

@ -297,14 +297,14 @@ export default {
border
style="width: auto">
<el-table-column type="index" label="序号" align="center" width="100"></el-table-column>
<el-table-column prop="oilTypeT" align="center" label="油品名称"/>
<el-table-column prop="oilTypeT" align="center" label="油品类型"/>
<el-table-column prop="oilNameT" align="center" label="油号名称"/>
<el-table-column prop="unit" align="center" label="计价单位"/>
<el-table-column prop="oilPrice" align="center" label="当前油品挂牌价"/>
<el-table-column prop="gbPrice" align="center" label="当前油品国标价"/>
<el-table-column prop="oilPrice" align="center" label="当前油品挂牌价(元/L"/>
<el-table-column prop="gbPrice" align="center" label="当前油品国标价(元/L"/>
<el-table-column prop="state" align="center" label="状态"/>
<el-table-column prop="remark" align="center" label="备注"/>
<el-table-column prop="oilNameT" align="center" label="创建人"/>
<el-table-column prop="realName" align="center" label="创建人"/>
<el-table-column prop="createTime" align="center" label="创建时间"/>
<el-table-column
fixed="right"

View File

@ -109,7 +109,7 @@ public class OilPresetPricesController extends BaseController {
*
* @return 删除结果
*/
@DeleteMapping
@DeleteMapping("{id}")
public ResponseObject delete(@PathVariable Integer id) {
try {
SysLog sysLog =new SysLog();

View File

@ -45,7 +45,9 @@ public class OilNumber extends BaseEntity {
public String amplitudeOfChange; //涨幅
@TableField(exist = false)
public String oilNames;
/**
* 创建人
*/
@TableField(exist = false)
private String realName;
}

View File

@ -1,6 +1,7 @@
package com.fuint.business.petrolStationManagement.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fuint.repository.model.base.BaseEntity;
@ -32,7 +33,11 @@ public class OilPresetPrices extends BaseEntity {
private Integer storeId; // 关联的店铺id
private Long jobId; // 定时任务id
/**
* 创建人
*/
@TableField(exist = false)
private String realName;
// /**
// * 获取主键值

View File

@ -29,8 +29,8 @@
</sql>
<select id="selectOilNumberList" resultMap="OilNumberResult">
<include refid="selectOilNumber"></include>
where store_id = #{oilNumber.storeId}
SELECT onu.*,ms.real_name FROM oil_number onu LEFT JOIN mt_staff ms ON onu.create_by = ms.id
where onu.store_id = #{oilNumber.storeId}
</select>

View File

@ -30,9 +30,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectOilPresetPricesList"
resultType="com.fuint.business.petrolStationManagement.entity.OilPresetPrices">
<include refid="selectOilPresetPrices"></include>
where store_id = #{presetPrices.storeId}
order by create_time desc
SELECT opp.*,ms.real_name FROM oil_preset_prices opp LEFT JOIN mt_staff ms ON opp.create_by = ms.id
where opp.store_id = #{presetPrices.storeId}
order by opp.create_time desc
</select>
<!-- older by preset_id desc-->
@ -53,6 +53,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test=" presetGbPrice != null">preset_gb_price,</if>
<if test=" createTime != null">create_time,</if>
<if test=" createTime != null">update_time,</if>
<if test=" createBy != null">create_by,</if>
<if test=" createBy != null">update_by,</if>
<if test=" effectiveTime != null">effective_time,</if>
<if test=" ifDelete != null">if_delete,</if>
<if test=" state != null">state,</if>
@ -67,6 +69,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test=" presetGbPrice != null">#{presetGbPrice},</if>
<if test=" createTime != null">#{createTime},</if>
<if test=" createTime != null">#{createTime},</if>
<if test=" createBy != null">#{createBy},</if>
<if test=" createBy != null">#{createBy},</if>
<if test=" effectiveTime != null">#{effectiveTime},</if>
<if test=" ifDelete != null">#{ifDelete},</if>
<if test=" state != null">#{state},</if>
@ -77,15 +81,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="updateOilPresetPrices">
update oil_preset_prices
<set>
<if test=" oilType != null">preset_id = #{oilType},</if>
<if test=" currentPetrolPrices != null"> oil_type = #{currentPetrolPrices},</if>
<if test=" presetOilPrices != null"> current_petrol_prices = #{presetOilPrices},</if>
<if test=" currentGbPrice != null"> preset_oil_prices = #{currentGbPrice},</if>
<if test=" presetGbPrice != null"> presetGbPrice = #{presetGbPrice},</if>
<if test=" updateTime != null"> create_time = #{updateTime},</if>
<if test=" effectiveTime != null"> update_time = #{effectiveTime},</if>
<if test=" ifDelete != null"> effective_time = #{ifDelete},</if>
<if test=" state != null"> effective_time = #{ifDelete},</if>
<if test=" oilType != null">oil_type = #{oilType},</if>
<if test=" currentPetrolPrices != null"> current_petrol_prices = #{currentPetrolPrices},</if>
<if test=" presetOilPrices != null"> preset_oil_prices = #{presetOilPrices},</if>
<if test=" currentGbPrice != null"> current_gb_price = #{currentGbPrice},</if>
<if test=" presetGbPrice != null"> preset_gb_price = #{presetGbPrice},</if>
<if test=" updateBy != null"> update_by = #{updateBy},</if>
<if test=" updateTime != null"> update_time = #{updateTime},</if>
<if test=" effectiveTime != null"> effective_time = #{effectiveTime},</if>
<if test=" ifDelete != null"> if_delete = #{ifDelete},</if>
<if test=" state != null"> state = #{state},</if>
</set>
where preset_id = #{presetId}
</update>

View File

@ -19,7 +19,10 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
/**
@ -77,8 +80,24 @@ public class OilPresetPricesServiceImpl extends ServiceImpl<OilPresetPricesMappe
presetPrices.setCreateBy(nowAccountInfo.getStaffId().toString());
presetPrices.setState("wait");
try {
if (judgeEnable(presetPrices.getEffectiveTime())){
presetPrices.setState("occur");
}
}catch (Exception e) {
e.printStackTrace();
}
baseMapper.insertOilPresetPrices(presetPrices);
if (presetPrices.getState().equals("occur")) {
// 关联价格将number中的数据修改掉
OilNumber oilNumber = new OilNumber();
oilNumber.setNumberId(presetPrices.getNumberId());
oilNumber.setOilPrice(presetPrices.getPresetOilPrices());
oilNumber.setGbPrice(presetPrices.getPresetGbPrice());
oilNumberMapper.updateOilNumber(oilNumber);
}
String coreTime = changeCore(presetPrices.getEffectiveTime());
// 创建定时任务
SysJob sysJob = new SysJob();
@ -102,6 +121,25 @@ public class OilPresetPricesServiceImpl extends ServiceImpl<OilPresetPricesMappe
return baseMapper.updateJobId(presetPrices);
}
/**
* 判断生效时间是否小于等于当前时间
* @param effectiveTime
* @return
*/
private boolean judgeEnable(String effectiveTime) throws ParseException {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date dateFromString = sdf.parse(effectiveTime);
Date currentDate = new Date();
if (dateFromString.before(currentDate)){
return true;
}else if (dateFromString.after(currentDate)){
return false;
}else {
return true;
}
}
private String changeCore(String dateTimeString) {
String inputPattern = "yyyy-MM-dd HH:mm:ss";
@ -140,9 +178,28 @@ public class OilPresetPricesServiceImpl extends ServiceImpl<OilPresetPricesMappe
@Override
public int updateOilPresetPrices(OilPresetPrices presetPrices) {
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
presetPrices.setStoreId(nowAccountInfo.getStoreId());
presetPrices.setUpdateBy(nowAccountInfo.getStaffId().toString());
presetPrices.setUpdateTime(new Date());
return baseMapper.insertOilPresetPrices(presetPrices);
try {
if (judgeEnable(presetPrices.getEffectiveTime())){
presetPrices.setState("occur");
}
}catch (Exception e){
e.printStackTrace();
}
int row = baseMapper.updateOilPresetPrices(presetPrices);
if (presetPrices.getState().equals("occur")) {
// 关联价格将number中的数据修改掉
OilNumber oilNumber = new OilNumber();
oilNumber.setNumberId(presetPrices.getNumberId());
oilNumber.setOilPrice(presetPrices.getPresetOilPrices());
oilNumber.setGbPrice(presetPrices.getPresetGbPrice());
oilNumberMapper.updateOilNumber(oilNumber);
}
return row;
}
@Override