123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- using EInk.Dtos;
- using EInk.Models;
- using Microsoft.AspNetCore.Mvc;
- using Newtonsoft.Json;
- using SqlSugar;
- using System;
- using System.ComponentModel;
- using System.Xml.Linq;
- using System;
- using System.Threading;
- using System.Text;
- using EInk.Dtos;
- using System.Reflection.Metadata;
- using Microsoft.AspNetCore.Mvc.Rendering;
- namespace EInk.Controllers
- {
- [Route("api/[controller]")]
- [ApiController]
- public class Lot3Controller : ControllerBase
- {
- private readonly ISqlSugarClient _db;
- public Lot3Controller(ISqlSugarClient db)
- {
- _db = db;
- }
- [HttpPost("UploadLot3")]
- public IActionResult Lot3Data([FromBody] Lot2Lot3Dto lot3Data)
- {
- try
- {
- try
- {
- lot3Data.Valid();
- }
- catch (Exception ex)
- {
- return Ok(ResultDto.Fail(ex.Message));
- }
- Lot2Lot3Model lot3model = new()
- {
- lot_id = lot3Data.id,
- is_send = 0,
- product_no = lot3Data.slidesNumber,
- content = JsonConvert.SerializeObject(lot3Data),
- create_time = DateTime.Now
- };
- //根据guid查看是否为重复插入
- if (_db.Ado.GetInt(string.Format("select count(*) from lot2lot3_info where lot_id='{0}'", lot3Data.id)) > 0)
- {
- lot3model.is_send = 3;
- }
- _db.Insertable(lot3model).ExecuteCommand();
- return Ok(ResultDto.Success());
- }
- catch (Exception ex)
- {
- return Ok(ResultDto.Fail("error:" + ex.Message));
- }
- }
- [HttpPost("UploadColourCast")]
- public IActionResult ColourCastData([FromBody] ColourCastDto ColourCastData)
- {
- try
- {
- try
- {
- ColourCastData.Valid();
- }
- catch (Exception ex)
- {
- return Ok(ResultDto.Fail(ex.Message));
- };
- ColourCastModel colourcastmodel = new()
- {
- gid = ColourCastData.id,
- slidesNumber = ColourCastData.slidesNumber,
- is_send = 0,
- content = JsonConvert.SerializeObject(ColourCastData),
- create_time = DateTime.Now
- };
- //根据guid查看是否为重复插入
- if (_db.Ado.GetInt(string.Format("select count(*) from colourcast_info where gid='{0}'", ColourCastData.id)) > 0)
- {
- colourcastmodel.is_send = 3;
- }
- _db.Insertable(colourcastmodel).ExecuteCommand();
- return Ok(ResultDto.Success());
- }
- catch (Exception ex)
- {
- return Ok(ResultDto.Fail("error:" + ex.Message));
- }
- }
- [HttpPost("UpdateDefectInfo")]
- public IActionResult UpdateDefectInfo([FromBody] IFormFile file)
- {
- if (file == null || file.Length == 0)
- {
- return Ok(ResultDto.Fail("No file selected"));
- }
- string line;
- try
- {
- _db.Ado.BeginTran();
- _db.Deleteable<DefectModel>().ExecuteCommand();
- using (var reader = new StreamReader(file.OpenReadStream(), Encoding.GetEncoding("gb2312")))
- {
- var header = reader.ReadLine();
- var headers = header.Split(',');
- while ((line = reader.ReadLine()) != null)
- {
- string[] linelist = line.Split(",");
- _db.Insertable(new DefectModel
- {
- id = Convert.ToInt32(linelist[0]),
- defect_code = linelist[1],
- defect_name = linelist[2],
- classification = linelist[3].Replace(';', ',')
- }).ExecuteCommand();
- }
- }
- _db.Ado.CommitTran();
- }
- catch (Exception ex)
- {
- _db.Ado.RollbackTran();
- return Ok(ResultDto.Fail(ex.Message));
- }
- return Ok(ResultDto.Success());
- }
- }
- }
|