Commit e4308871 by yucheng.jiang
parents bf4c28d6 fec99e86
...@@ -24,15 +24,16 @@ ...@@ -24,15 +24,16 @@
<span class="red">*</span> <span class="red">*</span>
</p> </p>
<div class="row"> <div class="row">
<p <div
:key="index" :key="index"
class="options" class="options2"
v-for="(item, index) in productionLine" v-for="(item, index) in stationList"
@click="change(index)" @click="change(index)"
:class="{ active: a == index }" :class="{ active: a == index }"
> >
{{ item.title }} <p>{{ item.title }}</p>
</p> <p>{{ item.status == 1 ? "待上料" : "运行中" }}</p>
</div>
</div> </div>
</div> </div>
<div class="choose"> <div class="choose">
...@@ -46,11 +47,8 @@ ...@@ -46,11 +47,8 @@
<label style="font-size: 16px" <label style="font-size: 16px"
>上料信息:</label >上料信息:</label
> >
<Input <Input type="text" class="searchInput"
type="text" style="width: 300px"/>
class="searchInput"
style="width: 300px"
></Input>
</div> </div>
<div class="row"> <div class="row">
<p class="flex"> <p class="flex">
...@@ -277,20 +275,25 @@ export default { ...@@ -277,20 +275,25 @@ export default {
method: "get", method: "get",
}) })
.then((res) => { .then((res) => {
if (res.data.ret == 1) {
this.productionLine = res.data.data; this.productionLine = res.data.data;
// this.change(0); // this.change(0);
if (this.productionLine.length == 0) { if (this.productionLine.length == 0) {
this.$Message.error(this.$t(950057)); this.$Message.error(this.$t(950057));
} }
}
}); });
}, },
getStations(id) { getStations(id) {
let data = {
line: id,
type: 0,
};
this.request( this.request(
"/qms/RepairPostionSetting/GetSettingByChanel?Id=" + id, "/acc/AutomationOperate/GetloadStation",
"", data,
"get" "get"
).then((res) => { ).then((res) => {
// console.log(res.data.data);
if (res.data.ret == 1) { if (res.data.ret == 1) {
this.stationList = res.data.data; this.stationList = res.data.data;
} }
...@@ -374,6 +377,18 @@ export default { ...@@ -374,6 +377,18 @@ export default {
margin-right: 50px; margin-right: 50px;
cursor: pointer; cursor: pointer;
} }
.options2 {
font-size: 12px;
padding: 0 12px;
height: 50px;
line-height: 25px;
text-align: center;
border-radius: 5px;
background-color: #f2f2f2;
margin: 10px 0;
margin-right: 50px;
cursor: pointer;
}
.active { .active {
background-color: #2d8cf0; background-color: #2d8cf0;
color: #fff; color: #fff;
......
...@@ -4,15 +4,23 @@ ...@@ -4,15 +4,23 @@
<h2>基本信息</h2> <h2>基本信息</h2>
<div class="newSearchDiv"> <div class="newSearchDiv">
<div class="filter"> <div class="filter">
<label>{{ $t("1950574") }}</label> <label>{{ $t("1132") }}</label>
<Cascader trigger="click" class="searchSelect"></Cascader> <Cascader
trigger="click"
class="searchSelect"
:data="datalevel"
:value="leveldata"
></Cascader>
</div> </div>
<div class="searchBtn"> <div class="searchBtn">
<Button type="primary" class="twoWord" icon="ios-search">{{ <Button
$t("1001") type="primary"
}}</Button> class="twoWord"
<Button type="primary" class="twoWord" icon="ios-search" icon="ios-search"
@click="search()"
>{{ $t("1001") }}</Button
>
<Button type="primary" class="twoWord" icon="ios-search" @click="exportExcel()"
>导出</Button >导出</Button
> >
</div> </div>
...@@ -26,10 +34,11 @@ ...@@ -26,10 +34,11 @@
<p><span>4</span>不可用</p> <p><span>4</span>不可用</p>
</div> </div>
<div class="stateWrap"> <div class="stateWrap">
<div class="stateItem"> <template v-for="(item,index) in stateList">
<div class="stateItem" :key="index">
<p class="flex"> <p class="flex">
<span class="infoLabel">工位:</span> <span class="infoLabel">工位:</span>
<span class="info"></span> <span class="info">{{item}}</span>
</p> </p>
<p class="flex"> <p class="flex">
<span class="infoLabel">产品:</span> <span class="infoLabel">产品:</span>
...@@ -48,6 +57,7 @@ ...@@ -48,6 +57,7 @@
<span class="info"></span> <span class="info"></span>
</p> </p>
</div> </div>
</template>
</div> </div>
<Table <Table
class="tableClass" class="tableClass"
...@@ -55,12 +65,15 @@ ...@@ -55,12 +65,15 @@
:columns="columns1" :columns="columns1"
:max-height="200" :max-height="200"
></Table> ></Table>
<div v-show="show1">
<Table <Table
class="tableClass" class="tableClass"
:data="data2" :data="data2"
:columns="columns2" :columns="columns2"
:max-height="200" :max-height="200"
></Table> ></Table>
</div>
<div v-show="show2">
<Table <Table
class="tableClass" class="tableClass"
:data="data3" :data="data3"
...@@ -69,15 +82,19 @@ ...@@ -69,15 +82,19 @@
></Table> ></Table>
</div> </div>
</div> </div>
</div>
</template> </template>
<script> <script>
import axios from "@/libs/api.request";
export default { export default {
data() { data() {
return { return {
productionLine: [], productionLine: [],
a: 0, leveldata: [], // 产线层级插件所需数据
modal: false, datalevel: [], // 产线层级选中数据
stateList:[0],
columns1: [ columns1: [
{ {
title: this.$t("1008"), title: this.$t("1008"),
...@@ -101,6 +118,19 @@ export default { ...@@ -101,6 +118,19 @@ export default {
{ {
title: "工装编号", title: "工装编号",
key: "install_sn", key: "install_sn",
render: (h, params) => {
return h(
"a",
{
on: {
click: () => {
this.show1 = true;
},
},
},
"look"
);
},
}, },
{ {
title: "产品编号", title: "产品编号",
...@@ -109,6 +139,19 @@ export default { ...@@ -109,6 +139,19 @@ export default {
{ {
title: "工件编号", title: "工件编号",
key: "storage_sn", key: "storage_sn",
render: (h, params) => {
return h(
"a",
{
on: {
click: () => {
this.show2 = true;
},
},
},
"look"
);
},
}, },
{ {
title: "状态", title: "状态",
...@@ -157,11 +200,43 @@ export default { ...@@ -157,11 +200,43 @@ export default {
key: "install_sn", key: "install_sn",
}, },
{ {
title: "最后更新时间", title: "子工装编号",
key: "install_sn",
},
{
title: "子工装名称",
key: "install_sn",
},
{
title: "子工装规格",
key: "install_sn",
},
{
title: "子工装编号",
key: "install_sn",
},
{
title: "状态",
key: "install_sn",
},
{
title: "备注",
key: "install_sn",
},
{
title: "附件",
key: "install_sn",
},
{
title: "维护人",
key: "install_sn",
},
{
title: "维护时间",
key: "workpiece_sn", key: "workpiece_sn",
}, },
], ],
data1: [], data2: [],
columns3: [ columns3: [
{ {
title: this.$t("1008"), title: this.$t("1008"),
...@@ -175,38 +250,94 @@ export default { ...@@ -175,38 +250,94 @@ export default {
width: 70, width: 70,
}, },
{ {
title: "产线层级", title: "产品编号",
key: "warehouse", key: "warehouse",
}, },
{ {
title: "设备", title: "产品名称",
key: "storage_sn", key: "storage_sn",
}, },
{ {
title: "工装编号", title: "产品编号",
key: "install_sn", key: "install_sn",
}, },
{ {
title: "产品编号", title: "工序顺序",
key: "workpiece_sn", key: "workpiece_sn",
}, },
{ {
title: "工件编号", title: "工序信息",
key: "storage_sn", key: "storage_sn",
}, },
{ {
title: "状态", title: "产线层级",
key: "install_sn", key: "install_sn",
}, },
{ {
title: "最后更新时间", title: "设备信息",
key: "workpiece_sn",
},
{
title: "工装信息",
key: "workpiece_sn",
},
{
title: "结果",
key: "workpiece_sn",
},
{
title: "维护人",
key: "workpiece_sn",
},
{
title: "维护时间",
key: "workpiece_sn", key: "workpiece_sn",
}, },
], ],
data1: [], data3: [],
show2: false,
show1: false,
}; };
}, },
created() {}, created() {
this.initlevel();
},
methods: {
search() {},
initlevel() {
// 初始化产线层级
this.axios
.request({
url: "config/ProjectLevelSection/GetSectionTree",
method: "get",
})
.then((res) => {
const arr = [];
if (res.data.data.length > 0) {
this.datalevel = res.data.data;
arr.push(res.data.data[0].value);
this.leveldata = arr;
}
});
},
exportExcel(){
let data = {};
this.axios
.request({
url: "",
data,
method: "",
})
.then((res) => {
if (res.data.ret === 1) {
window.location.href =
axios.publicPath + "" + res.data.data;
} else {
this.$Message.error(this.$t(res.data.msg));
}
});
}
},
}; };
</script> </script>
......
...@@ -44,11 +44,11 @@ ...@@ -44,11 +44,11 @@
</div> </div>
<div class="filter"> <div class="filter">
<label>任务编号:</label> <label>任务编号:</label>
<Input type="text" class="searchInput"></Input> <Input type="text" class="searchInput" />
</div> </div>
<div class="filter"> <div class="filter">
<label>工件编号:</label> <label>工件编号:</label>
<Input type="text" class="searchInput"></Input> <Input type="text" class="searchInput"/>
</div> </div>
<div class="filter"> <div class="filter">
<label>状态:</label> <label>状态:</label>
...@@ -138,6 +138,8 @@ ...@@ -138,6 +138,8 @@
</template> </template>
<script> <script>
import axios from "@/libs/api.request";
export default { export default {
data() { data() {
return { return {
...@@ -259,6 +261,23 @@ export default { ...@@ -259,6 +261,23 @@ export default {
} }
}); });
}, },
exportExcel(){
let data = {};
this.axios
.request({
url: "",
data,
method: "",
})
.then((res) => {
if (res.data.ret === 1) {
window.location.href =
axios.publicPath + "" + res.data.data;
} else {
this.$Message.error(this.$t(res.data.msg));
}
});
}
}, },
}; };
</script> </script>
......
...@@ -406,7 +406,7 @@ export default{ ...@@ -406,7 +406,7 @@ export default{
this.loading1 = true this.loading1 = true
axios axios
.request({ .request({
url: '/qms/ManualCollection/GetPageList', url: '/qms/ManualCollection/GetManualPageList',
params, params,
method: 'get' method: 'get'
}) })
...@@ -479,7 +479,7 @@ export default{ ...@@ -479,7 +479,7 @@ export default{
} }
this.loading2 = true this.loading2 = true
axios.request({ axios.request({
url: '/qms/ManualCollection/GetPageList', url: '/qms/ManualCollection/GetManualPageList',
params, params,
method: 'get' method: 'get'
}).then(res => { }).then(res => {
......
...@@ -722,7 +722,6 @@ export default { ...@@ -722,7 +722,6 @@ export default {
alert(err.msg); alert(err.msg);
}); });
}, },
request(url, data, type) { request(url, data, type) {
if (type == "get") { if (type == "get") {
return this.axios return this.axios
......
...@@ -240,7 +240,7 @@ namespace Siger.ApiACC.Controllers ...@@ -240,7 +240,7 @@ namespace Siger.ApiACC.Controllers
if (lineMode==null) if (lineMode==null)
{ {
Logger.WriteLineInfo($"AutoProcess 产线模式未找到"); Logger.WriteLineInfo($"AutoProcess 产线模式未找到");
throw new BadRequestException(RequestEnum.LevelSectionNotFound); throw new BadRequestException(AccEnum.LineModeNotfound);
} }
if (lineMode.mode==0) if (lineMode.mode==0)
{ {
...@@ -283,7 +283,7 @@ namespace Siger.ApiACC.Controllers ...@@ -283,7 +283,7 @@ namespace Siger.ApiACC.Controllers
if (cleanMachine.status == (int)Automation.MachineStatus.Complated) if (cleanMachine.status == (int)Automation.MachineStatus.Complated)
{ {
Logger.WriteLineInfo($"AutoProcess 有清洗机完成,创建清洗剂Task"); Logger.WriteLineInfo($"AutoProcess 有清洗机完成,创建清洗剂Task");
CreateTask(cleanMachine, TaskActionType.Unload, TaskAction.Step_QXJ_LK); CreateTask(cleanMachine,TaskActionType.Unload, TaskAction.Step_QXJ_LK);
return; //完成当前任务 退出 return; //完成当前任务 退出
} }
} }
...@@ -294,7 +294,7 @@ namespace Siger.ApiACC.Controllers ...@@ -294,7 +294,7 @@ namespace Siger.ApiACC.Controllers
if (freeMachine != null) if (freeMachine != null)
{ {
Logger.WriteLineInfo($"AutoProcess 普通空闲,创建普通设备上料Task"); Logger.WriteLineInfo($"AutoProcess 普通空闲,创建普通设备上料Task");
CreateTask(freeMachine, TaskActionType.Load ,TaskAction.Step_LK_JGZX); CreateTask(freeMachine,TaskActionType.Load ,TaskAction.Step_LK_JGZX);
return; //完成当前任务 退出 return; //完成当前任务 退出
} }
//优先级3:其他设备下料 (加工中心 ->立库) //优先级3:其他设备下料 (加工中心 ->立库)
...@@ -304,14 +304,14 @@ namespace Siger.ApiACC.Controllers ...@@ -304,14 +304,14 @@ namespace Siger.ApiACC.Controllers
if (fullMachine != null && cleanMachine.status==(int)Automation.MachineStatus.Waiting) if (fullMachine != null && cleanMachine.status==(int)Automation.MachineStatus.Waiting)
{ {
Logger.WriteLineInfo($"AutoProcess 普通空闲,创建普通设备下料Task "); Logger.WriteLineInfo($"AutoProcess 普通空闲,创建普通设备下料Task ");
CreateTask(fullMachine, TaskActionType.Unload, TaskAction.Step_JGZX_QXJ); CreateTask(fullMachine,TaskActionType.Unload, TaskAction.Step_JGZX_QXJ);
return; //完成当前任务 退出 return; //完成当前任务 退出
} }
} }
} }
void CreateTask(siger_automation_machine_status machineStatus, TaskActionType actionType, TaskAction taskAction) void CreateTask(siger_automation_machine_status machineStatus,TaskActionType actionType, TaskAction taskAction)
{ {
_automationTaskList.Insert(new siger_automation_task_list _automationTaskList.Insert(new siger_automation_task_list
...@@ -320,7 +320,7 @@ namespace Siger.ApiACC.Controllers ...@@ -320,7 +320,7 @@ namespace Siger.ApiACC.Controllers
sectionid = machineStatus.section, sectionid = machineStatus.section,
trigger = TaskTrigerType.Auto, trigger = TaskTrigerType.Auto,
action = taskAction, action = taskAction,
actiontype = TaskTrigerType.Auto,//默认自动动作 actiontype = ExcueType.None,
tasktype = actionType, tasktype = actionType,
triggertime = DateTime.Now, triggertime = DateTime.Now,
completetime = DateTime.MinValue, completetime = DateTime.MinValue,
...@@ -328,6 +328,7 @@ namespace Siger.ApiACC.Controllers ...@@ -328,6 +328,7 @@ namespace Siger.ApiACC.Controllers
send = 0, send = 0,
operater = 0, operater = 0,
status = 1, status = 1,
remark="自动任务"
}); });
if (_unitOfWork.Commit() > 0) if (_unitOfWork.Commit() > 0)
......
...@@ -26,14 +26,12 @@ namespace Siger.ApiACC.Controllers ...@@ -26,14 +26,12 @@ namespace Siger.ApiACC.Controllers
private readonly ISigerTrMaterialsRepository _materialsRepository; private readonly ISigerTrMaterialsRepository _materialsRepository;
public AutomationLocationController(IUnitOfWork unitOfWork, IAutomationFixtureToolsCategoryRepository toolsCategoryRepository, public AutomationLocationController(IUnitOfWork unitOfWork, IAutomationFixtureToolsCategoryRepository toolsCategoryRepository,
IAutomationFixtureToolsRepository toolsRepository, IAutomationLocationRepository autoLocationRepository, IAutomationFixtureToolsRepository toolsRepository, IAutomationLocationRepository autoLocationRepository)
ISigerTrMaterialsRepository materialsRepository)
{ {
_unitOfWork = unitOfWork; _unitOfWork = unitOfWork;
_toolsCategoryRepository = toolsCategoryRepository; _toolsCategoryRepository = toolsCategoryRepository;
_toolsRepository = toolsRepository; _toolsRepository = toolsRepository;
_autoLocationRepository = autoLocationRepository; _autoLocationRepository = autoLocationRepository;
_materialsRepository = materialsRepository;
} }
public IActionResult GetPageList(string wavehouseid, string locationid, int page, int pagesize) public IActionResult GetPageList(string wavehouseid, string locationid, int page, int pagesize)
...@@ -45,7 +43,7 @@ namespace Siger.ApiACC.Controllers ...@@ -45,7 +43,7 @@ namespace Siger.ApiACC.Controllers
[HttpPost] [HttpPost]
public IActionResult Add([FromBody]RequestAddAutomationLocation req) public IActionResult Add([FromBody]RequestAddAutomationLocation req)
{ {
if (string.IsNullOrEmpty(req.locationid) || string.IsNullOrEmpty(req.fixturetoolid) || string.IsNullOrEmpty(req.materialid)) if (string.IsNullOrEmpty(req.locationid) || string.IsNullOrEmpty(req.fixturetoolid))
{ {
throw new BadRequestException(RequestEnum.ParameterMiss); throw new BadRequestException(RequestEnum.ParameterMiss);
} }
...@@ -59,39 +57,18 @@ namespace Siger.ApiACC.Controllers ...@@ -59,39 +57,18 @@ namespace Siger.ApiACC.Controllers
{ {
throw new BadRequestException(RequestEnum.LocationNull); throw new BadRequestException(RequestEnum.LocationNull);
} }
var material = _materialsRepository.Get(q => q.id == req.materialid.ToInt() && q.projectId == ProjectId && q.status == (int)RowState.Valid); var exsit = _autoLocationRepository.Get(q => q.projectId == ProjectId && q.status == (int)RowState.Valid &&
var data = _autoLocationRepository.Get(q => q.projectId == ProjectId && q.status == (int)RowState.Valid && q.fixturetools == fixturetool.guid && (q.fixturetools == req.fixturetoolid || q.locationid == req.locationid.ToInt()));
q.locationid == req.locationid.ToInt()); if(exsit != null)
if (data != null)
{ {
throw new BadRequestException(RequestEnum.DataExist); throw new BadRequestException(RequestEnum.DataExist);
} }
var state = 1;
if (fixturetool != null && material == null)
{
state = 1;//有工装 无工件
}
else if(fixturetool != null && material != null)
{
state = 2;//有工装 有工件
}
else if (fixturetool == null && material == null)
{
state = 3;//无工装 无工件
}
else if (fixturetool == null && material != null)
{
state = 4;//无工装 有工件
}
var entity = new siger_automation_location var entity = new siger_automation_location
{ {
guid = Guid.NewGuid().ToString(), guid = Guid.NewGuid().ToString(),
locationid = req.locationid.ToInt(), locationid = req.locationid.ToInt(),
fixturetools = fixturetool.guid, fixturetools = fixturetool.guid,
materialid = req.materialid.ToInt(),
processid = req.processid.ToInt(),
materialstate = state,
attachment = req.fileurl, attachment = req.fileurl,
filename = req.filename, filename = req.filename,
remark = req.remark, remark = req.remark,
...@@ -118,6 +95,10 @@ namespace Siger.ApiACC.Controllers ...@@ -118,6 +95,10 @@ namespace Siger.ApiACC.Controllers
throw new BadRequestException(RequestEnum.ParameterMiss); throw new BadRequestException(RequestEnum.ParameterMiss);
} }
var entity = _autoLocationRepository.Get(q => q.id == req.id && q.projectId == ProjectId && q.status == (int)RowState.Valid); var entity = _autoLocationRepository.Get(q => q.id == req.id && q.projectId == ProjectId && q.status == (int)RowState.Valid);
if(entity == null)
{
throw new BadRequestException(CommonEnum.RecordNotFound);
}
var fixturetool = _toolsRepository.Get(q => q.id == req.fixturetoolid.ToInt() && q.projectId == ProjectId); var fixturetool = _toolsRepository.Get(q => q.id == req.fixturetoolid.ToInt() && q.projectId == ProjectId);
if (fixturetool == null) if (fixturetool == null)
{ {
...@@ -128,36 +109,15 @@ namespace Siger.ApiACC.Controllers ...@@ -128,36 +109,15 @@ namespace Siger.ApiACC.Controllers
{ {
throw new BadRequestException(RequestEnum.LocationNull); throw new BadRequestException(RequestEnum.LocationNull);
} }
var material = _materialsRepository.Get(q => q.id == req.materialid.ToInt() && q.projectId == ProjectId && q.status == (int)RowState.Valid); var exsit = _autoLocationRepository.Get(q => q.projectId == ProjectId && q.status == (int)RowState.Valid &&
var data = _autoLocationRepository.Get(q => q.projectId == ProjectId && q.status == (int)RowState.Valid && q.fixturetools == fixturetool.guid && (q.fixturetools == req.fixturetoolid || q.locationid == req.locationid.ToInt()) && q.id != req.id);
q.locationid == req.locationid.ToInt() && q.id != req.id); if (exsit != null)
if (data != null)
{ {
throw new BadRequestException(RequestEnum.DataExist); throw new BadRequestException(RequestEnum.DataExist);
} }
var state = 1;
if (fixturetool != null && material == null)
{
state = 1;//有工装 无工件
}
else if (fixturetool != null && material != null)
{
state = 2;//有工装 有工件
}
else if (fixturetool == null && material == null)
{
state = 3;//无工装 无工件
}
else if (fixturetool == null && material != null)
{
state = 4;//无工装 有工件
}
entity.locationid = req.locationid.ToInt(); entity.locationid = req.locationid.ToInt();
entity.fixturetools = fixturetool.guid; entity.fixturetools = fixturetool.guid;
entity.materialid = req.materialid.ToInt();
entity.processid = req.processid.ToInt();
entity.materialstate = state;
entity.attachment = req.fileurl; entity.attachment = req.fileurl;
entity.filename = req.filename; entity.filename = req.filename;
entity.remark = req.remark; entity.remark = req.remark;
...@@ -218,5 +178,11 @@ namespace Siger.ApiACC.Controllers ...@@ -218,5 +178,11 @@ namespace Siger.ApiACC.Controllers
return new ObjectResult(CommonEnum.Succefull); return new ObjectResult(CommonEnum.Succefull);
throw new BadRequestException(CommonEnum.Fail); throw new BadRequestException(CommonEnum.Fail);
} }
[HttpGet]
public IActionResult GetLocationList()
{
return new ObjectResult(_autoLocationRepository.GetDataList(ProjectId).ToList());
}
} }
} }
...@@ -9,6 +9,7 @@ using Siger.Middlelayer.AccRepository.Request; ...@@ -9,6 +9,7 @@ using Siger.Middlelayer.AccRepository.Request;
using Siger.Middlelayer.AccRepository.Response; using Siger.Middlelayer.AccRepository.Response;
using Siger.Middlelayer.Common; using Siger.Middlelayer.Common;
using Siger.Middlelayer.Common.Extensions; using Siger.Middlelayer.Common.Extensions;
using Siger.Middlelayer.Common.ModuleEnum;
using Siger.Middlelayer.Log; using Siger.Middlelayer.Log;
using Siger.Middlelayer.Repository; using Siger.Middlelayer.Repository;
using Siger.Middlelayer.Repository.Repositories.Interface; using Siger.Middlelayer.Repository.Repositories.Interface;
...@@ -26,19 +27,16 @@ namespace Siger.ApiACC.Controllers ...@@ -26,19 +27,16 @@ namespace Siger.ApiACC.Controllers
private readonly ISigerDict _sigerDict; private readonly ISigerDict _sigerDict;
private readonly IAutomationMachineStatus _automationMachineStatus; private readonly IAutomationMachineStatus _automationMachineStatus;
private readonly ISigerProjectMachineAttributionRepository _sigerProjectMachineAttribution; private readonly ISigerProjectMachineAttributionRepository _sigerProjectMachineAttribution;
private readonly IAutomationTaskListRepository _automationTaskList;
public AutomationOperateController(IUnitOfWork unitOfWork,ISigerProjectLevelSectionRepository sigerProjectLevelSection , ISigerDict sigerDict,IAutomationMachineStatus automationMachineStatus,ISigerProjectMachineAttributionRepository sigerProjectMachineAttribution) public AutomationOperateController(IUnitOfWork unitOfWork,ISigerProjectLevelSectionRepository sigerProjectLevelSection , ISigerDict sigerDict,IAutomationMachineStatus automationMachineStatus,ISigerProjectMachineAttributionRepository sigerProjectMachineAttribution,IAutomationTaskListRepository automationTaskList)
{ {
_unitOfWork = unitOfWork; _unitOfWork = unitOfWork;
_sigerProjectLevelSection = sigerProjectLevelSection; _sigerProjectLevelSection = sigerProjectLevelSection;
_sigerDict = sigerDict; _sigerDict = sigerDict;
_automationMachineStatus = automationMachineStatus; _automationMachineStatus = automationMachineStatus;
_sigerProjectMachineAttribution = sigerProjectMachineAttribution; _sigerProjectMachineAttribution = sigerProjectMachineAttribution;
} _automationTaskList = automationTaskList;
public IActionResult Get()
{
return new ObjectResult(1);
} }
/// <summary> /// <summary>
...@@ -118,23 +116,82 @@ namespace Siger.ApiACC.Controllers ...@@ -118,23 +116,82 @@ namespace Siger.ApiACC.Controllers
return new ObjectResult(data); return new ObjectResult(data);
} }
/// <summary>
/// 查询状态
/// </summary>
/// <param name="section"></param>
/// <returns></returns>
[HttpGet]
public IActionResult GetLoadingState(int section)
{
var data = new ResponseAutomationInfo
{
sn = "sn0001",
wo = "wo123123"
};
return new ObjectResult(data);
}
/// <summary> /// <summary>
/// 准备上料 /// 准备上料 -生成指令
/// </summary> /// </summary>
/// <param name="loading"></param> /// <param name="loading"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
public IActionResult Loading([FromBody]requestAutomationLoading loading) public IActionResult Loading([FromBody]requestAutomationLoading loading)
{ {
var data = new ResponseAutomationInfo {
sn="sn0001", var machineAttr = _sigerProjectMachineAttribution.Get(f => f.station == loading.section && f.status == (int)RowState.Valid);
wo="wo123123" if (machineAttr==null)
}; {
return new ObjectResult(data); throw new BadRequestException(CommonEnum.RecordNotFound);
}
var machineStatus = _automationMachineStatus.Get(f => f.machineid==machineAttr.machine);
if (machineStatus==null)
{
throw new BadRequestException(CommonEnum.RecordNotFound);
}
if (machineStatus.enable==0)
{
throw new BadRequestException(AccEnum.MachineDisable);
}
if(machineStatus.status!=(int)Automation.MachineStatus.Waiting)
{
throw new BadRequestException(AccEnum.MachineBusy);
}
if (!_automationTaskList.CanTask(ProjectId,loading.section))
{
throw new BadRequestException(AccEnum.TaskProcessing);
}
var taskNo = _automationTaskList.CrateTaskNumber(Automation.TaskTrigerType.Manual);
_automationTaskList.Insert(new siger_automation_task_list
{
guid=taskNo,
action= Automation.TaskAction.Step_LK_SXLW,
actiontype= Automation.ExcueType.None,
triggertime=DateTime.MinValue,
tasktype= Automation.TaskActionType.Load,
operater=UserId,
operatetime=DateTime.Now,
sectionid=loading.section,
send=0,
status=1,
completetime=DateTime.MinValue,
trigger= Automation.TaskTrigerType.Manual,
projectId=ProjectId,
remark="手动任务",
});
if (_unitOfWork.Commit() > 0)
return new ObjectResult(CommonEnum.Succefull);
else
throw new BadRequestException(CommonEnum.Fail);
} }
/// <summary> /// <summary>
/// 安装完成 /// 安装完成 -生成指令
/// </summary> /// </summary>
/// <param name="assemble"></param> /// <param name="assemble"></param>
/// <returns></returns> /// <returns></returns>
......
...@@ -34,7 +34,7 @@ namespace Siger.ApiACC.Controllers ...@@ -34,7 +34,7 @@ namespace Siger.ApiACC.Controllers
} }
[HttpGet] [HttpGet]
public IActionResult GetPageList(string category, string code, string name, int projectid, int page, int pagesize) public IActionResult GetPageList(string category, string code, string name, int page, int pagesize)
{ {
var data = _toolsAssemblyRepository.GetPagedList(category.ToInt(), code, name, ProjectId, page, pagesize); var data = _toolsAssemblyRepository.GetPagedList(category.ToInt(), code, name, ProjectId, page, pagesize);
return new PagedObjectResult(data.Data, data.Total, page, pagesize); return new PagedObjectResult(data.Data, data.Total, page, pagesize);
......
...@@ -70,13 +70,15 @@ namespace Siger.ApiACC.Controllers ...@@ -70,13 +70,15 @@ namespace Siger.ApiACC.Controllers
{ {
guid = Guid.NewGuid().ToString(), guid = Guid.NewGuid().ToString(),
fixturetools = fixtureTool.guid, fixturetools = fixtureTool.guid,
remark=req.remark, remark = req.remark,
productid=req.productid.ToInt(), productid = req.productid.ToInt(),
projectId = ProjectId, projectId = ProjectId,
createtime = DateTime.Now, createtime = DateTime.Now,
updatetime = DateTime.Now, updatetime = DateTime.Now,
creator = UserId, creator = UserId,
updator = UserId, updator = UserId,
attachment = req.fileurl,
filename = req.filename
}; };
_toolsProductRepository.Insert(entity); _toolsProductRepository.Insert(entity);
if (_unitOfWork.Commit() > 0) if (_unitOfWork.Commit() > 0)
...@@ -123,7 +125,9 @@ namespace Siger.ApiACC.Controllers ...@@ -123,7 +125,9 @@ namespace Siger.ApiACC.Controllers
entity.productid = req.productid.ToInt(); entity.productid = req.productid.ToInt();
entity.updatetime = DateTime.Now; entity.updatetime = DateTime.Now;
entity.updator = UserId; entity.updator = UserId;
_toolsProductRepository.Insert(entity); entity.filename = req.filename;
entity.attachment = req.fileurl;
_toolsProductRepository.Update(entity);
if (_unitOfWork.Commit() > 0) if (_unitOfWork.Commit() > 0)
{ {
return new ObjectResult(CommonEnum.Succefull); return new ObjectResult(CommonEnum.Succefull);
......
...@@ -13,8 +13,6 @@ using Siger.Middlelayer.Repository; ...@@ -13,8 +13,6 @@ using Siger.Middlelayer.Repository;
using Siger.Middlelayer.Repository.Repositories.Interface; using Siger.Middlelayer.Repository.Repositories.Interface;
using Siger.Middlelayer.AccRepository.Response; using Siger.Middlelayer.AccRepository.Response;
using Siger.Middlelayer.Common.Extensions; using Siger.Middlelayer.Common.Extensions;
using Siger.Middlelayer.Dapper.CheckTrace.Repostriories;
using Siger.Middlelayer.Dapper.CheckTrace.Data;
namespace Siger.ApiACC.Controllers namespace Siger.ApiACC.Controllers
{ {
...@@ -104,59 +102,6 @@ namespace Siger.ApiACC.Controllers ...@@ -104,59 +102,6 @@ namespace Siger.ApiACC.Controllers
SaveTraceData(trace, uid); SaveTraceData(trace, uid);
return new ObjectResult(CommonEnum.Succefull); return new ObjectResult(CommonEnum.Succefull);
} }
/// <summary>
/// 保存Trace 1.2
/// </summary>
/// <param name="trace"></param>
/// <returns></returns>
[HttpPost]
[NoTokenValidateFilter]
public IActionResult SaveTraceInfo([FromBody]RequestTraceDetailsList trace)
{
var machine = _sigerProjectLevelSectionMachine.Get(f => f.section_id == trace.SectionID);
var newTrace = new SnTrace
{
MaterialID = 0,
ProductID = 0,
SectionID = trace.SectionID,
MachineID = machine?.machine_id ?? 0,
WorkOrder = "",
SN = trace.SN ?? "",
Result = trace.Result,
UserID = 0,
RouteID = 0,
CreateTime = DateTime.Now,
CheckType = 0
};
var dtslist = new List<SnTraceDetailList>();
var traceRepostory = new TraceDetailRepository(trace.companyId, trace.projectId);
foreach (var item in trace.Details)
{
var result = item.Result;
var itemVal = 0d;
// double数值超大时保存到result
if (item.Value.Length > 15)
result = item.Value;
else
itemVal = item.Value.ToDouble();
dtslist.Add(new SnTraceDetailList
{
ItemName = item.Item,
Result = result,
Value = itemVal,
});
}
var ret = traceRepostory.InsertTraceDetail(newTrace, dtslist, trace.projectId);
if (ret)
{
return new ObjectResult(CommonEnum.Succefull);
}
throw new BadRequestException(CommonEnum.Fail);
}
[HttpPost] [HttpPost]
public IActionResult SaveTFTrace([FromBody]RequestTFSaveTrace trace) public IActionResult SaveTFTrace([FromBody]RequestTFSaveTrace trace)
{ {
......
...@@ -3,6 +3,7 @@ using System.IO; ...@@ -3,6 +3,7 @@ using System.IO;
using System.Net; using System.Net;
using System.Net.Http; using System.Net.Http;
using System.Net.Http.Headers; using System.Net.Http.Headers;
using System.Web;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Siger.ApiCommon.Filters; using Siger.ApiCommon.Filters;
using Siger.ApiCommon.Utilities; using Siger.ApiCommon.Utilities;
...@@ -321,39 +322,32 @@ namespace Siger.ApiConfig.Controller ...@@ -321,39 +322,32 @@ namespace Siger.ApiConfig.Controller
[NoResultFilter] [NoResultFilter]
public IActionResult DownloadFileByUrl(string url, string name) public IActionResult DownloadFileByUrl(string url, string name)
{ {
if (string.IsNullOrWhiteSpace(url)) if (!string.IsNullOrEmpty(url))
{ {
return new NoContentResult(); var file_url = url.Split("Files");
} if (url.Length == 2)
var fileSetting = Config<FileSettings>.Get();
if (fileSetting == null)
{ {
return new NoContentResult(); url = "Files" + file_url[1];
} }
var rootDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, fileSetting.FileSetting.PhysicalFolder);
if (!Directory.Exists(rootDir))
{
return new NoContentResult();
} }
var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, url).Replace("Files", "TemporaryFiles");
var path = rootDir + url;
if (!System.IO.File.Exists(path)) if (!System.IO.File.Exists(path))
{ {
return new NoContentResult(); return new NoContentResult();
} }
try try
{ {
var stream = new FileStream(path, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite); var stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
var response = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StreamContent(stream) }; var response = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StreamContent(stream) };
response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment") response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
{ {
FileName = string.IsNullOrWhiteSpace(name) ? url.Substring(url.LastIndexOf('.')) : name FileName = name
}; };
return File(stream, "application/octet-stream"); return File(stream, "application/octet-stream");
} }
catch catch (Exception e)
{ {
throw new BadRequestException(CommonEnum.Fail); throw new BadRequestException(CommonEnum.Fail);
} }
......
...@@ -8,7 +8,6 @@ using Siger.Middlelayer.Common.Extensions; ...@@ -8,7 +8,6 @@ using Siger.Middlelayer.Common.Extensions;
using Siger.Middlelayer.Common.Helpers; using Siger.Middlelayer.Common.Helpers;
using Siger.Middlelayer.Common.ModuleEnum; using Siger.Middlelayer.Common.ModuleEnum;
using Siger.Middlelayer.Dapper; using Siger.Middlelayer.Dapper;
using Siger.Middlelayer.Dapper.CheckTrace.Repostriories;
using Siger.Middlelayer.DashboardRepository.Repositories.Interface; using Siger.Middlelayer.DashboardRepository.Repositories.Interface;
using Siger.Middlelayer.QmsRepository.Repositories.Interface; using Siger.Middlelayer.QmsRepository.Repositories.Interface;
using Siger.Middlelayer.Repository; using Siger.Middlelayer.Repository;
...@@ -34,6 +33,7 @@ namespace Siger.ApiDashboard.Controllers ...@@ -34,6 +33,7 @@ namespace Siger.ApiDashboard.Controllers
private readonly IDashboardFactoryChanel _dashboardFactoryChanel; private readonly IDashboardFactoryChanel _dashboardFactoryChanel;
private readonly IDashboardLevelRepository _dashboardLevel; private readonly IDashboardLevelRepository _dashboardLevel;
private readonly IInspectStandardRepository _standardRepository; private readonly IInspectStandardRepository _standardRepository;
private readonly ICheckSnTraceDetailRepository _traceDetailRepository;
/// <inheritdoc /> /// <inheritdoc />
public DashboardQmsController(IUnitOfWork unitOfWork, public DashboardQmsController(IUnitOfWork unitOfWork,
...@@ -42,7 +42,7 @@ namespace Siger.ApiDashboard.Controllers ...@@ -42,7 +42,7 @@ namespace Siger.ApiDashboard.Controllers
Isiger_wms_bussinese_contactsRepository businessRepository, ISigerAndonInfoRepository andonInfoRepository, Isiger_wms_bussinese_contactsRepository businessRepository, ISigerAndonInfoRepository andonInfoRepository,
IQmsReworkDataRepository reworkDataRepository, ISigerAndonExpectionTypeRepository andonExpectionRepository, IQmsReworkDataRepository reworkDataRepository, ISigerAndonExpectionTypeRepository andonExpectionRepository,
ISigerSystemConfigRepository systemConfigRepository, IDashboardFactoryChanel dashboardFactory, ISigerSystemConfigRepository systemConfigRepository, IDashboardFactoryChanel dashboardFactory,
IDashboardLevelRepository dashboardLevel, IInspectStandardRepository standardRepository) IDashboardLevelRepository dashboardLevel, IInspectStandardRepository standardRepository, ICheckSnTraceDetailRepository traceDetailRepository)
{ {
_unitOfWork = unitOfWork; _unitOfWork = unitOfWork;
_traceMaterialRepository = traceMaterialRepository; _traceMaterialRepository = traceMaterialRepository;
...@@ -57,6 +57,7 @@ namespace Siger.ApiDashboard.Controllers ...@@ -57,6 +57,7 @@ namespace Siger.ApiDashboard.Controllers
_dashboardFactoryChanel = dashboardFactory; _dashboardFactoryChanel = dashboardFactory;
_dashboardLevel = dashboardLevel; _dashboardLevel = dashboardLevel;
_standardRepository = standardRepository; _standardRepository = standardRepository;
_traceDetailRepository = traceDetailRepository;
} }
[HttpGet] [HttpGet]
public IActionResult GetIncomingCheckResult() public IActionResult GetIncomingCheckResult()
...@@ -115,12 +116,10 @@ namespace Siger.ApiDashboard.Controllers ...@@ -115,12 +116,10 @@ namespace Siger.ApiDashboard.Controllers
throw new BadRequestException(RequestEnum.LevelSectionNotFound); throw new BadRequestException(RequestEnum.LevelSectionNotFound);
} }
var res = new GetCheckStationStatusResult(); var res = new GetCheckStationStatusResult();
var _traceRepostory = new TraceDetailRepository(CompanyId, ProjectId);
var daterange = DateTimeHelper.GetDateTimeRange(DateTime.Now.ToString()); var daterange = DateTimeHelper.GetDateTimeRange(DateTime.Now.ToString());
var stime = daterange.StarTime.ToString(ParameterConstant.DateTimeFormat); var stime = daterange.StarTime.ToString(ParameterConstant.DateTimeFormat);
var etime = daterange.EndTime.ToString(ParameterConstant.DateTimeFormat); var etime = daterange.EndTime.ToString(ParameterConstant.DateTimeFormat);
var data = _traceRepostory.GetSnTracePageList(new List<int>(), 0, 0, 0, type, var data = _traceDetailRepository.GetSnTraceList(new List<int>(), 0, 0, type, stime, etime, ProjectId).ToList();
"", "", new List<long>(), stime, etime, 1, 10, ProjectId, "1", 0).ToList();
var typeOne = type.ToString(); var typeEnd = $",{typeOne}"; var typeStart = $"{typeOne},"; var typeTwo = $",{typeOne},";//精确匹配,避免类似12匹配到1的情况 var typeOne = type.ToString(); var typeEnd = $",{typeOne}"; var typeStart = $"{typeOne},"; var typeTwo = $",{typeOne},";//精确匹配,避免类似12匹配到1的情况
var sectionIds = _standardRepository.GetList(t => t.projectid == ProjectId && t.status == (int)RowState.Valid && var sectionIds = _standardRepository.GetList(t => t.projectid == ProjectId && t.status == (int)RowState.Valid &&
(t.checktype.Contains(",") ? (t.checktype.Contains(typeTwo) || t.checktype.StartsWith(typeStart) || t.checktype.EndsWith(typeEnd)) : (t.checktype == typeOne))).Select(t => t.sectionid).Distinct().ToList(); (t.checktype.Contains(",") ? (t.checktype.Contains(typeTwo) || t.checktype.StartsWith(typeStart) || t.checktype.EndsWith(typeEnd)) : (t.checktype == typeOne))).Select(t => t.sectionid).Distinct().ToList();
...@@ -255,7 +254,6 @@ namespace Siger.ApiDashboard.Controllers ...@@ -255,7 +254,6 @@ namespace Siger.ApiDashboard.Controllers
throw new BadRequestException(RequestEnum.LevelSectionNotFound); throw new BadRequestException(RequestEnum.LevelSectionNotFound);
} }
var res = new GetChannelFtqResult(); var res = new GetChannelFtqResult();
var _traceRepostory = new TraceDetailRepository(CompanyId, ProjectId);
var _yieldRepository = new LocationYieldRepository(CompanyId, ProjectId); var _yieldRepository = new LocationYieldRepository(CompanyId, ProjectId);
var daterange = DateTimeHelper.GetDateTimeRange(date); var daterange = DateTimeHelper.GetDateTimeRange(date);
var stime = daterange.StarTime; var stime = daterange.StarTime;
...@@ -267,8 +265,7 @@ namespace Siger.ApiDashboard.Controllers ...@@ -267,8 +265,7 @@ namespace Siger.ApiDashboard.Controllers
lstSections.AddRange(stations); lstSections.AddRange(stations);
lines = lines.Where(f => f.id == section); lines = lines.Where(f => f.id == section);
} }
var data = _traceRepostory.GetSnTracePageList(lstSections, 0, 0, 0, 0, var data = _traceDetailRepository.GetSnTraceList(lstSections, 0, 0, 0, stime.ToString(ParameterConstant.DateTimeFormat), etime.ToString(ParameterConstant.DateTimeFormat), ProjectId).ToList();
"", "", new List<long> { }, stime.ToString(ParameterConstant.DateTimeFormat), etime.ToString(ParameterConstant.DateTimeFormat), 1, 10, ProjectId, "1", 0).ToList();
var stationLow = new List<LineFtqObj>(); var stationLow = new List<LineFtqObj>();
var ychart = new double[] { 98.92 , 87.9 , 99.45 , 100 , 96.11 }; var ychart = new double[] { 98.92 , 87.9 , 99.45 , 100 , 96.11 };
...@@ -279,61 +276,12 @@ namespace Siger.ApiDashboard.Controllers ...@@ -279,61 +276,12 @@ namespace Siger.ApiDashboard.Controllers
t.id == line.id); t.id == line.id);
if (channel != null) if (channel != null)
{ {
//var sections = GetSectionSelect(1, line.id);
//var yieldDatas = _yieldRepository.GetLocationYieldsBySectionIds(new List<int> { line.id }, stime, etime).ToList();
res.X.Add(channel.title); res.X.Add(channel.title);
//var list = data.Where(t => sections.Select(q => q.id).Contains(t.SectionID)).ToList();
//double okRate = 1;
//var yieldCount = 0;
//var recordCount = 0d;
//var yield = yieldDatas.Sum(t => t.yield);
//foreach (var _section in sections)
//{
// var ngNum = list.Count(t => t.SectionID == _section.id && t.Result.ToUpper() == "NG");
// if (yield == 0)
// continue;
// var actualYield = (yield - ngNum) > 0 ? (yield - ngNum) : 0;
// var rate = yield > 0 ? actualYield / (double)yield : 0;
// if (rate < okRate)
// {
// okRate = rate;
// }
// yieldCount += actualYield;
// recordCount += yield;
//}
//stationLow.Add(new LineFtqObj
//{
// OkRate = okRate,
// Station = channel.id,
// OkCount = yieldCount,
// TotalCount = recordCount,
//});
res.Y.Add(ychart[i]); res.Y.Add(ychart[i]);
i++; i++;
} }
} }
//if (section != 0) //通道显示
//{
// res.totalFtq = res.Y[0];
//}
//else
//{
// var lowChanel = stationLow.OrderBy(f => f.OkRate).FirstOrDefault();
// if (lowChanel.TotalCount == 0)
// {
// res.totalFtq = 0;
// }
// else
// {
// var rateTotal = lowChanel.OkCount / lowChanel.TotalCount;
// res.totalFtq = Math.Round((rateTotal > 1 ? 1 : rateTotal) * 100, 2);
// }
//}
res.totalFtq = 99.78; res.totalFtq = 99.78;
return new ObjectResult(res); return new ObjectResult(res);
...@@ -352,15 +300,13 @@ namespace Siger.ApiDashboard.Controllers ...@@ -352,15 +300,13 @@ namespace Siger.ApiDashboard.Controllers
throw new BadRequestException(RequestEnum.LevelSectionNotFound); throw new BadRequestException(RequestEnum.LevelSectionNotFound);
} }
var res = new GetChannelFtqResult(); var res = new GetChannelFtqResult();
var _traceRepostory = new TraceDetailRepository(CompanyId, ProjectId);
var daterange = DateTimeHelper.GetDateTimeRange(DateTime.Now.ToString()); var daterange = DateTimeHelper.GetDateTimeRange(DateTime.Now.ToString());
var stime = daterange.StarTime.ToString(ParameterConstant.DateTimeFormat); var stime = daterange.StarTime.ToString(ParameterConstant.DateTimeFormat);
var etime = daterange.EndTime.ToString(ParameterConstant.DateTimeFormat); var etime = daterange.EndTime.ToString(ParameterConstant.DateTimeFormat);
var _yieldRepository = new LocationYieldRepository(CompanyId, ProjectId); var _yieldRepository = new LocationYieldRepository(CompanyId, ProjectId);
var data = _traceRepostory.GetSnTracePageList(new List<int> { }, 0, 0, 0, 0, var data = _traceDetailRepository.GetSnTraceList(new List<int> { }, 0, 0, 0, stime.ToString(), etime.ToString(), ProjectId).ToList();
"", "", new List<long> { }, stime.ToStr(), etime.ToStr(), 1, 10, ProjectId, "1", 0).ToList();
var yieldCount = 0; var yieldCount = 0;
var recordCount = 0d; var recordCount = 0d;
foreach (var line in lines) foreach (var line in lines)
......
...@@ -13,7 +13,6 @@ using Siger.Middlelayer.Dapper; ...@@ -13,7 +13,6 @@ using Siger.Middlelayer.Dapper;
using Siger.Middlelayer.DashboardRepository.Response; using Siger.Middlelayer.DashboardRepository.Response;
using Siger.Middlelayer.Common.Helpers; using Siger.Middlelayer.Common.Helpers;
using Siger.Middlelayer.Common.ModuleEnum; using Siger.Middlelayer.Common.ModuleEnum;
using Siger.Middlelayer.Dapper.CheckTrace.Repostriories;
using Siger.Middlelayer.TpmRepository; using Siger.Middlelayer.TpmRepository;
using Siger.Middlelayer.QmsRepository; using Siger.Middlelayer.QmsRepository;
using Siger.Middlelayer.Share.Enum.ModuleEnum; using Siger.Middlelayer.Share.Enum.ModuleEnum;
...@@ -231,11 +230,10 @@ namespace Siger.ApiDashboard.Tasks ...@@ -231,11 +230,10 @@ namespace Siger.ApiDashboard.Tasks
{ {
try try
{ {
var _traceRepostory = new TraceDetailRepository(companyId, projectId);
var _yieldRepository = new LocationYieldRepository(companyId, projectId); var _yieldRepository = new LocationYieldRepository(companyId, projectId);
var data = _traceRepostory.GetSnTracePageList(new List<int> { }, 0, 0, 0, 0, var data = _qmsDbContext.siger_check_sn_trace_inspection.Where(q => q.projectid == projectId && q.status == (int)RowState.Valid && q.checking_time <= end &&
"", "", new List<long> { }, begin.ToString(ParameterConstant.DateTimeFormat), end.ToString(ParameterConstant.DateTimeFormat), 1, 10, projectId, "1", 0).ToList(); q.checking_time >= begin).ToList();
var lines = GetLine(projectId).ToList(); var lines = GetLine(projectId).ToList();
foreach (var line in lines) foreach (var line in lines)
{ {
...@@ -244,7 +242,7 @@ namespace Siger.ApiDashboard.Tasks ...@@ -244,7 +242,7 @@ namespace Siger.ApiDashboard.Tasks
//var yieldDatas = _yieldRepository.GetLocationYieldsBySectionIds(sections.Select(t => t.id), begin, end).ToList(); //var yieldDatas = _yieldRepository.GetLocationYieldsBySectionIds(sections.Select(t => t.id), begin, end).ToList();
//var bottleMachine = GetBottleMachine(projectId, line.id,false); //var bottleMachine = GetBottleMachine(projectId, line.id,false);
var list = data.Where(t => sections.Select(q => q.id).Contains(t.SectionID)).ToList(); var list = data.Where(t => sections.Select(q => q.id).Contains(t.sectionid)).ToList();
double okRate = 1; double okRate = 1;
//var minOk = 0d; //var minOk = 0d;
//var minTtl = 0d; //var minTtl = 0d;
...@@ -253,7 +251,7 @@ namespace Siger.ApiDashboard.Tasks ...@@ -253,7 +251,7 @@ namespace Siger.ApiDashboard.Tasks
var yield = yieldDatas.Sum(t => t.yield); var yield = yieldDatas.Sum(t => t.yield);
foreach (var _section in sections) foreach (var _section in sections)
{ {
var ngNum = list.Count(t => t.SectionID == _section.id && t.Result.ToUpper() == "NG"); var ngNum = list.Count(t => t.sectionid == _section.id && t.result == ((int)SendTestType.Unqualified).ToString());
if (yield == 0) if (yield == 0)
continue; continue;
var actualYield = (yield - ngNum) > 0 ? (yield - ngNum) : 0; var actualYield = (yield - ngNum) > 0 ? (yield - ngNum) : 0;
......
...@@ -19,10 +19,6 @@ using Siger.Middlelayer.Repository.Repositories.Interface; ...@@ -19,10 +19,6 @@ using Siger.Middlelayer.Repository.Repositories.Interface;
using Siger.Middlelayer.Repository.Response; using Siger.Middlelayer.Repository.Response;
using Siger.Middlelayer.Utility.Helpers; using Siger.Middlelayer.Utility.Helpers;
using Siger.Middlelayer.Utility.ImportEntities; using Siger.Middlelayer.Utility.ImportEntities;
using Siger.Middlelayer.Dapper.CheckTrace.Repostriories;
using System.Threading.Tasks;
using Siger.Middlelayer.Dapper.CheckTrace.Data;
using Siger.Middlelayer.Dapper.CheckTrace.Constant;
using Siger.ApiQMS.Utility; using Siger.ApiQMS.Utility;
using Siger.Middlelayer.Common.Helpers; using Siger.Middlelayer.Common.Helpers;
...@@ -72,231 +68,6 @@ namespace Siger.ApiQMS.Controllers ...@@ -72,231 +68,6 @@ namespace Siger.ApiQMS.Controllers
} }
/// <summary> /// <summary>
/// 产品追溯查询
/// </summary>
/// <param name="sectionid">产线ID</param>
/// <param name="productid">产品ID</param>
/// <param name="materialid">物料ID</param>
/// <param name="route">工序ID</param>
/// <param name="checktype">检验类型</param>
/// <param name="sn">二维码</param>
/// <param name="result">结果OK 或者 NG 或者 传 2=让步放行</param>
/// <param name="itemid">检验项目ID</param>
/// <param name="itemname">检验项目名称 检验项目表的item_en</param>
/// <param name="starttime">开始时间</param>
/// <param name="endtime">结束时间</param>
/// <param name="userid">检验人ID</param>
/// <param name="usercheck">是否有检验人ID 0=>查询所有数据 大于0=>只查询有检验人的数据</param>
/// <param name="page"></param>
/// <param name="pagesize"></param>
/// <param name="toexcel">是否导出excel 0=>不导出,查询数据 1=>导出数据到excel</param>
/// <param name="inspectiontype">1->送检 2->人工检验</param>
/// <returns></returns>
[HttpGet]
public IActionResult GetPageList(int sectionid, int productid, int materialid, int route, int checktype, string sn, string result, int itemid, string itemname,
string starttime, string endtime, string userid, string usercheck, int page, int pagesize, string toexcel, int inspectiontype = 0)
{
if (result.ToInt() == (int)SendTestType.DeviationRelease)
{
return GetPageListByDeviationRelease(sectionid, productid, materialid, route, checktype, sn, result, itemid, itemname,
starttime, endtime, page, pagesize, toexcel);
}
else
{
return GetPageListResult(sectionid, productid, materialid, route, checktype, sn, result, itemid, itemname,
starttime, endtime, userid.ToInt(), usercheck.ToInt(), page, pagesize, toexcel, inspectiontype);
}
}
private IActionResult GetPageListResult(int sectionid, int productid, int materialid, int route, int checktype, string sn, string result, int itemid, string itemname,
string starttime, string endtime, int userid, int usercheck, int page, int pagesize, string toexcel, int inspectiontype = 0)
{
var list = new List<ResponseDataCollection>();
long total = 0;
var _traceRepostory = new TraceDetailRepository(CompanyId, ProjectId);
var tables = _traceRepostory.GetSubTableList(TabelNameConstant.SnTraceDetailTable);
var traceIds = new List<long>();
if (itemid > 0)
{
traceIds = _traceRepostory.GetTraceIdList(new List<long>(), 0, new List<int> { itemid },
itemname ?? "", starttime, endtime, ProjectId).ToList();
}
var sectionIds = new List<int>();
if (sectionid > 0)
{
sectionIds = _levelSectionRepository.GetLevelSectionIds(sectionid, ProjectId).ToList();
}
Task<bool>[] tasks = new Task<bool>[2];
var traces = new List<SnTrace>();
tasks[0] = Task<bool>.Factory.StartNew(() =>
{
traces = _traceRepostory.GetSnTracePageList(sectionIds, productid, materialid, route, checktype, sn, result,
traceIds, starttime, endtime, page, pagesize, ProjectId, toexcel, userid, usercheck, false, inspectiontype).ToList();
return true;
});
tasks[1] = Task<bool>.Factory.StartNew(() =>
{
total = _traceRepostory.CountTrace(sectionIds, productid, materialid, route, checktype, sn, result,
traceIds, starttime, endtime, ProjectId, userid, usercheck, false, inspectiontype);
return true;
});
Task.WaitAll(tasks);
if (traces.Any())
{
var checkIds = traces.Select(t => t.ID).Distinct().ToList();
var inspections = _traceInspectionRepository.GetList(t => checkIds.Contains(t.trace_id) && t.status == (int)RowState.Valid &&
t.projectid == ProjectId).ToList();
var sections = _levelSectionRepository.GetList(t => t.projectid == ProjectId && t.status == (int)RowState.Valid).ToList();
var userIds = traces.Select(t => t.UserID).Distinct().ToList();
var users = _projectUserRepository.GetList(t => t.projectid == ProjectId && t.status == (int)RowState.Valid &&
userIds.Contains(t.mid)).ToList();
var productIds = traces.Select(t => t.ProductID).Distinct().ToList();
var products = _productRepository.GetList(t => productIds.Contains(t.id) && t.projectid == ProjectId &&
t.status == (int)RowState.Valid).ToList();
var routeIds = traces.Select(t => t.RouteID).Distinct().ToList();
var routes = _productRouteRepository.GetList(t => routeIds.Contains(t.id) && t.projectId == ProjectId &&
t.status == (int)RowState.Valid).ToList();
var materialIds = traces.Select(t => t.MaterialID).Distinct().ToList();
var materials = _materialsRepository.GetList(t => materialIds.Contains(t.id) && t.projectId == ProjectId &&
t.status == (int)RowState.Valid).ToList();
foreach (var trace in traces)
{
var inspection = inspections.FirstOrDefault(t => t.trace_id == trace.ID);
var product = products.FirstOrDefault(t => t.id == trace.ProductID);
var user = users.FirstOrDefault(t => t.mid == trace.UserID);
var routeModel = routes.FirstOrDefault(t => t.id == trace.RouteID);
var material = materials.FirstOrDefault(t => t.id == trace.MaterialID);
var data = new ResponseDataCollection
{
id = trace.ID,
productid = trace.ProductID,
productcode = product?.code ?? "",
productname = product?.name ?? "",
sectionid = trace.SectionID,
sectionname = ChannelSectionHelper.GetChannelSection(trace.SectionID, sections),
workorder = trace.WorkOrder,
sn = trace.SN,
result = inspection?.result ?? (trace.Result.ToUpper() == "OK" ? ((int)SendTestType.Qalified).ToString() : ((int)SendTestType.Unqualified).ToString()),
check_mid = trace.UserID,
check_user = user?.name ?? "",
check_time = trace.CreateTime.ToString(ParameterConstant.DateTimeFormat),
routeid = trace.RouteID,
routename = routeModel?.name ?? "",
materialid = trace.MaterialID,
materialname = material?.name ?? "",
materialpn = material?.pn ?? "",
checktype = inspection == null ? trace.CheckType : inspection.check_type
};
list.Add(data);
}
}
if (toexcel.ToInt() == 1)
{
return ExportExcel(list);
}
return new PagedLongTotalObjectResult(list, total, page, pagesize);
}
private IActionResult GetPageListByDeviationRelease(int sectionid, int productid, int materialid, int route, int checktype, string sn, string result, int itemid, string itemname,
string starttime, string endtime, int page, int pagesize, string toexcel)
{
var list = new List<ResponseDataCollection>();
long total = 0;
var inspections = _traceInspectionRepository.GetList(t => t.projectid == ProjectId && t.status == (int)RowState.Valid &&
t.result.ToInt() == result.ToInt() && t.check_status == (int)SendCheckStatus.Completed);
var sectionIds = new List<int>();
if (sectionid > 0)
{
sectionIds = _levelSectionRepository.GetLevelSectionIds(sectionid, ProjectId).ToList();
if (sectionIds.Any())
{
inspections = inspections.Where(t => sectionIds.Contains(t.sectionid));
}
}
if (productid > 0)
{
inspections = inspections.Where(t => t.productid == productid);
}
if (materialid > 0)
{
inspections = inspections.Where(t => t.materialid == materialid);
}
if (route > 0)
{
inspections = inspections.Where(t => t.routeid == route);
}
if (!string.IsNullOrEmpty(starttime) && !string.IsNullOrEmpty(endtime))
{
inspections = inspections.Where(t => t.check_time <= endtime.ToDateTime() && t.check_time >= starttime.ToDateTime());
}
var _traceRepostory = new TraceDetailRepository(CompanyId, ProjectId);
var tables = _traceRepostory.GetSubTableList(TabelNameConstant.SnTraceDetailTable);
var itemTraceIds = new List<long>();
if (itemid > 0)
{
itemTraceIds = _traceRepostory.GetTraceIdList(new List<long>(), 0, new List<int> { itemid },
itemname ?? "", starttime, endtime, ProjectId).ToList();
}
if (itemTraceIds.Any())
{
inspections = inspections.Where(t => itemTraceIds.Contains(t.trace_id));
}
total = inspections.Count();
var dataList = toexcel.ToInt() == 1 ? inspections.OrderByDescending(t => t.check_time).ToList() :
inspections.OrderByDescending(t => t.check_time).Skip((page - 1) * pagesize).Take(pagesize).ToList();
var traceIds = dataList.Where(t => t.trace_id > 0).Select(t => t.trace_id).ToList();
if (dataList.Any())
{
var sections = _levelSectionRepository.GetList(t => t.projectid == ProjectId && t.status == (int)RowState.Valid).ToList();
var users = _projectUserRepository.GetList(t => t.projectid == ProjectId && t.status == (int)RowState.Valid).ToList();
var routeIds = dataList.Select(t => t.routeid).Distinct().ToList();
var routes = _productRouteRepository.GetList(t => routeIds.Contains(t.id) && t.projectId == ProjectId &&
t.status == (int)RowState.Valid).ToList();
foreach (var trace in dataList)
{
var inspection = inspections.FirstOrDefault(t => t.trace_id == trace.trace_id);
var product = _productRepository.Get(t => t.id == trace.productid && t.projectid == ProjectId &&
t.status == (int)RowState.Valid);
var user = users.FirstOrDefault(t => t.mid == trace.check_mid);
var routeModel = routes.FirstOrDefault(t => t.id == trace.routeid);
var data = new ResponseDataCollection
{
id = trace.trace_id,
productid = trace.productid,
productcode = product?.code ?? "",
productname = product?.name ?? "",
sectionid = trace.sectionid,
sectionname = ChannelSectionHelper.GetChannelSection(trace.sectionid, sections),
workorder = "",
sn = trace.sn,
result = inspection.result ?? "",
check_mid = trace.check_mid,
check_user = user?.name ?? "",
check_time = (trace.check_time.HasValue && trace.check_time != DateTime.MinValue) ?
trace.check_time.Value.ToString(ParameterConstant.DateTimeFormat) : "",
routeid = trace.routeid,
routename = routeModel?.name ?? "",
};
list.Add(data);
}
}
if (toexcel.ToInt() == 1)
{
return ExportExcel(list);
}
return new PagedLongTotalObjectResult(list, total, page, pagesize);
}
/// <summary>
/// 人工检验数据查询 /// 人工检验数据查询
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
...@@ -310,7 +81,7 @@ namespace Siger.ApiQMS.Controllers ...@@ -310,7 +81,7 @@ namespace Siger.ApiQMS.Controllers
sectionIds = _levelSectionRepository.GetLevelSectionIds(sectionid, ProjectId).ToList(); sectionIds = _levelSectionRepository.GetLevelSectionIds(sectionid, ProjectId).ToList();
} }
var dataList = new List<ResponseDataCollection>(); var dataList = new List<ResponseDataCollection>();
var res = _traceDetailRepository.GetPagedList(sectionIds, productid, materialid, route, checktype, sn, result, new List<long>(), var res = _traceDetailRepository.GetPagedList(sectionIds, productid, materialid, route, checktype, sn, result, new List<string>(),
starttime, endtime, userid.ToInt(), itemid, ProjectId, page, pagesize, toexcel); starttime, endtime, userid.ToInt(), itemid, ProjectId, page, pagesize, toexcel);
var sections = _levelSectionRepository.GetList(t => t.projectid == ProjectId && var sections = _levelSectionRepository.GetList(t => t.projectid == ProjectId &&
t.status == (int)RowState.Valid).ToList(); t.status == (int)RowState.Valid).ToList();
...@@ -428,7 +199,7 @@ namespace Siger.ApiQMS.Controllers ...@@ -428,7 +199,7 @@ namespace Siger.ApiQMS.Controllers
} }
insertDetailList.Add(new SnTraceDetailList insertDetailList.Add(new SnTraceDetailList
{ {
TraceID = 0, TraceID = "",
ItemID = detail.itemid, ItemID = detail.itemid,
Result = detail.result, Result = detail.result,
Value = detail.value, Value = detail.value,
...@@ -468,7 +239,7 @@ namespace Siger.ApiQMS.Controllers ...@@ -468,7 +239,7 @@ namespace Siger.ApiQMS.Controllers
} }
insertDetailList.Add(new SnTraceDetailList insertDetailList.Add(new SnTraceDetailList
{ {
TraceID = 0, TraceID = "",
ItemID = detail.itemid, ItemID = detail.itemid,
Result = detailResult, Result = detailResult,
Value = detail.value, Value = detail.value,
...@@ -481,14 +252,8 @@ namespace Siger.ApiQMS.Controllers ...@@ -481,14 +252,8 @@ namespace Siger.ApiQMS.Controllers
} }
} }
} }
var _traceRepostory = new TraceDetailRepository(CompanyId, ProjectId);
var resDetails = new List<SnTraceDetailList>(); var trace_id = Guid.NewGuid().ToString();
//插入大数据库 检验详情表
var res = _traceRepostory.InsertTraceDetailReturnTraceIdNumberIndex(trace, insertDetailList, ProjectId, out resDetails);
if (res <= 0)
{
throw new BadRequestException(CommonEnum.Fail);
}
#region 插入检验扩展表 #region 插入检验扩展表
...@@ -503,7 +268,7 @@ namespace Siger.ApiQMS.Controllers ...@@ -503,7 +268,7 @@ namespace Siger.ApiQMS.Controllers
//插入中间层库的trace表 //插入中间层库的trace表
var inspection = new siger_check_sn_trace_inspection var inspection = new siger_check_sn_trace_inspection
{ {
trace_id = res, trace_id = trace_id,
testroom = "", testroom = "",
productid = req.productid, productid = req.productid,
materialid = req.materialid.ToInt(), materialid = req.materialid.ToInt(),
...@@ -672,22 +437,15 @@ namespace Siger.ApiQMS.Controllers ...@@ -672,22 +437,15 @@ namespace Siger.ApiQMS.Controllers
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[HttpGet] [HttpGet]
public IActionResult GetDetails(int productid, int sectionid, long id) public IActionResult GetDetails(int productid, int sectionid, string id)
{ {
var res = new List<ResponseDataCollectionDetail>(); var res = new List<ResponseDataCollectionDetail>();
if (id > 0) if (!string.IsNullOrEmpty(id))
{
var _traceRepostory = new TraceDetailRepository(CompanyId, ProjectId);
var trace = _traceRepostory.GetSnTrace(id, ProjectId);
if (trace == null)
{ {
throw new BadRequestException(CommonEnum.RecordNotFound); var dataDetails = _traceDetailRepository.GetList(q => q.TraceID == id && q.projectid == ProjectId && q.status == (int)RowState.Valid).ToList();
} var standards = _inspectStandard.GetList(t => t.productid == productid &&
t.sectionid == sectionid && t.projectid == ProjectId &&
var standards = _inspectStandard.GetList(t => t.productid == trace.ProductID &&
t.sectionid == trace.SectionID && t.projectid == ProjectId &&
t.status == (int)RowState.Valid).ToList(); t.status == (int)RowState.Valid).ToList();
var dataDetails = _traceRepostory.GetSingleTraceDetailList(trace.ID, ProjectId);
foreach (var standard in standards) foreach (var standard in standards)
{ {
...@@ -743,17 +501,11 @@ namespace Siger.ApiQMS.Controllers ...@@ -743,17 +501,11 @@ namespace Siger.ApiQMS.Controllers
/// <param name="id"></param> /// <param name="id"></param>
/// <returns></returns> /// <returns></returns>
[HttpGet] [HttpGet]
public IActionResult GetDetailList(long id) public IActionResult GetDetailList(string id)
{ {
var res = new List<ResponseDataCollectionDetail>(); var res = new List<ResponseDataCollectionDetail>();
var _traceRepostory = new TraceDetailRepository(CompanyId, ProjectId);
var trace = _traceRepostory.GetSnTrace(id, ProjectId);
if (trace == null)
{
throw new BadRequestException(CommonEnum.RecordNotFound);
}
var dataDetails = _traceDetailRepository.GetList(t => t.projectid == ProjectId && t.status == (int)RowState.Valid && var dataDetails = _traceDetailRepository.GetList(t => t.projectid == ProjectId && t.status == (int)RowState.Valid &&
t.TraceID == trace.ID).ToList(); t.TraceID == id).ToList();
var configKeys = dataDetails.Select(t => t.ItemName).ToList(); var configKeys = dataDetails.Select(t => t.ItemName).ToList();
var configs = _defaultInfoConfigRepository.GetList(t => configKeys.Contains(t.key)).ToList(); var configs = _defaultInfoConfigRepository.GetList(t => configKeys.Contains(t.key)).ToList();
...@@ -790,16 +542,10 @@ namespace Siger.ApiQMS.Controllers ...@@ -790,16 +542,10 @@ namespace Siger.ApiQMS.Controllers
/// <param name="id"></param> /// <param name="id"></param>
/// <returns></returns> /// <returns></returns>
[HttpGet] [HttpGet]
public IActionResult GetTraceDetailList(long id) public IActionResult GetTraceDetailList(string id)
{ {
var res = new List<ResponseDataCollectionDetail>(); var res = new List<ResponseDataCollectionDetail>();
var _traceRepostory = new TraceDetailRepository(CompanyId, ProjectId); var dataDetails = _traceDetailRepository.GetList(q => q.projectid == ProjectId && q.status == (int)RowState.Valid && q.TraceID == id).ToList();
var trace = _traceRepostory.GetSnTrace(id, ProjectId);
if (trace == null)
{
throw new BadRequestException(CommonEnum.RecordNotFound);
}
var dataDetails = _traceRepostory.GetSingleTraceDetailList(id, ProjectId);
var configKeys = dataDetails.Select(t => t.ItemName).ToList(); var configKeys = dataDetails.Select(t => t.ItemName).ToList();
var configs = _defaultInfoConfigRepository.GetList(t => configKeys.Contains(t.key)).ToList(); var configs = _defaultInfoConfigRepository.GetList(t => configKeys.Contains(t.key)).ToList();
...@@ -847,16 +593,12 @@ namespace Siger.ApiQMS.Controllers ...@@ -847,16 +593,12 @@ namespace Siger.ApiQMS.Controllers
} }
[HttpGet] [HttpGet]
public IActionResult Delete(long id) public IActionResult Delete(string id)
{ {
if (id == 0) if (string.IsNullOrEmpty(id))
{ {
throw new BadRequestException(CommonEnum.RecordNotFound); throw new BadRequestException(CommonEnum.RecordNotFound);
} }
var _traceRepostory = new TraceDetailRepository(CompanyId, ProjectId);
var result = _traceRepostory.DeleteData(id);
if (result)
{
var inspections = _traceInspectionRepository.GetList(t => var inspections = _traceInspectionRepository.GetList(t =>
t.trace_id == id && t.projectid == ProjectId && t.status == (int)RowState.Valid).ToList(); t.trace_id == id && t.projectid == ProjectId && t.status == (int)RowState.Valid).ToList();
var details = _traceDetailRepository.GetList(t => var details = _traceDetailRepository.GetList(t =>
...@@ -871,7 +613,8 @@ namespace Siger.ApiQMS.Controllers ...@@ -871,7 +613,8 @@ namespace Siger.ApiQMS.Controllers
detail.status = (int)RowState.Invalid; detail.status = (int)RowState.Invalid;
_traceDetailRepository.Update(detail); _traceDetailRepository.Update(detail);
} }
_unitOfWork.Commit(); if(_unitOfWork.Commit() > 0)
{
return new ObjectResult(CommonEnum.Succefull); return new ObjectResult(CommonEnum.Succefull);
} }
else else
...@@ -883,9 +626,9 @@ namespace Siger.ApiQMS.Controllers ...@@ -883,9 +626,9 @@ namespace Siger.ApiQMS.Controllers
[HttpPost] [HttpPost]
public IActionResult Update([FromBody]RequestUpdateDataCollection req) public IActionResult Update([FromBody]RequestUpdateDataCollection req)
{ {
var _traceRepostory = new TraceDetailRepository(CompanyId, ProjectId); var inspection = _traceInspectionRepository.Get(t => t.status == (int)RowState.Valid && t.projectid == ProjectId &&
var snTrace = _traceRepostory.GetSnTrace(req.id, ProjectId); t.trace_id == req.id);
if (snTrace == null) if (inspection == null)
{ {
throw new BadRequestException(CommonEnum.RecordNotFound); throw new BadRequestException(CommonEnum.RecordNotFound);
} }
...@@ -957,7 +700,7 @@ namespace Siger.ApiQMS.Controllers ...@@ -957,7 +700,7 @@ namespace Siger.ApiQMS.Controllers
} }
insertDetailList.Add(new SnTraceDetailList insertDetailList.Add(new SnTraceDetailList
{ {
TraceID = 0, TraceID = "",
ItemID = detail.itemid, ItemID = detail.itemid,
Result = detail.result, Result = detail.result,
Value = detail.value, Value = detail.value,
...@@ -997,7 +740,7 @@ namespace Siger.ApiQMS.Controllers ...@@ -997,7 +740,7 @@ namespace Siger.ApiQMS.Controllers
} }
insertDetailList.Add(new SnTraceDetailList insertDetailList.Add(new SnTraceDetailList
{ {
TraceID = 0, TraceID = "",
ItemID = detail.itemid, ItemID = detail.itemid,
Result = detailResult, Result = detailResult,
Value = detail.value, Value = detail.value,
...@@ -1010,16 +753,6 @@ namespace Siger.ApiQMS.Controllers ...@@ -1010,16 +753,6 @@ namespace Siger.ApiQMS.Controllers
} }
} }
} }
if (!_traceRepostory.DeleteDetail(req.id))
{
throw new BadRequestException(CommonEnum.Fail);
}
var resDetails = new List<SnTraceDetailList>();
var res = _traceRepostory.InsertTraceOnlyDetailsReturnNumerIndex(snTrace, insertDetailList, ProjectId, traceResult, out resDetails);
if (!res)
{
throw new BadRequestException(CommonEnum.Fail);
}
#region 插入检验扩展表 #region 插入检验扩展表
if (req.result.ToUpper() == "OK") if (req.result.ToUpper() == "OK")
...@@ -1030,34 +763,7 @@ namespace Siger.ApiQMS.Controllers ...@@ -1030,34 +763,7 @@ namespace Siger.ApiQMS.Controllers
{ {
req.result = ((int)SendTestType.Unqualified).ToString(); req.result = ((int)SendTestType.Unqualified).ToString();
} }
var inspection = _traceInspectionRepository.Get(t => t.status == (int)RowState.Valid && t.projectid == ProjectId &&
t.trace_id == req.id);
if(inspection == null)
{
inspection = new siger_check_sn_trace_inspection
{
trace_id = snTrace.ID,
testroom = "",
productid = snTrace.ProductID,
materialid = snTrace.MaterialID,
sectionid = snTrace.SectionID,
sn = snTrace.SN ?? "",
routeid = snTrace.RouteID,
check_type = snTrace.CheckType,
check_status = (int)SendCheckStatus.Completed,
result = req.result,
send_mid = snTrace.UserID,
send_time = snTrace.CreateTime,
check_mid = snTrace.UserID,
check_time = snTrace.CreateTime,
inspection_type = (int)InspectionType.ManualCollection,
projectid = ProjectId,
workorder = snTrace.WorkOrder,
number = req.number.ToInt(),
quantity = req.quantity.ToInt()
};
_traceInspectionRepository.Insert(inspection);
}
else else
{ {
inspection.result = req.result; inspection.result = req.result;
...@@ -1075,7 +781,7 @@ namespace Siger.ApiQMS.Controllers ...@@ -1075,7 +781,7 @@ namespace Siger.ApiQMS.Controllers
{ {
var model = new siger_check_sn_trace_detail var model = new siger_check_sn_trace_detail
{ {
TraceID = snTrace.ID, TraceID = req.id,
ItemID = detail.ItemID, ItemID = detail.ItemID,
Result = detail.Result, Result = detail.Result,
Value = detail.Value, Value = detail.Value,
...@@ -1085,7 +791,7 @@ namespace Siger.ApiQMS.Controllers ...@@ -1085,7 +791,7 @@ namespace Siger.ApiQMS.Controllers
LowerLimit = detail.LowerLimit, LowerLimit = detail.LowerLimit,
UpperLimit = detail.UpperLimit, UpperLimit = detail.UpperLimit,
projectid = ProjectId, projectid = ProjectId,
CreateTime = snTrace.CreateTime, CreateTime = inspection.checking_time.HasValue ? inspection.checking_time.Value : DateTime.Now,
}; };
_traceDetailRepository.Insert(model); _traceDetailRepository.Insert(model);
} }
...@@ -1141,7 +847,7 @@ namespace Siger.ApiQMS.Controllers ...@@ -1141,7 +847,7 @@ namespace Siger.ApiQMS.Controllers
} }
[HttpGet] [HttpGet]
public IActionResult GetUpdateDetails(long id) public IActionResult GetUpdateDetails(string id)
{ {
var res = new ResponseDataCollectionDetailList(); var res = new ResponseDataCollectionDetailList();
var trace = _traceInspectionRepository.Get(t => t.projectid == ProjectId && t.status == (int)RowState.Valid && t.trace_id == id var trace = _traceInspectionRepository.Get(t => t.projectid == ProjectId && t.status == (int)RowState.Valid && t.trace_id == id
......
...@@ -20,8 +20,6 @@ using Siger.Middlelayer.Repository.Repositories.Interface; ...@@ -20,8 +20,6 @@ using Siger.Middlelayer.Repository.Repositories.Interface;
using Siger.Middlelayer.Repository.Response; using Siger.Middlelayer.Repository.Response;
using Siger.Middlelayer.Utility.Helpers; using Siger.Middlelayer.Utility.Helpers;
using Siger.Middlelayer.Utility.ImportEntities; using Siger.Middlelayer.Utility.ImportEntities;
using Siger.Middlelayer.Dapper.CheckTrace.Repostriories;
using Siger.Middlelayer.Dapper.CheckTrace.Data;
using Siger.ApiQMS.Utility; using Siger.ApiQMS.Utility;
using UploadFileModel = Siger.Middlelayer.QmsRepository.Response.UploadFileModel; using UploadFileModel = Siger.Middlelayer.QmsRepository.Response.UploadFileModel;
using Siger.Middlelayer.Repository.Entities; using Siger.Middlelayer.Repository.Entities;
...@@ -377,7 +375,7 @@ namespace Siger.ApiQMS.Controllers ...@@ -377,7 +375,7 @@ namespace Siger.ApiQMS.Controllers
} }
insertDetailList.Add(new SnTraceDetailList insertDetailList.Add(new SnTraceDetailList
{ {
TraceID = 0, TraceID = "",
ItemID = detail.itemid, ItemID = detail.itemid,
Result = detail.result, Result = detail.result,
Value = detail.value, Value = detail.value,
...@@ -417,7 +415,7 @@ namespace Siger.ApiQMS.Controllers ...@@ -417,7 +415,7 @@ namespace Siger.ApiQMS.Controllers
} }
insertDetailList.Add(new SnTraceDetailList insertDetailList.Add(new SnTraceDetailList
{ {
TraceID = 0, TraceID = "",
ItemID = detail.itemid, ItemID = detail.itemid,
Result = detailResult, Result = detailResult,
Value = detail.value, Value = detail.value,
...@@ -430,13 +428,7 @@ namespace Siger.ApiQMS.Controllers ...@@ -430,13 +428,7 @@ namespace Siger.ApiQMS.Controllers
} }
} }
} }
var _traceRepostory = new TraceDetailRepository(CompanyId, ProjectId); var traceId = Guid.NewGuid().ToString();
var resDetails = new List<SnTraceDetailList>();
var traceId = _traceRepostory.InsertTraceDetailReturnTraceIdNumberIndex(trace, insertDetailList, ProjectId, out resDetails);
if (traceId <= 0)
{
throw new BadRequestException(CommonEnum.Fail);
}
var nowTime = DateTime.Now; var nowTime = DateTime.Now;
var machineIds = _machineAttributionRepository.GetList(t => t.projectid == ProjectId && t.station == sendTest.sectionid && var machineIds = _machineAttributionRepository.GetList(t => t.projectid == ProjectId && t.station == sendTest.sectionid &&
t.status == (int)RowState.Valid && t.attribution == (int)MachineAttributionEnum.equipment).Select(t => t.machine).ToList(); t.status == (int)RowState.Valid && t.attribution == (int)MachineAttributionEnum.equipment).Select(t => t.machine).ToList();
...@@ -853,11 +845,6 @@ namespace Siger.ApiQMS.Controllers ...@@ -853,11 +845,6 @@ namespace Siger.ApiQMS.Controllers
} }
if (_unitOfWork.Commit() > 0) if (_unitOfWork.Commit() > 0)
{ {
if(data.trace_id > 0)
{
var _traceRepostory = new TraceDetailRepository(CompanyId, ProjectId);
_traceRepostory.DeleteData(data.trace_id);
}
return new ObjectResult(CommonEnum.Succefull); return new ObjectResult(CommonEnum.Succefull);
} }
else else
...@@ -921,24 +908,6 @@ namespace Siger.ApiQMS.Controllers ...@@ -921,24 +908,6 @@ namespace Siger.ApiQMS.Controllers
var delTraceDetails = _traceDetailRepository.GetList(t => t.projectid == ProjectId && t.status == (int)RowState.Valid && var delTraceDetails = _traceDetailRepository.GetList(t => t.projectid == ProjectId && t.status == (int)RowState.Valid &&
t.TraceID == sendTest.trace_id).ToList(); t.TraceID == sendTest.trace_id).ToList();
var _traceRepostory = new TraceDetailRepository(CompanyId, ProjectId);
var snTrace = _traceRepostory.GetSnTrace(sendTest.trace_id, ProjectId);
var trace = new SnTrace
{
MaterialID = sendTest.materialid,
ProductID = sendTest.productid,
SectionID = sendTest.sectionid,
MachineID = machine?.id ?? 0,
WorkOrder = "",
SN = sendTest.sn ?? "",
Result = (result == (int)SendTestType.Qalified || result == (int)SendTestType.DeviationRelease) ? "OK" : "NG",
UserID = snTrace == null ? sendTest.check_mid : snTrace.UserID,
RouteID = sendTest.routeid,
CreateTime = snTrace == null ? ((sendTest.check_time.HasValue && sendTest.check_time != DateTime.MinValue) ?
sendTest.check_time.Value : DateTime.Now) : snTrace.CreateTime,
CheckType = sendTest.check_type
};
var insertDetailList = new List<SnTraceDetailList>(); var insertDetailList = new List<SnTraceDetailList>();
foreach (var index in indexs) foreach (var index in indexs)
{ {
...@@ -958,7 +927,7 @@ namespace Siger.ApiQMS.Controllers ...@@ -958,7 +927,7 @@ namespace Siger.ApiQMS.Controllers
} }
insertDetailList.Add(new SnTraceDetailList insertDetailList.Add(new SnTraceDetailList
{ {
TraceID = 0, TraceID = "",
ItemID = detail.itemid, ItemID = detail.itemid,
Result = detail.result, Result = detail.result,
Value = detail.value, Value = detail.value,
...@@ -998,7 +967,7 @@ namespace Siger.ApiQMS.Controllers ...@@ -998,7 +967,7 @@ namespace Siger.ApiQMS.Controllers
} }
insertDetailList.Add(new SnTraceDetailList insertDetailList.Add(new SnTraceDetailList
{ {
TraceID = 0, TraceID = "",
ItemID = detail.itemid, ItemID = detail.itemid,
Result = detailResult, Result = detailResult,
Value = detail.value, Value = detail.value,
...@@ -1012,30 +981,7 @@ namespace Siger.ApiQMS.Controllers ...@@ -1012,30 +981,7 @@ namespace Siger.ApiQMS.Controllers
} }
} }
var traceId = Guid.NewGuid().ToString();
// 删除旧数据
if (sendTest.trace_id > 0)
{
_traceRepostory.DeleteDetail(sendTest.trace_id);
}
long traceId = 0;
var resDetails = new List<SnTraceDetailList>();
if(snTrace == null)//如果没有这条数据,则插入trace,trace_detail,如果有直插入trace_detail
{
traceId = _traceRepostory.InsertTraceDetailReturnTraceIdNumberIndex(trace, insertDetailList, ProjectId, out resDetails);
}
else
{
if (_traceRepostory.InsertTraceOnlyDetailsReturnNumerIndex(snTrace, insertDetailList, ProjectId, trace.Result, out resDetails))
{
traceId = snTrace.ID;
}
}
if (traceId <= 0)
{
throw new BadRequestException(CommonEnum.Fail);
}
sendTest.result = req.result ?? ""; sendTest.result = req.result ?? "";
sendTest.trace_id = traceId; sendTest.trace_id = traceId;
sendTest.number = req.number.ToInt(); sendTest.number = req.number.ToInt();
...@@ -1076,7 +1022,7 @@ namespace Siger.ApiQMS.Controllers ...@@ -1076,7 +1022,7 @@ namespace Siger.ApiQMS.Controllers
LowerLimit = detail.LowerLimit, LowerLimit = detail.LowerLimit,
UpperLimit = detail.UpperLimit, UpperLimit = detail.UpperLimit,
projectid = ProjectId, projectid = ProjectId,
CreateTime = trace.CreateTime CreateTime = sendTest.checking_time.HasValue ? sendTest.checking_time.Value : DateTime.Now
}; };
_traceDetailRepository.Insert(model); _traceDetailRepository.Insert(model);
} }
...@@ -1086,11 +1032,6 @@ namespace Siger.ApiQMS.Controllers ...@@ -1086,11 +1032,6 @@ namespace Siger.ApiQMS.Controllers
throw new BadRequestException(CommonEnum.Fail); throw new BadRequestException(CommonEnum.Fail);
} }
if (snTrace == null)//如果时新插入的数据,添加SN
{
AddSnList(sendTest, trace);
}
return new ObjectResult(CommonEnum.Succefull); return new ObjectResult(CommonEnum.Succefull);
} }
......
using Microsoft.AspNetCore.Mvc;
using Siger.Middlelayer.Common;
using Siger.Middlelayer.Repository;
using System.Linq;
using Siger.Middlelayer.QmsRepository.Repositories.Interface;
using Siger.Middlelayer.QmsRepository.Request;
using Siger.Middlelayer.Common.Extensions;
using Siger.ApiCommon.Filters;
using Siger.Middlelayer.QmsRepository.Response;
using Siger.Middlelayer.QmsRepository.Entities;
using System;
using Siger.Middlelayer.Repository.Repositories.Interface;
using System.Collections.Generic;
using Siger.Middlelayer.Repository.Response;
using Siger.Middlelayer.Dapper.CheckTrace.Repostriories;
using Siger.Middlelayer.Common.ModuleEnum;
using Siger.Middlelayer.Dapper.CheckTrace.Data;
namespace Siger.ApiQMS.Controllers
{
public class SensorDataCollectionController : BaseController
{
private readonly IUnitOfWork _unitOfWork;
private readonly IInspectStandardRepository _inspectStandard;
private readonly IPortSettingRepository _portSettingRepository;
private readonly ISigerProjectLevelRepository _levelRepository;
private readonly ISigerProjectLevelSectionRepository _levelSectionRepository;
private readonly ISigerProjectProductRepository _productRepository;
private readonly ICheckSnListRepository _snListRepository;
private readonly ISigerTrMaterialsRepository _materialsRepository;
public SensorDataCollectionController(IUnitOfWork unitOfWork, IInspectStandardRepository inspectStandard,
IPortSettingRepository portSettingRepository, ISigerProjectLevelRepository levelRepository,
ISigerProjectLevelSectionRepository levelSectionRepository, ISigerProjectProductRepository productRepository,
ICheckSnListRepository snListRepository, ISigerTrMaterialsRepository materialsRepository)
{
_unitOfWork = unitOfWork;
_inspectStandard = inspectStandard;
_portSettingRepository = portSettingRepository;
_levelRepository = levelRepository;
_levelSectionRepository = levelSectionRepository;
_productRepository = productRepository;
_snListRepository = snListRepository;
_materialsRepository = materialsRepository;
}
[HttpGet]
[NoTokenValidateFilter]
public IActionResult GetPageList(int page, int pagesize, int projectid)
{
var data = _portSettingRepository.GetDataList(projectid);
//return new PagedObjectResult(data.Data, data.Total, page, pagesize);
return new ObjectResult(data);
}
[HttpGet]
[NoTokenValidateFilter]
public IActionResult GetItemList(int projectid)
{
var items = _inspectStandard.GetList(t => t.projectid == projectid && t.status == (int)RowState.Valid)
.Select(q => new ResponseIdNameItem { id = q.id, name = q.item, en_name = q.item_en }).ToList();
return new ObjectResult(items);
}
[HttpPost]
[NoTokenValidateFilter]
public IActionResult Add([FromBody]RequestAddPortSetting req)
{
var entity = _portSettingRepository.Get(t => t.projectid == req.projectid && t.status == (int)RowState.Valid &&
t.itemid == req.itemid);
if(entity != null)
{
throw new BadRequestException(RequestEnum.InspectItemRepeat);
}
var model = new siger_qms_port_setting
{
port = req.port,
paritycheck = req.paritycheck,
baudrate = req.baudrate,
databit = req.databit,
stopbit = req.stopbit,
itemid = req.itemid,
projectid = req.projectid,
status = (int)RowState.Valid,
createtime = DateTime.Now
};
_portSettingRepository.Insert(model);
if (_unitOfWork.Commit() > 0)
{
return new ObjectResult(CommonEnum.Succefull);
}
else
{
throw new BadRequestException(CommonEnum.Fail);
}
}
[HttpPost]
[NoTokenValidateFilter]
public IActionResult Update([FromBody]RequestUpdatePortSetting req)
{
var data = _portSettingRepository.Get(t => t.id == req.id && t.projectid == req.projectid && t.status == (int)RowState.Valid);
if(data == null)
{
throw new BadRequestException(CommonEnum.RecordNotFound);
}
data.port = req.port;
data.paritycheck = req.paritycheck;
data.baudrate = req.baudrate;
data.databit = req.databit;
data.stopbit = req.stopbit;
data.itemid = req.itemid;
_portSettingRepository.Update(data);
if (_unitOfWork.Commit() > 0)
{
return new ObjectResult(CommonEnum.Succefull);
}
else
{
throw new BadRequestException(CommonEnum.Fail);
}
}
[HttpGet]
[NoTokenValidateFilter]
public IActionResult Delete(int id, int projectid)
{
var data = _portSettingRepository.Get(t => t.id == id && t.projectid == projectid && t.status == (int)RowState.Valid);
if (data == null)
{
throw new BadRequestException(CommonEnum.RecordNotFound);
}
data.status = (int)RowState.Invalid;
_portSettingRepository.Update(data);
if (_unitOfWork.Commit() > 0)
{
return new ObjectResult(CommonEnum.Succefull);
}
else
{
throw new BadRequestException(CommonEnum.Fail);
}
}
[HttpGet]
[NoTokenValidateFilter]
public IActionResult GetSectionSelect(int reverselevel, int parentid, int projectid)
{
var levels = _levelRepository.GetList(t => t.status == (int)RowState.Valid && t.projectid == projectid).OrderByDescending(t => t.id).ToList();
if (levels.Count < reverselevel)
{
throw new BadRequestException(RequestEnum.LevelNotFound);
}
var res = _levelSectionRepository.GetSectionIdNamesByLevel(levels[reverselevel - 1].id, parentid, projectid).ToList();
return new ObjectResult(res);
}
[HttpGet]
[NoTokenValidateFilter]
public IActionResult GetProducts(int projectid)
{
var res = _productRepository.GetList(t => t.projectid == projectid && t.status == (int)RowState.Valid)
.Select(t =>new
{
t.id,
t.name,
t.code
}).ToList();
return new ObjectResult(res);
}
[HttpGet]
[NoTokenValidateFilter]
public IActionResult GetMaterials(int productid, int projectid)
{
var res = _snListRepository.GetSonMaterialsByProductId(projectid, productid).ToList();
return new ObjectResult(res);
}
[HttpGet]
[NoTokenValidateFilter]
public IActionResult GetSectionRoutes(int productid, int sectionid, int projectid)
{
var res = new List<ResponseIdName>();
var product = _productRepository.Get(t => t.id == productid && t.status == (int)RowState.Valid && t.projectid == projectid);
if (product != null)
{
res = _inspectStandard.GetSectionRouteList(product.code, sectionid, projectid).ToList();
}
return new ObjectResult(res);
}
[HttpGet]
[NoTokenValidateFilter]
public IActionResult GetDetailList(int productid, int sectionid, int projectid)
{
var res = new List<ResponseSensorDataCollectionDetail>();
var standards = _inspectStandard.GetList(t =>
t.productid == productid && t.sectionid == sectionid && t.projectid == projectid
&& t.status == (int)RowState.Valid).ToList();
var senSorPorts = _portSettingRepository.GetList(t => t.projectid == projectid && t.status == (int)RowState.Valid).ToList();
foreach (var standard in standards)
{
var port = senSorPorts.FirstOrDefault(t => t.itemid == standard.id);
var model = new ResponseSensorDataCollectionDetail
{
id = standard.id,
itemid = standard.id,
max_value = standard.max_value,
min_value = standard.min_value,
result = "",
value = null,
item = standard.item,
standard = standard.standard,
checktype = standard.value_type,
portName = port?.port,
parity = port?.paritycheck ?? 0,
bautRate = port?.baudrate ?? 0,
dataBits = port?.databit ?? 0,
stopBits = port?.stopbit ?? 0
};
res.Add(model);
}
return new ObjectResult(res);
}
[HttpPost]
[NoTokenValidateFilter]
public IActionResult AddTrace([FromBody]RequestAddSensorDataCollection req)
{
if (req.details == null || !req.details.Any() || string.IsNullOrEmpty(req.result))
{
throw new BadRequestException(RequestEnum.CheckItemNotFound);
}
var product = _productRepository.Get(t => t.projectid == req.projectid && t.status == (int)RowState.Valid &&
t.id == req.productid);
if (product == null)
{
throw new BadRequestException(RequestEnum.ProductNotFound);
}
var maxLevel = _levelRepository.GetList(t => t.status == (int)RowState.Valid && t.projectid == req.projectid).Max(q => q.id);
var section = _levelSectionRepository.Get(t => t.status == (int)RowState.Valid && t.projectid == req.projectid && t.id == req.sectionid);
if (section == null || section.levelid != maxLevel)
{
throw new ServerException(1052);
}
var machine = _inspectStandard.GetMachineBySectionId(section.id, req.projectid);
if (machine == null)
{
throw new BadRequestException(RequestEnum.SectionMachineNull);
}
if (string.IsNullOrEmpty(req.result))
{
throw new BadRequestException(RequestEnum.SelectCheckResult);
}
var items = _inspectStandard.GetList(t => req.details.Select(q => q.itemid).Contains(t.id)).ToList();
foreach (var detail in req.details)
{
var item = items.FirstOrDefault(t => t.id == detail.itemid);
if (item == null)
{
throw new BadRequestException(RequestEnum.ParameterMiss);
}
if (string.IsNullOrEmpty(detail.result) && detail.checktype == (int)ValueTypeStatus.O)
{
throw new BadRequestException(RequestEnum.ParameterMiss);
}
if (detail.value == null && detail.checktype == (int)ValueTypeStatus.V)
{
throw new BadRequestException(RequestEnum.ParameterMiss);
}
}
var trace = new SnTrace
{
MaterialID = req.materialid.ToInt(),
ProductID = req.productid,
SectionID = req.sectionid,
MachineID = machine.id,
WorkOrder = req.workorder ?? "",
SN = req.sn ?? "",
Result = req.result,
UserID = UserId,
RouteID = req.routeid.ToInt(),
CreateTime = DateTime.Now,
CheckType = req.checktype
};
var insertDetailList = new List<SnTraceDetailList>();
foreach (var detail in req.details)
{
var item = items.FirstOrDefault(t => t.id == detail.itemid);
var result = "";
if (item.value_type == (int)ValueTypeStatus.V)
{
result = (detail.value.Value <= item.max_value && detail.value.Value >= item.min_value) ? "OK" : "NG";
}
else
{
result = detail.result;
}
insertDetailList.Add(new SnTraceDetailList
{
TraceID = 0,
ItemID = detail.itemid,
Result = result,
Value = detail.value,
ItemName = item.item
});
}
var _traceRepostory = new TraceDetailRepository(req.companyid, req.projectid);
var res = _traceRepostory.InsertTraceDetail(trace, insertDetailList, req.projectid);
if (res)
{
var snEntity = _snListRepository.Get(t => t.projectid == req.projectid && t.status == (int)RowState.Valid &&
t.SN == trace.SN);
if (snEntity == null)
{
var stateCode = "000";
var eventNoObj = _snListRepository.GetEventNoByResult(trace.SN, req.projectid);
if (eventNoObj != null)
{
//出站信息获取
var outObj = _snListRepository.GetOutStationByEventNo(eventNoObj.EventNo, trace.SectionID, req.projectid);
if (outObj != null)
{
stateCode = outObj.ResultStatus;
}
}
var material = _materialsRepository.Get(t => t.projectId == req.projectid && t.status == (int)RowState.Valid &&
t.id == req.materialid.ToInt());
var snListObj = new siger_check_sn_list
{
SN = trace.SN,
BatchNumber = "",
ProductID = trace.ProductID,
ProductCode = product.code,
LineID = section.parentid,
WorkOrder = trace.WorkOrder,
MaterialID = material?.id ?? 0,
PartNumber = material?.pn ?? "",
StateCode = stateCode,
CreateTime = DateTime.Now,
projectid = req.projectid
};
_snListRepository.Insert(snListObj);
_unitOfWork.Commit();
}
return new ObjectResult(CommonEnum.Succefull);
}
throw new BadRequestException(CommonEnum.Fail);
}
[HttpGet]
[NoTokenValidateFilter]
public IActionResult GetProductsBySectionId(string sectionid)
{
var productIds = _inspectStandard.GetList(t => t.sectionid == sectionid.ToInt() && t.projectid == ProjectId &&
t.status == (int)RowState.Valid).Select(t => t.productid).ToList();
var products = _productRepository.GetList(t => productIds.Contains(t.id) && t.projectid == ProjectId &&
t.status == (int)RowState.Valid).Select(t => new
{
t.id,
t.name,
t.code
}).ToList();
return new ObjectResult(products);
}
[HttpGet]
[NoTokenValidateFilter]
public IActionResult GetItems(int sectionid, int productid, int projectid)
{
var items = _inspectStandard.GetList(t => t.projectid == projectid && t.status == (int)RowState.Valid &&
t.sectionid == sectionid && t.productid == productid)
.Select(q => new ResponseIdNameItem { id = q.id, name = q.item, en_name = q.item_en }).ToList();
return new ObjectResult(items);
}
[HttpGet]
[NoTokenValidateFilter]
public IActionResult GetItemSectionSelect(int reverselevel, int parentid, int projectid)
{
var levels = _levelRepository.GetList(t => t.status == (int)RowState.Valid && t.projectid == projectid).OrderByDescending(t => t.id).ToList();
if (levels.Count < reverselevel)
{
throw new BadRequestException(RequestEnum.LevelNotFound);
}
var res = _levelSectionRepository.GetSectionIdNamesByLevel(levels[reverselevel - 1].id, parentid, projectid).ToList();
if(reverselevel == 2)
{
var itemSectionIds = _inspectStandard.GetList(t => t.projectid == projectid && t.status == (int)RowState.Valid)
.Select(t => t.sectionid).ToList();
var channelIds = _levelSectionRepository.GetList(t => itemSectionIds.Contains(t.id)).Select(t => t.parentid).ToList();
res = res.Where(t => channelIds.Contains(t.id)).ToList();
}
if(reverselevel == 1)
{
var itemSectionIds = _inspectStandard.GetList(t => t.projectid == projectid && t.status == (int)RowState.Valid &&
res.Select(q => q.id).Contains(t.sectionid)).Select(t => t.sectionid).ToList();
res = res.Where(t => itemSectionIds.Contains(t.id)).ToList();
}
return new ObjectResult(res);
}
}
}
\ No newline at end of file
...@@ -12,7 +12,6 @@ using Siger.Middlelayer.QmsRepository.Request; ...@@ -12,7 +12,6 @@ using Siger.Middlelayer.QmsRepository.Request;
using Siger.Middlelayer.QmsRepository.Response; using Siger.Middlelayer.QmsRepository.Response;
using Siger.Middlelayer.Repository.Repositories.Interface; using Siger.Middlelayer.Repository.Repositories.Interface;
using Siger.Middlelayer.Repository.Entities; using Siger.Middlelayer.Repository.Entities;
using Siger.Middlelayer.Dapper.CheckTrace.Repostriories;
using Siger.Middlelayer.Repository.Response; using Siger.Middlelayer.Repository.Response;
using Siger.Middlelayer.QmsRepository.Entities; using Siger.Middlelayer.QmsRepository.Entities;
using Siger.Middlelayer.Utility.Helpers; using Siger.Middlelayer.Utility.Helpers;
...@@ -80,7 +79,6 @@ namespace Siger.ApiQMS.Controllers ...@@ -80,7 +79,6 @@ namespace Siger.ApiQMS.Controllers
} }
var maxLevel = _levelRepository.GetList(t => t.projectid == ProjectId && t.status == (int)RowState.Valid) var maxLevel = _levelRepository.GetList(t => t.projectid == ProjectId && t.status == (int)RowState.Valid)
.OrderByDescending(t => t.id).FirstOrDefault(); .OrderByDescending(t => t.id).FirstOrDefault();
var _traceRepostory = new TraceDetailRepository(CompanyId, ProjectId);
if (req.x_id.ToInt() == 0) if (req.x_id.ToInt() == 0)
{ {
var sectionIds = new List<int>(); var sectionIds = new List<int>();
...@@ -95,9 +93,8 @@ namespace Siger.ApiQMS.Controllers ...@@ -95,9 +93,8 @@ namespace Siger.ApiQMS.Controllers
sectionIds = ChannelSectionHelper.GetSonLevelSectionList(req.sectionid.ToInt(), levelSections).Select(m => m.id).ToList(); sectionIds = ChannelSectionHelper.GetSonLevelSectionList(req.sectionid.ToInt(), levelSections).Select(m => m.id).ToList();
} }
var datas = _traceRepostory.GetSnTracePageList(sectionIds, req.productid.ToInt() var datas = _traceDetailRepository.GetSnTraceList(sectionIds, req.productid.ToInt()
, req.materialid.ToInt(), 0, req.checktype.ToInt(), , req.materialid.ToInt(), req.checktype.ToInt(), req.starttime, req.endtime, ProjectId).ToList();
"", "", new List<long>(), req.starttime, req.endtime, 1, 10, ProjectId, "1", 0).ToList();
foreach (var sec in sections) foreach (var sec in sections)
{ {
var lastSections = ChannelSectionHelper.GetSonLevelSections(sec, levelSections) var lastSections = ChannelSectionHelper.GetSonLevelSections(sec, levelSections)
...@@ -120,8 +117,8 @@ namespace Siger.ApiQMS.Controllers ...@@ -120,8 +117,8 @@ namespace Siger.ApiQMS.Controllers
var lastSections = section == null ? levelSections.Where(t=>t.levelid == maxLevel.id).ToList() : var lastSections = section == null ? levelSections.Where(t=>t.levelid == maxLevel.id).ToList() :
ChannelSectionHelper.GetSonLevelSections(section, levelSections).Where(t => t.levelid == maxLevel.id).ToList(); ChannelSectionHelper.GetSonLevelSections(section, levelSections).Where(t => t.levelid == maxLevel.id).ToList();
var lastSectionIds = lastSections.Select(t => t.id).ToList(); var lastSectionIds = lastSections.Select(t => t.id).ToList();
var data = _traceRepostory.GetSnTracePageList(lastSectionIds, product?.id ?? 0, req.materialid.ToInt(), 0, req.checktype.ToInt(), var data = _traceDetailRepository.GetSnTraceList(lastSectionIds, product?.id ?? 0, req.materialid.ToInt(), req.checktype.ToInt(),
"", "", new List<long>(), req.starttime, req.endtime, 1, 10, ProjectId, "1", 0).Where(t => t.RouteID > 0).ToList(); req.starttime, req.endtime, ProjectId).Where(t => t.RouteID > 0).ToList();
var routeIds = data.Select(t => t.RouteID).ToList(); var routeIds = data.Select(t => t.RouteID).ToList();
var routes = _routeRepository.GetList(t => t.projectId == ProjectId && t.status == (int)RowState.Valid && var routes = _routeRepository.GetList(t => t.projectId == ProjectId && t.status == (int)RowState.Valid &&
routeIds.Contains(t.id)).ToList(); routeIds.Contains(t.id)).ToList();
...@@ -284,7 +281,7 @@ namespace Siger.ApiQMS.Controllers ...@@ -284,7 +281,7 @@ namespace Siger.ApiQMS.Controllers
} }
var etime = req.endtime.ToDateTime(); var etime = req.endtime.ToDateTime();
var stime = req.starttime.ToDateTime(); var stime = req.starttime.ToDateTime();
var traceIds = new List<long>(); var traceIds = new List<string>();
if (req.itemid.ToInt() > 0) if (req.itemid.ToInt() > 0)
{ {
var item = _inspectStandardRepository.Get(t => t.id == req.itemid.ToInt() && t.projectid == ProjectId && var item = _inspectStandardRepository.Get(t => t.id == req.itemid.ToInt() && t.projectid == ProjectId &&
......
...@@ -11,7 +11,7 @@ namespace Siger.ApiQMS.Result ...@@ -11,7 +11,7 @@ namespace Siger.ApiQMS.Result
public double LCL { get; set; } public double LCL { get; set; }
public long traceID { get; set; } public string traceID { get; set; }
public List<long> traceDetailID { get; set; } = new List<long>(); public List<long> traceDetailID { get; set; } = new List<long>();
...@@ -27,7 +27,7 @@ namespace Siger.ApiQMS.Result ...@@ -27,7 +27,7 @@ namespace Siger.ApiQMS.Result
public double UCL { get; set; } public double UCL { get; set; }
public double LCL { get; set; } public double LCL { get; set; }
public long traceID { get; set; } public string traceID { get; set; }
public string value { get; set; } public string value { get; set; }
public int rule1 { get; set; } public int rule1 { get; set; }
public int rule2 { get; set; } public int rule2 { get; set; }
......
using FluentScheduler;
using Siger.Middlelayer.Common;
using Siger.Middlelayer.Common.Extensions;
using Siger.Middlelayer.Common.Helpers;
using Siger.Middlelayer.Dapper.CheckTrace.Constant;
using Siger.Middlelayer.Dapper.CheckTrace.Data;
using Siger.Middlelayer.Dapper.CheckTrace.Repostriories;
using Siger.Middlelayer.Log;
using Siger.Middlelayer.QmsRepository;
using Siger.Middlelayer.Redis;
using Siger.Middlelayer.Repository;
using System;
using System.Linq;
namespace Siger.ApiQMS.Tasks
{
public class QmsCreateTraceTablJob : IJob
{
private static ApiQmsDbContext _context;
private static ApiConfigDbContext _configContext;
static QmsCreateTraceTablJob()
{
_context = new ApiQmsDbContext();
_configContext = new ApiConfigDbContext();
}
public void Execute()
{
if (DateTime.Now.Day != 1)
{
return;
}
_context = new ApiQmsDbContext();
_configContext = new ApiConfigDbContext();
try
{
var dbConfigs = RedisCache.Instance.GetDbNameConfigs();
foreach (var item in dbConfigs)
{
try
{
if(item.Cid > 0 && item.Pid > 0)
{
CreateTraceTable(item.Pid, item.Cid);
}
}
catch (Exception e)
{
Logger.WriteLineError(e.Message);
}
}
_context.Dispose();
_configContext.Dispose();
}
catch (Exception ex)
{
_context.Dispose();
_configContext.Dispose();
Logger.WriteLineError(ex.Message);
}
}
private void CreateTraceTable(int pid, int cid)
{
var projectInfo = _configContext.siger_project.FirstOrDefault(q => q.id == pid);
if(projectInfo == null)
{
return;
}
var _traceRepostory = new TraceDetailTableRepository(cid, pid);
var traceIsExsit = _traceRepostory.TableIsExsit(TabelNameConstant.SnTraceTable, $"{cid}_{pid}");
if (!traceIsExsit)
{
_traceRepostory.CreateTable(TabelNameConstant.SnTraceTable, TabelNameConstant.SnTraceTable, 1);
}
var subTableIsExsit = _traceRepostory.TableIsExsit(TabelNameConstant.SubTableTable, $"{cid}_{pid}");
if (!subTableIsExsit)
{
_traceRepostory.CreateTable(TabelNameConstant.SubTableTable, TabelNameConstant.SubTableTable, 1);
}
var now = DateTime.Now.ToString(ParameterConstant.MouthFirstDay).ToDateTime();
var startTime = "2020-03-01 00:00:00".ToDateTime();
var projectStartTime = UnixTimeHelper.ConvertIntDate(projectInfo.createtime).ToDateTime().ToString(ParameterConstant.MouthFirstDay).ToDateTime();
startTime = startTime > projectStartTime ? startTime : projectStartTime;
for(var time = startTime; time <= now; time = time.AddMonths(1))
{
var detailTableName = $"{TabelNameConstant.SnTraceDetailTable}_{time.Year}{time.Month.ToString("00")}";
var detailIsExsit = _traceRepostory.TableIsExsit(detailTableName, $"{cid}_{pid}");
if (detailIsExsit)
{
var detailTable = _traceRepostory.GetSubTableInfo(detailTableName, TabelNameConstant.SnTraceDetailTable);
if (detailTable == null)
{
var minid = _traceRepostory.GetTableMinID(detailTableName);
var maxid = _traceRepostory.GetTableMaxID(detailTableName);
_traceRepostory.InsertSubTable(new SubTable
{
name = detailTableName,
tablename = TabelNameConstant.SnTraceDetailTable,
startid = minid,
endid = maxid,
validtime = time.AddMonths(-1),
createtime = DateTime.Now,
status = (int)RowState.Valid
});
}
continue;
}
var startid = 1L;
if (time > startTime)
{
var lastDetailTableName = $"{TabelNameConstant.SnTraceDetailTable}_{time.AddMonths(-1).Year}{time.AddMonths(-1).Month.ToString("00")}";
var lastDetailTable = _traceRepostory.GetSubTableInfo(lastDetailTableName, TabelNameConstant.SnTraceDetailTable);
if (lastDetailTable == null)
{
var minid = _traceRepostory.GetTableMinID(lastDetailTableName);
var maxid = _traceRepostory.GetTableMaxID(lastDetailTableName);
_traceRepostory.InsertSubTable(new SubTable
{
name = lastDetailTableName,
tablename = TabelNameConstant.SnTraceDetailTable,
startid = minid,
endid = maxid,
validtime = time.AddMonths(-1),
createtime = DateTime.Now,
status = (int)RowState.Valid
});
}
else
{
var maxId = _traceRepostory.GetTableMaxID(lastDetailTableName);
startid = maxId + 1;
_traceRepostory.UpdateSubTableEndId(lastDetailTable.id, maxId);
}
}
_traceRepostory.CreateTable(TabelNameConstant.SnTraceDetailTable, detailTableName, startid);
_traceRepostory.InsertSubTable(new SubTable
{
name = detailTableName,
tablename = TabelNameConstant.SnTraceDetailTable,
startid = startid,
endid = 0,
validtime = time,
createtime = DateTime.Now,
status = (int)RowState.Valid
});
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using FluentScheduler;
using Siger.Middlelayer.Common;
using Siger.Middlelayer.Common.Extensions;
using Siger.Middlelayer.Common.ModuleEnum;
using Siger.Middlelayer.Dapper.CheckTrace.Repostriories;
using Siger.Middlelayer.Log;
using Siger.Middlelayer.QmsRepository;
using Siger.Middlelayer.QmsRepository.Entities;
using Siger.Middlelayer.Redis;
namespace Siger.ApiQMS.Tasks
{
public class QmsDataMigrationJob : IJob
{
private static ApiQmsDbContext _context;
static QmsDataMigrationJob()
{
_context = new ApiQmsDbContext();
}
public void Execute()
{
_context = new ApiQmsDbContext();
try
{
var state = _context.siger_system_config.FirstOrDefault(t => t.status == (int)RowState.Valid &&
t.key == SystemConfigKey.QmsDataMigrationStatus);
if ((state != null && state.value.ToInt() != (int)RowState.Valid) || state == null)
{
_context.Dispose();
return;
}
var dbConfigs = RedisCache.Instance.GetDbNameConfigs();
foreach (var item in dbConfigs)
{
try
{
SyncBigDataToMiddleDataBase(item.Pid, item.Cid);
SyncMiddleDataToBigDataBase();
}
catch(Exception e)
{
Logger.WriteLineError(e.Message);
}
}
_context.Dispose();
}
catch (Exception ex)
{
_context.Dispose();
Logger.WriteLineError(ex.Message);
}
}
/// <summary>
/// 迁移大数据的数据到中间层(老数据迁移
/// </summary>
public void SyncBigDataToMiddleDataBase(int projectid, int companyid)
{
var _traceRepository = new TraceDataRepository(companyid, projectid);
var datas = _traceRepository.GetSnTraceList(projectid);
var traces = _context.siger_check_sn_trace_inspection.Where(t => t.projectid == projectid && t.status == (int)RowState.Valid &&
datas.Select(q => q.ID).Contains(t.trace_id)).ToList();
datas = datas.Where(t => !traces.Select(q => q.trace_id).Contains(t.ID)).ToList();
var insertModels = new List<siger_check_sn_trace_inspection>();
var insertDetailModels = new List<siger_check_sn_trace_detail>();
foreach(var data in datas)
{
var model = new siger_check_sn_trace_inspection
{
trace_id = data.ID,
testroom = "",
productid = data.ProductID,
materialid = data.MaterialID,
sectionid = data.SectionID,
sn = data.SN,
routeid = data.RouteID,
check_type = data.CheckType,
check_status = (int)SendCheckStatus.Completed,
result = data.Result.ToUpper() == "OK" ? ((int)SendTestType.Qalified).ToString() : ((int)SendTestType.Unqualified).ToString(),
send_mid = data.UserID,
send_time = data.CreateTime,
check_mid = data.UserID,
check_time = data.CreateTime,
inspection_type = (int)InspectionType.ManualCollection,
projectid = projectid,
reason = "",
workorder = data.WorkOrder,
recieve_mid = data.UserID,
recieve_time = data.CreateTime,
checking_mid = data.UserID,
checking_time = data.CreateTime
};
var dataDetails = _context.siger_check_sn_trace_detail.Where(t => t.projectid == projectid && t.status == (int)RowState.Valid &&
data.ID == t.TraceID).ToList();
if (dataDetails.Any())
{
continue;
}
var details = _traceRepository.GetSingleTraceDetailList(data.ID, projectid);
var numberIndexs = _context.siger_check_partindex.Where(t => t.projectid == projectid && t.status == (int)RowState.Valid &&
details.Select(q => q.ID).Contains(t.trace_detailid)).ToList();
var number = 0;
foreach (var detail in details)
{
var numberIndex = numberIndexs.FirstOrDefault(t => t.trace_detailid == detail.ID);
var detailModel = new siger_check_sn_trace_detail
{
TraceID = detail.TraceID,
ItemID = detail.ItemID,
Result = detail.Result,
Value = detail.Value,
ItemName = detail.ItemName,
SN = string.IsNullOrEmpty(detail.SN) ? model.sn : detail.SN,
NumberIndex = numberIndex?.partindex ?? 1,
projectid = projectid,
CreateTime = data.CreateTime
};
insertDetailModels.Add(detailModel);
if(detailModel.NumberIndex > number)
{
number = detailModel.NumberIndex;
}
}
model.number = number;
insertModels.Add(model);
}
foreach(var trace in traces)
{
var dataDetails = _context.siger_check_sn_trace_detail.Where(t => t.projectid == projectid && t.status == (int)RowState.Valid &&
trace.trace_id == t.TraceID).ToList();
if (dataDetails.Any())
{
continue;
}
var details = _traceRepository.GetSingleTraceDetailList(trace.trace_id, projectid);
var numberIndexs = _context.siger_check_partindex.Where(t => t.projectid == projectid && t.status == (int)RowState.Valid &&
details.Select(q => q.ID).Contains(t.trace_detailid)).ToList();
foreach (var detail in details)
{
var numberIndex = numberIndexs.FirstOrDefault(t => t.trace_detailid == detail.ID);
var detailModel = new siger_check_sn_trace_detail
{
TraceID = detail.TraceID,
ItemID = detail.ItemID,
Result = detail.Result,
Value = detail.Value,
ItemName = detail.ItemName,
SN = string.IsNullOrEmpty(detail.SN) ? trace.sn : detail.SN,
NumberIndex = numberIndex?.partindex ?? 1,
projectid = projectid,
CreateTime = (trace.check_time.HasValue && trace.check_time != DateTime.MinValue) ? trace.check_time.Value : DateTime.Now
};
insertDetailModels.Add(detailModel);
}
}
_context.siger_check_sn_trace_inspection.AddRange(insertModels);
_context.siger_check_sn_trace_detail.AddRange(insertDetailModels);
_context.SaveChanges();
}
public void SyncMiddleDataToBigDataBase()
{
return;
}
}
}
...@@ -4,7 +4,6 @@ using Siger.ApiQMS.Result; ...@@ -4,7 +4,6 @@ using Siger.ApiQMS.Result;
using Siger.Middlelayer.Common; using Siger.Middlelayer.Common;
using Siger.Middlelayer.Common.Helpers; using Siger.Middlelayer.Common.Helpers;
using Siger.Middlelayer.Common.ModuleEnum; using Siger.Middlelayer.Common.ModuleEnum;
using Siger.Middlelayer.Dapper.CheckTrace.Repostriories;
using Siger.Middlelayer.Log; using Siger.Middlelayer.Log;
using Siger.Middlelayer.QmsRepository.Entities; using Siger.Middlelayer.QmsRepository.Entities;
using Siger.Middlelayer.QmsRepository.Repositories.Interface; using Siger.Middlelayer.QmsRepository.Repositories.Interface;
...@@ -56,7 +55,7 @@ namespace Siger.ApiQMS.Utility ...@@ -56,7 +55,7 @@ namespace Siger.ApiQMS.Utility
/// <param name="machineid"></param> /// <param name="machineid"></param>
/// <param name="triggerAndon"></param> /// <param name="triggerAndon"></param>
/// <param name="typeCode"></param> /// <param name="typeCode"></param>
public void AbnomalRuleCheck(int num, long traceid, int sectionid, int machineid, bool triggerAndon, int typeCode) public void AbnomalRuleCheck(int num, string traceid, int sectionid, int machineid, bool triggerAndon, int typeCode)
{ {
if (num <= 0) if (num <= 0)
{ {
...@@ -170,7 +169,7 @@ namespace Siger.ApiQMS.Utility ...@@ -170,7 +169,7 @@ namespace Siger.ApiQMS.Utility
} }
} }
private void UpdateTraceWorkOrder(long traceid, string workOrder) private void UpdateTraceWorkOrder(string traceid, string workOrder)
{ {
if (string.IsNullOrEmpty(workOrder)) if (string.IsNullOrEmpty(workOrder))
{ {
...@@ -188,9 +187,6 @@ namespace Siger.ApiQMS.Utility ...@@ -188,9 +187,6 @@ namespace Siger.ApiQMS.Utility
{ {
return; return;
} }
var _itemTraceRepository = new TraceDataRepository(_companyId, _projectId);
_itemTraceRepository.UpdateSnTraceWorkOrder(traceid, workOrder, _projectId);
} }
/// <summary> /// <summary>
......
...@@ -13,7 +13,7 @@ namespace Siger.ApiQMS.Utility ...@@ -13,7 +13,7 @@ namespace Siger.ApiQMS.Utility
{ {
public class SpcAnalysisUtility :IDisposable public class SpcAnalysisUtility :IDisposable
{ {
public ResponseQMSDynamicDiag CheckDataRule(int itemID, double UCL, double LCL, long traceID, List<double> valueList, public ResponseQMSDynamicDiag CheckDataRule(int itemID, double UCL, double LCL, string traceID, List<double> valueList,
List<int> rules) List<int> rules)
{ {
var request = new RequestQMSDynamicDiag var request = new RequestQMSDynamicDiag
......
...@@ -924,6 +924,7 @@ namespace Siger.ApiWMS.Controllers ...@@ -924,6 +924,7 @@ namespace Siger.ApiWMS.Controllers
throw new BadRequestException(RequestEnum.LocationTypeNotFound); throw new BadRequestException(RequestEnum.LocationTypeNotFound);
} }
var sonLocationTypes = GetSonTypes(0, locationTypes).ToList(); var sonLocationTypes = GetSonTypes(0, locationTypes).ToList();
var locationTypeId = sonLocationTypes.LastOrDefault()?.id ?? 0;
var waveHouse = storage.Get(q => q.projectid == ProjectId && q.status == (int)RowState.Valid && q.id == req.warehouseid); var waveHouse = storage.Get(q => q.projectid == ProjectId && q.status == (int)RowState.Valid && q.id == req.warehouseid);
if (waveHouse == null) if (waveHouse == null)
{ {
...@@ -934,14 +935,27 @@ namespace Siger.ApiWMS.Controllers ...@@ -934,14 +935,27 @@ namespace Siger.ApiWMS.Controllers
{ {
throw new BadRequestException(RequestEnum.LocationCountError); throw new BadRequestException(RequestEnum.LocationCountError);
} }
foreach (var Location in req.storeArr) foreach (var Location in req.storeArr)
{ {
var loca = location.Get(q => q.realname == Location.val && q.projectid == ProjectId); if (Location.id == locationTypeId)
if (loca != null) {
var locationIdExist = location.Get(q => q.projectid == ProjectId && q.status == (int)RowState.Valid && q.typeid == locationTypeId &&
q.locationid == req.storeID.ToInt());
if (locationIdExist != null)
{ {
throw new BadRequestException(RequestEnum.DataExist); throw new BadRequestException(RequestEnum.IDExist);
}
} }
//判断名称重复
//if (req.storeArr.Count(q => q.val == Location.val) > 1)
//{
// throw new BadRequestException(RequestEnum.DataExist);
//}
//var loca = location.Get(q => q.realname == Location.val && q.projectid == ProjectId);
//if (loca != null)
//{
// throw new BadRequestException(RequestEnum.DataExist);
//}
} }
var ids = new List<int>(); var ids = new List<int>();
...@@ -967,7 +981,7 @@ namespace Siger.ApiWMS.Controllers ...@@ -967,7 +981,7 @@ namespace Siger.ApiWMS.Controllers
update_time = DateTime.Now, update_time = DateTime.Now,
projectid = ProjectId, projectid = ProjectId,
status = req.status == (int)RowState.Valid ? (int)RowState.Valid : (int)RowState.Invalid, status = req.status == (int)RowState.Valid ? (int)RowState.Valid : (int)RowState.Invalid,
locationid = req.storeID.ToInt() locationid = Location.id == locationTypeId ? req.storeID.ToInt() : 0
}; };
parentid = InsertLocation(tmp, waveHouse.name); parentid = InsertLocation(tmp, waveHouse.name);
if (parentid > 0) if (parentid > 0)
...@@ -1043,6 +1057,7 @@ namespace Siger.ApiWMS.Controllers ...@@ -1043,6 +1057,7 @@ namespace Siger.ApiWMS.Controllers
throw new BadRequestException(RequestEnum.LocationTypeNotFound); throw new BadRequestException(RequestEnum.LocationTypeNotFound);
} }
var sonLocationTypes = GetSonTypes(0, locationTypes).ToList(); var sonLocationTypes = GetSonTypes(0, locationTypes).ToList();
var locationTypeId = sonLocationTypes.LastOrDefault()?.id ?? 0;
var waveHouse = storage.Get(q => q.projectid == ProjectId && q.status == (int)RowState.Valid && q.id == req.warehouseid); var waveHouse = storage.Get(q => q.projectid == ProjectId && q.status == (int)RowState.Valid && q.id == req.warehouseid);
if (waveHouse == null) if (waveHouse == null)
{ {
...@@ -1056,11 +1071,25 @@ namespace Siger.ApiWMS.Controllers ...@@ -1056,11 +1071,25 @@ namespace Siger.ApiWMS.Controllers
foreach (var Location in req.storeArr) foreach (var Location in req.storeArr)
{ {
var loca = location.Get(q => q.realname == Location.val && q.projectid == ProjectId && q.id != Location.locationid.ToInt()); if(Location.id == locationTypeId)
if (loca != null)
{ {
throw new BadRequestException(RequestEnum.DataExist); var locationIdExist = location.Get(q => q.projectid == ProjectId && q.status == (int)RowState.Valid && q.typeid == locationTypeId &&
q.locationid == req.storeID.ToInt() && q.id != Location.locationid.ToInt());
if (locationIdExist != null)
{
throw new BadRequestException(RequestEnum.IDExist);
}
} }
//判断名称重复
//if (req.storeArr.Count(q => q.val == Location.val) > 1)
//{
// throw new BadRequestException(RequestEnum.DataExist);
//}
//var loca = location.Get(q => q.realname == Location.val && q.projectid == ProjectId && q.id != Location.locationid.ToInt());
//if (loca != null)
//{
// throw new BadRequestException(RequestEnum.DataExist);
//}
} }
var ids = new List<int>(); var ids = new List<int>();
...@@ -1078,6 +1107,7 @@ namespace Siger.ApiWMS.Controllers ...@@ -1078,6 +1107,7 @@ namespace Siger.ApiWMS.Controllers
tmp.realname = Location.val; tmp.realname = Location.val;
if (tmp.parentid == 0) if (tmp.parentid == 0)
{ {
tmp.locationid = Location.id == locationTypeId ? req.storeID.ToInt() : 0;
tmp.name = $"{waveHouse.name} -> {tmp.realname}"; tmp.name = $"{waveHouse.name} -> {tmp.realname}";
} }
location.Update(tmp); location.Update(tmp);
......
...@@ -316,9 +316,15 @@ namespace Siger.Middlelayer.Common.ModuleEnum ...@@ -316,9 +316,15 @@ namespace Siger.Middlelayer.Common.ModuleEnum
[Description("序号已全部生成")] [Description("序号已全部生成")]
SerinumFull, SerinumFull,
[Description("该任务状态已经完成")] [Description("该任务状态已经完成")]
AutoTaskDone AutoTaskDone,
[Description("产线模式未找到")]
LineModeNotfound,
[Description("设备状态不可用")]
MachineDisable,
[Description("设备正在使用中")]
MachineBusy,
[Description("任务进行中")]
TaskProcessing
} }
public enum SeriNumCfg public enum SeriNumCfg
......
...@@ -22,6 +22,24 @@ namespace Siger.Middlelayer.Share.Enum.ModuleEnum ...@@ -22,6 +22,24 @@ namespace Siger.Middlelayer.Share.Enum.ModuleEnum
Auto=2 Auto=2
} }
/// <summary> /// <summary>
/// 执行任务 任务发方式 0,未执行 1 手动执行 2 自动执行
/// </summary>
public enum ExcueType
{
/// <summary>
/// 未执行
/// </summary>
None=0,
/// <summary>
/// 手动执行
/// </summary>
Manual = 1,
/// <summary>
/// 自动执行
/// </summary>
Auto = 2
}
/// <summary>
/// Task任务状态结果 /// Task任务状态结果
/// </summary> /// </summary>
public enum TaskResultStatus public enum TaskResultStatus
......
...@@ -1470,5 +1470,8 @@ namespace Siger.Middlelayer.Common ...@@ -1470,5 +1470,8 @@ namespace Siger.Middlelayer.Common
[Description("未找到工装信息")] [Description("未找到工装信息")]
FixtureToolNotFound, FixtureToolNotFound,
[Description("ID重复")]
IDExist,
} }
} }
...@@ -163,5 +163,7 @@ namespace Siger.Middlelayer.AccRepository ...@@ -163,5 +163,7 @@ namespace Siger.Middlelayer.AccRepository
public DbSet<siger_automation_line_mode> siger_automation_line_mode { get; set; } public DbSet<siger_automation_line_mode> siger_automation_line_mode { get; set; }
public DbSet<siger_automation_machine_status> siger_automation_machine_status { get; set; } public DbSet<siger_automation_machine_status> siger_automation_machine_status { get; set; }
public DbSet<siger_automation_produce_history> siger_automation_produce_history { get; set; }
} }
} }
...@@ -32,5 +32,8 @@ namespace Siger.Middlelayer.AccRepository.Entities ...@@ -32,5 +32,8 @@ namespace Siger.Middlelayer.AccRepository.Entities
public DateTime? updatetime { get; set; } public DateTime? updatetime { get; set; }
public string extend1 { get; set; } public string extend1 { get; set; }
public string attachment { get; set; }
public string filename { get; set; }
} }
} }
...@@ -5,7 +5,7 @@ using System.Text; ...@@ -5,7 +5,7 @@ using System.Text;
namespace Siger.Middlelayer.AccRepository.Entities namespace Siger.Middlelayer.AccRepository.Entities
{ {
/// <summary> /// <summary>
/// 储位信息 /// 储位工装信息
/// </summary> /// </summary>
public class siger_automation_location : AccEntityBase public class siger_automation_location : AccEntityBase
{ {
...@@ -19,18 +19,6 @@ namespace Siger.Middlelayer.AccRepository.Entities ...@@ -19,18 +19,6 @@ namespace Siger.Middlelayer.AccRepository.Entities
/// </summary> /// </summary>
public string fixturetools { get; set; } public string fixturetools { get; set; }
/// <summary> /// <summary>
/// 物料ID
/// </summary>
public int materialid { get; set; }
/// <summary>
/// 工序ID
/// </summary>
public int processid { get; set; }
/// <summary>
/// 物料状态
/// </summary>
public int materialstate { get; set; }
/// <summary>
/// 附件 /// 附件
/// </summary> /// </summary>
public string attachment { get; set; } public string attachment { get; set; }
......
using System;
using System.Collections.Generic;
using System.Text;
namespace Siger.Middlelayer.AccRepository.Entities
{
/// <summary>
/// 工装台账信息
/// </summary>
public class siger_automation_produce_history : AccEntityBase
{
/// <summary>
/// 设备状态ID
/// </summary>
public int statusid { get; set; }
/// <summary>
/// 产线ID
/// </summary>
public int section { get; set; }
/// <summary>
/// 产品ID
/// </summary>
public int productid { get; set; }
/// <summary>
/// 产品编号
/// </summary>
public string productcode { get; set; }
/// <summary>
/// 产品名称
/// </summary>
public string productname { get; set; }
/// <summary>
/// 储位ID
/// </summary>
public int locationid { get; set; }
/// <summary>
/// 储位名称
/// </summary>
public string locationname { get; set; }
/// <summary>
/// 工件编号
/// </summary>
public string sn { get; set; }
/// <summary>
/// 工序
/// </summary>
public string route { get; set; }
/// <summary>
/// 操作时间
/// </summary>
public DateTime? updatetime { get; set; }
}
}
...@@ -16,11 +16,11 @@ namespace Siger.Middlelayer.AccRepository.Entities ...@@ -16,11 +16,11 @@ namespace Siger.Middlelayer.AccRepository.Entities
/// </summary> /// </summary>
public int sectionid { get; set; } public int sectionid { get; set; }
/// <summary> /// <summary>
/// 触发方式 /// 触发方式 产生TASK
/// </summary> /// </summary>
public TaskTrigerType trigger { get; set; } public TaskTrigerType trigger { get; set; }
/// <summary> /// <summary>
/// 任务类型 /// 任务类型 load ,unload
/// </summary> /// </summary>
public TaskActionType tasktype { get; set; } public TaskActionType tasktype { get; set; }
/// <summary> /// <summary>
...@@ -53,12 +53,12 @@ namespace Siger.Middlelayer.AccRepository.Entities ...@@ -53,12 +53,12 @@ namespace Siger.Middlelayer.AccRepository.Entities
public int fixturetools { get; set; } public int fixturetools { get; set; }
/// <summary> /// <summary>
/// 动作类型 1 手动 2 自动 /// Task 执行动作类型 1 手动 2 自动
/// </summary> /// </summary>
public TaskTrigerType actiontype { get; set; } public ExcueType actiontype { get; set; }
/// <summary> /// <summary>
/// 动作 /// Task 动作执行
/// </summary> /// </summary>
public TaskAction action { get; set; } public TaskAction action { get; set; }
......
...@@ -32,15 +32,20 @@ namespace Siger.Middlelayer.AccRepository.Repositories ...@@ -32,15 +32,20 @@ namespace Siger.Middlelayer.AccRepository.Repositories
select new ResponseAumationFixtureToolsProduct select new ResponseAumationFixtureToolsProduct
{ {
id = q.id, id = q.id,
categoryid=c.id, categoryid = c.id,
categoryname=c.name, categoryname = c.name,
fixturetoolid = t.id, fixturetoolid = t.id,
fixturetool = t.name, fixturetool = t.name,
productid = q.productid, productid = q.productid,
productname = p.name, productname = p.name,
remark = q.remark, remark = q.remark,
updator = q.updator, updator = u.name ?? "",
updatetime = q.updatetime.HasValue && q.updatetime > DateTime.MinValue ? q.updatetime.Value.ToString(ParameterConstant.DateTimeFormat) : "" updatetime = q.updatetime.HasValue && q.updatetime > DateTime.MinValue ? q.updatetime.Value.ToString(ParameterConstant.DateTimeFormat) : "",
fileurl = q.attachment,
filename = q.filename,
partnumber = t.partnumber,
specfication = t.specification,
productcode = p.code
}; };
Expression<Func<ResponseAumationFixtureToolsProduct, bool>> categoryExpression = f => true; Expression<Func<ResponseAumationFixtureToolsProduct, bool>> categoryExpression = f => true;
if (category > 0) if (category > 0)
......
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Linq.Expressions; using System.Linq.Expressions;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
...@@ -27,9 +28,6 @@ namespace Siger.Middlelayer.AccRepository.Repositories ...@@ -27,9 +28,6 @@ namespace Siger.Middlelayer.AccRepository.Repositories
join c in _context.siger_automation_fixture_tools_category on t.category equals c.guid join c in _context.siger_automation_fixture_tools_category on t.category equals c.guid
join l in _context.siger_wms_storage_location on q.locationid equals l.locationid join l in _context.siger_wms_storage_location on q.locationid equals l.locationid
join w in _context.siger_wms_storage on l.storageid equals w.id join w in _context.siger_wms_storage on l.storageid equals w.id
join m in _context.siger_tr_assist_materials on q.materialid equals m.id
join p in _context.siger_project_process on q.processid equals p.id into pp
from p in pp.DefaultIfEmpty()
join u in _context.siger_project_user on q.updator equals u.mid into uu join u in _context.siger_project_user on q.updator equals u.mid into uu
from u in uu.DefaultIfEmpty() from u in uu.DefaultIfEmpty()
where q.projectId == projectid && q.status == (int)RowState.Valid where q.projectId == projectid && q.status == (int)RowState.Valid
...@@ -45,12 +43,6 @@ namespace Siger.Middlelayer.AccRepository.Repositories ...@@ -45,12 +43,6 @@ namespace Siger.Middlelayer.AccRepository.Repositories
category = c.name, category = c.name,
code = t.code, code = t.code,
specfication = t.specification, specfication = t.specification,
materialid = q.materialid,
materialcode = m.pn,
processid = q.processid,
processnumber = p == null ? 0 : p.Process_Seq,
processname = p.Process_name ?? "",
materialstate = q.materialstate,
fileurl = q.attachment ?? "", fileurl = q.attachment ?? "",
filename = q.filename ?? "", filename = q.filename ?? "",
remark = q.remark, remark = q.remark,
...@@ -78,5 +70,31 @@ namespace Siger.Middlelayer.AccRepository.Repositories ...@@ -78,5 +70,31 @@ namespace Siger.Middlelayer.AccRepository.Repositories
{ {
return _context.siger_wms_storage_location.FirstOrDefault(q => q.locationid == id && q.projectId == projectid && q.status == (int)RowState.Valid); return _context.siger_wms_storage_location.FirstOrDefault(q => q.locationid == id && q.projectId == projectid && q.status == (int)RowState.Valid);
} }
public IEnumerable<ResponseAutomationLocationList> GetDataList(int projectid)
{
var query = from q in _context.siger_automation_location
join t in _context.siger_automation_fixture_tools on q.fixturetools equals t.guid
join c in _context.siger_automation_fixture_tools_category on t.category equals c.guid
join l in _context.siger_wms_storage_location on q.locationid equals l.locationid
join w in _context.siger_wms_storage on l.storageid equals w.id
where q.projectId == projectid && q.status == (int)RowState.Valid
select new ResponseAutomationLocationList
{
id = q.id,
locationid = l.locationid,
location = l.realname,
locationcode = l.serial_number,
wavehouseid = w.id,
wavehouse = w.name,
wavehousecode = w.serial_number,
fixturetoolid = t.id,
code = t.code,
name = t.name,
materialsn = "TestData"
};
var entities = query.OrderByDescending(q => q.id).AsNoTracking().ToList();
return entities;
}
} }
} }
using System;
using System.Linq;
using System.Linq.Expressions;
using Microsoft.EntityFrameworkCore;
using Siger.Middlelayer.AccRepository.Entities;
using Siger.Middlelayer.AccRepository.Repositories.Interface;
using Siger.Middlelayer.AccRepository.Response;
using Siger.Middlelayer.Common;
using Siger.Middlelayer.Repository.Data.Acc;
using Siger.Middlelayer.Repository.Extensions;
using Siger.Middlelayer.Repository.Paged;
namespace Siger.Middlelayer.AccRepository.Repositories
{
internal class AutomationProduceHistoryRepository : AccRepositoryBase<siger_automation_produce_history>, IAutomationProduceHistoryRepository
{
private ApiAccDbContext _context;
public AutomationProduceHistoryRepository(ApiAccDbContext context) : base(context)
{
_context = context;
}
}
}
...@@ -4,8 +4,11 @@ using System.Linq.Expressions; ...@@ -4,8 +4,11 @@ using System.Linq.Expressions;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Siger.Middlelayer.AccRepository.Entities; using Siger.Middlelayer.AccRepository.Entities;
using Siger.Middlelayer.AccRepository.Repositories.Interface; using Siger.Middlelayer.AccRepository.Repositories.Interface;
using Siger.Middlelayer.Common.Helpers;
using Siger.Middlelayer.Repository.Data.Acc; using Siger.Middlelayer.Repository.Data.Acc;
using Siger.Middlelayer.Repository.Paged; using Siger.Middlelayer.Repository.Paged;
using Siger.Middlelayer.Share.Enum.ModuleEnum;
using static Siger.Middlelayer.Share.Enum.ModuleEnum.Automation;
namespace Siger.Middlelayer.AccRepository.Repositories namespace Siger.Middlelayer.AccRepository.Repositories
{ {
...@@ -16,5 +19,31 @@ namespace Siger.Middlelayer.AccRepository.Repositories ...@@ -16,5 +19,31 @@ namespace Siger.Middlelayer.AccRepository.Repositories
{ {
_context = context; _context = context;
} }
public bool CanTask(int projectId,int section)
{
var taskObj = _context.siger_automation_task_list.FirstOrDefault(f => f.projectId == projectId && f.status >= (int)TaskResultStatus.Cancel && f.status < (int)TaskResultStatus.Complated);
if (taskObj==null)
return true;
else
return false;
}
public string CrateTaskNumber(TaskTrigerType trigerType)
{
var date = DateTime.Now;
var lable = date.ToString(UnixTimeHelper.DateTimeFormatYmd)+date.Hour + date.Minute + date.Second + date.Millisecond;
var radon = new Random().Next(1000, 9999);
if (trigerType== TaskTrigerType.Auto)
{
return $"A{radon}T{lable}";
}else
{
return $"M{radon}T{lable}";
}
}
} }
} }
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
using Siger.Middlelayer.AccRepository.Response; using Siger.Middlelayer.AccRepository.Response;
using Siger.Middlelayer.Repository.Data.Acc; using Siger.Middlelayer.Repository.Data.Acc;
using Siger.Middlelayer.Repository.Paged; using Siger.Middlelayer.Repository.Paged;
using System.Collections.Generic;
namespace Siger.Middlelayer.AccRepository.Repositories.Interface namespace Siger.Middlelayer.AccRepository.Repositories.Interface
{ {
...@@ -11,5 +12,7 @@ namespace Siger.Middlelayer.AccRepository.Repositories.Interface ...@@ -11,5 +12,7 @@ namespace Siger.Middlelayer.AccRepository.Repositories.Interface
siger_wms_storage_location GetLocation(int id, int projectid); siger_wms_storage_location GetLocation(int id, int projectid);
IEnumerable<ResponseAutomationLocationList> GetDataList(int projectid);
} }
} }
using System; using Siger.Middlelayer.AccRepository.Entities;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
namespace Siger.Middlelayer.Dapper.CheckTrace.Constant namespace Siger.Middlelayer.AccRepository.Repositories.Interface
{ {
public class TabelNameConstant public interface IAutomationProduceHistoryRepository : IAccRepositoryBase<siger_automation_produce_history>
{ {
public const string SnTraceTable = "siger_check_sn_trace";
public const string SnTraceDetailTable = "siger_check_sn_trace_detail";
public const string SubTableTable = "siger_project_subtable";
public const string TraceInspection = "siger_check_sn_trace_inspection";
} }
} }
using Siger.Middlelayer.AccRepository.Entities; using Siger.Middlelayer.AccRepository.Entities;
using Siger.Middlelayer.Repository.Data.Acc; using Siger.Middlelayer.Repository.Data.Acc;
using Siger.Middlelayer.Repository.Paged; using Siger.Middlelayer.Repository.Paged;
using static Siger.Middlelayer.Share.Enum.ModuleEnum.Automation;
namespace Siger.Middlelayer.AccRepository.Repositories.Interface namespace Siger.Middlelayer.AccRepository.Repositories.Interface
{ {
public interface IAutomationTaskListRepository : IAccRepositoryBase<siger_automation_task_list> public interface IAutomationTaskListRepository : IAccRepositoryBase<siger_automation_task_list>
{ {
string CrateTaskNumber(TaskTrigerType trigerType);
/// <summary>
/// 是否能创建任务
/// </summary>
/// <param name="projectId"></param>
/// <param name="section"></param>
/// <returns></returns>
bool CanTask(int projectId,int section);
} }
} }
...@@ -87,6 +87,8 @@ namespace Siger.Middlelayer.AccRepository.Request ...@@ -87,6 +87,8 @@ namespace Siger.Middlelayer.AccRepository.Request
/// 备注 /// 备注
/// </summary> /// </summary>
public string remark { get; set; } public string remark { get; set; }
public string fileurl { get; set; }
public string filename { get; set; }
} }
public class RequestUpdateFixtureToolsProduct : RequestAddFixtureToolsProduct public class RequestUpdateFixtureToolsProduct : RequestAddFixtureToolsProduct
...@@ -107,14 +109,6 @@ namespace Siger.Middlelayer.AccRepository.Request ...@@ -107,14 +109,6 @@ namespace Siger.Middlelayer.AccRepository.Request
/// </summary> /// </summary>
public string fixturetoolid { get; set; } public string fixturetoolid { get; set; }
/// <summary> /// <summary>
/// 物料ID
/// </summary>
public string materialid { get; set; }
/// <summary>
/// 工序ID
/// </summary>
public string processid { get; set; }
/// <summary>
/// 附件 /// 附件
/// </summary> /// </summary>
public string fileurl { get; set; } public string fileurl { get; set; }
......
...@@ -93,19 +93,24 @@ namespace Siger.Middlelayer.AccRepository.Response ...@@ -93,19 +93,24 @@ namespace Siger.Middlelayer.AccRepository.Response
/// </summary> /// </summary>
public int fixturetoolid { get; set; } public int fixturetoolid { get; set; }
public string fixturetool { get; set; } public string fixturetool { get; set; }
public string partnumber { get; set; }
public string specfication { get; set; }
/// <summary> /// <summary>
/// 产品ID /// 产品ID
/// </summary> /// </summary>
public int productid { get; set; } public int productid { get; set; }
public string productname { get; set; } public string productname { get; set; }
public string productcode { get; set; }
/// <summary> /// <summary>
/// 备注 /// 备注
/// </summary> /// </summary>
public string remark { get; set; } public string remark { get; set; }
public int updator { get; set; } public string updator { get; set; }
public string updatetime { get; set; } public string updatetime { get; set; }
public string fileurl { get; set; }
public string filename { get; set; }
} }
public class ResponseAumationFixtureToolsAssembly public class ResponseAumationFixtureToolsAssembly
......
...@@ -18,6 +18,7 @@ namespace Siger.Middlelayer.AccRepository.Response ...@@ -18,6 +18,7 @@ namespace Siger.Middlelayer.AccRepository.Response
public string sn { get; set; } public string sn { get; set; }
public int status { get; set; } public int status { get; set; }
public int statusDesc { get; set; } public int statusDesc { get; set; }
public int location { get; set; }
/// <summary> /// <summary>
/// 储位位置 /// 储位位置
/// </summary> /// </summary>
......
...@@ -23,16 +23,11 @@ namespace Siger.Middlelayer.AccRepository.Response ...@@ -23,16 +23,11 @@ namespace Siger.Middlelayer.AccRepository.Response
public string code { get; set; } public string code { get; set; }
public string specfication { get; set; } public string specfication { get; set; }
/// <summary> /// <summary>
/// 物料ID /// 工件
/// </summary> /// </summary>
public int materialid { get; set; } public string sn { get; set; }
public string materialcode { get; set; } public string routenumber { get; set; }
/// <summary> public string route { get; set; }
/// 工序ID
/// </summary>
public int processid { get; set; }
public int processnumber { get; set; }
public string processname { get; set; }
/// <summary> /// <summary>
/// 物料状态 /// 物料状态
/// </summary> /// </summary>
...@@ -53,4 +48,31 @@ namespace Siger.Middlelayer.AccRepository.Response ...@@ -53,4 +48,31 @@ namespace Siger.Middlelayer.AccRepository.Response
public int status { get; set; } public int status { get; set; }
} }
public class ResponseAutomationLocationList
{
public int id { get; set; }
/// <summary>
/// 储位位置
/// </summary>
public int locationid { get; set; }
/// <summary>
/// 储位
/// </summary>
public string location { get; set; }
public string locationcode { get; set; }
public int wavehouseid { get; set; }
/// <summary>
/// 仓库
/// </summary>
public string wavehouse { get; set; }
public string wavehousecode { get; set; }
/// <summary>
/// 工装ID
/// </summary>
public int fixturetoolid { get; set; }
public string code { get; set; }
public string name { get; set; }
public string materialsn { get; set; }
}
} }
...@@ -18,7 +18,7 @@ namespace Siger.Middlelayer.QmsRepository.Entities ...@@ -18,7 +18,7 @@ namespace Siger.Middlelayer.QmsRepository.Entities
public int MachineID { get; set; } public int MachineID { get; set; }
public long TraceID { get; set; } public string TraceID { get; set; }
public string SN { get; set; } public string SN { get; set; }
......
...@@ -8,7 +8,7 @@ namespace Siger.Middlelayer.QmsRepository.Entities ...@@ -8,7 +8,7 @@ namespace Siger.Middlelayer.QmsRepository.Entities
/// </summary> /// </summary>
public class siger_check_sn_trace_inspection : QmsEntityBase public class siger_check_sn_trace_inspection : QmsEntityBase
{ {
public long trace_id { get; set; } public string trace_id { get; set; }
/// <summary> /// <summary>
/// 检测室字典key /// 检测室字典key
...@@ -38,7 +38,7 @@ namespace Siger.Middlelayer.QmsRepository.Entities ...@@ -38,7 +38,7 @@ namespace Siger.Middlelayer.QmsRepository.Entities
public int routeid { get; set; } public int routeid { get; set; }
/// <summary> /// <summary>
/// 检验类型 1->首检2->巡检3->末检4->标准件检 /// 检验类型
/// </summary> /// </summary>
public int check_type { get; set; } public int check_type { get; set; }
......
...@@ -23,7 +23,7 @@ namespace Siger.Middlelayer.QmsRepository.Repositories ...@@ -23,7 +23,7 @@ namespace Siger.Middlelayer.QmsRepository.Repositories
} }
public IPagedCollectionResult<ResponseDataCollection> GetPagedList(List<int> sectionid, int productid, int materialid, public IPagedCollectionResult<ResponseDataCollection> GetPagedList(List<int> sectionid, int productid, int materialid,
int route, int checktype, string sn, string result, List<long> traceIds, string starttime, string endtime, int userid, int itemid, int route, int checktype, string sn, string result, List<string> traceIds, string starttime, string endtime, int userid, int itemid,
int projectId, int page, int pagesize, string toexcel) int projectId, int page, int pagesize, string toexcel)
{ {
var minDate = "0001-01-01 00:00:00".ToDateTime(); var minDate = "0001-01-01 00:00:00".ToDateTime();
...@@ -146,7 +146,7 @@ namespace Siger.Middlelayer.QmsRepository.Repositories ...@@ -146,7 +146,7 @@ namespace Siger.Middlelayer.QmsRepository.Repositories
} }
} }
public List<double> GetHistoryDts(int limt, long traceId, int typeCode, int projectId, int itemId, DateTime minDate) public List<double> GetHistoryDts(int limt, string traceId, int typeCode, int projectId, int itemId, DateTime minDate)
{ {
var query = from d in _context.siger_check_sn_trace_detail var query = from d in _context.siger_check_sn_trace_detail
join t in _context.siger_check_sn_trace_inspection on d.TraceID equals t.trace_id join t in _context.siger_check_sn_trace_inspection on d.TraceID equals t.trace_id
...@@ -158,5 +158,56 @@ namespace Siger.Middlelayer.QmsRepository.Repositories ...@@ -158,5 +158,56 @@ namespace Siger.Middlelayer.QmsRepository.Repositories
return query.OrderByDescending(t => t.CreateTime).OrderByDescending(t => t.NumberIndex) return query.OrderByDescending(t => t.CreateTime).OrderByDescending(t => t.NumberIndex)
.OrderByDescending(t => t.ID).Take(limt).Select(t => t.Value.Value).ToList(); .OrderByDescending(t => t.ID).Take(limt).Select(t => t.Value.Value).ToList();
} }
public IEnumerable<SnTrace> GetSnTraceList(List<int> sectionIds, int productid, int materialid, int checktype, string starttime, string endtime, int projectid)
{
var query = from q in _context.siger_check_sn_trace_inspection
//join t in _context.siger_check_sn_trace_inspection on q.TraceID equals t.trace_id
where q.projectid == productid && q.status == (int)RowState.Valid //&& t.status == (int)RowState.Valid && q.projectid == productid
&& q.check_status == (int)SendCheckStatus.Completed
select new SnTrace
{
ID = q.trace_id,
ProductID = q.productid,
MaterialID = q.materialid,
SectionID = q.sectionid,
WorkOrder = q.workorder,
SN = q.sn,
Result = q.result == ((int)SendTestType.Unqualified).ToString() ? "NG" : "OK",
UserID = q.checking_mid,
CreateTime = q.check_time > DateTime.MinValue ? q.check_time.Value : DateTime.MinValue,
RouteID = q.routeid,
CheckType = q.check_type,
};
Expression<Func<SnTrace, bool>> materialExpression = q => true;
if (materialid > 0)
{
materialExpression = q => q.MaterialID == materialid;
}
Expression<Func<SnTrace, bool>> sectionExpression = q => true;
if (sectionIds.Any())
{
sectionExpression = q => sectionIds.Contains(q.SectionID);
}
Expression<Func<SnTrace, bool>> productExpression = q => true;
if (productid > 0)
{
productExpression = q => q.ProductID == productid;
}
Expression<Func<SnTrace, bool>> checkTypeExpression = q => true;
if (checktype > 0)
{
checkTypeExpression = q => q.CheckType == checktype;
}
Expression<Func<SnTrace, bool>> timeExpression = q => true;
if (!string.IsNullOrEmpty(starttime) && !string.IsNullOrEmpty(endtime))
{
timeExpression = q => q.CreateTime <= endtime.ToDateTime() && q.CreateTime >= starttime.ToDateTime();
}
var expression = materialExpression.And(sectionExpression).And(productExpression).And(checkTypeExpression).And(timeExpression);
return query.Where(expression);
}
} }
} }
...@@ -9,9 +9,11 @@ namespace Siger.Middlelayer.QmsRepository.Repositories.Interface ...@@ -9,9 +9,11 @@ namespace Siger.Middlelayer.QmsRepository.Repositories.Interface
public interface ICheckSnTraceDetailRepository : IQmsRepositoryBase<siger_check_sn_trace_detail> public interface ICheckSnTraceDetailRepository : IQmsRepositoryBase<siger_check_sn_trace_detail>
{ {
IPagedCollectionResult<ResponseDataCollection> GetPagedList(List<int> sectionid, int productid, int materialid, IPagedCollectionResult<ResponseDataCollection> GetPagedList(List<int> sectionid, int productid, int materialid,
int route, int checktype, string sn, string result, List<long> traceIds, string starttime, string endtime, int userid, int itemid, int route, int checktype, string sn, string result, List<string> traceIds, string starttime, string endtime, int userid, int itemid,
int projectId, int page, int pagesize, string toexcel); int projectId, int page, int pagesize, string toexcel);
List<double> GetHistoryDts(int limt, long traceId, int typeCode, int projectId, int itemId, DateTime minDate); List<double> GetHistoryDts(int limt, string traceId, int typeCode, int projectId, int itemId, DateTime minDate);
IEnumerable<SnTrace> GetSnTraceList(List<int> sectionIds, int productid, int materialid, int checktype, string starttime, string endtime, int projectid);
} }
} }
...@@ -38,7 +38,7 @@ namespace Siger.Middlelayer.QmsRepository.Request ...@@ -38,7 +38,7 @@ namespace Siger.Middlelayer.QmsRepository.Request
public class RequestUpdateDataCollection : RequestAddDataCollection public class RequestUpdateDataCollection : RequestAddDataCollection
{ {
public long id { get; set; } public string id { get; set; }
} }
public class DataCollectionDetail public class DataCollectionDetail
......
...@@ -5,7 +5,7 @@ namespace Siger.Middlelayer.QmsRepository.Response ...@@ -5,7 +5,7 @@ namespace Siger.Middlelayer.QmsRepository.Response
{ {
public class ResponseDataCollection public class ResponseDataCollection
{ {
public long id { get; set; } public string id { get; set; }
public int productid { get; set; } public int productid { get; set; }
...@@ -138,4 +138,61 @@ namespace Siger.Middlelayer.QmsRepository.Response ...@@ -138,4 +138,61 @@ namespace Siger.Middlelayer.QmsRepository.Response
public int stopBits { get; set; } public int stopBits { get; set; }
} }
public class SnTrace
{
public string ID { get; set; }
public int ProductID { get; set; }
public int MaterialID { get; set; }
public int SectionID { get; set; }
public int MachineID { get; set; }
public string WorkOrder { get; set; }
public string SN { get; set; }
public string Result { get; set; }
public int UserID { get; set; }
public int RouteID { get; set; }
public DateTime CreateTime { get; set; }
public int CheckType { get; set; }
public string ItemName { get; set; } = string.Empty;
}
public class SnTraceDetail
{
public long ID { get; set; }
public string TraceID { get; set; }
public int ItemID { get; set; }
public string ItemName { get; set; } = string.Empty;
public string Result { get; set; }
public double? Value { get; set; }
public string SN { get; set; }
}
public class SnTraceDetailList : SnTraceDetail
{
public int NumberIndex { get; set; }
public double? LowerLimit { get; set; }
public double? UpperLimit { get; set; }
}
} }
...@@ -6,7 +6,7 @@ namespace Siger.Middlelayer.QmsRepository.Response ...@@ -6,7 +6,7 @@ namespace Siger.Middlelayer.QmsRepository.Response
public class ResponseSendTestCollection public class ResponseSendTestCollection
{ {
public int id { get; set; } public int id { get; set; }
public long traceid { get; set; } public string traceid { get; set; }
public int productid { get; set; } public int productid { get; set; }
public string productcode { get; set; } public string productcode { get; set; }
public string productname { get; set; } public string productname { get; set; }
......
...@@ -248,6 +248,8 @@ CREATE TABLE IF NOT EXISTS `siger_automation_fixture_tools_product` ( ...@@ -248,6 +248,8 @@ CREATE TABLE IF NOT EXISTS `siger_automation_fixture_tools_product` (
`fixturetools` varchar(45) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'siger_automation_fixture_tools.guid', `fixturetools` varchar(45) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'siger_automation_fixture_tools.guid',
`productid` int(11) NOT NULL DEFAULT 0 COMMENT '产品ID', `productid` int(11) NOT NULL DEFAULT 0 COMMENT '产品ID',
`remark` varchar(45) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注', `remark` varchar(45) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
`attachment` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '附件',
`filename` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '附件名称',
`projectid` int(11) NOT NULL DEFAULT 0, `projectid` int(11) NOT NULL DEFAULT 0,
`status` int(11) NOT NULL DEFAULT 1, `status` int(11) NOT NULL DEFAULT 1,
`creator` int(11) NOT NULL DEFAULT 0, `creator` int(11) NOT NULL DEFAULT 0,
...@@ -379,4 +381,27 @@ CREATE TABLE `siger_automation_line_mode` ( ...@@ -379,4 +381,27 @@ CREATE TABLE `siger_automation_line_mode` (
PRIMARY KEY (`id`) USING BTREE PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- 生产线模式
-- Table structure for siger_automation_produce_history
-- ----------------------------
DROP TABLE IF EXISTS `siger_automation_produce_history`;;
CREATE TABLE `siger_automation_produce_history` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`statusid` int(11) NOT NULL DEFAULT 0 COMMENT '设备状态ID',
`section` int(11) NOT NULL DEFAULT 0 COMMENT '产线ID',
`projectid` int(11) NOT NULL DEFAULT 0,
`productid` int(1) NOT NULL DEFAULT 1 COMMENT '产品ID',
`productcode` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '产品编号',
`productname` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '产品名称',
`locationid` int(11) NOT NULL DEFAULT 0 COMMENT '储位ID',
`locationname` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '储位名称',
`sn` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '工件编号',
`route` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '工序',
`updatetime` datetime(0) NULL DEFAULT NULL COMMENT '操作时间',
`status` int(1) NOT NULL DEFAULT 1 COMMENT '',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
SET FOREIGN_KEY_CHECKS = 1; SET FOREIGN_KEY_CHECKS = 1;
using System;
using System.Collections.Generic;
using System.Text;
namespace Siger.Middlelayer.Dapper.CheckTrace.Data
{
public class SnTrace
{
public long ID { get; set; }
public int ProductID { get; set; }
public int MaterialID { get; set; }
public int SectionID { get; set; }
public int MachineID { get; set; }
public string WorkOrder { get; set; }
public string SN { get; set; }
public string Result { get; set; }
public int UserID { get; set; }
public int RouteID { get; set; }
public DateTime CreateTime { get; set; }
public int CheckType { get; set; }
public string ItemName { get; set; } = string.Empty;
}
public class SnTraceDetail
{
public long ID { get; set; }
public long TraceID { get; set; }
public int ItemID { get; set; }
public string ItemName { get; set; } = string.Empty;
public string Result { get; set; }
public double? Value { get; set; }
public string SN { get; set; }
}
public class SnTraceDetailList : SnTraceDetail
{
public int NumberIndex { get; set; }
public double? LowerLimit { get; set; }
public double? UpperLimit { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace Siger.Middlelayer.Dapper.CheckTrace.Data
{
public class SubTable
{
public int id { get; set; }
public string name { get; set; }
public string tablename { get; set; }
public long startid { get; set; }
public long endid { get; set; }
public DateTime validtime { get; set; }
public DateTime createtime { get; set; }
public int status { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Text;
using Dapper;
using Siger.Middlelayer.Dapper.CheckTrace.Data;
using Siger.Middlelayer.Dapper.CheckTrace.Constant;
using System.Linq;
using System.Threading.Tasks;
using Siger.Middlelayer.Common.Extensions;
using Siger.Middlelayer.Common.Log;
using Siger.Middlelayer.Common;
using Siger.Middlelayer.Common.ModuleEnum;
namespace Siger.Middlelayer.Dapper.CheckTrace.Repostriories
{
public class TraceDataRepository : TraceDbContext
{
public TraceDataRepository(int companyId, int projectId) : base(companyId, projectId)
{
}
public List<SubTable> GetSubTableList(string name)
{
using (var conn = GetDbConnection())
{
var sql = $"select * from {TabelNameConstant.SubTableTable} where tablename='{name}' and status=1";
var dataList = conn.Query<SubTable>(sql);
return dataList.ToList();
}
}
public IEnumerable<SnTrace> GetSnTraceList(int projectid)
{
var sql = $@"select ID,ProductID,MaterialID,SectionID,WorkOrder,SN,Result,UserID,CreateTime,RouteID,CheckType
from {TabelNameConstant.SnTraceTable}
where Status={(int)RowState.Valid} and ProjectID={projectid} and UserID>0
order by CreateTime";
var dataList = GetDataList<SnTrace>(sql);
return dataList;
}
public IEnumerable<SnTraceDetail> GetSingleTraceDetailList(long traceId, int projectid)
{
var snTraces = new List<SnTraceDetail>();
var subTables = GetSubTableList(TabelNameConstant.SnTraceDetailTable);
if (subTables.Count > 0)
{
Parallel.ForEach(subTables, new ParallelOptions { MaxDegreeOfParallelism = subTables.Count },
t => { snTraces.AddRange(GetSingleTraceDetails(t, traceId, projectid)); });
}
Task.WaitAll();
return snTraces.ToList();
}
private IEnumerable<SnTraceDetail> GetSingleTraceDetails(SubTable table, long traceId, int projectid)
{
var conditon = string.Empty;
if (traceId > 0)
{
conditon += $" and TraceID={traceId}";
}
var sql = $@"select ID,ItemID,TraceID,Result,Value,ItemName,SN
from {table.name}
where Status=1 and ProjectID={projectid} {conditon}";
var dataList = GetDataList<SnTraceDetail>(sql);
return dataList;
}
public SnTrace GetSnTrace(long id, int projectid)
{
using (var conn = GetDbConnection())
{
var sql = $"select * from {TabelNameConstant.SnTraceTable} where ID={id} and Status=1 and ProjectID={projectid}";
var data = conn.QuerySingleOrDefault<SnTrace>(sql);
return data;
}
}
public void UpdateSnTraceWorkOrder(long id, string workorder, int projectid)
{
using (var conn = GetDbConnection())
{
var sql = $"update {TabelNameConstant.SnTraceTable} set WorkOrder='{workorder}' where ID={id} and Status=1 and ProjectID={projectid}";
var data = conn.Execute(sql);
}
}
public override void Dispose()
{
throw new NotImplementedException();
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
using Dapper;
using Siger.Middlelayer.Dapper.CheckTrace.Data;
using Siger.Middlelayer.Dapper.CheckTrace.Constant;
using System.Linq;
using System.Threading.Tasks;
using Siger.Middlelayer.Common.Extensions;
using Siger.Middlelayer.Common.Log;
using Siger.Middlelayer.Common;
using Siger.Middlelayer.Common.ModuleEnum;
namespace Siger.Middlelayer.Dapper.CheckTrace.Repostriories
{
public class TraceDetailRepository : TraceDbContext
{
public TraceDetailRepository(int companyId, int projectId) : base(companyId, projectId)
{
}
public List<SubTable> GetSubTableList(string name)
{
using (var conn = GetDbConnection())
{
var sql = $"select * from {TabelNameConstant.SubTableTable} where tablename='{name}' and status=1";
var dataList = conn.Query<SubTable>(sql);
return dataList.ToList();
}
}
/// <summary>
/// 查询分页 和 导出获取数据
/// </summary>
/// <param name="sectionId"></param>
/// <param name="productId"></param>
/// <param name="materialId"></param>
/// <param name="routeId"></param>
/// <param name="checkType"></param>
/// <param name="sn"></param>
/// <param name="result"></param>
/// <param name="ids">siger_check_sn_trace.ID</param>
/// <param name="starttime"></param>
/// <param name="endtime"></param>
/// <param name="page"></param>
/// <param name="pagesize"></param>
/// <param name="projectid"></param>
/// <param name="toexcel"></param>
/// <param name="userId"></param>
/// <param name="userCheck">0->查询所有数据 1->查询有检验人的数据</param>
/// <param name="okContainsDeviation">查询OK的时候是否包含偏差放行 true->包含 false->不包含</param>
/// <param name="inspectionType">1->送检数据 2->人工检验数据</param>
/// <returns></returns>
public IEnumerable<SnTrace> GetSnTracePageList(List<int> sectionId, int productId, int materialId, int routeId, int checkType, string sn, string result, List<long> ids,
string starttime, string endtime, int page, int pagesize, int projectid, string toexcel, int userId, int userCheck = 0, bool okContainsDeviation = true, int inspectionType = 0)
{
var conditon = GetCondition(sectionId, productId, materialId, routeId, checkType, sn, result, ids,
starttime, endtime, userId, userCheck);
var pageLimit = "";
if(toexcel.ToInt() == 0)
{
pageLimit = $" limit { (page - 1) * pagesize},{ pagesize}";
}
if (!string.IsNullOrEmpty(result) && (result.ToUpper() == "OK" || result == ((int)SendTestType.DeviationRelease).ToString()) &&
okContainsDeviation == false)
{
var dbName = GetDbName();
var midDbName = GetMidDataBaseName();
var sql = $@"select t.ID,t.ProductID,t.MaterialID,t.SectionID,t.WorkOrder,t.SN,t.Result,t.UserID,t.CreateTime,t.RouteID,t.CheckType
from {dbName}.{TabelNameConstant.SnTraceTable} t left join {midDbName}.{TabelNameConstant.TraceInspection} s on t.ID=s.trace_id
where t.Status=1 and t.ProjectID={projectid} and (s.result='{((int)SendTestType.Qalified).ToString()}' or s.result is null) and
(s.status=1 or s.status is null) and (s.projectid={projectid} or s.projectid is null) {conditon}
order by t.CreateTime DESC {pageLimit}";
var dataList = GetDataList<SnTrace>(sql);
return dataList;
}
else if (inspectionType == (int)InspectionType.ManualCollection)
{
var dbName = GetDbName();
var midDbName = GetMidDataBaseName();
var sql = $@"select t.ID,t.ProductID,t.MaterialID,t.SectionID,t.WorkOrder,t.SN,t.Result,t.UserID,t.CreateTime,t.RouteID,t.CheckType
from {dbName}.{TabelNameConstant.SnTraceTable} t left join {midDbName}.{TabelNameConstant.TraceInspection} s on t.ID=s.trace_id
where t.Status=1 and t.ProjectID={projectid} and (s.inspection_type={(int)InspectionType.ManualCollection} or s.trace_id is NULL) and
(s.status=1 or s.status is null) and (s.projectid={projectid} or s.projectid is null) {conditon}
order by t.CreateTime DESC {pageLimit}";
var dataList = GetDataList<SnTrace>(sql);
return dataList;
}
else
{
var sql = $@"select t.ID,t.ProductID,t.MaterialID,t.SectionID,t.WorkOrder,t.SN,t.Result,t.UserID,t.CreateTime,t.RouteID,t.CheckType
from {TabelNameConstant.SnTraceTable} t
where t.Status=1 and t.ProjectID={projectid} {conditon}
order by t.CreateTime DESC {pageLimit}";
var dataList = GetDataList<SnTrace>(sql);
return dataList;
}
}
public long CountTrace(List<int> sectionId, int productId, int materialId, int routeId, int checkType, string sn, string result, List<long> ids,
string starttime, string endtime, int projectid, int userId, int userCheck = 0, bool okContainsDeviation = true, int inspectionType = 0)
{
using (var conn = GetDbConnection())
{
var conditon = GetCondition(sectionId, productId, materialId, routeId, checkType, sn, result, ids,
starttime, endtime, userId, userCheck);
if(!string.IsNullOrEmpty(result) && (result.ToUpper() == "OK" || result == ((int)SendTestType.DeviationRelease).ToString()) &&
okContainsDeviation == false)
{
var dbName = GetDbName();
var midDbName = GetMidDataBaseName();
var res = conn.ExecuteScalar<long>($@"select count(1) from {dbName}.{TabelNameConstant.SnTraceTable} t left join {midDbName}.{TabelNameConstant.TraceInspection} s on t.ID=s.trace_id
where t.Status=1 and t.ProjectID={projectid} and (s.result='{((int)SendTestType.Qalified).ToString()}' or s.result is null) and
(s.status=1 or s.status is null) and (s.projectid={projectid} or s.projectid is null) {conditon}");
return res;
}
else if(inspectionType == (int)InspectionType.ManualCollection)
{
var dbName = GetDbName();
var midDbName = GetMidDataBaseName();
var sql = $@"select count(1) from {dbName}.{TabelNameConstant.SnTraceTable} t left join {midDbName}.{TabelNameConstant.TraceInspection} s on t.ID=s.trace_id
where t.Status=1 and t.ProjectID={projectid} and (s.inspection_type={(int)InspectionType.ManualCollection} || s.trace_id is NULL) and
(s.status=1 or s.status is null) and (s.projectid={projectid} or s.projectid is null) {conditon}";
var res = conn.ExecuteScalar<long>(sql);
return res;
}
else
{
var res = conn.ExecuteScalar<long>($@"select count(1) from {TabelNameConstant.SnTraceTable} t
where t.Status=1 and t.ProjectID={projectid} {conditon}");
return res;
}
}
}
private string GetCondition(List<int> sectionId, int productId, int materialId, int routeId, int checkType, string sn, string result, List<long> ids,
string starttime, string endtime, int userId, int userCheck)
{
var conditon = string.Empty;
if (sectionId.Any())
{
conditon += $" and t.SectionID in ({string.Join(",", sectionId)})";
}
if (userCheck > 0)
{
conditon += $" and t.UserID>0";
}
if (productId > 0)
{
conditon += $" and t.ProductID={productId}";
}
if (materialId > 0)
{
conditon += $" and t.MaterialID={materialId}";
}
if (routeId > 0)
{
conditon += $" and t.RouteID={routeId}";
}
if (checkType > 0)
{
conditon += $" and t.CheckType={checkType}";
}
if (!string.IsNullOrEmpty(sn))
{
conditon += $" and t.SN={sn}";
}
if (!string.IsNullOrEmpty(result))
{
conditon += $" and t.Result='{result}'";
}
if (ids.Any())
{
conditon += $" and t.ID in ({string.Join(",", ids)})";
}
if (!string.IsNullOrEmpty(starttime) && !string.IsNullOrEmpty(endtime))
{
conditon += $" and t.CreateTime<='{endtime}' and t.CreateTime >= '{starttime}'";
}
if(userId > 0)
{
conditon += $" and t.UserID={userId}";
}
return conditon;
}
public SnTrace GetSnTrace(long id, int projectid)
{
using (var conn = GetDbConnection())
{
var sql = $"select * from {TabelNameConstant.SnTraceTable} where ID={id} and Status=1 and ProjectID={projectid}";
var data = conn.QuerySingleOrDefault<SnTrace>(sql);
return data;
}
}
/// <summary>
/// 通过TraceID获取详情数据
/// </summary>
/// <returns></returns>
public IEnumerable<SnTraceDetail> GetSingleTraceDetailList(long traceId, int projectid)
{
var snTraces = new List<SnTraceDetail>();
var subTables = GetSubTableList(TabelNameConstant.SnTraceDetailTable);
if (subTables.Count > 0)
{
Parallel.ForEach(subTables, new ParallelOptions { MaxDegreeOfParallelism = subTables.Count },
t => { snTraces.AddRange(GetSingleTraceDetails(t, traceId, projectid)); });
}
Task.WaitAll();
return snTraces.ToList();
}
private IEnumerable<SnTraceDetail> GetSingleTraceDetails(SubTable table, long traceId, int projectid)
{
var conditon = string.Empty;
if (traceId > 0)
{
conditon += $" and TraceID={traceId}";
}
var sql = $@"select ID,ItemID,TraceID,Result,Value,ItemName
from {table.name}
where Status=1 and ProjectID={projectid} {conditon}
order by CreateTime";
var dataList = GetDataList<SnTraceDetail>(sql);
return dataList;
}
public bool InsertTraceDetail(SnTrace trace, List<SnTraceDetailList> details, int projectid)
{
var tables = GetSubTableList(TabelNameConstant.SnTraceDetailTable);
if (!tables.Any())
{
return false;
}
using (var conn = GetDbConnection())
{
var now = DateTime.Now;
var tran = BeginTransaction(conn);
try
{
var time = DateTime.Now.ToString(ParameterConstant.DateTimeFormat);
var sql = $"insert into {TabelNameConstant.SnTraceTable} (SN,ProductID,MaterialID,SectionID,MachineID,WorkOrder,RouteID," +
$"UserID,Result,CreateTime,ProjectID,Status,CheckType) values('{trace.SN}',{trace.ProductID},{trace.MaterialID},{trace.SectionID},{trace.MachineID}," +
$"'{trace.WorkOrder}',{trace.RouteID},{trace.UserID},'{trace.Result}','{time}',{projectid},1,{trace.CheckType});";
sql += "SELECT @@identity;";//@ID=SCOPE_IDENTITY();
var traceId = conn.Query<long>(sql, tran).FirstOrDefault();
foreach (var detail in details)
{
var table = tables.FirstOrDefault(t => t.validtime.Year == now.Year && t.validtime.Month == now.Month);
if (table != null)
{
if (detail.Value.HasValue)
{
var dSQL = $"insert into {table.name}" +
$"(TraceID,MachineID,SN,ItemID,ItemName,Value,Result,CreateTime,ProjectID,Status) values" +
$"({traceId},{trace.MachineID},'{trace.SN}',{detail.ItemID},'{detail.ItemName}',{detail.Value.Value}," +
$"'{detail.Result}','{time}',{projectid},1)";
conn.Execute(dSQL, tran);
}
else
{
var dSQL = $"insert into {table.name}" +
$"(TraceID,MachineID,SN,ItemID,ItemName,Result,CreateTime,ProjectID,Status) values" +
$"({traceId},{trace.MachineID},'{trace.SN}',{detail.ItemID},'{detail.ItemName}'," +
$"'{detail.Result}','{time}',{projectid},1)";
conn.Execute(dSQL, tran);
}
}
}
Commit(tran, conn);
return true;
}
catch(Exception ex)
{
Logger.WriteLineError(ex.ToString());
Rollback(tran, conn);
return false;
}
}
}
/// <summary>
/// 删除所有数据
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public bool DeleteData(long id)
{
var tables = GetSubTableList(TabelNameConstant.SnTraceDetailTable);
using (var conn = GetDbConnection())
{
var tran = BeginTransaction(conn);
try
{
var sql = $"update {TabelNameConstant.SnTraceTable} set Status={(int)RowState.Invalid} where ID={id}";
conn.Execute(sql);
foreach(var table in tables)
{
var sql2 = $"update {table.name} set Status={(int)RowState.Invalid} where TraceID={id}";
conn.Execute(sql2);
}
Commit(tran, conn);
return true;
}
catch
{
Rollback(tran, conn);
return false;
}
}
}
/// <summary>
/// 只删除详情表数据
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public bool DeleteDetail(long id)
{
var tables = GetSubTableList(TabelNameConstant.SnTraceDetailTable);
using (var conn = GetDbConnection())
{
var tran = BeginTransaction(conn);
try
{
foreach (var table in tables)
{
var sql = $"update {table.name} set Status={(int)RowState.Invalid} where TraceID={id}";
conn.Execute(sql);
}
Commit(tran, conn);
return true;
}
catch
{
Rollback(tran, conn);
return false;
}
}
}
/// <summary>
/// 插入检验数据,并返回有插入ID和顺序序号的检验详情数据
/// </summary>
/// <returns></returns>
public long InsertTraceDetailReturnTraceIdNumberIndex(SnTrace trace, List<SnTraceDetailList> details, int projectid,
out List<SnTraceDetailList> resDetails)
{
resDetails = new List<SnTraceDetailList>();
var tables = GetSubTableList(TabelNameConstant.SnTraceDetailTable);
if (!tables.Any())
{
return 0;
}
using (var conn = GetDbConnection())
{
var now = DateTime.Now;
var tran = BeginTransaction(conn);
try
{
var time = trace.CreateTime.ToString(ParameterConstant.DateTimeFormat);
var sql = $"insert into {TabelNameConstant.SnTraceTable} (SN,ProductID,MaterialID,SectionID,MachineID,WorkOrder,RouteID," +
$"UserID,Result,CreateTime,ProjectID,Status,CheckType) values('{trace.SN}',{trace.ProductID},{trace.MaterialID},{trace.SectionID},{trace.MachineID}," +
$"'{trace.WorkOrder}',{trace.RouteID},{trace.UserID},'{trace.Result}','{time}',{projectid},1,{trace.CheckType});";
sql += "SELECT @@identity;";//@ID=SCOPE_IDENTITY();
var traceId = conn.Query<long>(sql, tran).FirstOrDefault();
foreach (var detail in details)
{
var table = tables.FirstOrDefault(t => t.validtime.Year == now.Year && t.validtime.Month == now.Month);
if (table != null)
{
if (detail.Value.HasValue)
{
var dSQL = $"insert into {table.name}" +
$"(TraceID,MachineID,SN,ItemID,ItemName,Value,Result,CreateTime,ProjectID,Status) values" +
$"({traceId},{trace.MachineID},'{trace.SN}',{detail.ItemID},'{detail.ItemName}',{detail.Value.Value}," +
$"'{detail.Result}','{time}',{projectid},1);";
dSQL += "SELECT @@identity;";
detail.ID = conn.Query<long>(dSQL, tran).FirstOrDefault();
resDetails.Add(detail);
}
else
{
var dSQL = $"insert into {table.name}" +
$"(TraceID,MachineID,SN,ItemID,ItemName,Result,CreateTime,ProjectID,Status) values" +
$"({traceId},{trace.MachineID},'{trace.SN}',{detail.ItemID},'{detail.ItemName}'," +
$"'{detail.Result}','{time}',{projectid},1);";
dSQL += "SELECT @@identity;";
detail.ID = conn.Query<long>(dSQL, tran).FirstOrDefault();
resDetails.Add(detail);
}
}
}
Commit(tran, conn);
return traceId;
}
catch (Exception ex)
{
Logger.WriteLineError("Insert Trace Detail Data Error:" + ex.ToString());
Rollback(tran, conn);
return 0;
}
}
}
/// <summary>
/// 插入检验数据,并返回有插入ID和顺序序号的检验详情数据
/// </summary>
/// <returns></returns>
public bool InsertTraceOnlyDetailsReturnNumerIndex(SnTrace trace, List<SnTraceDetailList> details, int projectid,
string result, out List<SnTraceDetailList> resDetails)
{
resDetails = new List<SnTraceDetailList>();
var tables = GetSubTableList(TabelNameConstant.SnTraceDetailTable);
if (!tables.Any())
{
return false;
}
using (var conn = GetDbConnection())
{
var now = DateTime.Now;
var tran = BeginTransaction(conn);
try
{
if (trace.Result != result)
{
var uSQL = $"update {TabelNameConstant.SnTraceTable} set Result='{result}' where ID={trace.ID} and Status=1 and ProjectID={projectid}";
conn.Execute(uSQL, tran);
}
var time = trace.CreateTime.ToString(ParameterConstant.DateTimeFormat);
foreach (var detail in details)
{
var table = tables.FirstOrDefault(t => t.validtime.Year == now.Year && t.validtime.Month == now.Month);
if (table != null)
{
if (detail.Value.HasValue)
{
var dSQL = $"insert into {table.name}" +
$"(TraceID,MachineID,SN,ItemID,ItemName,Value,Result,CreateTime,ProjectID,Status) values" +
$"({trace.ID},{trace.MachineID},'{trace.SN}',{detail.ItemID},'{detail.ItemName}',{detail.Value.Value}," +
$"'{detail.Result}','{time}',{projectid},1);";
dSQL += "SELECT @@identity;";
detail.ID = conn.Query<long>(dSQL, tran).FirstOrDefault();
resDetails.Add(detail);
}
else
{
var dSQL = $"insert into {table.name}" +
$"(TraceID,MachineID,SN,ItemID,ItemName,Result,CreateTime,ProjectID,Status) values" +
$"({trace.ID},{trace.MachineID},'{trace.SN}',{detail.ItemID},'{detail.ItemName}'," +
$"'{detail.Result}','{time}',{projectid},1);";
dSQL += "SELECT @@identity;";
detail.ID = conn.Query<long>(dSQL, tran).FirstOrDefault();
resDetails.Add(detail);
}
}
}
Commit(tran, conn);
return true;
}
catch (Exception ex)
{
Logger.WriteLineError("Insert Trace Detail Data Error:" + ex.ToString());
Rollback(tran, conn);
return false;
}
}
}
/// <summary>
/// 通过多个项目ID 获取TraceID
/// </summary>
/// <returns></returns>
public IEnumerable<long> GetTraceIdList(List<long> ids, long traceId, List<int> itemIds,
string itemName, string starttime, string endtime, int projectid)
{
var snTraceIds = new List<long>();
var subTables = GetSubTableList(TabelNameConstant.SnTraceDetailTable);
if (subTables.Any())
{
Parallel.ForEach(subTables, new ParallelOptions { MaxDegreeOfParallelism = subTables.Count },
t => { snTraceIds.AddRange(GetSnTraceIds(t, ids, traceId, itemIds, itemName, starttime, endtime, projectid)); });
Task.WaitAll();
}
return snTraceIds.ToList();
}
private IEnumerable<long> GetSnTraceIds(SubTable table, List<long> ids, long traceId, List<int> itemIds, string itemName
, string starttime, string endtime, int projectid)
{
var conditon = string.Empty;
var stime = starttime.ToDateTime();
var etime = endtime.ToDateTime();
if (ids.Any())
{
var detailIds = new List<int>();
if (DateTime.Now.Year == table.validtime.Year && DateTime.Now.Month == table.validtime.Month)
{
ids.Where(t => t >= table.startid);
}
else
{
ids.Where(t => t <= table.endid && t >= table.startid).ToList();
}
if (detailIds.Any())
{
conditon = $" and ID in ({string.Join(",", detailIds)}) ";
}
else
{
return new List<long>();
}
}
if (traceId > 0)
{
conditon += $" and TraceID={traceId}";
}
if (!string.IsNullOrEmpty(itemName))
{
conditon += $" and ItemName='{itemName}'";
}
if (itemIds.Any())
{
conditon += $" and ItemID in ({string.Join(",", itemIds)})";
}
var sql = $@"select TraceID
from {table.name}
where Status=1 and ProjectID={projectid} and CreateTime<='{endtime}' and
CreateTime>='{starttime}' {conditon}
group by TraceID ";
var dataList = GetDataList<long>(sql);
return dataList;
}
public override void Dispose()
{
throw new NotImplementedException();
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
using Dapper;
using Siger.Middlelayer.Dapper.CheckTrace.Data;
using Siger.Middlelayer.Dapper.CheckTrace.Constant;
using System.Linq;
using System.Threading.Tasks;
using Siger.Middlelayer.Common.Extensions;
using Siger.Middlelayer.Common.Log;
using Siger.Middlelayer.Common;
using Siger.Middlelayer.Common.ModuleEnum;
namespace Siger.Middlelayer.Dapper.CheckTrace.Repostriories
{
public class TraceDetailTableRepository : TraceDetailRepository
{
public TraceDetailTableRepository(int companyId, int projectId) : base(companyId, projectId)
{
}
/// <summary>
/// 查询表是否存在
/// </summary>
/// <returns></returns>
public bool TableIsExsit(string tablename, string schemaname)
{
using (var conn = GetDbConnection())
{
var sql = $"select TABLE_NAME from information_schema.TABLES where TABLE_NAME = '{tablename}' and TABLE_SCHEMA='{schemaname}';";
var data = conn.Query<string>(sql);
return !string.IsNullOrEmpty(data.FirstOrDefault());
}
}
public void CreateTable(string tablename, string true_tablename, long startid)
{
using (var conn = GetDbConnection())
{
var sql = string.Empty;
switch (tablename)
{
case TabelNameConstant.SnTraceTable:
{
sql = "CREATE TABLE `" + true_tablename + @"` (
`ID` bigint(20) NOT NULL AUTO_INCREMENT,
`SN` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '二维码',
`ProductID` int(11) NOT NULL COMMENT '产品ID',
`MaterialID` int(11) NOT NULL DEFAULT 0 COMMENT '物料ID',
`SectionID` int(20) NOT NULL COMMENT '工位ID',
`MachineID` int(11) NOT NULL COMMENT '设备ID',
`WorkOrder` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '工单号',
`RouteID` int(11) NOT NULL DEFAULT 0 COMMENT '产品工序ID',
`UserID` int(20) NOT NULL DEFAULT 0 COMMENT '用户MID',
`Result` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '结果',
`CheckType` int(2) NOT NULL DEFAULT 0 COMMENT '检验类型',
`CreateTime` datetime(0) NOT NULL,
`ProjectID` int(20) NOT NULL DEFAULT 0,
`Status` int(2) NOT NULL DEFAULT 1,
PRIMARY KEY(`ID`) USING BTREE,
INDEX `sn`(`SN`) USING BTREE,
INDEX `UserID`(`UserID`) USING BTREE,
INDEX `CreateTime`(`CreateTime`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = DYNAMIC; ";
break;
}
case TabelNameConstant.SnTraceDetailTable:
{
sql = @"CREATE TABLE `" + true_tablename + @"` (
`ID` bigint(20) NOT NULL AUTO_INCREMENT,
`MachineID` int(11) NOT NULL DEFAULT 0,
`TraceID` bigint(20) NOT NULL DEFAULT 0 COMMENT 'siger_tr_sn_trace.id(trace表ID)',
`SN` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '二维码',
`ItemID` int(11) NOT NULL DEFAULT 0 COMMENT 'siger_qms_inspection_standard.id(项目ID)',
`ItemName` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '项目名称',
`Value` double NULL DEFAULT NULL COMMENT '检测值',
`Result` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '结果',
`CreateTime` datetime(0) NOT NULL,
`ProjectID` int(20) NOT NULL DEFAULT 0,
`Status` int(20) NOT NULL DEFAULT 1,
PRIMARY KEY (`ID`) USING BTREE,
INDEX `index_createtime`(`CreateTime`) USING BTREE,
INDEX `index_itemname`(`ItemName`) USING BTREE,
INDEX `index_itemid`(`ItemID`) USING BTREE,
INDEX `index_traceid`(`TraceID`, `ProjectID`, `Status`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = " + startid + " CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = DYNAMIC;";
break;
}
case TabelNameConstant.SubTableTable:
{
sql = "CREATE TABLE `" + true_tablename + @"` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '分表表名',
`tablename` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '原始表名',
`startid` bigint(20) NOT NULL DEFAULT 0 COMMENT '分表最小ID',
`endid` bigint(20) NOT NULL DEFAULT 0 COMMENT '分表最大ID,新建表默认0',
`validtime` datetime(0) NOT NULL COMMENT '有效月份',
`createtime` datetime(0) NOT NULL COMMENT '创建时间',
`status` int(2) NOT NULL DEFAULT 1,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = DYNAMIC;";
break;
}
}
var data = conn.Execute(sql);
}
}
public long GetTableMaxID(string tablename)
{
using (var conn = GetDbConnection())
{
var sql = $"select max(ID) from {tablename}";
var data = conn.Query<string>(sql);
bool num = long.TryParse(data.First(), out long result);
return num ? result : 0L;
}
}
public long GetTableMinID(string tablename)
{
using (var conn = GetDbConnection())
{
var sql = $"select min(ID) from {tablename}";
var data = conn.Query<string>(sql);
bool num = long.TryParse(data.First(), out long result);
return num ? result : 1L;
}
}
public SubTable GetSubTableInfo(string name, string tablename)
{
using (var conn = GetDbConnection())
{
var sql = $"select * from {TabelNameConstant.SubTableTable} where name='{name}' and tablename='{tablename}' and status=1";
var dataList = conn.Query<SubTable>(sql);
return dataList.FirstOrDefault();
}
}
public bool InsertSubTable(SubTable entity)
{
using (var conn = GetDbConnection())
{
var sql = $"INSERT INTO `siger_project_subtable` (name,tablename,startid,endid,validtime,createtime,status) VALUES ('{entity.name}', '{entity.tablename}', {entity.startid}, {entity.endid}, '{entity.validtime.ToString(ParameterConstant.DateTimeFormat)}', '{entity.createtime.ToString(ParameterConstant.DateTimeFormat)}', {entity.status});";
var data = conn.Execute(sql);
return data > 0;
}
}
public bool UpdateSubTableEndId(int id, long endid)
{
using (var conn = GetDbConnection())
{
var sql = $"update siger_project_subtable set endid={endid} where id={id}";
var data = conn.Execute(sql);
return data > 0;
}
}
public override void Dispose()
{
throw new NotImplementedException();
}
}
}
using System;
using System.Collections.Generic;
using System.Data;
using System.Threading.Tasks;
using Dapper;
using MySql.Data.MySqlClient;
using Siger.Middlelayer.Common.Configuration;
using Siger.Middlelayer.Redis;
namespace Siger.Middlelayer.Dapper.CheckTrace
{
public abstract class TraceDbContext
{
private static string _dbConnection;
private static string _dbMidConnection;
private readonly int _companyId;
private readonly int _projectId;
protected TraceDbContext(int companyId, int projectId)
{
var useOneDb = ConfigManager.GetValue("DbSetting", "UseOneDb", true);
if (useOneDb)
{
_dbConnection = ConfigManager.GetValue("DbSetting", "DbConnectionKM", string.Empty);
}
else
{
_dbConnection = ConfigManager.GetValue("DbClusterSetting", "ClusterConnectionKM", string.Empty);
}
if (string.IsNullOrEmpty(_dbConnection))
{
throw new Exception("DbSetting about [DbConnectionKM] not found.");
}
_dbMidConnection = ConfigManager.GetValue("DbSetting", "DbConnection", string.Empty);
if (string.IsNullOrEmpty(_dbMidConnection))
{
throw new Exception("DbSetting about [DbConnection] not found.");
}
_companyId = companyId;
_projectId = projectId;
}
public string GetDbName()
{
return $"{_companyId}_{_projectId}";
}
public IDbConnection GetMidDbConnection()
{
try
{
var connecctionStr = $"{_dbMidConnection}";
var connect = new MySqlConnection(connecctionStr);
connect.Open();
return connect;
}
catch (Exception e)
{
throw new Exception($"connect mysql db {_dbMidConnection} failed, error:" + e);
}
}
public IDbConnection GetDbConnection()
{
try
{
var dbConfig = RedisCache.Instance.GetDbName(_companyId, _projectId);
var connecctionStr = $"{_dbConnection};database={dbConfig.MysqlDbName}";
var connect = new MySqlConnection(connecctionStr);
connect.Open();
return connect;
}
catch (Exception e)
{
throw new Exception($"connect mysql db {_companyId}_{_projectId} failed, error:" + e);
}
}
protected async Task<IEnumerable<T>> GetDataListAsync<T>(string sql)
{
return await Task.Run(() =>
{
using (var conn = GetDbConnection())
{
var dataList = conn.QueryAsync<T>(sql);
return dataList;
}
});
}
protected IEnumerable<T> GetDataList<T>(string sql)
{
using (var conn = GetDbConnection())
{
var dataList = conn.Query<T>(sql);
return dataList;
}
}
protected long Count(string table)
{
using (var conn = GetDbConnection())
{
var result = conn.ExecuteScalar<long>($"select count(1) from {table}");
return result;
}
}
protected string GetMidDataBaseName()
{
using (var conn = GetMidDbConnection())
{
return conn.Database;
}
}
/// <summary>
/// 开启事务
/// </summary>
/// <param name="conn"></param>
/// <returns></returns>
public IDbTransaction BeginTransaction(IDbConnection conn)
{
IDbTransaction tran = conn.BeginTransaction();
return tran;
}
/// <summary>
/// 提交事务
/// </summary>
/// <param name="tran"></param>
/// <param name="conn"></param>
public void Commit(IDbTransaction tran, IDbConnection conn)
{
tran.Commit();
}
/// <summary>
/// 回滚事务
/// </summary>
/// <param name="tran"></param>
/// <param name="conn"></param>
public void Rollback(IDbTransaction tran, IDbConnection conn)
{
tran.Rollback();
}
public abstract void Dispose();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment