2025年度投票修改

This commit is contained in:
路 范
2025-06-10 19:19:30 +08:00
parent 88316af778
commit 4d17ef84c2
14 changed files with 1096 additions and 8 deletions

View File

@@ -642,6 +642,15 @@
<Content Update="wwwroot\html\outsidewall\result.html"> <Content Update="wwwroot\html\outsidewall\result.html">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content> </Content>
<Content Update="wwwroot\html\yjbvote2025\Expert.html">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\html\yjbvote2025\index.html">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\html\yjbvote2025\VoteResult.html">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\html\yjbvote\Expert.html"> <Content Update="wwwroot\html\yjbvote\Expert.html">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content> </Content>

View File

@@ -106,7 +106,7 @@
//location = '/gb/yjb/manage/VoteResult' //location = '/gb/yjb/manage/VoteResult'
//location = '/gb/yjb/manage/nbczResult' //location = '/gb/yjb/manage/nbczResult'
//location = '/202307/html/outsidewall/result.html' //location = '/202307/html/outsidewall/result.html'
location = '../yjbvote/voteresult.html'; location = '../yjbvote2025/voteresult.html';
} }
} }
_this.loading = false; _this.loading = false;

View File

@@ -0,0 +1,175 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="../../lib/element-ui/theme-chalk/index.css">
<script src="../../lib/vue2/vue.min.js"></script>
<script src="../../lib/element-ui/theme-chalk/index.js"></script>
<script src="../../lib/axios/axios.min.js"></script>
<script src="../../lib/qs/qs.min.js"></script>
</head>
<body>
<div id="app" v-loading="loading">
<h3 style="text-align:center;">专家选票结果</h3>
<el-table :data="tableData" style="width: 20%;margin:0 auto;">
<el-table-column prop="login_code" label="专家"> </el-table-column>
<el-table-column prop="is_vote" label="是否投票" width="120">
<template slot-scope="scope">
<el-tag type="info" v-if="scope.row.is_vote==true">已投</el-tag>
<el-tag type="danger" v-else>未投</el-tag>
</template>
</el-table-column>
</el-table>
<h3 style="text-align:center;">
<el-button @click="load_vote">刷新数据</el-button>
<el-button @click="show_expert_vote">查看项目投票情况</el-button>
<el-button @click="show_dialog">新增专家</el-button>
</h3>
<el-dialog title="新增专家" :visible.sync="dialogVisible" width="20%">
<div class="blocks">
<el-input v-model="addexpertnum" placeholder="输入新增专家个数" style="width:100px"></el-input>
<el-button @click="add_expert">确定</el-button>
</div>
</el-dialog>
<!--<el-dialog v-model="dialogVisible" title="弹框" :close-on-click-modal="false" :close-on-press-escape="false" :show-close="false" append-to-body width="60%">
<el-form :model="pageData.loginForm" ref="loginFormRef" label-position="top">
<el-form-item label="手机号码" label-width="80px" prop="phone" :rules="[{ required: true, trigger: 'blur', min: 11, max: 11, message: '请输入正确的手机号码' }]">
<el-input v-model="pageData.loginForm.phone" autocomplete="off" />
</el-form-item>
<el-form-item label="验证码" label-width="80px" prop="code" :rules="[{ required: true, trigger: 'blur', min: 4, max: 4, message: '请输入验证码' }]">
<el-input type="text" maxlength="4" placeholder="验证码" v-model="pageData.loginForm.code">
<template slot="append" #append>
<el-button :disabled="pageData.loginForm.disabled" @click="(v,v2)=>funHandles.getCode(v,pageData,loginFormRef)">{{ pageData.loginForm.valiBtn }}</el-button>
</template>
</el-input>
</el-form-item>
</el-form>
<template #footer>
<span class="dialog-footer">-->
<!--<el-button @click="dialogFormVisible = false">Cancel</el-button>-->
<!--<el-button type="primary" @click="(v,v2)=>funHandles.verifyKey(pageData,loginFormRef)">登录</el-button>
</span>
</template>
</el-dialog>-->
</div>
</body>
<style scoped>
.buhuanhang {
white-space: nowrap;
width: 21%;
}
</style>
<script>
new Vue({
el: '#app',
data: function () {
return {
tableData: [],
loading: false,
token: '',
dialogVisible: false,
addexpertnum: 1
}
},
created: function () {
this.check_login()
this.loading = true;
this.load_vote();
},
methods: {
show_expert_vote() {
location = 'voteresult.html'
},
check_login() {
this.token = window.sessionStorage.getItem('__TOKEN');
if (!this.token)
location = '../manage/login.html'
},
load_vote() {
this.loading = true;
let _this = this;
axios({
headers: { 'Content-Type': 'application/json;charset=UTF-8' },
method: 'post',
url: '/gb/yjb/api/projects2025/expert-vote',
data: {},
responseType: "json",
headers: {
Authorization: 'Bearer ' + _this.token
}
}).then(function (response) {
_this.tableData = response.data.data
console.log(_this.tableData)
_this.loading = false;
}).catch(function (error) {
if (error.response.status == 403)
location = '../manage/login.html'
console.log(error)
_this.$message({
type: 'error',
message: error.message
})
_this.loading = false;
})
},
loading_false() { this.loading = false },
dateFormat(fmt, date) {
let ret;
const opt = {
"Y+": date.getFullYear().toString(), // 年
"m+": (date.getMonth() + 1).toString(), // 月
"d+": date.getDate().toString(), // 日
"H+": date.getHours().toString(), // 时
"M+": date.getMinutes().toString(), // 分
"S+": date.getSeconds().toString() // 秒
// 有其他格式化字符需求可以继续添加,必须转化成字符串
};
for (let k in opt) {
ret = new RegExp("(" + k + ")").exec(fmt);
if (ret) {
fmt = fmt.replace(ret[1], (ret[1].length == 1) ? (opt[k]) : (opt[k].padStart(ret[1].length, "0")))
};
};
return fmt;
}
,
show_dialog() {
this.dialogVisible = true
}
,
add_expert() {
this.loading = true;
let _this = this;
axios({
headers: { 'Content-Type': 'application/json;charset=UTF-8' },
method: 'post',
url: '/gb/yjb/api/projects2025/expert',
data: { expertnum: this.addexpertnum },
responseType: "json",
headers: {
Authorization: 'Bearer ' + _this.token
}
}).then(function (response) {
_this.loading = false;
location.reload();
}).catch(function (error) {
console.log(error)
_this.$message({
type: 'error',
message: error.message
})
_this.loading = false;
})
}
}
})
</script>
</html>

