|
|
@@ -4,6 +4,7 @@ namespace app\api\controller;
|
|
|
|
|
|
|
|
|
use app\common\controller\Api;
|
|
|
+use Monolog\Handler\IFTTTHandler;
|
|
|
use think\Db;
|
|
|
|
|
|
/**
|
|
|
@@ -26,23 +27,26 @@ class WorkOrder extends Api
|
|
|
if ($this->request->isGet() === false){
|
|
|
$this->error('请求错误');
|
|
|
}
|
|
|
- //客户列表
|
|
|
- $ClientList = Db::table('erp_客户供应商')->where('类型','客户')->column('简称','编号');
|
|
|
+ $where = [
|
|
|
+ '行号' => '1',
|
|
|
+ ];
|
|
|
+ $ClientList = Db::table('erp_客户供应商')->where('类型','客户')->cache(true)->column('简称','编号');
|
|
|
//获取总计划中数量和总生产中数量
|
|
|
- $productingAll = Db::table('工单_基本资料')->where('gd_statu','2-生产中')->count();
|
|
|
- $progressAll = Db::table('工单_基本资料')->where('gd_statu','3-计划中')->count();
|
|
|
+ $productingAll = Db::table('工单_基本资料')->where('gd_statu','2-生产中')->cache(true)->count();
|
|
|
+ $progressAll = Db::table('工单_基本资料')->where('gd_statu','3-计划中')->cache(true)->count();
|
|
|
$data = [
|
|
|
'productingAll' => $productingAll,
|
|
|
'progressAll' => $progressAll
|
|
|
];
|
|
|
//按客户编号查询生产中,计划中数量
|
|
|
foreach ($ClientList as $key=>$value){
|
|
|
- $order = Db::table('工单_基本资料')->where('Gd_客户代号',$key)->count();
|
|
|
+ $order = Db::table('工单_基本资料')->where('Gd_客户代号',$key)->cache(true)->count();
|
|
|
if ($order !== 0){
|
|
|
- $productIng = Db::table('工单_基本资料')->where('Gd_客户代号',$key)->where('gd_statu','2-生产中')->count();
|
|
|
- $proGress = Db::table('工单_基本资料')->where('Gd_客户代号',$key)->where('gd_statu','3-计划中')->count();
|
|
|
+ $productIng = Db::table('工单_基本资料')->where('Gd_客户代号',$key)->where($where)->where('gd_statu','2-生产中')->cache(true)->count();
|
|
|
+ $proGress = Db::table('工单_基本资料')->where('Gd_客户代号',$key)->where($where)->where('gd_statu','3-计划中')->cache(true)->count();
|
|
|
+ $code = Db::table('工单_基本资料')->where('Gd_客户代号',$key)->field('rtrim(成品代号) as 成品代号')->cache(true)->find();
|
|
|
$Detail = [
|
|
|
- 'Gd_khdh' => rtrim($key),
|
|
|
+ 'Gd_khdh' => substr($code['成品代号'],0,4),
|
|
|
'Gd_khmc' => rtrim($value),
|
|
|
'producting' => $productIng = 0?'':"生产中:".$productIng,
|
|
|
'progress' => $proGress=0?'':'计划中:'.$proGress,
|
|
|
@@ -75,7 +79,7 @@ class WorkOrder extends Api
|
|
|
$startTime = input('start');
|
|
|
$endTime = input('end');
|
|
|
$where = [
|
|
|
- 'Gd_khdh' => $clientNumber
|
|
|
+ '成品代号' => ['like',$clientNumber.'%']
|
|
|
];
|
|
|
if (isset($startTime) && isset($endTime)){
|
|
|
$where['接单日期'] = ['between',[$startTime,$endTime]];
|
|
|
@@ -295,4 +299,249 @@ class WorkOrder extends Api
|
|
|
$list['平张投料'] = $printData['平张投料'];
|
|
|
$this->success('成功',$list);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 工单资料修改
|
|
|
+ * @ApiMethod (POST)
|
|
|
+ * @param array $data 上传数据
|
|
|
+ * @return void
|
|
|
+ * @throws \think\Exception
|
|
|
+ * @throws \think\exception\PDOException
|
|
|
+ */
|
|
|
+
|
|
|
+ public function WorkOrderEdit()
|
|
|
+ {
|
|
|
+ if ($this->request->isPost() === false){
|
|
|
+ $this->error('请求错误');
|
|
|
+ }
|
|
|
+ $data = input('data');
|
|
|
+ if (empty($data)){
|
|
|
+ $this->error('参数错误');
|
|
|
+ }
|
|
|
+ $sql = Db::table('工单_基本资料')->where('Gd_gdbh',$data['Gd_gdbh'])->fetchSql(true)->update($data);
|
|
|
+ $res = Db::query($sql);
|
|
|
+ if ($res === 0){
|
|
|
+ $this->error('修改失败');
|
|
|
+ }
|
|
|
+ $this->success('成功');
|
|
|
+ }
|
|
|
+
|
|
|
+ //U8投料试算
|
|
|
+
|
|
|
+ public function U8Trial()
|
|
|
+ {
|
|
|
+ if ($this->request->isGet() === false)
|
|
|
+ {
|
|
|
+ $this->error('请求错误');
|
|
|
+ }
|
|
|
+ $productCode = input('productCode');
|
|
|
+ if (empty($productCode)){
|
|
|
+ $this->error('参数错误');
|
|
|
+ }
|
|
|
+// $field = 'rtrim(Gy0_cpdh) as 产品代号,rtrim(Gy0_yjno) as 印件号,rtrim(Gy0_gxh) as 工序号,rtrim(gy0_gxmc) as gxmc,rtrim(Add_gxmc) as add_gxmc,
|
|
|
+// rtrim(Gy0_Ms) as 墨色数,rtrim(Gy0_shdh) as 损耗代号,rtrim(损耗系数) as 损耗系数,rtrim(Gy0_ls) as 加工联数,'
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 引用产品资料->获取产品资料
|
|
|
+ * @ApiMethod (GET)
|
|
|
+ * @param string $workOrder 工单编号
|
|
|
+ * @return void
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ * @throws \think\exception\DbException
|
|
|
+ */
|
|
|
+
|
|
|
+ public function ProductInformation()
|
|
|
+ {
|
|
|
+ if ($this->request->isGet() === false)
|
|
|
+ {
|
|
|
+ $this->error('请求错误');
|
|
|
+ }
|
|
|
+ $workOrder = input('workOrder');
|
|
|
+ if (empty($workOrder)){
|
|
|
+ $this->error('参数错误');
|
|
|
+ }
|
|
|
+ $field = 'rtrim(Gd_gdbh) as 工单编号,rtrim(Gd_客户名称) as 客户名称,rtrim(成品代号) as 产品代号,rtrim(成品名称) as 产品名称';
|
|
|
+ $Detail = Db::table('工单_基本资料')->where('Gd_gdbh',$workOrder)->field($field)->find();
|
|
|
+ if (empty($Detail)){
|
|
|
+ $this->error('未找到工单信息');
|
|
|
+ }
|
|
|
+ $Detail['客户代号'] = substr($Detail['产品代号'],0,4);
|
|
|
+ $this->success('成功',$Detail);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 引用产品资料->复制产品工艺资料
|
|
|
+ * @ApiMethod (POST)
|
|
|
+ * @param string $oldWorkOrder 被复制工单编号
|
|
|
+ * @param string $newWorkOrder 复制工单编号
|
|
|
+ * @return void
|
|
|
+ * @throws \think\Exception
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ * @throws \think\exception\DbException
|
|
|
+ * @throws \think\exception\PDOException
|
|
|
+ */
|
|
|
+
|
|
|
+ public function ProductInformationEdit()
|
|
|
+ {
|
|
|
+ if ($this->request->isPost() === false)
|
|
|
+ {
|
|
|
+ $this->error('请求错误');
|
|
|
+ }
|
|
|
+ $oldWorkOrder = input('oldWorkOrder');
|
|
|
+ $newWorkOrder = input('newWorkOrder');
|
|
|
+ if (empty($oldWorkOrder) || empty($newWorkOrder))
|
|
|
+ {
|
|
|
+ $this->error('参数错误');
|
|
|
+ }
|
|
|
+ //获取原工单工艺资料
|
|
|
+ $oldProcessData = Db::table('工单_工艺资料')->where('Gy0_gdbh',$oldWorkOrder)->select();
|
|
|
+ $ProsessUniqId = Db::table('工单_工艺资料')->field('UniqId')->order('UniqId desc')->find();
|
|
|
+ foreach ($oldProcessData as $k=>$v){
|
|
|
+ $oldProcessData[$k]['Gy0_gdbh'] = $newWorkOrder;
|
|
|
+ $oldProcessData[$k]['Sys_id'] = '';
|
|
|
+ $oldProcessData[$k]['UniqId'] = $ProsessUniqId['UniqId'] + $k + 1;
|
|
|
+ }
|
|
|
+ if (Db::table('工单_工艺资料')->where('Gy0_gdbh',$newWorkOrder)->find()){
|
|
|
+ Db::table('工单_工艺资料')->where('Gy0_gdbh',$newWorkOrder)->delete();
|
|
|
+ }
|
|
|
+ //获取原工单印件资料
|
|
|
+ $oldPrintData = Db::table('工单_印件资料')->where('Yj_Gdbh',$oldWorkOrder)->select();
|
|
|
+ $PrintUniqId = Db::table('工单_印件资料')->field('Uniqid')->order('Uniqid desc')->find();
|
|
|
+ foreach ($oldPrintData as $k=>$v){
|
|
|
+ $oldPrintData[$k]['Yj_Gdbh'] = $newWorkOrder;
|
|
|
+ $oldPrintData[$k]['Sys_id'] = '';
|
|
|
+ $oldPrintData[$k]['Uniqid'] = $PrintUniqId['Uniqid'] +$k +1;
|
|
|
+ }
|
|
|
+ if (Db::table('工单_印件资料')->where('Yj_Gdbh',$newWorkOrder)->find()){
|
|
|
+ Db::table('工单_印件资料')->where('Yj_Gdbh',$newWorkOrder)->delete();
|
|
|
+ }
|
|
|
+ //复制印件、工艺资料
|
|
|
+ $ProcessSQL = Db::table('工单_工艺资料')->fetchSql(true)->insertAll($oldProcessData);
|
|
|
+ $ProcessRes = Db::query($ProcessSQL);
|
|
|
+ $PrintSQL = Db::table('工单_印件资料')->fetchSql(true)->insertAll($oldPrintData);
|
|
|
+ $PrintRes = Db::query($PrintSQL);
|
|
|
+ if ($ProcessRes !== false && $PrintRes !== false){
|
|
|
+ $this->success('成功');
|
|
|
+ }else{
|
|
|
+ $this->error('失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 工艺流程调成->获取当前工单工艺资料
|
|
|
+ * @ApiMethod (GET)
|
|
|
+ * @param string $workorder 当前工单编号
|
|
|
+ * @return void
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ * @throws \think\exception\DbException
|
|
|
+ */
|
|
|
+ public function ProcessFlow()
|
|
|
+ {
|
|
|
+ if ($this->request->isGet() === false){
|
|
|
+ $this->error('请求错误');
|
|
|
+ }
|
|
|
+ $workOrder = input('workOrder');
|
|
|
+ if (empty($workOrder)){
|
|
|
+ $this->error('参数错误');
|
|
|
+ }
|
|
|
+ $list = Db::table('工单_基本资料')->where('Gd_gdbh',$workOrder)->field('rtrim(成品代号) as 成品编号,rtrim(成品名称) as 成品名称')->find();
|
|
|
+ if (empty($list)){
|
|
|
+ $this->error('未找到工单信息');
|
|
|
+ }
|
|
|
+ $filed = 'rtrim(Gy0_方案) as 方案,rtrim(Gy0_yjno) as 印件号,rtrim(Gy0_gxh) as 工序号,rtrim(Gy0_gxmc) as gxmc,rtrim(Add_gxmc) as add_gxmc,
|
|
|
+ rtrim(工价系数) as 工价系数,rtrim(损耗系数) as 损耗系数,rtrim(Gy0_ks) as ks,rtrim(Gy0_ls) as ls,rtrim(工序备注) as 备注,rtrim(Gy0_SITE) as 车间,
|
|
|
+ rtrim(Gy0_sbbh) as 设备编号,rtrim(Gy0_sbmc) as 设备名称,rtrim(Sys_id) as 建档用户,rtrim(Sys_rq) as 建档时间,rtrim(Mod_rq) as 更新时间';
|
|
|
+ $process = Db::table('工单_工艺资料')->where('Gy0_gdbh',$workOrder)->field($filed)->select();
|
|
|
+ if (empty($process)){
|
|
|
+ $this->error('未找到该工单工艺资料');
|
|
|
+ }
|
|
|
+ foreach ($process as $key=>$value){
|
|
|
+ if (isset($value['add_gxmc'])){
|
|
|
+ $process[$key]['工序名称'] = $value['gxmc'] . '【'.$value['add_gxmc'].'】';
|
|
|
+ }else{
|
|
|
+ $process[$key]['工序名称'] = $value['gxmc'];
|
|
|
+ }
|
|
|
+ $process[$key]['工价系数'] = (float)$value['工价系数'];
|
|
|
+ $process[$key]['损耗系数'] = (float)$value['损耗系数'];
|
|
|
+ $process[$key]['开数*联数'] = $value['ks'].'*'.$value['ls'];
|
|
|
+ }
|
|
|
+ $list['process'] = $process;
|
|
|
+ $this->success('成功',$list);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 参照工单列表获取
|
|
|
+ * @ApiMethod (GET)
|
|
|
+ * @param string $workOrder 工单编号
|
|
|
+ * @param string $productCode 产品代号
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function ReferenceWorkOrder()
|
|
|
+ {
|
|
|
+ if ($this->request->isGet() === false){
|
|
|
+ $this->error('请求错误');
|
|
|
+ }
|
|
|
+ $productCode = input('productCode');
|
|
|
+ $workOrder = input('workOrder');
|
|
|
+ if (empty($productCode) || empty($workOrder)){
|
|
|
+ $this->error('参数错误');
|
|
|
+ }
|
|
|
+ $list = Db::table('工单_基本资料')->where('成品代号',$productCode)->where('Gd_gdbh','<>',$workOrder)->column('Gd_gdbh');
|
|
|
+ if (empty($list)){
|
|
|
+ $this->error('未获取该产品其他工单信息');
|
|
|
+ }
|
|
|
+ $this->success('成功',$list);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 工艺资料复制
|
|
|
+ * @ApiMethod (POST)
|
|
|
+ * @param string $oldWorkOrder 被复制工单编号
|
|
|
+ * @param string $newWorkOrder 复制工单编号
|
|
|
+ * @return void
|
|
|
+ * @throws \think\Exception
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ * @throws \think\exception\DbException
|
|
|
+ * @throws \think\exception\PDOException
|
|
|
+ *
|
|
|
+ */
|
|
|
+ public function ProcessCopy()
|
|
|
+ {
|
|
|
+ if ($this->request->isPost() === false){
|
|
|
+ $this->error('请求错误');
|
|
|
+ }
|
|
|
+ $oldWorkOrder = input('oldWorkOrder');
|
|
|
+ $newWorkOrder = input('newWorkOrder');
|
|
|
+ if (empty($oldWorkOrder) || empty($newWorkOrder))
|
|
|
+ {
|
|
|
+ $this->error('参数错误');
|
|
|
+ }
|
|
|
+ //获取原工单工艺资料
|
|
|
+ $oldProcessData = Db::table('工单_工艺资料')->where('Gy0_gdbh',$oldWorkOrder)->select();
|
|
|
+ $ProsessUniqId = Db::table('工单_工艺资料')->field('UniqId')->order('UniqId desc')->find();
|
|
|
+ foreach ($oldProcessData as $k=>$v){
|
|
|
+ $oldProcessData[$k]['Gy0_gdbh'] = $newWorkOrder;
|
|
|
+ $oldProcessData[$k]['Sys_id'] = '';
|
|
|
+ $oldProcessData[$k]['Mod_rq'] = date('Y-m-d H:i:s',time());
|
|
|
+ $oldProcessData[$k]['UniqId'] = $ProsessUniqId['UniqId'] + $k + 1;
|
|
|
+ }
|
|
|
+ if (Db::table('工单_工艺资料')->where('Gy0_gdbh',$newWorkOrder)->find()){
|
|
|
+ Db::table('工单_工艺资料')->where('Gy0_gdbh',$newWorkOrder)->delete();
|
|
|
+ }
|
|
|
+ //插入工艺资料
|
|
|
+ $ProcessSQL = Db::table('工单_工艺资料')->fetchSql(true)->insertAll($oldProcessData);
|
|
|
+ $ProcessRes = Db::query($ProcessSQL);
|
|
|
+ if ($ProcessRes !== false){
|
|
|
+ $this->success('成功');
|
|
|
+ }else{
|
|
|
+ $this->error('失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|