Ver a proveniência

学生报道添加照片对比功能

大厂分支
zhichao lei há 4 anos
ascendente
cometimento
b65e7ef0db
8 ficheiros alterados com 364 adições e 15 eliminações
  1. +1
    -0
      .gitignore
  2. +51
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/StuInfoFreshController.cs
  3. +223
    -5
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuInfoFresh/RegisterIndex.cshtml
  4. +22
    -5
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuInfoFresh/RegisterIndex.js
  5. +1
    -1
      Learun.Framework.Ultimate V7/Learun.Application.Web/XmlConfig/system.config
  6. +24
    -4
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuInfoFresh/StuInfoFreshBLL.cs
  7. +6
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuInfoFresh/StuInfoFreshIBLL.cs
  8. +36
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuInfoFresh/StuInfoFreshService.cs

+ 1
- 0
.gitignore Ver ficheiro

@@ -75,3 +75,4 @@ typings/

unpackage
Learun.Framework.Ultimate V7/LearunApp-2.2.0/config.js
/Learun.Framework.Ultimate V7/Learun.Application.Web/Resource/System/20200831

+ 51
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/StuInfoFreshController.cs Ver ficheiro

@@ -1069,5 +1069,56 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers

#endregion

#region 上传图片
[HttpPost]
[AjaxOnly]
public ActionResult IsPhoto(string stuId, string base64url)
{
var loginuser = LoginUserInfo.Get();
//头像处理
var folderId = Guid.NewGuid().ToString();

string filePath = Config.GetValue("AnnexesFile");
string uploadDate = DateTime.Now.ToString("yyyyMMdd");
string FileEextension = ".png";
string fileGuid = Guid.NewGuid().ToString();

string virtualPath = string.Format("{0}/{1}/{2}/{3}{4}", filePath, loginuser.account, uploadDate, fileGuid, FileEextension);

//创建文件夹
string path = Path.GetDirectoryName(virtualPath);
Directory.CreateDirectory(path);
AnnexesFileEntity fileAnnexesEntity = new AnnexesFileEntity();
if (!System.IO.File.Exists(virtualPath))
{
byte[] bytes = Convert.FromBase64String(base64url.Replace("data:image/png;base64,", ""));
FileInfo file = new FileInfo(virtualPath);
FileStream fs = file.Create();
fs.Write(bytes, 0, bytes.Length);
fs.Close();

//文件信息写入数据库
fileAnnexesEntity.F_Id = fileGuid;
fileAnnexesEntity.F_FileName = "userphoto.png";
fileAnnexesEntity.F_FilePath = virtualPath;
fileAnnexesEntity.F_FileSize = bytes.Length.ToString();
fileAnnexesEntity.F_FileExtensions = FileEextension;
fileAnnexesEntity.F_FileType = FileEextension.Replace(".", "");
fileAnnexesEntity.F_CreateUserId = loginuser.userId;
fileAnnexesEntity.F_CreateUserName = loginuser.realName;
annexesFileIBLL.SaveEntity(folderId, fileAnnexesEntity);
}
var result = stuInfoFreshIBLL.IsPhoto(stuId, true, fileGuid);
if (result.Item1)
{
return Success(result.Item2);
}
else
{
return Fail(result.Item2);
}
}
#endregion

}
}

+ 223
- 5
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuInfoFresh/RegisterIndex.cshtml Ver ficheiro

@@ -6,7 +6,6 @@
.lr-select {
width: 150px;
}