View File

@@ -0,0 +1,217 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="../../lib/element-ui/theme-chalk/index.css">
<script src="../../lib/vue2/vue.min.js"></script>
<script src="../../lib/element-ui/theme-chalk/index.js"></script>
<script src="../../lib/axios/axios.min.js"></script>
<script src="../../lib/qs/qs.min.js"></script>
</head>
<body>
<div id="app" v-loading="loading">
<h3 style="text-align:center;">2024年度宁波市市级优质工程免于现场评估项目选票结果</h3>
<el-collapse style="width: 80%;margin:0 auto;">
<el-collapse-item v-for="(prolist,idx) in tableData1" :title="prolist.name" :name="idx" v-show="prolist.data.length>0" :key="idx">
<el-table :data="prolist.data" style="width:95%;margin:0 auto;">
<el-table-column prop="serial_number" label="序号" width="120"> </el-table-column>
<el-table-column prop="name" label="工程名称"> </el-table-column>
<el-table-column prop="no_count" label="不同意票数" width="120"> </el-table-column>
<el-table-column prop="yes_count" label="同意票数" width="120"> </el-table-column>
<el-table-column prop="is_agree" label="是否通过" width="120">
<template slot-scope="scope">
<el-tag type="info" v-if="scope.row.is_agree==true">通过</el-tag>
<el-tag type="danger" v-else>不通过</el-tag>
</template>
</el-table-column>
</el-table>
</el-collapse-item>
</el-collapse>
<h3 style="text-align:center;">
<el-button @click="load_projects">刷新数据</el-button>
<el-button type="primary" @click="export_excel1">导出Excel</el-button>
<el-button @click="show_expert_vote">查看专家投票情况</el-button>
</h3>
<el-collapse style="width: 80%;margin:0 auto;">
<h3 style="text-align:center;">2024年度宁波市市级优质工程现场评估项目选票结果</h3>
<el-collapse-item v-for="(prolist,idx) in tableData2" :title="prolist.name" :name="idx" v-show="prolist.data.length>0" :key="idx">
<el-table :data="prolist.data" style="width:95%;margin:0 auto;">
<el-table-column prop="serial_number" label="序号" width="120"> </el-table-column>
<el-table-column prop="name" label="工程名称"> </el-table-column>
<el-table-column prop="no_count" label="不同意票数" width="120"> </el-table-column>
<el-table-column prop="yes_count" label="同意票数" width="120"> </el-table-column>
<el-table-column prop="is_agree" label="是否通过" width="120">
<template slot-scope="scope">
<el-tag type="info" v-if="scope.row.is_agree==true">通过</el-tag>
<el-tag type="danger" v-else>不通过</el-tag>
</template>
</el-table-column>
</el-table>
</el-collapse-item>
<h3 style="text-align:center;">
<el-button @click="load_projects">刷新数据</el-button>
<el-button type="primary" @click="export_excel2">导出Excel</el-button>
<el-button @click="show_expert_vote">查看专家投票情况</el-button>
</h3>
</div>
</body>
<style scoped>
.buhuanhang {
white-space: nowrap;
width: 21%;
}
</style>
<script>
new Vue({
el: '#app',
data: function () {
return {
tableData1: [],
tableData2: [],
loading: false,
token: ''
}
},
created: function () {
this.check_login()
this.loading = true;
this.load_projects();
},
methods: {
show_expert_vote() {
//location = '/gb/yjb/manage/expert'
location = 'Expert.html'
},
export_excel1() {
this.download('/gb/yjb/api/projects2025/download?s=1', this.dateFormat("YYYYmmddHHMMSS", new Date()) + "-选票结果.xlsx", this.loading_false);
},
export_excel2() {
this.download('/gb/yjb/api/projects2025/download?s=2', this.dateFormat("YYYYmmddHHMMSS", new Date()) + "-选票结果.xlsx", this.loading_false);
},
check_login() {
this.token = window.sessionStorage.getItem('__TOKEN');
if (!this.token)
location = '../manage/login.html'
},
load_projects() {
this.loading = true;
let _this = this;
axios({
headers: { 'Content-Type': 'application/json;charset=UTF-8' },
method: 'post',
url: '/gb/yjb/api/projects2025/list2',
data: {},
responseType: "json",
headers: {
Authorization: 'Bearer ' + _this.token
}
}).then(function (response) {
_this.tableData1 = [];
_this.tableData2 = [];
console.log(response)
let typeList = response.data.data.typeList
let _data = response.data.data.data
let _data1 = _data.filter(a => { return a.is_no_inspection == 1 });
let _data2 = _data.filter(a => { return a.is_no_inspection == 0 });
for (var i = 0; i < typeList.length; i++) {
var _p = _data1.filter(a => { return a.type == i; });
_this.tableData1.push({ name: typeList[i], data: _p })
}
console.log(_this.tableData1)
for (var i = 0; i < typeList.length; i++) {
var _p = _data2.filter(a => { return a.type == i; });
_this.tableData2.push({ name: typeList[i], data: _p })
}
console.log(_this.tableData2)
_this.loading = false;
}).catch(function (error) {
if (error.response.status == 403)
location = '../manage/login.html'
console.log(error)
_this.$message({
type: 'error',
message: error.message
})
_this.loading = false;
})
},
loading_false() { this.loading = false },
download(url, filename, callback) {
let _this = this;
axios({
headers: { 'Content-Type': 'application/json;charset=UTF-8' },
method: 'post',
url: url,
data: {},
responseType: "blob",
headers: {
Authorization: 'Bearer ' + _this.token
}
}).then(function (response) {
console.log(response);
//解析文件充blod中解析
const url = window.URL.createObjectURL(
new Blob([response.data], { type: "application/vnd.ms-excel" })
);
const link = document.createElement("a");
link.style.display = "none";
link.href = url;
link.setAttribute("download", filename);
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
callback();
}).catch(function (error) {
callback();
console.log(error)
_this.$message({
type: 'error',
message: error.message
})
})
},
getMonthWeek(now) {
var a = now.getYear();
var b = now.getMonth() + 1;
var c = now.getDate();
/*
a = d = 当前日期
b = 6 - w = 当前周的还有几天过完(不算今天)
a + b 的和在除以7 就是当天是当前月份的第几周
*/
var date = new Date(a, parseInt(b) - 1, c), w = date.getDay(), d = date.getDate();
return Math.ceil(
(d + 6 - w) / 7
);
},
dateFormat(fmt, date) {
let ret;
const opt = {
"Y+": date.getFullYear().toString(), // 年
"m+": (date.getMonth() + 1).toString(), // 月
"d+": date.getDate().toString(), // 日
"H+": date.getHours().toString(), // 时
"M+": date.getMinutes().toString(), // 分
"S+": date.getSeconds().toString() // 秒
// 有其他格式化字符需求可以继续添加,必须转化成字符串
};
for (let k in opt) {
ret = new RegExp("(" + k + ")").exec(fmt);
if (ret) {
fmt = fmt.replace(ret[1], (ret[1].length == 1) ? (opt[k]) : (opt[k].padStart(ret[1].length, "0")))
};
};
return fmt;
}
}
})
</script>
</html>

