|
|
@@ -4,6 +4,7 @@ namespace app\api\controller;
|
|
|
|
|
|
use app\common\controller\Api;
|
|
|
use think\Request;
|
|
|
+use function fast\e;
|
|
|
|
|
|
/**
|
|
|
* 印版库管理
|
|
|
@@ -83,7 +84,13 @@ class PrintingPlate extends Api
|
|
|
}
|
|
|
|
|
|
|
|
|
- //存货编码列表
|
|
|
+ /**
|
|
|
+ * 存货编码列表
|
|
|
+ * @return void
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ * @throws \think\exception\DbException
|
|
|
+ */
|
|
|
public function MaterailCodeList()
|
|
|
{
|
|
|
if ($this->request->isGet() === false){
|
|
|
@@ -101,22 +108,93 @@ class PrintingPlate extends Api
|
|
|
$code = substr($param['code'], 0, 6);
|
|
|
}
|
|
|
//根据物料编码分类查询
|
|
|
-
|
|
|
+ $list = db('产品_印版库')
|
|
|
+ ->alias('a')
|
|
|
+ ->join('物料_存货编码 b', 'a.存货编码 = b.物料代码')
|
|
|
+ ->join('工单_印版领用记录 c', 'a.存货编码 = c.Yb_存货编码 AND a.供方批号 = c.Yb_供方批号', 'left')
|
|
|
+ ->where('a.存货编码', 'like', $code . '%')
|
|
|
+ ->group('a.存货编码, a.供方批号')
|
|
|
+ ->order('报废日期, a.存货编码')
|
|
|
+ ->field('
|
|
|
+ rtrim(a.存货编码) as 存货编码,
|
|
|
+ rtrim(b.物料名称) as 物料名称,
|
|
|
+ rtrim(a.印版名称) as 印版名称,
|
|
|
+ rtrim(a.供方批号) as 供方批号,
|
|
|
+ DATE(a.制造日期) as 制造日期,
|
|
|
+ CASE
|
|
|
+ WHEN a.报废日期 = "1900-01-01 00:00:00" THEN NULL
|
|
|
+ ELSE DATE(a.报废日期)
|
|
|
+ END as 报废日期,
|
|
|
+ a.原始印数,
|
|
|
+ a.考核印数,
|
|
|
+ a.UniqID,
|
|
|
+ a.Sys_id as 创建用户,
|
|
|
+ a.Sys_rq as 创建日期,
|
|
|
+ a.Mod_rq as 修改时间,
|
|
|
+ count(c.Yb_印数) as 累计印数
|
|
|
+ ')
|
|
|
+ ->select();
|
|
|
+ if (empty($list)) {
|
|
|
+ $this->error('失败');
|
|
|
+ }else{
|
|
|
+ $this->success('成功', $list);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 印版管理印版修改
|
|
|
+ * @return void
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ * @throws \think\exception\DbException
|
|
|
+ */
|
|
|
public function MaterailDetail()
|
|
|
{
|
|
|
if ($this->request->isGet() === false){
|
|
|
$this->error('请求错误');
|
|
|
}
|
|
|
$param = $this->request->param();
|
|
|
- if (empty($param) || !isset($param['code'])){
|
|
|
+ if (empty($param) || !isset($param['UniqID'])){
|
|
|
$this->error('参数错误');
|
|
|
}
|
|
|
+ $result = db('产品_印版库')
|
|
|
+ ->alias('a')
|
|
|
+ ->join('物料_存货编码 b', 'a.存货编码 = b.物料代码')
|
|
|
+ ->where('a.UniqID', $param['UniqID'])
|
|
|
+ ->order('报废日期, a.存货编码')
|
|
|
+ ->field('
|
|
|
+ rtrim(a.存货编码) as 存货编码,
|
|
|
+ rtrim(b.物料名称) as 物料名称,
|
|
|
+ rtrim(a.印版名称) as 印版备注,
|
|
|
+ rtrim(a.供方批号) as 供方批号,
|
|
|
+ DATE(a.制造日期) as 制造日期,
|
|
|
+ CASE
|
|
|
+ WHEN a.报废日期 = "1900-01-01 00:00:00" THEN NULL
|
|
|
+ ELSE DATE(a.报废日期)
|
|
|
+ END as 报废日期,
|
|
|
+ a.原始印数,
|
|
|
+ a.考核印数,
|
|
|
+ a.UniqID
|
|
|
+ ')
|
|
|
+ ->find();
|
|
|
+ if (empty($result)) {
|
|
|
+ $this->error('未找到数据');
|
|
|
+ }else{
|
|
|
+ $this->success('成功', $result);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
|
- //印版资料修改
|
|
|
+ /**
|
|
|
+ * 印版资料新增修改
|
|
|
+ * @return void
|
|
|
+ * @throws \think\Exception
|
|
|
+ * @throws \think\db\exception\BindParamException
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ * @throws \think\exception\DbException
|
|
|
+ * @throws \think\exception\PDOException
|
|
|
+ */
|
|
|
public function MaterailEdit()
|
|
|
{
|
|
|
if ($this->request->isPost() === false){
|
|
|
@@ -155,4 +233,66 @@ class PrintingPlate extends Api
|
|
|
$this->success('修改成功');
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 印版新增->存货编码获取
|
|
|
+ * @return void
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ * @throws \think\exception\DbException
|
|
|
+ */
|
|
|
+ public function getInventoryCode()
|
|
|
+ {
|
|
|
+ if (!$this->request->isGet()) {
|
|
|
+ $this->error('请求错误');
|
|
|
+ }
|
|
|
+
|
|
|
+ $param = $this->request->param();
|
|
|
+ if (empty($param) || !isset($param['code'])) {
|
|
|
+ $this->error('参数错误');
|
|
|
+ }
|
|
|
+ // 提取前缀
|
|
|
+ $codeLength = preg_match('/[a-zA-Z]/', $param['code']) ? 5 : 4;
|
|
|
+ $code = substr($param['code'], 0, $codeLength);
|
|
|
+ $where['物料代码'] = ['like', $code . '%'];
|
|
|
+
|
|
|
+ if (!empty($param['search'])) {
|
|
|
+ $where['物料名称'] = ['like', '%' . $param['search'] . '%'];
|
|
|
+ }
|
|
|
+ // 查询物料存货编码
|
|
|
+ $list = db('物料_存货编码')
|
|
|
+ ->where($where)
|
|
|
+ ->field('rtrim(物料代码) as 物料代码, rtrim(物料名称) as 物料名称, rtrim(规格) as 规格')
|
|
|
+ ->select();
|
|
|
+ // 数据处理
|
|
|
+ $data = [];
|
|
|
+ foreach ($list as $item) {
|
|
|
+ // 提取物料代码的前缀
|
|
|
+ $prefixLength = preg_match('/[a-zA-Z]/', $item['物料代码']) ? [3, 5, 7] : [2, 4, 6];
|
|
|
+
|
|
|
+ // 使用普通的数组映射替代箭头函数
|
|
|
+ $num1 = substr($item['物料代码'], 0, $prefixLength[0]);
|
|
|
+ $num2 = substr($item['物料代码'], 0, $prefixLength[1]);
|
|
|
+ $num3 = substr($item['物料代码'], 0, $prefixLength[2]);
|
|
|
+
|
|
|
+ // 批量查询物料结构名称
|
|
|
+ $names = db('物料_存货结构')
|
|
|
+ ->whereIn('编号', [$num1, $num2, $num3])
|
|
|
+ ->column('名称', '编号');
|
|
|
+
|
|
|
+ // 将数据组织进数组
|
|
|
+ $name1 = isset($names[$num1]) ? $names[$num1] : '';
|
|
|
+ $name2 = isset($names[$num2]) ? $names[$num2] : '';
|
|
|
+ $name3 = isset($names[$num3]) ? $names[$num3] : '';
|
|
|
+
|
|
|
+ if (!isset($data["$num1/$name1"][$num2][$num3.'/'.$name3])) {
|
|
|
+ $data["$num1/$name1"][$num2][$num3.'/'.$name3] = [];
|
|
|
+ }
|
|
|
+
|
|
|
+ $data["$num1/$name1"][$num2][$num3.'/'.$name3][] = "{$item['物料代码']}/{$item['物料名称']}/{$item['规格']}";
|
|
|
+ }
|
|
|
+ $this->success('成功', $data);
|
|
|
+ }
|
|
|
+
|
|
|
}
|