|
|
@@ -2,6 +2,7 @@
|
|
|
|
|
|
namespace app\api\controller;
|
|
|
|
|
|
+use app\admin\model\EntrustLog;
|
|
|
use app\common\controller\Api;
|
|
|
use \think\Request;
|
|
|
use \think\Db;
|
|
|
@@ -123,10 +124,11 @@ class Product extends Api
|
|
|
$yjRes = db('产品_印件资料')->where($where)->field($field)->select();
|
|
|
//印版资料
|
|
|
$filter['a.YB_Cpdh'] = $code;
|
|
|
- $yb_field = 'rtrim(a.YB_方案) as YB_方案,a.YB_Yjno,rtrim(a.存货编码) as 存货编码,a.考核印数,rtrim(a.Sys_id) as Sys_id,a.Mod_rq,rtrim(b.物料名称) as 印版名称,a.UniqID';
|
|
|
+ $yb_field = 'rtrim(a.YB_方案) as YB_方案,a.YB_Yjno,rtrim(a.存货编码) as 存货编码,a.考核印数,rtrim(a.Sys_id) as Sys_id,a.Mod_rq,rtrim(b.物料名称) as 印版名称,rtrim(c.名称) as 印版类别,a.UniqID';
|
|
|
$ybRes = db('产品_印版资料')->alias('a')
|
|
|
- ->join('物料_存货编码 b','a.存货编码 = b.物料代码')
|
|
|
- ->where($filter)->field($yb_field)->select();
|
|
|
+ ->join('物料_存货编码 b','a.存货编码 = b.物料代码','left')
|
|
|
+ ->join('物料_存货结构 c','LEFT(a.存货编码,4) = c.编号','left')
|
|
|
+ ->where($filter)->field($yb_field)->order('a.YB_Yjno,a.存货编码')->select();
|
|
|
$list = [];
|
|
|
$list['yjData'] = $yjRes;
|
|
|
$list['gyData'] = $gyRes;
|
|
|
@@ -135,7 +137,7 @@ class Product extends Api
|
|
|
$this->success('请求成功',$list);
|
|
|
}
|
|
|
/**
|
|
|
- * 获取单个产品工艺数据
|
|
|
+ * 4.获取单个工艺数据(排产参数调整)
|
|
|
*
|
|
|
* @ApiMethod GET
|
|
|
*@param string product_code
|
|
|
@@ -156,7 +158,7 @@ class Product extends Api
|
|
|
$gy_field = 'rtrim(a.Gy0_方案) as programme,a.Gy0_yjno,a.Gy0_gxh,rtrim(a.gy0_gxmc) as gy0_gxmc,a.A类产能 as A_power,rtrim(a.Gy0_shdh) as Gy0_shdh,rtrim(a.Gy0_sbbh) as Gy0_sbbh,
|
|
|
a.工价系数 as difficulty_coe,a.损耗系数 as loss_coe,a.Gy0_Ms as ms_coe,a.Gy0_Ks,a.Gy0_ls,rtrim(a.Gy0_site) as Gy0_site,rtrim(a.Add_gxmc) as Add_gxmc,a.UniqID,a.Gy0_辅助工时,
|
|
|
rtrim(a.工序备注) as remark,a.人工检_正品板 as artificial_zp,a.人工检_次品板 as artificial_cp,a.人工检_废检 as artificial_fj,a.机检_正品板 as machine_zp,a.机检_次品板 as machine_cp,
|
|
|
- a.机检_废检 as machine_fj,rtrim(b.客户名称) as custom_name,rtrim(b.产品名称) as product_name';
|
|
|
+ a.机检_废检 as machine_fj,rtrim(b.客户名称) as custom_name,rtrim(b.产品名称) as product_name,UniqId';
|
|
|
$gyRes = db('产品_工艺资料')->alias('a')
|
|
|
->join('产品_基本资料 b','a.Gy0_cpdh = b.产品编号','left')
|
|
|
->where($option)->field($gy_field)->order('a.Gy0_yjno asc,a.Gy0_gxh asc')->select();
|
|
|
@@ -532,7 +534,7 @@ class Product extends Api
|
|
|
}
|
|
|
$field = "yj_yjno,rtrim(yj_yjdh) as yj_yjdh,rtrim(yj_yjmc) as yj_yjmc,rtrim(yj_zzdh) as yj_zzdh,rtrim(yj_zzmc) as yj_zzmc,rtrim(yj_zzdh1) as yj_zzdh1,rtrim(yj_zzdh2) as yj_zzdh2,
|
|
|
rtrim(yj_zzdh3) as yj_zzdh3,rtrim(yj_zzdh4) as yj_zzdh4,rtrim(yj_zzmc1) as yj_zzmc1,rtrim(yj_zzmc2) as yj_zzmc2,rtrim(yj_zzmc3) as yj_zzmc3,
|
|
|
- rtrim(yj_zzmc4) as yj_zzmc4,rtrim(yj_tlgg) as yj_tlgg,rtrim(yj_klgg) as yj_klgg,yj_ks,yj_ls,KgToPages,rtrim(yj_desc) as yj_desc,";
|
|
|
+ rtrim(yj_zzmc4) as yj_zzmc4,rtrim(yj_tlgg) as yj_tlgg,rtrim(yj_klgg) as yj_klgg,yj_ks,yj_ls,KgToPages,rtrim(yj_desc) as yj_desc,UniqId";
|
|
|
$list = \db('产品_印件资料')->where('UniqId',$params['UniqId'])->field($field)->select();
|
|
|
$this->success('请求成功',$list);
|
|
|
}
|
|
|
@@ -646,6 +648,259 @@ class Product extends Api
|
|
|
}
|
|
|
$params = Request::instance()->get();
|
|
|
$search = $params['search'];
|
|
|
-// $list = \db('物料_存货结构')->where('LEFT(编号)')
|
|
|
+ if (!empty($search)){
|
|
|
+ $sql = "SELECT rtrim(a.`物料代码`) as 物料代码,rtrim(a.`物料名称`) as 物料名称,rtrim(a.`规格`) as 规格,rtrim(b.编号) as oneCode,rtrim(b.名称) as oneName,
|
|
|
+ rtrim(c.`编号`) as twoCode,rtrim(c.`名称`) as twoName,rtrim(d.`编号`) as thrCode,rtrim(d.`名称`) as thrName
|
|
|
+ FROM `物料_存货编码` a
|
|
|
+ LEFT JOIN `物料_存货结构` b ON LEFT(a.物料代码,2) = b.编号
|
|
|
+ LEFT JOIN `物料_存货结构` c ON LEFT(a.物料代码,4) = c.编号
|
|
|
+ LEFT JOIN `物料_存货结构` d ON LEFT(a.物料代码,6) = d.编号
|
|
|
+ WHERE a.物料名称 LIKE '%{$search}%' AND (a.物料代码 LIKE '00%' or a.物料代码 LIKE '01%' or a.物料代码 LIKE '30%')";
|
|
|
+ }else{
|
|
|
+ $sql = "SELECT rtrim(a.`物料代码`) as 物料代码,rtrim(a.`物料名称`) as 物料名称,rtrim(a.`规格`) as 规格,rtrim(b.编号) as oneCode,rtrim(b.名称) as oneName,
|
|
|
+ rtrim(c.`编号`) as twoCode,rtrim(c.`名称`) as twoName,rtrim(d.`编号`) as thrCode,rtrim(d.`名称`) as thrName
|
|
|
+ FROM `物料_存货编码` a
|
|
|
+ LEFT JOIN `物料_存货结构` b ON LEFT(a.物料代码,2) = b.编号
|
|
|
+ LEFT JOIN `物料_存货结构` c ON LEFT(a.物料代码,4) = c.编号
|
|
|
+ LEFT JOIN `物料_存货结构` d ON LEFT(a.物料代码,6) = d.编号
|
|
|
+ WHERE a.物料代码 LIKE '00%' or a.物料代码 LIKE '01%' or a.物料代码 LIKE '30%'";
|
|
|
+ }
|
|
|
+ $data = Db::query($sql);
|
|
|
+ $mergedArray = [];
|
|
|
+ foreach ($data as $item) {
|
|
|
+ $oneCode = $item['oneCode'];
|
|
|
+ $twoCode = $item['twoCode'];
|
|
|
+ $thrCode = $item['thrCode'];
|
|
|
+ $oneName = $item['oneName'];
|
|
|
+ $twoName = $item['twoName'];
|
|
|
+ $thrName = $item['thrName'];
|
|
|
+ // Create a unique key using the combination of oneCode, twoCode, and thrCode
|
|
|
+ $oneKey = "{$oneCode}/{$oneName}";
|
|
|
+ $twoKey = "{$twoCode}/{$twoName}";
|
|
|
+ $thrKey = "{$thrCode}/{$thrName}";
|
|
|
+ // Initialize arrays if not already set
|
|
|
+ if (!isset($mergedArray[$oneKey])) {
|
|
|
+ $mergedArray[$oneKey] = [];
|
|
|
+ }
|
|
|
+ if (!isset($mergedArray[$oneKey][$twoKey])) {
|
|
|
+ $mergedArray[$oneKey][$twoKey] = [];
|
|
|
+ }
|
|
|
+ // Append items to the arrays
|
|
|
+ $mergedArray[$oneKey][$twoKey][$thrKey][] = $item;
|
|
|
+ }
|
|
|
+ $this->success('请求成功',$mergedArray);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ *3.6工艺资料-获取产品工艺资料
|
|
|
+ */
|
|
|
+ public function getProductGyInfo(){
|
|
|
+ if (Request::instance()->isGet() == false){
|
|
|
+ $this->error('非法请求');
|
|
|
+ }
|
|
|
+ $params = Request::instance()->param();
|
|
|
+ if (empty($params['UniqID']) || empty($params['UniqID'])){
|
|
|
+ $this->error('参数错误');
|
|
|
+ }
|
|
|
+ $field = "rtrim(a.Gy0_方案) as Gy0_方案,a.Gy0_yjno,a.Gy0_gxh,a.Gy0_Ks,a.Gy0_ls,rtrim(a.Gy0_site) as Gy0_site,rtrim(a.gy0_gxmc) as gy0_gxmc,rtrim(a.Add_gxmc) as Add_gxmc,a.Gy0_Ms,
|
|
|
+ rtrim(a.Gy0_sbbh) as Gy0_sbbh,rtrim(a.Gy0_shdh) as Gy0_shdh,rtrim(b.sys_mc) as sys_mc,b.sys_rate0,b.sys_rate1,a.工价系数,a.损耗系数,rtrim(a.工序备注) as 工序备注,
|
|
|
+ rtrim(a.质量要求) as 质量要求,rtrim(a.质量隐患) as 质量隐患,a.UniqID";
|
|
|
+ $data = \db('产品_工艺资料')->alias('a')
|
|
|
+ ->join('dic_lzsh b','a.Gy0_shdh = b.sys_bh','left')
|
|
|
+ ->where('a.UniqID',$params['UniqID'])
|
|
|
+ ->field($field)
|
|
|
+ ->find();
|
|
|
+ $this->success('请求成功',$data);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 3.7工艺资料-获取车间及工艺名称
|
|
|
+ * @ApiMethod GET
|
|
|
+ *
|
|
|
+ */
|
|
|
+ public function getDepartName(){
|
|
|
+ if (Request::instance()->isGet() == false){
|
|
|
+ $this->error('非法请求');
|
|
|
+ }
|
|
|
+ $data = \db('erp_常用字典')->where('分类','印刷工艺')->order('编号 asc')->column('名称');
|
|
|
+
|
|
|
+ $resultArray = [];
|
|
|
+ foreach ($data as $item) {
|
|
|
+ $parts = explode('_', $item);
|
|
|
+ // 使用第一个部分作为一级键,第二个部分作为二级键
|
|
|
+ $firstKey = $parts[0];
|
|
|
+ $secondKey = $parts[1];
|
|
|
+ $thirdValue = $parts[2];
|
|
|
+
|
|
|
+ $resultArray[$firstKey][$secondKey][] = $thirdValue;
|
|
|
+ }
|
|
|
+ $this->success('请求成功',$resultArray);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 3.8工艺资料-新增产品工艺
|
|
|
+ */
|
|
|
+ public function addProductGyInfo(){
|
|
|
+ if (Request::instance()->isPost() == false){
|
|
|
+ $this->error('非法请求');
|
|
|
+ }
|
|
|
+ $params = Request::instance()->post();
|
|
|
+ $UniqId = \db('产品_工艺资料')->order('UniqID desc')->value('UniqID');
|
|
|
+ if ($UniqId < 2000000){
|
|
|
+ $UniqId = 2000000;
|
|
|
+ }else{
|
|
|
+ $UniqId = $UniqId + 1;
|
|
|
+ }
|
|
|
+ $params['UniqID'] = $UniqId;
|
|
|
+ $params['Sys_rq'] = date('Y-m-d H:i:s');
|
|
|
+ $sql = \db('产品_工艺资料')->fetchSql(true)->insert($params);
|
|
|
+ $res = Db::query($sql);
|
|
|
+ if ($res !== false){
|
|
|
+ $this->success('新增成功');
|
|
|
+ }else{
|
|
|
+ $this->error('新增失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 3.9印版资料-获取产品印版资料
|
|
|
+ * @ApiMethod GET
|
|
|
+ */
|
|
|
+ public function getProductYbInfo(){
|
|
|
+ if (Request::instance()->isGet() == false){
|
|
|
+ $this->error('非法请求');
|
|
|
+ }
|
|
|
+ $params = Request::instance()->param();
|
|
|
+ if (empty($params['UniqID']) || empty($params['UniqID'])){
|
|
|
+ $this->error('参数错误');
|
|
|
+ }
|
|
|
+ $field = "rtrim(a.YB_方案) as YB_方案,a.YB_Yjno,a.YB_gxh,rtrim(a.存货编码) as 存货编码,rtrim(a.印版名称) as 印版名称,a.UniqID,rtrim(b.gy0_gxmc) as gy0_gxmc,
|
|
|
+ rtrim(b.Add_gxmc) as Add_gxmc,rtrim(c.物料名称) as 物料名称,rtrim(a.YB_cpdh) as YB_cpdh";
|
|
|
+ $data = \db('产品_印版资料')->alias('a')
|
|
|
+ ->join('产品_工艺资料 b','a.YB_cpdh = b.Gy0_cpdh and a.YB_Yjno = b.Gy0_yjno and a.YB_gxh = b.Gy0_gxh','left')
|
|
|
+ ->join('物料_存货编码 c','a.存货编码 = c.物料代码','left')
|
|
|
+ ->where('a.UniqID',$params['UniqID'])->field($field)->order('存货编码')->find();
|
|
|
+ $where['Gy0_site'] = [
|
|
|
+ ['like','%胶印%'],
|
|
|
+ ['like','%烫模%'],
|
|
|
+ 'or'
|
|
|
+ ];
|
|
|
+ $option['Gy0_cpdh'] = $data['YB_cpdh'];
|
|
|
+ $option['Gy0_gxh'] = ['<',10];
|
|
|
+ $option['Gy0_sbbh'] = ['neq',''];
|
|
|
+ $gyData = \db('产品_工艺资料')->where($option)->where($where)->field('Gy0_方案,Gy0_yjno,Gy0_gxh,gy0_gxmc')->order('Gy0_yjno,Gy0_gxh')->select();
|
|
|
+ halt($gyData);
|
|
|
+ $this->success('请求成功',$data);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 3.10印版资料-修改产品印版资料
|
|
|
+ * @ApiMethod POST
|
|
|
+ * @params string UniqId
|
|
|
+ */
|
|
|
+ public function editProductYbInfo(){
|
|
|
+ if (Request::instance()->isPost() == false){
|
|
|
+ $this->error('非法请求');
|
|
|
+ }
|
|
|
+ $params = Request::instance()->post();
|
|
|
+ if (empty($params) || !isset($params['UniqId'])){
|
|
|
+ $this->error('参数不能为空');
|
|
|
+ }
|
|
|
+ $UniqId = $params['UniqId'];
|
|
|
+ unset($params['UniqId']);
|
|
|
+ $sql = \db('产品_印版资料')->where('UniqId',$UniqId)->fetchSql(true)->update($params);
|
|
|
+ $res = Db::query($sql);
|
|
|
+ if ($res !== false){
|
|
|
+ $this->success('更新成功');
|
|
|
+ }else{
|
|
|
+ $this->error('更新失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 印版资料-获取物料名称
|
|
|
+ * @ApiMethod GET
|
|
|
+ *
|
|
|
+ */
|
|
|
+ public function getProductYbMaterialList(){
|
|
|
+ if (Request::instance()->isGet() == false){
|
|
|
+ $this->error('非法请求');
|
|
|
+ }
|
|
|
+ $sql = "SELECT rtrim(`编号`) as 编号, rtrim(`名称`) as 名称 FROM `物料_存货结构` WHERE `编号` IN ('0502','0503','0510','0511','0512','0513','0514','0520','0521','0523','0524','0525')";
|
|
|
+ $data = Db::query($sql);
|
|
|
+ $this->success('请求成功',$data);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ *3.12印版资料-获取详细存货名称
|
|
|
+ * @ApiMethod GET
|
|
|
+ * @params string code
|
|
|
+ */
|
|
|
+ public function getProductYbMaterialDetail(){
|
|
|
+ if (Request::instance()->isGet() == false){
|
|
|
+ $this->error('非法请求');
|
|
|
+ }
|
|
|
+ $params = Request::instance()->get();
|
|
|
+ if (empty($params) || !isset($params['code'])){
|
|
|
+ $this->error('参数不能为空');
|
|
|
+ }
|
|
|
+ $code = $params['code'];
|
|
|
+ $search = $params['search'];
|
|
|
+ if (!empty($search)){
|
|
|
+ $sql = "SELECT rtrim(a.`物料代码`) as 物料代码,rtrim(a.`物料名称`) as 物料名称,rtrim(a.`规格`) as 规格,
|
|
|
+ rtrim(c.`编号`) as twoCode,rtrim(c.`名称`) as twoName,rtrim(d.`编号`) as thrCode,rtrim(d.`名称`) as thrName
|
|
|
+ FROM `物料_存货编码` a
|
|
|
+ LEFT JOIN `物料_存货结构` c ON LEFT(a.物料代码,4) = c.编号
|
|
|
+ LEFT JOIN `物料_存货结构` d ON LEFT(a.物料代码,6) = d.编号
|
|
|
+ WHERE a.物料代码 LIKE '{$code}%' AND a.物料名称 LIKE '%{$search}%'";
|
|
|
+ }else{
|
|
|
+ $sql = "SELECT rtrim(a.`物料代码`) as 物料代码,rtrim(a.`物料名称`) as 物料名称,rtrim(a.`规格`) as 规格,
|
|
|
+ rtrim(c.`编号`) as twoCode,rtrim(c.`名称`) as twoName,rtrim(d.`编号`) as thrCode,rtrim(d.`名称`) as thrName
|
|
|
+ FROM `物料_存货编码` a
|
|
|
+ LEFT JOIN `物料_存货结构` c ON LEFT(a.物料代码,4) = c.编号
|
|
|
+ LEFT JOIN `物料_存货结构` d ON LEFT(a.物料代码,6) = d.编号
|
|
|
+ WHERE a.物料代码 LIKE '{$code}%'";
|
|
|
+ }
|
|
|
+ $data = Db::query($sql);
|
|
|
+ $mergedArray = [];
|
|
|
+ foreach ($data as $item) {
|
|
|
+ $oneCode = '05';
|
|
|
+ $twoCode = $item['twoCode'];
|
|
|
+ $thrCode = $item['thrCode'];
|
|
|
+ $oneName = '版材';
|
|
|
+ $twoName = $item['twoName'];
|
|
|
+ $thrName = $item['thrName'];
|
|
|
+ $oneKey = "{$oneCode}/{$oneName}";
|
|
|
+ $twoKey = "{$twoCode}/{$twoName}";
|
|
|
+ $thrKey = "{$thrCode}/{$thrName}";
|
|
|
+ if (!isset($mergedArray[$oneKey])) {
|
|
|
+ $mergedArray[$oneKey] = [];
|
|
|
+ }
|
|
|
+ if (!isset($mergedArray[$oneKey][$twoKey])) {
|
|
|
+ $mergedArray[$oneKey][$twoKey] = [];
|
|
|
+ }
|
|
|
+ $mergedArray[$oneKey][$twoKey][$thrKey][] = $item;
|
|
|
+ }
|
|
|
+ $this->success('请求成功',$mergedArray);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 3.13印版资料-新增产品印版资料
|
|
|
+ * @ApiMethod POST
|
|
|
+ * @params array data
|
|
|
+ */
|
|
|
+ public function addProductYbInfo(){
|
|
|
+ if (Request::instance()->isPost() == false){
|
|
|
+ $this->error('非法请求');
|
|
|
+ }
|
|
|
+ $params = Request::instance()->post();
|
|
|
+ $UniqId = \db('产品_印版资料')->order('UniqID desc')->value('UniqID');
|
|
|
+ if ($UniqId < 2000000){
|
|
|
+ $UniqId = 2000000;
|
|
|
+ }else{
|
|
|
+ $UniqId = $UniqId + 1;
|
|
|
+ }
|
|
|
+ $params['UniqID'] = $UniqId;
|
|
|
+ $params['考核印数'] = '0.00';
|
|
|
+ $params['Sys_rq'] = date('Y-m-d H:i:s');
|
|
|
+ $sql = \db('产品_印版资料')->fetchSql(true)->insert($params);
|
|
|
+ $res = Db::query($sql);
|
|
|
+ if ($res !== false){
|
|
|
+ $this->success('新增成功');
|
|
|
+ }else{
|
|
|
+ $this->error('新增失败');
|
|
|
+ }
|
|
|
}
|
|
|
}
|