View File

@@ -0,0 +1,291 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0,
maximum-scale=1.0, user-scalable=no" />
<link rel="stylesheet" href="../../lib/element-ui/theme-chalk/index.css">
<script src="../../lib/vue2/vue.min.js"></script>
<script src="../../lib/element-ui/theme-chalk/index.js"></script>
<script src="../../lib/axios/axios.min.js"></script>
<script src="../../lib/qs/qs.min.js"></script>
</head>
<body>
<div id="app" v-loading="loading">
<h3 style="text-align:center;">2024年度宁波市市级优质工程免于现场评估项目</h3>
<el-collapse>
<el-collapse-item v-for="(prolist,idx) in projects1" :title="prolist.name" :name="idx" v-show="prolist.data.length>0" :key="idx">
<el-descriptions class="margin-top" title="" :column="1" border v-for="project in prolist.data" :key="project.id">
<el-descriptions-item label-class-name="buhuanhang" label="项目名称">{{project.serial_number}}:{{project.name}}</el-descriptions-item>
<el-descriptions-item label="请投票">
<template>
<el-radio-group v-model="project.vote">
<el-radio label="true">同意</el-radio>
<el-radio label="false">淘汰</el-radio>
</el-radio-group>
</template>
</el-descriptions-item>
</el-descriptions>
</el-collapse-item>
</el-collapse>
<h3 style="text-align:center;">2024年度宁波市市级优质工程现场评估项目</h3>
<el-collapse>
<el-collapse-item v-for="(prolist,idx) in projects2" :title="prolist.name" :name="idx" v-show="prolist.data.length>0" :key="idx">
<el-descriptions class="margin-top" title="" :column="1" border v-for="project in prolist.data" :key="project.id">
<el-descriptions-item label-class-name="buhuanhang" label="项目名称">{{project.serial_number}}:{{project.name}}</el-descriptions-item>
<el-descriptions-item label="请投票">
<template>
<el-radio-group v-model="project.vote">
<el-radio label="true">同意</el-radio>
<el-radio label="false">淘汰</el-radio>
</el-radio-group>
</template>
</el-descriptions-item>
</el-descriptions>
</el-collapse-item>
</el-collapse>
<h3 style="text-align:center;">
<el-input v-model="logincode" placeholder="请输入提交码"></el-input>
</h3>
<h3 style="text-align:center;">
<el-button @click="alltrue">重置</el-button>
<el-button type="primary" @click="submit">提交</el-button>
</h3>
</div>
</body>
<style scoped>
.buhuanhang {
white-space: nowrap;
width: 21%;
}
.el-message-box {
width: 300px !important;
}
</style>
<script>
new Vue({
el: '#app',
data: function () {
return {
projects1: [],
projects2: [],
confirm_title: '',
loading: false,
logincode: ''
}
},
created: function () {
this.loading = true;
this.load_projects();
},
methods: {
alltrue() {
this.projects1.map(a => {
a.data.map(b => { b.vote = "true"; return b; })
});
this.projects2.map(a => {
a.data.map(b => { b.vote = "true"; return b; })
});
},
async checkcode() {
let _this = this;
//检验码
if (this.logincode.length < 6) {
//this.$alert(`<div>提交码输入错误</div>`, '错误', {
// confirmButtonText: '确定', dangerouslyUseHTMLString: true, center: true, closeOnClickModal: true
//}).then(a => { }).catch(err => { console.log(err) });
alert("提交码输入错误");
return false;
}
return new Promise((resolve, reject) => {
axios({
headers: { 'Content-Type': 'application/json;charset=UTF-8' },
method: 'post',
url: '/gb/yjb/api/projects/check-submit-code',
data: { 'code': this.logincode },
responseType: "json",
}).then(async response => {
if (response.data.data != true) {
//_this.$alert(`<div>提交码输入错误</div>`, '错误', {
// confirmButtonText: '确定', dangerouslyUseHTMLString: true, center: true, closeOnClickModal: true
//}).then(a => { }).catch(err => { console.log(err) });
alert("提交码输入错误");
reject();
} else {
resolve(true)
}
_this.loading = false;
}).catch(async error => {
console.log(error)
_this.$message({
type: 'error',
message: error.message
})
_this.loading = false;
})
})
},
async submit() {
let _this = this;
await this.checkcode().then(a => {
if (a == false)
return;
var msg1 = "";
var msg2 = "";
var all_no_select_num = 0;
var select_false_list = [];
var all_select_false_num = 0;
var all_select_true_num = 0;
var allselects = [];
let projects = _this.projects1.concat(_this.projects2);
for (var i = 0; i < projects.length; i++) {
var _p = projects[i];
if (_p.data.length > 0) {
var no_select = _p.data.filter(a => { return !a.vote }).length;
all_no_select_num += no_select;
if (no_select > 0) {
msg1 += `<p>目前[` + _p.name + `]未选择的有` + no_select + `个</p>`;
}
var select_false = _p.data.filter(a => { return a.vote == "false" }).length;
select_false_list.push(select_false)
if (select_false < 1) {
msg2 += `<p>目前[` + _p.name + `]淘汰的有` + select_false + `个</p>`;
}
all_select_false_num += select_false;
all_select_true_num += _p.data.filter(a => { return a.vote == "true" }).length;
allselects = allselects.concat(_p.data)
}
}
if (all_no_select_num > 0) {
//this.$alert(`<div>请全部选择完毕后再次提交!</div>` + msg1, '错误', {
// confirmButtonText: '确定', dangerouslyUseHTMLString: true, center: true, closeOnClickModal: true
//}).then(a => { }).catch(err => { console.log(err) });
alert("请全部选择完毕后再次提交");
return;
}
debugger
//if (select_false_list.filter(a => a < 1).length > 0) {
// this.$alert(`<div>每个专业必须有一个淘汰!</div>` + msg2, '错误', {
// confirmButtonText: '确定', dangerouslyUseHTMLString: true, center: true, closeOnClickModal: true
// }).then(a => { }).catch(err => { console.log(err) });
// return;
//}
////房建不少于5个
//if (select_false_list[0] < 5) {
// this.$alert(`<div>房建工程不少于5个淘汰</div>` + msg2, '错误', {
// confirmButtonText: '确定', dangerouslyUseHTMLString: true, center: true, closeOnClickModal: true
// }).then(a => { }).catch(err => { console.log(err) });
// return;
//}
////市政不少于4个
//if (select_false_list[1] < 1) {
// this.$alert(`<div>市政工程不少于4个淘汰</div>` + msg2, '错误', {
// confirmButtonText: '确定', dangerouslyUseHTMLString: true, center: true, closeOnClickModal: true
// }).then(a => { }).catch(err => { console.log(err) });
// return;
//}
////交通不少于1个
//if (select_false_list[3] < 1) {
// this.$alert(`<div>交通工程不少于1个淘汰</div>` + msg2, '错误', {
// confirmButtonText: '确定', dangerouslyUseHTMLString: true, center: true, closeOnClickModal: true
// }).then(a => { }).catch(err => { console.log(err) });
// return;
//}
////水利不少于1个
//if (select_false_list[4] < 1) {
// this.$alert(`<div>水利工程不少于1个淘汰</div>` + msg2, '错误', {
// confirmButtonText: '确定', dangerouslyUseHTMLString: true, center: true, closeOnClickModal: true
// }).then(a => { }).catch(err => { console.log(err) });
// return;
//}
if (all_select_false_num <= 5) {
//this.$alert(`<div>淘汰总数必须大于20个</div>` + msg2, '错误', {
// confirmButtonText: '确定', dangerouslyUseHTMLString: true, center: true, closeOnClickModal: true
//}).then(a => { }).catch(err => { console.log(err) });
alert("淘汰总数必须大于5个");
return;
}
this.$confirm('您此次选择了同意' + all_select_true_num + '个,淘汰' + all_select_false_num + '个,是否继续提交?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
_this.loading = true;
axios({
headers: { 'Content-Type': 'application/json;charset=UTF-8' },
method: 'post',
url: '/gb/yjb/api/projects/submit-vote',
data: { 'code': this.logincode, 'projects': allselects },
responseType: "json",
}).then(async response => {
if (response.data.data != true) {
//_this.$alert(`<div>` + response.data.message + `</div>`, '错误', {
// confirmButtonText: '确定', dangerouslyUseHTMLString: true, center: true, closeOnClickModal: true
//}).then(a => { }).catch(err => { console.log(err) });
alert(response.data.message);
} else {
//_this.$alert(`<div>提交成功</div>`, '成功', {
// confirmButtonText: '确定', dangerouslyUseHTMLString: true, center: true, closeOnClickModal: true
//}).then(a => { }).catch(err => { console.log(err) });
alert("提交成功");
}
_this.loading = false;
}).catch(async error => {
console.log(error)
_this.$message({
type: 'error',
message: error.message
})
_this.loading = false;
})
}).catch(() => {
});
})
},
load_projects() {
let _this = this;
axios({
headers: { 'Content-Type': 'application/json;charset=UTF-8' },
method: 'post',
url: '/gb/yjb/api/projects2025/list',
data: {},
responseType: "json",
}).then(function (response) {
//console.log(response)
var typeList = response.data.data.typeList
let _data1 = response.data.data.data1
_data1.map(a => { a.vote = !a.vote ? '' : a.vote.toString(); return a; });
for (var i = 0; i < typeList.length; i++) {
var _p = _data1.filter(a => { return a.type == i; });
_this.projects1.push({ name: typeList[i], data: _p })
}
let _data2 = response.data.data.data2
_data2.map(a => { a.vote = !a.vote ? '' : a.vote.toString(); return a; });
for (var i = 0; i < typeList.length; i++) {
var _p = _data2.filter(a => { return a.type == i; });
_this.projects2.push({ name: typeList[i], data: _p })
}
_this.alltrue();
_this.loading = false;
}).catch(function (error) {
console.log(error)
_this.$message({
type: 'error',
message: error.message
})
_this.loading = false;
})
},
loading_false() { this.loading = false },
}
})
</script>
</html>