</style>
<div class="lr-layout ">
<div class="lr-layout-center">
@@ -17,7 +16,7 @@
<input id="txt_Keyword" type="text" class="form-control" placeholder="考生号/准考证号/姓名/身份证号" />
</div>
<div class="lr-layout-tool-item">
<div id="RegisterStatus" type="lrselect" class="lr-select" ></div>
<div id="RegisterStatus" type="lrselect" class="lr-select"></div>
</div>
<div class="lr-layout-tool-item">
<a id="btn_Search" class="btn btn-primary btn-sm"><i class="fa fa-search"></i>&nbsp;查询</a>
@@ -29,8 +28,8 @@
</div>
<div class=" btn-group btn-group-sm" learun-authorize="yes">
<a id="lr_printlc" class="btn btn-default"><i class="fa fa-print"></i>&nbsp;打印报道流程单</a>
<a id="lr_view" class="btn btn-default"><i class="fa fa-pencil-square-o"></i>&nbsp;查看</a>
<a id="lr_register" class="btn btn-default"><i class="fa fa-plus"></i>&nbsp;确认报到</a>
<a id="lr_view" class="btn btn-default"><i class="fa fa-pencil-square-o"></i>&nbsp;查看</a>
<a id="lr_register" class="btn btn-default"><i class="fa fa-plus"></i>&nbsp;确认报到</a>
<a id="lr_cancelRegister" class="btn btn-default"><i class="fa fa-trash-o"></i>&nbsp;取消报到</a>
</div>
<div class=" btn-group btn-group-sm" learun-authorize="yes">
@@ -39,7 +38,226 @@
</div>
</div>
<div class="lr-layout-body" id="gridtable"></div>
<!--图片裁剪框 start-->
<div style="display: none" class="tailoring-container">
<div class="black-cloth" onclick="closeTailor(this)"></div>
<style>
.userPhotoBox {
width: 127px;
height: 178px;
overflow: hidden;
margin: 10px auto 10px!important
}
.userPhotoBox img{
width: 100%
}
</style>
<div class="tailoring-content">
<div class="tailoring-content-one">
<label title="上传图片" for="chooseImg" class="l2-btn choose-btn">
<input type="file" accept="image/jpg,image/jpeg,image/png" name="file" id="chooseImg" class="hidden" onchange="selectImg(this)">
本地上传
</label>
<label title="拍照" class="l2-btn choose-btn" id='capture' style="margin-left: 2%;">拍照</label>
<label title="重拍" class="l2-btn choose-btn" id='takeAgain' style="margin-left: 2%;">重拍</label>
<div class="close-tailoring" onclick="closeTailor(this)">×</div>
</div>
<div class="tailoring-content-two">
<div class="tailoring-box-parcel">
<video id="video" width="100%" height="100%" style="float: left;"></video>
<canvas id="canvas" width="482px" height="448px" style="float: left;" hidden="hidden"></canvas>
<div id="showImg" hidden="hidden" style="width: 100%; height: 100%;">
<img id="tailoringImg">
</div>
</div>
<div class="preview-box-parcel">
<p>原照片:</p>
<div class="userPhotoBox">
<img id="userPhoto">
</div>
<p>拍照预览:</p>
<div class="square previewImg"></div>
</div>
</div>
<div class="tailoring-content-three">
<button class="l2-btn cropper-reset-btn">复位</button>
<button class="l2-btn cropper-rotate-btn">旋转</button>
<button class="l2-btn cropper-scaleX-btn">换向</button>
<button class="l2-btn sureCut" id="sureReport">确定报道</button>
<button class="l2-btn sureCut" id="sureCut">确定照片</button>
</div>
</div>
</div>
<!--图片裁剪框 end-->
</div>
</div>
</div>
@Html.AppendJsFile("/Areas/EducationalAdministration/Views/StuInfoFresh/RegisterIndex.js")
@Html.AppendJsFile("/Areas/EducationalAdministration/Views/StuInfoFresh/RegisterIndex.js", "/Content/camera/cropper.min.js",
"/Areas/EducationalAdministration/Views/StuEnroll/LodopFuncs.js")
@Html.AppendCssFile("/Content/camera/cropper.min.css", "/Content/camera/ImgCropping.css")
<script>
//弹出框水平垂直居中
(window.onresize = function () {
var win_height = $(window).height();
var win_width = $(window).width();
if (win_width <= 768) {
$(".tailoring-content").css({
"top": (win_height - $(".tailoring-content").outerHeight()) / 2,
"left": 0
});
} else {
$(".tailoring-content").css({
"top": (win_height - $(".tailoring-content").outerHeight()) / 2,
"left": (win_width - $(".tailoring-content").outerWidth()) / 2
});
}
})();
//图像上传
function selectImg(file) {
if (!file.files || !file.files[0]) {
return;
}
var reader = new FileReader();
reader.onload = function (evt) {
var replaceSrc = evt.target.result;
//更换cropper的图片
$('#tailoringImg').cropper('replace', replaceSrc, false);//默认false,适应高度,不失真

}
reader.readAsDataURL(file.files[0]);
mediaStreamTrack && mediaStreamTrack.stop();
$("#video").hide();
$("#showImg").show();

}
//cropper图片裁剪
$('#tailoringImg').cropper({
aspectRatio: 5 / 7,//默认比例
preview: '.previewImg',//预览视图
guides: false, //裁剪框的虚线(九宫格)
autoCropArea: 0.5, //0-1之间的数值,定义自动剪裁区域的大小,默认0.8
movable: false, //是否允许移动图片
dragCrop: true, //是否允许移除当前的剪裁框,并通过拖动来新建一个剪裁框区域
movable: true, //是否允许移动剪裁框
resizable: true, //是否允许改变裁剪框的大小
zoomable: false, //是否允许缩放图片大小
mouseWheelZoom: false, //是否允许通过鼠标滚轮来缩放图片
touchDragZoom: true, //是否允许通过触摸移动来缩放图片
rotatable: true, //是否允许旋转图片
crop: function (e) {
// 输出结果数据裁剪图像。
}
});
//旋转
$(".cropper-rotate-btn").on("click", function () {
$('#tailoringImg').cropper("rotate", 45);
});
//复位
$(".cropper-reset-btn").on("click", function () {
$('#tailoringImg').cropper("reset");
});
//换向
var flagX = true;
$(".cropper-scaleX-btn").on("click", function () {
if (flagX) {
$('#tailoringImg').cropper("scaleX", -1);
flagX = false;
} else {
$('#tailoringImg').cropper("scaleX", 1);
flagX = true;
}
flagX != flagX;
});
//裁剪后的处理
$("#sureCut").on("click", function () {
var cas = $('#tailoringImg').cropper('getCroppedCanvas');//获取被裁剪后的canvas
var base64url = cas.toDataURL('image/png'); //转换为base64地址形式
base64url = base64url.replace("\r", "");
top.learun.postForm(top.$.rootUrl + '/EducationalAdministration/StuInfoFresh/IsPhoto', { stuId: StuId, base64url: base64url },
function (res) {
//关闭裁剪框
StuId = "";
//closeTailor();
//refreshGirdData();
});
});
//关闭裁剪框
function closeTailor() {
StuId = "";
$(".tailoring-container").toggle();
mediaStreamTrack && mediaStreamTrack.stop();
}

