|
|
@@ -9,7 +9,7 @@ use think\Cache;
|
|
|
use function fast\e;
|
|
|
|
|
|
/**
|
|
|
- * 产品管理接口
|
|
|
+ * 产品资料
|
|
|
*/
|
|
|
class Product extends Api
|
|
|
{
|
|
|
@@ -18,1143 +18,231 @@ class Product extends Api
|
|
|
|
|
|
/**
|
|
|
* 首页
|
|
|
- *
|
|
|
*/
|
|
|
public function index()
|
|
|
{
|
|
|
- $this->success('请求成功');
|
|
|
+ $this->success('产品_基本资料');
|
|
|
}
|
|
|
- /**
|
|
|
- * 获取产品资料
|
|
|
- *
|
|
|
- * @ApiMethod GET
|
|
|
- *@param string custom_code
|
|
|
- *@param string limit
|
|
|
- *@param string page
|
|
|
- */
|
|
|
- public function getProduct(){
|
|
|
- if (Request::instance()->isGet() == false){
|
|
|
- $this->error('非法请求');
|
|
|
- }
|
|
|
- $params = Request::instance()->param();
|
|
|
- $limit = $params['limit'];
|
|
|
- $yjno = 10;
|
|
|
- if (!isset($limit)){
|
|
|
- $limit = 15;
|
|
|
- }
|
|
|
- if (!isset($params['page'])){
|
|
|
- $pages = 0;
|
|
|
- }else{
|
|
|
- $pages = ((int)$params['page'] -1 ) * (int)$limit;
|
|
|
- }
|
|
|
- $total = 0;
|
|
|
- if (isset($params['custom_code']) && !empty($params['custom_code'])){
|
|
|
- $customCode = $params['custom_code'];
|
|
|
- $sql = "SELECT rtrim(客户编号) as 客户编号,rtrim(客户名称) as 客户名称,客户料号,rtrim(产品编号) as 产品编号,rtrim(产品名称) as 产品名称,版本号,成品规格,
|
|
|
- rtrim(计量单位) as 计量单位,rtrim(产品类别) as 产品类别,生产类别,产品备注,投产日期,状态,U8UID,rtrim(Sys_id) as Sys_id,Sys_rq,Mod_rq,UniqID
|
|
|
- FROM `产品_基本资料` WHERE `客户编号` = '{$customCode}' ORDER BY CASE WHEN `状态` IS NULL THEN 0 ELSE 1 END,
|
|
|
- `客户编号`ASC,`状态` ASC,`产品编号` DESC LIMIT {$limit} OFFSET {$pages}";
|
|
|
- $total = db('产品_基本资料')->where('客户编号',$customCode)->count();
|
|
|
- }else{
|
|
|
- if (isset($params['search']) && !empty($params['search'])){
|
|
|
- $search = $params['search'];
|
|
|
- $sql = "SELECT rtrim(客户编号) as 客户编号,rtrim(客户名称) as 客户名称,客户料号,rtrim(产品编号) as 产品编号,rtrim(产品名称) as 产品名称,版本号,成品规格,
|
|
|
- rtrim(计量单位) as 计量单位,rtrim(产品类别) as 产品类别,生产类别,产品备注,投产日期,状态,U8UID,rtrim(Sys_id) as Sys_id,Sys_rq,Mod_rq,UniqID
|
|
|
- FROM `产品_基本资料` WHERE `产品名称` LIKE '%{$search}%' OR `产品编号` LIKE '%{$search}%' ORDER BY CASE WHEN `状态` IS NULL THEN 0 ELSE 1 END,
|
|
|
- `客户编号`ASC,`状态` ASC,`产品编号` DESC LIMIT {$limit} OFFSET {$pages}";
|
|
|
- $total = db('产品_基本资料')->where('产品名称','like','%'.$search.'%')->count();
|
|
|
- }else{
|
|
|
- $sql = "SELECT rtrim(客户编号) as 客户编号,rtrim(客户名称) as 客户名称,客户料号,rtrim(产品编号) as 产品编号,rtrim(产品名称) as 产品名称,版本号,成品规格,
|
|
|
- rtrim(计量单位) as 计量单位,rtrim(产品类别) as 产品类别,生产类别,产品备注,投产日期,状态,U8UID,rtrim(Sys_id) as Sys_id,Sys_rq,Mod_rq,UniqID
|
|
|
- FROM `产品_基本资料` ORDER BY CASE WHEN `状态` IS NULL THEN 0 ELSE 1 END,
|
|
|
- `客户编号`ASC,`状态` ASC,`产品编号` DESC LIMIT {$limit} OFFSET {$pages}";
|
|
|
- $total = db('产品_基本资料')->count();
|
|
|
- }
|
|
|
- }
|
|
|
- $list = Db::query($sql);
|
|
|
- foreach ($list as $key=>$value){
|
|
|
- $code = trim($value['产品编号']);
|
|
|
- $gd_sql = "SELECT `接单日期` FROM `工单_基本资料` WHERE `成品代号` = '{$code}' ORDER BY Uniqid DESC";
|
|
|
- $gdRes = Db::query($gd_sql);
|
|
|
- $list[$key]['receiveDate'] = '';
|
|
|
- if (!empty($gdRes)){
|
|
|
- $list[$key]['receiveDate'] = $gdRes[0]['接单日期'];
|
|
|
- }
|
|
|
- if (isset($params['sort'])){
|
|
|
- $gy_sql = "SELECT * FROM `产品_工艺资料` WHERE Gy0_cpdh = '{$code}' AND Gy0_yjno >= '{$yjno}'";
|
|
|
- $gyRes = Db::query($gy_sql);
|
|
|
- }else{
|
|
|
- $gy_sql = "SELECT * FROM `产品_工艺资料` WHERE Gy0_cpdh = '{$code}'";
|
|
|
- $gyRes = Db::query($gy_sql);
|
|
|
- }
|
|
|
- $list[$key]['gyData'] = '';
|
|
|
- if (empty($gyRes)){
|
|
|
- $list[$key]['gyData'] = '缺';
|
|
|
- }
|
|
|
- if (isset($params['sort'])){
|
|
|
- $yj_sql = "SELECT COUNT(*) as total FROM `产品_印件资料` WHERE `yj_cpdh` = '{$code}' AND yj_yjno >= '{$yjno}'";
|
|
|
- $yjRes = Db::query($yj_sql);
|
|
|
- }else{
|
|
|
- $yj_sql = "SELECT COUNT(*) as total FROM `产品_印件资料` WHERE `yj_cpdh` = '{$code}'";
|
|
|
- $yjRes = Db::query($yj_sql);
|
|
|
- }
|
|
|
|
|
|
- $list[$key]['yjData'] = '无';
|
|
|
- if ($yjRes[0]['total'] > 0){
|
|
|
- $list[$key]['yjData'] = $yjRes[0]['total'];
|
|
|
- }
|
|
|
- }
|
|
|
- $data['data'] = $list;
|
|
|
- $data['total'] = $total;
|
|
|
- $this->success('请求成功',$data);
|
|
|
- }
|
|
|
- /**
|
|
|
- * 获取产品基础数据
|
|
|
- *
|
|
|
- * @ApiMethod POST
|
|
|
- *@param string product_code
|
|
|
- */
|
|
|
- public function getProductData(){
|
|
|
- if (Request::instance()->isGet() == false){
|
|
|
- $this->error('非法请求');
|
|
|
- }
|
|
|
- $params = Request::instance()->param();
|
|
|
- $code = $params['product_code'];
|
|
|
- if (!isset($code)){
|
|
|
- $this->error('参数不能为空');
|
|
|
- }
|
|
|
- if (isset($params['sort'])){
|
|
|
- $PriWhere['yj_yjno'] = ['>=',10];
|
|
|
- $proWhere['Gy0_yjno'] = ['>=',10];
|
|
|
- }else{
|
|
|
- $PriWhere['yj_yjno'] = ['<',10];
|
|
|
- $proWhere['Gy0_yjno'] = ['<',10];
|
|
|
- }
|
|
|
- $num = config('product_code_digit');
|
|
|
- //工艺资料
|
|
|
- $option['a.Gy0_cpdh'] = $code;
|
|
|
- $gy_field = 'rtrim(a.Gy0_方案) as 方案,a.Gy0_yjno,a.Gy0_gxh,rtrim(a.gy0_gxmc) as gy0_gxmc,rtrim(a.Add_gxmc) as add_gxmc,a.Gy0_Ks,a.Gy0_ls,rtrim(a.工序备注) as 备注,
|
|
|
- a.工价系数,a.损耗系数,a.Gy0_Ms,a.人工检_正品板,a.人工检_次品板,a.人工检_废检,a.机检_正品板,a.机检_次品板,a.机检_废检,rtrim(a.Gy0_sbmc) as Gy0_sbmc,rtrim(a.Sys_id) as Sys_id,
|
|
|
- a.Sys_rq,a.Mod_rq,b.sys_rate0 as 基础损耗,b.sys_rate1 as 损耗率,a.UniqID';
|
|
|
- $gyRes = db('产品_工艺资料')->alias('a')
|
|
|
- ->join('dic_lzsh b','a.Gy0_shdh = b.sys_bh','left')
|
|
|
- ->where($option)->where($proWhere)->field($gy_field)->order('a.Gy0_yjno asc,a.Gy0_gxh asc')->select();
|
|
|
- //印件资料
|
|
|
- $where['yj_cpdh'] = $code;
|
|
|
- $field = 'yj_yjno,rtrim(yj_yjdh) as yj_yjdh,yj_yjmc,rtrim(yj_zzdh) as yj_zzdh,rtrim(yj_zzmc) as yj_zzmc,rtrim(yj_tlgg) as yj_tlgg,
|
|
|
- rtrim(yj_klgg) as yj_klgg,yj_ks,yj_ls,rtrim(yj_desc) as yj_desc,rtrim(sys_id) as sys_id,sys_rq,mod_rq,UniqId';
|
|
|
- $yjRes = db('产品_印件资料')->where($where)->where($PriWhere)->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 印版名称,rtrim(c.名称) as 印版类别,a.UniqID';
|
|
|
- $ybRes = db('产品_印版资料')->alias('a')
|
|
|
- ->join('物料_存货编码 b','a.存货编码 = b.物料代码','left')
|
|
|
- ->join('物料_存货结构 c','LEFT(a.存货编码,'.$num.') = c.编号','left')
|
|
|
- ->where($filter)->field($yb_field)->order('a.YB_Yjno,a.存货编码')->select();
|
|
|
- //技术附件
|
|
|
- $jsRes = db('产品_技术附件')
|
|
|
- ->where('关联产品','like','%'.$code.'%')
|
|
|
- ->select();
|
|
|
- foreach ($jsRes as $key=>&$value){
|
|
|
- if(mb_detect_encoding($value['附件内容'])!='ASCII'){
|
|
|
- $value['附件内容'] = '';
|
|
|
- }
|
|
|
- }
|
|
|
- $list = [];
|
|
|
- $list['yjData'] = $yjRes;
|
|
|
- $list['gyData'] = $gyRes;
|
|
|
- $list['ybData'] = $ybRes;
|
|
|
- $list['jsData'] = $jsRes;
|
|
|
- $this->success('请求成功',$list);
|
|
|
- }
|
|
|
- /**
|
|
|
- * 4.获取单个工艺数据(排产参数调整)
|
|
|
- *
|
|
|
- * @ApiMethod GET
|
|
|
- *@param string product_code
|
|
|
- */
|
|
|
- public function getProductGy(){
|
|
|
- if (Request::instance()->isGet() == false){
|
|
|
- $this->error('非法请求');
|
|
|
- }
|
|
|
- $params = Request::instance()->param();
|
|
|
- $code = $params['product_code'];
|
|
|
- if (!isset($code)){
|
|
|
- $this->error('参数不能为空');
|
|
|
- }
|
|
|
- $option['a.Gy0_cpdh'] = $code;
|
|
|
- if (!empty($params['plan'])){
|
|
|
- $option['a.Gy0_方案'] = $params['plan'];
|
|
|
- }
|
|
|
- $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.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();
|
|
|
- $this->success('请求成功',$gyRes);
|
|
|
- }
|
|
|
- /**
|
|
|
- * 修改工艺参数
|
|
|
- *
|
|
|
- * @ApiMethod
|
|
|
- * @params array data
|
|
|
- */
|
|
|
- public function editGy(){
|
|
|
- if (Request::instance()->isPost() == false){
|
|
|
- $this->error('非法请求');
|
|
|
- }
|
|
|
- $params = Request::instance()->post();
|
|
|
- if (!isset($params) || !isset($params[0]['UniqID'])){
|
|
|
- $this->error('参数不能为空');
|
|
|
- }
|
|
|
- $i = 0;
|
|
|
- foreach ($params as $key=>$value){
|
|
|
- $data = [];
|
|
|
- if (!empty($value['A_power'])){
|
|
|
- $data['A类产能'] = $value['A_power'];
|
|
|
- }
|
|
|
- if (!empty($value['shdh'])){
|
|
|
- $data['Gy0_shdh'] = $value['shdh'];
|
|
|
- }
|
|
|
- if (!empty($value['machine'])){
|
|
|
- $data['Gy0_sbbh'] = $value['machine'];
|
|
|
- }
|
|
|
- if (!empty($value['time'])){
|
|
|
- $data['Gy0_辅助工时'] = $value['time'];
|
|
|
- }
|
|
|
- if (!empty($value['difficulty_coe'])){
|
|
|
- $data['工价系数'] = $value['difficulty_coe'];
|
|
|
- }
|
|
|
- if (!empty($value['loss_coe'])){
|
|
|
- $data['损耗系数'] = $value['loss_coe'];
|
|
|
- }
|
|
|
- if (!empty($value['ms_coe'])){
|
|
|
- $data['Gy0_Ms'] = $value['ms_coe'];
|
|
|
- }
|
|
|
- $sql = db('产品_工艺资料')->where('UniqID',$value['UniqID'])->fetchSql(true)->update($data);
|
|
|
- $res = Db::query($sql);
|
|
|
- if ($res !== false){
|
|
|
- $i++;
|
|
|
- }
|
|
|
- }
|
|
|
- if ($i !== 0){
|
|
|
- $this->success('更新成功');
|
|
|
- }else{
|
|
|
- $this->error('更新失败');
|
|
|
- }
|
|
|
- }
|
|
|
- /**
|
|
|
- * 修改产品信息
|
|
|
- *
|
|
|
- * @ApiMethod POST
|
|
|
- *
|
|
|
- * @params object data
|
|
|
- */
|
|
|
- public function editProduct(){
|
|
|
- if (Request::instance()->isPost() == false){
|
|
|
- $this->error('非法请求');
|
|
|
- }
|
|
|
- $params = Request::instance()->post();
|
|
|
- if (empty($params)){
|
|
|
- $this->error('参数不能为空');
|
|
|
- }
|
|
|
- if (!isset($params['印品代号'])){
|
|
|
- $this->error('印品代号不能为空');
|
|
|
- }
|
|
|
- $code = $params['印品代号'];
|
|
|
- unset($params['印品代号']);
|
|
|
- $sql = db('产品_基本资料')->where('产品编号',$code)->fetchSql(true)->update($params);
|
|
|
- $res = Db::query($sql);
|
|
|
- if ($res !== false){
|
|
|
- $this->success('更新成功');
|
|
|
- }else{
|
|
|
- $this->error('更新失败');
|
|
|
- }
|
|
|
- }
|
|
|
- /**
|
|
|
- * 设置产品状态
|
|
|
- *
|
|
|
- * @ApiMethod POST
|
|
|
- * @params string status
|
|
|
- * @params string code
|
|
|
- */
|
|
|
- public function setProductStatus(){
|
|
|
- if (Request::instance()->isPost() == false){
|
|
|
- $this->error('非法请求');
|
|
|
- }
|
|
|
- $params = Request::instance()->post();
|
|
|
- if (empty($params['code']) || empty($params['status'])){
|
|
|
- $this->error('参数不能为空');
|
|
|
- }
|
|
|
- $code = $params['code'];
|
|
|
- $status = '';
|
|
|
- if ($params['status'] == 2){
|
|
|
- $status = '停产';
|
|
|
- }
|
|
|
- $sql = db('产品_基本资料')->where('产品编号',$code)->fetchSql(true)->setField('状态',$status);
|
|
|
- $res = Db::query($sql);
|
|
|
- if ($res !== false){
|
|
|
- $this->success('更新成功');
|
|
|
- }else{
|
|
|
- $this->error('更新失败');
|
|
|
- }
|
|
|
- }
|
|
|
- /**
|
|
|
- * 获取产品工艺数量
|
|
|
- *
|
|
|
- * @ApiMethod GET
|
|
|
- * @params string code
|
|
|
- */
|
|
|
- public function getGyTotal(){
|
|
|
- if (Request::instance()->isGet() == false){
|
|
|
- $this->error('非法请求');
|
|
|
- }
|
|
|
- $params = Request::instance()->param();
|
|
|
- $code = $params['code'];
|
|
|
- if (!isset($code)){
|
|
|
- $this->error('参数不能为空');
|
|
|
- }
|
|
|
- $res = db('产品_工艺资料')->where('Gy0_cpdh',$code)->distinct(true)->column('rtrim(Gy0_方案) as gy_plan');
|
|
|
- $data['gy'] = $res;
|
|
|
- $product = db('产品_基本资料')->where('产品编号',$code)->find();
|
|
|
- $data['name'] = rtrim($product['产品名称']);
|
|
|
- $this->success('请求成功',$data);
|
|
|
- }
|
|
|
- /**
|
|
|
- * 复制产品工艺信息
|
|
|
- *
|
|
|
- * @ApiMethod POST
|
|
|
- * @params string from_code
|
|
|
- * @params string from_pro
|
|
|
- * @params string to_code
|
|
|
- * @params string to_pro
|
|
|
- * @params int is_copy_gy
|
|
|
- */
|
|
|
- public function copyProductGy(){
|
|
|
- if (Request::instance()->isPost() == false){
|
|
|
- $this->error('非法请求');
|
|
|
- }
|
|
|
- $params = Request::instance()->post();
|
|
|
- if (empty($params['from_code']) || empty($params['from_pro']) || empty($params['to_code']) ){
|
|
|
- $this->error('参数不能为空');
|
|
|
- }
|
|
|
- if ($params['is_copy_gy'] == 1){
|
|
|
- if (empty($params['to_pro'])){
|
|
|
- $this->error('工艺方案不能为空');
|
|
|
- }
|
|
|
- //查出参考的工艺数据
|
|
|
- $where['Gy0_cpdh'] = $params['from_code'];
|
|
|
- $where['Gy0_方案'] = $params['from_pro'];
|
|
|
- $gyList = db('产品_工艺资料')->where($where)->select();
|
|
|
- if (empty($gyList)){
|
|
|
- $this->error('参考产品无工艺资料数据');
|
|
|
- }
|
|
|
- $UniqID = db('产品_工艺资料')->order('UniqID desc')->value('UniqID');
|
|
|
- foreach ($gyList as $key=>$value){
|
|
|
- unset($gyList[$key]['UniqID']);
|
|
|
- $UniqID ++;
|
|
|
- $gyList[$key]['Gy0_方案'] = $params['to_pro'];
|
|
|
- $gyList[$key]['Gy0_cpdh'] = $params['to_code'];
|
|
|
- $gyList[$key]['UniqID'] = $UniqID;
|
|
|
- }
|
|
|
- }
|
|
|
- if ($params['is_copy_yb'] == 1){
|
|
|
- $UniqId = db('产品_印版资料')->order('UniqID desc')->value('UniqID');
|
|
|
- $option['YB_Cpdh'] = $params['from_code'];
|
|
|
- $ybList = db('产品_印版资料')->where($option)->select();
|
|
|
- if (empty($ybList)){
|
|
|
- $this->error('参考产品无印版资料数据');
|
|
|
- }
|
|
|
- foreach ($ybList as $key=>$value){
|
|
|
- unset($ybList[$key]['UniqID']);
|
|
|
- $UniqId++;
|
|
|
- $ybList[$key]['YB_Cpdh'] = $params['to_code'];
|
|
|
- $ybList[$key]['UniqID'] = $UniqId;
|
|
|
- }
|
|
|
- }
|
|
|
- if ($params['is_copy_gy'] == 1 && $params['is_copy_yb'] == 1){
|
|
|
- $gyResult = db('产品_工艺资料')->insertAll($gyList);
|
|
|
- if (!$gyResult){
|
|
|
- $this->error('复制产品工艺资料数据失败');
|
|
|
- }
|
|
|
- $ybResult = db('产品_印版资料')->insertAll($ybList);
|
|
|
- if (!$ybResult){
|
|
|
- $this->error('复制产品印版资料数据失败');
|
|
|
- }
|
|
|
- }elseif ($params['is_copy_gy'] == 1 && $params['is_copy_yb'] == 0){
|
|
|
- $gyResult = db('产品_工艺资料')->insertAll($gyList);
|
|
|
- if (!$gyResult){
|
|
|
- $this->error('复制产品工艺资料数据失败');
|
|
|
- }
|
|
|
- }elseif ($params['is_copy_gy'] == 0 && $params['is_copy_yb'] == 1){
|
|
|
- $ybResult = db('产品_印版资料')->insertAll($ybList);
|
|
|
- if (!$ybResult){
|
|
|
- $this->error('复制产品印版资料数据失败');
|
|
|
- }
|
|
|
- }else{
|
|
|
- $this->success('工艺、印版至少选中一个');
|
|
|
- }
|
|
|
- $this->success('工艺复制成功');
|
|
|
- }
|
|
|
- /**
|
|
|
- * 工艺方案更名
|
|
|
- *
|
|
|
- * @ApiMethod POST
|
|
|
- * @params string code
|
|
|
- * @params string name
|
|
|
- */
|
|
|
- public function editGyName(){
|
|
|
- if (Request::instance()->isPost() == false){
|
|
|
- $this->error('非法请求');
|
|
|
- }
|
|
|
- $params = Request::instance()->post();
|
|
|
- if (empty($params['code']) || empty($params['old_name']) || empty($params['new_name'])){
|
|
|
- $this->error('参数不能为空');
|
|
|
- }
|
|
|
- $where['Gy0_cpdh'] = $params['code'];
|
|
|
- $where['Gy0_方案'] = $params['old_name'];
|
|
|
- $sql = db('产品_工艺资料')->where($where)->fetchSql(true)->setField('Gy0_方案',$params['new_name']);
|
|
|
- $res = Db::query($sql);
|
|
|
- if ($res !== false){
|
|
|
- $this->success('更新成功');
|
|
|
- }else{
|
|
|
- $this->error('更新失败');
|
|
|
- }
|
|
|
- }
|
|
|
- /**
|
|
|
- * 工艺方案附加
|
|
|
- *
|
|
|
- * @ApiMethod POST
|
|
|
- * @params object data
|
|
|
- */
|
|
|
- public function editGyNo(){
|
|
|
- if (Request::instance()->isPost() == false){
|
|
|
- $this->error('非法请求');
|
|
|
- }
|
|
|
- $params = Request::instance()->post();
|
|
|
- if (empty($params) || !isset($params[0]['UniqID'])){
|
|
|
- $this->error('参数不能为空');
|
|
|
- }
|
|
|
- $i = 0;
|
|
|
- foreach ($params as $key=>$value){
|
|
|
- $data = [];
|
|
|
- if (!empty($value['Gy0_yjno'])){
|
|
|
- $data['Gy0_yjno'] = $value['Gy0_yjno'];
|
|
|
- }
|
|
|
- if (!empty($value['Gy0_gxh'])){
|
|
|
- $data['Gy0_gxh'] = $value['Gy0_gxh'];
|
|
|
- }
|
|
|
- if (!empty($value['Gy0_Ks'])){
|
|
|
- $data['Gy0_Ks'] = $value['Gy0_Ks'];
|
|
|
- }
|
|
|
- if (!empty($value['Gy0_ls'])){
|
|
|
- $data['Gy0_ls'] = $value['Gy0_ls'];
|
|
|
- }
|
|
|
- $sql = db('产品_工艺资料')->where('UniqID',$value['UniqID'])->fetchSql(true)->update($data);
|
|
|
- $res = Db::query($sql);
|
|
|
- if ($res !== false){
|
|
|
- $i++;
|
|
|
- }
|
|
|
- }
|
|
|
- if ($i !== 0){
|
|
|
- $this->success('更新成功');
|
|
|
- }else{
|
|
|
- $this->error('更新失败');
|
|
|
- }
|
|
|
- }
|
|
|
/**
|
|
|
- * 计损色数修正
|
|
|
- *
|
|
|
- * @ApiMethod POST
|
|
|
- * @params object data
|
|
|
- */
|
|
|
- public function editGyMs(){
|
|
|
- if (Request::instance()->isPost() == false){
|
|
|
+ * 新增产品资料
|
|
|
+ */
|
|
|
+ public function ProductAdd()
|
|
|
+ {
|
|
|
+ if (!Request::instance()->isPost()) {
|
|
|
$this->error('非法请求');
|
|
|
}
|
|
|
- $params = Request::instance()->post();
|
|
|
- if (empty($params) || !isset($params[0]['UniqID'])){
|
|
|
- $this->error('参数不能为空');
|
|
|
- }
|
|
|
- $i = 0;
|
|
|
- foreach ($params as $key=>$value){
|
|
|
- $data = [];
|
|
|
- if (!empty($value['Gy0_Ms'])){
|
|
|
- $data['Gy0_Ms'] = $value['Gy0_Ms'];
|
|
|
- }
|
|
|
- if (!empty($value['Gy0_Ks'])){
|
|
|
- $data['Gy0_Ks'] = $value['Gy0_Ks'];
|
|
|
- }
|
|
|
- if (!empty($value['Gy0_ls'])){
|
|
|
- $data['Gy0_ls'] = $value['Gy0_ls'];
|
|
|
- }
|
|
|
- $data['Add_gxmc'] = $value['Add_gxmc'];
|
|
|
- $data['工序备注'] = $value['remark'];
|
|
|
|
|
|
- $sql = db('产品_工艺资料')->where('UniqID',$value['UniqID'])->fetchSql(true)->update($data);
|
|
|
- $res = Db::query($sql);
|
|
|
- if ($res !== false){
|
|
|
- $i++;
|
|
|
- }
|
|
|
- }
|
|
|
- if ($i !== 0){
|
|
|
- $this->success('更新成功');
|
|
|
- }else{
|
|
|
- $this->error('更新失败');
|
|
|
- }
|
|
|
- }
|
|
|
- /**
|
|
|
- * 产品质检废品系数调整
|
|
|
- *
|
|
|
- * @ApiMethod POST
|
|
|
- * @params object data
|
|
|
- */
|
|
|
- public function editGyWaste(){
|
|
|
- if (Request::instance()->isPost() == false){
|
|
|
- $this->error('非法请求');
|
|
|
- }
|
|
|
- $params = Request::instance()->post();
|
|
|
- if (empty($params) || !isset($params[0]['UniqID'])){
|
|
|
- $this->error('参数不能为空');
|
|
|
- }
|
|
|
- $i = 0;
|
|
|
- foreach ($params as $key=>$value){
|
|
|
- $data = [];
|
|
|
- if (!empty($value['artificial_zp'])){
|
|
|
- $data['人工检_正品板'] = $value['artificial_zp'];
|
|
|
- }
|
|
|
- if (!empty($value['artificial_cp'])){
|
|
|
- $data['人工检_次品板'] = $value['artificial_cp'];
|
|
|
- }
|
|
|
- if (!empty($value['artificial_fj'])){
|
|
|
- $data['人工检_废检'] = $value['artificial_fj'];
|
|
|
- }
|
|
|
- if (!empty($value['machine_zp'])){
|
|
|
- $data['机检_正品板'] = $value['machine_zp'];
|
|
|
- }
|
|
|
- if (!empty($value['machine_cp'])){
|
|
|
- $data['机检_次品板'] = $value['machine_cp'];
|
|
|
- }
|
|
|
- if (!empty($value['machine_fj'])){
|
|
|
- $data['机检_废检'] = $value['machine_fj'];
|
|
|
- }
|
|
|
- $sql = db('产品_工艺资料')->where('UniqID',$value['UniqID'])->fetchSql(true)->update($data);
|
|
|
- $res = Db::query($sql);
|
|
|
- if ($res !== false){
|
|
|
- $i++;
|
|
|
- }
|
|
|
- }
|
|
|
- if ($i !== 0){
|
|
|
- $this->success('更新成功');
|
|
|
- }else{
|
|
|
- $this->error('更新失败');
|
|
|
- }
|
|
|
- }
|
|
|
- /**
|
|
|
- * 获取产品印件资料
|
|
|
- * @ApiMethod GET
|
|
|
- * @params string UniqId
|
|
|
- */
|
|
|
- public function getProductYjInfo(){
|
|
|
- if (Request::instance()->isGet() == false){
|
|
|
- $this->error('非法请求');
|
|
|
- }
|
|
|
$params = Request::instance()->param();
|
|
|
- if (empty($params['UniqId']) || empty($params['UniqId'])){
|
|
|
- $this->error('参数错误');
|
|
|
- }
|
|
|
- $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,UniqId";
|
|
|
- $list = \db('产品_印件资料')->where('UniqId',$params['UniqId'])->field($field)->select();
|
|
|
- $this->success('请求成功',$list);
|
|
|
- }
|
|
|
- /**
|
|
|
- * 修改产品印件资料
|
|
|
- * @ApiMethod POST
|
|
|
- * @params array data
|
|
|
- */
|
|
|
- public function editProductYjInfo(){
|
|
|
- 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']);
|
|
|
- $res = \db('产品_印件资料')->where('UniqId',$UniqId)->update($params);
|
|
|
- if ($res !== false){
|
|
|
- $this->success('更新成功');
|
|
|
- }else{
|
|
|
- $this->error('更新失败');
|
|
|
- }
|
|
|
- }
|
|
|
- /**
|
|
|
- * 新增产品印件资料
|
|
|
- * @ApiMethod POST
|
|
|
- * @params array data
|
|
|
- */
|
|
|
- public function addProductYjInfo(){
|
|
|
- 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');
|
|
|
- $res = \db('产品_印件资料')->insert($params);
|
|
|
- if ($res !== false){
|
|
|
+
|
|
|
+ // 自动生成产品编号:CP000001
|
|
|
+ $lastCode = \db('产品_基本资料')->order('id desc')->value('product_code');
|
|
|
+ if ($lastCode) {
|
|
|
+ $num = intval(str_replace('CP', '', $lastCode)) + 1;
|
|
|
+ } else {
|
|
|
+ $num = 1;
|
|
|
+ }
|
|
|
+ $params['product_code'] = 'CP' . str_pad($num, 6, '0', STR_PAD_LEFT);
|
|
|
+
|
|
|
+ $params['Sys_id'] = session('admin_id'); // 或写死 admin
|
|
|
+ $params['Sys_rq'] = date('Y-m-d H:i:s');
|
|
|
+ $params['mod_rq'] = 0;
|
|
|
+
|
|
|
+ $result = \db('产品_基本资料')->insert($params);
|
|
|
+
|
|
|
+ if ($result) {
|
|
|
$this->success('新增成功');
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
$this->error('新增失败');
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
- * 获取印件代码及名称
|
|
|
- * @ApiMethod GET
|
|
|
- *
|
|
|
- */
|
|
|
- public function getProductYjList(){
|
|
|
- if (Request::instance()->isGet() == false){
|
|
|
- $this->error('非法请求');
|
|
|
- }
|
|
|
- $params = Request::instance()->get();
|
|
|
- $search = $params['search'];
|
|
|
- $num = config('product_code_digit');
|
|
|
- if (!empty($search)){
|
|
|
- $sql = "SELECT DISTINCT rtrim(a.`物料代码`) AS `物料代码`,rtrim(a.`物料名称`) AS `物料名称`,rtrim(b.`客户编号`) AS `客户编号`,rtrim(b.`客户名称`) AS `客户名称` FROM
|
|
|
- `物料_存货编码` a
|
|
|
- JOIN `产品_基本资料` b ON LEFT(a.`物料代码`,$num) = LEFT(b.`客户编号`,$num)
|
|
|
- WHERE (a.`物料名称` LIKE '%{$search}%' or a.物料代码 LIKE '%{$search}%')
|
|
|
- ORDER BY a.`物料代码` ASC";
|
|
|
- }else{
|
|
|
- $sql = "SELECT DISTINCT rtrim(a.`物料代码`) as `物料代码`, rtrim(a.`物料名称`) as `物料名称`,rtrim(b.客户编号) as 客户编号,rtrim(b.客户名称) as 客户名称
|
|
|
- FROM `物料_存货编码` a
|
|
|
- JOIN `产品_基本资料` b ON LEFT(a.`物料代码`,$num) = LEFT(b.`客户编号`,$num)
|
|
|
-
|
|
|
- ORDER BY a.`物料代码` ASC";
|
|
|
- }
|
|
|
- $data = Db::query($sql);
|
|
|
- // 初始化一个关联数组,用于存储相同客户编号的数据
|
|
|
- $groupedData = [];
|
|
|
- foreach ($data as $row) {
|
|
|
- $customerCode = substr($row['物料代码'],0,$num).substr($row['客户编号'],2,2).'/'.$row['客户名称'];
|
|
|
- $materialCodePrefix = substr($row['物料代码'], 0, $num);
|
|
|
- if ($materialCodePrefix == 'Y1401' ){
|
|
|
- $materialCodePrefix = $materialCodePrefix.'/糊盒类产品(含贴码)';
|
|
|
- }else{
|
|
|
- $materialCodePrefix = $materialCodePrefix.'/直接领用产品';
|
|
|
- }
|
|
|
- // 如果关联数组中不存在该物料代码前四位的键,则创建一个空数组
|
|
|
- if (!isset($groupedData[$materialCodePrefix])) {
|
|
|
- $groupedData[$materialCodePrefix] = [];
|
|
|
- }
|
|
|
- // 如果物料代码前四位数组中不存在该客户编号的键,则创建一个空数组
|
|
|
- if (!isset($groupedData[$materialCodePrefix][$customerCode])) {
|
|
|
- $groupedData[$materialCodePrefix][$customerCode] = [];
|
|
|
- }
|
|
|
- // 去除客户编号和客户名称
|
|
|
- unset($row['客户编号']);
|
|
|
- unset($row['客户名称']);
|
|
|
- // 将当前行的数据添加到相应的物料代码前四位和客户编号的数组中
|
|
|
- $groupedData[$materialCodePrefix][$customerCode][] = $row;
|
|
|
- }
|
|
|
- $this->success('请求成功',$groupedData);
|
|
|
- }
|
|
|
- /**
|
|
|
- * 获取纸张代号及名称
|
|
|
- * @ApiMethod GET
|
|
|
- * @params string search
|
|
|
- */
|
|
|
- public function getProductZzList(){
|
|
|
+ * 获取左侧菜单产品分类列表
|
|
|
+ * 按 product_type 分组 → 分类下显示对应产品
|
|
|
+ */
|
|
|
+ public function ProductTypeMenu()
|
|
|
+ {
|
|
|
if (Request::instance()->isGet() == false){
|
|
|
$this->error('非法请求');
|
|
|
}
|
|
|
- $params = Request::instance()->get();
|
|
|
- $search = $params['search'];
|
|
|
- $num = config('product_code_digit');
|
|
|
- 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.物料代码,$num-2) = b.编号
|
|
|
- LEFT JOIN `物料_存货结构` c ON LEFT(a.物料代码,$num) = c.编号
|
|
|
- LEFT JOIN `物料_存货结构` d ON LEFT(a.物料代码,$num+2) = d.编号
|
|
|
- WHERE (a.物料名称 LIKE '%{$search}%' or a.物料代码 LIKE '%{$search}%') and
|
|
|
- (a.物料代码 LIKE 'Y00%' or a.物料代码 LIKE 'Y01%' or a.物料代码 LIKE 'Y04%' or a.物料代码 LIKE 'J03%' or a.物料代码 LIKE 'Y14%')";
|
|
|
- $data = Db::query($sql);
|
|
|
- }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.物料代码,$num-2) = b.编号
|
|
|
- LEFT JOIN `物料_存货结构` c ON LEFT(a.物料代码,$num) = c.编号
|
|
|
- LEFT JOIN `物料_存货结构` d ON LEFT(a.物料代码,$num+2) = d.编号
|
|
|
- WHERE a.物料代码 LIKE 'Y00%' or a.物料代码 LIKE 'Y01%' or a.物料代码 LIKE 'Y04%' or a.物料代码 LIKE 'J03%' or a.物料代码 LIKE 'Y14%'";
|
|
|
- $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] = [];
|
|
|
+ $params = Request::instance()->param();
|
|
|
+
|
|
|
+ // 获取所有产品
|
|
|
+ $productList = \db('产品_基本资料')->whereNull('mod_rq')
|
|
|
+ ->column('id,product_code,product_name,product_type');
|
|
|
+
|
|
|
+ $data = [];
|
|
|
+ if ($productList) {
|
|
|
+ foreach ($productList as $item) {
|
|
|
+ $type = $item['product_type'] ?: '未分类';
|
|
|
+ // 分类
|
|
|
+ $data[$type]['name'] = $type;
|
|
|
+ // 分类下的产品
|
|
|
+ $data[$type]['list'][] = [
|
|
|
+ 'id' => $item['id'],
|
|
|
+ 'product_code' => $item['product_code'],
|
|
|
+ 'product_name' => $item['product_name']
|
|
|
+ ];
|
|
|
}
|
|
|
- // Append items to the arrays
|
|
|
- $mergedArray[$oneKey][$twoKey][$thrKey][] = $item;
|
|
|
}
|
|
|
- $this->success('请求成功',$mergedArray);
|
|
|
+
|
|
|
+ // 转成索引数组返回
|
|
|
+ $result = array_values($data);
|
|
|
+
|
|
|
+ $this->success('获取成功', $result);
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
- *3.6工艺资料-获取产品工艺资料
|
|
|
- */
|
|
|
- public function getProductGyInfo(){
|
|
|
+ * 获取产品资料列表
|
|
|
+ */
|
|
|
+ public function ProductList()
|
|
|
+ {
|
|
|
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('非法请求');
|
|
|
- }
|
|
|
- $param = $this->request->param();
|
|
|
- $data = \db('erp_常用字典')->where('分类','印刷工艺')->order('编号 asc')->column('名称');
|
|
|
|
|
|
- $resultArray = [];
|
|
|
- foreach ($data as $item) {
|
|
|
- $parts = explode('_', $item);
|
|
|
- // 使用第一个部分作为一级键,第二个部分作为二级键
|
|
|
- $firstKey = $parts[0];
|
|
|
- $secondKey = $parts[1];
|
|
|
- $thirdValue = $parts[2];
|
|
|
+ $where = [];
|
|
|
|
|
|
- $resultArray[$firstKey][$secondKey][] = $thirdValue;
|
|
|
- }
|
|
|
- if (isset($param['sort'])){
|
|
|
- $result['标准工艺']['智能车间'] = $resultArray['标准工艺']['智能车间'];
|
|
|
- }else{
|
|
|
- unset($resultArray['标准工艺']['智能车间']);
|
|
|
- $result = $resultArray;
|
|
|
- }
|
|
|
- $this->success('请求成功',$result);
|
|
|
- }
|
|
|
- /**
|
|
|
- * 3.8工艺资料-新增产品工艺
|
|
|
- */
|
|
|
- public function addProductGyInfo(){
|
|
|
- if (Request::instance()->isPost() == false){
|
|
|
- $this->error('非法请求');
|
|
|
+ if (!empty($params['search'])){
|
|
|
+ $where['product_code|product_name|product_type'] = array('like','%'.$params['search'].'%');
|
|
|
}
|
|
|
- $params = Request::instance()->post();
|
|
|
- $UniqId = \db('产品_工艺资料')->order('UniqID desc')->value('UniqID');
|
|
|
- if ($UniqId < 2000000){
|
|
|
- $UniqId = 2000000;
|
|
|
- }else{
|
|
|
- $UniqId = $UniqId + 1;
|
|
|
+ $limit = $params['limit'];
|
|
|
+ if (empty($limit)){
|
|
|
+ $limit = 30;
|
|
|
}
|
|
|
- $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('新增失败');
|
|
|
+ $pages = $params['page'];
|
|
|
+ if (empty($pages)){
|
|
|
+ $pages = 1;
|
|
|
}
|
|
|
+ $list = \db('产品_基本资料')->whereNull('mod_rq')->where($where)->page($pages)->limit($limit)->order('id desc')->select();
|
|
|
+
|
|
|
+ $count = \db('产品_基本资料')->whereNull('mod_rq')->where($where)->page($pages)->limit($limit)->count();
|
|
|
+
|
|
|
+ $this->success('获取成功', ['list' => $list, 'count' => $count]);
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
- * 3.9印版资料-获取产品印版资料
|
|
|
- * @ApiMethod GET
|
|
|
- */
|
|
|
- public function getProductYbInfo(){
|
|
|
- if (Request::instance()->isGet() == false){
|
|
|
+ * 修改产品资料
|
|
|
+ */
|
|
|
+ public function ProductEdit()
|
|
|
+ {
|
|
|
+ if (!Request::instance()->isPost()) {
|
|
|
$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();
|
|
|
- if (empty($data)){
|
|
|
- $this->error('未查询到产品印版资料');
|
|
|
- }
|
|
|
- $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('rtrim(Gy0_方案) as Gy0_方案,Gy0_yjno,Gy0_gxh,rtrim(gy0_gxmc) as gy0_gxmc,rtrim(Add_gxmc) as Add_gxmc')
|
|
|
- ->order('Gy0_yjno,Gy0_gxh')->select();
|
|
|
- $list = [];
|
|
|
- foreach ($gyData as $key=>$value){
|
|
|
- $yjno = $value['Gy0_yjno'] > 10 ? $value['Gy0_yjno'] : '0'.$value['Gy0_yjno'];
|
|
|
- $gxh = $value['Gy0_gxh'] > 10 ? $value['Gy0_gxh'] : '0'.$value['Gy0_gxh'];
|
|
|
- $list[$key]['gy'] = $value['Gy0_方案'].'-->'.$yjno.'-'.$gxh.' '.$value['gy0_gxmc'];
|
|
|
- $list[$key]['gxmc'] = $value['Add_gxmc'];
|
|
|
- }
|
|
|
- $data['gy_data'] = $list;
|
|
|
- $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'];
|
|
|
- $num = config('product_code_digit');
|
|
|
- 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.物料代码,$num) = c.编号
|
|
|
- LEFT JOIN `物料_存货结构` d ON LEFT(a.物料代码,$num+2) = 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.物料代码,$num) = c.编号
|
|
|
- LEFT JOIN `物料_存货结构` d ON LEFT(a.物料代码,$num+2) = 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('新增失败');
|
|
|
- }
|
|
|
- }
|
|
|
- /**
|
|
|
- * 3.14工艺资料-获取损耗代号
|
|
|
- * @ApiMethod GET
|
|
|
- * @params code
|
|
|
- */
|
|
|
- public function getLossCode(){
|
|
|
- if (Request::instance()->isGet() == false){
|
|
|
- $this->error('非法请求');
|
|
|
- }
|
|
|
- $params = Request::instance()->get();
|
|
|
- if (empty($params) || !isset($params['code'])){
|
|
|
- $this->error('参数不能为空');
|
|
|
+
|
|
|
+ if (empty($params['id'])) {
|
|
|
+ $this->error('请选择数据');
|
|
|
}
|
|
|
|
|
|
- $code = $params['code'];
|
|
|
- $where['sys_bh|sys_mc'] = array('like','%'.$code.'%');
|
|
|
- $data = \db('dic_lzsh')
|
|
|
- ->where($where)
|
|
|
- ->field('rtrim(sys_bh) as sys_bh, rtrim(sys_mc) as sys_mc,sys_rate0,sys_rate1')
|
|
|
- ->select();
|
|
|
- $this->success('请求成功',$data);
|
|
|
+ // 禁止修改编号
|
|
|
+ unset($params['product_code']);
|
|
|
+
|
|
|
+ $result = \db('产品_基本资料')
|
|
|
+ ->where('id', $params['id'])
|
|
|
+ ->update($params);
|
|
|
+
|
|
|
+ if ($result !== false) {
|
|
|
+ $this->success('修改成功');
|
|
|
+ } else {
|
|
|
+ $this->error('修改失败');
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 产品工艺资料删除
|
|
|
- * @return void
|
|
|
- * @throws \think\Exception
|
|
|
- * @throws \think\exception\PDOException
|
|
|
+ * 删除产品资料(软删除)
|
|
|
*/
|
|
|
- public function ProcessDetailDel()
|
|
|
+ public function ProductDelete()
|
|
|
{
|
|
|
- if ($this->request->isGet() === false) {
|
|
|
- $this->error('请求错误');
|
|
|
+ if (!Request::instance()->isPost()) {
|
|
|
+ $this->error('非法请求');
|
|
|
}
|
|
|
- $param = $this->request->param();
|
|
|
- if (isset($param['UniqId']) === false) {
|
|
|
- $this->error('参数错误');
|
|
|
+
|
|
|
+ $id = input('id');
|
|
|
+ if (empty($id)) {
|
|
|
+ $this->error('请选择需要删除的数据');
|
|
|
}
|
|
|
- $printId = explode(',', $param['UniqId']);
|
|
|
- $res = \db('产品_工艺资料')->where('UniqID','in',$printId)->delete();
|
|
|
- if ($res){
|
|
|
+
|
|
|
+ $ids = explode(',', $id);
|
|
|
+
|
|
|
+ $result = \db('产品_基本资料')
|
|
|
+ ->where('id', 'in', $ids)
|
|
|
+ ->update(['mod_rq' => 1]);
|
|
|
+
|
|
|
+ if ($result !== false) {
|
|
|
$this->success('删除成功');
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
$this->error('删除失败');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 产品印件资料删除
|
|
|
- * @return void
|
|
|
- * @throws \think\Exception
|
|
|
- * @throws \think\exception\PDOException
|
|
|
+ * 获取产品工艺列表
|
|
|
*/
|
|
|
- public function PrintDetailDel()
|
|
|
+ public function ProductGyList()
|
|
|
{
|
|
|
- if ($this->request->isGet() === false){
|
|
|
- $this->error('请求错误');
|
|
|
- }
|
|
|
- $param = $this->request->param();
|
|
|
- if (isset($param['UniqId']) === false){
|
|
|
- $this->error('参数错误');
|
|
|
- }
|
|
|
- $printId = explode(',',$param['UniqId']);
|
|
|
- $res = \db('产品_印件资料')->where('UniqID','in',$printId)->delete();
|
|
|
- if ($res){
|
|
|
- $this->success('删除成功');
|
|
|
- }else{
|
|
|
- $this->error('删除失败');
|
|
|
+ if (Request::instance()->isGet() == false){
|
|
|
+ $this->error('非法请求');
|
|
|
}
|
|
|
+ $params = Request::instance()->param();
|
|
|
|
|
|
- }
|
|
|
- /**
|
|
|
- * 新增产品
|
|
|
- * @ApiMethod POST
|
|
|
- *
|
|
|
- */
|
|
|
- public function addProduct(){
|
|
|
- if (Request::instance()->isPost() == false){
|
|
|
- $this->error('非法请求');
|
|
|
- }
|
|
|
- $params = Request::instance()->post();
|
|
|
- if (empty($params)){
|
|
|
- $this->error('参数不能为空');
|
|
|
- }
|
|
|
- $uniqId = \db('产品_基本资料')->order('UniqID desc')->value('UniqID');
|
|
|
- if (empty($uniqId)){
|
|
|
- $params['UniqID'] = 1;
|
|
|
- }else{
|
|
|
- $params['UniqID'] = $uniqId + 1;
|
|
|
- }
|
|
|
- $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('新增失败');
|
|
|
- }
|
|
|
- }
|
|
|
+ $where = [];
|
|
|
|
|
|
- /**
|
|
|
- * 产品资料删除
|
|
|
- * @return void
|
|
|
- * @throws \think\exception\PDOException
|
|
|
- */
|
|
|
- public function ProductDel()
|
|
|
- {
|
|
|
- if ($this->request->isGet() === false){
|
|
|
- $this->error('请求错误');
|
|
|
+ if (!empty($params['search'])){
|
|
|
+ $where['gy_name'] = array('like','%'.$params['search'].'%');
|
|
|
}
|
|
|
- $param = $this->request->param();
|
|
|
- if (isset($param['UniqId']) === false){
|
|
|
- $this->error('参数错误');
|
|
|
+ if (!empty($params['product_code'])){
|
|
|
+ $where['product_code'] = $params['product_code'];
|
|
|
}
|
|
|
- $WorkOrderId = explode(',',$param['UniqId']);
|
|
|
- $i = 0;
|
|
|
- foreach ($WorkOrderId as $key=>$value){
|
|
|
- //获取产品编号
|
|
|
- $product = \db('产品_基本资料')
|
|
|
- ->where('UniqID',$value)
|
|
|
- ->value('rtrim(产品编号)');
|
|
|
- //删除工单资料、工艺资料、印件资料
|
|
|
- \db()->startTrans();
|
|
|
- try {
|
|
|
- \db('产品_基本资料')->where('UniqID',$value)->delete();
|
|
|
- if (!empty(\db('产品_工艺资料')->where('Gy0_cpdh',$product)->find())){
|
|
|
- \db('产品_工艺资料')->where('Gy0_cpdh',$product)->delete();
|
|
|
- }
|
|
|
- if (!empty(\db('产品_印件资料')->where('yj_cpdh',$product)->find())){
|
|
|
- \db('产品_印件资料')->where('yj_cpdh',$product)->delete();
|
|
|
- }
|
|
|
- \db()->commit();
|
|
|
- }catch (\Exception $e){
|
|
|
- \db()->rollback();
|
|
|
- $i++;
|
|
|
- }
|
|
|
+ $limit = $params['limit'];
|
|
|
+ if (empty($limit)){
|
|
|
+ $limit = 30;
|
|
|
}
|
|
|
- if ($i === 0){
|
|
|
- $this->success('删除成功');
|
|
|
- }else{
|
|
|
- $this->error('删除失败');
|
|
|
+ $pages = $params['page'];
|
|
|
+ if (empty($pages)){
|
|
|
+ $pages = 1;
|
|
|
}
|
|
|
+ $list = \db('产品_工艺资料')->whereNull('mod_rq')->where($where)->page($pages)->limit($limit)->order('id desc')->select();
|
|
|
+ $count = \db('产品_工艺资料')->whereNull('mod_rq')->where($where)->page($pages)->limit($limit)->count();
|
|
|
+
|
|
|
+ $this->success('获取成功', ['list' => $list, 'count' => $count]);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 修改产品工艺资料
|
|
|
- * @ApiMethod POST
|
|
|
- *
|
|
|
+ * 获取产品部件列表
|
|
|
*/
|
|
|
- public function productEdit(){
|
|
|
- if (Request::instance()->isPost() == false){
|
|
|
+ public function ProductPartList()
|
|
|
+ {
|
|
|
+ if (Request::instance()->isGet() == false){
|
|
|
$this->error('非法请求');
|
|
|
}
|
|
|
- $params = Request::instance()->post();
|
|
|
- if (empty($params)){
|
|
|
- $this->error('参数不能为空');
|
|
|
+ $params = Request::instance()->param();
|
|
|
+
|
|
|
+ $where = [];
|
|
|
+
|
|
|
+ if (!empty($params['search'])){
|
|
|
+ $where['part_name'] = array('like','%'.$params['search'].'%');
|
|
|
}
|
|
|
- $UniqId = $params['UniqID'];
|
|
|
- unset($params['UniqID']);
|
|
|
- $params['Mod_rq'] = date('Y-m-d H:i:s');
|
|
|
- $sql = \db('产品_工艺资料')->where('UniqID',$UniqId)->fetchSql(true)->update($params);
|
|
|
- $res = Db::query($sql);
|
|
|
- if ($res !== false){
|
|
|
- $this->success('修改成功');
|
|
|
- }else{
|
|
|
- $this->error('修改失败');
|
|
|
+ if (!empty($params['product_code'])){
|
|
|
+ $where['product_code'] = array('like','%'.$params['product_code'].'%');
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取联数
|
|
|
- * @return void
|
|
|
- * @throws \think\db\exception\DataNotFoundException
|
|
|
- * @throws \think\db\exception\ModelNotFoundException
|
|
|
- * @throws \think\exception\DbException
|
|
|
- */
|
|
|
- public function getCouplet()
|
|
|
- {
|
|
|
- if ($this->request->isGet() === false){
|
|
|
- $this->error('请求错误');
|
|
|
+ $limit = $params['limit'];
|
|
|
+ if (empty($limit)){
|
|
|
+ $limit = 30;
|
|
|
}
|
|
|
- $param = $this->request->param();
|
|
|
- if (empty($param['product']) || empty($param['yjno'])){
|
|
|
- $this->error('参数错误');
|
|
|
+ $pages = $params['page'];
|
|
|
+ if (empty($pages)){
|
|
|
+ $pages = 1;
|
|
|
}
|
|
|
- $list = \db('产品_印件资料')
|
|
|
- ->where('yj_cpdh',$param['product'])
|
|
|
- ->where('yj_yjno',$param['yjno'])
|
|
|
- ->field('rtrim(yj_ks) as 开数,rtrim(yj_ls) as 联数')
|
|
|
- ->find();
|
|
|
- $process = \db('产品_工艺资料')
|
|
|
- ->where('Gy0_cpdh',$param['product'])
|
|
|
- ->where('Gy0_yjno',$param['yjno'])
|
|
|
- ->order('Gy0_gxh desc')
|
|
|
- ->value('Gy0_gxh');
|
|
|
- $list['工序号'] = $process + 1;
|
|
|
- $this->success('成功',$list);
|
|
|
+ $list = \db('产品_部件资料')->whereNull('mod_rq')->where($where)->page($pages)->limit($limit)->order('id desc')->select();
|
|
|
+ $count = \db('产品_部件资料')->whereNull('mod_rq')->where($where)->page($pages)->limit($limit)->count();
|
|
|
+
|
|
|
+ $this->success('获取成功', ['list' => $list, 'count' => $count]);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}
|