View File

@@ -0,0 +1,270 @@
using COSXML.Model.Tag;
using Ewide.Core.Util;
using Furion.DatabaseAccessor;
using Furion.DynamicApiController;
using Furion.FriendlyException;
using Mapster;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Vote.Services.Dto;
using Vote.Services.Entities;
using static Vote.Services.Dto.ProjectsList2Output;
namespace Vote.Services.ApiController
{
/// <summary>
/// 项目
/// </summary>
[ApiDescriptionSettings("Vote", Order = 0)]
[Route("/gb/yjb/api/projects2025")]
public class Projects2025Service : IDynamicApiController
{
//private readonly IRepository<Entities.Projects> rep_Projects;
private readonly IRepository<Entities.Projects_2025> rep_Projects2025;
private readonly IRepository<Entities.Experts> rep_Experts;
private readonly IRepository<Entities.VoteRecords> rep_VoteRecords;
private readonly IRepository<Entities.Projects_2021> rep_Projects2021;
private readonly IRepository<Entities.VoteRecords_2021> rep_VoteRecords2021;
private readonly IRepository<Entities.Projects_2022> rep_Projects2022;
private readonly IRepository<Entities.VoteRecords_2022> rep_VoteRecords2022;
public Projects2025Service(
IRepository<Entities.Projects> _rep_Projects,
IRepository<Entities.Experts> _rep_Experts,
IRepository<Entities.VoteRecords> _rep_VoteRecords,
IRepository<Entities.Projects_2021> _rep_Projects2021,
IRepository<Entities.VoteRecords_2021> _rep_VoteRecords2021,
IRepository<Entities.Projects_2022> _rep_Projects2022,
IRepository<Entities.VoteRecords_2022> _rep_VoteRecords2022,
IRepository<Projects_2025> _rep_Projects2025)
{
//rep_Projects = _rep_Projects;
rep_Experts = _rep_Experts;
rep_VoteRecords = _rep_VoteRecords;
rep_Projects2021 = _rep_Projects2021;
rep_VoteRecords2021 = _rep_VoteRecords2021;
rep_Projects2022 = _rep_Projects2022;
rep_VoteRecords2022 = _rep_VoteRecords2022;
rep_Projects2025 = _rep_Projects2025;
}
/// <summary>
/// 列表
/// </summary>
/// <returns></returns>
[HttpPost]
[Microsoft.AspNetCore.Authorization.AllowAnonymous]
public async Task<dynamic> List(ProjectsInput args)
{
var typeList = new List<string> { "房建工程", "市政工程", "轨道交通工程", "能源工程", "交通工程", "水利工程" };
var data = await rep_Projects2025.DetachedEntities.Where(p => !p.IsDeleted)
.Where(args.type != null, a => (int)a.type == args.type)
.Where(args.is_no_inspection != null, a => (int)a.is_no_inspection == args.is_no_inspection)
.ProjectToType<ProjectsOutput>()
.OrderBy(a => a.serial_number)
.ToListAsync();
var data1 = data.Where(a => a.is_no_inspection == 1).ToList();
var data2 = data.Where(a => a.is_no_inspection == 0).ToList();
return new
{
typeList,
data1,
data2
};
}
/// <summary>
/// 检验提交码
/// </summary>
/// <returns></returns>
[HttpPost]
[Microsoft.AspNetCore.Authorization.AllowAnonymous]
public async Task<dynamic> CheckSubmitCode(CheckSubmitCodeInput args)
{
var data = await rep_Experts.DetachedEntities.Where(p => !p.IsDeleted)
.Where(a => a.login_code == args.code)
.FirstOrDefaultAsync();
return data != null;
}
/// <summary>
/// 提交
/// </summary>
/// <returns></returns>
[HttpPost]
[UnitOfWork]
[Microsoft.AspNetCore.Authorization.AllowAnonymous]
public async Task<dynamic> SubmitSubmitVote(SubmitInput args)
{
try
{
var data = await rep_Experts.DetachedEntities.Where(p => !p.IsDeleted)
.Where(a => a.login_code == args.code)
.FirstOrDefaultAsync();
_ = (data == null) ? throw Oops.Oh("提交码错误") : 1;
//var list = args.projects.Adapt<List<Entities.VoteRecords>>();
//删除这个专家上次提交的结果
//或者提示不能再次提交
_ = (await rep_VoteRecords.DetachedEntities.Where(a => !a.IsDeleted && a.expert_login_code == args.code).CountAsync() > 0) ? throw Oops.Oh("已提交,无需再次提交") : 1;
var now = DateTime.Now;
args.projects.ForEach(async a =>
{
var model = new Entities.VoteRecords
{
expert_login_code = args.code,
project_id = a.id,
is_agree = a.vote,
vote_time = now
};
await model.InsertOrUpdate();
});
return true;
}
catch (Exception ex)
{
return false;
}
}
private async Task<List<ProjectsList2Output>> GetVoteData()
{
var query = from a in rep_Projects2025.DetachedEntities
join b in rep_VoteRecords.DetachedEntities
on a.Id equals b.project_id into grouping
from p in grouping.DefaultIfEmpty()
group new { a, p } by new { a.Id, a.name, a.serial_number, a.type, a.is_no_inspection } into pp
select new ProjectsList2Output
{
serial_number = pp.Key.serial_number,
id = pp.Key.Id,
name = pp.Key.name,
yes_count = pp.Where(a => a.p.is_agree).Count(),
no_count = pp.Where(a => !a.p.is_agree).Count(),
type = pp.Key.type,
is_no_inspection = pp.Key.is_no_inspection
};
return await query.OrderBy(a => a.serial_number).ToListAsync();
}
/// <summary>
/// 列表
/// </summary>
/// <returns></returns>
[HttpPost]
public async Task<dynamic> List2()
{
//var data = rep_Projects.DetachedEntities.Where(p => !p.IsDeleted)
// //.Where(args.type != null, a => (int)a.type == args.type)
// .Join(rep_VoteRecords.DetachedEntities, a => a.Id, a => a.project_id, (a, b) =>
// new
// {
// //a.Id,
// //type = (int)a.type,
// //serial_number = a.serial_number,
// //name = a.name,
// //no_count = b.Where(bb => !bb.is_agree).Count(),
// //yes_count = b.Where(bb => bb.is_agree).Count(),
// }).ToList();
////.ProjectToType<ProjectsList2Output>()
////.OrderBy(a => a.serial_number)
////.ToListAsync();
var data = await GetVoteData();
//var data0 = data.Where(a => a.type == Entities.EnumProjectType.FangJian).ToList();
//var data1 = data.Where(a => a.type == Entities.EnumProjectType.ShiZheng).ToList();
//var data2 = data.Where(a => a.type == Entities.EnumProjectType.GuiDaoGongCheng).ToList();
//var data3 = data.Where(a => a.type == Entities.EnumProjectType.DianLiGongCheng).ToList();
//var data4 = data.Where(a => a.type == Entities.EnumProjectType.JiaoTongGongCheng).ToList();
//var data5 = data.Where(a => a.type == Entities.EnumProjectType.ShuiLiGongCheng).ToList();
//return new
//{
// data0,
// data1,
// data2,
// data3,
// data4,
// data5
//};
var typeList = new List<string> { "房建工程", "市政工程", "轨道交通工程", "能源工程", "交通工程", "水利工程" };
return new { data, typeList };
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public async Task<dynamic> Download([FromQuery] int s)
{
var data = await GetVoteData();
var data1 = data.Where(a => a.is_no_inspection == 1).ToList();
var data2 = data.Where(a => a.is_no_inspection == 0).ToList();
//var filepath = Tools.ExcelHelper.WriteTemplate(data, 4, "C");
string template_name = s == 1 ? "票1 免于现场评估项目汇总表投票表格.xlsx" : "票2 现场评估项目(含)现场投票表格.xlsx";
var filepath = Tools.ExcelHelper.WriteTemplate(template_name, s == 1 ? data1 : data2, 5, "C");
return new FileStreamResult(new FileStream(filepath, FileMode.Open), "application/octet-stream") { FileDownloadName = filepath };
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public async Task<dynamic> ExpertVote()
{
try
{
var list = await rep_Experts.DetachedEntities.GroupJoin(rep_VoteRecords.DetachedEntities, a => a.login_code, a => a.expert_login_code, (a, b) => new { a, b })
.SelectMany(a => a.b.DefaultIfEmpty(), (a, b) => new { a.a.Id, a.a.login_code, is_vote = b != null })
.Distinct()
.OrderBy(a => a.Id)
.ToListAsync();
return list;
//var query = from a in rep_Experts.DetachedEntities
// join b in rep_VoteRecords.DetachedEntities on a.login_code equals b.expert_login_code into temp
// from tt in temp.DefaultIfEmpty()
// select new
// {
// a.Id,
// a.login_code,
// is_vote = tt == null
// };
//return await query.ToListAsync();
}
catch (Exception ex)
{ }
return null;
}
/// <summary>
/// 新增专家
/// </summary>
/// <returns></returns>
[HttpPost]
public async Task AddExpert(AddExpertInput args)
{
if (args == null || args.expertnum <= 0)
throw Oops.Oh("参数异常");
try
{
var list = new List<Experts>();
for (int i = 0; i < args.expertnum; i++)
{
var newid = Ulid.NewUlid().ToString();
var newidsimple = newid.ToUpper().Replace("I", "").Replace("L", "").Replace("0", "").Replace("O", "").Replace("1", "");
list.Add(new Experts
{
Id = newid,
login_code = newidsimple.Substring(newidsimple.Length - 6, 6),
CreatedTime = DateTime.Now
});
}
await rep_Experts.InsertAsync(list);
}
catch (Exception ex)
{ }
}
}
}

View File

@@ -178,7 +178,8 @@ namespace Vote.Services.ApiController
{ {
var data = await GetVoteData(); var data = await GetVoteData();
//var filepath = Tools.ExcelHelper.WriteTemplate(data, 4, "C"); //var filepath = Tools.ExcelHelper.WriteTemplate(data, 4, "C");
var filepath = Tools.ExcelHelper.WriteTemplate(data, 5, "C"); string template_name = "2024年度宁波市结构优质认定项目投票结果.xlsx";
var filepath = Tools.ExcelHelper.WriteTemplate(template_name, data, 5, "C");
return new FileStreamResult(new FileStream(filepath, FileMode.Open), "application/octet-stream") { FileDownloadName = filepath }; return new FileStreamResult(new FileStream(filepath, FileMode.Open), "application/octet-stream") { FileDownloadName = filepath };
} }
/// <summary> /// <summary>

View File

@@ -15,6 +15,7 @@ namespace Vote.Services.Dto
/// 项目类型 /// 项目类型
/// </summary> /// </summary>
public int? type { get; set; } public int? type { get; set; }
public int? is_no_inspection { get; set; }
} }
public class ProjectsOutput public class ProjectsOutput
{ {
@@ -48,6 +49,7 @@ namespace Vote.Services.Dto
/// ///
/// </summary> /// </summary>
public bool vote { get; set; } = false; public bool vote { get; set; } = false;
public int is_no_inspection { get; set; }
} }
public class CheckSubmitCodeInput public class CheckSubmitCodeInput
{ {
@@ -116,5 +118,6 @@ namespace Vote.Services.Dto
[Required] [Required]
public int expertnum { get; set; } public int expertnum { get; set; }
} }
public int is_no_inspection { get; set; }
} }
} }