let video = document.getElementById('video');
let canvas = document.getElementById('canvas');
let context = canvas.getContext('2d');
var mediaStreamTrack;
document.getElementById('capture').addEventListener('click',
function () {
context.drawImage(video, 0, 0, 518, 420);
mediaStreamTrack && mediaStreamTrack.stop();
$('#tailoringImg').cropper('replace', canvas.toDataURL("image/png"), false); //默认false,适应高度,不失真
$("#video").hide(); //隐藏拍照框
$("#showImg").show(); //将拍照结果显示
});

//请求拍照
$("#takeAgain").bind("click", function () {
takePhoto();
});

//开始拍照
function takeImg() {
$(".tailoring-container").toggle();
takePhoto();
}

//请求摄像头
function takePhoto() {
// 老的浏览器可能根本没有实现 mediaDevices,所以我们可以先设置一个空的对象
if (navigator.mediaDevices === undefined) {
navigator.mediaDevices = {};
}
if (navigator.mediaDevices.getUserMedia === undefined) {
navigator.mediaDevices.getUserMedia = function (constraints) {
// 首先,如果有getUserMedia的话,就获得它
var getUserMedia = navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;

// 一些浏览器根本没实现它 - 那么就返回一个error到promise的reject来保持一个统一的接口
if (!getUserMedia) {
return Promise.reject(new Error('不支持此浏览器,请更换Chrome或360浏览器'));
}
// 否则,为老的navigator.getUserMedia方法包裹一个Promise
return new Promise(function (resolve, reject) {
getUserMedia.call(navigator, constraints, resolve, reject);
});
}
}
const constraints = {
video: true,
audio: false
};
let videoPlaying = false;
let promise = navigator.mediaDevices.getUserMedia(constraints);
promise.then(stream => {
// 旧的浏览器可能没有srcObject
if ("srcObject" in video) {
video.srcObject = stream;
mediaStreamTrack = stream.getTracks()[0];
} else {
// 防止再新的浏览器里使用它,应为它已经不再支持了
video.src = window.URL.createObjectURL(stream);
}
video.onloadedmetadata = function (e) {
video.play();
videoPlaying = true;
};
}).catch(err => {
console.error(err.name + ": " + err.message);
});
$("#showImg").hide();//隐藏拍照结果显示框
//$('#showImg').html('<img id="tailoringImg" hidden="hidden">')
$("#video").show();//开启拍照框
}
</script>

+ 22
- 5
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuInfoFresh/RegisterIndex.js Ver ficheiro

