!258 导粉记录优化,采购计划SQL优化,后续建立索引

Merge pull request !258 from 德仔/xzj
This commit is contained in:
德仔 2021-05-25 09:33:10 +08:00 committed by Gitee
commit fe1691970d
7 changed files with 137 additions and 27 deletions

View File

@ -162,4 +162,26 @@ public class SysImportFanRecordController extends BaseController
result.put("fanNumList", fanNumList);
return AjaxResult.success(result);
}
/**
* 删除导粉记录中对应微信记录
*/
@PreAuthorize("@ss.hasPermi('custom:importFanRecord:remove')")
@Log(title = "删除导粉记录中对应微信记录", businessType = BusinessType.DELETE)
@GetMapping("/removeFanWxAccount/{ids}")
public AjaxResult removeFanWxAccount(@PathVariable Long[] ids)
{
return toAjax(sysImportFanWxAccountService.deleteSysImportFanWxAccountByIds(ids));
}
/**
* 删除导粉记录中对应微信记录
*/
@PreAuthorize("@ss.hasPermi('custom:importFanRecord:edit')")
@GetMapping("/saveWxAccountFanNum")
public AjaxResult saveWxAccountFanNum(SysImportFanWxAccount sysImportFanWxAccount)
{
return toAjax(sysImportFanWxAccountService.updateSysImportFanWxAccount(sysImportFanWxAccount));
}
}

View File