View File

@@ -174,9 +174,9 @@ namespace Vote.Services.Entities
[Description("轨道工程")] [Description("轨道工程")]
GuiDaoGongCheng = 2, GuiDaoGongCheng = 2,
/// <summary> /// <summary>
/// 电力工程 /// 能源工程
/// </summary> /// </summary>
[Description("电力工程")] [Description("能源工程")]
DianLiGongCheng = 3, DianLiGongCheng = 3,
/// <summary> /// <summary>
/// 交通工程 /// 交通工程

View File

@@ -0,0 +1,51 @@
using Ewide.Core;
using Ewide.Core.Util;
using Furion;
using Furion.DatabaseAccessor;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Vote.Services.Entities
{
/// <summary>
/// 项目表
/// </summary>
public class Projects_2025 : DEntityBase//, IEntitySeedData<Projects>
{
/// <summary>
/// 项目序号
/// </summary>
[Comment("项目序号")]
public int serial_number { get; set; }
/// <summary>
/// 工程名称
/// </summary>
[Comment("工程名称")]
public string name { get; set; }
/// <summary>
/// 项目类型
/// </summary>
[Comment("项目类型")]
public EnumProjectType type { get; set; }
/// <summary>
///
/// </summary>
[NotMapped]
public string type_title
{
get
{
return type.GetEnumDescription();
}
}
public int is_no_inspection { get; set; }
}
}