@@ -6,13 +6,14 @@
*/
var selectedRow;
var refreshGirdData;
var StuId;
var bootstrap = function ($, learun) {
"use strict";
var page = {
init: function () {
page.bind();
page.initGird();
},
bind: function () {
// 查询
@@ -44,22 +45,38 @@ var bootstrap = function ($, learun) {
});
// 确认报到
$('#lr_register').on('click', function () {
var keyValue = $('#gridtable').jfGridValue('ID');
StuId = $('#gridtable').jfGridValue('ID');
selectedRow = $('#gridtable').jfGridGet('rowdata');
if (learun.checkrow(keyValue)) {
if (learun.checkrow(StuId)) {
if (selectedRow.RegisterStatus == "1") {
learun.alert.warning("当前新生已报到!");
return;
}

$.lrSetForm(top.$.rootUrl + '/EducationalAdministration/StuInfoFresh/GetFormData?keyValue=' + StuId, function (data) {
console.log(data);
$('#userPhoto').attr('src', data.Url);
takeImg();
});



}
});
$("#sureReport").on('click', function () {
StuId = $('#gridtable').jfGridValue('ID');
if (learun.checkrow(StuId)) {
learun.layerConfirm('是否确认报到!', function (res) {
if (res) {
learun.postForm(top.$.rootUrl + '/EducationalAdministration/StuInfoFresh/IsRegister', { keyValue: keyValue, status: 1 }, function () {
learun.postForm(top.$.rootUrl + '/EducationalAdministration/StuInfoFresh/IsRegister', { keyValue: StuId, status: 1 }, function () {
refreshGirdData();
closeTailor();
refreshGirdData();
});
}
});
}
});
})
//打印报道流程单
$('#lr_printlc').on('click', function () {
var keyValue = $('#gridtable').jfGridValue('ID');


+ 1
- 1
Learun.Framework.Ultimate V7/Learun.Application.Web/XmlConfig/system.config Ver ficheiro

@@ -63,7 +63,7 @@
<add key="IMUrl" value="http://192.168.2.126:8012/signalr" />
<add key="userKey" value="14B417B0-463D-4F2B-8075-0A20EEDB773A" />
<!-- ==================注意附件上传地址 修改到部署目录下的Resource要不然飞星会报错================== -->
<add key="AnnexesFile" value="D:\Project\数字化校园\Learun.Framework.Ultimate V7\Learun.Application.Web\Resource" />
<add key="AnnexesFile" value="D:\gitLocalRepositories\DigitalScholl\Learun.Framework.Ultimate V7\Learun.Application.Web\Resource" />
<!-- ================== 8:流程服务地址 ================== -->
<add key="workflowapi" value="http://localhost:8013" />
<!--Redis 缓存前缀 -->


+ 24
- 4
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuInfoFresh/StuInfoFreshBLL.cs Ver ficheiro

@@ -689,11 +689,11 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration
}
}
}
public void GetUniform(string keyValue,bool Status)
public void GetUniform(string keyValue, bool Status)
{
try
{
stuInfoFreshService.GetUniform(keyValue,Status);
stuInfoFreshService.GetUniform(keyValue, Status);
}
catch (Exception ex)
{
@@ -707,11 +707,11 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration
}
}
}
public void PayUniform(string keyValue,bool Status)
public void PayUniform(string keyValue, bool Status)
{
try
{
stuInfoFreshService.PayUniform(keyValue,Status);
stuInfoFreshService.PayUniform(keyValue, Status);
}
catch (Exception ex)
{
@@ -771,5 +771,25 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration
}

#endregion
#region 上传图片
public (bool, string) IsPhoto(string stuId, bool status, string fileGuid)
{
try
{
return stuInfoFreshService.IsPhoto(stuId, status, fileGuid);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
#endregion
}
}

+ 6
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuInfoFresh/StuInfoFreshIBLL.cs Ver ficheiro

@@ -200,5 +200,11 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration
/// </summary>
void DeleteBed(string keyValue);
#endregion

#region 上传图片

(bool, string) IsPhoto(string stuId, bool status, string fileGuid);

#endregion
}
}

+ 36
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuInfoFresh/StuInfoFreshService.cs Ver ficheiro

@@ -1606,5 +1606,41 @@ where bb.StuNo not in (select b.StuNo from StuInfoBasic b where b.StuNo=bb.StuNo

#endregion

#region 上传图片

internal (bool, string) IsPhoto(string stuId, bool status, string fileGuid)
{
try
{
string result = "";
bool resultBool = false;
var model = this.BaseRepository("CollegeMIS").FindEntity<StuInfoFreshEntity>(a => a.ID == stuId);
if (model != null)
{
model.Photo = fileGuid;
resultBool = true;
result = "操作成功!";
this.BaseRepository("CollegeMIS").Update(model);
}
else
{
result = "错误";
}
return (resultBool, result);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}

#endregion
}
}

Carregando…
Cancelar
Guardar