@ -64,7 +64,10 @@ public class SysRecipesServiceImpl implements ISysRecipesService {
@Override
public List<SysRecipes> selectSysRecipesByRecipesId(Long id) {
return sysRecipesMapper.selectSysRecipesByRecipesId(id);
long t = System.currentTimeMillis();
List<SysRecipes> list = sysRecipesMapper.selectSysRecipesByRecipesId(id);
System.out.println(System.currentTimeMillis() - t);
return list;
}
@Override

View File

@ -28,7 +28,7 @@
<result property="fanChannelName" column="fan_channel_name"></result>
<!-- 根据渠道查询对应微信号(微信账号分配表中) -->
<!--<association property="wxAccountList" column="fan_channel" select="getWxAccountListByFanChannel"/>-->
<association property="wxAccountList" column="id" select="getWxAccountListByLiveId"/>
</resultMap>
<resultMap type="SysLiveSchedul" id="SysLiveSchedulResultSigle">
@ -74,9 +74,9 @@
<if test="fanChannel != null">
and slc.fan_channel = #{fanChannel}
</if>
<if test="wxAccountId != null">
<!--<if test="wxAccountId != null">
and slc.fan_channel = (SELECT swd.account_id FROM sys_wx_distribution AS swd where swd.wechat_account = #{wxAccountId} and swd.del_flag = 0 limit 1)
</if>
</if>-->
order by slc.live_schedul_date desc,slc.live_start_time desc ,slc.live_room asc
</select>
@ -162,14 +162,15 @@
</foreach>
</update>
<!-- 根据渠道查询该渠道下分配的微信号 -->
<select id="getWxAccountListByFanChannel" parameterType="Integer" resultType="Map">
SELECT su.nick_name as nickName,swsa.wx_account as wxAccount,asg.dict_label as saleGroupName
FROM sys_wx_distribution AS swd
lEFT JOIN sys_wx_sale_account swsa ON swsa.id = swd.wechat_account and swsa.del_flag = 0
LEFT JOIN sys_user su ON su.user_id = swd.user_id AND su.del_flag = 0
LEFT JOIN (SELECT dict_label, dict_value FROM sys_dict_data WHERE dict_type = 'sale_group') AS asg ON asg.dict_value = swd.sale_group_id
where swd.account_id = #{fan_channel} and swd.del_flag = 0
<!-- 根据直播ID查询该渠道下分配的微信号 -->
<select id="getWxAccountListByLiveId" parameterType="Long" resultType="Map">
SELECT su.nick_name as saleName,w.wx_account as wxAccount, sum(wa.import_fan_num) as fanNum from sys_import_fan_record as fc
left join sys_import_fan_wx_account as wa on wa.import_fan_record_id = fc.id and wa.del_flag = 0
left join sys_wx_sale_account as w on w.id = wa.import_wx_account_id and w.del_flag = 0
left join sys_wx_distribution swd on swd.wechat_account = w.id and swd.del_flag = 0
left join sys_user su on swd.user_id = su.user_id and su.del_flag = 0
where fc.import_fan_live = #{id} and fc.del_flag = 0
group by w.wx_account,su.nick_name
</select>
<!-- 查询直播时间范围是否重叠 -->

View File

@ -198,12 +198,16 @@
</select>
<select id="selectDishesByMenuIdShow" parameterType="Long" resultMap="SysDishesResultShow">
SELECT * FROM (SELECT id, menu_id, dishes_id, type, detail, remark FROM sys_customer_menu_dishes WHERE menu_id = #{id}) AS menu
LEFT JOIN sys_dishes ON menu.dishes_id = sys_dishes.id
SELECT
menu.id, menu.menu_id, menu.dishes_id, menu.type, menu.detail, menu.remark, sd.is_main,sd.name,sd.methods
FROM (SELECT id, menu_id, dishes_id, type, detail, remark FROM sys_customer_menu_dishes WHERE menu_id = #{id}) AS menu
LEFT JOIN sys_dishes as sd ON menu.dishes_id = sd.id
</select>
<select id="selectIngredientsByDishesIdShow" parameterType="Long" resultMap="SysIgdsResultShow">
SELECT * FROM(
SELECT
ing.id,ing.name,ing.type.ing.protein_ratio,ing.fat_ratio,ing.carbon_ratio.ing.area,dishes.cus_weight,dishes.cus_unit,dishes.weight
FROM(
SELECT ingredient_id AS id, ingredient_weight AS weight, cus_weight, cus_unit, remark
FROM sys_dishes_ingredient
WHERE dishes_id = #{id}

View File

@ -59,3 +59,20 @@ export function getWxAccountAndSale(query){
params: query
})
}
// 删除导粉记录中对应的微信记录
export function removeFanWxAccount(id) {
return request({
url: '/custom/importFanRecord/removeFanWxAccount/' + id,
method: 'get'
})
}
export function saveWxAccountFanNum(data){
return request({
url: '/custom/importFanRecord/saveWxAccountFanNum',
method: 'get',
params: data
})
}

View File

@ -104,12 +104,48 @@
<template slot-scope="scope">
<el-popover
placement="left"
width="390"
width="520"
trigger="click">
<el-table :data="scope.row.wxAccountList" style="width:370;height: 400px;overflow: auto;">
<el-table-column width="100" property="saleName" label="销售" align="center"></el-table-column>
<el-table :data="scope.row.wxAccountList" style="width:450;height: 400px;overflow: auto;">
<el-table-column width="80" property="saleName" label="销售" align="center"></el-table-column>
<el-table-column width="160" property="wxAccount" label="微信号" align="center"></el-table-column>
<el-table-column width="80" property="importFanNum" label="导粉数量" align="center"></el-table-column>
<el-table-column width="120" property="importFanNum" label="导粉数量" align="center">
<template slot-scope="scope">
<div v-if="scope.row.updateFlag">
<el-input-number v-model="scope.row.importFanNum" controls-position="right" :min="1" :max="10000" style="width:100px"></el-input-number>
</div>
<div v-else>
{{scope.row.importFanNum}}
</div>
</template>
</el-table-column>
<el-table-column width="120" label="操作" align="center">
<template slot-scope="scope">
<el-button
v-if="scope.row.updateFlag"
size="mini"
type="text"
icon="el-icon-check"
@click="saveWxAccountFanNum(scope.row)"
v-hasPermi="['custom:importFanRecord:edit']"
>保存</el-button>
<el-button
v-else
size="mini"
type="text"
icon="el-icon-edit"
@click="scope.row.updateFlag = true"
v-hasPermi="['custom:importFanRecord:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="removeWxAccount(scope.row.id)"
v-hasPermi="['custom:importFanRecord:remove']"
>移除</el-button>
</template>
</el-table-column>
</el-table>
<el-button slot="reference">详情</el-button>
</el-popover>
@ -158,7 +194,7 @@
:layout="`${'total, slot, sizes, prev, pager, next, jumper'}`"
@pagination="getList"
>
<span style="margin-right: 12px" v-if="!isMobile"
<span style="margin-right: 12px"
>总计导粉量{{
totalFanNum
}}
@ -195,7 +231,7 @@
</template>
<script>
import { listImportFanRecord, getImportFanRecord, delImportFanRecord, addImportFanRecord, updateImportFanRecord, exportImportFanRecord } from "@/api/custom/importFanRecord";
import { listImportFanRecord, getImportFanRecord, delImportFanRecord, addImportFanRecord, updateImportFanRecord, exportImportFanRecord,removeFanWxAccount,saveWxAccountFanNum } from "@/api/custom/importFanRecord";
import ImportFan from "@/components/ImportFanRecord/ImportFan";
import dayjs from "dayjs";
const nowDate = dayjs().format("YYYY-MM-DD");
@ -257,6 +293,13 @@ export default {
listImportFanRecord(this.queryParams).then(response => {
if(response.rows != null && response.rows.length > 0){
this.totalFanNum = response.rows[0].totalFanNum;
response.rows.forEach((item,index) => {
if(item.wxAccountList != null && item.wxAccountList.length > 0){
item.wxAccountList.forEach((wx,i) => {
wx.updateFlag = false;
})
}
});
}else{
this.totalFanNum = 0;
}
@ -393,6 +436,26 @@ export default {
});
}
return fanNum;
},
removeWxAccount(id){
removeFanWxAccount(id).then(response => {
if (response.code === 200) {
this.msgSuccess("移除成功");
this.getList();
}
});
},
saveWxAccountFanNum(row){
let param = {
id: row.id,
importFanNum: row.importFanNum
};
saveWxAccountFanNum(param).then(response => {
if (response.code === 200) {
this.msgSuccess("保存成功");
this.getList();
}
});
}
}
};

View File

@ -144,12 +144,12 @@
<template slot-scope="scope">
<el-popover
placement="left"
width="390"
width="370"
trigger="click">
<el-table :data="scope.row.wxAccountList" style="width:370;height: 400px;overflow: auto;">
<el-table-column width="100" property="nickName" label="销售"></el-table-column>
<el-table-column width="120" property="wxAccount" label="微信号"></el-table-column>
<el-table-column width="120" property="saleGroupName" label="销售组别"></el-table-column>
<el-table :data="scope.row.wxAccountList" style="width:360;height: 300px;overflow: auto;">
<el-table-column width="80" property="saleName" label="销售"></el-table-column>
<el-table-column width="180" property="wxAccount" label="微信号" align="center"></el-table-column>
<el-table-column width="80" property="fanNum" label="导粉量" align="center"></el-table-column>
</el-table>
<el-button slot="reference">详情</el-button>
</el-popover>