View File

@@ -114,11 +114,10 @@ namespace Vote.Services.Tools
/// ///
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public static string WriteTemplate(List<ProjectsList2Output> list, int start_row, string start_column) public static string WriteTemplate(string template_name, List<ProjectsList2Output> list, int start_row, string start_column)
{ {
try try
{ {
string template_name = "2024年度宁波市结构优质认定项目投票结果.xlsx";
string excelFilePath = $"{App.WebHostEnvironment.WebRootPath}\\ExcelTemplate\\{template_name}"; string excelFilePath = $"{App.WebHostEnvironment.WebRootPath}\\ExcelTemplate\\{template_name}";
string outputPath = string.Empty; string outputPath = string.Empty;
if (!string.IsNullOrEmpty(excelFilePath)) if (!string.IsNullOrEmpty(excelFilePath))

View File

@@ -203,6 +203,53 @@
</summary> </summary>
<returns></returns> <returns></returns>
</member> </member>
<member name="T:Vote.Services.ApiController.Projects2025Service">
<summary>
项目
</summary>
</member>
<member name="M:Vote.Services.ApiController.Projects2025Service.List(Vote.Services.Dto.ProjectsInput)">
<summary>
列表
</summary>
<returns></returns>
</member>
<member name="M:Vote.Services.ApiController.Projects2025Service.CheckSubmitCode(Vote.Services.Dto.CheckSubmitCodeInput)">
<summary>
检验提交码
</summary>
<returns></returns>
</member>
<member name="M:Vote.Services.ApiController.Projects2025Service.SubmitSubmitVote(Vote.Services.Dto.SubmitInput)">
<summary>
提交
</summary>
<returns></returns>
</member>
<member name="M:Vote.Services.ApiController.Projects2025Service.List2">
<summary>
列表
</summary>
<returns></returns>
</member>
<member name="M:Vote.Services.ApiController.Projects2025Service.Download(System.Int32)">
<summary>
</summary>
<returns></returns>
</member>
<member name="M:Vote.Services.ApiController.Projects2025Service.ExpertVote">
<summary>
</summary>
<returns></returns>
</member>
<member name="M:Vote.Services.ApiController.Projects2025Service.AddExpert(Vote.Services.Dto.ProjectsList2Output.AddExpertInput)">
<summary>
新增专家
</summary>
<returns></returns>
</member>
<member name="T:Vote.Services.ApiController.ProjectsService"> <member name="T:Vote.Services.ApiController.ProjectsService">
<summary> <summary>
项目 项目
@@ -933,7 +980,7 @@
</member> </member>
<member name="F:Vote.Services.Entities.EnumProjectType.DianLiGongCheng"> <member name="F:Vote.Services.Entities.EnumProjectType.DianLiGongCheng">
<summary> <summary>
电力工程 能源工程
</summary> </summary>
</member> </member>
<member name="F:Vote.Services.Entities.EnumProjectType.JiaoTongGongCheng"> <member name="F:Vote.Services.Entities.EnumProjectType.JiaoTongGongCheng">
@@ -996,6 +1043,31 @@
</summary> </summary>
</member> </member>
<member name="T:Vote.Services.Entities.Projects_2025">
<summary>
项目表
</summary>
</member>
<member name="P:Vote.Services.Entities.Projects_2025.serial_number">
<summary>
项目序号
</summary>
</member>
<member name="P:Vote.Services.Entities.Projects_2025.name">
<summary>
工程名称
</summary>
</member>
<member name="P:Vote.Services.Entities.Projects_2025.type">
<summary>
项目类型
</summary>
</member>
<member name="P:Vote.Services.Entities.Projects_2025.type_title">
<summary>
</summary>
</member>
<member name="T:Vote.Services.Entities.VoteRecords"> <member name="T:Vote.Services.Entities.VoteRecords">
<summary> <summary>
投票记录 投票记录
@@ -1112,7 +1184,7 @@
<param name="index"></param> <param name="index"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Vote.Services.Tools.ExcelHelper.WriteTemplate(System.Collections.Generic.List{Vote.Services.Dto.ProjectsList2Output},System.Int32,System.String)"> <member name="M:Vote.Services.Tools.ExcelHelper.WriteTemplate(System.String,System.Collections.Generic.List{Vote.Services.Dto.ProjectsList2Output},System.Int32,System.String)">
<summary> <summary>
</summary> </summary>